示例#1
0
S32 CuOs_GetBssidList(THandle hCuWext, OS_802_11_BSSID_LIST_EX *bssidList)
{
	TCuWext* pCuWext = (TCuWext*)hCuWext;
	S32 res, NumberOfItems;

	/* allocate the scan result buffer */
	U8* buffer = os_MemoryCAlloc(IW_SCAN_MAX_DATA, sizeof(U8));
	if(buffer == NULL) {
		os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuOs_Get_BssidList - cant allocate scan result buffer\n");
		return EOALERR_CU_WEXT_ERROR_CANT_ALLOCATE;
	}

	NumberOfItems = 0;
	pCuWext->req_data.data.pointer = buffer;
	pCuWext->req_data.data.flags = 0;
	do {
		pCuWext->req_data.data.length = IW_SCAN_MAX_DATA;

		res = IPC_STA_Wext_Send(pCuWext->hIpcSta, SIOCGIWSCAN, &pCuWext->req_data, sizeof(struct iw_point));
		if(res != OK) {
			os_MemoryFree(buffer);
			return res;
		}

		/* parse the scan results */
		if(pCuWext->req_data.data.length) {
			struct iw_event     iwe;
			struct stream_descr stream;
			S32                 ret;

			/* init the event stream */
			os_memset((char *)&stream, '\0', sizeof(struct stream_descr));
			stream.current = (char *)buffer;
			stream.end = (char *)(buffer + pCuWext->req_data.data.length);

			do {
				/* Extract an event and print it */
				ret = ParsEvent_GetEvent(&stream, &iwe);
				if(ret > 0)
					NumberOfItems += CuWext_FillBssidList(&iwe, bssidList->Bssid, NumberOfItems);
			} while(ret > 0);
		}

	} while(pCuWext->req_data.data.flags);

	bssidList->NumberOfItems = NumberOfItems;

	/* free the scan result buffer */
	os_MemoryFree(buffer);

	return OK;
}
示例#2
0
static VOID IpcEvent_wext_event_wireless(IpcEvent_Child_t* pIpcEventChild, PS8 data, S32 len)
{
    struct iw_event     iwe;      
    struct stream_descr stream;                 
    S32                 ret;  
    IPC_EV_DATA*        pEvent;    
    U32                 EventId = 0;

    /* init the event stream */
    os_memset((char *)&stream, '\0', sizeof(struct stream_descr));
    stream.current = (char *)data;
    stream.end = (char *)(data + len);

    do  
    {     
        /* Extract an event and print it */   
        ret = ParsEvent_GetEvent(&stream, &iwe);     

        if(ret <= 0)   
            break;

        switch (iwe.cmd) 
        {
            case SIOCGIWAP:
                if((iwe.u.ap_addr.sa_data[0] == 0) && 
                    (iwe.u.ap_addr.sa_data[1] == 0) &&
                    (iwe.u.ap_addr.sa_data[2] == 0) &&
                    (iwe.u.ap_addr.sa_data[3] == 0) &&
                    (iwe.u.ap_addr.sa_data[4] == 0) &&
                    (iwe.u.ap_addr.sa_data[5] == 0))
                {
                    EventId=IPC_EVENT_DISASSOCIATED;
                     IpcEvent_PrintEvent(pIpcEventChild, EventId, NULL,0);
                } 
                else 
                {
#ifdef XCC_MODULE_INCLUDED
                    /* Send a signal to the udhcpc application to trigger the renew request */
                    system("killall -SIGUSR1 udhcpc"); 
#endif
                    EventId=IPC_EVENT_ASSOCIATED;
                    IpcEvent_PrintEvent(pIpcEventChild, EventId, NULL,0); 
                }
                break;
            case IWEVMICHAELMICFAILURE:
                EventId=IPC_EVENT_MEDIA_SPECIFIC;
                IpcEvent_PrintEvent(pIpcEventChild, EventId, NULL,0);    
                break;
            case IWEVCUSTOM:
                pEvent =  (IPC_EV_DATA*)iwe.u.data.pointer;
                if (pEvent)
                {
                    EventId = (U32)pEvent->EvParams.uEventType;
                    IpcEvent_PrintEvent (pIpcEventChild, EventId, pEvent->uBuffer, pEvent->uBufferSize);
                }
                break;
            case SIOCGIWSCAN:
                EventId=IPC_EVENT_SCAN_COMPLETE;
                IpcEvent_PrintEvent(pIpcEventChild, EventId, NULL,0);             
                break;
            case IWEVASSOCREQIE:
                /* NOP */
                break;
            case IWEVASSOCRESPIE:
                /* NOP */
                break;
            case IWEVPMKIDCAND:
                EventId=IPC_EVENT_MEDIA_SPECIFIC;
                IpcEvent_PrintEvent(pIpcEventChild, EventId, NULL,0);    
                break;
        }

        g_tester_send_event((U8) EventId);

    }      
    while(1);
}