462-wpa_s-support-htmode-param.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. From b9329c5dfeed7d5c55d2117d8dfe326fc40c8fb1 Mon Sep 17 00:00:00 2001
  2. From: Antonio Quartulli <ordex@autistici.org>
  3. Date: Tue, 3 Jul 2012 00:36:24 +0200
  4. Subject: [PATCH] wpa_s: support htmode param
  5. possible values are HT20, HT40-, HT40+ and NOHT
  6. Signed-off-by: Antonio Quartulli <ordex@autistici.org>
  7. ---
  8. src/drivers/driver.h | 2 ++
  9. src/drivers/driver_nl80211.c | 16 ++++++++++
  10. wpa_supplicant/config.c | 66 +++++++++++++++++++++++++++++++++++++++
  11. wpa_supplicant/config_ssid.h | 2 ++
  12. wpa_supplicant/wpa_supplicant.c | 2 ++
  13. 5 files changed, 88 insertions(+)
  14. --- a/src/drivers/driver.h
  15. +++ b/src/drivers/driver.h
  16. @@ -608,6 +608,8 @@ struct wpa_driver_associate_params {
  17. unsigned char rates[WLAN_SUPP_RATES_MAX];
  18. int mcast_rate;
  19. + int ht_set;
  20. + unsigned int htmode;
  21. /**
  22. * bssid_hint - BSSID of a proposed AP
  23. --- a/src/drivers/driver_nl80211.c
  24. +++ b/src/drivers/driver_nl80211.c
  25. @@ -5020,6 +5020,22 @@ retry:
  26. nla_put_u32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
  27. }
  28. + if (params->ht_set) {
  29. + switch(params->htmode) {
  30. + case NL80211_CHAN_HT20:
  31. + wpa_printf(MSG_DEBUG, " * ht=HT20");
  32. + break;
  33. + case NL80211_CHAN_HT40PLUS:
  34. + wpa_printf(MSG_DEBUG, " * ht=HT40+");
  35. + break;
  36. + case NL80211_CHAN_HT40MINUS:
  37. + wpa_printf(MSG_DEBUG, " * ht=HT40-");
  38. + break;
  39. + }
  40. + nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
  41. + params->htmode);
  42. + }
  43. +
  44. ret = nl80211_set_conn_keys(params, msg);
  45. if (ret)
  46. goto fail;
  47. --- a/wpa_supplicant/config.c
  48. +++ b/wpa_supplicant/config.c
  49. @@ -1923,6 +1923,71 @@ static char * wpa_config_write_mcast_rat
  50. }
  51. #endif /* NO_CONFIG_WRITE */
  52. +static int wpa_config_parse_htmode(const struct parse_data *data,
  53. + struct wpa_ssid *ssid, int line,
  54. + const char *value)
  55. +{
  56. + int i;
  57. + static const struct {
  58. + const char *name;
  59. + unsigned int val;
  60. + } htmap[] = {
  61. + { .name = "HT20", .val = NL80211_CHAN_HT20, },
  62. + { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
  63. + { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
  64. + { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
  65. + };
  66. + ssid->ht_set = 0;;
  67. + for (i = 0; i < 4; i++) {
  68. + if (strcasecmp(htmap[i].name, value) == 0) {
  69. + ssid->htmode = htmap[i].val;
  70. + ssid->ht_set = 1;
  71. + break;
  72. + }
  73. + }
  74. +
  75. + return 0;
  76. +}
  77. +
  78. +#ifndef NO_CONFIG_WRITE
  79. +static char * wpa_config_write_htmode(const struct parse_data *data,
  80. + struct wpa_ssid *ssid)
  81. +{
  82. + char *value;
  83. + int res;
  84. +
  85. + value = os_malloc(6); /* longest: HT40+ */
  86. + if (value == NULL)
  87. + return NULL;
  88. +
  89. + switch(ssid->htmode) {
  90. + case NL80211_CHAN_HT20:
  91. + res = os_snprintf(value, 4, "HT20");
  92. + break;
  93. + case NL80211_CHAN_HT40PLUS:
  94. + res = os_snprintf(value, 5, "HT40+");
  95. + break;
  96. + case NL80211_CHAN_HT40MINUS:
  97. + res = os_snprintf(value, 5, "HT40-");
  98. + break;
  99. + case NL80211_CHAN_NO_HT:
  100. + res = os_snprintf(value, 4, "NOHT");
  101. + break;
  102. + default:
  103. + os_free(value);
  104. + return NULL;
  105. + }
  106. +
  107. + if (res < 0) {
  108. + os_free(value);
  109. + return NULL;
  110. + }
  111. +
  112. + return value;
  113. +}
  114. +#endif /* NO_CONFIG_WRITE */
  115. +
  116. +
  117. static int wpa_config_parse_rates(const struct parse_data *data,
  118. struct wpa_ssid *ssid, int line,
  119. const char *value)
  120. @@ -2218,6 +2283,7 @@ static const struct parse_data ssid_fiel
  121. { INT_RANGE(fixed_freq, 0, 1) },
  122. { FUNC(rates) },
  123. { FUNC(mcast_rate) },
  124. + { FUNC(htmode) },
  125. #ifdef CONFIG_MACSEC
  126. { INT_RANGE(macsec_policy, 0, 1) },
  127. { INT_RANGE(macsec_integ_only, 0, 1) },
  128. --- a/wpa_supplicant/config_ssid.h
  129. +++ b/wpa_supplicant/config_ssid.h
  130. @@ -723,6 +723,8 @@ struct wpa_ssid {
  131. unsigned char rates[WLAN_SUPP_RATES_MAX];
  132. double mcast_rate;
  133. + int ht_set;
  134. + unsigned int htmode;
  135. #ifdef CONFIG_MACSEC
  136. /**
  137. --- a/wpa_supplicant/wpa_supplicant.c
  138. +++ b/wpa_supplicant/wpa_supplicant.c
  139. @@ -2568,6 +2568,8 @@ static void wpas_start_assoc_cb(struct w
  140. i++;
  141. }
  142. params.mcast_rate = ssid->mcast_rate;
  143. + params.ht_set = ssid->ht_set;
  144. + params.htmode = ssid->htmode;
  145. }
  146. params.wpa_ie = wpa_ie;