802_11.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:8k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. #ifndef IEEE_802_11
  2. #define IEEE_802_11  
  3. #include <linux/types.h>
  4. enum ieee_802_11_link_status_failure_reason {
  5. reserved0, Unspecified=1, Previous_not_valid, 
  6. Sender_Quits_ESS_or_IBSS,
  7. Due_Inactivity, AP_Overload, 
  8. Class_2_from_NonAuth,
  9. Class_3_from_NonAuth,
  10. Sender_Quits_BSS,
  11. Association_requester_not_authenticated,
  12. Reserved10 
  13. };
  14. #define IEEE_802_11_LINK_STATUS_FAILURE_REASON_STRINGS 
  15. {
  16.         {reserved0, 0xff," Reserved reason "},
  17.         {Unspecified, 0xff," Unspecified Reason "},
  18.         {Previous_not_valid, 0xff," Previous Authentication no longer valid "},
  19.         {Sender_Quits_ESS_or_IBSS,0xff," Deauthenticated because sending station is leaving (has left) IBSS or ESS "},
  20.         {Due_Inactivity, 0xff," Disassociated due to inactivity "},
  21.         {AP_Overload, 0xff," Disassociated because AP is unable to handle all currently associated stations "},
  22.         {Class_2_from_NonAuth, 0xff," Class 2 frame received from non-Authenticated station"},
  23.         {Class_3_from_NonAuth, 0xff," Class 3 frame received from non瑼ssociated station"},
  24.         {Sender_Quits_BSS, 0xff," Disassociated because sending station is leaving (has left) BSS"},
  25.         {Association_requester_not_authenticated,0xff," Station requesting (Re)Association is not Authenticated with responding station"},
  26.         {Reserved10, 0xff," Reserved"},
  27. {0,0,NULL}
  28. };
  29. struct ieee_802_11_header {
  30. u16 frame_control;// needs to be subtyped
  31. u16 duration;
  32. u8 mac1[6];
  33. u8 mac2[6];
  34. u8 mac3[6];
  35. u16 SeqCtl;
  36. u8 mac4[6];
  37. u16 gapLen;
  38. u8 gap[8];
  39. };
  40. struct ieee_802_3_header {
  41. u16 status;
  42. u16 payload_length;
  43. u8 dst_mac[6];
  44. u8 src_mac[6];
  45. };
  46. #define P80211_OUI_LEN 3
  47. struct ieee_802_11_snap_header { 
  48. u8    dsap;   /* always 0xAA */
  49. u8    ssap;   /* always 0xAA */
  50. u8    ctrl;   /* always 0x03 */
  51. u8    oui[P80211_OUI_LEN];    /* organizational universal id */
  52. } __attribute__ ((packed));
  53. #define P80211_LLC_OUI_LEN 3
  54. struct ieee_802_11_802_1H_header {
  55. u8    dsap;   
  56. u8    ssap;   /* always 0xAA */
  57. u8    ctrl;   /* always 0x03 */
  58. u8    oui[P80211_OUI_LEN];    /* organizational universal id */
  59. u16    unknown1;      /* packet type ID fields */
  60. u16    unknown2; /* here is something like length in some cases */
  61. } __attribute__ ((packed));
  62. struct ieee_802_11_802_2_header {
  63. u8    dsap;   
  64. u8    ssap;   /* always 0xAA */
  65. u8    ctrl;   /* always 0x03 */
  66. u8    oui[P80211_OUI_LEN];    /* organizational universal id */
  67. u8    type;      /* packet type ID field. i guess,  */
  68. } __attribute__ ((packed));
  69. // following is incoplete and may be incorrect and need reorganization
  70. #define ieee_802_11_frame_type_Management 0x00
  71. #define ieee_802_11_frame_type_Control 0x01
  72. #define ieee_802_11_frame_type_Data 0x10
  73. #define ieee_802_11_frame_type_Reserved 0x11
  74. #define ieee_802_11_frame_subtype_Association_Req 0x0 // Association Request
  75. #define ieee_802_11_frame_subtype_Association_Resp 0x1 // Association Response
  76. #define ieee_802_11_frame_subtype_Reassociation_Req 0x2 // Reassociation Request
  77. #define ieee_802_11_frame_subtype_Reassociation_Resp 0x3 // Reassociation Response
  78. #define ieee_802_11_frame_subtype_Probe_Req 0x4 // Probe Request
  79. #define ieee_802_11_frame_subtype_Probe_Resp 0x5 // Probe Response
  80. #define ieee_802_11_frame_subtype_Beacon  0x8 // Beacon
  81. #define ieee_802_11_frame_subtype_ATIM  0x9 // ATIM
  82. #define ieee_802_11_frame_subtype_Disassociation  0xA // Disassociation
  83. #define ieee_802_11_frame_subtype_Authentication  0xB // Authentication
  84. #define ieee_802_11_frame_subtype_Deauthentication  0xC // Deauthentication
  85. #define ieee_802_11_frame_subtype_PS_Poll  0xA // PS-Poll
  86. #define ieee_802_11_frame_subtype_RTS  0xB // RTS
  87. #define ieee_802_11_frame_subtype_CTS  0xC // CTS
  88. #define ieee_802_11_frame_subtype_ACK  0xD // ACK
  89. #define ieee_802_11_frame_subtype_CFEnd  0xE // CF-End
  90. #define ieee_802_11_frame_subtype_CFEnd_CFAck  0xF // CF-End + CF-Ack
  91. #define ieee_802_11_frame_subtype_Data  0x0 // Data
  92. #define ieee_802_11_frame_subtype_Data_CFAck  0x1 // Data + CF-Ack
  93. #define ieee_802_11_frame_subtype_Data_CF_Poll  0x2 // Data + CF-Poll
  94. #define ieee_802_11_frame_subtype_Data_CF_AckCF_Poll  0x3 // Data + CF-Ack + CF-Poll
  95. #define ieee_802_11_frame_subtype_NullFunction  0x4 // Null Function (no data)
  96. #define ieee_802_11_frame_subtype_CF_Ack  0x5 // CF-Ack (no data)
  97. #define ieee_802_11_frame_subtype_CF_Poll  0x6 // CF-Poll (no data)
  98. #define ieee_802_11_frame_subtype_CF_AckCF_Poll  0x7 // CF-Ack + CF-Poll (no data)
  99. #define ieee_802_11_frame_subtype_strings {
  100. { ieee_802_11_frame_subtype_Association_Req, 0xF,"f  Association Request"},
  101. { ieee_802_11_frame_subtype_Association_Resp, 0xF,"1  Association Response"},
  102. { ieee_802_11_frame_subtype_Reassociation_Req, 0xF,"2  Reassociation Request"},
  103. { ieee_802_11_frame_subtype_Reassociation_Resp, 0xF,"3  Reassociation Response"},
  104. { ieee_802_11_frame_subtype_Probe_Req , 0xF,"4  Probe Request"},
  105. { ieee_802_11_frame_subtype_Probe_Resp , 0xF,"5  Probe Response"},
  106. { ieee_802_11_frame_subtype_Beacon  , 0xF,"8  Beacon"},
  107. { ieee_802_11_frame_subtype_ATIM  , 0xF,"9  ATIM"},
  108. { ieee_802_11_frame_subtype_Disassociation, 0xF,"A  Disassociation"},
  109. { ieee_802_11_frame_subtype_Authentication, 0xF,"B  Authentication"},
  110. { ieee_802_11_frame_subtype_Deauthentication, 0xF,"C  Deauthentication"},
  111. { ieee_802_11_frame_subtype_PS_Poll  , 0xF,"A  PS-Poll"},
  112. { ieee_802_11_frame_subtype_RTS  , 0xF,"B  RTS"},
  113. { ieee_802_11_frame_subtype_CTS  , 0xF,"C  CTS"},
  114. { ieee_802_11_frame_subtype_ACK  , 0xF,"D  ACK"},
  115. { ieee_802_11_frame_subtype_CFEnd , 0xF,"E  CF-End"},
  116. { ieee_802_11_frame_subtype_CFEnd_CFAck , 0xF,"F  CF-End + CF-Ack"},
  117. { ieee_802_11_frame_subtype_Data  , 0xF,"0  Data"},
  118. { ieee_802_11_frame_subtype_Data_CFAck  , 0xF,"1  Data + CF-Ack"},
  119. { ieee_802_11_frame_subtype_Data_CFPoll , 0xF,"2  Data + CF-Poll"},
  120. { ieee_802_11_frame_subtype_Data_CFAck_CFPoll, 0xF,"3  Data + CF-Ack + CF-Poll"},
  121. { ieee_802_11_frame_subtype_Null_Function , 0xF,"4  Null Function (no data)"},
  122. { ieee_802_11_frame_subtype_CFAck , 0xF,"5  CF-Ack (no data)"},
  123. { ieee_802_11_frame_subtype_CFPoll , 0xF,"6  CF-Poll (no data)"},
  124. { ieee_802_11_frame_subtype_CFAck_CFPoll, 0xF,"y7  CF-Ack + CF-Poll (no data)"},
  125. { 0,0,NULL}
  126. }
  127. struct ieee_802_11_frame_subtype_class {
  128. u8 subtype;
  129. u8 mask;
  130. u8 class;
  131. u8 type;
  132. };
  133. #define ieee_802_11_frame_subtype_classes {
  134. { ieee_802_11_frame_subtype_Association_Req, 0xF,2,ieee_802_11_frame_type_Management},
  135. { ieee_802_11_frame_subtype_Association_Resp, 0xF,2,ieee_802_11_frame_type_Management},
  136. { ieee_802_11_frame_subtype_Reassociation_Req, 0xF,2,ieee_802_11_frame_type_Management},
  137. { ieee_802_11_frame_subtype_Reassociation_Resp, 0xF,2,ieee_802_11_frame_type_Management},
  138. { ieee_802_11_frame_subtype_Probe_Req , 0xF,1,ieee_802_11_frame_type_Management},
  139. { ieee_802_11_frame_subtype_Probe_Resp , 0xF,1,ieee_802_11_frame_type_Management},
  140. { ieee_802_11_frame_subtype_Beacon  , 0xF,1,ieee_802_11_frame_type_Management},
  141. { ieee_802_11_frame_subtype_ATIM  , 0xF,1,ieee_802_11_frame_type_Management},
  142. { ieee_802_11_frame_subtype_Disassociation, 0xF,2,ieee_802_11_frame_type_Management},
  143. { ieee_802_11_frame_subtype_Authentication, 0xF,1,ieee_802_11_frame_type_Management},
  144. { ieee_802_11_frame_subtype_Deauthentication, 0xF,3,ieee_802_11_frame_type_Management},
  145. { ieee_802_11_frame_subtype_PS-Poll  , 0xF,3,ieee_802_11_frame_type_Control},
  146. { ieee_802_11_frame_subtype_RTS  , 0xF,1,ieee_802_11_frame_type_Control},
  147. { ieee_802_11_frame_subtype_CTS  , 0xF,1,ieee_802_11_frame_type_Control},
  148. { ieee_802_11_frame_subtype_ACK  , 0xF,1,ieee_802_11_frame_type_Control},
  149. { ieee_802_11_frame_subtype_CFEnd , 0xF,1,ieee_802_11_frame_type_Control},
  150. { ieee_802_11_frame_subtype_CFEnd_CFAck , 0xF,1,ieee_802_11_frame_type_Control},
  151. { ieee_802_11_frame_subtype_Data  , 0xF,3,ieee_802_11_frame_type_Data},
  152. { ieee_802_11_frame_subtype_Data_CFAck  , 0xF,3,ieee_802_11_frame_type_Data},
  153. { ieee_802_11_frame_subtype_Data_CF_Poll  0xF,3,ieee_802_11_frame_type_Data},
  154. { ieee_802_11_frame_subtype_Data_CF_AckCF_Poll, 0xF,3,ieee_802_11_frame_type_Data},
  155. { ieee_802_11_frame_subtype_NullFunction  0xF,1,ieee_802_11_frame_type_Data},
  156. { ieee_802_11_frame_subtype_CF_Ack , 0xF,1,ieee_802_11_frame_type_Data},
  157. { ieee_802_11_frame_subtype_CF_Poll , 0xF,1,ieee_802_11_frame_type_Data},
  158. { ieee_802_11_frame_subtype_CF_AckCF_Poll, 0xF,1,ieee_802_11_frame_type_Data},
  159. { 0,0,NULL}
  160. }
  161. #endif