/*----------------------------------------------------------------------------*/
VOID
kalIndicateStatusAndComplete(IN P_GLUE_INFO_T prGlueInfo,
			     IN WLAN_STATUS eStatus, IN PVOID pvBuf, IN UINT_32 u4BufLen)
{
	ASSERT(prGlueInfo);

	/* Indicate the protocol that the media state was changed. */
	NdisMIndicateStatus(prGlueInfo->rMiniportAdapterHandle,
			    (NDIS_STATUS) eStatus, (PVOID) pvBuf, u4BufLen);

	/* NOTE: have to indicate status complete every time you indicate status */
	NdisMIndicateStatusComplete(prGlueInfo->rMiniportAdapterHandle);

	if (eStatus == WLAN_STATUS_MEDIA_CONNECT || eStatus == WLAN_STATUS_MEDIA_DISCONNECT) {

		if (eStatus == WLAN_STATUS_MEDIA_CONNECT) {
			prGlueInfo->eParamMediaStateIndicated = PARAM_MEDIA_STATE_CONNECTED;
		} else if (eStatus == WLAN_STATUS_MEDIA_DISCONNECT) {
			prGlueInfo->eParamMediaStateIndicated = PARAM_MEDIA_STATE_DISCONNECTED;
		}

		if (wlanResetMediaStreamMode(prGlueInfo->prAdapter) == TRUE) {
			MEDIA_STREAMING_INDICATIONS_T rMediaStreamIndication;

			/* following MSDN for Media Streaming Indication */
			rMediaStreamIndication.StatusType = Ndis802_11StatusType_MediaStreamMode;
			rMediaStreamIndication.MediaStreamMode = Ndis802_11MediaStreamOff;

			NdisMIndicateStatus(prGlueInfo->rMiniportAdapterHandle,
					    (NDIS_STATUS) WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
					    (PVOID) &rMediaStreamIndication,
					    sizeof(MEDIA_STREAMING_INDICATIONS_T));
		}
	}
}				/* kalIndicateStatusAndComplete */
Exemplo n.º 2
0
u8 set_802_11_test(_adapter* padapter, NDIS_802_11_TEST *test)
{
	u8 ret=_TRUE;
	
_func_enter_;

	switch(test->Type)
	{
		case 1:
			NdisMIndicateStatus(padapter->hndis_adapter, NDIS_STATUS_MEDIA_SPECIFIC_INDICATION, (PVOID)&test->AuthenticationEvent, test->Length - 8);
			NdisMIndicateStatusComplete(padapter->hndis_adapter);
			break;

		case 2:
			NdisMIndicateStatus(padapter->hndis_adapter, NDIS_STATUS_MEDIA_SPECIFIC_INDICATION, (PVOID)&test->RssiTrigger, sizeof(NDIS_802_11_RSSI));
			NdisMIndicateStatusComplete(padapter->hndis_adapter);
			break;

		default:
			ret=_FALSE;
			break;
	}

_func_exit_;

	return ret;	
}
Exemplo n.º 3
0
VOID
	natpStatus(
		IN NDIS_HANDLE ProtocolBindingContext,
		IN NDIS_STATUS GeneralStatus,
		IN PVOID StatusBuffer,
		IN UINT StatusBufferSize
		)
{
	PFILTER_ADAPTER	pAdapt = (PFILTER_ADAPTER)ProtocolBindingContext;

	if ((pAdapt->MiniportHandle != NULL)  &&
		(pAdapt->natpDeviceState == NdisDeviceStateD0) &&
		(pAdapt->natmDeviceState == NdisDeviceStateD0))    
	{
		if ((GeneralStatus == NDIS_STATUS_MEDIA_CONNECT) || 
			(GeneralStatus == NDIS_STATUS_MEDIA_DISCONNECT))
		{

			pAdapt->LastIndicatedStatus = GeneralStatus;
		}
		NdisMIndicateStatus(pAdapt->MiniportHandle,
			GeneralStatus,
			StatusBuffer,
			StatusBufferSize);
	}else{

		if ((pAdapt->MiniportHandle != NULL) && 
			((GeneralStatus == NDIS_STATUS_MEDIA_CONNECT) || 
			(GeneralStatus == NDIS_STATUS_MEDIA_DISCONNECT)))
		{
			pAdapt->LatestUnIndicateStatus = GeneralStatus;
		}
	}
}
Exemplo n.º 4
0
void
shared_indicate_status(NDIS_HANDLE adapterhandle, NDIS_STATUS StatusCode,
	void *StatusBuffer,	ULONG StatusBufferSize)
{
#ifndef NDIS60
/*	NdisMIndicateStatus(wl->sh.adapterhandle, 
		NDIS_STATUS_MEDIA_SPECIFIC_INDICATION,
	  StatusBuffer, StatusBufferSize);
	NdisMIndicateStatusComplete(wl->sh.adapterhandle);
 */
	NdisMIndicateStatus(adapterhandle,
		NDIS_STATUS_MEDIA_SPECIFIC_INDICATION,
	  StatusBuffer, StatusBufferSize);
	NdisMIndicateStatusComplete(adapterhandle);
#else
	NDIS_STATUS_INDICATION ind;

	bzero(&ind, sizeof(NDIS_STATUS_INDICATION));

	ind.Header.Type = NDIS_OBJECT_TYPE_STATUS_INDICATION;
	ind.Header.Revision = NDIS_STATUS_INDICATION_REVISION_1;
	ind.Header.Size = sizeof(NDIS_STATUS_INDICATION);

	ind.SourceHandle = adapterhandle;
	ind.DestinationHandle = NULL;
	/* [N.B.: Jiandong says the RequestID field is not needed...] */

	ind.StatusCode = StatusCode;
	ind.StatusBuffer = StatusBuffer;
	ind.StatusBufferSize = StatusBufferSize;

	NdisMIndicateStatusEx(adapterhandle, &ind);
#endif /* NDIS60 */
}
Exemplo n.º 5
0
void
CAR6KMini::WMIDisconnectIndication()
{

	NDIS_DEBUG_PRINTF(DBG_TRACE," \r %s : \r\n", __FUNCTION__);
	
    if (m_Connected) {
	    NdisMIndicateStatus(m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, 0, 0);
	    NdisMIndicateStatusComplete(m_MiniportAdapterHandle);
    }
    
	m_Connected = false;
	m_ConnectInProgress = false;
	m_ConnectedChannel = 0;
	memset(m_PeerBSSID, 0, ETHERNET_MAC_ADDRESS_LENGTH);


	if (m_WantToBeConnected)
	{
		// We have completed disconnecting and now want to connect to a new SSID.
		// Start that process.
		SendWMIConnectCommand(&m_SSID);
	}

	NdisSetEvent (&m_SuspendEvent);
}
Exemplo n.º 6
0
void
CAR6KMini::WMIMicErrEvent(
	 A_UINT8 keyid, A_BOOL isMcast)
{
	struct ar6kAuthIndication {
		NDIS_802_11_STATUS_INDICATION         ind;
		NDIS_802_11_AUTHENTICATION_REQUEST    req;
	} ar6kAuthEvent;

	ar6kAuthEvent.ind.StatusType = Ndis802_11StatusType_Authentication;
	if (isMcast) {
		ar6kAuthEvent.req.Flags = NDIS_802_11_AUTH_REQUEST_GROUP_ERROR;
	} else {
		ar6kAuthEvent.req.Flags = NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR;
	}

	memcpy(&ar6kAuthEvent.req.Bssid[0], m_PeerBSSID, ETHERNET_MAC_ADDRESS_LENGTH);
	ar6kAuthEvent.req.Length = sizeof(NDIS_802_11_AUTHENTICATION_REQUEST);

    NdisMIndicateStatus(m_MiniportAdapterHandle,
                        NDIS_STATUS_MEDIA_SPECIFIC_INDICATION,
                        &ar6kAuthEvent, sizeof(ar6kAuthEvent));
    NdisMIndicateStatusComplete(m_MiniportAdapterHandle);

	return;
}
Exemplo n.º 7
0
void
CAR6KMini::WMIPeerEvent(A_UINT8 eventCode)
{
   if(PEER_FIRST_NODE_JOIN_EVENT == eventCode){
       m_Connected         = TRUE;
       m_ConnectInProgress = FALSE;
       NdisMIndicateStatus (m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_CONNECT, 0, 0);
       NdisMIndicateStatusComplete (m_MiniportAdapterHandle);
   }

   if(PEER_LAST_NODE_LEAVE_EVENT == eventCode){
       NdisMIndicateStatus(m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, 0, 0);
       NdisMIndicateStatusComplete(m_MiniportAdapterHandle);

   }

}
Exemplo n.º 8
0
// Check the cable connection state
void NeoCheckConnectState()
{
	if (ctx == NULL || ctx->NdisMiniport == NULL)
	{
		return;
	}

	if (keep_link == false)
	{
		if (ctx->ConnectedOld != ctx->Connected || ctx->ConnectedForce)
		{
			ctx->ConnectedForce = FALSE;
			ctx->ConnectedOld = ctx->Connected;
			if (ctx->Halting == FALSE)
			{
				NdisMIndicateStatus(ctx->NdisMiniport,
					ctx->Connected ? NDIS_STATUS_MEDIA_CONNECT : NDIS_STATUS_MEDIA_DISCONNECT,
					0, 0);
				NdisMIndicateStatusComplete(ctx->NdisMiniport);
			}
		}
	}
	else
	{
		if (ctx->ConnectedForce)
		{
			ctx->ConnectedForce = false;

			if (ctx->Halting == FALSE)
			{
				NdisMIndicateStatus(ctx->NdisMiniport,
					NDIS_STATUS_MEDIA_CONNECT,
					0, 0);
				NdisMIndicateStatusComplete(ctx->NdisMiniport);
			}
		}
	}
}
Exemplo n.º 9
0
/*
 *************************************************************************
 *  MiniportHandleInterrupt
 *************************************************************************
 *
 *
 *  This is the deferred interrupt processing routine (DPC) which is 
 *  optionally called following an interrupt serviced by MiniportISR.
 *
 */
VOID MiniportHandleInterrupt(NDIS_HANDLE MiniportAdapterContext)
{
	IrDevice *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext);

	DBGOUT(("==> MiniportHandleInterrupt(0x%x)", (UINT)MiniportAdapterContext));


	/*
	 *  If we have just started receiving a packet, 
	 *  indicate media-busy to the protocol.
	 */
	if (thisDev->mediaBusy && !thisDev->haveIndicatedMediaBusy){
		NdisMIndicateStatus(thisDev->ndisAdapterHandle, NDIS_STATUS_MEDIA_BUSY, NULL, 0);
		NdisMIndicateStatusComplete(thisDev->ndisAdapterHandle);
		thisDev->haveIndicatedMediaBusy = TRUE;
	}


	/*
	 *  Deliver all undelivered receive packets to the protocol.
	 */
	DeliverFullBuffers(thisDev);


	/*
	 *  Update the rcv queue 'first' and 'last' pointers.
	 *
	 *  We cannot use a spinlock to coordinate accesses to the rcv buffers
	 *  with the ISR, since ISR's are not allowed to acquire spinlocks.
	 *  So instead, we synchronize with the ISR using this special mechanism.
	 *  MiniportSyncHandleInterrupt will do our work for us with the IRQ
	 *  masked out in the PIC.
	 */
	NdisMSynchronizeWithInterrupt(	&thisDev->interruptObj,
									MiniportSyncHandleInterrupt,
									(PVOID)MiniportAdapterContext);


	/*
	 *  Send any pending write packets if possible. 
	 */
	if (IsCommReadyForTransmit(thisDev)){
		PortReadyForWrite(thisDev, FALSE);
	}

	DBGOUT(("<== MiniportHandleInterrupt"));
}
Exemplo n.º 10
0
 void
 CAR6KMini::addNewStation(A_UINT8 *mac,A_UINT16 aid,A_UINT8 *wpaie,A_UINT8 ielen)
 {
     A_INT8 free_slot=-1,i;

     for(i=0;i<AP_MAX_NUM_STA;i++)
     {
         if(A_MEMCMP(m_staList[i].mac,mac,6) == 0)
         {
             NDIS_DEBUG_PRINTF(ATH_LOG_TRC,"AR6K: Station Already Available");
             return ; /* Station already available cond. */
         }
         if(!((1 << i) & m_staListIndex))
         {
             free_slot = i;
             break;
         }
     }

     if(free_slot >= 0)
     {
         A_MEMCPY(m_staList[free_slot].mac,mac,6);
         A_MEMCPY(m_staList[free_slot].wpa_ie,wpaie,ielen);
         m_staList[free_slot].aid = aid;
         m_staList[free_slot].hnd_shk_completed = FALSE;
         m_staList[i].m_keyState = 0;
         m_staList[i].PTKlength = 0;
         A_MEMZERO(m_staList[i].ANonce, sizeof (m_staList[i].ANonce));
         A_MEMZERO(m_staList[i].SNonce, sizeof (m_staList[i].SNonce));
         A_MEMZERO(m_staList[i].PTK, sizeof (m_staList[i].PTK));
         m_staListIndex = m_staListIndex | (1 << free_slot);
         InitializeListHead(&m_staList[free_slot].ucastq);
         m_AP_conn_sta ++;
     }
     else
     {
         NDIS_DEBUG_PRINTF(ATH_LOG_TRC,"AR6K: Error Adding New Station");
     }

   if (m_AP_conn_sta == 1)
   {
       NdisMIndicateStatus (m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_CONNECT, 0, 0);
       NdisMIndicateStatusComplete (m_MiniportAdapterHandle);
   }

 }
Exemplo n.º 11
0
void
CAR6KMini::WMIMicErrEvent(
    A_UINT8 keyid,
    A_BOOL isMcast)
{
   if (m_networkType == AP_NETWORK)
   {
        car6k_ap_mic_event (keyid, isMcast);
        return;
   }
    struct ar6kAuthIndication {
        NDIS_802_11_STATUS_INDICATION         ind;
        NDIS_802_11_AUTHENTICATION_REQUEST    req;
    } ar6kAuthEvent;

    ar6kAuthEvent.ind.StatusType = Ndis802_11StatusType_Authentication;
    if (isMcast) {
        ar6kAuthEvent.req.Flags = NDIS_802_11_AUTH_REQUEST_GROUP_ERROR;
    } else {
        ar6kAuthEvent.req.Flags = NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR;
    }

    memcpy(&ar6kAuthEvent.req.Bssid[0], m_PeerBSSID, ETHERNET_MAC_ADDRESS_LENGTH);
    ar6kAuthEvent.req.Length = sizeof(NDIS_802_11_AUTHENTICATION_REQUEST);

    m_MicErrorCount++;

    if(m_MicErrorCount >= MAX_MIC_ERRORS)
    {
        m_CounterMeasureOn = TRUE;
        A_UNTIMEOUT (&m_CounterMeasureEnterTimer);
    }
    else
    {
        A_TIMEOUT_MS(&m_CounterMeasureEnterTimer, MIC_ERROR_TIMEOUT_MSEC, 0);
    }

    NdisMIndicateStatus(m_MiniportAdapterHandle,
                        NDIS_STATUS_MEDIA_SPECIFIC_INDICATION,
                        &ar6kAuthEvent, sizeof(ar6kAuthEvent));
    NdisMIndicateStatusComplete(m_MiniportAdapterHandle);

    return;
}
Exemplo n.º 12
0
void
CAR6KMini::WMIRssiThresholdEvent(
    A_UINT16 rssi)
{
    NDIS_802_11_RSSI rssi_level = 0;

    rssi_level = ABS_TO_RSSI (rssi);

    //
    // save the current RSSI level as rssiTriggering Event
    //
    m_rssiEvent = (A_INT16)rssi_level;

    NdisMIndicateStatus(m_MiniportAdapterHandle,
                        NDIS_STATUS_MEDIA_SPECIFIC_INDICATION,
                        &rssi_level, sizeof (NDIS_802_11_RSSI));

    NdisMIndicateStatusComplete (m_MiniportAdapterHandle);
}
Exemplo n.º 13
0
void
CAR6KMini::WMIScanIndication (void *si, ULONG len)
{
    NdisMIndicateStatus (m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_SPECIFIC_INDICATION, si, len);
    NdisMIndicateStatusComplete (m_MiniportAdapterHandle);
}
Exemplo n.º 14
0
/******************************************************************************
 *
 *  Name: wlan_compute_rssi()
 *
 *  Description: This function computes the RSSI in received packet
 *
 *  Arguments:  PMRVDRV_ADAPTER Adapter:  A pointer to wlan adapter structure
                        RxPD   pRxPDCurrent: A pointer to RxPD structure of received packet
 *    
 *  Return Value: NONE
 * 
 *  Notes:        
 *
 *****************************************************************************/
__inline 
VOID
wlan_compute_rssi(PMRVDRV_ADAPTER Adapter, PRxPD   pRxPDCurrent)
{

    DBGPRINT(DBG_RSSI|DBG_HELP ,(L"RxPD: SNR = %d, NF = %d\n", pRxPDCurrent->SNR, pRxPDCurrent->NF));
    DBGPRINT(DBG_RSSI|DBG_HELP ,(L"Before computing SNR and NF\n"));
    DBGPRINT(DBG_RSSI|DBG_HELP,(L"Adapter: SNR- avg = %d, NF-avg = %d\n", Adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, Adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE));
  
     Adapter->SNR[TYPE_RXPD][TYPE_NOAVG] = pRxPDCurrent->SNR;
     Adapter->NF[TYPE_RXPD][TYPE_NOAVG] = pRxPDCurrent->NF;
     Adapter->RxPDRate = pRxPDCurrent->RxRate;
     //Adapter->RxPDSNRAge = os_time_get();

      /* Average out the SNR from the received packet */
      Adapter->SNR[TYPE_RXPD][TYPE_AVG] =
        CAL_AVG_SNR_NF(Adapter->SNR[TYPE_RXPD][TYPE_AVG], pRxPDCurrent->SNR,Adapter->data_avg_factor);

      /* Average out the NF value */
      Adapter->NF[TYPE_RXPD][TYPE_AVG] = 
        CAL_AVG_SNR_NF(Adapter->NF[TYPE_RXPD][TYPE_AVG], pRxPDCurrent->NF, Adapter->data_avg_factor);
    
      DBGPRINT(DBG_RSSI|DBG_HELP ,(L"After computing SNR and NF\n"));
      DBGPRINT(DBG_RSSI|DBG_HELP ,(L"Adapter: SNR- avg = %d, NF-avg = %d\n", (Adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE), (Adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE)));

      Adapter->RSSI[TYPE_RXPD][TYPE_NOAVG] = 
            (SHORT)CAL_RSSI(Adapter->SNR[TYPE_RXPD][TYPE_NOAVG],
                Adapter->NF[TYPE_RXPD][TYPE_NOAVG]);

      Adapter->RSSI[TYPE_RXPD][TYPE_AVG] = 
            (SHORT)CAL_RSSI(Adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE,
                Adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE);

    
      Adapter->ulRSSITickCount=GetTickCount();

      if ((Adapter->RSSI[TYPE_RXPD][TYPE_AVG] > -10) || (Adapter->RSSI[TYPE_RXPD][TYPE_AVG] < -200))
      {
    
         if(Adapter->MediaConnectStatus == NdisMediaStateConnected)
         {
          DBGPRINT(DBG_ERROR, (L"ERROR: Incorrect RSSI Value2 - SNR = %d, NF= %d, Adapter->RSSI[TYPE_RXPD][TYPE_AVG] = %d, Adapter->LastRSSI = %d\n", 
                               pRxPDCurrent->SNR, 
                               pRxPDCurrent->NF,
                               Adapter->RSSI[TYPE_RXPD][TYPE_AVG],
                               Adapter->LastRSSI));
         }
      
      }
      else
      {           
              Adapter->LastRSSI = (LONG)Adapter->RSSI[TYPE_RXPD][TYPE_AVG];                      
      }
        
       if (Adapter->LastRSSI <= Adapter->RSSITriggerValue)
        {
          // Increment RSSITriggerCounter
          Adapter->RSSITriggerCounter++;
        }
        else
        {
          // Reset the counter if RSSI goes above the trigger level
          if (Adapter->RSSITriggerCounter !=0)
            Adapter->RSSITriggerCounter=0;
        }
      
        // If the trigger occurs many times, send indication above
      if (Adapter->RSSITriggerCounter >= MRVDRV_RSSI_INDICATION_THRESHOLD)
        {     
          // Indicate to protocol driver about RSSI status
          NdisMIndicateStatus(Adapter->MrvDrvAdapterHdl,
                NDIS_STATUS_MEDIA_SPECIFIC_INDICATION,
                &(Adapter->LastRSSI),
                sizeof(LONG));
          NdisMIndicateStatusComplete(Adapter->MrvDrvAdapterHdl);
          // Reset the counter
          Adapter->RSSITriggerCounter=0;
    
        }

}
Exemplo n.º 15
0
VOID
PtStatus(
	IN  NDIS_HANDLE			ProtocolBindingContext,
	IN  NDIS_STATUS			GeneralStatus,
	IN  PVOID				StatusBuffer,
	IN  UINT				StatusBufferSize
	)
/*++

Routine Description:

	Status handler for the lower-edge(protocol).

Arguments:

	ProtocolBindingContext	Pointer to the adapter structure
	GeneralStatus			Status code
	StatusBuffer			Status buffer
	StatusBufferSize		Size of the status buffer

Return Value:

	None

--*/
{
	PADAPT	  pAdapt = (PADAPT)ProtocolBindingContext;

	//
	// Pass up this indication only if the upper edge miniport is initialized
	// and powered on. Also ignore indications that might be sent by the lower
	// miniport when it isn't at D0.
	//
	if ((pAdapt->MiniportHandle != NULL)  &&
		(pAdapt->MPDeviceState == NdisDeviceStateD0) &&
		(pAdapt->PTDeviceState == NdisDeviceStateD0))	
	{
        if ((GeneralStatus == NDIS_STATUS_MEDIA_CONNECT) || 
            (GeneralStatus == NDIS_STATUS_MEDIA_DISCONNECT))
        {
            
            pAdapt->LastIndicatedStatus = GeneralStatus;
        }
		NdisMIndicateStatus(pAdapt->MiniportHandle,
							GeneralStatus,
							StatusBuffer,
							StatusBufferSize);
	}
    //
    // Save the last indicated media status 
    //
    else
    {
        if ((pAdapt->MiniportHandle != NULL) && 
        ((GeneralStatus == NDIS_STATUS_MEDIA_CONNECT) || 
            (GeneralStatus == NDIS_STATUS_MEDIA_DISCONNECT)))
        {
            pAdapt->LatestUnIndicateStatus = GeneralStatus;
        }
    }
    
}
Exemplo n.º 16
0
VOID
MiniportProcessSetPowerOid5(
    IN OUT PNDIS_STATUS          pNdisStatus,
    IN PADAPTER                  pAdapt,
    IN PVOID                     InformationBuffer,
    IN ULONG                     InformationBufferLength,
    OUT PULONG                   BytesRead,
    OUT PULONG                   BytesNeeded
    )
{
    
    NDIS_DEVICE_POWER_STATE NewDeviceState;

    ASSERT (InformationBuffer != NULL);

    *pNdisStatus = NDIS_STATUS_FAILURE;

    do 
    {
        //
        // Check for invalid length
        //
        if (InformationBufferLength < sizeof(NDIS_DEVICE_POWER_STATE))
        {
            *pNdisStatus = NDIS_STATUS_INVALID_LENGTH;
            break;
        }

        NewDeviceState = (*(PNDIS_DEVICE_POWER_STATE)InformationBuffer);

        //
        // Check for invalid device state
        //
        if ((pAdapt->MiniportDeviceState > NdisDeviceStateD0) && (NewDeviceState != NdisDeviceStateD0))
        {
            //
            // If the miniport is in a non-D0 state, the miniport can only receive a Set Power to D0
            //
            ASSERT (!(pAdapt->MiniportDeviceState > NdisDeviceStateD0) && (NewDeviceState != NdisDeviceStateD0));

            *pNdisStatus = NDIS_STATUS_FAILURE;
            break;
        }    

        //
        // Is the miniport transitioning from an On (D0) state to an Low Power State (>D0)
        // If so, then set the StandingBy Flag - (Block all incoming requests)
        //
        if (pAdapt->MiniportDeviceState == NdisDeviceStateD0 && NewDeviceState > NdisDeviceStateD0)
        {
            pAdapt->StandingBy = TRUE;
        }

        //
        // If the miniport is transitioning from a low power state to ON (D0), then clear the StandingBy flag
        // All incoming requests will be pended until the physical miniport turns ON.
        //
        if (pAdapt->MiniportDeviceState > NdisDeviceStateD0 &&  NewDeviceState == NdisDeviceStateD0)
        {
            pAdapt->StandingBy = FALSE;
        }
        
        //
        // Now update the state in the pAdapt structure;
        //
        pAdapt->MiniportDeviceState = NewDeviceState;
        
        *pNdisStatus = NDIS_STATUS_SUCCESS;
    

    } while (FALSE);    
        
    if (*pNdisStatus == NDIS_STATUS_SUCCESS)
    {
        //
        // The miniport resume from low power state
        // 
        if (pAdapt->StandingBy == FALSE)
        {
            //
            // If we need to indicate the media connect state
            // 
            if (pAdapt->LastIndicatedStatus != pAdapt->LatestUnIndicateStatus)
            {
               NdisMIndicateStatus(pAdapt->MiniportHandle,
                                        pAdapt->LatestUnIndicateStatus,
                                        (PVOID)NULL,
                                        0);
               NdisMIndicateStatusComplete(pAdapt->MiniportHandle);
               pAdapt->LastIndicatedStatus = pAdapt->LatestUnIndicateStatus;
            }
        }
        else
        {
            //
            // Initialize LatestUnIndicatedStatus
            //
            pAdapt->LatestUnIndicateStatus = pAdapt->LastIndicatedStatus;
        }
        *BytesRead = sizeof(NDIS_DEVICE_POWER_STATE);
        *BytesNeeded = 0;
    }
    else
    {
        *BytesRead = 0;
        *BytesNeeded = sizeof (NDIS_DEVICE_POWER_STATE);
    }

}
Exemplo n.º 17
0
VOID
NTAPI
MiniportHandleInterrupt (
    IN NDIS_HANDLE MiniportAdapterContext
    )
{
    PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext;
    ULONG txStatus;
    UCHAR command;
    PPACKET_HEADER nicHeader;
    PETH_HEADER ethHeader;
        
    NdisDprAcquireSpinLock(&adapter->Lock);
    
    NDIS_DbgPrint(MAX_TRACE, ("Interrupts pending: 0x%x\n", adapter->InterruptPending));
    
    //
    // Handle a link change
    //
    if (adapter->LinkChange)
    {
        NdisDprReleaseSpinLock(&adapter->Lock);
        NdisMIndicateStatus(adapter->MiniportAdapterHandle,
                            adapter->MediaState == NdisMediaStateConnected ?
                                NDIS_STATUS_MEDIA_CONNECT : NDIS_STATUS_MEDIA_DISCONNECT,
                            NULL,
                            0);
        NdisMIndicateStatusComplete(adapter->MiniportAdapterHandle);
        NdisDprAcquireSpinLock(&adapter->Lock);
        adapter->LinkChange = FALSE;
    }                            
    
    //
    // Handle a TX interrupt
    //
    if (adapter->InterruptPending & (R_I_TXOK | R_I_TXERR))
    {
        while (adapter->TxFull || adapter->DirtyTxDesc != adapter->CurrentTxDesc)
        {
            NdisRawReadPortUlong(adapter->IoBase + R_TXSTS0 +
                                 (adapter->DirtyTxDesc * sizeof(ULONG)), &txStatus);
            
            if (!(txStatus & (R_TXS_STATOK | R_TXS_UNDERRUN | R_TXS_ABORTED)))
            {
                //
                // Not sent yet
                //
                break;
            }
            
            NDIS_DbgPrint(MAX_TRACE, ("Transmission for desc %d complete: 0x%x\n",
                                      adapter->DirtyTxDesc, txStatus));
            
            if (txStatus & R_TXS_STATOK)
            {
                adapter->TransmitOk++;
            }
            else
            {
                adapter->TransmitError++;
            }

            adapter->DirtyTxDesc++;
            adapter->DirtyTxDesc %= TX_DESC_COUNT;
            adapter->InterruptPending &= ~(R_I_TXOK | R_I_TXERR);
            adapter->TxFull = FALSE;
        }
    }
    
    //
    // Handle a good RX interrupt
    //
    if (adapter->InterruptPending & (R_I_RXOK | R_I_RXERR))
    {
        for (;;)
        {
            NdisRawReadPortUchar(adapter->IoBase + R_CMD, &command);
            if (command & R_CMD_RXEMPTY)
            {
                //
                // The buffer is empty
                //
                adapter->InterruptPending &= ~(R_I_RXOK | R_I_RXERR);
                break;
            }
            
            adapter->ReceiveOffset %= RECEIVE_BUFFER_SIZE;
            
            NDIS_DbgPrint(MAX_TRACE, ("Looking for a packet at offset 0x%x\n",
                            adapter->ReceiveOffset));
            nicHeader = (PPACKET_HEADER)(adapter->ReceiveBuffer + adapter->ReceiveOffset);
            if (!(nicHeader->Status & RSR_ROK))
            {
                //
                // Receive failed
                //
                NDIS_DbgPrint(MIN_TRACE, ("Receive failed: 0x%x\n", nicHeader->Status));
                
                if (nicHeader->Status & RSR_FAE)
                {
                    adapter->ReceiveAlignmentError++;
                }
                else if (nicHeader->Status & RSR_CRC)
                {
                    adapter->ReceiveCrcError++;
                }
                adapter->ReceiveError++;
                
                goto NextPacket;
            }
            
            NDIS_DbgPrint(MAX_TRACE, ("Indicating %d byte packet to NDIS\n",
                           nicHeader->PacketLength - RECV_CRC_LENGTH));
   
            ethHeader = (PETH_HEADER)(nicHeader + 1);
            NdisMEthIndicateReceive(adapter->MiniportAdapterHandle,
                                    NULL,
                                    (PVOID)(ethHeader),
                                    sizeof(ETH_HEADER),
                                    (PVOID)(ethHeader + 1),
                                    nicHeader->PacketLength - sizeof(ETH_HEADER) - RECV_CRC_LENGTH,
                                    nicHeader->PacketLength - sizeof(ETH_HEADER) - RECV_CRC_LENGTH);
            adapter->ReceiveOk++;
            
        NextPacket:
            adapter->ReceiveOffset += nicHeader->PacketLength + sizeof(PACKET_HEADER);
            adapter->ReceiveOffset = (adapter->ReceiveOffset + 3) & ~3;
            NdisRawWritePortUshort(adapter->IoBase + R_CAPR, adapter->ReceiveOffset - 0x10);
            
            if (adapter->InterruptPending & (R_I_RXOVRFLW | R_I_FIFOOVR))
            {
                //
                // We can only clear these interrupts once CAPR has been reset
                //
                NdisRawWritePortUshort(adapter->IoBase + R_IS, R_I_RXOVRFLW | R_I_FIFOOVR);
                adapter->InterruptPending &= ~(R_I_RXOVRFLW | R_I_FIFOOVR);
            }
        }
        
        NdisMEthIndicateReceiveComplete(adapter->MiniportAdapterHandle);
    }
    
    NdisDprReleaseSpinLock(&adapter->Lock);
}
Exemplo n.º 18
0
void
CAR6KMini::disconnectIndicationTimeout()
{
    NdisMIndicateStatus(m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, 0, 0);
    NdisMIndicateStatusComplete(m_MiniportAdapterHandle);
}
Exemplo n.º 19
0
void
CAR6KMini::WMIDisconnectIndication(A_UINT8 reason)
{
#ifdef NO_BCAST_PROBE_IN_CONNECT
    wmi_probedSsid_cmd((struct wmi_t *)m_pWMI, 0, ANY_SSID_FLAG, 0,NULL);
#endif
    do
    {
        //
        // Ignore pyxis specific reason during IEEE Mode
        //
        if (m_Connected)
        {
            if (reason == NO_NETWORK_AVAIL)
            {
                // remove the current associated bssid node
                wmi_free_node ((wmi_t *)m_pWMI, m_PeerBSSID);

                //
                // In case any other same SSID nodes are present
                // remove it, since those nodes also not available now
                //
                IterateNodeAndRemoveSSID (&m_SSID);

                SendWMIDisconnectCommand ();
            }

            // Flush any pending NDIS packets
            FlushNdisPacketTransmitQueue();

#ifdef OS_ROAM_MANAGEMENT
        if (FALSE == m_osRoamControl)
        {
#endif
        m_RSSIlevel = 0;
        if (m_Config.hostAssistedRoaming)
        {
            A_UNTIMEOUT(&m_rssiScanTimer);
        }
            NdisMIndicateStatus(m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, 0, 0);
        NdisMIndicateStatusComplete(m_MiniportAdapterHandle);
#ifdef OS_ROAM_MANAGEMENT
        }
        else
        {
            A_UNTIMEOUT(&m_disconnectIndicationTimer);
            A_TIMEOUT_MS(&m_disconnectIndicationTimer, m_Config.discTimeout*1000, 0);
        }
#endif
        //
        // Reset Chanel and BSSID info
        //
        m_Connected         = FALSE;
        m_ChannelHint       = 0;
        m_ConnectedChannel  = 0;
        memset (m_PeerBSSID, 0, ETHERNET_MAC_ADDRESS_LENGTH);
    }

    if (m_bIsSwitchAPtoSTA)
    {
        m_bIsSwitchAPtoSTA = FALSE;
        NdisMIndicateStatus(m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, 0, 0);
        NdisMIndicateStatusComplete(m_MiniportAdapterHandle);
       //     configTargetParams();
        m_WantToBeConnected = TRUE;
    }


        {
            //
            // no need to send WMIConnect when target reply disconnect
            // reason other than DISCONNECT_CMD
            //
            if (DISCONNECT_CMD == reason)
            {
                m_ConnectInProgress = FALSE;
                if (m_WantToBeConnected)
                {
                    SendWMIConnectCommand (&m_SSID);
                }
            }
        }

    } while (FALSE);

    NdisSetEvent (&m_SuspendEvent);
}
Exemplo n.º 20
0
void
CAR6KMini::WMINeighborReportEvent(
       unsigned int numAps,
	   WMI_NEIGHBOR_INFO *info)
{
#ifdef SUPPORT_WPA2
	NDIS_802_11_PMKID_CANDIDATE_LIST *pOidList;
    PMKID_CANDIDATE                  *curCandidate;
    unsigned int                      lBuf, i;

    // Return if Authentication Mode is not WPA2 or WPA2-PSK
    if((m_AuthenticationMode != Ndis802_11AuthModeWPA2) && (m_AuthenticationMode != Ndis802_11AuthModeWPA2PSK)) {
	    return;
    }
	    
	struct ar6kPmkIdIndication {
		NDIS_802_11_STATUS_INDICATION         ind;
		NDIS_802_11_PMKID_CANDIDATE_LIST      req;
	} *pAr6kPmkIdEvent;

    /*
     * XXX the buffer to be sent up is dynamically allocated.
     * The assumption is made that it can be freed after
     * NdisMIndicateStatusComplete is called.
     * This needs to be checked.
     */

    lBuf = sizeof(*pAr6kPmkIdEvent) + (numAps - 1) * sizeof(PMKID_CANDIDATE);
    pAr6kPmkIdEvent = (struct ar6kPmkIdIndication *)A_MALLOC(lBuf);
    if (!pAr6kPmkIdEvent) {
		NDIS_DEBUG_PRINTF(DBG_ERR, "%s() malloc failed \r\n", __FUNCTION__);
        return;
    }

    A_MEMZERO(pAr6kPmkIdEvent, lBuf);

	pAr6kPmkIdEvent->ind.StatusType = (NDIS_802_11_STATUS_TYPE)Ndis802_11StatusType_PMKID_CandidateList;
	pOidList = (NDIS_802_11_PMKID_CANDIDATE_LIST *)(&pAr6kPmkIdEvent->req);

    /* Fill up the OID's candidate list */
    curCandidate = pOidList->CandidateList;

    for (i=0; i < numAps; info++, curCandidate++, i++) {
        /* Get the preauth capability of the AP */
		if (info->bssFlags & WMI_PREAUTH_CAPABLE_BSS) {
			curCandidate->Flags = NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
		} else {
			curCandidate->Flags = 0;
		}

        /* Get the Bssid */
        A_MEMCPY(&curCandidate->BSSID,
		 info->bssid,
                 sizeof(NDIS_802_11_MAC_ADDRESS));
    }

    /* Fill up the OID header */
    pOidList->Version = 1;
    pOidList->NumCandidates = numAps;

    NdisMIndicateStatus(m_MiniportAdapterHandle,
                        NDIS_STATUS_MEDIA_SPECIFIC_INDICATION,
                        pAr6kPmkIdEvent, lBuf);
    NdisMIndicateStatusComplete(m_MiniportAdapterHandle);

    /* Free the allocated buffer. Assumption described earlier */
    A_FREE(pAr6kPmkIdEvent);
#endif // SUPPORT_WPA2

	return;
}
Exemplo n.º 21
0
void
CAR6KMini::WMIConnectIndication(
	IN USHORT		Channel, 
	IN PBYTE 		PeerBSSID,
	IN USHORT		listenInterval,
	IN USHORT		beaconInterval,
	NETWORK_TYPE	networkType, 
	IN BYTE			assocReqLen, 
	IN BYTE			assocRespLen,
	IN PBYTE		assocInfo,
	IN BYTE			beaconIeLen)
	
{
	BYTE       len = 0;
	int        i = 0;
	A_STATUS wmiStatus;
	bss_t * bss;

	NDIS_DEBUG_PRINTF(1,"WMIConnectIndication Enter , %02x:%02x:%02x:%02x:%02x:%02x \r\n",
							PeerBSSID[0],PeerBSSID[1],PeerBSSID[2],PeerBSSID[3],PeerBSSID[4],PeerBSSID[5]);

	/* Set the Listen interval to appropriate value (100/1000 TUs) depending
	 * on the power mode setting. For REC Mode we always indicate 1000TUs to the
	 * AP in the conn. req. but reset it appropriately here upon conn Ind.
	 */
	if( m_80211_PowerMode == Ndis802_11PowerModeFast_PSP ) 
	{
	

		wmiStatus = wmi_listeninterval_cmd((struct wmi_t *)m_pWMI, 
			m_ListenInterval, 0);
	
		if (wmiStatus != A_OK) 
		{
			NDIS_DEBUG_PRINTF(DBG_ERR_LOG,"AR6K: ERROR - wmi_listeninterval_cmd failed = %u \r\n", wmiStatus);
		}
	}


	memcpy(m_PeerBSSID, PeerBSSID, ETHERNET_MAC_ADDRESS_LENGTH);
	m_ConnectedChannel = Channel;
	m_Connected = true;
	m_ConnectInProgress = false;
	m_AssocReqLen = assocReqLen;
	m_AssocRespLen = assocRespLen;
	m_BeaconIeLen = beaconIeLen;
	
	if (m_pAssocInfo != NULL) {
		A_FREE(m_pAssocInfo);
	}


	m_pAssocInfo = (PBYTE)malloc(m_AssocReqLen + m_AssocRespLen + m_BeaconIeLen);
	if(m_pAssocInfo == NULL ) 
	{
		NDIS_DEBUG_PRINTF(DBG_ERR, " %s() -> malloc faile!! size = %d \r\n",__FUNCTION__, m_AssocReqLen + m_AssocRespLen + m_BeaconIeLen);
		return;
	}
	else 
	{
		memcpy(m_pAssocInfo, assocInfo, m_AssocReqLen + m_AssocRespLen + m_BeaconIeLen);
	}


    // Send Command to Enable or disable Background Scan
	if (m_Config.bkScanEnable) 
	{
	    m_WMIBssFilter = ALL_BUT_BSS_FILTER;
	} 
	else 
	{
	    m_WMIBssFilter = NONE_BSS_FILTER;
    }
	
	wmi_bssfilter_cmd((struct wmi_t *)m_pWMI, m_WMIBssFilter,0);

	//Add the key here for WEP encryption with open Auth or Autoswitch.
	// For Shared Auth, the keys are plumbed before the connect cmd is issued and
	// for WPA/WPA2, the keys are plumbed when the AddKey OID comes.

	if (m_AuthenticationMode == Ndis802_11AuthModeOpen ||
		m_AuthenticationMode == Ndis802_11AuthModeAutoSwitch ) 

	{

		if (m_EncryptionStatus == Ndis802_11WEPEnabled) 
		{
			
			NDIS_DEBUG_PRINTF(DBG_TRACE, "WEP encryption  \r\n");
			
			for (i=0;i<4;i++) 
			{
				if (m_cbKey[i] != 0) 
				{
					NDIS_DEBUG_PRINTF(DBG_TRACE, "AR6K: adding WEP keys @ index %d \r\n", i);

					wmiStatus = wmi_addKey_cmd((wmi_t *)m_pWMI, (A_UINT8)m_KeyIndex[i], 	
						WEP_CRYPT, m_KeyUsage[i], (A_UINT8)m_cbKey[i], NULL, m_Key[i],
						KEY_OP_INIT_VAL,NULL,NO_SYNC_WMIFLAG);

                    if (wmiStatus != A_OK) 
					{
					    NDIS_DEBUG_PRINTF(DBG_TRACE, "AR6K: ERROR - wmi_addKey_cmd failed = %u \r\n", wmiStatus);
                    }
				}
			}
		}
	}

	// Indicate MEDIA_CONNECT to Ndis
	NdisMIndicateStatus(m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_CONNECT, 0, 0);
	NdisMIndicateStatusComplete(m_MiniportAdapterHandle);
	bss=wmi_find_node((wmi_t *)m_pWMI,m_PeerBSSID);
    if (bss != NULL) {
	    m_beaconInterval = bss->ni_cie.ie_beaconInt;
    }

	NDIS_DEBUG_PRINTF(DBG_TRACE,"%s() - Exit !! \r\n",__FUNCTION__);
	return;
}
Exemplo n.º 22
0
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//  Routine Name:   NetFlexRingStatus
//
//  Description:
//      This routine does the clean up work necessary
//      when a ring status occurs.
//
//  Input:
//      acb - Our Driver Context for this adapter or head.
//
//  Output:
//      None
//
//  Called By:
//      NetFlexHandleInterrupt
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VOID
NetFlexRingStatus(
    PACB acb
    )
{
    USHORT value;
    ULONG  RingStatus = 0;

    value = acb->acb_ssb_virtptr->SSB_Status;

    DebugPrint(1,("NF(%d): RingStatus value = %x\n",acb->anum, value));

    //
    // Determine the reason for the ring interrupt.
    //
    if (value & RING_STATUS_SIGNAL_LOSS)
    {
        RingStatus |= NDIS_RING_SIGNAL_LOSS;
        DebugPrint(1,("NF(%d): RING_STATUS_SIGNAL_LOSS\n",acb->anum));

        //
        // Have we already reported the error?
        //
        if (!acb->SentRingStatusLog &&
            ((acb->acb_lastringstatus & RING_STATUS_SIGNAL_LOSS) == 0))
        {
            // no, so send one.
            NdisWriteErrorLogEntry( acb->acb_handle,
                                    EVENT_NDIS_SIGNAL_LOSS_ERROR,
                                    3,
                                    NETFLEX_RINGSTATUS_ERROR_CODE,
                                    (ULONG) acb->acb_baseaddr,
                                    (ULONG) value
                                    );
            acb->SentRingStatusLog = TRUE;
        }
    }

    if (value & RING_STATUS_HARD_ERROR)
    {
        RingStatus |= NDIS_RING_HARD_ERROR;
        DebugPrint(1,("NF(%d): RING_STATUS_HARD_ERROR\n",acb->anum));
    }
    if (value & RING_STATUS_SOFT_ERROR)
    {
        RingStatus |= NDIS_RING_SOFT_ERROR;
        DebugPrint(1,("NF(%d): RING_STATUS_SOFT_ERROR\n",acb->anum));
    }
    if (value & RING_STATUS_XMIT_BEACON)
    {
        RingStatus |= NDIS_RING_TRANSMIT_BEACON;
        DebugPrint(1,("NF(%d): RING_STATUS_XMIT_BEACON\n",acb->anum));
    }
    if (value & RING_STATUS_LOBE_WIRE_FAULT)
    {
        RingStatus |= NDIS_RING_LOBE_WIRE_FAULT;
        DebugPrint(1,("NF(%d): RING_STATUS_LOBE_WIRE_FAULT\n",acb->anum));
        //
        // Have we already reported the error?
        //
        if (!acb->SentRingStatusLog &&
            ((acb->acb_lastringstatus & NDIS_RING_LOBE_WIRE_FAULT) == 0))
        {
            // no, so send one.
            NdisWriteErrorLogEntry( acb->acb_handle,
                                    EVENT_NDIS_LOBE_FAILUE_ERROR,
                                    3,
                                    NETFLEX_RINGSTATUS_ERROR_CODE,
                                    (ULONG) acb->acb_baseaddr,
                                    (ULONG) value
                                    );

            acb->SentRingStatusLog = TRUE;
        }
    }

    if (value & (RING_STATUS_AUTO_REMOVE_1 | RING_STATUS_REMOVE_RECEIVED))
    {
        if (value & RING_STATUS_AUTO_REMOVE_1)
        {
            RingStatus |= NDIS_RING_AUTO_REMOVAL_ERROR;
            DebugPrint(1,("NF(%d): RING_STATUS_AUTO_REMOVE_1\n",acb->anum));
        }
        if (value & RING_STATUS_REMOVE_RECEIVED)
        {
            RingStatus |= NDIS_RING_REMOVE_RECEIVED;
            DebugPrint(1,("NF(%d): RING_STATUS_REMOVE_RECEIVED\n",acb->anum));
        }
        //
        // Have we already reported the error?
        //
        if ((acb->acb_lastringstatus &
                (RING_STATUS_AUTO_REMOVE_1 | RING_STATUS_REMOVE_RECEIVED )) == 0)
        {
            // no, so send one.
            NdisWriteErrorLogEntry( acb->acb_handle,
                                    EVENT_NDIS_REMOVE_RECEIVED_ERROR,
                                    3,
                                    NETFLEX_RINGSTATUS_ERROR_CODE,
                                    (ULONG) acb->acb_baseaddr,
                                    (ULONG) value
                                    );
        }
    }

    if (value & RING_STATUS_OVERFLOW)
    {
         RingStatus |= NDIS_RING_COUNTER_OVERFLOW;
         DebugPrint(1,("NF(%d): RING_STATUS_OVERFLOW\n",acb->anum));
    }

    if (value & RING_STATUS_SINGLESTATION)
    {
        RingStatus |= NDIS_RING_SINGLE_STATION;
        DebugPrint(1,("NF(%d): RING_STATUS_SINGLESTATION\n",acb->anum));
    }

    if (value & RING_STATUS_RINGRECOVERY)
    {
        RingStatus |= NDIS_RING_RING_RECOVERY;
        DebugPrint(1,("NF(%d): RING_STATUS_RINGRECOVERY\n",acb->anum));
    }

    //
    // Save the Ring Status
    //
    acb->acb_lastringstatus = RingStatus;


    //
    // Indicate to the filter the ring status.
    //
    NdisMIndicateStatus(
        acb->acb_handle,
        NDIS_STATUS_RING_STATUS,
        &RingStatus,
        sizeof(ULONG)
        );

    //
    // Tell the filter that we have completed the ring status.
    //
    NdisMIndicateStatusComplete(acb->acb_handle);
}
Exemplo n.º 23
0
VOID
MPProcessSetPowerOid(
    IN OUT PNDIS_STATUS          pNdisStatus,
    IN PADAPT                    pAdapt,
    IN PVOID                     InformationBuffer,
    IN ULONG                     InformationBufferLength,
    OUT PULONG                   BytesRead,
    OUT PULONG                   BytesNeeded
    )
/*++

Routine Description:
    This routine does all the procssing for a request with a SetPower Oid
    The miniport shoud accept  the Set Power and transition to the new state

    The Set Power should not be passed to the miniport below

    If the IM miniport is going into a low power state, then there is no guarantee if it will ever
    be asked go back to D0, before getting halted. No requests should be pended or queued.

    
Arguments:
    pNdisStatus           - Status of the operation
    pAdapt                - The Adapter structure
    InformationBuffer     - The New DeviceState
    InformationBufferLength
    BytesRead             - No of bytes read
    BytesNeeded           -  No of bytes needed


Return Value:
    Status  - NDIS_STATUS_SUCCESS if all the wait events succeed.

--*/
{

    
    NDIS_DEVICE_POWER_STATE NewDeviceState;

    DBGPRINT(("==>MPProcessSetPowerOid: Adapt %p\n", pAdapt)); 

    ASSERT (InformationBuffer != NULL);

    *pNdisStatus = NDIS_STATUS_FAILURE;

    do 
    {
        //
        // Check for invalid length
        //
        if (InformationBufferLength < sizeof(NDIS_DEVICE_POWER_STATE))
        {
            *pNdisStatus = NDIS_STATUS_INVALID_LENGTH;
            break;
        }

        NewDeviceState = (*(PNDIS_DEVICE_POWER_STATE)InformationBuffer);

        //
        // Check for invalid device state
        //
        if ((pAdapt->MPDeviceState > NdisDeviceStateD0) && (NewDeviceState != NdisDeviceStateD0))
        {
            //
            // If the miniport is in a non-D0 state, the miniport can only receive a Set Power to D0
            //
            ASSERT (!(pAdapt->MPDeviceState > NdisDeviceStateD0) && (NewDeviceState != NdisDeviceStateD0));

            *pNdisStatus = NDIS_STATUS_FAILURE;
            break;
        }    

        //
        // Is the miniport transitioning from an On (D0) state to an Low Power State (>D0)
        // If so, then set the StandingBy Flag - (Block all incoming requests)
        //
        if (pAdapt->MPDeviceState == NdisDeviceStateD0 && NewDeviceState > NdisDeviceStateD0)
        {
            pAdapt->StandingBy = TRUE;
        }

        //
        // If the miniport is transitioning from a low power state to ON (D0), then clear the StandingBy flag
        // All incoming requests will be pended until the physical miniport turns ON.
        //
        if (pAdapt->MPDeviceState > NdisDeviceStateD0 &&  NewDeviceState == NdisDeviceStateD0)
        {
            pAdapt->StandingBy = FALSE;
        }
        
        //
        // Now update the state in the pAdapt structure;
        //
        pAdapt->MPDeviceState = NewDeviceState;
        
        *pNdisStatus = NDIS_STATUS_SUCCESS;
    

    } while (FALSE);    
        
    if (*pNdisStatus == NDIS_STATUS_SUCCESS)
    {
        //
        // The miniport resume from low power state
        // 
        if (pAdapt->StandingBy == FALSE)
        {
            //
            // If we need to indicate the media connect state
            // 
            if (pAdapt->LastIndicatedStatus != pAdapt->LatestUnIndicateStatus)
            {
               NdisMIndicateStatus(pAdapt->MiniportHandle,
                                        pAdapt->LatestUnIndicateStatus,
                                        (PVOID)NULL,
                                        0);
               NdisMIndicateStatusComplete(pAdapt->MiniportHandle);
               pAdapt->LastIndicatedStatus = pAdapt->LatestUnIndicateStatus;
            }
        }
        else
        {
            //
            // Initialize LatestUnIndicatedStatus
            //
            pAdapt->LatestUnIndicateStatus = pAdapt->LastIndicatedStatus;
        }
        *BytesRead = sizeof(NDIS_DEVICE_POWER_STATE);
        *BytesNeeded = 0;
    }
    else
    {
        *BytesRead = 0;
        *BytesNeeded = sizeof (NDIS_DEVICE_POWER_STATE);
    }

    DBGPRINT(("<==MPProcessSetPowerOid: Adapt %p\n", pAdapt)); 
}
Exemplo n.º 24
0
void
CAR6KMini::WMIConnectIndication(
    IN USHORT Channel,
    IN PBYTE  PeerBSSID,
    IN USHORT listenInterval,
    IN BYTE   assocReqLen,
    IN BYTE   assocRespLen,
    IN PBYTE  assocInfo,
    IN BYTE   beaconIeLen,
    IN USHORT beaconInterval,
    NETWORK_TYPE networkType)
{
    BYTE        len = 0;
    int         i = 0;
    PBYTE       pAssocReq;
    PBYTE       pAssocReqEnd;
    PBYTE       pBeaconIE;
    BYTE        byKeyType = 0;
#ifdef OS_ROAM_MANAGEMENT
    A_UNTIMEOUT(&m_disconnectIndicationTimer);
#endif
#ifdef NO_BCAST_PROBE_IN_CONNECT
    wmi_probedSsid_cmd((struct wmi_t *)m_pWMI, 0, ANY_SSID_FLAG, 0,NULL);
#endif


    memcpy(m_PeerBSSID, PeerBSSID, ETHERNET_MAC_ADDRESS_LENGTH);
    m_ConnectedChannel      = Channel;
    m_ConnectInProgress     = FALSE;
    m_AssocReqLen           = assocReqLen;
    m_AssocRespLen          = assocRespLen;
    m_BeaconIeLen           = beaconIeLen;
    m_BeaconInterval        = beaconInterval;
    m_WantToBeConnected     = FALSE;

    if (m_pAssocInfo != NULL) {
        A_FREE(m_pAssocInfo);
    }

    m_pAssocInfo = (PBYTE)A_MALLOC(m_AssocReqLen + m_AssocRespLen + m_BeaconIeLen);

    if (m_pAssocInfo)
    {
        memcpy(m_pAssocInfo, assocInfo, m_AssocReqLen + m_AssocRespLen + m_BeaconIeLen);

        //Get network type in use
        if (m_ConnectedChannel >= 2412 && m_ConnectedChannel <= 2484) {
            PBYTE pAssocRsp = m_pAssocInfo + m_BeaconIeLen + m_AssocReqLen;
            PBYTE pAssocRspEnd = pAssocRsp + m_AssocRespLen;

            m_NetworkTypeInUse = Ndis802_11DS;

            //Skip capability, status code and assoc. ID
            pAssocRsp += 6;
            if ((pAssocRsp + 2) < pAssocRspEnd && IEEE80211_ELEMID_RATES == pAssocRsp[0]) {
                pAssocRsp += (pAssocRsp[1] + 2);
                if ((pAssocRsp + 2) < pAssocRspEnd && IEEE80211_ELEMID_XRATES == pAssocRsp[0]) {
                    m_NetworkTypeInUse = Ndis802_11OFDM24;
                }
            }
        }
        else {
            m_NetworkTypeInUse = Ndis802_11OFDM5;
        }

        // Update the group wise crypto type from the ie info
    #define RSN_MULTICAST_CIPHER_OFFSET 7
    #define WPA_MULTICAST_CIPHER_OFFSET 11
        pBeaconIE = m_pAssocInfo;
        if (m_BeaconIeLen) {
            if ((m_AuthenticationMode == Ndis802_11AuthModeWPA2) ||
                (m_AuthenticationMode == Ndis802_11AuthModeWPA2PSK))
            {
                if (m_BeaconIeLen <= RSN_MULTICAST_CIPHER_OFFSET) {
                    // Default to AES if cipher suite not present
                    m_GrpwiseCryptoType = AES_CRYPT;
                } else {
                    byKeyType = *(pBeaconIE + RSN_MULTICAST_CIPHER_OFFSET);
                    switch (byKeyType)
                    {
                        case RSN_CSE_WEP40:
                        case RSN_CSE_WEP104:
                            m_GrpwiseCryptoType = WEP_CRYPT;
                            break;
                        case RSN_CSE_TKIP:
                            m_GrpwiseCryptoType = TKIP_CRYPT;
                            break;
                        case RSN_CSE_CCMP:
                            m_GrpwiseCryptoType = AES_CRYPT;
                            break;
                    }
                }
            } else
                if ((m_AuthenticationMode == Ndis802_11AuthModeWPA) ||
                    (m_AuthenticationMode == Ndis802_11AuthModeWPAPSK))
            {
                if (m_BeaconIeLen <= WPA_MULTICAST_CIPHER_OFFSET) {
                    // Default to TKIP if cipher suite not present
                    m_GrpwiseCryptoType = TKIP_CRYPT;
                } else {
                    byKeyType = *(pBeaconIE + WPA_MULTICAST_CIPHER_OFFSET);
                    switch (byKeyType)
                    {
                        case WPA_CSE_WEP40:
                        case WPA_CSE_WEP104:
                            m_GrpwiseCryptoType = WEP_CRYPT;
                            break;
                        case WPA_CSE_TKIP:
                            m_GrpwiseCryptoType = TKIP_CRYPT;
                            break;
                        case WPA_CSE_CCMP:
                            m_GrpwiseCryptoType = AES_CRYPT;
                            break;
                    }
                }
            }
        }

        // Get supported basic rates
        pAssocReq = m_pAssocInfo + m_BeaconIeLen;
        pAssocReqEnd = pAssocReq + m_AssocReqLen;

        // skip capability and listen interval
        pAssocReq += 4;

        if (((pAssocReq + 2) < pAssocReqEnd) &&
            (IEEE80211_ELEMID_SSID == pAssocReq[0]))
        {
            // Skip SSID
            pAssocReq += (pAssocReq[1] + 2);
            if ((pAssocReq + 2) < pAssocReqEnd &&
                IEEE80211_ELEMID_RATES == pAssocReq[0] &&
                (pAssocReq + pAssocReq[1] + 2) <= pAssocReqEnd)
            {
                // Get rates
                memset (m_pSupportedRates, 0, sizeof(NDIS_802_11_RATES));
                memcpy(m_pSupportedRates, &pAssocReq[2],
                      (pAssocReq[1] < sizeof(NDIS_802_11_RATES)) ? pAssocReq[1] : sizeof(NDIS_802_11_RATES));
            }
        }

    }

#ifdef OS_ROAM_MANAGEMENT
    m_RateInfo.TxDataFrames = 0;
    m_RateInfo.RxDataFrames = 0;
#endif

    // Indicate MEDIA_CONNECT to Ndis

    ConnectIndicationPostProc ();
    if (networkType == INFRA_NETWORK){
        m_Connected         = TRUE;
        m_ConnectInProgress = FALSE;
        NdisMIndicateStatus (m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_CONNECT, 0, 0);
        NdisMIndicateStatusComplete (m_MiniportAdapterHandle);
    }else{
        m_Connected = FALSE;
    }
    m_RSSIlevel = 0;
    if (m_Config.hostAssistedRoaming)
    {
        A_UNTIMEOUT(&m_rssiScanTimer);
        A_TIMEOUT_MS(&m_rssiScanTimer, 1000, 0);
    }

    return;
}