PageRenderTime 64ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/release/src/include/proto/wpa.h

https://gitlab.com/envieidoc/tomato
C Header | 158 lines | 110 code | 21 blank | 27 comment | 11 complexity | f5a2d3c2bebf53077c2e041e7d58abf6 MD5 | raw file
  1. /*
  2. * Fundamental types and constants relating to WPA
  3. *
  4. * Copyright 2004, Broadcom Corporation
  5. * All Rights Reserved.
  6. *
  7. * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
  8. * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
  9. * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
  10. * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
  11. *
  12. * $Id$
  13. */
  14. #ifndef _proto_wpa_h_
  15. #define _proto_wpa_h_
  16. #include <typedefs.h>
  17. #include <proto/ethernet.h>
  18. /* enable structure packing */
  19. #if defined(__GNUC__)
  20. #define PACKED __attribute__((packed))
  21. #else
  22. #pragma pack(1)
  23. #define PACKED
  24. #endif
  25. /* Reason Codes */
  26. /* 13 through 23 taken from IEEE Std 802.11i-2004 */
  27. #define DOT11_RC_INVALID_WPA_IE 13 /* Invalid info. element */
  28. #define DOT11_RC_MIC_FAILURE 14 /* Michael failure */
  29. #define DOT11_RC_4WH_TIMEOUT 15 /* 4-way handshake timeout */
  30. #define DOT11_RC_GTK_UPDATE_TIMEOUT 16 /* Group key update timeout */
  31. #define DOT11_RC_WPA_IE_MISMATCH 17 /* WPA IE in 4-way handshake differs from
  32. * (re-)assoc. request/probe response
  33. */
  34. #define DOT11_RC_INVALID_MC_CIPHER 18 /* Invalid multicast cipher */
  35. #define DOT11_RC_INVALID_UC_CIPHER 19 /* Invalid unicast cipher */
  36. #define DOT11_RC_INVALID_AKMP 20 /* Invalid authenticated key management protocol */
  37. #define DOT11_RC_BAD_WPA_VERSION 21 /* Unsupported WPA version */
  38. #define DOT11_RC_INVALID_WPA_CAP 22 /* Invalid WPA IE capabilities */
  39. #define DOT11_RC_8021X_AUTH_FAIL 23 /* 802.1X authentication failure */
  40. #define WPA2_PMKID_LEN 16
  41. /* WPA IE fixed portion */
  42. typedef struct
  43. {
  44. uint8 tag; /* TAG */
  45. uint8 length; /* TAG length */
  46. uint8 oui[3]; /* IE OUI */
  47. uint8 oui_type; /* OUI type */
  48. struct {
  49. uint8 low;
  50. uint8 high;
  51. } PACKED version; /* IE version */
  52. } PACKED wpa_ie_fixed_t;
  53. #define WPA_IE_OUITYPE_LEN 4
  54. #define WPA_IE_FIXED_LEN 8
  55. #define WPA_IE_TAG_FIXED_LEN 6
  56. #ifdef BCMWPA2
  57. typedef struct {
  58. uint8 tag; /* TAG */
  59. uint8 length; /* TAG length */
  60. struct {
  61. uint8 low;
  62. uint8 high;
  63. } PACKED version; /* IE version */
  64. } PACKED wpa_rsn_ie_fixed_t;
  65. #define WPA_RSN_IE_FIXED_LEN 4
  66. #define WPA_RSN_IE_TAG_FIXED_LEN 2
  67. typedef uint8 wpa_pmkid_t[WPA2_PMKID_LEN];
  68. #endif
  69. /* WPA suite/multicast suite */
  70. typedef struct
  71. {
  72. uint8 oui[3];
  73. uint8 type;
  74. } PACKED wpa_suite_t, wpa_suite_mcast_t;
  75. #define WPA_SUITE_LEN 4
  76. /* WPA unicast suite list/key management suite list */
  77. typedef struct
  78. {
  79. struct {
  80. uint8 low;
  81. uint8 high;
  82. } PACKED count;
  83. wpa_suite_t list[1];
  84. } PACKED wpa_suite_ucast_t, wpa_suite_auth_key_mgmt_t;
  85. #define WPA_IE_SUITE_COUNT_LEN 2
  86. #ifdef BCMWPA2
  87. typedef struct
  88. {
  89. struct {
  90. uint8 low;
  91. uint8 high;
  92. } PACKED count;
  93. wpa_pmkid_t list[1];
  94. } PACKED wpa_pmkid_list_t;
  95. #endif
  96. /* WPA cipher suites */
  97. #define WPA_CIPHER_NONE 0 /* None */
  98. #define WPA_CIPHER_WEP_40 1 /* WEP (40-bit) */
  99. #define WPA_CIPHER_TKIP 2 /* TKIP: default for WPA */
  100. #define WPA_CIPHER_AES_OCB 3 /* AES (OCB) */
  101. #define WPA_CIPHER_AES_CCM 4 /* AES (CCM) */
  102. #define WPA_CIPHER_WEP_104 5 /* WEP (104-bit) */
  103. #define IS_WPA_CIPHER(cipher) ((cipher) == WPA_CIPHER_NONE || \
  104. (cipher) == WPA_CIPHER_WEP_40 || \
  105. (cipher) == WPA_CIPHER_WEP_104 || \
  106. (cipher) == WPA_CIPHER_TKIP || \
  107. (cipher) == WPA_CIPHER_AES_OCB || \
  108. (cipher) == WPA_CIPHER_AES_CCM)
  109. /* WPA TKIP countermeasures parameters */
  110. #define WPA_TKIP_CM_DETECT 60 /* multiple MIC failure window (seconds) */
  111. #define WPA_TKIP_CM_BLOCK 60 /* countermeasures active window (seconds) */
  112. /* RSN IE defines */
  113. #define RSN_CAP_LEN 2 /* Length of RSN capabilities field (2 octets) */
  114. /* RSN Capabilities defined in 802.11i */
  115. #define RSN_CAP_PREAUTH 0x0001
  116. #define RSN_CAP_NOPAIRWISE 0x0002
  117. #define RSN_CAP_PTK_REPLAY_CNTR_MASK 0x000C
  118. #define RSN_CAP_PTK_REPLAY_CNTR_SHIFT 2
  119. #define RSN_CAP_GTK_REPLAY_CNTR_MASK 0x0030
  120. #define RSN_CAP_GTK_REPLAY_CNTR_SHIFT 4
  121. #define RSN_CAP_1_REPLAY_CNTR 0
  122. #define RSN_CAP_2_REPLAY_CNTRS 1
  123. #define RSN_CAP_4_REPLAY_CNTRS 2
  124. #define RSN_CAP_16_REPLAY_CNTRS 3
  125. /* WPA capabilities defined in 802.11i */
  126. #define WPA_CAP_4_REPLAY_CNTRS RSN_CAP_4_REPLAY_CNTRS
  127. #define WPA_CAP_16_REPLAY_CNTRS RSN_CAP_16_REPLAY_CNTRS
  128. #define WPA_CAP_REPLAY_CNTR_SHIFT RSN_CAP_PTK_REPLAY_CNTR_SHIFT
  129. #define WPA_CAP_REPLAY_CNTR_MASK RSN_CAP_PTK_REPLAY_CNTR_MASK
  130. /* WPA Specific defines */
  131. #define WPA_CAP_LEN RSN_CAP_LEN /* Length of RSN capabilities in RSN IE (2 octets) */
  132. #define WPA_CAP_WPA2_PREAUTH RSN_CAP_PREAUTH
  133. #undef PACKED
  134. #if !defined(__GNUC__)
  135. #pragma pack()
  136. #endif
  137. #endif /* _proto_wpa_h_ */