copy libiptc.a to staging dir
[openwrt.git] / package / openwrt / wlcompat.c
1 /*
2 * wlcompat.c
3 *
4 * Copyright (C) 2005 Mike Baker,
5 * Felix Fietkau <nbd@vd-s.ath.cx>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * $Id$
22 */
23
24
25 #include <linux/config.h>
26 #include <linux/module.h>
27 #include <linux/init.h>
28 #include <linux/if_arp.h>
29 #include <asm/uaccess.h>
30 #include <linux/wireless.h>
31
32 #include <net/iw_handler.h>
33 #include <wlioctl.h>
34
35 static struct net_device *dev;
36 char buf[WLC_IOCTL_MAXLEN];
37
38 /* The frequency of each channel in MHz */
39 const long channel_frequency[] = {
40 2412, 2417, 2422, 2427, 2432, 2437, 2442,
41 2447, 2452, 2457, 2462, 2467, 2472, 2484
42 };
43 #define NUM_CHANNELS ( sizeof(channel_frequency) / sizeof(channel_frequency[0]) )
44
45 static int wlcompat_private_ioctl(struct net_device *dev,
46 struct iw_request_info *info,
47 union iwreq_data *wrqu,
48 char *extra);
49
50 static int wl_ioctl(struct net_device *dev, int cmd, void *buf, int len)
51 {
52 mm_segment_t old_fs = get_fs();
53 struct ifreq ifr;
54 int ret;
55 wl_ioctl_t ioc;
56 ioc.cmd = cmd;
57 ioc.buf = buf;
58 ioc.len = len;
59 strncpy(ifr.ifr_name, dev->name, IFNAMSIZ);
60 ifr.ifr_data = (caddr_t) &ioc;
61 set_fs(KERNEL_DS);
62 ret = dev->do_ioctl(dev,&ifr,SIOCDEVPRIVATE);
63 set_fs (old_fs);
64 return ret;
65 }
66
67 static int wl_set_val(struct net_device *dev, char *var, void *val, int len)
68 {
69 char buf[128];
70 int buf_len;
71
72 /* check for overflow */
73 if ((buf_len = strlen(var)) + 1 + len > sizeof(buf))
74 return -1;
75
76 strcpy(buf, var);
77 buf_len += 1;
78
79 /* append int value onto the end of the name string */
80 memcpy(&buf[buf_len], val, len);
81 buf_len += len;
82
83 return wl_ioctl(dev, WLC_SET_VAR, buf, buf_len);
84 }
85
86 static int wl_get_val(struct net_device *dev, char *var, void *val, int len)
87 {
88 char buf[128];
89 int ret;
90
91 /* check for overflow */
92 if (strlen(var) + 1 > sizeof(buf) || len > sizeof(buf))
93 return -1;
94
95 strcpy(buf, var);
96 if ((ret = wl_ioctl(dev, WLC_GET_VAR, buf, sizeof(buf))))
97 return ret;
98
99 memcpy(val, buf, len);
100 return 0;
101 }
102
103
104 static int wlcompat_ioctl_getiwrange(struct net_device *dev,
105 char *extra)
106 {
107 int i, k;
108 struct iw_range *range;
109
110 range = (struct iw_range *) extra;
111
112 range->we_version_compiled = WIRELESS_EXT;
113 range->we_version_source = WIRELESS_EXT;
114
115 range->min_nwid = range->max_nwid = 0;
116
117 range->num_channels = NUM_CHANNELS;
118 k = 0;
119 for (i = 0; i < NUM_CHANNELS; i++) {
120 range->freq[k].i = i + 1;
121 range->freq[k].m = channel_frequency[i] * 100000;
122 range->freq[k].e = 1;
123 k++;
124 if (k >= IW_MAX_FREQUENCIES)
125 break;
126 }
127 range->num_frequency = k;
128 range->sensitivity = 3;
129
130 /* nbd: don't know what this means, but other drivers set it this way */
131 range->pmp_flags = IW_POWER_PERIOD;
132 range->pmt_flags = IW_POWER_TIMEOUT;
133 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
134
135 range->min_pmp = 0;
136 range->max_pmp = 65535000;
137 range->min_pmt = 0;
138 range->max_pmt = 65535 * 1000;
139
140 range->min_rts = 0;
141 if (wl_ioctl(dev, WLC_GET_RTS, &range->max_rts, sizeof(int)) < 0)
142 range->max_rts = 2347;
143
144 range->min_frag = 256;
145
146 if (wl_ioctl(dev, WLC_GET_FRAG, &range->max_frag, sizeof(int)) < 0)
147 range->max_frag = 2346;
148
149 range->txpower_capa = IW_TXPOW_MWATT;
150
151 return 0;
152 }
153
154
155 static int wlcompat_set_scan(struct net_device *dev,
156 struct iw_request_info *info,
157 union iwreq_data *wrqu,
158 char *extra)
159 {
160 int ap = 0, oldap = 0;
161 wl_scan_params_t params;
162
163 memset(&params, 0, sizeof(params));
164
165 /* use defaults (same parameters as wl scan) */
166 memset(&params.bssid, 0xff, sizeof(params.bssid));
167 params.bss_type = DOT11_BSSTYPE_ANY;
168 params.scan_type = -1;
169 params.nprobes = -1;
170 params.active_time = -1;
171 params.passive_time = -1;
172 params.home_time = -1;
173
174 /* can only scan in STA mode */
175 wl_ioctl(dev, WLC_GET_AP, &oldap, sizeof(oldap));
176 if (oldap > 0)
177 wl_ioctl(dev, WLC_SET_AP, &ap, sizeof(ap));
178
179 if (wl_ioctl(dev, WLC_SCAN, &params, 64) < 0)
180 return -EINVAL;
181
182 if (oldap > 0)
183 wl_ioctl(dev, WLC_SET_AP, &oldap, sizeof(oldap));
184
185 return 0;
186 }
187
188
189 static int wlcompat_get_scan(struct net_device *dev,
190 struct iw_request_info *info,
191 union iwreq_data *wrqu,
192 char *extra)
193 {
194 wl_scan_results_t *results = (wl_scan_results_t *) buf;
195 wl_bss_info_t *bss_info;
196 char *info_ptr;
197 char *current_ev = extra;
198 char *current_val;
199 char *end_buf = extra + IW_SCAN_MAX_DATA;
200 struct iw_event iwe;
201 int i, j;
202
203 if (wl_ioctl(dev, WLC_SCAN_RESULTS, buf, WLC_IOCTL_MAXLEN) < 0)
204 return -EAGAIN;
205
206 bss_info = &(results->bss_info[0]);
207 info_ptr = (char *) bss_info;
208 for (i = 0; i < results->count; i++) {
209
210 /* send the cell address (must be sent first) */
211 iwe.cmd = SIOCGIWAP;
212 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
213 memcpy(&iwe.u.ap_addr.sa_data, &bss_info->BSSID, sizeof(bss_info->BSSID));
214 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
215
216 /* send the ESSID */
217 iwe.cmd = SIOCGIWESSID;
218 iwe.u.data.length = bss_info->SSID_len;
219 if (iwe.u.data.length > IW_ESSID_MAX_SIZE)
220 iwe.u.data.length = IW_ESSID_MAX_SIZE;
221 iwe.u.data.flags = 1;
222 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, bss_info->SSID);
223
224 /* send frequency/channel info */
225 iwe.cmd = SIOCGIWFREQ;
226 iwe.u.freq.e = 0;
227 iwe.u.freq.m = bss_info->channel;
228 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
229
230 /* add quality statistics */
231 iwe.cmd = IWEVQUAL;
232 iwe.u.qual.level = bss_info->RSSI;
233 iwe.u.qual.noise = bss_info->phy_noise;
234 iwe.u.qual.qual = 0;
235 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
236
237 /* send rate information */
238 iwe.cmd = SIOCGIWRATE;
239 current_val = current_ev + IW_EV_LCP_LEN;
240 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
241
242 for(j = 0 ; j < bss_info->rateset.count ; j++) {
243 iwe.u.bitrate.value = ((bss_info->rateset.rates[j] & 0x7f) * 500000);
244 current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
245 }
246 if((current_val - current_ev) > IW_EV_LCP_LEN)
247 current_ev = current_val;
248
249 info_ptr += sizeof(wl_bss_info_t);
250 if (bss_info->ie_length % 4)
251 info_ptr += bss_info->ie_length + 4 - (bss_info->ie_length % 4);
252 else
253 info_ptr += bss_info->ie_length;
254 bss_info = (wl_bss_info_t *) info_ptr;
255 }
256
257 wrqu->data.length = (current_ev - extra);
258 wrqu->data.flags = 0;
259
260 return 0;
261 }
262
263 static int wlcompat_ioctl(struct net_device *dev,
264 struct iw_request_info *info,
265 union iwreq_data *wrqu,
266 char *extra)
267 {
268 switch (info->cmd) {
269 case SIOCGIWNAME:
270 strcpy(wrqu->name, "IEEE 802.11-DS");
271 break;
272 case SIOCGIWFREQ:
273 {
274 channel_info_t ci;
275
276 if (wl_ioctl(dev,WLC_GET_CHANNEL, &ci, sizeof(ci)) < 0)
277 return -EINVAL;
278
279 wrqu->freq.m = ci.target_channel;
280 wrqu->freq.e = 0;
281 break;
282 }
283 case SIOCSIWFREQ:
284 {
285 if (wrqu->freq.e == 1) {
286 int channel = 0;
287 int f = wrqu->freq.m / 100000;
288 while ((channel < NUM_CHANNELS + 1) && (f != channel_frequency[channel]))
289 channel++;
290
291 if (channel == NUM_CHANNELS) // channel not found
292 return -EINVAL;
293
294 wrqu->freq.e = 0;
295 wrqu->freq.m = channel + 1;
296 }
297 if ((wrqu->freq.e == 0) && (wrqu->freq.m < 1000)) {
298 if (wl_ioctl(dev, WLC_SET_CHANNEL, &wrqu->freq.m, sizeof(int)) < 0)
299 return -EINVAL;
300 } else {
301 return -EINVAL;
302 }
303 break;
304 }
305 case SIOCGIWAP:
306 {
307 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
308 if (wl_ioctl(dev,WLC_GET_BSSID,wrqu->ap_addr.sa_data,6) < 0)
309 return -EINVAL;
310 break;
311 }
312 case SIOCGIWESSID:
313 {
314 wlc_ssid_t ssid;
315
316 if (wl_ioctl(dev,WLC_GET_SSID, &ssid, sizeof(wlc_ssid_t)) < 0)
317 return -EINVAL;
318
319 wrqu->essid.flags = wrqu->data.flags = 1;
320 wrqu->essid.length = wrqu->data.length = ssid.SSID_len + 1;
321 memcpy(extra,ssid.SSID,ssid.SSID_len + 1);
322 break;
323 }
324 case SIOCSIWESSID:
325 {
326 wlc_ssid_t ssid;
327 memset(&ssid, 0, sizeof(ssid));
328 ssid.SSID_len = strlen(extra);
329 if (ssid.SSID_len > WLC_ESSID_MAX_SIZE)
330 ssid.SSID_len = WLC_ESSID_MAX_SIZE;
331 memcpy(ssid.SSID, extra, ssid.SSID_len);
332 if (wl_ioctl(dev, WLC_SET_SSID, &ssid, sizeof(ssid)) < 0)
333 return -EINVAL;
334 break;
335 }
336 case SIOCGIWRTS:
337 {
338 if (wl_ioctl(dev,WLC_GET_RTS,&(wrqu->rts.value),sizeof(int)) < 0)
339 return -EINVAL;
340 break;
341 }
342 case SIOCSIWRTS:
343 {
344 if (wl_ioctl(dev,WLC_SET_RTS,&(wrqu->rts.value),sizeof(int)) < 0)
345 return -EINVAL;
346 break;
347 }
348 case SIOCGIWFRAG:
349 {
350 if (wl_ioctl(dev,WLC_GET_FRAG,&(wrqu->frag.value),sizeof(int)) < 0)
351 return -EINVAL;
352 break;
353 }
354 case SIOCSIWFRAG:
355 {
356 if (wl_ioctl(dev,WLC_SET_FRAG,&(wrqu->frag.value),sizeof(int)) < 0)
357 return -EINVAL;
358 break;
359 }
360 case SIOCGIWTXPOW:
361 {
362 if (wl_get_val(dev, "qtxpower", &(wrqu->txpower.value), sizeof(int)) < 0)
363 return -EINVAL;
364
365 wrqu->txpower.value &= ~WL_TXPWR_OVERRIDE;
366
367 wrqu->txpower.fixed = 0;
368 wrqu->txpower.disabled = 0;
369 wrqu->txpower.flags = IW_TXPOW_MWATT;
370 break;
371 }
372 case SIOCSIWTXPOW:
373 {
374 int override;
375
376 if (wl_get_val(dev, "qtxpower", &override, sizeof(int)) < 0)
377 return -EINVAL;
378
379 wrqu->txpower.value |= override & WL_TXPWR_OVERRIDE;
380
381 if (wrqu->txpower.flags != IW_TXPOW_MWATT)
382 return -EINVAL;
383
384 if (wl_set_val(dev, "qtxpower", &wrqu->txpower.value, sizeof(int)) < 0)
385 return -EINVAL;
386 }
387 case SIOCGIWENCODE:
388 {
389 int val = 0;
390 if (wl_ioctl(dev, WLC_GET_WEP, &val, sizeof(val)) < 0)
391 return -EINVAL;
392
393 if (val > 0) {
394 wrqu->data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
395 } else {
396 wrqu->data.flags = IW_ENCODE_DISABLED;
397 }
398
399
400
401 break;
402 }
403 case SIOCGIWRANGE:
404 {
405 return wlcompat_ioctl_getiwrange(dev, extra);
406 break;
407 }
408 case SIOCSIWMODE:
409 {
410 int ap = -1, infra = -1, passive = 0, wet = 0;
411
412 switch (wrqu->mode) {
413 case IW_MODE_MONITOR:
414 passive = 1;
415 break;
416 case IW_MODE_ADHOC:
417 infra = 0;
418 ap = 0;
419 break;
420 case IW_MODE_MASTER:
421 infra = 1;
422 ap = 1;
423 break;
424 case IW_MODE_INFRA:
425 infra = 1;
426 ap = 0;
427 break;
428 case IW_MODE_REPEAT:
429 infra = 1;
430 ap = 0;
431 wet = 1;
432 break;
433 default:
434 return -EINVAL;
435 }
436
437 if (wl_ioctl(dev, WLC_SET_PASSIVE, &passive, sizeof(passive)) < 0)
438 return -EINVAL;
439 if (wl_ioctl(dev, WLC_SET_MONITOR, &passive, sizeof(passive)) < 0)
440 return -EINVAL;
441 if (wl_ioctl(dev, WLC_SET_WET, &wet, sizeof(wet)) < 0)
442 return -EINVAL;
443 if (ap >= 0)
444 if (wl_ioctl(dev, WLC_SET_AP, &ap, sizeof(ap)) < 0)
445 return -EINVAL;
446 if (infra >= 0)
447 if (wl_ioctl(dev, WLC_SET_INFRA, &infra, sizeof(infra)) < 0)
448 return -EINVAL;
449
450 break;
451
452 }
453 case SIOCGIWMODE:
454 {
455 int ap, infra, wet, passive;
456
457 if (wl_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap)) < 0)
458 return -EINVAL;
459 if (wl_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra)) < 0)
460 return -EINVAL;
461 if (wl_ioctl(dev, WLC_GET_PASSIVE, &passive, sizeof(passive)) < 0)
462 return -EINVAL;
463 if (wl_ioctl(dev, WLC_GET_WET, &wet, sizeof(wet)) < 0)
464 return -EINVAL;
465
466 if (passive) {
467 wrqu->mode = IW_MODE_MONITOR;
468 } else if (!infra) {
469 wrqu->mode = IW_MODE_ADHOC;
470 } else {
471 if (ap) {
472 wrqu->mode = IW_MODE_MASTER;
473 } else {
474 if (wet) {
475 wrqu->mode = IW_MODE_REPEAT;
476 } else {
477 wrqu->mode = IW_MODE_INFRA;
478 }
479 }
480 }
481 break;
482 }
483 default:
484 {
485 if (info->cmd >= SIOCIWFIRSTPRIV)
486 return wlcompat_private_ioctl(dev, info, wrqu, extra);
487
488 return -EINVAL;
489 }
490 }
491
492 return 0;
493 }
494
495 static const iw_handler wlcompat_handler[] = {
496 NULL, /* SIOCSIWCOMMIT */
497 wlcompat_ioctl, /* SIOCGIWNAME */
498 NULL, /* SIOCSIWNWID */
499 NULL, /* SIOCGIWNWID */
500 wlcompat_ioctl, /* SIOCSIWFREQ */
501 wlcompat_ioctl, /* SIOCGIWFREQ */
502 wlcompat_ioctl, /* SIOCSIWMODE */
503 wlcompat_ioctl, /* SIOCGIWMODE */
504 NULL, /* SIOCSIWSENS */
505 NULL, /* SIOCGIWSENS */
506 NULL, /* SIOCSIWRANGE, unused */
507 wlcompat_ioctl, /* SIOCGIWRANGE */
508 NULL, /* SIOCSIWPRIV */
509 NULL, /* SIOCGIWPRIV */
510 NULL, /* SIOCSIWSTATS */
511 NULL, /* SIOCGIWSTATS */
512 iw_handler_set_spy, /* SIOCSIWSPY */
513 iw_handler_get_spy, /* SIOCGIWSPY */
514 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
515 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
516 NULL, /* SIOCSIWAP */
517 wlcompat_ioctl, /* SIOCGIWAP */
518 NULL, /* -- hole -- */
519 NULL, /* SIOCGIWAPLIST */
520 wlcompat_set_scan, /* SIOCSIWSCAN */
521 wlcompat_get_scan, /* SIOCGIWSCAN */
522 wlcompat_ioctl, /* SIOCSIWESSID */
523 wlcompat_ioctl, /* SIOCGIWESSID */
524 NULL, /* SIOCSIWNICKN */
525 NULL, /* SIOCGIWNICKN */
526 NULL, /* -- hole -- */
527 NULL, /* -- hole -- */
528 NULL, /* SIOCSIWRATE */
529 NULL, /* SIOCGIWRATE */
530 wlcompat_ioctl, /* SIOCSIWRTS */
531 wlcompat_ioctl, /* SIOCGIWRTS */
532 wlcompat_ioctl, /* SIOCSIWFRAG */
533 wlcompat_ioctl, /* SIOCGIWFRAG */
534 wlcompat_ioctl, /* SIOCSIWTXPOW */
535 wlcompat_ioctl, /* SIOCGIWTXPOW */
536 NULL, /* SIOCSIWRETRY */
537 NULL, /* SIOCGIWRETRY */
538 NULL, /* SIOCSIWENCODE */
539 wlcompat_ioctl, /* SIOCGIWENCODE */
540 };
541
542 #define PRIV_SET_MONITOR SIOCIWFIRSTPRIV + 0
543 #define PRIV_GET_MONITOR SIOCIWFIRSTPRIV + 1
544 #define PRIV_SET_TXPWR_LIMIT SIOCIWFIRSTPRIV + 2
545 #define PRIV_GET_TXPWR_LIMIT SIOCIWFIRSTPRIV + 3
546
547 static const struct iw_priv_args wlcompat_private_args[] =
548 {
549 { PRIV_SET_MONITOR,
550 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
551 0,
552 "set_monitor"
553 },
554 { PRIV_GET_MONITOR,
555 0,
556 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
557 "get_monitor"
558 },
559 { PRIV_SET_TXPWR_LIMIT,
560 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
561 0,
562 "set_txpwr_limit"
563 },
564 { PRIV_GET_TXPWR_LIMIT,
565 0,
566 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
567 "get_txpwr_limit"
568 }
569 };
570
571 static int wlcompat_private_ioctl(struct net_device *dev,
572 struct iw_request_info *info,
573 union iwreq_data *wrqu,
574 char *extra)
575 {
576 int *value = (int *) wrqu->name;
577
578 switch (info->cmd) {
579 case PRIV_SET_MONITOR:
580 {
581 if (wl_ioctl(dev, WLC_SET_MONITOR, value, sizeof(int)) < 0)
582 return -EINVAL;
583
584 break;
585 }
586 case PRIV_GET_MONITOR:
587 {
588 if (wl_ioctl(dev, WLC_GET_MONITOR, extra, sizeof(int)) < 0)
589 return -EINVAL;
590
591 break;
592 }
593 case PRIV_SET_TXPWR_LIMIT:
594 {
595 int val;
596
597
598 if (wl_get_val(dev, "qtxpower", &val, sizeof(int)) < 0)
599 return -EINVAL;
600
601 if (*extra > 0)
602 val |= WL_TXPWR_OVERRIDE;
603 else
604 val &= ~WL_TXPWR_OVERRIDE;
605
606 if (wl_set_val(dev, "qtxpower", &val, sizeof(int)) < 0)
607 return -EINVAL;
608
609 break;
610 }
611 case PRIV_GET_TXPWR_LIMIT:
612 {
613 if (wl_get_val(dev, "qtxpower", value, sizeof(int)) < 0)
614 return -EINVAL;
615
616 *value = ((*value & WL_TXPWR_OVERRIDE) == WL_TXPWR_OVERRIDE ? 1 : 0);
617
618 break;
619 }
620 default:
621 {
622 return -EINVAL;
623 }
624
625 }
626 return 0;
627 }
628
629
630 static const iw_handler wlcompat_private[] =
631 {
632 wlcompat_private_ioctl,
633 wlcompat_private_ioctl,
634 wlcompat_private_ioctl,
635 wlcompat_private_ioctl
636 };
637
638
639 static const struct iw_handler_def wlcompat_handler_def =
640 {
641 .standard = (iw_handler *) wlcompat_handler,
642 .num_standard = sizeof(wlcompat_handler)/sizeof(iw_handler),
643 .private = wlcompat_private,
644 .num_private = sizeof(wlcompat_private)/sizeof(iw_handler),
645 .private_args = wlcompat_private_args,
646 .num_private_args = sizeof(wlcompat_private_args)/sizeof(struct iw_priv_args),
647 };
648
649
650 #ifdef DEBUG
651 static int (*old_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);
652 void print_buffer(int len, unsigned char *buf) {
653 int x;
654 if (buf != NULL) {
655 for (x=0;x<len && x<180 ;x++) {
656 if ((x % 4) == 0)
657 printk(" ");
658 printk("%02X",buf[x]);
659 }
660 } else {
661 printk(" NULL");
662 }
663 printk("\n");
664
665 }
666 static int new_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {
667 int ret = 0;
668 printk("dev: %s ioctl: 0x%04x\n",dev->name,cmd);
669 if (cmd==SIOCDEVPRIVATE) {
670 wl_ioctl_t *ioc = (wl_ioctl_t *)ifr->ifr_data;
671 unsigned char *buf = ioc->buf;
672 printk(" cmd: %d buf: 0x%08x len: %d\n",ioc->cmd,&(ioc->buf),ioc->len);
673 printk(" send: ->");
674 print_buffer(ioc->len, buf);
675 ret = old_ioctl(dev,ifr,cmd);
676 printk(" recv: ->");
677 print_buffer(ioc->len, buf);
678 printk(" ret: %d\n", ret);
679 } else {
680 ret = old_ioctl(dev,ifr,cmd);
681 }
682 return ret;
683 }
684 #endif
685
686 static int __init wlcompat_init()
687 {
688 dev = dev_get_by_name("eth1");
689 #ifdef DEBUG
690 old_ioctl = dev->do_ioctl;
691 dev->do_ioctl = new_ioctl;
692 #endif
693 dev->wireless_handlers = (struct iw_handler_def *)&wlcompat_handler_def;
694 return 0;
695 }
696
697 static void __exit wlcompat_exit()
698 {
699 dev->wireless_handlers = NULL;
700 #ifdef DEBUG
701 dev->do_ioctl = old_ioctl;
702 #endif
703 return;
704 }
705
706 EXPORT_NO_SYMBOLS;
707 MODULE_AUTHOR("openwrt.org");
708 MODULE_LICENSE("GPL");
709
710 module_init(wlcompat_init);
711 module_exit(wlcompat_exit);
This page took 0.070884 seconds and 5 git commands to generate.