100-wext.patch 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. diff --git a/scan.c b/scan.c
  2. index 387d487..d9cde10 100644
  3. --- a/scan.c
  4. +++ b/scan.c
  5. @@ -4,6 +4,7 @@
  6. * IOCTL handlers as well as command preperation and response routines
  7. * for sending scan commands to the firmware.
  8. */
  9. +#include <linux/version.h>
  10. #include <linux/etherdevice.h>
  11. #include <asm/unaligned.h>
  12. @@ -13,6 +14,14 @@
  13. #include "scan.h"
  14. #include "cmd.h"
  15. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
  16. +#define IWE(func, ...) func(info, __VA_ARGS__)
  17. +#define LCP_LEN iwe_stream_lcp_len(info)
  18. +#else
  19. +#define IWE(func, ...) func(__VA_ARGS__)
  20. +#define LCP_LEN IW_EV_LCP_LEN
  21. +#endif
  22. +
  23. //! Approximate amount of data needed to pass a scan result back to iwlist
  24. #define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN \
  25. + IW_ESSID_MAX_SIZE \
  26. @@ -776,6 +785,7 @@ out:
  27. #define MAX_CUSTOM_LEN 64
  28. static inline char *lbs_translate_scan(struct lbs_private *priv,
  29. + struct iw_request_info *info,
  30. char *start, char *stop,
  31. struct bss_descriptor *bss)
  32. {
  33. @@ -801,24 +811,24 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
  34. iwe.cmd = SIOCGIWAP;
  35. iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
  36. memcpy(iwe.u.ap_addr.sa_data, &bss->bssid, ETH_ALEN);
  37. - start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN);
  38. + start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_ADDR_LEN);
  39. /* SSID */
  40. iwe.cmd = SIOCGIWESSID;
  41. iwe.u.data.flags = 1;
  42. iwe.u.data.length = min((uint32_t) bss->ssid_len, (uint32_t) IW_ESSID_MAX_SIZE);
  43. - start = iwe_stream_add_point(start, stop, &iwe, bss->ssid);
  44. + start = IWE(iwe_stream_add_point, start, stop, &iwe, bss->ssid);
  45. /* Mode */
  46. iwe.cmd = SIOCGIWMODE;
  47. iwe.u.mode = bss->mode;
  48. - start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN);
  49. + start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_UINT_LEN);
  50. /* Frequency */
  51. iwe.cmd = SIOCGIWFREQ;
  52. iwe.u.freq.m = (long)cfp->freq * 100000;
  53. iwe.u.freq.e = 1;
  54. - start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN);
  55. + start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_FREQ_LEN);
  56. /* Add quality statistics */
  57. iwe.cmd = IWEVQUAL;
  58. @@ -852,7 +862,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
  59. nf = priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
  60. iwe.u.qual.level = CAL_RSSI(snr, nf);
  61. }
  62. - start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);
  63. + start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_QUAL_LEN);
  64. /* Add encryption capability */
  65. iwe.cmd = SIOCGIWENCODE;
  66. @@ -862,9 +872,9 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
  67. iwe.u.data.flags = IW_ENCODE_DISABLED;
  68. }
  69. iwe.u.data.length = 0;
  70. - start = iwe_stream_add_point(start, stop, &iwe, bss->ssid);
  71. + start = IWE(iwe_stream_add_point, start, stop, &iwe, bss->ssid);
  72. - current_val = start + IW_EV_LCP_LEN;
  73. + current_val = start + LCP_LEN;
  74. iwe.cmd = SIOCGIWRATE;
  75. iwe.u.bitrate.fixed = 0;
  76. @@ -874,19 +884,19 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
  77. for (j = 0; bss->rates[j] && (j < sizeof(bss->rates)); j++) {
  78. /* Bit rate given in 500 kb/s units */
  79. iwe.u.bitrate.value = bss->rates[j] * 500000;
  80. - current_val = iwe_stream_add_value(start, current_val,
  81. + current_val = IWE(iwe_stream_add_value, start, current_val,
  82. stop, &iwe, IW_EV_PARAM_LEN);
  83. }
  84. if ((bss->mode == IW_MODE_ADHOC) && priv->adhoccreate
  85. && !lbs_ssid_cmp(priv->curbssparams.ssid,
  86. priv->curbssparams.ssid_len,
  87. bss->ssid, bss->ssid_len)) {
  88. iwe.u.bitrate.value = 22 * 500000;
  89. - current_val = iwe_stream_add_value(start, current_val,
  90. + current_val = IWE(iwe_stream_add_value, start, current_val,
  91. stop, &iwe, IW_EV_PARAM_LEN);
  92. }
  93. /* Check if we added any event */
  94. - if((current_val - start) > IW_EV_LCP_LEN)
  95. + if((current_val - start) > LCP_LEN)
  96. start = current_val;
  97. memset(&iwe, 0, sizeof(iwe));
  98. @@ -895,7 +905,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
  99. memcpy(buf, bss->wpa_ie, bss->wpa_ie_len);
  100. iwe.cmd = IWEVGENIE;
  101. iwe.u.data.length = bss->wpa_ie_len;
  102. - start = iwe_stream_add_point(start, stop, &iwe, buf);
  103. + start = IWE(iwe_stream_add_point, start, stop, &iwe, buf);
  104. }
  105. memset(&iwe, 0, sizeof(iwe));
  106. @@ -904,7 +914,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
  107. memcpy(buf, bss->rsn_ie, bss->rsn_ie_len);
  108. iwe.cmd = IWEVGENIE;
  109. iwe.u.data.length = bss->rsn_ie_len;
  110. - start = iwe_stream_add_point(start, stop, &iwe, buf);
  111. + start = IWE(iwe_stream_add_point, start, stop, &iwe, buf);
  112. }
  113. if (bss->mesh) {
  114. @@ -915,7 +925,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
  115. p += snprintf(p, MAX_CUSTOM_LEN, "mesh-type: olpc");
  116. iwe.u.data.length = p - custom;
  117. if (iwe.u.data.length)
  118. - start = iwe_stream_add_point(start, stop, &iwe, custom);
  119. + start = IWE(iwe_stream_add_point, start, stop, &iwe, custom);
  120. }
  121. out:
  122. @@ -1036,7 +1046,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
  123. }
  124. /* Translate to WE format this entry */
  125. - next_ev = lbs_translate_scan(priv, ev, stop, iter_bss);
  126. + next_ev = lbs_translate_scan(priv, info, ev, stop, iter_bss);
  127. if (next_ev == NULL)
  128. continue;
  129. ev = next_ev;