1 /* $NetBSD: sockio.h,v 1.4 2007/08/20 04:49:41 skd Exp $ */
2
3 /*-
4 * Copyright (c) 1982, 1986, 1990, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 #ifndef _COMPAT_SYS_SOCKIO_H_
33 #define _COMPAT_SYS_SOCKIO_H_
34
35 #ifdef _KERNEL_OPT
36
37 #include "opt_compat_netbsd.h"
38
39 #if defined(COMPAT_09) || defined(COMPAT_10) || defined(COMPAT_11) || \
40 defined(COMPAT_12) || defined(COMPAT_13) || defined(COMPAT_14) || \
41 defined(COMPAT_15) || defined(COMPAT_16) || defined(COMPAT_20) || \
42 defined(COMPAT_30) || defined(COMPAT_40)
43 #define COMPAT_OIFREQ
44 #endif
45
46 #else
47 #define COMPAT_OIFREQ
48 #endif
49
50 struct oifreq {
51 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
52 union {
53 struct sockaddr ifru_addr;
54 struct sockaddr ifru_dstaddr;
55 struct sockaddr ifru_broadaddr;
56 short ifru_flags;
57 int ifru_metric;
58 int ifru_mtu;
59 int ifru_dlt;
60 u_int ifru_value;
61 void * ifru_data;
62 struct {
63 uint32_t b_buflen;
64 void *b_buf;
65 } ifru_b;
66 } ifr_ifru;
67 };
68 struct oifconf {
69 int ifc_len; /* size of associated buffer */
70 union {
71 void * ifcu_buf;
72 struct oifreq *ifcu_req;
73 } ifc_ifcu;
74 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
75 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
76 };
77
78 #define OSIOCSIFADDR _IOW('i', 12, struct oifreq) /* set ifnet address */
79 #define OOSIOCGIFADDR _IOWR('i', 13, struct oifreq) /* get ifnet address */
80 #define OSIOCSIFDSTADDR _IOW('i', 14, struct oifreq) /* set p-p address */
81 #define OOSIOCGIFDSTADDR _IOWR('i', 15, struct oifreq) /* get p-p address */
82 #define OSIOCSIFFLAGS _IOW('i', 16, struct oifreq) /* set ifnet flags */
83 #define OSIOCGIFFLAGS _IOWR('i', 17, struct oifreq) /* get ifnet flags */
84 #define OOSIOCGIFBRDADDR _IOWR('i', 18, struct oifreq) /* get bcast addr */
85 #define OSIOCSIFBRDADDR _IOW('i', 19, struct oifreq) /* set bcast addr */
86 #define OOSIOCGIFCONF _IOWR('i', 20, struct ifconf) /* get ifnet list */
87 #define OOSIOCGIFNETMASK _IOWR('i', 21, struct oifreq) /* get net addr mask */
88 #define OSIOCSIFNETMASK _IOW('i', 22, struct oifreq) /* set net addr mask */
89 #define OSIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */
90 #define OSIOCADDMULTI _IOW('i', 49, struct oifreq) /* add m'cast addr */
91 #define OSIOCDELMULTI _IOW('i', 50, struct oifreq) /* del m'cast addr */
92 #define OSIOCSIFMEDIA _IOWR('i', 53, struct oifreq) /* set net media */
93
94
95
96
97 #define OBIOCGETIF _IOR('B', 107, struct oifreq)
98 #define OBIOCSETIF _IOW('B', 108, struct oifreq)
99 #define OTAPGIFNAME _IOR('e', 0, struct oifreq)
100
101 #define ifreqn2o(oi, ni) \
102 do { \
103 (void)memcpy((oi)->ifr_name, (ni)->ifr_name, \
104 sizeof((oi)->ifr_name)); \
105 (void)memcpy(&(oi)->ifr_ifru, &(ni)->ifr_ifru, \
106 sizeof((oi)->ifr_ifru)); \
107 } while (/*CONSTCOND*/0)
108
109 #define ifreqo2n(oi, ni) \
110 do { \
111 (void)memcpy((ni)->ifr_name, (oi)->ifr_name, \
112 sizeof((oi)->ifr_name)); \
113 (void)memcpy(&(ni)->ifr_ifru, &(oi)->ifr_ifru, \
114 sizeof((oi)->ifr_ifru)); \
115 } while (/*CONSTCOND*/0)
116
117 #ifdef _KERNEL
118 __BEGIN_DECLS
119 int compat_ifconf(u_long, void *);
120 __END_DECLS
121 #endif
122 #endif /* _COMPAT_SYS_SOCKIO_H_ */
Cache object: 097ecea17c28c2c9e98b657b1e3327b9
|