42
res = miniport_query_info(handle, OID_802_11_RSSI, &rssi,
42
res = miniport_query_info(wd, OID_802_11_RSSI, &rssi, sizeof(rssi));
45
44
p += sprintf(p, "signal_level=%d dBm\n", (s32)rssi);
47
res = miniport_query_info(handle, OID_802_11_STATISTICS,
46
res = miniport_query_info(wd, OID_802_11_STATISTICS,
48
47
&stats, sizeof(stats));
91
res = miniport_query_info(handle, OID_802_11_BSSID,
90
res = miniport_query_info(wd, OID_802_11_BSSID,
92
91
&ap_address, sizeof(ap_address));
94
93
memset(ap_address, 0, ETH_ALEN);
97
96
p += sprintf(p, ":%2.2X", ap_address[i]);
98
97
p += sprintf(p, "\n");
100
res = miniport_query_info(handle, OID_802_11_SSID, &essid,
99
res = miniport_query_info(wd, OID_802_11_SSID, &essid,
103
102
essid.essid[essid.length] = '\0';
104
103
p += sprintf(p, "essid=%s\n", essid.essid);
107
res = miniport_query_int(handle, OID_802_11_ENCRYPTION_STATUS,
106
res = miniport_query_int(wd, OID_802_11_ENCRYPTION_STATUS,
109
res |= miniport_query_int(handle, OID_802_11_AUTHENTICATION_MODE,
108
res |= miniport_query_int(wd, OID_802_11_AUTHENTICATION_MODE,
113
int t = handle->encr_info.tx_key_index;
114
p += sprintf(p, "tx_key=%u\n", handle->encr_info.tx_key_index);
112
int t = wd->encr_info.tx_key_index;
113
p += sprintf(p, "tx_key=%u\n", wd->encr_info.tx_key_index);
115
114
p += sprintf(p, "key=");
116
if (handle->encr_info.keys[t].length > 0)
115
if (wd->encr_info.keys[t].length > 0)
117
116
for (i = 0; i < NDIS_ENCODING_TOKEN_MAX &&
118
i < handle->encr_info.keys[t].length;
117
i < wd->encr_info.keys[t].length;
120
119
p += sprintf(p, "%2.2X",
121
handle->encr_info.keys[t].key[i]);
120
wd->encr_info.keys[t].key[i]);
123
122
p += sprintf(p, "off");
124
123
p += sprintf(p, "\n");
127
126
p += sprintf(p, "auth_mode=%d\n", auth_mode);
130
res = miniport_query_int(handle, OID_802_11_INFRASTRUCTURE_MODE,
129
res = miniport_query_int(wd, OID_802_11_INFRASTRUCTURE_MODE,
132
131
p += sprintf(p, "mode=%s\n", (infra_mode == Ndis802_11IBSS) ?
133
132
"adhoc" : (infra_mode == Ndis802_11Infrastructure) ?
163
res = miniport_query_info(handle, OID_802_11_CONFIGURATION,
162
res = miniport_query_info(wd, OID_802_11_CONFIGURATION,
164
163
&config, sizeof(config));
166
165
p += sprintf(p, "beacon_period=%u msec\n",
175
174
config.fh_config.dwell_time);
178
res = miniport_query_info(handle, OID_802_11_TX_POWER_LEVEL,
177
res = miniport_query_info(wd, OID_802_11_TX_POWER_LEVEL,
179
178
&tx_power, sizeof(tx_power));
181
180
p += sprintf(p, "tx_power=%u mW\n", tx_power);
183
res = miniport_query_info(handle, OID_GEN_LINK_SPEED,
182
res = miniport_query_info(wd, OID_GEN_LINK_SPEED,
184
183
&bit_rate, sizeof(bit_rate));
186
185
p += sprintf(p, "bit_rate=%u kBps\n", (u32)bit_rate / 10);
188
res = miniport_query_info(handle, OID_802_11_RTS_THRESHOLD,
187
res = miniport_query_info(wd, OID_802_11_RTS_THRESHOLD,
189
188
&rts_threshold, sizeof(rts_threshold));
191
190
p += sprintf(p, "rts_threshold=%u bytes\n", rts_threshold);
193
res = miniport_query_info(handle, OID_802_11_FRAGMENTATION_THRESHOLD,
192
res = miniport_query_info(wd, OID_802_11_FRAGMENTATION_THRESHOLD,
194
193
&frag_threshold, sizeof(frag_threshold));
196
195
p += sprintf(p, "frag_threshold=%u bytes\n", frag_threshold);
198
res = miniport_query_int(handle, OID_802_11_POWER_MODE, &power_mode);
197
res = miniport_query_int(wd, OID_802_11_POWER_MODE, &power_mode);
200
199
p += sprintf(p, "power_mode=%s\n",
201
200
(power_mode == NDIS_POWER_OFF) ?
203
202
(power_mode == NDIS_POWER_MAX) ?
204
203
"max_savings" : "min_savings");
206
res = miniport_query_info(handle, OID_802_11_NUMBER_OF_ANTENNAS,
205
res = miniport_query_info(wd, OID_802_11_NUMBER_OF_ANTENNAS,
207
206
&antenna, sizeof(antenna));
209
208
p += sprintf(p, "num_antennas=%u\n", antenna);
211
res = miniport_query_info(handle, OID_802_11_TX_ANTENNA_SELECTED,
210
res = miniport_query_info(wd, OID_802_11_TX_ANTENNA_SELECTED,
212
211
&antenna, sizeof(antenna));
214
213
p += sprintf(p, "tx_antenna=%u\n", antenna);
216
res = miniport_query_info(handle, OID_802_11_RX_ANTENNA_SELECTED,
215
res = miniport_query_info(wd, OID_802_11_RX_ANTENNA_SELECTED,
217
216
&antenna, sizeof(antenna));
219
218
p += sprintf(p, "rx_antenna=%u\n", antenna);
220
p += sprintf(p, "encryption_modes=%s%s%s%s%s%s%s\n",
221
test_bit(Ndis802_11Encryption1Enabled, &wd->capa.encr) ?
224
test_bit(Ndis802_11Encryption2Enabled, &wd->capa.encr) ?
225
"; TKIP with WPA" : "",
226
test_bit(Ndis802_11AuthModeWPA2, &wd->capa.auth) ?
228
test_bit(Ndis802_11AuthModeWPA2PSK, &wd->capa.auth) ?
231
test_bit(Ndis802_11Encryption3Enabled, &wd->capa.encr) ?
232
"; AES/CCMP with WPA" : "",
233
test_bit(Ndis802_11AuthModeWPA2, &wd->capa.auth) ?
235
test_bit(Ndis802_11AuthModeWPA2PSK, &wd->capa.auth) ?
221
238
if (p - page > count) {
222
239
WARNING("wrote %lu bytes (limit is %u)",
223
240
(unsigned long)(p - page), count);
242
259
p += sprintf(p, "hangcheck_interval=%d\n",
243
(int)(handle->hangcheck_interval / HZ));
260
(int)(wd->hangcheck_interval / HZ));
245
list_for_each_entry(setting, &handle->device->settings, list) {
262
list_for_each_entry(setting, &wd->ndis_device->settings, list) {
246
263
p += sprintf(p, "%s=%s\n", setting->name, setting->value);
252
269
static int procfs_write_settings(struct file *file, const char *buf,
253
270
unsigned long count, void *data)
255
struct ndis_handle *handle = (struct ndis_handle *)data;
272
struct wrapper_dev *wd = (struct wrapper_dev *)data;
256
273
char setting[MAX_PROC_STR_LEN], *p;
258
275
if (count > MAX_PROC_STR_LEN)
277
294
i = simple_strtol(p, NULL, 10);
278
hangcheck_del(handle);
279
handle->hangcheck_interval = i * HZ;
280
hangcheck_add(handle);
296
wd->hangcheck_interval = i * HZ;
298
} else if (!strcmp(setting, "check_capa")) {
300
printk(KERN_INFO "%s: encryption modes supported: %s%s%s%s%s%s%s\n",
302
test_bit(Ndis802_11Encryption1Enabled, &wd->capa.encr) ?
305
test_bit(Ndis802_11Encryption2Enabled, &wd->capa.encr) ?
306
"; TKIP with WPA" : "",
307
test_bit(Ndis802_11AuthModeWPA2, &wd->capa.auth) ?
309
test_bit(Ndis802_11AuthModeWPA2PSK, &wd->capa.auth) ?
312
test_bit(Ndis802_11Encryption3Enabled, &wd->capa.encr) ?
313
"; AES/CCMP with WPA" : "",
314
test_bit(Ndis802_11AuthModeWPA2, &wd->capa.auth) ?
316
test_bit(Ndis802_11AuthModeWPA2PSK, &wd->capa.auth) ?
281
318
} else if (!strcmp(setting, "suspend")) {
287
324
i = simple_strtol(p, NULL, 10);
288
325
if (i <= 0 || i > 3)
290
if (handle->device->bustype == NDIS_PCI_BUS)
291
ndiswrapper_suspend_pci(handle->dev.pci, i);
327
if (wd->ndis_device->bustype == NDIS_PCI_BUS)
328
ndiswrapper_suspend_pci(wd->dev.pci, PMSG_SUSPEND);
329
#if defined(CONFIG_USB) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
330
else if (wd->ndis_device->bustype == NDIS_USB_BUS)
331
ndiswrapper_suspend_usb(wd->dev.usb.intf,
292
336
} else if (!strcmp(setting, "resume")) {
293
if (handle->device->bustype == NDIS_PCI_BUS)
294
ndiswrapper_resume_pci(handle->dev.pci);
337
if (wd->ndis_device->bustype == NDIS_PCI_BUS)
338
ndiswrapper_resume_pci(wd->dev.pci);
339
#if defined(CONFIG_USB) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
340
else if (wd->ndis_device->bustype == NDIS_USB_BUS)
341
ndiswrapper_resume_usb(wd->dev.usb.intf);
295
345
} else if (!strcmp(setting, "reinit")) {
296
if (ndis_reinit(handle))
349
} else if (!strcmp(setting, "irp")) {
351
struct io_stack_location *irp_sl;
353
int major_fn, minor_fn, n;
354
struct device_object *dev;
358
n = sscanf(p, "%d,%d,%x", &major_fn, &minor_fn, (int *)&dev);
359
DBGTRACE1("n = %d, mj = %d, mn = %d, dev = %p", n, major_fn,
363
irp = IoAllocateIrp(dev->stack_size, FALSE);
364
DBGTRACE1("stack size: %d, irp = %p", dev->stack_size, irp);
365
DBGTRACE1("drv_obj: %p", dev->drv_obj);
366
irp_sl = IoGetNextIrpStackLocation(irp);
367
irp_sl->major_fn = major_fn;
368
irp_sl->minor_fn = minor_fn;
369
irp->io_status.status = STATUS_NOT_SUPPORTED;
371
status = IoCallDriver(dev, irp);
372
DBGTRACE1("status = %d", status);
298
374
} else if (!strcmp(setting, "power_profile")) {
300
376
struct miniport_char *miniport;
318
394
profile_inf = NdisPowerProfileBattery;
320
miniport->pnp_event_notify(handle->adapter_ctx,
396
miniport->pnp_event_notify(wd->nmb->adapter_ctx,
321
397
NdisDevicePnPEventPowerProfileChanged,
322
398
&profile_inf, sizeof(profile_inf));
323
399
} else if (!strcmp(setting, "auth_mode")) {
342
418
if (i <= 0 || i > 7)
345
if (set_encr_mode(handle, i))
421
if (set_encr_mode(wd, i))
423
} else if (!strcmp(setting, "stats_enabled")) {
429
i = simple_strtol(p, NULL, 10);
431
wd->stats_enabled = TRUE;
433
wd->stats_enabled = FALSE;
434
} else if (!strcmp(setting, "tx_antenna")) {
435
ndis_antenna antenna;
442
i = simple_strtol(p, NULL, 16);
443
res = miniport_query_info(wd, OID_802_11_NUMBER_OF_ANTENNAS,
444
&antenna, sizeof(antenna));
447
if (i >= -1 && i < antenna)
449
res = miniport_set_info(wd, OID_802_11_TX_ANTENNA_SELECTED,
450
&antenna, sizeof(antenna));
453
} else if (!strcmp(setting, "rx_antenna")) {
454
ndis_antenna antenna;
461
i = simple_strtol(p, NULL, 16);
462
res = miniport_query_info(wd, OID_802_11_NUMBER_OF_ANTENNAS,
463
&antenna, sizeof(antenna));
466
if (i >= -1 && i < antenna)
468
res = miniport_set_info(wd, OID_802_11_RX_ANTENNA_SELECTED,
469
&antenna, sizeof(antenna));
352
477
TRACEEXIT1(return -EINVAL);
354
479
DBGTRACE1("name='%s', value='%s'\n", setting, p);
355
list_for_each_entry(dev_setting, &handle->device->settings,
480
list_for_each_entry(dev_setting, &wd->ndis_device->settings,
357
482
struct ndis_config_param *param;
483
struct unicode_string *ustring;
359
485
param = &dev_setting->config_param;
360
486
if (!stricmp(dev_setting->name, setting)) {
363
489
memset(dev_setting->value, 0,
364
490
MAX_NDIS_SETTING_VALUE_LEN);
365
491
memcpy(dev_setting->value, p, strlen(p));
492
ustring = ¶m->data.ustring;
366
493
if (param->type == NDIS_CONFIG_PARAM_STRING)
367
RtlFreeUnicodeString(¶m->data.ustring);
494
RtlFreeUnicodeString(ustring);
368
495
param->type = NDIS_CONFIG_PARAM_NONE;
380
int ndiswrapper_procfs_add_iface(struct ndis_handle *handle)
507
int ndiswrapper_procfs_add_iface(struct wrapper_dev *wd)
382
struct net_device *dev = handle->net_dev;
509
struct net_device *dev = wd->net_dev;
383
510
struct proc_dir_entry *proc_iface, *procfs_entry;
385
handle->procfs_iface = NULL;
512
wd->procfs_iface = NULL;
386
513
if (ndiswrapper_procfs_entry == NULL)
389
516
proc_iface = proc_mkdir(dev->name, ndiswrapper_procfs_entry);
391
handle->procfs_iface = proc_iface;
518
wd->procfs_iface = proc_iface;
393
520
if (proc_iface == NULL) {
394
ERROR("%s", "Couldn't create proc directory");
521
ERROR("couldn't create proc directory");
397
524
proc_iface->uid = proc_uid;
400
527
procfs_entry = create_proc_entry("hw", S_IFREG | S_IRUSR | S_IRGRP,
402
529
if (procfs_entry == NULL) {
403
ERROR("%s", "Couldn't create proc entry for 'hw'");
530
ERROR("couldn't create proc entry for 'hw'");
406
533
procfs_entry->uid = proc_uid;
407
534
procfs_entry->gid = proc_gid;
408
procfs_entry->data = handle;
535
procfs_entry->data = wd;
409
536
procfs_entry->read_proc = procfs_read_hw;
412
539
procfs_entry = create_proc_entry("stats", S_IFREG | S_IRUSR | S_IRGRP,
414
541
if (procfs_entry == NULL) {
415
ERROR("%s", "Couldn't create proc entry for 'stats'");
542
ERROR("couldn't create proc entry for 'stats'");
418
545
procfs_entry->uid = proc_uid;
419
546
procfs_entry->gid = proc_gid;
420
procfs_entry->data = handle;
547
procfs_entry->data = wd;
421
548
procfs_entry->read_proc = procfs_read_stats;
424
551
procfs_entry = create_proc_entry("encr", S_IFREG | S_IRUSR | S_IRGRP,
426
553
if (procfs_entry == NULL) {
427
ERROR("%s", "Couldn't create proc entry for 'encr'");
554
ERROR("couldn't create proc entry for 'encr'");
430
557
procfs_entry->uid = proc_uid;
431
558
procfs_entry->gid = proc_gid;
432
procfs_entry->data = handle;
559
procfs_entry->data = wd;
433
560
procfs_entry->read_proc = procfs_read_encr;
437
564
S_IRUSR | S_IRGRP |
438
565
S_IWUSR | S_IWGRP, proc_iface);
439
566
if (procfs_entry == NULL) {
440
ERROR("%s", "Couldn't create proc entry for 'settings'");
567
ERROR("couldn't create proc entry for 'settings'");
443
570
procfs_entry->uid = proc_uid;
444
571
procfs_entry->gid = proc_gid;
445
procfs_entry->data = handle;
572
procfs_entry->data = wd;
446
573
procfs_entry->read_proc = procfs_read_settings;
447
574
procfs_entry->write_proc = procfs_write_settings;
452
void ndiswrapper_procfs_remove_iface(struct ndis_handle *handle)
579
void ndiswrapper_procfs_remove_iface(struct wrapper_dev *wd)
454
struct net_device *dev = handle->net_dev;
455
struct proc_dir_entry *procfs_iface = handle->procfs_iface;
581
struct net_device *dev = wd->net_dev;
582
struct proc_dir_entry *procfs_iface = wd->procfs_iface;
457
584
if (procfs_iface == NULL)
462
589
remove_proc_entry("settings", procfs_iface);
463
590
if (ndiswrapper_procfs_entry != NULL)
464
591
remove_proc_entry(dev->name, ndiswrapper_procfs_entry);
465
handle->procfs_iface = NULL;
592
wd->procfs_iface = NULL;
468
595
static int procfs_read_debug(char *page, char **start, off_t off,
483
610
static int procfs_write_debug(struct file *file, const char *buf,
484
611
unsigned long count, void *data)
486
char debug_level[MAX_PROC_STR_LEN];
614
char setting[MAX_PROC_STR_LEN], *p;
489
616
if (count > MAX_PROC_STR_LEN)
492
memset(debug_level, 0, sizeof(debug_level));
493
if (copy_from_user(debug_level, buf, count))
619
memset(setting, 0, sizeof(setting));
620
if (copy_from_user(setting, buf, count))
496
i = simple_strtol(debug_level, NULL, 10);
497
#if defined(DEBUG) && DEBUG > 0
498
if (i < 0 || i > DEBUG)
623
if ((p = strchr(setting, '\n')))
626
if ((p = strchr(setting, '=')))
629
i = simple_strtol(setting, NULL, 10);
630
if (i >= 0 && i < 10)