INT Set_P2P_Scan( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { POS_COOKIE pObj; int bScan; bScan = simple_strtol(arg, 0, 10); pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; if (bScan) { pAd->StaCfg.bAutoReconnect = FALSE; P2pScan(pAd); } else { pAd->StaCfg.bAutoReconnect = TRUE; P2pStopScan(pAd); } return TRUE; }
INT Set_P2P_Scan( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { POS_COOKIE pObj; int ScanType; PRT_P2P_CONFIG pP2PCtrl = &pAd->P2pCfg; ScanType = simple_strtol(arg, 0, 10); pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; switch(ScanType) { case P2P_STOP_SCAN: /* Stop scan and stop to response peer P2P scanning */ #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT pAd->StaCfg.bAutoReconnect = FALSE; #else pAd->StaCfg.bAutoReconnect = TRUE; #endif /* NATIVE_WPA_SUPPLICANT_SUPPORT */ pP2PCtrl->bSentProbeRSP = FALSE; P2pStopScan(pAd); break; case P2P_SCANNING: /* Do P2P scanning */ pAd->StaCfg.bAutoReconnect = FALSE; pP2PCtrl->bSentProbeRSP = TRUE; P2pGroupTabInit(pAd); P2pScan(pAd); break; case P2P_STOP_SCAN_AND_LISTEN: /* Stop scan and lock at Listen Channel to response peer P2P scanning */ pAd->P2pCfg.bSentProbeRSP = TRUE; P2pStopScan(pAd); break; default: DBGPRINT(RT_DEBUG_ERROR, ("Incorrect scan type:%d\n", ScanType)); } return TRUE; }
INT Set_P2P_Provision_Dev_Addr_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { POS_COOKIE pObj; UCHAR p2pindex = P2P_NOT_FOUND; PUCHAR pAddr; UCHAR ConnAddr[6]; UINT32 i; UINT16 retry_cnt = 0; extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN]; extern UCHAR BROADCAST_ADDR[MAC_ADDR_LEN]; pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; DBGPRINT(RT_DEBUG_ERROR, ("%s:: Connect to DevAddr[%s]\n", __FUNCTION__, arg)); /* If the input is the zero mac address, it means use our default(from EEPROM) MAC address as out-going MAC address. If the input is the broadcast MAC address, it means use the source MAC of first packet forwarded by our device as the out-going MAC address. If the input is any other specific valid MAC address, use it as the out-going MAC address. */ if( pAd->P2pTable.ClientNumber == 0) { DBGPRINT( RT_DEBUG_ERROR, ("P2P Table is Empty! Scan First!\n")); P2pScan(pAd); OS_WAIT(2000); } NdisMoveMemory(&ConnAddr[0], &ZERO_MAC_ADDR[0], MAC_ADDR_LEN); if (rtstrmactohex(arg, (PSTRING) &ConnAddr[0]) == FALSE) return FALSE; DBGPRINT(RT_DEBUG_ERROR, ("%s:: DevMac = %02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__, PRINT_MAC(ConnAddr))); if (MAC_ADDR_EQUAL(ConnAddr, ZERO_MAC_ADDR)) { P2pLinkDown(pAd, P2P_CONNECT_FAIL); return TRUE; } retry: for (i=0; i < pAd->P2pTable.ClientNumber; i++) { if (MAC_ADDR_EQUAL(pAd->P2pTable.Client[i].addr, ConnAddr) || MAC_ADDR_EQUAL(pAd->P2pTable.Client[i].bssid, ConnAddr) || MAC_ADDR_EQUAL(pAd->P2pTable.Client[i].InterfaceAddr, ConnAddr)) { p2pindex = i; break; } } DBGPRINT(RT_DEBUG_TRACE,("pAd->P2pTable.ClientNumber = %d, p2pindex = %d\n", pAd->P2pTable.ClientNumber, p2pindex)); if ((p2pindex < pAd->P2pTable.ClientNumber) && (p2pindex != P2P_NOT_FOUND)) { pAddr = &pAd->P2pTable.Client[p2pindex].addr[0]; P2pConnectPrepare(pAd, pAddr, P2PSTATE_PROVISION_COMMAND); } else { retry_cnt ++; if ( retry_cnt < 5 ) { OS_WAIT(2000); goto retry; } DBGPRINT(RT_DEBUG_ERROR, ("Table Idx out of range!\n")); #ifdef RT_P2P_SPECIFIC_WIRELESS_EVENT P2pSendWirelessEvent(pAd, RT_P2P_CONNECT_FAIL, NULL, NULL); #endif /* RT_P2P_SPECIFIC_WIRELESS_EVENT */ } return TRUE; }