View | Details | Raw Unified | Return to bug 25577
Collapse All | Expand All

(-)sbin/ifconfig//Makefile (+4 lines)
Lines 15-20 Link Here
15
CFLAGS+=-DUSE_VLANS
15
CFLAGS+=-DUSE_VLANS
16
.endif
16
.endif
17
17
18
#comment out to exclude SIOC[GS]IEEE80211 support
19
SRCS+=	ifieee80211.c
20
CFLAGS+=-DUSE_IEEE80211
21
18
MAN8=	ifconfig.8
22
MAN8=	ifconfig.8
19
DPADD=	${LIBIPX}
23
DPADD=	${LIBIPX}
20
LDADD=	-lipx
24
LDADD=	-lipx
(-)sbin/ifconfig//ifconfig.8 (+105 lines)
Lines 403-408 Link Here
403
It happens automatically when setting the first address on an interface.
403
It happens automatically when setting the first address on an interface.
404
If the interface was reset when previously marked down,
404
If the interface was reset when previously marked down,
405
the hardware will be re-initialized.
405
the hardware will be re-initialized.
406
.It Cm ssid Ar ssid
407
For IEEE 802.11 wireless interfaces, set the desired Service Set
408
Identifier (aka network name.)  The SSID is a string up to 32 characters
409
in length and may be specified as either a normal string or in
410
hexadecimal when proceeded by
411
.Sq 0x .
412
Additionally, the SSID may be cleared by setting it to
413
.Sq - .
414
.It Cm nwid Ar ssid
415
Another name for the 
416
.Dq ssid
417
parameter.  Included for NetBSD compatibility.
418
.It Cm stationname Ar name
419
For IEEE 802.11 wireless interfaces, set the name of this station.
420
It appears that the station name is not really part of the IEEE 802.11
421
protocol though all interfaces seem to support it.  As such it only
422
seems to be meaningful to identical or virtually identical equipment.
423
Setting the station name is identical in syntax to setting the SSID.
424
.It Cm station Ar name
425
Another name for the 
426
.Dq stationname
427
parameter.  Included for BSD/OS compatibility.
428
.It Cm channel Ar number
429
For IEEE 802.11 wireless interfaces, set the desired channel.
430
Channels range from 1 to 14, but the exact selection available
431
depends on the region your adaptor was manufactured for.  Setting
432
the channel to 0 will give you the default for your adaptor.  Many
433
adaptors ignore this setting unless you are in ad-hoc mode.
434
.It Cm authmode Ar mode
435
For IEEE 802.11 wireless interfaces, set the desired authentication mode
436
in infrastructure mode.  Not all adaptors support all modes.  The set of
437
valid modes is
438
.Dq none ,
439
.Dq open ,
440
and
441
.Dq shared .
442
Modes are case insensitive.
443
.It Cm powersave
444
For IEEE 802.11 wireless interfaces, enable powersave mode.
445
.It Cm -powersave
446
For IEEE 802.11 wireless interfaces, disable powersave mode.
447
.It Cm powersavesleep Ar sleep
448
For IEEE 802.11 wireless interfaces, set the desired max powersave sleep
449
time in milliseconds.
450
.It Cm wepmode Ar mode
451
For IEEE 802.11 wireless interfaces, set the desired WEP mode.  Not all
452
adaptors support all modes.  The set of valid modes is
453
.Dq off ,
454
.Dq on ,
455
and
456
.Dq mixed .
457
.Dq Mixed
458
mode explicitly tells the adaptor to allow association with access
459
points which allow both encrypted and unencrypted traffic.  On these
460
adaptors,
461
.Dq on
462
means that the access point must only allow encrypted connections.  On
463
other adaptors,
464
.Dq on
465
is generally another name for
466
.Dq mixed .
467
Modes are case insensitive.
468
.It Cm weptxkey Ar index
469
For IEEE 802.11 wireless interfaces, set the WEP key to be used for
470
transmission.
471
.It Cm wepkey Ar key|index:key
472
For IEEE 802.11 wireless interfaces, set the selected WEP key.  If
473
an
474
.Ar index
475
is not given, key 1 is set.  A WEP key will be either 5 or 13
476
characters (40 or 104 bits) depending of the local network and the
477
capabilities of the adaptor.  It may be specified either as a plain
478
string or as a string of hexadecimal digits proceeded by
479
.Sq 0x .
480
A key may be cleared by setting it to
481
.Sq - .
482
If WEP is supported then there are at least four keys.  Some adaptors
483
support more then four keys.  If that is the case, then the first four keys
484
(1-4) will be the standard temporary keys and any others will be adaptor
485
specific keys such as permanent keys stored in NVRAM.
486
.It Cm wep
487
Another way of saying 
488
.Dq wepmode on .
489
Included for BSD/OS compatibility.
490
.It Cm -wep
491
Another way of saying
492
.Dq wepmode off .
493
Included for BSD/OS compatibility.
494
.It Cm nwkey key
495
Another way of saying:
496
.Pp
497
``wepmode on weptxkey 1 wepkey 1:key wepkey 2:- wepkey 3:- wepkey 4:-''.
498
.Pp
499
Included for NetBSD compatibility.
500
.It Cm nwkey n:k1,k2,k3,k4
501
Another way of saying
502
.Pp
503
``wepmode on weptxkey n wepkey 1:k1 wepkey 2:k2 wepkey 3:k3 wepkey 4:k4''.
504
.Pp
505
Included for NetBSD compatibility.
506
.It Cm -nwkey
507
Another way of saying
508
.Dq wepmode off .
509
.Pp
510
Included for NetBSD compatibility.
406
.El
511
.El
407
.Pp
512
.Pp
408
.Nm Ifconfig
513
.Nm Ifconfig
(-)sbin/ifconfig//ifconfig.c (+26 lines)
Lines 223-228 Link Here
223
	{ "vlandev",	NEXTARG,	setvlandev },
223
	{ "vlandev",	NEXTARG,	setvlandev },
224
	{ "-vlandev",	NEXTARG,	unsetvlandev },
224
	{ "-vlandev",	NEXTARG,	unsetvlandev },
225
#endif
225
#endif
226
#ifdef USE_IEEE80211
227
	{ "ssid",	NEXTARG,	set80211ssid },
228
	{ "nwid",	NEXTARG,	set80211ssid },
229
	{ "stationname", NEXTARG,	set80211stationname },
230
	{ "station",	NEXTARG,	set80211stationname },	/* BSD/OS */
231
	{ "channel",	NEXTARG,	set80211channel },
232
	{ "authmode",	NEXTARG,	set80211authmode },
233
	{ "powersavemode", NEXTARG,	set80211powersavemode },
234
	{ "powersave",	1,		set80211powersave },
235
	{ "-powersave",	0,		set80211powersave },
236
	{ "powersavesleep", NEXTARG,	set80211powersavesleep },
237
	{ "wepmode",	NEXTARG,	set80211wepmode },
238
	{ "wep",	1,		set80211wep },
239
	{ "-wep",	0,		set80211wep },
240
	{ "weptxkey",	NEXTARG,	set80211weptxkey },
241
	{ "wepkey",	NEXTARG,	set80211wepkey },
242
	{ "nwkey",	NEXTARG,	set80211nwkey },	/* NetBSD */
243
	{ "-nwkey",	0,		set80211wep },		/* NetBSD */
244
#endif
226
	{ "normal",	-IFF_LINK0,	setifflags },
245
	{ "normal",	-IFF_LINK0,	setifflags },
227
	{ "compress",	IFF_LINK0,	setifflags },
246
	{ "compress",	IFF_LINK0,	setifflags },
228
	{ "noicmp",	IFF_LINK1,	setifflags },
247
	{ "noicmp",	IFF_LINK1,	setifflags },
Lines 291-296 Link Here
291
#ifdef USE_VLANS
310
#ifdef USE_VLANS
292
	{ "vlan", AF_UNSPEC, vlan_status, NULL, NULL, },  /* XXX not real!! */
311
	{ "vlan", AF_UNSPEC, vlan_status, NULL, NULL, },  /* XXX not real!! */
293
#endif
312
#endif
313
#ifdef USE_IEEE80211
314
	{ "ieee80211", AF_UNSPEC, ieee80211_status, NULL, NULL, },  /* XXX not real!! */
315
#endif
294
#endif
316
#endif
295
	{ 0,	0,	    0,		0 }
317
	{ 0,	0,	    0,		0 }
296
};
318
};
Lines 969-974 Link Here
969
#ifdef USE_VLANS
991
#ifdef USE_VLANS
970
	if (allfamilies || afp->af_status == vlan_status)
992
	if (allfamilies || afp->af_status == vlan_status)
971
		vlan_status(s, NULL);
993
		vlan_status(s, NULL);
994
#endif
995
#ifdef USE_IEEE80211
996
	if (allfamilies || afp->af_status == ieee80211_status)
997
		ieee80211_status(s, NULL);
972
#endif
998
#endif
973
	strncpy(ifs.ifs_name, name, sizeof ifs.ifs_name);
999
	strncpy(ifs.ifs_name, name, sizeof ifs.ifs_name);
974
	if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0) 
1000
	if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0) 
(-)sbin/ifconfig//ifconfig.h (+14 lines)
Lines 49-51 Link Here
49
extern void setvlandev(const char *, int, int, const struct afswtch *rafp);
49
extern void setvlandev(const char *, int, int, const struct afswtch *rafp);
50
extern void unsetvlandev(const char *, int, int, const struct afswtch *rafp);
50
extern void unsetvlandev(const char *, int, int, const struct afswtch *rafp);
51
extern void vlan_status(int s, struct rt_addrinfo *);
51
extern void vlan_status(int s, struct rt_addrinfo *);
52
53
extern void set80211ssid(const char *, int, int, const struct afswtch *rafp);
54
extern void set80211stationname(const char *, int, int, const struct afswtch *rafp);
55
extern void set80211channel(const char *, int, int, const struct afswtch *rafp);
56
extern void set80211authmode(const char *, int, int, const struct afswtch *rafp);
57
extern void set80211powersave(const char *, int, int, const struct afswtch *rafp);
58
extern void set80211powersavemode(const char *, int, int, const struct afswtch *rafp);
59
extern void set80211powersavesleep(const char *, int, int, const struct afswtch *rafp);
60
extern void set80211wepmode(const char *, int, int, const struct afswtch *rafp);
61
extern void set80211wep(const char *, int, int, const struct afswtch *rafp);
62
extern void set80211weptxkey(const char *, int, int, const struct afswtch *rafp);
63
extern void set80211wepkey(const char *, int, int, const struct afswtch *rafp);
64
extern void set80211nwkey(const char *, int, int, const struct afswtch *rafp);
65
extern void ieee80211_status(int s, struct rt_addrinfo *);
(-)sbin/ifconfig//ifmedia.c (-3 / +33 lines)
Lines 152-157 Link Here
152
			else
152
			else
153
				printf("no ring");
153
				printf("no ring");
154
			break;
154
			break;
155
		case IFM_IEEE80211:
156
			/* XXX: Different value for adhoc? */
157
			if (ifmr.ifm_status & IFM_ACTIVE)
158
				printf("associated");
159
			else
160
				printf("no carrier");
161
			break;
155
		}
162
		}
156
	}
163
	}
157
164
Lines 318-323 Link Here
318
static struct ifmedia_description ifm_subtype_fddi_option_descriptions[] =
325
static struct ifmedia_description ifm_subtype_fddi_option_descriptions[] =
319
    IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS;
326
    IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS;
320
327
328
static struct ifmedia_description ifm_subtype_ieee80211_descriptions[] =
329
    IFM_SUBTYPE_IEEE80211_DESCRIPTIONS;
330
331
static struct ifmedia_description ifm_subtype_ieee80211_aliases[] =
332
    IFM_SUBTYPE_IEEE80211_ALIASES;
333
334
static struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] =
335
    IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS;
336
321
static struct ifmedia_description ifm_subtype_shared_descriptions[] =
337
static struct ifmedia_description ifm_subtype_shared_descriptions[] =
322
    IFM_SUBTYPE_SHARED_DESCRIPTIONS;
338
    IFM_SUBTYPE_SHARED_DESCRIPTIONS;
323
339
Lines 350-356 Link Here
350
		},
366
		},
351
		{
367
		{
352
			{ &ifm_shared_option_descriptions[0], 0 },
368
			{ &ifm_shared_option_descriptions[0], 0 },
353
			{ &ifm_subtype_ethernet_option_descriptions[0], 1 },
369
			{ &ifm_subtype_ethernet_option_descriptions[0], 0 },
354
			{ NULL, 0 },
370
			{ NULL, 0 },
355
		},
371
		},
356
	},
372
	},
Lines 364-370 Link Here
364
		},
380
		},
365
		{
381
		{
366
			{ &ifm_shared_option_descriptions[0], 0 },
382
			{ &ifm_shared_option_descriptions[0], 0 },
367
			{ &ifm_subtype_tokenring_option_descriptions[0], 1 },
383
			{ &ifm_subtype_tokenring_option_descriptions[0], 0 },
368
			{ NULL, 0 },
384
			{ NULL, 0 },
369
		},
385
		},
370
	},
386
	},
Lines 377-384 Link Here
377
			{ NULL, 0 },
393
			{ NULL, 0 },
378
		},
394
		},
379
		{
395
		{
396
			{ &ifm_shared_option_descriptions[0], 0 },
397
			{ &ifm_subtype_fddi_option_descriptions[0], 0 },
398
			{ NULL, 0 },
399
		},
400
	},
401
	{
402
		{
403
			{ &ifm_subtype_shared_descriptions[0], 0 },
404
			{ &ifm_subtype_shared_aliases[0], 1 },
405
			{ &ifm_subtype_ieee80211_descriptions[0], 0 },
406
			{ &ifm_subtype_ieee80211_aliases[0], 1 },
407
			{ NULL, 0 },
408
		},
409
		{
380
			{ &ifm_shared_option_descriptions[0], 0 },
410
			{ &ifm_shared_option_descriptions[0], 0 },
381
			{ &ifm_subtype_fddi_option_descriptions[0], 1 },
411
			{ &ifm_subtype_ieee80211_option_descriptions[0], 0 },
382
			{ NULL, 0 },
412
			{ NULL, 0 },
383
		},
413
		},
384
	},
414
	},
(-)sbin/ifconfig/ifieee80211.c (+518 lines)
Line 0 Link Here
1
/*
2
 * Copyright 2001 The Aerospace Corporation.  All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION ``AS IS'' AND
14
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
17
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
 * SUCH DAMAGE.
24
 */
25
26
/*-
27
 * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
28
 * All rights reserved.
29
 *
30
 * This code is derived from software contributed to The NetBSD Foundation
31
 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
32
 * NASA Ames Research Center.
33
 *
34
 * Redistribution and use in source and binary forms, with or without
35
 * modification, are permitted provided that the following conditions
36
 * are met:
37
 * 1. Redistributions of source code must retain the above copyright
38
 *    notice, this list of conditions and the following disclaimer.
39
 * 2. Redistributions in binary form must reproduce the above copyright
40
 *    notice, this list of conditions and the following disclaimer in the
41
 *    documentation and/or other materials provided with the distribution.
42
 * 3. All advertising materials mentioning features or use of this software
43
 *    must display the following acknowledgement:
44
 *	This product includes software developed by the NetBSD
45
 *	Foundation, Inc. and its contributors.
46
 * 4. Neither the name of The NetBSD Foundation nor the names of its
47
 *    contributors may be used to endorse or promote products derived
48
 *    from this software without specific prior written permission.
49
 *
50
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
51
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
52
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
54
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
55
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
56
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
57
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
58
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
59
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
60
 * POSSIBILITY OF SUCH DAMAGE.
61
 */
62
63
#include <sys/param.h>
64
#include <sys/ioctl.h>
65
#include <sys/socket.h>
66
#include <sys/sysctl.h>
67
#include <sys/time.h>
68
69
#include <net/ethernet.h>
70
#include <net/if.h>
71
#include <net/if_dl.h>
72
#include <net/if_types.h>
73
#include <net/route.h>
74
#include <net/if_ieee80211.h>
75
76
#include <ctype.h>
77
#include <err.h>
78
#include <errno.h>
79
#include <fcntl.h>
80
#include <stdio.h>
81
#include <stdlib.h>
82
#include <string.h>
83
#include <unistd.h>
84
85
#include "ifconfig.h"
86
87
static void set80211(int s, int type, int val, int len, u_int8_t *data);
88
static const char *get_string(const char *val, const char *sep,
89
    u_int8_t *buf, int *lenp);
90
static void print_string(const u_int8_t *buf, int len);
91
92
void
93
set80211ssid(const char *val, int d, int s, const struct afswtch *rafp)
94
{
95
	int		ssid;
96
	int		len;
97
	u_int8_t	data[33];
98
99
	ssid = 0;
100
101
	bzero(data, sizeof(data));
102
	len = sizeof(data);
103
	get_string(val, NULL, data, &len);
104
105
	set80211(s, IEEE80211_IOC_SSID, ssid, len, data);
106
}
107
108
void
109
set80211stationname(const char *val, int d, int s, const struct afswtch *rafp)
110
{
111
	int			len;
112
	u_int8_t		data[33];
113
114
	bzero(data, sizeof(data));
115
	len = sizeof(data);
116
	get_string(val, NULL, data, &len);
117
118
	set80211(s, IEEE80211_IOC_STATIONNAME, 0, len, data);
119
}
120
121
void
122
set80211channel(const char *val, int d, int s, const struct afswtch *rafp)
123
{
124
	set80211(s, IEEE80211_IOC_CHANNEL, atoi(val), 0, NULL);
125
}
126
127
void
128
set80211authmode(const char *val, int d, int s, const struct afswtch *rafp)
129
{
130
	int	mode;
131
132
	if(strcasecmp(val, "none") == 0) {
133
		mode = IEEE80211_AUTH_NONE;
134
	} else if(strcasecmp(val, "open") == 0) {
135
		mode = IEEE80211_AUTH_OPEN;
136
	} else if(strcasecmp(val, "shared") == 0) {
137
		mode = IEEE80211_AUTH_SHARED;
138
	} else {
139
		err(1, "unknown authmode");
140
	}
141
142
	set80211(s, IEEE80211_IOC_AUTHMODE, mode, 0, NULL);
143
}
144
145
void
146
set80211powersavemode(const char *val, int d, int s, const struct afswtch *rafp)
147
{
148
	int	mode;
149
150
	if(strcasecmp(val, "off") == 0) {
151
		mode = IEEE80211_POWERSAVE_OFF;
152
	} else if(strcasecmp(val, "on") == 0) {
153
		mode = IEEE80211_POWERSAVE_ON;
154
	} else if(strcasecmp(val, "cam") == 0) {
155
		mode = IEEE80211_POWERSAVE_CAM;
156
	} else if(strcasecmp(val, "psp") == 0) {
157
		mode = IEEE80211_POWERSAVE_PSP;
158
	} else if(strcasecmp(val, "psp-cam") == 0) {
159
		mode = IEEE80211_POWERSAVE_PSP_CAM;
160
	} else {
161
		err(1, "unknown powersavemode");
162
	}
163
164
	set80211(s, IEEE80211_IOC_POWERSAVE, mode, 0, NULL);
165
}
166
167
void
168
set80211powersave(const char *val, int d, int s, const struct afswtch *rafp)
169
{
170
	if (d == 0)
171
		set80211(s, IEEE80211_IOC_POWERSAVE, IEEE80211_POWERSAVE_OFF,
172
		    0, NULL);
173
	else
174
		set80211(s, IEEE80211_IOC_POWERSAVE, IEEE80211_POWERSAVE_ON,
175
		    0, NULL);
176
}
177
178
void
179
set80211powersavesleep(const char *val, int d, int s, const struct afswtch *rafp)
180
{
181
	set80211(s, IEEE80211_IOC_POWERSAVESLEEP, atoi(val), 0, NULL);
182
}
183
184
void
185
set80211wepmode(const char *val, int d, int s, const struct afswtch *rafp)
186
{
187
	int	mode;
188
189
	if(strcasecmp(val, "off") == 0) {
190
		mode = IEEE80211_WEP_OFF;
191
	} else if(strcasecmp(val, "on") == 0) {
192
		mode = IEEE80211_WEP_ON;
193
	} else if(strcasecmp(val, "mixed") == 0) {
194
		mode = IEEE80211_WEP_MIXED;
195
	} else {
196
		err(1, "unknown wep mode");
197
	}
198
199
	set80211(s, IEEE80211_IOC_WEP, mode, 0, NULL);
200
}
201
202
void
203
set80211wep(const char *val, int d, int s, const struct afswtch *rafp)
204
{
205
	set80211(s, IEEE80211_IOC_WEP, d, 0, NULL);
206
}
207
208
void
209
set80211weptxkey(const char *val, int d, int s, const struct afswtch *rafp)
210
{
211
	set80211(s, IEEE80211_IOC_WEPTXKEY, atoi(val)-1, 0, NULL);
212
}
213
214
void
215
set80211wepkey(const char *val, int d, int s, const struct afswtch *rafp)
216
{
217
	int		key = 0;
218
	int		len;
219
	u_int8_t	data[14];
220
221
	if(isdigit(val[0]) && val[1] == ':') {
222
		key = atoi(val)-1;
223
		val += 2;
224
	}
225
226
	bzero(data, sizeof(data));
227
	len = sizeof(data);
228
	get_string(val, NULL, data, &len);
229
230
	set80211(s, IEEE80211_IOC_WEPKEY, key, len, data);
231
}
232
233
/*
234
 * This function is purly a NetBSD compatability interface.  The NetBSD
235
 * iterface is too inflexable, but it's there so we'll support it since
236
 * it's not all that hard.
237
 */
238
void
239
set80211nwkey(const char *val, int d, int s, const struct afswtch *rafp)
240
{
241
	int		txkey;
242
	int		i, len;
243
	u_int8_t	data[14];
244
245
	set80211(s, IEEE80211_IOC_WEP, IEEE80211_WEP_ON, 0, NULL);
246
247
	if(isdigit(val[0]) && val[1] == ':') {
248
		txkey = val[0]-'0'-1;
249
		val += 2;
250
251
		for(i = 0; i < 4; i++) {
252
			bzero(data, sizeof(data));
253
			len = sizeof(data);
254
			val = get_string(val, ",", data, &len);
255
256
			set80211(s, IEEE80211_IOC_WEPKEY, i, len, data);
257
		}
258
	} else {
259
		bzero(data, sizeof(data));
260
		len = sizeof(data);
261
		get_string(val, NULL, data, &len);
262
		txkey = 0;
263
264
		set80211(s, IEEE80211_IOC_WEPKEY, 0, len, data);
265
266
		bzero(data, sizeof(data));
267
		for(i = 1; i < 4; i++)
268
			set80211(s, IEEE80211_IOC_WEPKEY, i, 0, data);
269
	}
270
271
	set80211(s, IEEE80211_IOC_WEPTXKEY, txkey, 0, NULL);
272
}
273
274
void
275
ieee80211_status (s, info)
276
	int s;
277
	struct rt_addrinfo *info __unused;
278
{
279
	int			i;
280
	int			num;
281
	struct ieee80211req	ireq;
282
	u_int8_t		data[32];
283
	char			spacer;
284
285
	(void) memset(&ireq, 0, sizeof(ireq));
286
	(void) strncpy(ireq.i_name, name, sizeof(ireq.i_name));
287
	ireq.i_data = &data;
288
289
	ireq.i_type = IEEE80211_IOC_SSID;
290
	ireq.i_val = -1;
291
	if (ioctl(s, SIOCG80211, &ireq) < 0) {
292
		/* If we can't get the SSID, the this isn't an 802.11 device. */
293
		return;
294
	}
295
	printf("\tssid ");
296
	print_string(data, ireq.i_len);
297
	printf("\n");
298
299
	ireq.i_type = IEEE80211_IOC_STATIONNAME;
300
	if (ioctl(s, SIOCG80211, &ireq) != -1) {
301
		printf("\tstationname ");
302
		print_string(data, ireq.i_len);
303
		printf("\n");
304
	}
305
306
	ireq.i_type = IEEE80211_IOC_CHANNEL;
307
	if (ioctl(s, SIOCG80211, &ireq) < 0) {
308
		goto end;
309
	}
310
	printf("\tchannel %d", ireq.i_val);
311
312
	ireq.i_type = IEEE80211_IOC_AUTHMODE;
313
	if (ioctl(s, SIOCG80211, &ireq) != -1) {
314
		printf(" authmode");
315
		switch (ireq.i_val) {
316
			case IEEE80211_AUTH_NONE:
317
				printf(" NONE");
318
				break;
319
			case IEEE80211_AUTH_OPEN:
320
				printf(" OPEN");
321
				break;
322
			case IEEE80211_AUTH_SHARED:
323
				printf(" SHARED");
324
				break;
325
			default:
326
				printf(" UNKNOWN");
327
				break;
328
		}
329
	}
330
331
	ireq.i_type = IEEE80211_IOC_POWERSAVE;
332
	if (ioctl(s, SIOCG80211, &ireq) != -1 &&
333
	    ireq.i_val != IEEE80211_POWERSAVE_NOSUP ) {
334
		printf(" powersavemode");
335
		switch (ireq.i_val) {
336
			case IEEE80211_POWERSAVE_OFF:
337
				printf(" OFF");
338
				break;
339
			case IEEE80211_POWERSAVE_CAM:
340
				printf(" CAM");
341
				break;
342
			case IEEE80211_POWERSAVE_PSP:
343
				printf(" PSP");
344
				break;
345
			case IEEE80211_POWERSAVE_PSP_CAM:
346
				printf(" PSP-CAM");
347
				break;
348
		}
349
350
		ireq.i_type = IEEE80211_IOC_POWERSAVESLEEP;
351
		if (ioctl(s, SIOCG80211, &ireq) != -1) {
352
			if(ireq.i_val)
353
				printf(" powersavesleep %d", ireq.i_val);
354
		}
355
	}
356
357
	printf("\n");
358
359
	ireq.i_type = IEEE80211_IOC_WEP;
360
	if (ioctl(s, SIOCG80211, &ireq) < 0 ||
361
	    ireq.i_val == IEEE80211_WEP_NOSUP)
362
		goto nowep;
363
	else {
364
		printf("\twepmode");
365
		switch (ireq.i_val) {
366
			case IEEE80211_WEP_OFF:
367
				printf(" OFF");
368
				break;
369
			case IEEE80211_WEP_ON:
370
				printf(" ON");
371
				break;
372
			case IEEE80211_WEP_MIXED:
373
				printf(" MIXED");
374
				break;
375
			default:
376
				printf(" UNKNOWN");
377
				break;
378
		}
379
380
		/*
381
		 * If we get here then we've got WEP support so we need
382
		 * to print WEP status.
383
		 */ 
384
385
		ireq.i_type = IEEE80211_IOC_WEPTXKEY;
386
		if (ioctl(s, SIOCG80211, &ireq) < 0) {
387
			warn("WEP support, but no tx key!");
388
			goto end;
389
		}
390
		printf(" weptxkey %d", ireq.i_val+1);
391
392
		ireq.i_type = IEEE80211_IOC_NUMWEPKEYS;
393
		if (ioctl(s, SIOCG80211, &ireq) < 0) {
394
			warn("WEP support, but no NUMWEPKEYS support!");
395
			goto end;
396
		}
397
		num = ireq.i_val;
398
399
		printf("\n");
400
401
		ireq.i_type = IEEE80211_IOC_WEPKEY;
402
		spacer = '\t';
403
		for(i = 0; i < num; i++) {
404
			ireq.i_val = i;
405
			if (ioctl(s, SIOCG80211, &ireq) < 0) {
406
				warn("WEP support, but can get keys!");
407
				goto end;
408
			}
409
			if(ireq.i_len == 0 || ireq.i_len > 13)
410
				continue;
411
			printf("%cwepkey %d:%s", spacer, i+1,
412
			    ireq.i_len <= 5 ? "64-bit" : "128-bit");
413
			if(spacer == '\t')
414
				spacer = ' ';
415
		}
416
417
		printf("\n");
418
	}
419
nowep:
420
421
422
end:
423
	return;
424
}
425
426
static void
427
set80211(int s, int type, int val, int len, u_int8_t *data)
428
{
429
	struct ieee80211req	ireq;
430
431
	(void) memset(&ireq, 0, sizeof(ireq));
432
	(void) strncpy(ireq.i_name, name, sizeof(ireq.i_name));
433
	ireq.i_type = type;
434
	ireq.i_val = val;
435
	ireq.i_len = len;
436
	ireq.i_data = data;
437
	if(ioctl(s, SIOCS80211, &ireq) < 0)
438
		err(1, "SIOCS80211");
439
}
440
441
static const char *
442
get_string(const char *val, const char *sep, u_int8_t *buf, int *lenp)
443
{
444
	int len;
445
	int hexstr;
446
	u_int8_t *p;
447
448
	len = *lenp;
449
	p = buf;
450
	hexstr = (val[0] == '0' && tolower((u_char)val[1]) == 'x');
451
	if (hexstr)
452
		val += 2;
453
	for (;;) {
454
		if (*val == '\0')
455
			break;
456
		if (sep != NULL && strchr(sep, *val) != NULL) {
457
			val++;
458
			break;
459
		}
460
		if (hexstr) {
461
			if (!isxdigit((u_char)val[0]) ||
462
			    !isxdigit((u_char)val[1])) {
463
				warnx("bad hexadecimal digits");
464
				return NULL;
465
			}
466
		}
467
		if (p > buf + len) {
468
			if (hexstr)
469
				warnx("hexadecimal digits too long");
470
			else
471
				warnx("strings too long");
472
			return NULL;
473
		}
474
		if (hexstr) {
475
#define	tohex(x)	(isdigit(x) ? (x) - '0' : tolower(x) - 'a' + 10)
476
			*p++ = (tohex((u_char)val[0]) << 4) |
477
			    tohex((u_char)val[1]);
478
#undef tohex
479
			val += 2;
480
		} else
481
			*p++ = *val++;
482
	}
483
	len = p - buf;
484
	/* The string "-" is treated as the empty string. */
485
	if (!hexstr && len == 1 && buf[0] == '-')
486
		len = 0;
487
	if (len < *lenp)
488
		memset(p, 0, *lenp - len);
489
	*lenp = len;
490
	return val;
491
}
492
493
static void
494
print_string(const u_int8_t *buf, int len)
495
{
496
	int i;
497
	int hasspc;
498
499
	i = 0;
500
	hasspc = 0;
501
	for(; i < len; i++) {
502
		if (!isprint(buf[i]) && buf[i] != '\0')
503
			break;
504
		if (isspace(buf[i]))
505
			hasspc++;
506
	}
507
	if (i == len) {
508
		if (hasspc || len == 0 || buf[0] == '\0')
509
			printf("\"%.*s\"", len, buf);
510
		else
511
			printf("%.*s", len, buf);
512
	} else {
513
		printf("0x");
514
		for (i = 0; i < len; i++)
515
			printf("%02x", buf[i]);
516
	}
517
}
518
(-)sys/dev/an/if_aironet_ieee.h (+2 lines)
Lines 336-341 Link Here
336
	u_int8_t		an_magic_packet_ctl;	/* 0x99 */
336
	u_int8_t		an_magic_packet_ctl;	/* 0x99 */
337
	u_int16_t		an_rsvd9;
337
	u_int16_t		an_rsvd9;
338
};
338
};
339
#endif
339
340
340
#define AN_OPMODE_IBSS_ADHOC			0x0000
341
#define AN_OPMODE_IBSS_ADHOC			0x0000
341
#define AN_OPMODE_INFRASTRUCTURE_STATION	0x0001
342
#define AN_OPMODE_INFRASTRUCTURE_STATION	0x0001
Lines 392-397 Link Here
392
#define AN_TXPOWER_100MW			100
393
#define AN_TXPOWER_100MW			100
393
#define AN_TXPOWER_250MW			250
394
#define AN_TXPOWER_250MW			250
394
395
396
#ifndef _KERNEL
395
struct an_ltv_ssidlist {
397
struct an_ltv_ssidlist {
396
	u_int16_t		an_len;
398
	u_int16_t		an_len;
397
	u_int16_t		an_type;
399
	u_int16_t		an_type;
(-)sys/dev/an/if_an.c (-1 / +492 lines)
Lines 113-118 Link Here
113
#include <net/ethernet.h>
113
#include <net/ethernet.h>
114
#include <net/if_dl.h>
114
#include <net/if_dl.h>
115
#include <net/if_types.h>
115
#include <net/if_types.h>
116
#include <net/if_ieee80211.h>
117
#include <net/if_media.h>
116
118
117
#ifdef INET
119
#ifdef INET
118
#include <netinet/in.h>
120
#include <netinet/in.h>
Lines 160-165 Link Here
160
					struct mbuf *, unsigned short));
162
					struct mbuf *, unsigned short));
161
#endif
163
#endif
162
164
165
static int an_media_change	__P((struct ifnet *));
166
static void an_media_status	__P((struct ifnet *, struct ifmediareq *));
167
163
/* 
168
/* 
164
 * We probe for an Aironet 4500/4800 card by attempting to
169
 * We probe for an Aironet 4500/4800 card by attempting to
165
 * read the default SSID list. On reset, the first entry in
170
 * read the default SSID list. On reset, the first entry in
Lines 375-385 Link Here
375
	sc->an_ssidlist.an_ssid1_len = strlen(AN_DEFAULT_NETNAME);
380
	sc->an_ssidlist.an_ssid1_len = strlen(AN_DEFAULT_NETNAME);
376
381
377
	sc->an_config.an_opmode =
382
	sc->an_config.an_opmode =
378
	    AN_OPMODE_IBSS_ADHOC;
383
	    AN_OPMODE_INFRASTRUCTURE_STATION;
379
384
380
	sc->an_tx_rate = 0;
385
	sc->an_tx_rate = 0;
381
	bzero((char *)&sc->an_stats, sizeof(sc->an_stats));
386
	bzero((char *)&sc->an_stats, sizeof(sc->an_stats));
382
387
388
	ifmedia_init(&sc->an_ifmedia, 0, an_media_change, an_media_status);
389
#define	ADD(m, c)	ifmedia_add(&sc->an_ifmedia, (m), (c), NULL)
390
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1,
391
	    IFM_IEEE80211_ADHOC, 0), 0);
392
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, 0, 0), 0);
393
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2,
394
	    IFM_IEEE80211_ADHOC, 0), 0);
395
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, 0, 0), 0);
396
	if(sc->an_caps.an_rates[2] == AN_RATE_5_5MBPS) {
397
		ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5,
398
		    IFM_IEEE80211_ADHOC, 0), 0);
399
		ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5, 0, 0), 0);
400
	}
401
	if(sc->an_caps.an_rates[3] == AN_RATE_11MBPS) {
402
		ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11,
403
		    IFM_IEEE80211_ADHOC, 0), 0);
404
		ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, 0, 0), 0);
405
	}
406
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO,
407
	    IFM_IEEE80211_ADHOC, 0), 0);
408
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0), 0);
409
#undef	ADD
410
	ifmedia_set(&sc->an_ifmedia, IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO,
411
	    0, 0));
412
383
	/*
413
	/*
384
	 * Call MI attach routine.
414
	 * Call MI attach routine.
385
	 */
415
	 */
Lines 1012-1025 Link Here
1012
	caddr_t			data;
1042
	caddr_t			data;
1013
{
1043
{
1014
	int			error = 0;
1044
	int			error = 0;
1045
	int			len;
1046
	int			i;
1015
	struct an_softc		*sc;
1047
	struct an_softc		*sc;
1016
	struct an_req		areq;
1048
	struct an_req		areq;
1017
	struct ifreq		*ifr;
1049
	struct ifreq		*ifr;
1018
	struct proc		*p = curproc;
1050
	struct proc		*p = curproc;
1051
	struct ieee80211req	*ireq;
1052
	u_int8_t		tmpstr[IEEE80211_NWID_LEN*2];
1053
	u_int8_t		*tmpptr;
1054
	struct an_ltv_genconfig	*config;
1055
	struct an_ltv_key	*key;
1056
	struct an_ltv_status	*status;
1057
	struct an_ltv_ssidlist	*ssids;
1019
1058
1020
	sc = ifp->if_softc;
1059
	sc = ifp->if_softc;
1021
	AN_LOCK(sc);
1060
	AN_LOCK(sc);
1022
	ifr = (struct ifreq *)data;
1061
	ifr = (struct ifreq *)data;
1062
	ireq = (struct ieee80211req *)data;
1063
1064
	config = (struct an_ltv_genconfig *)&areq;
1065
	key = (struct an_ltv_key *)&areq;
1066
	status = (struct an_ltv_status *)&areq;
1067
	ssids = (struct an_ltv_ssidlist *)&areq;
1023
1068
1024
	if (sc->an_gone) {
1069
	if (sc->an_gone) {
1025
		error = ENODEV;
1070
		error = ENODEV;
Lines 1051-1056 Link Here
1051
		sc->an_if_flags = ifp->if_flags;
1096
		sc->an_if_flags = ifp->if_flags;
1052
		error = 0;
1097
		error = 0;
1053
		break;
1098
		break;
1099
	case SIOCSIFMEDIA:
1100
	case SIOCGIFMEDIA:
1101
		error = ifmedia_ioctl(ifp, ifr, &sc->an_ifmedia, command);
1102
		break;
1054
	case SIOCADDMULTI:
1103
	case SIOCADDMULTI:
1055
	case SIOCDELMULTI:
1104
	case SIOCDELMULTI:
1056
		/* The Aironet has no multicast filter. */
1105
		/* The Aironet has no multicast filter. */
Lines 1090-1095 Link Here
1090
			break;
1139
			break;
1091
		an_setdef(sc, &areq);
1140
		an_setdef(sc, &areq);
1092
		break;
1141
		break;
1142
	case SIOCG80211:
1143
		areq.an_len = sizeof(areq);
1144
		switch(ireq->i_type) {
1145
		case IEEE80211_IOC_SSID:
1146
			if(ireq->i_val == -1) {
1147
				areq.an_type = AN_RID_STATUS;
1148
				if (an_read_record(sc,
1149
				    (struct an_ltv_gen *)&areq)) {
1150
					error = EINVAL;
1151
					break;
1152
				}
1153
				len = status->an_ssidlen;
1154
				tmpptr = status->an_ssid;
1155
			} else if(ireq->i_val >= 0) {
1156
				areq.an_type = AN_RID_SSIDLIST;
1157
				if (an_read_record(sc,
1158
				    (struct an_ltv_gen *)&areq)) {
1159
					error = EINVAL;
1160
					break;
1161
				}
1162
				if(ireq->i_val == 0) {
1163
					len = ssids->an_ssid1_len;
1164
					tmpptr = ssids->an_ssid1;
1165
				} else if(ireq->i_val == 1) {
1166
					len = ssids->an_ssid2_len;
1167
					tmpptr = ssids->an_ssid3;
1168
				} else if(ireq->i_val == 1) {
1169
					len = ssids->an_ssid3_len;
1170
					tmpptr = ssids->an_ssid3;
1171
				} else {
1172
					error = EINVAL;
1173
					break;
1174
				}
1175
			} else {
1176
				error = EINVAL;
1177
				break;
1178
			}
1179
			if(len > IEEE80211_NWID_LEN) {
1180
				error = EINVAL;
1181
				break;
1182
			}
1183
			ireq->i_len = len;
1184
			bzero(tmpstr, IEEE80211_NWID_LEN);
1185
			bcopy(tmpptr, tmpstr, len);
1186
			error = copyout(tmpstr, ireq->i_data,
1187
			    IEEE80211_NWID_LEN);
1188
			break;
1189
		case IEEE80211_IOC_NUMSSIDS:
1190
			ireq->i_val = 3;
1191
			break;
1192
		case IEEE80211_IOC_WEP:
1193
			areq.an_type = AN_RID_ACTUALCFG;
1194
			if (an_read_record(sc,
1195
			    (struct an_ltv_gen *)&areq)) {
1196
				error = EINVAL;
1197
				break;
1198
			}
1199
			if(config->an_authtype & AN_AUTHTYPE_PRIVACY_IN_USE) {
1200
				if(config->an_authtype &
1201
				    AN_AUTHTYPE_ALLOW_UNENCRYPTED)
1202
					ireq->i_val = IEEE80211_WEP_MIXED;
1203
				else
1204
					ireq->i_val = IEEE80211_WEP_ON;
1205
				
1206
			} else {
1207
				ireq->i_val = IEEE80211_WEP_OFF;
1208
			}
1209
			break;
1210
		case IEEE80211_IOC_WEPKEY:
1211
			/*
1212
			 * XXX: I'm not entierly convinced this is
1213
			 * correct, but it's what is implemented in
1214
			 * ancontrol so it will have to do until we get
1215
			 * access to actual Cisco code.
1216
			 */
1217
			if(ireq->i_val < 0 || ireq->i_val > 7) {
1218
				error = EINVAL;
1219
				break;
1220
			}
1221
			len = 0;
1222
			if(ireq->i_val < 4) {
1223
				areq.an_type = AN_RID_WEP_TEMP;
1224
				for(i=0; i<4; i++) {
1225
					if (an_read_record(sc,
1226
					    (struct an_ltv_gen *)&areq)) {
1227
						error = EINVAL;
1228
						break;
1229
					}
1230
					len = key->klen;
1231
					if(i == ireq->i_val)
1232
						break;
1233
					/* Required to get next entry */
1234
					areq.an_type = AN_RID_WEP_PERM;
1235
				}
1236
				if(error)
1237
					break;
1238
			}
1239
			/* We aren't allowed to read the value of the
1240
			 * key from the card so we just output zeros
1241
			 * like we would if we could read the card, but
1242
			 * denied the user access.
1243
			 */
1244
			bzero(tmpstr, len);
1245
			ireq->i_len = len;
1246
			error = copyout(tmpstr, ireq->i_data, len);
1247
			break;
1248
		case IEEE80211_IOC_NUMWEPKEYS:
1249
			ireq->i_val = 8;
1250
			break;
1251
		case IEEE80211_IOC_WEPTXKEY:
1252
			areq.an_type = AN_RID_WEP_PERM;
1253
			key->kindex = 0xffff;
1254
			if (an_read_record(sc,
1255
			    (struct an_ltv_gen *)&areq)) {
1256
				error = EINVAL;
1257
				break;
1258
			}
1259
			ireq->i_val = key->mac[0];
1260
			break;
1261
		case IEEE80211_IOC_AUTHMODE:
1262
			areq.an_type = AN_RID_ACTUALCFG;
1263
			if (an_read_record(sc,
1264
			    (struct an_ltv_gen *)&areq)) {
1265
				error = EINVAL;
1266
				break;
1267
			}
1268
			if ((config->an_authtype & AN_AUTHTYPE_MASK) ==
1269
			    AN_AUTHTYPE_NONE) {
1270
			    ireq->i_val = IEEE80211_AUTH_NONE;
1271
			} else if ((config->an_authtype & AN_AUTHTYPE_MASK) ==
1272
			    AN_AUTHTYPE_OPEN) {
1273
			    ireq->i_val = IEEE80211_AUTH_OPEN;
1274
			} else if ((config->an_authtype & AN_AUTHTYPE_MASK) ==
1275
			    AN_AUTHTYPE_SHAREDKEY) {
1276
			    ireq->i_val = IEEE80211_AUTH_SHARED;
1277
			} else
1278
				error = EINVAL;
1279
			break;
1280
		case IEEE80211_IOC_STATIONNAME:
1281
			areq.an_type = AN_RID_ACTUALCFG;
1282
			if (an_read_record(sc,
1283
			    (struct an_ltv_gen *)&areq)) {
1284
				error = EINVAL;
1285
				break;
1286
			}
1287
			ireq->i_len = sizeof(config->an_nodename);
1288
			tmpptr = config->an_nodename;
1289
			bzero(tmpstr, IEEE80211_NWID_LEN);
1290
			bcopy(tmpptr, tmpstr, ireq->i_len);
1291
			error = copyout(tmpstr, ireq->i_data,
1292
			    IEEE80211_NWID_LEN);
1293
			break;
1294
		case IEEE80211_IOC_CHANNEL:
1295
			areq.an_type = AN_RID_STATUS;
1296
			if (an_read_record(sc,
1297
			    (struct an_ltv_gen *)&areq)) {
1298
				error = EINVAL;
1299
				break;
1300
			}
1301
			ireq->i_val = status->an_cur_channel;
1302
			break;
1303
		case IEEE80211_IOC_POWERSAVE:
1304
			areq.an_type = AN_RID_ACTUALCFG;
1305
			if (an_read_record(sc,
1306
			    (struct an_ltv_gen *)&areq)) {
1307
				error = EINVAL;
1308
				break;
1309
			}
1310
			if(config->an_psave_mode == AN_PSAVE_NONE) {
1311
				ireq->i_val = IEEE80211_POWERSAVE_OFF;
1312
			} else if(config->an_psave_mode == AN_PSAVE_CAM) {
1313
				ireq->i_val = IEEE80211_POWERSAVE_CAM;
1314
			} else if(config->an_psave_mode == AN_PSAVE_PSP) {
1315
				ireq->i_val = IEEE80211_POWERSAVE_PSP;
1316
			} else if(config->an_psave_mode == AN_PSAVE_PSP_CAM) {
1317
				ireq->i_val = IEEE80211_POWERSAVE_PSP_CAM;
1318
			} else
1319
				error = EINVAL;
1320
			break;
1321
		case IEEE80211_IOC_POWERSAVESLEEP:
1322
			areq.an_type = AN_RID_ACTUALCFG;
1323
			if (an_read_record(sc,
1324
			    (struct an_ltv_gen *)&areq)) {
1325
				error = EINVAL;
1326
				break;
1327
			}
1328
			ireq->i_val = config->an_listen_interval;
1329
			break;
1330
		}	
1331
		break;
1332
	case SIOCS80211:
1333
		areq.an_len = sizeof(areq);
1334
		/*
1335
		 * We need a config structure for everything but the WEP
1336
		 * key management and SSIDs so we get it now so avoid
1337
		 * duplicating this code every time.
1338
		 */
1339
		if (ireq->i_type != IEEE80211_IOC_SSID &&
1340
		    ireq->i_type != IEEE80211_IOC_WEPKEY &&
1341
		    ireq->i_type != IEEE80211_IOC_WEPTXKEY) {
1342
			areq.an_type = AN_RID_GENCONFIG;
1343
			if (an_read_record(sc,
1344
			    (struct an_ltv_gen *)&areq)) {
1345
				error = EINVAL;
1346
				break;
1347
			}
1348
		}
1349
		switch(ireq->i_type) {
1350
		case IEEE80211_IOC_SSID:
1351
			areq.an_type = AN_RID_SSIDLIST;
1352
			if (an_read_record(sc,
1353
			    (struct an_ltv_gen *)&areq)) {
1354
				error = EINVAL;
1355
				break;
1356
			}
1357
			if(ireq->i_len > IEEE80211_NWID_LEN) {
1358
				error = EINVAL;
1359
				break;
1360
			}
1361
			switch (ireq->i_val) {
1362
			case 0:
1363
				error = copyin(ireq->i_data,
1364
				    ssids->an_ssid1, ireq->i_len);
1365
				ssids->an_ssid1_len = ireq->i_len;
1366
				break;
1367
			case 1:
1368
				error = copyin(ireq->i_data,
1369
				    ssids->an_ssid2, ireq->i_len);
1370
				ssids->an_ssid2_len = ireq->i_len;
1371
				break;
1372
			case 2:
1373
				error = copyin(ireq->i_data,
1374
				    ssids->an_ssid3, ireq->i_len);
1375
				ssids->an_ssid3_len = ireq->i_len;
1376
				break;
1377
			default:
1378
				error = EINVAL;
1379
				break;
1380
			}
1381
			break;
1382
		case IEEE80211_IOC_WEP:
1383
			switch (ireq->i_val) {
1384
			case IEEE80211_WEP_OFF:
1385
				config->an_authtype &=
1386
				    ~(AN_AUTHTYPE_PRIVACY_IN_USE |
1387
				    AN_AUTHTYPE_ALLOW_UNENCRYPTED);
1388
				break;
1389
			case IEEE80211_WEP_ON:
1390
				config->an_authtype |=
1391
				    AN_AUTHTYPE_PRIVACY_IN_USE;
1392
				config->an_authtype &=
1393
				    ~AN_AUTHTYPE_ALLOW_UNENCRYPTED;
1394
				break;
1395
			case IEEE80211_WEP_MIXED:
1396
				config->an_authtype |=
1397
				    AN_AUTHTYPE_PRIVACY_IN_USE |
1398
				    AN_AUTHTYPE_ALLOW_UNENCRYPTED;
1399
				break;
1400
			default:
1401
				error = EINVAL;
1402
				break;
1403
			}
1404
			break;
1405
		case IEEE80211_IOC_WEPKEY:
1406
			if (ireq->i_val < 0 || ireq->i_val > 7 ||
1407
			    ireq->i_len > 13) {
1408
				error = EINVAL;
1409
				break;
1410
			}
1411
			error = copyin(ireq->i_data, tmpstr, 13);
1412
			if(error)
1413
				break;
1414
			bzero(&areq, sizeof(struct an_ltv_key));
1415
			areq.an_len = sizeof(struct an_ltv_key);
1416
			key->mac[0] = 1;	/* The others are 0. */
1417
			key->kindex = ireq->i_val % 4;
1418
			if(ireq->i_val < 4)
1419
				areq.an_type = AN_RID_WEP_TEMP;
1420
			else
1421
				areq.an_type = AN_RID_WEP_PERM;
1422
			key->klen = ireq->i_len;
1423
			bcopy(tmpstr, key->key, key->klen);
1424
			break;
1425
		case IEEE80211_IOC_WEPTXKEY:
1426
			if(ireq->i_val < 0 || ireq->i_val > 3) {
1427
				error = EINVAL;
1428
				break;
1429
			}
1430
			bzero(&areq, sizeof(struct an_ltv_key));
1431
			areq.an_len = sizeof(struct an_ltv_key);
1432
			areq.an_type = AN_RID_WEP_PERM;
1433
			key->kindex = 0xffff;
1434
			key->mac[0] = ireq->i_val;
1435
			break;
1436
		case IEEE80211_IOC_AUTHMODE:
1437
			switch (ireq->i_val) {
1438
			case IEEE80211_AUTH_NONE:
1439
				config->an_authtype = AN_AUTHTYPE_NONE |
1440
				    (config->an_authtype & ~AN_AUTHTYPE_MASK);
1441
				break;
1442
			case IEEE80211_AUTH_OPEN:
1443
				config->an_authtype = AN_AUTHTYPE_OPEN |
1444
				    (config->an_authtype & ~AN_AUTHTYPE_MASK);
1445
				break;
1446
			case IEEE80211_AUTH_SHARED:
1447
				config->an_authtype = AN_AUTHTYPE_SHAREDKEY |
1448
				    (config->an_authtype & ~AN_AUTHTYPE_MASK);
1449
				break;
1450
			default:
1451
				error = EINVAL;
1452
			}
1453
			break;
1454
		case IEEE80211_IOC_STATIONNAME:
1455
			if(ireq->i_len > 16) {
1456
				error = EINVAL;
1457
				break;
1458
			}
1459
			bzero(config->an_nodename, 16);
1460
			error = copyin(ireq->i_data,
1461
			    config->an_nodename, ireq->i_len);
1462
			break;
1463
		case IEEE80211_IOC_CHANNEL:
1464
			/*
1465
			 * The actual range is 1-14, but if you set it
1466
			 * to 0 you get the default so we let that work
1467
			 * too.
1468
			 */
1469
			if (ireq->i_val < 0 || ireq->i_val >14) {
1470
				error = EINVAL;
1471
				break;
1472
			}
1473
			config->an_ds_channel = ireq->i_val;
1474
			break;
1475
		case IEEE80211_IOC_POWERSAVE:
1476
			switch (ireq->i_val) {
1477
			case IEEE80211_POWERSAVE_OFF:
1478
				config->an_psave_mode = AN_PSAVE_NONE;
1479
				break;
1480
			case IEEE80211_POWERSAVE_CAM:
1481
				config->an_psave_mode = AN_PSAVE_CAM;
1482
				break;
1483
			case IEEE80211_POWERSAVE_PSP:
1484
				config->an_psave_mode = AN_PSAVE_PSP;
1485
				break;
1486
			case IEEE80211_POWERSAVE_PSP_CAM:
1487
				config->an_psave_mode = AN_PSAVE_PSP_CAM;
1488
				break;
1489
			default:
1490
				error = EINVAL;
1491
				break;
1492
			}
1493
			break;
1494
		case IEEE80211_IOC_POWERSAVESLEEP:
1495
			config->an_listen_interval = ireq->i_val;
1496
			break;
1497
		}
1498
1499
		if (!error)
1500
			an_setdef(sc, &areq);
1501
		break;
1093
	default:
1502
	default:
1094
		error = EINVAL;
1503
		error = EINVAL;
1095
		break;
1504
		break;
Lines 1447-1452 Link Here
1447
	static int cache_slot = 0; 	/* use this cache entry */
1856
	static int cache_slot = 0; 	/* use this cache entry */
1448
	static int wrapindex = 0;       /* next "free" cache entry */
1857
	static int wrapindex = 0;       /* next "free" cache entry */
1449
	int saanp=0;
1858
	int saanp=0;
1859
	int sig, noise;
1450
1860
1451
	/* filters:
1861
	/* filters:
1452
	 * 1. ip only
1862
	 * 1. ip only
Lines 1554-1556 Link Here
1554
	return;
1964
	return;
1555
}
1965
}
1556
#endif
1966
#endif
1967
1968
static int an_media_change(ifp)
1969
	struct ifnet		*ifp;
1970
{
1971
	struct an_softc *sc = ifp->if_softc;
1972
	int otype = sc->an_config.an_opmode;
1973
	int orate = sc->an_tx_rate;
1974
1975
	if ((sc->an_ifmedia.ifm_cur->ifm_media & IFM_IEEE80211_ADHOC) != 0)
1976
		sc->an_config.an_opmode = AN_OPMODE_IBSS_ADHOC;
1977
	else
1978
		sc->an_config.an_opmode = AN_OPMODE_INFRASTRUCTURE_STATION;
1979
1980
	switch (IFM_SUBTYPE(sc->an_ifmedia.ifm_cur->ifm_media)) {
1981
	case IFM_IEEE80211_DS1:
1982
		sc->an_tx_rate = AN_RATE_1MBPS;
1983
		break;
1984
	case IFM_IEEE80211_DS2:
1985
		sc->an_tx_rate = AN_RATE_2MBPS;
1986
		break;
1987
	case IFM_IEEE80211_DS5:
1988
		sc->an_tx_rate = AN_RATE_5_5MBPS;
1989
		break;
1990
	case IFM_IEEE80211_DS11:
1991
		sc->an_tx_rate = AN_RATE_11MBPS;
1992
		break;
1993
	case IFM_AUTO:
1994
		sc->an_tx_rate = 0;
1995
		break;
1996
	}
1997
1998
	if (otype != sc->an_config.an_opmode ||
1999
	    orate != sc->an_tx_rate)
2000
		an_init(sc);
2001
2002
	return(0);
2003
}
2004
2005
static void an_media_status(ifp, imr)
2006
	struct ifnet		*ifp;
2007
	struct ifmediareq	*imr;
2008
{
2009
	struct an_ltv_status	status;
2010
	struct an_softc		*sc = ifp->if_softc;
2011
2012
	status.an_len = sizeof(status);
2013
	status.an_type = AN_RID_STATUS;
2014
	if (an_read_record(sc, (struct an_ltv_gen *)&status)) {
2015
		/* If the status read fails, just lie. */
2016
		imr->ifm_active = sc->an_ifmedia.ifm_cur->ifm_media;
2017
		imr->ifm_status = IFM_AVALID|IFM_ACTIVE;
2018
	}
2019
2020
	if(sc->an_tx_rate == 0) {
2021
		imr->ifm_active = IFM_IEEE80211|IFM_AUTO;
2022
		if (sc->an_config.an_opmode == AN_OPMODE_IBSS_ADHOC)
2023
			imr->ifm_active |= IFM_IEEE80211_ADHOC;
2024
		switch(status.an_current_tx_rate) {
2025
		case AN_RATE_1MBPS:
2026
			imr->ifm_active |= IFM_IEEE80211_DS1;
2027
			break;
2028
		case AN_RATE_2MBPS:
2029
			imr->ifm_active |= IFM_IEEE80211_DS2;
2030
			break;
2031
		case AN_RATE_5_5MBPS:
2032
			imr->ifm_active |= IFM_IEEE80211_DS5;
2033
			break;
2034
		case AN_RATE_11MBPS:
2035
			imr->ifm_active |= IFM_IEEE80211_DS11;
2036
			break;
2037
		}
2038
	} else {
2039
		imr->ifm_active = sc->an_ifmedia.ifm_cur->ifm_media;
2040
	}
2041
2042
	imr->ifm_status = IFM_AVALID;
2043
	if (sc->an_config.an_opmode == AN_OPMODE_IBSS_ADHOC)
2044
		imr->ifm_status |= IFM_ACTIVE;
2045
	else if (status.an_opmode & AN_STATUS_OPMODE_ASSOCIATED)
2046
			imr->ifm_status |= IFM_ACTIVE;
2047
}
(-)sys/dev/an/if_an_isa.c (+2 lines)
Lines 63-68 Link Here
63
#include <net/ethernet.h>
63
#include <net/ethernet.h>
64
#include <net/if_dl.h>
64
#include <net/if_dl.h>
65
#include <net/if_types.h>
65
#include <net/if_types.h>
66
#include <net/if_media.h>
66
67
67
#include <isa/isavar.h>
68
#include <isa/isavar.h>
68
#include <isa/pnpvar.h>
69
#include <isa/pnpvar.h>
Lines 137-142 Link Here
137
	struct ifnet		*ifp = &sc->arpcom.ac_if;
138
	struct ifnet		*ifp = &sc->arpcom.ac_if;
138
139
139
	an_stop(sc);
140
	an_stop(sc);
141
	ifmedia_removeall(&sc->an_ifmedia);
140
	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
142
	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
141
	bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
143
	bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
142
	an_release_resources(dev);
144
	an_release_resources(dev);
(-)sys/dev/an/if_an_pccard.c (+2 lines)
Lines 63-68 Link Here
63
#include <net/ethernet.h>
63
#include <net/ethernet.h>
64
#include <net/if_dl.h>
64
#include <net/if_dl.h>
65
#include <net/if_types.h>
65
#include <net/if_types.h>
66
#include <net/if_media.h>
66
67
67
#ifndef lint
68
#ifndef lint
68
static const char rcsid[] =
69
static const char rcsid[] =
Lines 110-115 Link Here
110
		return(0);
111
		return(0);
111
	}
112
	}
112
	an_stop(sc);
113
	an_stop(sc);
114
	ifmedia_removeall(&sc->an_ifmedia);
113
	ifp->if_flags &= ~IFF_RUNNING;
115
	ifp->if_flags &= ~IFF_RUNNING;
114
	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
116
	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
115
	sc->an_gone = 1;
117
	sc->an_gone = 1;
(-)sys/dev/an/if_an_pci.c (+2 lines)
Lines 76-81 Link Here
76
#include <net/if_arp.h>
76
#include <net/if_arp.h>
77
#include <net/ethernet.h>
77
#include <net/ethernet.h>
78
#include <net/if_dl.h>
78
#include <net/if_dl.h>
79
#include <net/if_media.h>
79
80
80
#include <pci/pcireg.h>
81
#include <pci/pcireg.h>
81
#include <pci/pcivar.h>
82
#include <pci/pcivar.h>
Lines 195-200 Link Here
195
	struct ifnet		*ifp = &sc->arpcom.ac_if;
196
	struct ifnet		*ifp = &sc->arpcom.ac_if;
196
197
197
	an_stop(sc);
198
	an_stop(sc);
199
	ifmedia_removeall(&sc->an_ifmedia);
198
	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
200
	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
199
	bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
201
	bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
200
	an_release_resources(dev);
202
	an_release_resources(dev);
(-)sys/dev/an/if_anreg.h (+1 lines)
Lines 842-847 Link Here
842
	struct callout_handle	an_stat_ch;
842
	struct callout_handle	an_stat_ch;
843
	struct mtx		an_mtx;
843
	struct mtx		an_mtx;
844
	device_t		an_dev;
844
	device_t		an_dev;
845
	struct ifmedia		an_ifmedia;
845
};
846
};
846
847
847
#define AN_LOCK(_sc)		mtx_lock(&(_sc)->an_mtx)
848
#define AN_LOCK(_sc)		mtx_lock(&(_sc)->an_mtx)
(-)sys/dev/awi/awi.c (+181 lines)
Lines 455-463 Link Here
455
	struct awi_softc *sc = ifp->if_softc;
455
	struct awi_softc *sc = ifp->if_softc;
456
	struct ifreq *ifr = (struct ifreq *)data;
456
	struct ifreq *ifr = (struct ifreq *)data;
457
	struct ifaddr *ifa = (struct ifaddr *)data;
457
	struct ifaddr *ifa = (struct ifaddr *)data;
458
	struct ieee80211req *ireq = (struct ieee80211req *)data;
458
	int s, error;
459
	int s, error;
459
	struct ieee80211_nwid nwid;
460
	struct ieee80211_nwid nwid;
460
	u_int8_t *p;
461
	u_int8_t *p;
462
	int len;
463
	u_int8_t tmpstr[IEEE80211_NWID_LEN*2];
461
464
462
	s = splnet();
465
	s = splnet();
463
466
Lines 566-571 Link Here
566
		error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
569
		error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
567
		break;
570
		break;
568
#endif
571
#endif
572
#ifdef __FreeBSD__
573
	case SIOCG80211:
574
		switch(ireq->i_type) {
575
		case IEEE80211_IOC_SSID:
576
			bzero(tmpstr, IEEE80211_NWID_LEN);
577
			if(ireq->i_val == -1 && ifp->if_flags & IFF_RUNNING) {
578
				if (sc->sc_mib_local.Network_Mode) {
579
					p = sc->sc_bss.essid;
580
					len = p[1];
581
					p += 2;
582
				} else {
583
					len = ETHER_ADDR_LEN;
584
					p = sc->sc_bss.bssid;
585
				}
586
			} else if(ireq->i_val == 0) {
587
				if (sc->sc_mib_local.Network_Mode)
588
					p = sc->sc_mib_mac.aDesired_ESS_ID;
589
				else
590
					p = sc->sc_ownssid;
591
				len = p[1];
592
				p += 2;
593
			} else {
594
				error = EINVAL;
595
				break;
596
			}
597
			if(len > IEEE80211_NWID_LEN) {
598
				error = EINVAL;
599
				break;
600
			}
601
			bcopy(p, tmpstr, len);
602
			error = copyout(tmpstr, ireq->i_data,
603
			    IEEE80211_NWID_LEN);
604
			break;
605
		case IEEE80211_IOC_NUMSSIDS:
606
			ireq->i_val = 1;
607
			break;
608
		case IEEE80211_IOC_WEP:
609
			/* XXX: I'm not sure this is entierly correct */
610
			ireq->i_val = awi_wep_getalgo(sc);
611
			if(ireq->i_val != IEEE80211_WEP_OFF)
612
				ireq->i_val = IEEE80211_WEP_ON;
613
			break;
614
		case IEEE80211_IOC_WEPKEY:
615
			if(ireq->i_val < 0 || ireq->i_val > 3) {
616
				error = EINVAL;
617
				break;
618
			}
619
			len = sizeof(tmpstr);
620
			error = awi_wep_getkey(sc, ireq->i_val, tmpstr, &len);
621
			if(error)
622
				break;
623
			if(!suser(curproc))
624
				bzero(tmpstr, len);
625
			ireq->i_val = len;
626
			error = copyout(tmpstr, ireq->i_data, len);
627
			break;
628
		case IEEE80211_IOC_NUMWEPKEYS:
629
			ireq->i_val = 4;
630
			break;
631
		case IEEE80211_IOC_WEPTXKEY:
632
			ireq->i_val = sc->sc_wep_defkid;
633
			break;
634
		case IEEE80211_IOC_AUTHMODE:
635
			/* XXX: Is this correct? */
636
			ireq->i_val = IEEE80211_AUTH_OPEN;
637
			break;
638
		case IEEE80211_IOC_STATIONNAME:
639
			bzero(tmpstr, IEEE80211_NWID_LEN);
640
			p = hostname;
641
			len = strlen(hostname);
642
			if(len > IEEE80211_NWID_LEN) {
643
				error = EINVAL;
644
				break;
645
			}
646
			bcopy(p, tmpstr, len);
647
			error = copyout(tmpstr, ireq->i_data,
648
			    IEEE80211_NWID_LEN);
649
			break;
650
		case IEEE80211_IOC_CHANNEL:
651
			/* XXX: Handle FH cards */
652
			ireq->i_val = sc->sc_bss.chanset;
653
			break;
654
		case IEEE80211_IOC_POWERSAVE:
655
			/*
656
			 * There appears to be a mib for this in the
657
			 * softc, but since there's no way to enable
658
			 * powersaving reporting it's value isn't really
659
			 * meaningfull.
660
			 */
661
			ireq->i_val = IEEE80211_POWERSAVE_NOSUP;
662
			break;
663
		case IEEE80211_IOC_POWERSAVESLEEP:
664
			error = EINVAL;
665
			break;
666
		default:
667
			error = EINVAL;
668
			break;
669
		}
670
		break;
671
	case SIOCS80211:
672
		error = suser(curproc);
673
		if(error)
674
			break;
675
		switch(ireq->i_type) {
676
		case IEEE80211_IOC_SSID:
677
			if(ireq->i_val != 0) {
678
				error = EINVAL;
679
				break;
680
			}
681
			bzero(tmpstr, AWI_ESS_ID_SIZE);
682
			tmpstr[0] = IEEE80211_ELEMID_SSID;
683
			tmpstr[1] = ireq->i_val;
684
			error = copyin(ireq->i_data, tmpstr+2, ireq->i_val);
685
			if(error)
686
				break;
687
			bcopy(tmpstr, sc->sc_mib_mac.aDesired_ESS_ID, 
688
				AWI_ESS_ID_SIZE);
689
			bcopy(tmpstr, sc->sc_ownssid, AWI_ESS_ID_SIZE);
690
			break;
691
		case IEEE80211_IOC_WEP:
692
			if(ireq->i_val == IEEE80211_WEP_OFF)
693
				error = awi_wep_setalgo(sc, 0);
694
			else
695
				error = awi_wep_setalgo(sc, 1);
696
			break;
697
		case IEEE80211_IOC_WEPKEY:
698
			error = copyin(ireq->i_data, tmpstr, 14);
699
			if(error)
700
				break;
701
			if(ireq->i_val < 0 || ireq->i_val > 3 ||
702
			    tmpstr[0] > 13) {
703
				error = EINVAL;
704
				break;
705
			}
706
			error = awi_wep_setkey(sc, ireq->i_val, tmpstr+1,
707
			    tmpstr[0]);
708
			break;
709
		case IEEE80211_IOC_WEPTXKEY:
710
			if(ireq->i_val < 0 || ireq->i_val > 3) {
711
				error = EINVAL;
712
				break;
713
			}
714
			sc->sc_wep_defkid = ireq->i_val;
715
			break;
716
		case IEEE80211_IOC_AUTHMODE:
717
			error = EINVAL;
718
			break;
719
		case IEEE80211_IOC_STATIONNAME:
720
			error = EPERM;
721
			break;
722
		case IEEE80211_IOC_CHANNEL:
723
			if(ireq->i_val < sc->sc_scan_min ||
724
			    ireq->i_val > sc->sc_scan_max) {
725
				error = EINVAL;
726
				break;
727
			}
728
			sc->sc_ownch = ireq->i_val;
729
			break;
730
		case IEEE80211_IOC_POWERSAVE:
731
			if(ireq->i_val != 0)
732
				error = EINVAL;
733
			break;
734
		case IEEE80211_IOC_POWERSAVESLEEP:
735
			error = EINVAL;
736
			break;
737
		default:
738
			error = EINVAL;
739
			break;
740
		}
741
		/* Restart the card so the change takes effect */
742
		if(!error) {
743
			if(sc->sc_enabled) {
744
				awi_stop(sc);
745
				error = awi_init(sc);
746
			}
747
		}
748
		break;
749
#endif /* __FreeBSD__ */
569
	default:
750
	default:
570
		error = awi_wicfg(ifp, cmd, data);
751
		error = awi_wicfg(ifp, cmd, data);
571
		break;
752
		break;
(-)sys/dev/wi/if_wavelan_ieee.h (-1 / +3 lines)
Lines 169-174 Link Here
169
	u_int32_t		wi_rx_msg_in_msg_frags;
169
	u_int32_t		wi_rx_msg_in_msg_frags;
170
	u_int32_t		wi_rx_msg_in_bad_msg_frags;
170
	u_int32_t		wi_rx_msg_in_bad_msg_frags;
171
};
171
};
172
#endif
172
173
173
/*
174
/*
174
 * These are all the LTV record types that we can read or write
175
 * These are all the LTV record types that we can read or write
Lines 247-252 Link Here
247
#define WI_RID_TX_CRYPT_KEY	0xFCB1
248
#define WI_RID_TX_CRYPT_KEY	0xFCB1
248
#define WI_RID_TICK_TIME	0xFCE0
249
#define WI_RID_TICK_TIME	0xFCE0
249
250
251
#ifndef _KERNEL
250
struct wi_key {
252
struct wi_key {
251
	u_int16_t		wi_keylen;
253
	u_int16_t		wi_keylen;
252
	u_int8_t		wi_keydat[14];
254
	u_int8_t		wi_keydat[14];
Lines 257-262 Link Here
257
	u_int16_t		wi_type;
259
	u_int16_t		wi_type;
258
	struct wi_key		wi_keys[4];
260
	struct wi_key		wi_keys[4];
259
};
261
};
262
#endif
260
263
261
/*
264
/*
262
 * NIC information
265
 * NIC information
Lines 315-321 Link Here
315
#define WI_RID_CCA_TIME		0xFDC4 /* clear chan assess time */
318
#define WI_RID_CCA_TIME		0xFDC4 /* clear chan assess time */
316
#define WI_RID_MAC_PROC_DELAY	0xFDC5 /* MAC processing delay time */
319
#define WI_RID_MAC_PROC_DELAY	0xFDC5 /* MAC processing delay time */
317
#define WI_RID_DATA_RATES	0xFDC6 /* supported data rates */
320
#define WI_RID_DATA_RATES	0xFDC6 /* supported data rates */
318
#endif
319
321
320
322
321
#endif
323
#endif
(-)sys/dev/wi/if_wi.c (-1 / +378 lines)
Lines 91-96 Link Here
91
#include <net/if_dl.h>
91
#include <net/if_dl.h>
92
#include <net/if_media.h>
92
#include <net/if_media.h>
93
#include <net/if_types.h>
93
#include <net/if_types.h>
94
#include <net/if_ieee80211.h>
94
95
95
#include <netinet/in.h>
96
#include <netinet/in.h>
96
#include <netinet/in_systm.h>
97
#include <netinet/in_systm.h>
Lines 157-162 Link Here
157
static int wi_alloc		__P((device_t));
158
static int wi_alloc		__P((device_t));
158
static void wi_free		__P((device_t));
159
static void wi_free		__P((device_t));
159
160
161
static int wi_get_cur_ssid	__P((struct wi_softc *, char *, int *));
162
static int wi_media_change	__P((struct ifnet *));
163
static void wi_media_status	__P((struct ifnet *, struct ifmediareq *));
164
160
static device_method_t wi_pccard_methods[] = {
165
static device_method_t wi_pccard_methods[] = {
161
	/* Device interface */
166
	/* Device interface */
162
	DEVMETHOD(device_probe,		pccard_compat_probe),
167
	DEVMETHOD(device_probe,		pccard_compat_probe),
Lines 242-247 Link Here
242
247
243
	wi_stop(sc);
248
	wi_stop(sc);
244
249
250
	/* Delete all remaining media. */
251
	ifmedia_removeall(&sc->ifmedia);
252
245
	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
253
	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
246
	bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
254
	bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
247
	wi_free(dev);
255
	wi_free(dev);
Lines 346-352 Link Here
346
	    sizeof(WI_DEFAULT_IBSS) - 1);
354
	    sizeof(WI_DEFAULT_IBSS) - 1);
347
355
348
	sc->wi_portnum = WI_DEFAULT_PORT;
356
	sc->wi_portnum = WI_DEFAULT_PORT;
349
	sc->wi_ptype = WI_PORTTYPE_ADHOC;
357
	sc->wi_ptype = WI_PORTTYPE_BSS;
350
	sc->wi_ap_density = WI_DEFAULT_AP_DENSITY;
358
	sc->wi_ap_density = WI_DEFAULT_AP_DENSITY;
351
	sc->wi_rts_thresh = WI_DEFAULT_RTS_THRESH;
359
	sc->wi_rts_thresh = WI_DEFAULT_RTS_THRESH;
352
	sc->wi_tx_rate = WI_DEFAULT_TX_RATE;
360
	sc->wi_tx_rate = WI_DEFAULT_TX_RATE;
Lines 385-390 Link Here
385
	wi_init(sc);
393
	wi_init(sc);
386
	wi_stop(sc);
394
	wi_stop(sc);
387
395
396
	ifmedia_init(&sc->ifmedia, 0, wi_media_change, wi_media_status);
397
	/* XXX: Should read from card capabilities */
398
#define ADD(m, c)       ifmedia_add(&sc->ifmedia, (m), (c), NULL)
399
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1,
400
	    IFM_IEEE80211_ADHOC, 0), 0);
401
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, 0, 0), 0);
402
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2,
403
	    IFM_IEEE80211_ADHOC, 0), 0);
404
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, 0, 0), 0);
405
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5,
406
	    IFM_IEEE80211_ADHOC, 0), 0);
407
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5, 0, 0), 0);
408
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11,
409
	    IFM_IEEE80211_ADHOC, 0), 0);
410
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, 0, 0), 0);
411
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 
412
		IFM_IEEE80211_ADHOC, 0), 0);
413
	ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0), 0);
414
#undef	ADD
415
	ifmedia_set(&sc->ifmedia, IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO,
416
	    0, 0));
417
418
388
	/*
419
	/*
389
	 * Call MI attach routine.
420
	 * Call MI attach routine.
390
	 */
421
	 */
Lines 1137-1150 Link Here
1137
	caddr_t			data;
1168
	caddr_t			data;
1138
{
1169
{
1139
	int			error = 0;
1170
	int			error = 0;
1171
	int			len;
1172
	u_int8_t		tmpkey[14];
1173
	char			tmpssid[IEEE80211_NWID_LEN];
1140
	struct wi_softc		*sc;
1174
	struct wi_softc		*sc;
1141
	struct wi_req		wreq;
1175
	struct wi_req		wreq;
1142
	struct ifreq		*ifr;
1176
	struct ifreq		*ifr;
1177
	struct ieee80211req	*ireq;
1143
	struct proc		*p = curproc;
1178
	struct proc		*p = curproc;
1144
1179
1145
	sc = ifp->if_softc;
1180
	sc = ifp->if_softc;
1146
	WI_LOCK(sc);
1181
	WI_LOCK(sc);
1147
	ifr = (struct ifreq *)data;
1182
	ifr = (struct ifreq *)data;
1183
	ireq = (struct ieee80211req *)data;
1148
1184
1149
	if (sc->wi_gone) {
1185
	if (sc->wi_gone) {
1150
		error = ENODEV;
1186
		error = ENODEV;
Lines 1177-1182 Link Here
1177
		sc->wi_if_flags = ifp->if_flags;
1213
		sc->wi_if_flags = ifp->if_flags;
1178
		error = 0;
1214
		error = 0;
1179
		break;
1215
		break;
1216
	case SIOCSIFMEDIA:
1217
	case SIOCGIFMEDIA:
1218
		error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, command);
1219
		break;
1180
	case SIOCADDMULTI:
1220
	case SIOCADDMULTI:
1181
	case SIOCDELMULTI:
1221
	case SIOCDELMULTI:
1182
		wi_setmulti(sc);
1222
		wi_setmulti(sc);
Lines 1238-1243 Link Here
1238
				wi_setdef(sc, &wreq);
1278
				wi_setdef(sc, &wreq);
1239
		}
1279
		}
1240
		break;
1280
		break;
1281
	case SIOCG80211:
1282
		switch(ireq->i_type) {
1283
		case IEEE80211_IOC_SSID:
1284
			if(ireq->i_val == -1) {
1285
				bzero(tmpssid, IEEE80211_NWID_LEN);
1286
				error = wi_get_cur_ssid(sc, tmpssid, &len);
1287
				printf("wi: '%s' %d\n", tmpssid, len);
1288
				if (error != 0)
1289
					break;
1290
				error = copyout(tmpssid, ireq->i_data,
1291
					IEEE80211_NWID_LEN);
1292
				ireq->i_len = len;
1293
			} else if (ireq->i_val == 0) {
1294
				error = copyout(sc->wi_net_name,
1295
				    ireq->i_data,
1296
				    IEEE80211_NWID_LEN);
1297
				ireq->i_len = IEEE80211_NWID_LEN;
1298
			} else
1299
				error = EINVAL;
1300
			break;
1301
		case IEEE80211_IOC_NUMSSIDS:
1302
			ireq->i_val = 1;
1303
			break;
1304
		case IEEE80211_IOC_WEP:
1305
			if(!sc->wi_has_wep) {
1306
				ireq->i_val = IEEE80211_WEP_NOSUP; 
1307
			} else {
1308
				if(sc->wi_use_wep) {
1309
					ireq->i_val =
1310
					    IEEE80211_WEP_MIXED;
1311
				} else {
1312
					ireq->i_val =
1313
					    IEEE80211_WEP_OFF;
1314
				}
1315
			}
1316
			break;
1317
		case IEEE80211_IOC_WEPKEY:
1318
			if(!sc->wi_has_wep ||
1319
			    ireq->i_val < 0 || ireq->i_val > 3) {
1320
				error = EINVAL;
1321
				break;
1322
			}
1323
			len = sc->wi_keys.wi_keys[ireq->i_val].wi_keylen;
1324
			if (suser(p))
1325
				bcopy(sc->wi_keys.wi_keys[ireq->i_val].wi_keydat,
1326
				    tmpkey, len);
1327
			else
1328
				bzero(tmpkey, len);
1329
1330
			ireq->i_len = len;
1331
			error = copyout(tmpkey, ireq->i_data, len);
1332
1333
			break;
1334
		case IEEE80211_IOC_NUMWEPKEYS:
1335
			if(!sc->wi_has_wep)
1336
				error = EINVAL;
1337
			else
1338
				ireq->i_val = 4;
1339
			break;
1340
		case IEEE80211_IOC_WEPTXKEY:
1341
			if(!sc->wi_has_wep)
1342
				error = EINVAL;
1343
			else
1344
				ireq->i_val = sc->wi_tx_key;
1345
			break;
1346
		case IEEE80211_IOC_AUTHMODE:
1347
			ireq->i_val = IEEE80211_AUTH_NONE;
1348
			break;
1349
		case IEEE80211_IOC_STATIONNAME:
1350
			error = copyout(sc->wi_node_name,
1351
			    ireq->i_data, IEEE80211_NWID_LEN);
1352
			ireq->i_len = IEEE80211_NWID_LEN;
1353
			break;
1354
		case IEEE80211_IOC_CHANNEL:
1355
			wreq.wi_type = WI_RID_CURRENT_CHAN;
1356
			wreq.wi_len = WI_MAX_DATALEN;
1357
			if (wi_read_record(sc, (struct wi_ltv_gen *)&wreq))
1358
				error = EINVAL;
1359
			else {
1360
				ireq->i_val = wreq.wi_val[0];
1361
			}
1362
			break;
1363
		case IEEE80211_IOC_POWERSAVE:
1364
			if(sc->wi_pm_enabled)
1365
				ireq->i_val = IEEE80211_POWERSAVE_ON;
1366
			else
1367
				ireq->i_val = IEEE80211_POWERSAVE_OFF;
1368
			break;
1369
		case IEEE80211_IOC_POWERSAVESLEEP:
1370
			ireq->i_val = sc->wi_max_sleep;
1371
			break;
1372
		default:
1373
			error = EINVAL;
1374
		}
1375
		break;
1376
	case SIOCS80211:
1377
		if ((error = suser(p)))
1378
			goto out;
1379
		switch(ireq->i_type) {
1380
		case IEEE80211_IOC_SSID:
1381
			if (ireq->i_val != 0 ||
1382
			    ireq->i_len > IEEE80211_NWID_LEN) {
1383
				error = EINVAL;
1384
				break;
1385
			}
1386
			/* We set both of them */
1387
			bzero(sc->wi_net_name, IEEE80211_NWID_LEN);
1388
			error = copyin(ireq->i_data,
1389
			    sc->wi_net_name, ireq->i_len);
1390
			bcopy(sc->wi_net_name, sc->wi_ibss_name, IEEE80211_NWID_LEN);
1391
			break;
1392
		case IEEE80211_IOC_WEP:
1393
			/*
1394
			 * These cards only support one mode so
1395
			 * we just turn wep on what ever is
1396
			 * passed in if it's not OFF.
1397
			 */
1398
			if (ireq->i_val == IEEE80211_WEP_OFF) {
1399
				sc->wi_use_wep = 0;
1400
			} else {
1401
				sc->wi_use_wep = 1;
1402
			}
1403
			break;
1404
		case IEEE80211_IOC_WEPKEY:
1405
			if (ireq->i_val < 0 || ireq->i_val > 3 ||
1406
				ireq->i_len > 13) {
1407
				error = EINVAL;
1408
				break;
1409
			} 
1410
			bzero(sc->wi_keys.wi_keys[ireq->i_val].wi_keydat, 13);
1411
			error = copyin(ireq->i_data, 
1412
			    sc->wi_keys.wi_keys[ireq->i_val].wi_keydat,
1413
			    ireq->i_len);
1414
			if(error)
1415
				break;
1416
			sc->wi_keys.wi_keys[ireq->i_val].wi_keylen =
1417
				    ireq->i_len;
1418
			break;
1419
		case IEEE80211_IOC_WEPTXKEY:
1420
			if (ireq->i_val < 0 || ireq->i_val > 3) {
1421
				error = EINVAL;
1422
				break;
1423
			}
1424
			sc->wi_tx_key = ireq->i_val;
1425
			break;
1426
		case IEEE80211_IOC_AUTHMODE:
1427
			error = EINVAL;
1428
			break;
1429
		case IEEE80211_IOC_STATIONNAME:
1430
			if (ireq->i_len > 32) {
1431
				error = EINVAL;
1432
				break;
1433
			}
1434
			bzero(sc->wi_node_name, 32);
1435
			error = copyin(ireq->i_data,
1436
			    sc->wi_node_name, ireq->i_len);
1437
			break;
1438
		case IEEE80211_IOC_CHANNEL:
1439
			/*
1440
			 * The actual range is 1-14, but if you
1441
			 * set it to 0 you get the default. So
1442
			 * we let that work too.
1443
			 */
1444
			if (ireq->i_val < 0 || ireq->i_val > 14) {
1445
				error = EINVAL;
1446
				break;
1447
			}
1448
			sc->wi_channel = ireq->i_val;
1449
			break;
1450
		case IEEE80211_IOC_POWERSAVE:
1451
			switch (ireq->i_val) {
1452
			case IEEE80211_POWERSAVE_OFF:
1453
				sc->wi_pm_enabled = 0;
1454
				break;
1455
			case IEEE80211_POWERSAVE_ON:
1456
				sc->wi_pm_enabled = 1;
1457
				break;
1458
			default:
1459
				error = EINVAL;
1460
				break;
1461
			}
1462
			break;
1463
		case IEEE80211_IOC_POWERSAVESLEEP:
1464
			if (ireq->i_val < 0) {
1465
				error = EINVAL;
1466
				break;
1467
			}
1468
			sc->wi_max_sleep = ireq->i_val;
1469
			break;
1470
		default:
1471
			error = EINVAL;
1472
			break;
1473
		}
1474
1475
		/* Reinitialize WaveLAN. */
1476
		wi_init(sc);
1477
1478
		break;
1241
	default:
1479
	default:
1242
		error = EINVAL;
1480
		error = EINVAL;
1243
		break;
1481
		break;
Lines 1796-1798 Link Here
1796
	return;
2034
	return;
1797
}
2035
}
1798
#endif
2036
#endif
2037
2038
static int wi_get_cur_ssid(sc, ssid, len)
2039
	struct wi_softc		*sc;
2040
	char			*ssid;
2041
	int			*len;
2042
{
2043
	int			error = 0;
2044
	struct wi_req		wreq;
2045
2046
	wreq.wi_len = WI_MAX_DATALEN;
2047
	switch (sc->wi_ptype) {
2048
	case WI_PORTTYPE_ADHOC:
2049
		wreq.wi_type = WI_RID_CURRENT_SSID;
2050
		error = wi_read_record(sc, (struct wi_ltv_gen *)&wreq);
2051
		if (error != 0)
2052
			break;
2053
		if (wreq.wi_val[0] > IEEE80211_NWID_LEN) {
2054
			error = EINVAL;
2055
			break;
2056
		}
2057
		*len = wreq.wi_val[0];
2058
		bcopy(&wreq.wi_val[1], ssid, IEEE80211_NWID_LEN);
2059
		break;
2060
	case WI_PORTTYPE_BSS:
2061
		wreq.wi_type = WI_RID_COMMQUAL;
2062
		error = wi_read_record(sc, (struct wi_ltv_gen *)&wreq);
2063
		if (error != 0)
2064
			break;
2065
		if (wreq.wi_val[0] != 0) /* associated */ {
2066
			wreq.wi_type = WI_RID_CURRENT_SSID;
2067
			wreq.wi_len = WI_MAX_DATALEN;
2068
			error = wi_read_record(sc, (struct wi_ltv_gen *)&wreq);
2069
			if (error != 0)
2070
				break;
2071
			if (wreq.wi_val[0] > IEEE80211_NWID_LEN) {
2072
				error = EINVAL;
2073
				break;
2074
			}
2075
			*len = wreq.wi_val[0];
2076
			bcopy(&wreq.wi_val[1], ssid, IEEE80211_NWID_LEN);
2077
		} else {
2078
			*len = IEEE80211_NWID_LEN;
2079
			bcopy(sc->wi_net_name, ssid, IEEE80211_NWID_LEN);
2080
		}
2081
		break;
2082
	default:
2083
		error = EINVAL;
2084
		break;
2085
	}
2086
2087
	return error;
2088
}
2089
2090
static int wi_media_change(ifp)
2091
	struct ifnet		*ifp;
2092
{
2093
	struct wi_softc		*sc = ifp->if_softc;
2094
	int			otype = sc->wi_ptype;
2095
	int			orate = sc->wi_tx_rate;
2096
2097
	if ((sc->ifmedia.ifm_cur->ifm_media & IFM_IEEE80211_ADHOC) != 0)
2098
		sc->wi_ptype = WI_PORTTYPE_ADHOC;
2099
	else
2100
		sc->wi_ptype = WI_PORTTYPE_BSS;
2101
2102
	switch (IFM_SUBTYPE(sc->ifmedia.ifm_cur->ifm_media)) {
2103
	case IFM_IEEE80211_DS1:
2104
		sc->wi_tx_rate = 1;
2105
		break;
2106
	case IFM_IEEE80211_DS2:
2107
		sc->wi_tx_rate = 2;
2108
		break;
2109
	case IFM_IEEE80211_DS5:
2110
		sc->wi_tx_rate = 5;
2111
		break;
2112
	case IFM_IEEE80211_DS11:
2113
		sc->wi_tx_rate = 11;
2114
		break;
2115
	case IFM_AUTO:
2116
		sc->wi_tx_rate = 3;
2117
		break;
2118
	}
2119
2120
	if (otype != sc->wi_ptype ||
2121
	    orate != sc->wi_tx_rate)
2122
		wi_init(sc);
2123
2124
	return(0);
2125
}
2126
2127
static void wi_media_status(ifp, imr)
2128
	struct ifnet		*ifp;
2129
	struct ifmediareq	*imr;
2130
{
2131
	struct wi_req		wreq;
2132
	struct wi_softc		*sc = ifp->if_softc;
2133
2134
	if (sc->wi_tx_rate == 3) {
2135
		imr->ifm_active = IFM_IEEE80211|IFM_AUTO;
2136
		if (sc->wi_ptype == WI_PORTTYPE_ADHOC)
2137
			imr->ifm_active |= IFM_IEEE80211_ADHOC;
2138
		wreq.wi_type = WI_RID_CUR_TX_RATE;
2139
		wreq.wi_len = WI_MAX_DATALEN;
2140
		if (wi_read_record(sc, (struct wi_ltv_gen *)&wreq) == 0) {
2141
			switch(wreq.wi_val[0]) {
2142
			case 1:
2143
				imr->ifm_active |= IFM_IEEE80211_DS1;
2144
				break;
2145
			case 2:
2146
				imr->ifm_active |= IFM_IEEE80211_DS2;
2147
				break;
2148
			case 6:
2149
				imr->ifm_active |= IFM_IEEE80211_DS5;
2150
				break;
2151
			case 11:
2152
				imr->ifm_active |= IFM_IEEE80211_DS11;
2153
				break;
2154
				}
2155
		}
2156
	} else {
2157
		imr->ifm_active = sc->ifmedia.ifm_cur->ifm_media;
2158
	}
2159
2160
	imr->ifm_status = IFM_AVALID;
2161
	if (sc->wi_ptype == WI_PORTTYPE_ADHOC)
2162
		/*
2163
		 * XXX: It would be nice if we could give some actually
2164
		 * useful status like whether we joined another IBSS or
2165
		 * created one ourselves.
2166
		 */
2167
		imr->ifm_status |= IFM_ACTIVE;
2168
	else {
2169
		wreq.wi_type = WI_RID_COMMQUAL;
2170
		wreq.wi_len = WI_MAX_DATALEN;
2171
		if (wi_read_record(sc, (struct wi_ltv_gen *)&wreq) == 0 &&
2172
		    wreq.wi_val[0] != 0)
2173
			imr->ifm_status |= IFM_ACTIVE;
2174
	}
2175
}
(-)sys/net/if_ieee80211.h (+39 lines)
Lines 168-171 Link Here
168
#define	SIOCS80211NWKEY		 _IOW('i', 232, struct ieee80211_nwkey)
168
#define	SIOCS80211NWKEY		 _IOW('i', 232, struct ieee80211_nwkey)
169
#define	SIOCG80211NWKEY		_IOWR('i', 233, struct ieee80211_nwkey)
169
#define	SIOCG80211NWKEY		_IOWR('i', 233, struct ieee80211_nwkey)
170
170
171
#define IEEE80211_WEP_NOSUP	-1
172
#define IEEE80211_WEP_OFF	0
173
#define IEEE80211_WEP_ON	1
174
#define IEEE80211_WEP_MIXED	2
175
176
#define IEEE80211_AUTH_NONE	0
177
#define IEEE80211_AUTH_OPEN	1
178
#define IEEE80211_AUTH_SHARED	2
179
180
#define IEEE80211_POWERSAVE_NOSUP	-1
181
#define IEEE80211_POWERSAVE_OFF		0
182
#define IEEE80211_POWERSAVE_CAM		1
183
#define IEEE80211_POWERSAVE_PSP		2
184
#define IEEE80211_POWERSAVE_PSP_CAM	3
185
#define IEEE80211_POWERSAVE_ON		IEEE80211_POWERSAVE_CAM
186
187
/* the first member must be matched with struct ifreq */
188
struct ieee80211req {
189
	char		i_name[IFNAMSIZ];	/* if_name, e.g. "wi0" */
190
	u_int16_t	i_type;			/* req type */
191
	int16_t		i_val;			/* Index or simple value */
192
	int16_t		i_len;			/* Index or simple value */
193
	void		*i_data;		/* Extra data */
194
};
195
#define	SIOCS80211		 _IOW('i', 234, struct ieee80211req)
196
#define	SIOCG80211		_IOWR('i', 235, struct ieee80211req)
197
198
#define IEEE80211_IOC_SSID		1
199
#define IEEE80211_IOC_NUMSSIDS		2
200
#define IEEE80211_IOC_WEP		3
201
#define IEEE80211_IOC_WEPKEY		4
202
#define IEEE80211_IOC_NUMWEPKEYS	5
203
#define IEEE80211_IOC_WEPTXKEY		6
204
#define IEEE80211_IOC_AUTHMODE		7
205
#define IEEE80211_IOC_STATIONNAME	8
206
#define IEEE80211_IOC_CHANNEL		9
207
#define IEEE80211_IOC_POWERSAVE		10
208
#define IEEE80211_IOC_POWERSAVESLEEP	11
209
171
#endif /* !_NET_IF_IEEE80211_H_ */
210
#endif /* !_NET_IF_IEEE80211_H_ */
(-)sys/net/if_media.c (+10 lines)
Lines 401-406 Link Here
401
struct ifmedia_description ifm_subtype_fddi_option_descriptions[] =
401
struct ifmedia_description ifm_subtype_fddi_option_descriptions[] =
402
    IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS;
402
    IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS;
403
403
404
struct ifmedia_description ifm_subtype_ieee80211_descriptions[] =
405
    IFM_SUBTYPE_IEEE80211_DESCRIPTIONS;
406
407
struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] =
408
    IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS;
409
404
struct ifmedia_description ifm_subtype_shared_descriptions[] =
410
struct ifmedia_description ifm_subtype_shared_descriptions[] =
405
    IFM_SUBTYPE_SHARED_DESCRIPTIONS;
411
    IFM_SUBTYPE_SHARED_DESCRIPTIONS;
406
412
Lines 425-430 Link Here
425
	{
431
	{
426
	  &ifm_subtype_fddi_descriptions[0],
432
	  &ifm_subtype_fddi_descriptions[0],
427
	  &ifm_subtype_fddi_option_descriptions[0]
433
	  &ifm_subtype_fddi_option_descriptions[0]
434
	},
435
	{
436
	  &ifm_subtype_ieee80211_descriptions[0],
437
	  &ifm_subtype_ieee80211_option_descriptions[0]
428
	},
438
	},
429
};
439
};
430
440
(-)sys/net/if_media.h (-3 / +47 lines)
Lines 167-172 Link Here
167
#define IFM_FDDI_DA	0x00000100	/* Dual attach / single attach */
167
#define IFM_FDDI_DA	0x00000100	/* Dual attach / single attach */
168
168
169
/*
169
/*
170
 * IEEE 802.11 Wireless
171
 */
172
#define IFM_IEEE80211		0x00000080
173
#define IFM_IEEE80211_FH1	3	/* Frequency Hopping 1Mbps */
174
#define IFM_IEEE80211_FH2	4	/* Frequency Hopping 2Mbps */
175
#define IFM_IEEE80211_DS1	5	/* Direct Sequence 1Mbps */
176
#define IFM_IEEE80211_DS2	6	/* Direct Sequence 2Mbps */
177
#define IFM_IEEE80211_DS5	7	/* Direct Sequence 5.5Mbps */
178
#define IFM_IEEE80211_DS11	8	/* Direct Sequence 11Mbps */
179
#define IFM_IEEE80211_ADHOC	0x00000100	/* Operate in Adhoc mode */
180
181
/*
170
 * Shared media sub-types
182
 * Shared media sub-types
171
 */
183
 */
172
#define	IFM_AUTO	0		/* Autoselect best media */
184
#define	IFM_AUTO	0		/* Autoselect best media */
Lines 229-237 Link Here
229
};
241
};
230
242
231
#define	IFM_TYPE_DESCRIPTIONS {						\
243
#define	IFM_TYPE_DESCRIPTIONS {						\
232
	{ IFM_ETHER,	"Ethernet" },					\
244
	{ IFM_ETHER,		"Ethernet" },				\
233
	{ IFM_TOKEN,	"Token ring" },					\
245
	{ IFM_TOKEN,		"Token ring" },				\
234
	{ IFM_FDDI,	"FDDI" },					\
246
	{ IFM_FDDI,		"FDDI" },				\
247
	{ IFM_IEEE80211,	"IEEE 802.11 Wireless Ethernet" },	\
235
	{ 0, NULL },							\
248
	{ 0, NULL },							\
236
}
249
}
237
250
Lines 327-332 Link Here
327
340
328
#define	IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS {				\
341
#define	IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS {				\
329
	{ IFM_FDDI_DA, "Dual-attach" },					\
342
	{ IFM_FDDI_DA, "Dual-attach" },					\
343
	{ 0, NULL },							\
344
}
345
346
#define	IFM_SUBTYPE_IEEE80211_DESCRIPTIONS {				\
347
	{ IFM_IEEE80211_FH1, "FH/1Mbps" },				\
348
	{ IFM_IEEE80211_FH2, "FH/2Mbps" },				\
349
	{ IFM_IEEE80211_DS1, "DS/1Mbps" },				\
350
	{ IFM_IEEE80211_DS2, "DS/2Mbps" },				\
351
	{ IFM_IEEE80211_DS5, "DS/5.5Mbps" },				\
352
	{ IFM_IEEE80211_DS11, "DS/11Mbps" },				\
353
	{ 0, NULL },							\
354
}
355
356
#define	IFM_SUBTYPE_IEEE80211_ALIASES {					\
357
	{ IFM_IEEE80211_FH1, "FH1" },					\
358
	{ IFM_IEEE80211_FH2, "FH2" },					\
359
	{ IFM_IEEE80211_FH1, "FrequencyHopping/1Mbps" },		\
360
	{ IFM_IEEE80211_FH2, "FrequencyHopping/2Mbps" },		\
361
	{ IFM_IEEE80211_DS1, "DS1" },					\
362
	{ IFM_IEEE80211_DS2, "DS2" },					\
363
	{ IFM_IEEE80211_DS5, "DS5.5" },					\
364
	{ IFM_IEEE80211_DS11, "DS11" },					\
365
	{ IFM_IEEE80211_DS1, "DirectSequence/1Mbps" },			\
366
	{ IFM_IEEE80211_DS2, "DirectSequence/2Mbps" },			\
367
	{ IFM_IEEE80211_DS5, "DirectSequence/5.5Mbps" },		\
368
	{ IFM_IEEE80211_DS11, "DirectSequence/11Mbps" },		\
369
	{ 0, NULL },							\
370
}
371
372
#define	IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS {			\
373
	{ IFM_IEEE80211_ADHOC, "adhoc" },				\
330
	{ 0, NULL },							\
374
	{ 0, NULL },							\
331
}
375
}
332
376
(-)share/man/man4/Makefile (+1 lines)
Lines 43-48 Link Here
43
	ichsmb.4 \
43
	ichsmb.4 \
44
	icmp.4 \
44
	icmp.4 \
45
	icmp6.4 \
45
	icmp6.4 \
46
	ieee80211.4 \
46
	ifmib.4 \
47
	ifmib.4 \
47
	iic.4 \
48
	iic.4 \
48
	iicbb.4 \
49
	iicbb.4 \
(-)share/man/man4/ieee80211.4 (+234 lines)
Line 0 Link Here
1
.\" Copyright (c) 2001
2
.\"	The Aerospace Corporation.  All rights reserved.
3
.\"
4
.\" Redistribution and use in source and binary forms, with or without
5
.\" modification, are permitted provided that the following conditions
6
.\" are met:
7
.\" 1. Redistributions of source code must retain the above copyright
8
.\"    notice, this list of conditions and the following disclaimer.
9
.\" 2. Redistributions in binary form must reproduce the above copyright
10
.\"    notice, this list of conditions and the following disclaimer in the
11
.\"    documentation and/or other materials provided with the distribution.
12
.\" 3. Neither the name of the University nor the names of its contributors
13
.\"    may be used to endorse or promote products derived from this software
14
.\"    without specific prior written permission.
15
.\"
16
.\" THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION ``AS IS'' AND
17
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
20
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
.\" SUCH DAMAGE.
27
.\"
28
.\" $FreeBSD$
29
.\"
30
.Dd February 23, 2001
31
.Dt IEEE80211 4
32
.Os FreeBSD 4.3
33
.Sh NAME
34
.Nm ieee80211
35
.Nd standard interface to IEEE 802.11 devices
36
.Sh SYNOPSIS
37
.Fd #include <net/if_ieee80211.h>
38
.Sh DESCRIPTION
39
This section describes the interface standard interface to configuration
40
and status information on IEEE 802.11 devices.  Most devices support
41
options not configurable by this interface.  They must be set by their
42
respective, specific control program.  The interface is via one
43
of the following
44
.Xr ioctl 2
45
calls on a socket:
46
.Bl -tag -width SIOCG80211
47
.It Dv SIOCG80211
48
Get configuration or status information.
49
.It Dv SIOCS80211
50
Set configuration information.
51
.El
52
These requests are made via a modified
53
.Ar ifreq
54
structure.  This structure is defined as follows:
55
.Bd -literal
56
struct ieee80211req {
57
	char		i_name[IFNAMSIZ];	/* if_name, e.g. "wi0" */
58
	u_int16_t	i_type;			/* req type */
59
	int16_t		i_val;			/* Index or simple value */
60
	int16_t		i_len;			/* Index or simple value */
61
	void		*i_data;		/* Extra data */
62
};
63
.Ed
64
.Pp
65
For
66
.Dv SIOCG80211
67
the following values of
68
.Ar i_type
69
are valid:
70
.Bl -tag -width IEEE80211_IOC_POWERSAVESLEEP
71
.It Dv IEEE80211_IOC_SSID
72
Returns the requested SSID by copying it into the buffer pointed to by
73
.Ar i_data
74
and setting
75
.Ar i_len
76
to the length.  If 
77
.Ar i_val
78
is >= 0 then the request refers to the configured value for that slot.
79
Generally, 0 is the only valid value, but some interfaces support more
80
SSIDs.  If
81
.Ar i_val
82
is -1 then the request refers to the currently active value.
83
.It Dv IEEE80211_IOC_NUMSSIDS
84
Returns the number of SSIDs this card supports.  In most cases, this is
85
1, but some devices such as
86
.Xr an 4
87
support more.
88
.It Dv IEEE80211_IOC_WEP
89
Returns the current WEP status in
90
.Ar i_val .
91
Valid values are
92
.Dv IEEE80211_WEP_NOSUP ,
93
.Dv IEEE80211_WEP_ON ,
94
.Dv IEEE80211_WEP_OFF ,
95
and
96
.Dv IEEE80211_WEP_MIXED .
97
Respectively, these values mean unsupported, mandatory for all devices,
98
off, and on, but not required for all devices.
99
.It Dv IEEE80211_IOC_WEPKEY
100
Returns the requested WEP key via
101
.Ar i_data
102
and it's length via
103
.Ar i_len .
104
If the device does not support returning the WEP key or the user is not
105
root then the key may be returned as all zeros.  Technically this is a
106
valid key, but it's the kind of key an idiot would put on his luggage so
107
we use it as a special value.  Generally, only four WEP keys are
108
allowed, but some devices support more.  If so, the first four (0-3) are
109
the standard keys stored in volatile storage and the others are device
110
specific.
111
.It Dv IEEE80211_IOC_NUMWEPKEYS
112
Returns the number of WEP keys supported by this device, generally 4.
113
A device that does not support WEP may either report 0 or simply return
114
.Dv EINVAL .
115
.It Dv IEEE80211_IOC_WEPTXKEY
116
Returns the WEP key used for transmission.
117
.It Dv IEEE80211_IOC_AUTHMODE
118
Returns the current authentication mode in
119
.Ar i_val .
120
Valid values are
121
.Dv IEEE80211_AUTH_NONE ,
122
.Dv IEEE80211_AUTH_OPEN ,
123
and
124
.Dv IEEE80211_AUTH_SHARED .
125
.It Dv IEEE80211_IOC_STATIONNAME
126
Returns the station name via
127
.Ar i_data
128
and its length via
129
.Ar i_len .
130
While all known devices seem to support this is some way or another,
131
they all do it differently and it appears to not have anything to do
132
with the actual IEEE 802.11 standard so making up an answer may be
133
necessary for future devices.
134
.It Dv IEEE80211_IOC_CHANNEL
135
Returns the current direct sequence spread spectrum channel in use.
136
.It Dv IEEE80211_IOC_POWERSAVE
137
Returns the current powersaving mode.  Valid values are
138
.Dv IEEE80211_POWERSAVE_NOSUP ,
139
.Dv IEEE80211_POWERSAVE_OFF ,
140
.Dv IEEE80211_POWERSAVE_ON ,
141
.Dv IEEE80211_POWERSAVE_CAM ,
142
.Dv IEEE80211_POWERSAVE_PSP ,
143
and
144
.Dv IEEE80211_POWERSAVE_PSP_CAM .
145
Currently,
146
.Dv IEEE80211_POWERSAVE_ON
147
is defined to be equal to
148
.Dv IEEE80211_POWERSAVE_CAM ,
149
but this may be incorrect.
150
.It Dv IEEE80211_IOC_POWERSAVESLEEP
151
Returns the powersave sleep time in msec in
152
.Ar i_val .
153
.El
154
.Pp
155
For
156
.Dv SIOCS80211
157
the following values of
158
.Ar i_type
159
are valid:
160
.Bl -tag -width IEEE80211_IOC_POWERSAVESLEEP
161
.It Dv IEEE80211_IOC_SSID
162
Set the desired SSID for infrastructure and ad-hoc modes to value given
163
by
164
.Ar i_data
165
and
166
.Ar i_len .
167
The length should be no longer then 32 characters.
168
.It Dv IEEE80211_IOC_WEP
169
Set the current WEP mode to the value given in
170
.Ar i_val .
171
Valid values are the same as those for this value above.  Devices which
172
do not support all modes may choose to either return
173
.Dv EINVAL
174
or choose a reasonable alternate (supported) setting.
175
.It Dv IEEE80211_IOC_WEPKEY
176
Set the WEP key indicated by
177
.Ar i_val
178
to the value given by
179
.Ar i_data
180
and
181
.Ar i_len .
182
Generally, valid values of
183
.Ar i_len
184
are 0, 5, and 13 though not all devices with WEP support have support
185
for 13-byte keys.
186
.It Dv IEEE80211_IOC_WEPTXKEY
187
Set the WEP key used for transmission to the value in
188
.Ar i_val .
189
Not all values which are valid for setting keys may be valid for setting
190
transmit keys due to strange device interfaces.
191
.It Dv IEEE80211_IOC_AUTHMODE
192
Set the current authorization mode to the value given in
193
.Ar i_val .
194
Valid values are given above.  No all devices support this.
195
.It Dv IEEE80211_IOC_STATIONNAME
196
Set the station name to the value given by
197
.Ar i_data
198
and
199
.Ar i_len .
200
The standard does not appear to deal with this feature so the range of
201
valid values may vary from device to device.
202
.It Dv IEEE80211_IOC_CHANNEL
203
Set the desired ad-hoc channel to the value given by
204
.Ar i_val .
205
On some devices this has an impact on infrastructure mode as well.
206
Valid values are 1-14, but 0 should be allowed and should return the
207
device to the default value.  May devices support this directly by
208
converting any invalid value to the default value.
209
.It Dv IEEE80211_IOC_POWERSAVE
210
Set the current powersaving mode to the value given in
211
.Ar i_val .
212
Valid values are the same as those for this value above.  Devices which
213
do not support all modes may choose to either return
214
.Dv EINVAL
215
or choose a reasonable alternate (supported) setting.  Most devices only
216
support CAM mode.
217
.It Dv IEEE80211_IOC_POWERSAVESLEEP
218
Set the powersave sleep time in msec to the value in
219
.Ar i_val .
220
.El
221
.Sh SEE ALSO
222
.Xr ioctl 2 ,
223
.Xr an 4 ,
224
.Xr ray 4 ,
225
.Xr wi 4 ,
226
.Xr ancontrol 8 ,
227
.Xr ifconfig 8 ,
228
.Xr raycontrol 8 ,
229
.Xr wicontrol 8 ,
230
.Sh HISTORY
231
The
232
.Nm ieee80211
233
manual appeared in
234
.Fx 4.3 .

Return to bug 25577