~ubuntu-branches/ubuntu/lucid/ndiswrapper/lucid

« back to all changes in this revision

Viewing changes to driver/proc.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2005-11-16 23:39:48 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051116233948-00yddqygl6w65vzg
Tags: 1.5-1ubuntu1
Resynchronise with Debian.  (Totally me!)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
                             int count, int *eof, void *data)
30
30
{
31
31
        char *p = page;
32
 
        struct ndis_handle *handle = (struct ndis_handle *) data;
 
32
        struct wrapper_dev *wd = (struct wrapper_dev *)data;
33
33
        struct ndis_wireless_stats stats;
34
34
        NDIS_STATUS res;
35
35
        ndis_rssi rssi;
39
39
                return 0;
40
40
        }
41
41
 
42
 
        res = miniport_query_info(handle, OID_802_11_RSSI, &rssi,
43
 
                                  sizeof(rssi));
 
42
        res = miniport_query_info(wd, OID_802_11_RSSI, &rssi, sizeof(rssi));
44
43
        if (!res)
45
44
                p += sprintf(p, "signal_level=%d dBm\n", (s32)rssi);
46
45
 
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));
49
48
        if (!res) {
50
49
 
77
76
                            int count, int *eof, void *data)
78
77
{
79
78
        char *p = page;
80
 
        struct ndis_handle *handle = (struct ndis_handle *) data;
 
79
        struct wrapper_dev *wd = (struct wrapper_dev *)data;
81
80
        int i, encr_status, auth_mode, infra_mode;
82
81
        NDIS_STATUS res;
83
82
        struct ndis_essid essid;
88
87
                return 0;
89
88
        }
90
89
 
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));
93
92
        if (res)
94
93
                memset(ap_address, 0, ETH_ALEN);
97
96
                p += sprintf(p, ":%2.2X", ap_address[i]);
98
97
        p += sprintf(p, "\n");
99
98
 
100
 
        res = miniport_query_info(handle, OID_802_11_SSID, &essid,
 
99
        res = miniport_query_info(wd, OID_802_11_SSID, &essid,
101
100
                                  sizeof(essid));
102
101
        if (!res) {
103
102
                essid.essid[essid.length] = '\0';
104
103
                p += sprintf(p, "essid=%s\n", essid.essid);
105
104
        }
106
105
 
107
 
        res = miniport_query_int(handle, OID_802_11_ENCRYPTION_STATUS,
 
106
        res = miniport_query_int(wd, OID_802_11_ENCRYPTION_STATUS,
108
107
                                 &encr_status);
109
 
        res |= miniport_query_int(handle, OID_802_11_AUTHENTICATION_MODE,
 
108
        res |= miniport_query_int(wd, OID_802_11_AUTHENTICATION_MODE,
110
109
                                  &auth_mode);
111
110
 
112
111
        if (!res) {
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;
119
118
                             i++)
120
119
                                p += sprintf(p, "%2.2X",
121
 
                                             handle->encr_info.keys[t].key[i]);
 
120
                                             wd->encr_info.keys[t].key[i]);
122
121
                else
123
122
                        p += sprintf(p, "off");
124
123
                p += sprintf(p, "\n");
127
126
                p += sprintf(p, "auth_mode=%d\n", auth_mode);
128
127
        }
129
128
 
130
 
        res = miniport_query_int(handle, OID_802_11_INFRASTRUCTURE_MODE,
 
129
        res = miniport_query_int(wd, OID_802_11_INFRASTRUCTURE_MODE,
131
130
                                 &infra_mode);
132
131
        p += sprintf(p, "mode=%s\n", (infra_mode == Ndis802_11IBSS) ?
133
132
                     "adhoc" : (infra_mode == Ndis802_11Infrastructure) ?
145
144
                          int count, int *eof, void *data)
146
145
{
147
146
        char *p = page;
148
 
        struct ndis_handle *handle = (struct ndis_handle *)data;
 
147
        struct wrapper_dev *wd = (struct wrapper_dev *)data;
149
148
        struct ndis_configuration config;
150
149
        unsigned int power_mode;
151
150
        NDIS_STATUS res;
160
159
                return 0;
161
160
        }
162
161
 
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));
165
164
        if (!res) {
166
165
                p += sprintf(p, "beacon_period=%u msec\n",
175
174
                             config.fh_config.dwell_time);
176
175
        }
177
176
 
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));
180
179
        if (!res)
181
180
                p += sprintf(p, "tx_power=%u mW\n", tx_power);
182
181
 
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));
185
184
        if (!res)
186
185
                p += sprintf(p, "bit_rate=%u kBps\n", (u32)bit_rate / 10);
187
186
 
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));
190
189
        if (!res)
191
190
                p += sprintf(p, "rts_threshold=%u bytes\n", rts_threshold);
192
191
 
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));
195
194
        if (!res)
196
195
                p += sprintf(p, "frag_threshold=%u bytes\n", frag_threshold);
197
196
 
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);
199
198
        if (!res)
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");
205
204
 
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));
208
207
        if (!res)
209
208
                p += sprintf(p, "num_antennas=%u\n", antenna);
210
209
 
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));
213
212
        if (!res)
214
213
                p += sprintf(p, "tx_antenna=%u\n", antenna);
215
214
 
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));
218
217
        if (!res)
219
218
                p += sprintf(p, "rx_antenna=%u\n", antenna);
220
219
 
 
220
        p += sprintf(p, "encryption_modes=%s%s%s%s%s%s%s\n",
 
221
                     test_bit(Ndis802_11Encryption1Enabled, &wd->capa.encr) ?
 
222
                     "WEP" : "none",
 
223
 
 
224
                     test_bit(Ndis802_11Encryption2Enabled, &wd->capa.encr) ?
 
225
                     "; TKIP with WPA" : "",
 
226
                     test_bit(Ndis802_11AuthModeWPA2, &wd->capa.auth) ?
 
227
                     ", WPA2" : "",
 
228
                     test_bit(Ndis802_11AuthModeWPA2PSK, &wd->capa.auth) ?
 
229
                     ", WPA2PSK" : "",
 
230
 
 
231
                     test_bit(Ndis802_11Encryption3Enabled, &wd->capa.encr) ?
 
232
                     "; AES/CCMP with WPA" : "",
 
233
                     test_bit(Ndis802_11AuthModeWPA2, &wd->capa.auth) ?
 
234
                     ", WPA2" : "",
 
235
                     test_bit(Ndis802_11AuthModeWPA2PSK, &wd->capa.auth) ?
 
236
                     ", WPA2PSK" : "");
 
237
 
221
238
        if (p - page > count) {
222
239
                WARNING("wrote %lu bytes (limit is %u)",
223
240
                        (unsigned long)(p - page), count);
231
248
                                int count, int *eof, void *data)
232
249
{
233
250
        char *p = page;
234
 
        struct ndis_handle *handle = (struct ndis_handle *)data;
 
251
        struct wrapper_dev *wd = (struct wrapper_dev *)data;
235
252
        struct device_setting *setting;
236
253
 
237
254
        if (off != 0) {
240
257
        }
241
258
 
242
259
        p += sprintf(p, "hangcheck_interval=%d\n",
243
 
                     (int)(handle->hangcheck_interval / HZ));
 
260
                     (int)(wd->hangcheck_interval / HZ));
244
261
 
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);
247
264
        }
248
265
 
252
269
static int procfs_write_settings(struct file *file, const char *buf,
253
270
                                 unsigned long count, void *data)
254
271
{
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;
257
274
 
258
275
        if (count > MAX_PROC_STR_LEN)
275
292
                        return -EINVAL;
276
293
                p++;
277
294
                i = simple_strtol(p, NULL, 10);
278
 
                hangcheck_del(handle);
279
 
                handle->hangcheck_interval = i * HZ;
280
 
                hangcheck_add(handle);
 
295
                hangcheck_del(wd);
 
296
                wd->hangcheck_interval = i * HZ;
 
297
                hangcheck_add(wd);
 
298
        } else if (!strcmp(setting, "check_capa")) {
 
299
                check_capa(wd);
 
300
                printk(KERN_INFO "%s: encryption modes supported: %s%s%s%s%s%s%s\n",
 
301
                       wd->net_dev->name,
 
302
                       test_bit(Ndis802_11Encryption1Enabled, &wd->capa.encr) ?
 
303
                       "WEP" : "none",
 
304
 
 
305
                       test_bit(Ndis802_11Encryption2Enabled, &wd->capa.encr) ?
 
306
                       "; TKIP with WPA" : "",
 
307
                       test_bit(Ndis802_11AuthModeWPA2, &wd->capa.auth) ?
 
308
                       ", WPA2" : "",
 
309
                       test_bit(Ndis802_11AuthModeWPA2PSK, &wd->capa.auth) ?
 
310
                       ", WPA2PSK" : "",
 
311
 
 
312
                       test_bit(Ndis802_11Encryption3Enabled, &wd->capa.encr) ?
 
313
                       "; AES/CCMP with WPA" : "",
 
314
                       test_bit(Ndis802_11AuthModeWPA2, &wd->capa.auth) ?
 
315
                       ", WPA2" : "",
 
316
                       test_bit(Ndis802_11AuthModeWPA2PSK, &wd->capa.auth) ?
 
317
                       ", WPA2PSK" : "");
281
318
        } else if (!strcmp(setting, "suspend")) {
282
319
                int i;
283
320
 
287
324
                i = simple_strtol(p, NULL, 10);
288
325
                if (i <= 0 || i > 3)
289
326
                        return -EINVAL;
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,
 
332
                                                PMSG_SUSPEND);
 
333
#endif
 
334
                else
 
335
                        return -EINVAL;
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);
 
342
#endif
 
343
                else
 
344
                        return -EINVAL;
295
345
        } else if (!strcmp(setting, "reinit")) {
296
 
                if (ndis_reinit(handle))
297
 
                        return -EINVAL;
 
346
                if (ndis_reinit(wd))
 
347
                        return -EINVAL;
 
348
#ifdef USB_DEBUG
 
349
        } else if (!strcmp(setting, "irp")) {
 
350
                struct irp *irp;
 
351
                struct io_stack_location *irp_sl;
 
352
                NTSTATUS status;
 
353
                int major_fn, minor_fn, n;
 
354
                struct device_object *dev;
 
355
                if (!p)
 
356
                        return -EINVAL;
 
357
                p++;
 
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,
 
360
                          minor_fn, dev);
 
361
                if (n != 3)
 
362
                        return -EINVAL;
 
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;
 
370
                status = 0;
 
371
                status = IoCallDriver(dev, irp);
 
372
                DBGTRACE1("status = %d", status);
 
373
#endif
298
374
        } else if (!strcmp(setting, "power_profile")) {
299
375
                int i;
300
376
                struct miniport_char *miniport;
307
383
                if (i < 0 || i > 1)
308
384
                        return -EINVAL;
309
385
 
310
 
                miniport = &handle->driver->miniport_char;
 
386
                miniport = &wd->driver->miniport;
311
387
                if (!miniport->pnp_event_notify)
312
388
                        return -EFAULT;
313
389
 
317
393
                else
318
394
                        profile_inf = NdisPowerProfileBattery;
319
395
                
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")) {
330
406
                if (i <= 0 || i > 5)
331
407
                        return -EINVAL;
332
408
 
333
 
                if (set_auth_mode(handle, i))
 
409
                if (set_auth_mode(wd, i))
334
410
                        return -EINVAL;
335
411
        } else if (!strcmp(setting, "encr_mode")) {
336
412
                int i;
342
418
                if (i <= 0 || i > 7)
343
419
                        return -EINVAL;
344
420
 
345
 
                if (set_encr_mode(handle, i))
 
421
                if (set_encr_mode(wd, i))
 
422
                        return -EINVAL;
 
423
        } else if (!strcmp(setting, "stats_enabled")) {
 
424
                int i;
 
425
 
 
426
                if (!p)
 
427
                        return -EINVAL;
 
428
                p++;
 
429
                i = simple_strtol(p, NULL, 10);
 
430
                if (i > 0)
 
431
                        wd->stats_enabled = TRUE;
 
432
                else
 
433
                        wd->stats_enabled = FALSE;
 
434
        } else if (!strcmp(setting, "tx_antenna")) {
 
435
                ndis_antenna antenna;
 
436
                unsigned int i;
 
437
                NTSTATUS res;
 
438
 
 
439
                if (!p)
 
440
                        return -EINVAL;
 
441
                p++;
 
442
                i = simple_strtol(p, NULL, 16);
 
443
                res = miniport_query_info(wd, OID_802_11_NUMBER_OF_ANTENNAS,
 
444
                                          &antenna, sizeof(antenna));
 
445
                if (res)
 
446
                        return -EINVAL;
 
447
                if (i >= -1 && i < antenna)
 
448
                        antenna = i;
 
449
                res = miniport_set_info(wd, OID_802_11_TX_ANTENNA_SELECTED,
 
450
                                  &antenna, sizeof(antenna));
 
451
                if (res)
 
452
                        return -EINVAL;
 
453
        } else if (!strcmp(setting, "rx_antenna")) {
 
454
                ndis_antenna antenna;
 
455
                unsigned int i;
 
456
                NTSTATUS res;
 
457
 
 
458
                if (!p)
 
459
                        return -EINVAL;
 
460
                p++;
 
461
                i = simple_strtol(p, NULL, 16);
 
462
                res = miniport_query_info(wd, OID_802_11_NUMBER_OF_ANTENNAS,
 
463
                                          &antenna, sizeof(antenna));
 
464
                if (res)
 
465
                        return -EINVAL;
 
466
                if (i >= -1 && i < antenna)
 
467
                        antenna = i;
 
468
                res = miniport_set_info(wd, OID_802_11_RX_ANTENNA_SELECTED,
 
469
                                  &antenna, sizeof(antenna));
 
470
                if (res)
346
471
                        return -EINVAL;
347
472
        } else {
348
473
                int res = -1;
352
477
                        TRACEEXIT1(return -EINVAL);
353
478
                p++;
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,
356
481
                                    list) {
357
482
                        struct ndis_config_param *param;
 
483
                        struct unicode_string *ustring;
358
484
 
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 = &param->data.ustring;
366
493
                                if (param->type == NDIS_CONFIG_PARAM_STRING)
367
 
                                        RtlFreeUnicodeString(&param->data.ustring);
 
494
                                        RtlFreeUnicodeString(ustring);
368
495
                                param->type = NDIS_CONFIG_PARAM_NONE;
369
496
                                res = 0;
370
497
                        }
377
504
 
378
505
}
379
506
 
380
 
int ndiswrapper_procfs_add_iface(struct ndis_handle *handle)
 
507
int ndiswrapper_procfs_add_iface(struct wrapper_dev *wd)
381
508
{
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;
384
511
 
385
 
        handle->procfs_iface = NULL;
 
512
        wd->procfs_iface = NULL;
386
513
        if (ndiswrapper_procfs_entry == NULL)
387
514
                return -ENOMEM;
388
515
 
389
516
        proc_iface = proc_mkdir(dev->name, ndiswrapper_procfs_entry);
390
517
 
391
 
        handle->procfs_iface = proc_iface;
 
518
        wd->procfs_iface = proc_iface;
392
519
 
393
520
        if (proc_iface == NULL) {
394
 
                ERROR("%s", "Couldn't create proc directory");
 
521
                ERROR("couldn't create proc directory");
395
522
                return -ENOMEM;
396
523
        }
397
524
        proc_iface->uid = proc_uid;
400
527
        procfs_entry = create_proc_entry("hw", S_IFREG | S_IRUSR | S_IRGRP,
401
528
                                         proc_iface);
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'");
404
531
                return -ENOMEM;
405
532
        } else {
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;
410
537
        }
411
538
 
412
539
        procfs_entry = create_proc_entry("stats", S_IFREG | S_IRUSR | S_IRGRP,
413
540
                                         proc_iface);
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'");
416
543
                return -ENOMEM;
417
544
        } else {
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;
422
549
        }
423
550
 
424
551
        procfs_entry = create_proc_entry("encr", S_IFREG | S_IRUSR | S_IRGRP,
425
552
                                         proc_iface);
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'");
428
555
                return -ENOMEM;
429
556
        } else {
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;
434
561
        }
435
562
 
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'");
441
568
                return -ENOMEM;
442
569
        } else {
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;
448
575
        }
449
576
        return 0;
450
577
}
451
578
 
452
 
void ndiswrapper_procfs_remove_iface(struct ndis_handle *handle)
 
579
void ndiswrapper_procfs_remove_iface(struct wrapper_dev *wd)
453
580
{
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;
456
583
 
457
584
        if (procfs_iface == NULL)
458
585
                return;
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;
466
593
}
467
594
 
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)
485
612
{
486
 
        char debug_level[MAX_PROC_STR_LEN];
487
613
        int i;
 
614
        char setting[MAX_PROC_STR_LEN], *p;
488
615
 
489
616
        if (count > MAX_PROC_STR_LEN)
490
617
                return -EINVAL;
491
618
 
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))
494
621
                return -EFAULT;
495
622
 
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')))
 
624
                *p = 0;
 
625
 
 
626
        if ((p = strchr(setting, '=')))
 
627
                *p = 0;
 
628
 
 
629
        i = simple_strtol(setting, NULL, 10);
 
630
        if (i >= 0 && i < 10)
 
631
                debug = i;
 
632
        else
499
633
                return -EINVAL;
500
 
#else
501
 
        return -EINVAL;
502
 
#endif
503
 
        debug = i;
504
 
 
505
634
        return count;
506
635
}
507
636