wme.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * hostapd / WMM (Wi-Fi Multimedia)
  3. * Copyright 2002-2003, Instant802 Networks, Inc.
  4. * Copyright 2005-2006, Devicescape Software, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Alternatively, this software may be distributed under the terms of BSD
  11. * license.
  12. *
  13. * See README and COPYING for more details.
  14. */
  15. #ifndef WME_H
  16. #define WME_H
  17. #ifdef __linux__
  18. #include <endian.h>
  19. #endif /* __linux__ */
  20. #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
  21. #include <sys/types.h>
  22. #include <sys/endian.h>
  23. #endif /* defined(__FreeBSD__) || defined(__NetBSD__) ||
  24. * defined(__DragonFly__) */
  25. #define WME_OUI_TYPE 2
  26. #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
  27. #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
  28. #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
  29. #define WME_VERSION 1
  30. #define WME_ACTION_CATEGORY 17
  31. #define WME_ACTION_CODE_SETUP_REQUEST 0
  32. #define WME_ACTION_CODE_SETUP_RESPONSE 1
  33. #define WME_ACTION_CODE_TEARDOWN 2
  34. #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
  35. #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
  36. #define WME_SETUP_RESPONSE_STATUS_REFUSED 3
  37. #define WME_TSPEC_DIRECTION_UPLINK 0
  38. #define WME_TSPEC_DIRECTION_DOWNLINK 1
  39. #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
  40. extern inline u16 tsinfo(int tag1d, int contention_based, int direction)
  41. {
  42. return (tag1d << 11) | (contention_based << 7) | (direction << 5) |
  43. (tag1d << 1);
  44. }
  45. struct wme_information_element {
  46. /* required fields for WME version 1 */
  47. u8 oui[3];
  48. u8 oui_type;
  49. u8 oui_subtype;
  50. u8 version;
  51. u8 acInfo;
  52. } __attribute__ ((packed));
  53. struct wme_ac_parameter {
  54. #if __BYTE_ORDER == __LITTLE_ENDIAN
  55. /* byte 1 */
  56. u8 aifsn:4,
  57. acm:1,
  58. aci:2,
  59. reserved:1;
  60. /* byte 2 */
  61. u8 eCWmin:4,
  62. eCWmax:4;
  63. #elif __BYTE_ORDER == __BIG_ENDIAN
  64. /* byte 1 */
  65. u8 reserved:1,
  66. aci:2,
  67. acm:1,
  68. aifsn:4;
  69. /* byte 2 */
  70. u8 eCWmax:4,
  71. eCWmin:4;
  72. #else
  73. #error "Please fix <endian.h>"
  74. #endif
  75. /* bytes 3 & 4 */
  76. le16 txopLimit;
  77. } __attribute__ ((packed));
  78. struct wme_parameter_element {
  79. /* required fields for WME version 1 */
  80. u8 oui[3];
  81. u8 oui_type;
  82. u8 oui_subtype;
  83. u8 version;
  84. u8 acInfo;
  85. u8 reserved;
  86. struct wme_ac_parameter ac[4];
  87. } __attribute__ ((packed));
  88. struct wme_tspec_info_element {
  89. u8 eid;
  90. u8 length;
  91. u8 oui[3];
  92. u8 oui_type;
  93. u8 oui_subtype;
  94. u8 version;
  95. u16 ts_info;
  96. u16 nominal_msdu_size;
  97. u16 maximum_msdu_size;
  98. u32 minimum_service_interval;
  99. u32 maximum_service_interval;
  100. u32 inactivity_interval;
  101. u32 start_time;
  102. u32 minimum_data_rate;
  103. u32 mean_data_rate;
  104. u32 maximum_burst_size;
  105. u32 minimum_phy_rate;
  106. u32 peak_data_rate;
  107. u32 delay_bound;
  108. u16 surplus_bandwidth_allowance;
  109. u16 medium_time;
  110. } __attribute__ ((packed));
  111. /* Access Categories */
  112. enum {
  113. WME_AC_BK = 1,
  114. WME_AC_BE = 0,
  115. WME_AC_VI = 2,
  116. WME_AC_VO = 3
  117. };
  118. struct ieee80211_mgmt;
  119. u8 * hostapd_eid_wme(struct hostapd_data *hapd, u8 *eid);
  120. int hostapd_eid_wme_valid(struct hostapd_data *hapd, u8 *eid, size_t len);
  121. int hostapd_wme_sta_config(struct hostapd_data *hapd, struct sta_info *sta);
  122. void hostapd_wme_action(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
  123. size_t len);
  124. #endif /* WME_H */