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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. #include "common/wpa_common.h"
  21. @@ -819,6 +820,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. @@ -17,6 +17,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. @@ -2130,6 +2131,97 @@ static char * wpa_config_write_peerkey(c
  39. #endif /* NO_CONFIG_WRITE */
  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. @@ -2382,6 +2474,8 @@ static const struct parse_data ssid_fiel
  134. { INT(ap_max_inactivity) },
  135. { INT(dtim_period) },
  136. { INT(beacon_int) },
  137. + { FUNC(rates) },
  138. + { FUNC(mcast_rate) },
  139. #ifdef CONFIG_MACSEC
  140. { INT_RANGE(macsec_policy, 0, 1) },
  141. { INT_RANGE(macsec_integ_only, 0, 1) },
  142. --- a/wpa_supplicant/config_ssid.h
  143. +++ b/wpa_supplicant/config_ssid.h
  144. @@ -10,8 +10,10 @@
  145. #define CONFIG_SSID_H
  146. #include "common/defs.h"
  147. +#include "ap/sta_info.h"
  148. #include "utils/list.h"
  149. #include "eap_peer/eap_config.h"
  150. +#include "drivers/nl80211_copy.h"
  151. #define DEFAULT_EAP_WORKAROUND ((unsigned int) -1)
  152. @@ -790,6 +792,9 @@ struct wpa_ssid {
  153. */
  154. void *parent_cred;
  155. + unsigned char rates[WLAN_SUPP_RATES_MAX];
  156. + double mcast_rate;
  157. +
  158. #ifdef CONFIG_MACSEC
  159. /**
  160. * macsec_policy - Determines the policy for MACsec secure session
  161. --- a/wpa_supplicant/wpa_supplicant.c
  162. +++ b/wpa_supplicant/wpa_supplicant.c
  163. @@ -3266,6 +3266,12 @@ static void wpas_start_assoc_cb(struct w
  164. params.beacon_int = ssid->beacon_int;
  165. else
  166. params.beacon_int = wpa_s->conf->beacon_int;
  167. + i = 0;
  168. + while (i < WLAN_SUPP_RATES_MAX) {
  169. + params.rates[i] = ssid->rates[i];
  170. + i++;
  171. + }
  172. + params.mcast_rate = ssid->mcast_rate;
  173. }
  174. params.pairwise_suite = cipher_pairwise;