]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/linux/files/iw241_we16-6.diff
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / linux / files / iw241_we16-6.diff
1 diff -u -p linux/include/linux/wireless.15.h linux/include/linux/wireless.h
2 --- linux/include/linux/wireless.15.h   Fri Jan 10 16:55:07 2003
3 +++ linux/include/linux/wireless.h      Wed Apr  2 16:33:31 2003
4 @@ -1,7 +1,7 @@
5  /*
6   * This file define a set of standard wireless extensions
7   *
8 - * Version :   15      12.7.02
9 + * Version :   16      2.4.03
10   *
11   * Authors :   Jean Tourrilhes - HPL - <jt@hpl.hp.com>
12   * Copyright (c) 1997-2002 Jean Tourrilhes, All Rights Reserved.
13 @@ -69,6 +69,8 @@
14  
15  /***************************** INCLUDES *****************************/
16  
17 +/* To minimise problems in user space, I might remove those headers
18 + * at some point. Jean II */
19  #include <linux/types.h>               /* for "caddr_t" et al          */
20  #include <linux/socket.h>              /* for "struct sockaddr" et al  */
21  #include <linux/if.h>                  /* for IFNAMSIZ and co... */
22 @@ -80,7 +82,7 @@
23   * (there is some stuff that will be added in the future...)
24   * I just plan to increment with each new version.
25   */
26 -#define WIRELESS_EXT   15
27 +#define WIRELESS_EXT   16
28  
29  /*
30   * Changes :
31 @@ -163,6 +165,16 @@
32   *     - Add IW_TXPOW_RANGE for range of Tx Powers
33   *     - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
34   *     - Add IW_MODE_MONITOR for passive monitor
35 + *
36 + * V15 to V16
37 + * ----------
38 + *     - Increase the number of bitrates in iw_range to 32 (for 802.11g)
39 + *     - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
40 + *     - Reshuffle struct iw_range for increases, add filler
41 + *     - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
42 + *     - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
43 + *     - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
44 + *     - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
45   */
46  
47  /**************************** CONSTANTS ****************************/
48 @@ -196,9 +208,11 @@
49  /* SIOCGIWSTATS is strictly used between user space and the kernel, and
50   * is never passed to the driver (i.e. the driver will never see it). */
51  
52 -/* Mobile IP support (statistics per MAC address) */
53 +/* Spy support (statistics per MAC address - used for Mobile IP support) */
54  #define SIOCSIWSPY     0x8B10          /* set spy addresses */
55  #define SIOCGIWSPY     0x8B11          /* get spy info (quality of link) */
56 +#define SIOCSIWTHRSPY  0x8B12          /* set spy threshold (spy event) */
57 +#define SIOCGIWTHRSPY  0x8B13          /* get spy threshold */
58  
59  /* Access Point manipulation */
60  #define SIOCSIWAP      0x8B14          /* set access point MAC addresses */
61 @@ -294,7 +308,7 @@
62  #define IW_PRIV_TYPE_FLOAT     0x5000  /* struct iw_freq */
63  #define IW_PRIV_TYPE_ADDR      0x6000  /* struct sockaddr */
64  
65 -#define IW_PRIV_SIZE_FIXED     0x0800  /* Variable or fixed nuber of args */
66 +#define IW_PRIV_SIZE_FIXED     0x0800  /* Variable or fixed number of args */
67  
68  #define IW_PRIV_SIZE_MASK      0x07FF  /* Max number of those args */
69  
70 @@ -306,13 +320,13 @@
71  /* ----------------------- OTHER CONSTANTS ----------------------- */
72  
73  /* Maximum frequencies in the range struct */
74 -#define IW_MAX_FREQUENCIES     16
75 +#define IW_MAX_FREQUENCIES     32
76  /* Note : if you have something like 80 frequencies,
77   * don't increase this constant and don't fill the frequency list.
78   * The user will be able to set by channel anyway... */
79  
80  /* Maximum bit rates in the range struct */
81 -#define IW_MAX_BITRATES                8
82 +#define IW_MAX_BITRATES                32
83  
84  /* Maximum tx powers in the range struct */
85  #define IW_MAX_TXPOWER         8
86 @@ -320,8 +334,7 @@
87   * a few of them in the struct iw_range. */
88  
89  /* Maximum of address that you may set with SPY */
90 -#define IW_MAX_SPY             8       /* set */
91 -#define IW_MAX_GET_SPY         64      /* get */
92 +#define IW_MAX_SPY             8
93  
94  /* Maximum of address that you may get in the
95     list of access points in range */
96 @@ -354,7 +367,8 @@
97  #define IW_ENCODE_ENABLED      0x0000  /* Encoding enabled */
98  #define IW_ENCODE_RESTRICTED   0x4000  /* Refuse non-encoded packets */
99  #define IW_ENCODE_OPEN         0x2000  /* Accept non-encoded packets */
100 -#define IW_ENCODE_NOKEY         0x0800  /* Key is write only, so not present */
101 +#define IW_ENCODE_NOKEY                0x0800  /* Key is write only, so not present */
102 +#define IW_ENCODE_TEMP         0x0400  /* Temporary key */
103  
104  /* Power management flags available (along with the value, if any) */
105  #define IW_POWER_ON            0x0000  /* No details... */
106 @@ -482,6 +496,17 @@ struct     iw_missed
107         __u32           beacon;         /* Missed beacons/superframe */
108  };
109  
110 +/*
111 + *     Quality range (for spy threshold)
112 + */
113 +struct iw_thrspy
114 +{
115 +       struct sockaddr         addr;           /* Source address (hw/mac) */
116 +       struct iw_quality       qual;           /* Quality of the link */
117 +       struct iw_quality       low;            /* Low threshold */
118 +       struct iw_quality       high;           /* High threshold */
119 +};
120 +
121  /* ------------------------ WIRELESS STATS ------------------------ */
122  /*
123   * Wireless statistics (used for /proc/net/wireless)
124 @@ -534,7 +559,7 @@ union       iwreq_data
125         struct iw_quality qual;         /* Quality part of statistics */
126  
127         struct sockaddr ap_addr;        /* Access point address */
128 -       struct sockaddr addr;           /* Destination address (hw) */
129 +       struct sockaddr addr;           /* Destination address (hw/mac) */
130  
131         struct iw_param param;          /* Other small parameters */
132         struct iw_point data;           /* Other large parameters */
133 @@ -582,17 +607,31 @@ struct    iw_range
134         __u32           min_nwid;       /* Minimal NWID we are able to set */
135         __u32           max_nwid;       /* Maximal NWID we are able to set */
136  
137 -       /* Frequency */
138 -       __u16           num_channels;   /* Number of channels [0; num - 1] */
139 -       __u8            num_frequency;  /* Number of entry in the list */
140 -       struct iw_freq  freq[IW_MAX_FREQUENCIES];       /* list */
141 -       /* Note : this frequency list doesn't need to fit channel numbers */
142 +       /* Old Frequency (backward compat - moved lower ) */
143 +       __u16           old_num_channels;
144 +       __u8            old_num_frequency;
145 +       /* Filler to keep "version" at the same offset */
146 +       __s32           old_freq[6];
147  
148         /* signal level threshold range */
149         __s32   sensitivity;
150  
151         /* Quality of link & SNR stuff */
152 +       /* Quality range (link, level, noise)
153 +        * If the quality is absolute, it will be in the range [0 ; max_qual],
154 +        * if the quality is dBm, it will be in the range [max_qual ; 0].
155 +        * Don't forget that we use 8 bit arithmetics... */
156         struct iw_quality       max_qual;       /* Quality of the link */
157 +       /* This should contain the average/typical values of the quality
158 +        * indicator. This should be the threshold between a "good" and
159 +        * a "bad" link (example : monitor going from green to orange).
160 +        * Currently, user space apps like quality monitors don't have any
161 +        * way to calibrate the measurement. With this, they can split
162 +        * the range between 0 and max_qual in different quality level
163 +        * (using a geometric subdivision centered on the average).
164 +        * I expect that people doing the user space apps will feedback
165 +        * us on which value we need to put in each driver... */
166 +       struct iw_quality       avg_qual;       /* Quality of the link */
167  
168         /* Rates */
169         __u8            num_bitrates;   /* Number of entries in the list */
170 @@ -619,6 +658,8 @@ struct      iw_range
171         __u16   encoding_size[IW_MAX_ENCODING_SIZES];   /* Different token sizes */
172         __u8    num_encoding_sizes;     /* Number of entry in the list */
173         __u8    max_encoding_tokens;    /* Max number of tokens */
174 +       /* For drivers that need a "login/passwd" form */
175 +       __u8    encoding_login_index;   /* token index for login token */
176  
177         /* Transmit power */
178         __u16           txpower_capa;   /* What options are supported */
179 @@ -638,18 +679,12 @@ struct    iw_range
180         __s32           min_r_time;     /* Minimal retry lifetime */
181         __s32           max_r_time;     /* Maximal retry lifetime */
182  
183 -       /* Average quality of link & SNR */
184 -       struct iw_quality       avg_qual;       /* Quality of the link */
185 -       /* This should contain the average/typical values of the quality
186 -        * indicator. This should be the threshold between a "good" and
187 -        * a "bad" link (example : monitor going from green to orange).
188 -        * Currently, user space apps like quality monitors don't have any
189 -        * way to calibrate the measurement. With this, they can split
190 -        * the range between 0 and max_qual in different quality level
191 -        * (using a geometric subdivision centered on the average).
192 -        * I expect that people doing the user space apps will feedback
193 -        * us on which value we need to put in each driver...
194 -        */
195 +       /* Frequency */
196 +       __u16           num_channels;   /* Number of channels [0; num - 1] */
197 +       __u8            num_frequency;  /* Number of entry in the list */
198 +       struct iw_freq  freq[IW_MAX_FREQUENCIES];       /* list */
199 +       /* Note : this frequency list doesn't need to fit channel numbers,
200 +        * because each entry contain its channel index */
201  };
202  
203  /*
204 diff -u -p linux/include/net/iw_handler.15.h linux/include/net/iw_handler.h
205 --- linux/include/net/iw_handler.15.h   Fri Jan 10 16:55:17 2003
206 +++ linux/include/net/iw_handler.h      Fri Jan 10 17:02:13 2003
207 @@ -1,7 +1,7 @@
208  /*
209   * This file define the new driver API for Wireless Extensions
210   *
211 - * Version :   4       21.6.02
212 + * Version :   5       4.12.02
213   *
214   * Authors :   Jean Tourrilhes - HPL - <jt@hpl.hp.com>
215   * Copyright (c) 2001-2002 Jean Tourrilhes, All Rights Reserved.
216 @@ -206,7 +206,7 @@
217   * will be needed...
218   * I just plan to increment with each new version.
219   */
220 -#define IW_HANDLER_VERSION     4
221 +#define IW_HANDLER_VERSION     5
222  
223  /*
224   * Changes :
225 @@ -220,10 +220,18 @@
226   * V3 to V4
227   * --------
228   *     - Reshuffle IW_HEADER_TYPE_XXX to map IW_PRIV_TYPE_XXX changes
229 + *
230 + * V4 to V5
231 + * --------
232 + *     - Add new spy support : struct iw_spy_data & prototypes
233   */
234  
235  /**************************** CONSTANTS ****************************/
236  
237 +/* Enable enhanced spy support. Disable to reduce footprint */
238 +#define IW_WIRELESS_SPY
239 +#define IW_WIRELESS_THRSPY
240 +
241  /* Special error message for the driver to indicate that we
242   * should do a commit after return from the iw_handler */
243  #define EIWCOMMIT      EINPROGRESS
244 @@ -315,6 +323,9 @@ struct iw_handler_def
245          * We will automatically export that to user space... */
246         struct iw_priv_args *   private_args;
247  
248 +       /* Driver enhanced spy support */
249 +       long                    spy_offset;     /* Spy data offset */
250 +
251         /* In the long term, get_wireless_stats will move from
252          * 'struct net_device' to here, to minimise bloat. */
253  };
254 @@ -350,6 +361,33 @@ struct iw_ioctl_description
255  
256  /* Need to think of short header translation table. Later. */
257  
258 +/* --------------------- ENHANCED SPY SUPPORT --------------------- */
259 +/*
260 + * In the old days, the driver was handling spy support all by itself.
261 + * Now, the driver can delegate this task to Wireless Extensions.
262 + * It needs to include this struct in its private part and use the
263 + * standard spy iw_handler.
264 + */
265 +
266 +/*
267 + * Instance specific spy data, i.e. addresses spied and quality for them.
268 + */
269 +struct iw_spy_data
270 +{
271 +#ifdef IW_WIRELESS_SPY
272 +       /* --- Standard spy support --- */
273 +       int                     spy_number;
274 +       u_char                  spy_address[IW_MAX_SPY][ETH_ALEN];
275 +       struct iw_quality       spy_stat[IW_MAX_SPY];
276 +#ifdef IW_WIRELESS_THRSPY
277 +       /* --- Enhanced spy support (event) */
278 +       struct iw_quality       spy_thr_low;    /* Low threshold */
279 +       struct iw_quality       spy_thr_high;   /* High threshold */
280 +       u_char                  spy_thr_under[IW_MAX_SPY];
281 +#endif /* IW_WIRELESS_THRSPY */
282 +#endif /* IW_WIRELESS_SPY */
283 +};
284 +
285  /**************************** PROTOTYPES ****************************/
286  /*
287   * Functions part of the Wireless Extensions (defined in net/core/wireless.c).
288 @@ -375,6 +413,31 @@ extern void wireless_send_event(struct n
289  
290  /* We may need a function to send a stream of events to user space.
291   * More on that later... */
292 +
293 +/* Standard handler for SIOCSIWSPY */
294 +extern int iw_handler_set_spy(struct net_device *      dev,
295 +                             struct iw_request_info *  info,
296 +                             union iwreq_data *        wrqu,
297 +                             char *                    extra);
298 +/* Standard handler for SIOCGIWSPY */
299 +extern int iw_handler_get_spy(struct net_device *      dev,
300 +                             struct iw_request_info *  info,
301 +                             union iwreq_data *        wrqu,
302 +                             char *                    extra);
303 +/* Standard handler for SIOCSIWTHRSPY */
304 +extern int iw_handler_set_thrspy(struct net_device *   dev,
305 +                                struct iw_request_info *info,
306 +                                union iwreq_data *     wrqu,
307 +                                char *                 extra);
308 +/* Standard handler for SIOCGIWTHRSPY */
309 +extern int iw_handler_get_thrspy(struct net_device *   dev,
310 +                                struct iw_request_info *info,
311 +                                union iwreq_data *     wrqu,
312 +                                char *                 extra);
313 +/* Driver call to update spy records */
314 +extern void wireless_spy_update(struct net_device *    dev,
315 +                               unsigned char *         address,
316 +                               struct iw_quality *     wstats);
317  
318  /************************* INLINE FUNTIONS *************************/
319  /*
320 diff -u -p linux/net/core/wireless.15.c linux/net/core/wireless.c
321 --- linux/net/core/wireless.15.c        Fri Jan 10 16:56:16 2003
322 +++ linux/net/core/wireless.c   Fri Jan 10 16:59:55 2003
323 @@ -2,7 +2,7 @@
324   * This file implement the Wireless Extensions APIs.
325   *
326   * Authors :   Jean Tourrilhes - HPL - <jt@hpl.hp.com>
327 - * Copyright (c) 1997-2002 Jean Tourrilhes, All Rights Reserved.
328 + * Copyright (c) 1997-2003 Jean Tourrilhes, All Rights Reserved.
329   *
330   * (As all part of the Linux kernel, this file is GPL)
331   */
332 @@ -43,6 +43,11 @@
333   *     o Turn on WE_STRICT_WRITE by default + kernel warning
334   *     o Fix WE_STRICT_WRITE in ioctl_export_private() (32 => iw_num)
335   *     o Fix off-by-one in test (extra_size <= IFNAMSIZ)
336 + *
337 + * v6 - 9.01.03 - Jean II
338 + *     o Add common spy support : iw_handler_set_spy(), wireless_spy_update()
339 + *     o Add enhanced spy support : iw_handler_set_thrspy() and event.
340 + *     o Add WIRELESS_EXT version display in /proc/net/wireless
341   */
342  
343  /***************************** INCLUDES *****************************/
344 @@ -52,6 +57,7 @@
345  #include <linux/types.h>               /* off_t */
346  #include <linux/netdevice.h>           /* struct ifreq, dev_get_by_name() */
347  #include <linux/rtnetlink.h>           /* rtnetlink stuff */
348 +#include <linux/if_arp.h>              /* ARPHRD_ETHER */
349  
350  #include <linux/wireless.h>            /* Pretty obvious */
351  #include <net/iw_handler.h>            /* New driver API */
352 @@ -65,6 +71,7 @@
353  /* Debuging stuff */
354  #undef WE_IOCTL_DEBUG          /* Debug IOCTL API */
355  #undef WE_EVENT_DEBUG          /* Debug Event dispatcher */
356 +#undef WE_SPY_DEBUG            /* Debug enhanced spy support */
357  
358  /* Options */
359  #define WE_EVENT_NETLINK       /* Propagate events using rtnetlink */
360 @@ -72,7 +79,7 @@
361  
362  /************************* GLOBAL VARIABLES *************************/
363  /*
364 - * You should not use global variables, because or re-entrancy.
365 + * You should not use global variables, because of re-entrancy.
366   * On our case, it's only const, so it's OK...
367   */
368  /*
369 @@ -115,11 +122,11 @@ static const struct iw_ioctl_description
370         /* SIOCSIWSPY */
371         { IW_HEADER_TYPE_POINT, 0, sizeof(struct sockaddr), 0, IW_MAX_SPY, 0},
372         /* SIOCGIWSPY */
373 -       { IW_HEADER_TYPE_POINT, 0, (sizeof(struct sockaddr) + sizeof(struct iw_quality)), 0, IW_MAX_GET_SPY, 0},
374 -       /* -- hole -- */
375 -       { IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
376 -       /* -- hole -- */
377 -       { IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
378 +       { IW_HEADER_TYPE_POINT, 0, (sizeof(struct sockaddr) + sizeof(struct iw_quality)), 0, IW_MAX_SPY, 0},
379 +       /* SIOCSIWTHRSPY */
380 +       { IW_HEADER_TYPE_POINT, 0, sizeof(struct iw_thrspy), 1, 1, 0},
381 +       /* SIOCGIWTHRSPY */
382 +       { IW_HEADER_TYPE_POINT, 0, sizeof(struct iw_thrspy), 1, 1, 0},
383         /* SIOCSIWAP */
384         { IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0},
385         /* SIOCGIWAP */
386 @@ -377,9 +384,9 @@ int dev_get_wireless_info(char * buffer,
387         struct net_device *     dev;
388  
389         size = sprintf(buffer,
390 -                      "Inter-| sta-|   Quality        |   Discarded packets               | Missed\n"
391 -                      " face | tus | link level noise |  nwid  crypt   frag  retry   misc | beacon\n"
392 -                       );
393 +                      "Inter-| sta-|   Quality        |   Discarded packets               | Missed | WE\n"
394 +                      " face | tus | link level noise |  nwid  crypt   frag  retry   misc | beacon | %d\n",
395 +                      WIRELESS_EXT);
396         
397         pos += size;
398         len += size;
399 @@ -1023,4 +1030,253 @@ void wireless_send_event(struct net_devi
400         kfree(event);
401  
402         return;         /* Always success, I guess ;-) */
403 +}
404 +
405 +/********************** ENHANCED IWSPY SUPPORT **********************/
406 +/*
407 + * In the old days, the driver was handling spy support all by itself.
408 + * Now, the driver can delegate this task to Wireless Extensions.
409 + * It needs to use those standard spy iw_handler in struct iw_handler_def,
410 + * push data to us via XXX and include struct iw_spy_data in its
411 + * private part.
412 + * One of the main advantage of centralising spy support here is that
413 + * it becomes much easier to improve and extend it without having to touch
414 + * the drivers. One example is the addition of the Spy-Threshold events.
415 + * Note : IW_WIRELESS_SPY is defined in iw_handler.h
416 + */
417 +
418 +/*------------------------------------------------------------------*/
419 +/*
420 + * Standard Wireless Handler : set Spy List
421 + */
422 +int iw_handler_set_spy(struct net_device *     dev,
423 +                      struct iw_request_info * info,
424 +                      union iwreq_data *       wrqu,
425 +                      char *                   extra)
426 +{
427 +#ifdef IW_WIRELESS_SPY
428 +       struct iw_spy_data *    spydata = (dev->priv +
429 +                                          dev->wireless_handlers->spy_offset);
430 +       struct sockaddr *       address = (struct sockaddr *) extra;
431 +
432 +       /* Disable spy collection while we copy the addresses.
433 +        * As we don't disable interrupts, we need to do this to avoid races.
434 +        * As we are the only writer, this is good enough. */
435 +       spydata->spy_number = 0;
436 +
437 +       /* Are there are addresses to copy? */
438 +       if(wrqu->data.length > 0) {
439 +               int i;
440 +
441 +               /* Copy addresses */
442 +               for(i = 0; i < wrqu->data.length; i++)
443 +                       memcpy(spydata->spy_address[i], address[i].sa_data,
444 +                              ETH_ALEN);
445 +               /* Reset stats */
446 +               memset(spydata->spy_stat, 0,
447 +                      sizeof(struct iw_quality) * IW_MAX_SPY);
448 +
449 +#ifdef WE_SPY_DEBUG
450 +               printk(KERN_DEBUG "iw_handler_set_spy() :  offset %ld, spydata %p, num %d\n", dev->wireless_handlers->spy_offset, spydata, wrqu->data.length);
451 +               for (i = 0; i < wrqu->data.length; i++)
452 +                       printk(KERN_DEBUG
453 +                              "%02X:%02X:%02X:%02X:%02X:%02X \n",
454 +                              spydata->spy_address[i][0],
455 +                              spydata->spy_address[i][1],
456 +                              spydata->spy_address[i][2],
457 +                              spydata->spy_address[i][3],
458 +                              spydata->spy_address[i][4],
459 +                              spydata->spy_address[i][5]);
460 +#endif /* WE_SPY_DEBUG */
461 +       }
462 +       /* Enable addresses */
463 +       spydata->spy_number = wrqu->data.length;
464 +
465 +       return 0;
466 +#else /* IW_WIRELESS_SPY */
467 +       return -EOPNOTSUPP;
468 +#endif /* IW_WIRELESS_SPY */
469 +}
470 +
471 +/*------------------------------------------------------------------*/
472 +/*
473 + * Standard Wireless Handler : get Spy List
474 + */
475 +int iw_handler_get_spy(struct net_device *     dev,
476 +                      struct iw_request_info * info,
477 +                      union iwreq_data *       wrqu,
478 +                      char *                   extra)
479 +{
480 +#ifdef IW_WIRELESS_SPY
481 +       struct iw_spy_data *    spydata = (dev->priv +
482 +                                          dev->wireless_handlers->spy_offset);
483 +       struct sockaddr *       address = (struct sockaddr *) extra;
484 +       int                     i;
485 +
486 +       wrqu->data.length = spydata->spy_number;
487 +
488 +       /* Copy addresses. */
489 +       for(i = 0; i < spydata->spy_number; i++)        {
490 +               memcpy(address[i].sa_data, spydata->spy_address[i], ETH_ALEN);
491 +               address[i].sa_family = AF_UNIX;
492 +       }
493 +       /* Copy stats to the user buffer (just after). */
494 +       if(spydata->spy_number > 0)
495 +               memcpy(extra  + (sizeof(struct sockaddr) *spydata->spy_number),
496 +                      spydata->spy_stat,
497 +                      sizeof(struct iw_quality) * spydata->spy_number);
498 +       /* Reset updated flags. */
499 +       for(i = 0; i < spydata->spy_number; i++)
500 +               spydata->spy_stat[i].updated = 0;
501 +       return 0;
502 +#else /* IW_WIRELESS_SPY */
503 +       return -EOPNOTSUPP;
504 +#endif /* IW_WIRELESS_SPY */
505 +}
506 +
507 +/*------------------------------------------------------------------*/
508 +/*
509 + * Standard Wireless Handler : set spy threshold
510 + */
511 +int iw_handler_set_thrspy(struct net_device *  dev,
512 +                         struct iw_request_info *info,
513 +                         union iwreq_data *    wrqu,
514 +                         char *                extra)
515 +{
516 +#ifdef IW_WIRELESS_THRSPY
517 +       struct iw_spy_data *    spydata = (dev->priv +
518 +                                          dev->wireless_handlers->spy_offset);
519 +       struct iw_thrspy *      threshold = (struct iw_thrspy *) extra;
520 +
521 +       /* Just do it */
522 +       memcpy(&(spydata->spy_thr_low), &(threshold->low),
523 +              2 * sizeof(struct iw_quality));
524 +
525 +       /* Clear flag */
526 +       memset(spydata->spy_thr_under, '\0', sizeof(spydata->spy_thr_under));
527 +
528 +#ifdef WE_SPY_DEBUG
529 +       printk(KERN_DEBUG "iw_handler_set_thrspy() :  low %d ; high %d\n", spydata->spy_thr_low.level, spydata->spy_thr_high.level);
530 +#endif /* WE_SPY_DEBUG */
531 +
532 +       return 0;
533 +#else /* IW_WIRELESS_THRSPY */
534 +       return -EOPNOTSUPP;
535 +#endif /* IW_WIRELESS_THRSPY */
536 +}
537 +
538 +/*------------------------------------------------------------------*/
539 +/*
540 + * Standard Wireless Handler : get spy threshold
541 + */
542 +int iw_handler_get_thrspy(struct net_device *  dev,
543 +                         struct iw_request_info *info,
544 +                         union iwreq_data *    wrqu,
545 +                         char *                extra)
546 +{
547 +#ifdef IW_WIRELESS_THRSPY
548 +       struct iw_spy_data *    spydata = (dev->priv +
549 +                                          dev->wireless_handlers->spy_offset);
550 +       struct iw_thrspy *      threshold = (struct iw_thrspy *) extra;
551 +
552 +       /* Just do it */
553 +       memcpy(&(threshold->low), &(spydata->spy_thr_low),
554 +              2 * sizeof(struct iw_quality));
555 +
556 +       return 0;
557 +#else /* IW_WIRELESS_THRSPY */
558 +       return -EOPNOTSUPP;
559 +#endif /* IW_WIRELESS_THRSPY */
560 +}
561 +
562 +#ifdef IW_WIRELESS_THRSPY
563 +/*------------------------------------------------------------------*/
564 +/*
565 + * Prepare and send a Spy Threshold event
566 + */
567 +static void iw_send_thrspy_event(struct net_device *   dev,
568 +                                struct iw_spy_data *   spydata,
569 +                                unsigned char *        address,
570 +                                struct iw_quality *    wstats)
571 +{
572 +       union iwreq_data        wrqu;
573 +       struct iw_thrspy        threshold;
574 +
575 +       /* Init */
576 +       wrqu.data.length = 1;
577 +       wrqu.data.flags = 0;
578 +       /* Copy address */
579 +       memcpy(threshold.addr.sa_data, address, ETH_ALEN);
580 +       threshold.addr.sa_family = ARPHRD_ETHER;
581 +       /* Copy stats */
582 +       memcpy(&(threshold.qual), wstats, sizeof(struct iw_quality));
583 +       /* Copy also thresholds */
584 +       memcpy(&(threshold.low), &(spydata->spy_thr_low),
585 +              2 * sizeof(struct iw_quality));
586 +
587 +#ifdef WE_SPY_DEBUG
588 +       printk(KERN_DEBUG "iw_send_thrspy_event() : address %02X:%02X:%02X:%02X:%02X:%02X, level %d, up = %d\n",
589 +              threshold.addr.sa_data[0],
590 +              threshold.addr.sa_data[1],
591 +              threshold.addr.sa_data[2],
592 +              threshold.addr.sa_data[3],
593 +              threshold.addr.sa_data[4],
594 +              threshold.addr.sa_data[5], threshold.qual.level);
595 +#endif /* WE_SPY_DEBUG */
596 +
597 +       /* Send event to user space */
598 +       wireless_send_event(dev, SIOCGIWTHRSPY, &wrqu, (char *) &threshold);
599 +}
600 +#endif /* IW_WIRELESS_THRSPY */
601 +
602 +/* ---------------------------------------------------------------- */
603 +/*
604 + * Call for the driver to update the spy data.
605 + * For now, the spy data is a simple array. As the size of the array is
606 + * small, this is good enough. If we wanted to support larger number of
607 + * spy addresses, we should use something more efficient...
608 + */
609 +void wireless_spy_update(struct net_device *   dev,
610 +                        unsigned char *        address,
611 +                        struct iw_quality *    wstats)
612 +{
613 +#ifdef IW_WIRELESS_SPY
614 +       struct iw_spy_data *    spydata = (dev->priv +
615 +                                          dev->wireless_handlers->spy_offset);
616 +       int                     i;
617 +       int                     match = -1;
618 +
619 +#ifdef WE_SPY_DEBUG
620 +       printk(KERN_DEBUG "wireless_spy_update() :  offset %ld, spydata %p, address %02X:%02X:%02X:%02X:%02X:%02X\n", dev->wireless_handlers->spy_offset, spydata, address[0], address[1], address[2], address[3], address[4], address[5]);
621 +#endif /* WE_SPY_DEBUG */
622 +
623 +       /* Update all records that match */
624 +       for(i = 0; i < spydata->spy_number; i++)
625 +               if(!memcmp(address, spydata->spy_address[i], ETH_ALEN)) {
626 +                       memcpy(&(spydata->spy_stat[i]), wstats,
627 +                              sizeof(struct iw_quality));
628 +                       match = i;
629 +               }
630 +#ifdef IW_WIRELESS_THRSPY
631 +       /* Generate an event if we cross the spy threshold.
632 +        * To avoid event storms, we have a simple hysteresis : we generate
633 +        * event only when we go under the low threshold or above the
634 +        * high threshold. */
635 +       if(match >= 0) {
636 +               if(spydata->spy_thr_under[match]) {
637 +                       if(wstats->level > spydata->spy_thr_high.level) {
638 +                               spydata->spy_thr_under[match] = 0;
639 +                               iw_send_thrspy_event(dev, spydata,
640 +                                                    address, wstats);
641 +                       }
642 +               } else {
643 +                       if(wstats->level < spydata->spy_thr_low.level) {
644 +                               spydata->spy_thr_under[match] = 1;
645 +                               iw_send_thrspy_event(dev, spydata,
646 +                                                    address, wstats);
647 +                       }
648 +               }
649 +       }
650 +#endif /* IW_WIRELESS_THRSPY */
651 +#endif /* IW_WIRELESS_SPY */
652  }
653 diff -u -p linux/net/netsyms.15.c linux/net/netsyms.c
654 --- linux/net/netsyms.15.c      Fri Jan 10 16:56:32 2003
655 +++ linux/net/netsyms.c Fri Jan 10 17:01:09 2003
656 @@ -594,6 +594,11 @@ EXPORT_SYMBOL(softnet_data);
657  #if defined(CONFIG_NET_RADIO) || defined(CONFIG_NET_PCMCIA_RADIO)
658  #include <net/iw_handler.h>
659  EXPORT_SYMBOL(wireless_send_event);
660 +EXPORT_SYMBOL(iw_handler_set_spy);
661 +EXPORT_SYMBOL(iw_handler_get_spy);
662 +EXPORT_SYMBOL(iw_handler_set_thrspy);
663 +EXPORT_SYMBOL(iw_handler_get_thrspy);
664 +EXPORT_SYMBOL(wireless_spy_update);
665  #endif /* CONFIG_NET_RADIO || CONFIG_NET_PCMCIA_RADIO */
666  
667  #endif  /* CONFIG_NET */