INT Set_P2P_Send_Invite_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { POS_COOKIE pObj; UCHAR ConnAddr[6]; extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN]; pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; DBGPRINT(RT_DEBUG_ERROR, ("%s:: Send invite 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. */ 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))); P2pConnectPrepare(pAd, ConnAddr, P2PSTATE_INVITE_COMMAND); return TRUE; }
INT Set_P2P_ProvisionByAddr_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { POS_COOKIE pObj; UCHAR p2pindex = 0; UCHAR ConnAddr[6] = {0}; pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; if (rtstrmactohex(arg, (PSTRING) &ConnAddr[0]) == FALSE) return FALSE; DBGPRINT(RT_DEBUG_TRACE, ("%s:: DevMac = %02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__, PRINT_MAC(ConnAddr))); p2pindex = P2pGroupTabSearch(pAd, ConnAddr); if (p2pindex < pAd->P2pTable.ClientNumber) { P2pConnectPrepare(pAd, ConnAddr, P2PSTATE_PROVISION_COMMAND); } else DBGPRINT(RT_DEBUG_ERROR, ("Table Idx out of range!\n")); return TRUE; }
INT Set_P2P_Connect_Dev_Addr_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { POS_COOKIE pObj; UCHAR p2pindex; PUCHAR pAddr; UCHAR ConnAddr[6]; UINT32 i; 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. */ 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))); 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; } } if (p2pindex < pAd->P2pTable.ClientNumber) { pAddr = &pAd->P2pTable.Client[p2pindex].addr[0]; P2pConnectPrepare(pAd, pAddr, P2PSTATE_CONNECT_COMMAND); } else DBGPRINT(RT_DEBUG_ERROR, ("Table Idx out of range!\n")); return TRUE; }
INT Set_P2P_DelDevByAddr_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { POS_COOKIE pObj; UCHAR DevAddr[6] = {0}; PMAC_TABLE_ENTRY pEntry = NULL; pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; if (rtstrmactohex(arg, (PSTRING) &DevAddr[0]) == FALSE) return FALSE; DBGPRINT(RT_DEBUG_TRACE, ("%s:: DevMac = %02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__, PRINT_MAC(DevAddr))); pEntry = MacTableLookup(pAd, DevAddr); if (pEntry) { PUCHAR pOutBuffer = NULL; ULONG FrameLen = 0; USHORT Reason = REASON_NO_LONGER_VALID; HEADER_802_11 DeAuthHdr; MlmeAllocateMemory(pAd, &pOutBuffer); if (pOutBuffer) { DBGPRINT(RT_DEBUG_WARN, ("Send DEAUTH - Reason = %d frame tO %02x:%02x:%02x:%02x:%02x:%02x \n", Reason, PRINT_MAC(DevAddr))); MgtMacHeaderInit(pAd, &DeAuthHdr, SUBTYPE_DEAUTH, 0, pEntry->HdrAddr1, pEntry->HdrAddr2, pEntry->HdrAddr3); MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(HEADER_802_11), &DeAuthHdr, 2, &Reason, END_OF_ARGS); MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); MlmeFreeMemory(pAd, pOutBuffer); MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr); P2pGroupTabDelete(pAd, P2P_NOT_FOUND, DevAddr); } } return TRUE; }
INT Set_P2P_Send_Service_Discovery_Comeback_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { POS_COOKIE pObj; UCHAR p2pindex = P2P_NOT_FOUND; PUCHAR pAddr; UCHAR ConnAddr[6]; UINT32 i; extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN]; pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; DBGPRINT(RT_DEBUG_ERROR, ("%s:: Send Service Discovery to DevAddr[%s]\n", __FUNCTION__, arg)); 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, RT_P2P_DISCONNECTED); return TRUE; } 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; } } if ((p2pindex < pAd->P2pTable.ClientNumber) && (p2pindex != P2P_NOT_FOUND)) { pAddr = &pAd->P2pTable.Client[p2pindex].addr[0]; P2pConnectPrepare(pAd, pAddr, P2PSTATE_SERVICE_COMEBACK_COMMAND); } else DBGPRINT(RT_DEBUG_ERROR, ("Table Idx out of range!\n")); 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; }