1
0

460-wpa_supplicant-add-new-config-params-to-be-used-with.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. From 4bb69d15477e0f2b00e166845341dc933de47c58 Mon Sep 17 00:00:00 2001
  2. From: Antonio Quartulli <ordex@autistici.org>
  3. Date: Sun, 3 Jun 2012 18:22:56 +0200
  4. Subject: [PATCHv2 601/602] wpa_supplicant: add new config params to be used
  5. with the ibss join command
  6. Signed-hostap: Antonio Quartulli <ordex@autistici.org>
  7. ---
  8. src/drivers/driver.h | 6 +++
  9. wpa_supplicant/config.c | 96 +++++++++++++++++++++++++++++++++++++++
  10. wpa_supplicant/config_ssid.h | 6 +++
  11. wpa_supplicant/wpa_supplicant.c | 23 +++++++---
  12. 4 files changed, 124 insertions(+), 7 deletions(-)
  13. --- a/src/drivers/driver.h
  14. +++ b/src/drivers/driver.h
  15. @@ -19,6 +19,7 @@
  16. #define WPA_SUPPLICANT_DRIVER_VERSION 4
  17. +#include "ap/sta_info.h"
  18. #include "common/defs.h"
  19. #include "common/ieee802_11_defs.h"
  20. #ifdef CONFIG_MACSEC
  21. @@ -605,6 +606,9 @@ struct wpa_driver_associate_params {
  22. * responsible for selecting with which BSS to associate. */
  23. const u8 *bssid;
  24. + unsigned char rates[WLAN_SUPP_RATES_MAX];
  25. + int mcast_rate;
  26. +
  27. /**
  28. * bssid_hint - BSSID of a proposed AP
  29. *
  30. --- a/wpa_supplicant/config.c
  31. +++ b/wpa_supplicant/config.c
  32. @@ -16,6 +16,7 @@
  33. #include "eap_peer/eap.h"
  34. #include "p2p/p2p.h"
  35. #include "fst/fst.h"
  36. +#include "ap/sta_info.h"
  37. #include "config.h"
  38. @@ -1891,6 +1892,97 @@ static char * wpa_config_write_mka_ckn(c
  39. #endif /* CONFIG_MACSEC */
  40. +static int wpa_config_parse_mcast_rate(const struct parse_data *data,
  41. + struct wpa_ssid *ssid, int line,
  42. + const char *value)
  43. +{
  44. + ssid->mcast_rate = (int)(strtod(value, NULL) * 10);
  45. +
  46. + return 0;
  47. +}
  48. +
  49. +#ifndef NO_CONFIG_WRITE
  50. +static char * wpa_config_write_mcast_rate(const struct parse_data *data,
  51. + struct wpa_ssid *ssid)
  52. +{
  53. + char *value;
  54. + int res;
  55. +
  56. + if (!ssid->mcast_rate == 0)
  57. + return NULL;
  58. +
  59. + value = os_malloc(6); /* longest: 300.0 */
  60. + if (value == NULL)
  61. + return NULL;
  62. + res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10);
  63. + if (res < 0) {
  64. + os_free(value);
  65. + return NULL;
  66. + }
  67. + return value;
  68. +}
  69. +#endif /* NO_CONFIG_WRITE */
  70. +
  71. +static int wpa_config_parse_rates(const struct parse_data *data,
  72. + struct wpa_ssid *ssid, int line,
  73. + const char *value)
  74. +{
  75. + int i;
  76. + char *pos, *r, *sptr, *end;
  77. + double rate;
  78. +
  79. + pos = (char *)value;
  80. + r = strtok_r(pos, ",", &sptr);
  81. + i = 0;
  82. + while (pos && i < WLAN_SUPP_RATES_MAX) {
  83. + rate = 0.0;
  84. + if (r)
  85. + rate = strtod(r, &end);
  86. + ssid->rates[i] = rate * 2;
  87. + if (*end != '\0' || rate * 2 != ssid->rates[i])
  88. + return 1;
  89. +
  90. + i++;
  91. + r = strtok_r(NULL, ",", &sptr);
  92. + }
  93. +
  94. + return 0;
  95. +}
  96. +
  97. +#ifndef NO_CONFIG_WRITE
  98. +static char * wpa_config_write_rates(const struct parse_data *data,
  99. + struct wpa_ssid *ssid)
  100. +{
  101. + char *value, *pos;
  102. + int res, i;
  103. +
  104. + if (ssid->rates[0] <= 0)
  105. + return NULL;
  106. +
  107. + value = os_malloc(6 * WLAN_SUPP_RATES_MAX + 1);
  108. + if (value == NULL)
  109. + return NULL;
  110. + pos = value;
  111. + for (i = 0; i < WLAN_SUPP_RATES_MAX - 1; i++) {
  112. + res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2);
  113. + if (res < 0) {
  114. + os_free(value);
  115. + return NULL;
  116. + }
  117. + pos += res;
  118. + }
  119. + res = os_snprintf(pos, 6, "%.1f",
  120. + (double)ssid->rates[WLAN_SUPP_RATES_MAX - 1] / 2);
  121. + if (res < 0) {
  122. + os_free(value);
  123. + return NULL;
  124. + }
  125. +
  126. + value[6 * WLAN_SUPP_RATES_MAX] = '\0';
  127. + return value;
  128. +}
  129. +#endif /* NO_CONFIG_WRITE */
  130. +
  131. /* Helper macros for network block parser */
  132. #ifdef OFFSET
  133. @@ -2123,6 +2215,9 @@ static const struct parse_data ssid_fiel
  134. { INT(ap_max_inactivity) },
  135. { INT(dtim_period) },
  136. { INT(beacon_int) },
  137. + { INT_RANGE(fixed_freq, 0, 1) },
  138. + { FUNC(rates) },
  139. + { FUNC(mcast_rate) },
  140. #ifdef CONFIG_MACSEC
  141. { INT_RANGE(macsec_policy, 0, 1) },
  142. { INT_RANGE(macsec_integ_only, 0, 1) },
  143. --- a/wpa_supplicant/config_ssid.h
  144. +++ b/wpa_supplicant/config_ssid.h
  145. @@ -10,8 +10,10 @@
  146. #define CONFIG_SSID_H
  147. #include "common/defs.h"
  148. +#include "ap/sta_info.h"
  149. #include "utils/list.h"
  150. #include "eap_peer/eap_config.h"
  151. +#include "drivers/nl80211_copy.h"
  152. #define DEFAULT_EAP_WORKAROUND ((unsigned int) -1)
  153. @@ -719,6 +721,9 @@ struct wpa_ssid {
  154. */
  155. void *parent_cred;
  156. + unsigned char rates[WLAN_SUPP_RATES_MAX];
  157. + double mcast_rate;
  158. +
  159. #ifdef CONFIG_MACSEC
  160. /**
  161. * macsec_policy - Determines the policy for MACsec secure session
  162. --- a/wpa_supplicant/wpa_supplicant.c
  163. +++ b/wpa_supplicant/wpa_supplicant.c
  164. @@ -2561,6 +2561,13 @@ static void wpas_start_assoc_cb(struct w
  165. params.beacon_int = ssid->beacon_int;
  166. else
  167. params.beacon_int = wpa_s->conf->beacon_int;
  168. + params.fixed_freq = ssid->fixed_freq;
  169. + i = 0;
  170. + while (i < WLAN_SUPP_RATES_MAX) {
  171. + params.rates[i] = ssid->rates[i];
  172. + i++;
  173. + }
  174. + params.mcast_rate = ssid->mcast_rate;
  175. }
  176. params.wpa_ie = wpa_ie;