2 * Copyright 2001 The Aerospace Corporation. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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. The name of The Aerospace Corporation may not be used to endorse or
13 * promote products derived from this software.
15 * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
32 * All rights reserved.
34 * This code is derived from software contributed to The NetBSD Foundation
35 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
36 * NASA Ames Research Center.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
47 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
48 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
49 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
50 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
51 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
53 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
55 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
57 * POSSIBILITY OF SUCH DAMAGE.
60 #include <sys/param.h>
61 #include <sys/ioctl.h>
62 #include <sys/socket.h>
63 #include <sys/sysctl.h>
66 #include <net/ethernet.h>
68 #include <net/if_dl.h>
69 #include <net/if_types.h>
70 #include <net/if_media.h>
71 #include <net/route.h>
73 #include <net80211/ieee80211_ioctl.h>
74 #include <net80211/ieee80211_freebsd.h>
75 #include <net80211/ieee80211_superg.h>
76 #include <net80211/ieee80211_tdma.h>
77 #include <net80211/ieee80211_mesh.h>
90 #include <stddef.h> /* NB: for offsetof */
92 #include "lib80211_ioctl.h"
95 * These implement basic net80211 accessor methods to wrap the IOCTL
100 lib80211_get80211(int s, const char *name, int type, void *data, int len)
102 struct ieee80211req ireq;
104 (void) memset(&ireq, 0, sizeof(ireq));
105 (void) strncpy(ireq.i_name, name, sizeof(ireq.i_name));
109 return ioctl(s, SIOCG80211, &ireq);
113 lib80211_get80211len(int s, const char *name, int type, void *data, int len, int *plen)
115 struct ieee80211req ireq;
117 (void) memset(&ireq, 0, sizeof(ireq));
118 (void) strncpy(ireq.i_name, name, sizeof(ireq.i_name));
121 assert(ireq.i_len == len); /* NB: check for 16-bit truncation */
123 if (ioctl(s, SIOCG80211, &ireq) < 0)
130 lib80211_get80211val(int s, const char *name, int type, int *val)
132 struct ieee80211req ireq;
134 (void) memset(&ireq, 0, sizeof(ireq));
135 (void) strncpy(ireq.i_name, name, sizeof(ireq.i_name));
137 if (ioctl(s, SIOCG80211, &ireq) < 0)
144 lib80211_set80211(int s, const char *name, int type, int val, int len, void *data)
146 struct ieee80211req ireq;
148 (void) memset(&ireq, 0, sizeof(ireq));
149 (void) strncpy(ireq.i_name, name, sizeof(ireq.i_name));
153 assert(ireq.i_len == len); /* NB: check for 16-bit truncation */
155 if (ioctl(s, SIOCS80211, &ireq) < 0)