IEEE11h.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 1996, 2005 VIA Networking Technologies, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. *
  20. * File: IEEE11h.c
  21. *
  22. * Purpose:
  23. *
  24. * Functions:
  25. *
  26. * Revision History:
  27. *
  28. * Author: Yiching Chen
  29. *
  30. * Date: Mar. 31, 2005
  31. *
  32. */
  33. #include "ttype.h"
  34. #include "tmacro.h"
  35. #include "tether.h"
  36. #include "IEEE11h.h"
  37. #include "device.h"
  38. #include "wmgr.h"
  39. #include "rxtx.h"
  40. #include "channel.h"
  41. /*--------------------- Static Definitions -------------------------*/
  42. #pragma pack(1)
  43. typedef struct _WLAN_FRAME_ACTION {
  44. WLAN_80211HDR_A3 Header;
  45. unsigned char byCategory;
  46. unsigned char byAction;
  47. unsigned char abyVars[1];
  48. } WLAN_FRAME_ACTION, *PWLAN_FRAME_ACTION;
  49. typedef struct _WLAN_FRAME_MSRREQ {
  50. WLAN_80211HDR_A3 Header;
  51. unsigned char byCategory;
  52. unsigned char byAction;
  53. unsigned char byDialogToken;
  54. WLAN_IE_MEASURE_REQ sMSRReqEIDs[1];
  55. } WLAN_FRAME_MSRREQ, *PWLAN_FRAME_MSRREQ;
  56. typedef struct _WLAN_FRAME_MSRREP {
  57. WLAN_80211HDR_A3 Header;
  58. unsigned char byCategory;
  59. unsigned char byAction;
  60. unsigned char byDialogToken;
  61. WLAN_IE_MEASURE_REP sMSRRepEIDs[1];
  62. } WLAN_FRAME_MSRREP, *PWLAN_FRAME_MSRREP;
  63. typedef struct _WLAN_FRAME_TPCREQ {
  64. WLAN_80211HDR_A3 Header;
  65. unsigned char byCategory;
  66. unsigned char byAction;
  67. unsigned char byDialogToken;
  68. WLAN_IE_TPC_REQ sTPCReqEIDs;
  69. } WLAN_FRAME_TPCREQ, *PWLAN_FRAME_TPCREQ;
  70. typedef struct _WLAN_FRAME_TPCREP {
  71. WLAN_80211HDR_A3 Header;
  72. unsigned char byCategory;
  73. unsigned char byAction;
  74. unsigned char byDialogToken;
  75. WLAN_IE_TPC_REP sTPCRepEIDs;
  76. } WLAN_FRAME_TPCREP, *PWLAN_FRAME_TPCREP;
  77. #pragma pack()
  78. /* action field reference ieee 802.11h Table 20e */
  79. #define ACTION_MSRREQ 0
  80. #define ACTION_MSRREP 1
  81. #define ACTION_TPCREQ 2
  82. #define ACTION_TPCREP 3
  83. #define ACTION_CHSW 4
  84. /*--------------------- Static Classes ----------------------------*/
  85. /*--------------------- Static Variables --------------------------*/
  86. /*--------------------- Static Functions --------------------------*/
  87. /*--------------------- Export Variables --------------------------*/
  88. /*--------------------- Export Functions --------------------------*/
  89. bool IEEE11hbMSRRepTx(void *pMgmtHandle)
  90. {
  91. PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle;
  92. PWLAN_FRAME_MSRREP pMSRRep = (PWLAN_FRAME_MSRREP)
  93. (pMgmt->abyCurrentMSRRep + sizeof(STxMgmtPacket));
  94. size_t uLength = 0;
  95. PSTxMgmtPacket pTxPacket = NULL;
  96. pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep;
  97. memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN);
  98. pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket +
  99. sizeof(STxMgmtPacket));
  100. pMSRRep->Header.wFrameCtl = (WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) |
  101. WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION)
  102. );
  103. memcpy(pMSRRep->Header.abyAddr1, ((PWLAN_FRAME_MSRREQ)
  104. (pMgmt->abyCurrentMSRReq))->Header.abyAddr2, WLAN_ADDR_LEN);
  105. memcpy(pMSRRep->Header.abyAddr2,
  106. CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN);
  107. memcpy(pMSRRep->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
  108. pMSRRep->byCategory = 0;
  109. pMSRRep->byAction = 1;
  110. pMSRRep->byDialogToken = ((PWLAN_FRAME_MSRREQ)
  111. (pMgmt->abyCurrentMSRReq))->byDialogToken;
  112. uLength = pMgmt->uLengthOfRepEIDs + offsetof(WLAN_FRAME_MSRREP,
  113. sMSRRepEIDs);
  114. pTxPacket->cbMPDULen = uLength;
  115. pTxPacket->cbPayloadLen = uLength - WLAN_HDR_ADDR3_LEN;
  116. if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING)
  117. return false;
  118. return true;
  119. }