netbsd32_ioctl.h revision 1.37 1 /* $NetBSD: netbsd32_ioctl.h,v 1.37 2011/08/30 07:06:39 macallan Exp $ */
2
3 /*
4 * Copyright (c) 1998, 2001 Matthew R. Green
5 * 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 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * 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
29 #include <sys/device.h>
30 #include <sys/disklabel.h>
31 #include <sys/disk.h>
32
33 #include <net/zlib.h>
34
35 #include <dev/dkvar.h>
36 #include <dev/vndvar.h>
37
38 #include <dev/wscons/wsconsio.h>
39
40 /* we define some handy macros here... */
41 #define IOCTL_STRUCT_CONV_TO(cmd, type) \
42 size = IOCPARM_LEN(cmd); \
43 if (size > sizeof(stkbuf)) \
44 data = memp = kmem_alloc(size, KM_SLEEP); \
45 else \
46 data = (void *)stkbuf; \
47 __CONCAT(netbsd32_to_, type)((struct __CONCAT(netbsd32_, type) *) \
48 data32, (struct type *)data, cmd); \
49 error = (*fp->f_ops->fo_ioctl)(fp, cmd, data); \
50 __CONCAT(netbsd32_from_, type)((struct type *)data, \
51 (struct __CONCAT(netbsd32_, type) *)data32, cmd); \
52 break
53
54 #define IOCTL_CONV_TO(cmd, type) \
55 size = IOCPARM_LEN(cmd); \
56 if (size > sizeof(stkbuf)) \
57 data = memp = kmem_alloc(size, KM_SLEEP); \
58 else \
59 data = (void *)stkbuf; \
60 __CONCAT(netbsd32_to_, type)((__CONCAT(netbsd32_, type) *) \
61 data32, (type *)data, cmd); \
62 error = (*fp->f_ops->fo_ioctl)(fp, cmd, data); \
63 __CONCAT(netbsd32_from_, type)((type *)data, \
64 (__CONCAT(netbsd32_, type) *)data32, cmd); \
65 break
66
67 /* from <sys/audioio.h> */
68 #define AUDIO_WSEEK32 _IOR('A', 25, netbsd32_u_long)
69
70 /* from <sys/dkio.h> */
71 typedef netbsd32_pointer_t netbsd32_disklabel_tp_t;
72 typedef netbsd32_pointer_t netbsd32_partition_tp_t;
73 struct netbsd32_partinfo {
74 netbsd32_disklabel_tp_t disklab;
75 netbsd32_partition_tp_t part;
76 };
77 #if 1
78 #define DIOCGPART32 _IOW('d', 104, struct netbsd32_partinfo) /* get partition */
79 #endif
80
81 #if 0 /* not implemented by anything */
82 struct netbsd32_format_op {
83 netbsd32_charp df_buf;
84 int df_count; /* value-result */
85 daddr_t df_startblk;
86 int df_reg[8]; /* result */
87 };
88 #define DIOCRFORMAT32 _IOWR('d', 105, struct netbsd32_format_op)
89 #define DIOCWFORMAT32 _IOWR('d', 106, struct netbsd32_format_op)
90 #endif
91
92 struct netbsd32_wsdisplay_addscreendata {
93 int idx; /* screen index */
94 netbsd32_charp screentype;
95 netbsd32_charp emul;
96 };
97 #define WSDISPLAYIO_ADDSCREEN32 _IOW('W', 78, struct netbsd32_wsdisplay_addscreendata)
98
99 /* can wait! */
100 #if 0
101 dev/ccdvar.h:219:#define CCDIOCSET _IOWR('F', 16, struct ccd_ioctl) /* enable ccd */
102 dev/ccdvar.h:220:#define CCDIOCCLR _IOW('F', 17, struct ccd_ioctl) /* disable ccd */
103
104 dev/md.h:45:#define MD_GETCONF _IOR('r', 0, struct md_conf) /* get unit config */
105 dev/md.h:46:#define MD_SETCONF _IOW('r', 1, struct md_conf) /* set unit config */
106
107 dev/wscons/wsconsio.h:133:#define WSKBDIO_GETMAP _IOWR('W', 13, struct wskbd_map_data)
108 dev/wscons/wsconsio.h:134:#define WSKBDIO_SETMAP _IOW('W', 14, struct wskbd_map_data)
109
110 dev/wscons/wsconsio.h:188:#define WSDISPLAYIO_GETCMAP _IOW('W', 66, struct wsdisplay_cmap)
111 dev/wscons/wsconsio.h:189:#define WSDISPLAYIO_PUTCMAP _IOW('W', 67, struct wsdisplay_cmap)
112
113 dev/wscons/wsconsio.h:227:#define WSDISPLAYIO_GCURSOR _IOWR('W', 73, struct wsdisplay_cursor)
114 dev/wscons/wsconsio.h:228:#define WSDISPLAYIO_SCURSOR _IOW('W', 74, struct wsdisplay_cursor)
115
116 dev/wscons/wsconsio.h:241:#define WSDISPLAYIO_SFONT _IOW('W', 77, struct wsdisplay_font)
117
118 net/bpf.h:127:#define BIOCSETF _IOW('B',103, struct bpf_program)
119 net/bpf.h:138:#define BIOCSTCPF _IOW('B',114, struct bpf_program)
120 net/bpf.h:139:#define BIOCSUDPF _IOW('B',115, struct bpf_program)
121 net/if_ppp.h:110:#define PPPIOCSPASS _IOW('t', 71, struct bpf_program) /* set pass filter */
122 net/if_ppp.h:111:#define PPPIOCSACTIVE _IOW('t', 70, struct bpf_program) /* set active filt */
123
124 net/if_atm.h:88:#define SIOCATMENA _IOWR('a', 123, struct atm_pseudoioctl) /* enable */
125 net/if_atm.h:89:#define SIOCATMDIS _IOWR('a', 124, struct atm_pseudoioctl) /* disable */
126
127 net/if_ppp.h:105:#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data)
128
129 netccitt/x25.h:157:#define SIOCSIFCONF_X25 _IOW('i', 12, struct ifreq_x25) /* set ifnet config */
130 netccitt/x25.h:158:#define SIOCGIFCONF_X25 _IOWR('i',13, struct ifreq_x25) /* get ifnet config */
131
132 netinet/ip_fil.h:46:#define SIOCGETFS _IOR('r', 64, struct friostat)
133 netinet/ip_fil.h:56:#define SIOCFRZST _IOWR('r', 74, struct friostat)
134
135 netinet/ip_fil.h:42:#define SIOCADAFR _IOW('r', 60, struct frentry)
136 netinet/ip_fil.h:43:#define SIOCRMAFR _IOW('r', 61, struct frentry)
137 netinet/ip_fil.h:49:#define SIOCADIFR _IOW('r', 67, struct frentry)
138 netinet/ip_fil.h:50:#define SIOCRMIFR _IOW('r', 68, struct frentry)
139 netinet/ip_fil.h:52:#define SIOCINAFR _IOW('r', 70, struct frentry)
140 netinet/ip_fil.h:53:#define SIOCINIFR _IOW('r', 71, struct frentry)
141 netinet/ip_fil.h:57:#define SIOCZRLST _IOWR('r', 75, struct frentry)
142
143 netinet/ip_fil.h:78:#define SIOCAUTHW _IOWR(r, 76, struct fr_info)
144 netinet/ip_fil.h:79:#define SIOCAUTHR _IOWR(r, 77, struct fr_info)
145
146 netinet/ip_fil.h:60:#define SIOCATHST _IOWR('r', 78, struct fr_authstat)
147
148 netinet/ip_nat.h:22:#define SIOCADNAT _IOW('r', 80, struct ipnat)
149 netinet/ip_nat.h:23:#define SIOCRMNAT _IOW('r', 81, struct ipnat)
150
151 netinet/ip_nat.h:24:#define SIOCGNATS _IOR('r', 82, struct natstat)
152
153 netinet/ip_nat.h:25:#define SIOCGNATL _IOWR('r', 83, struct natlookup)
154
155 netinet/ip_nat.h:26:#define SIOCGFRST _IOR('r', 84, struct ipfrstat)
156
157 netinet/ip_nat.h:27:#define SIOCGIPST _IOR('r', 85, struct ips_stat)
158
159 sys/module.h?
160
161 sys/rnd.h:186:#define RNDGETPOOL _IOR('R', 103, u_char *) /* get whole pool */
162
163 sys/scanio.h:86:#define SCIOCGET _IOR('S', 1, struct scan_io) /* retrieve parameters */
164 sys/scanio.h:87:#define SCIOCSET _IOW('S', 2, struct scan_io) /* set parameters */
165
166 sys/scsiio.h:43:#define SCIOCCOMMAND _IOWR('Q', 1, scsireq_t)
167 #endif
168
169 /* from <net/if.h> */
170
171 typedef netbsd32_pointer_t netbsd32_ifreq_tp_t;
172 /*
173 * note that ifr_data is the only one that needs to be changed
174 */
175 struct netbsd32_oifreq {
176 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
177 union {
178 struct sockaddr ifru_addr;
179 struct sockaddr ifru_dstaddr;
180 struct sockaddr ifru_broadaddr;
181 short ifru_flags;
182 int ifru_metric;
183 int ifru_mtu;
184 int ifru_dlt;
185 u_int ifru_value;
186 netbsd32_caddr_t ifru_data;
187 struct {
188 uint32_t b_buflen;
189 netbsd32_caddr_t b_buf;
190 } ifru_b;
191 } ifr_ifru;
192 #define ifr_addr ifr_ifru.ifru_addr /* address */
193 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
194 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
195 #define ifr_flags ifr_ifru.ifru_flags /* flags */
196 #define ifr_metric ifr_ifru.ifru_metric /* metric */
197 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
198 #define ifr_media ifr_ifru.ifru_metric /* media options (overload) */
199 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
200 };
201 struct netbsd32_ifreq {
202 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
203 union {
204 struct sockaddr ifru_addr;
205 struct sockaddr ifru_dstaddr;
206 struct sockaddr ifru_broadaddr;
207 struct sockaddr_storage ifru_space;
208 short ifru_flags;
209 int ifru_metric;
210 int ifru_mtu;
211 int ifru_dlt;
212 u_int ifru_value;
213 netbsd32_caddr_t ifru_data;
214 struct {
215 uint32_t b_buflen;
216 netbsd32_caddr_t b_buf;
217 } ifru_b;
218 } ifr_ifru;
219 };
220
221 struct netbsd32_if_addrprefreq {
222 char ifap_name[IFNAMSIZ];
223 uint16_t ifap_preference;
224 struct {
225 __uint8_t ss_len; /* address length */
226 sa_family_t ss_family; /* address family */
227 char __ss_pad1[_SS_PAD1SIZE];
228 __int32_t __ss_align[2];
229 char __ss_pad2[_SS_PAD2SIZE];
230 } ifap_addr;
231 };
232
233 /* from <dev/pci/if_devar.h> */
234 #define SIOCGADDRROM32 _IOW('i', 240, struct netbsd32_ifreq) /* get 128 bytes of ROM */
235 #define SIOCGCHIPID32 _IOWR('i', 241, struct netbsd32_ifreq) /* get chipid */
236 /* from <sys/sockio.h> */
237 #define SIOCSIFADDR32 _IOW('i', 12, struct netbsd32_ifreq) /* set ifnet address */
238 #define OSIOCSIFADDR32 _IOW('i', 12, struct netbsd32_oifreq) /* set ifnet address */
239 #define OOSIOCGIFADDR32 _IOWR('i', 13, struct netbsd32_oifreq) /* get ifnet address */
240
241 #define SIOCGIFADDR32 _IOWR('i', 33, struct netbsd32_ifreq) /* get ifnet address */
242 #define OSIOCGIFADDR32 _IOWR('i', 33, struct netbsd32_oifreq) /* get ifnet address */
243
244 #define SIOCSIFDSTADDR32 _IOW('i', 14, struct netbsd32_ifreq) /* set p-p address */
245 #define OSIOCSIFDSTADDR32 _IOW('i', 14, struct netbsd32_oifreq) /* set p-p address */
246 #define OOSIOCGIFDSTADDR32 _IOWR('i', 15, struct netbsd32_oifreq) /* get p-p address */
247
248 #define SIOCGIFDSTADDR32 _IOWR('i', 34, struct netbsd32_ifreq) /* get p-p address */
249 #define OSIOCGIFDSTADDR32 _IOWR('i', 34, struct netbsd32_oifreq) /* get p-p address */
250
251 #define SIOCSIFFLAGS32 _IOW('i', 16, struct netbsd32_ifreq) /* set ifnet flags */
252 #define OSIOCSIFFLAGS32 _IOW('i', 16, struct netbsd32_oifreq) /* set ifnet flags */
253
254 #define SIOCGIFFLAGS32 _IOWR('i', 17, struct netbsd32_ifreq) /* get ifnet flags */
255 #define OSIOCGIFFLAGS32 _IOWR('i', 17, struct netbsd32_oifreq) /* get ifnet flags */
256
257
258 #define SIOCSIFBRDADDR32 _IOW('i', 19, struct netbsd32_ifreq) /* set broadcast addr */
259 #define OSIOCSIFBRDADDR32 _IOW('i', 19, struct netbsd32_oifreq) /* set broadcast addr */
260 #define OOSIOCGIFBRDADDR32 _IOWR('i', 18, struct netbsd32_oifreq) /* get broadcast addr */
261
262 #define SIOCGIFBRDADDR32 _IOWR('i', 35, struct netbsd32_ifreq) /* get broadcast addr */
263 #define OSIOCGIFBRDADDR32 _IOWR('i', 35, struct netbsd32_oifreq) /* get broadcast addr */
264
265 #define OOSIOCGIFNETMASK32 _IOWR('i', 21, struct netbsd32_oifreq) /* get net addr mask */
266
267 #define SIOCGIFNETMASK32 _IOWR('i', 37, struct netbsd32_ifreq) /* get net addr mask */
268 #define OSIOCGIFNETMASK32 _IOWR('i', 37, struct netbsd32_oifreq) /* get net addr mask */
269
270 #define SIOCSIFNETMASK32 _IOW('i', 22, struct netbsd32_ifreq) /* set net addr mask */
271 #define OSIOCSIFNETMASK32 _IOW('i', 22, struct netbsd32_oifreq) /* set net addr mask */
272
273 #define SIOCGIFMETRIC32 _IOWR('i', 23, struct netbsd32_ifreq) /* get IF metric */
274 #define OSIOCGIFMETRIC32 _IOWR('i', 23, struct netbsd32_oifreq) /* get IF metric */
275
276 #define SIOCSIFMETRIC32 _IOW('i', 24, struct netbsd32_ifreq) /* set IF metric */
277 #define OSIOCSIFMETRIC32 _IOW('i', 24, struct netbsd32_oifreq) /* set IF metric */
278
279 #define SIOCDIFADDR32 _IOW('i', 25, struct netbsd32_ifreq) /* delete IF addr */
280 #define OSIOCDIFADDR32 _IOW('i', 25, struct netbsd32_oifreq) /* delete IF addr */
281
282 #define SIOCSIFADDRPREF32 _IOW('i', 31, struct netbsd32_if_addrprefreq)
283 #define SIOCGIFADDRPREF32 _IOWR('i', 32, struct netbsd32_if_addrprefreq)
284
285 #define SIOCADDMULTI32 _IOW('i', 49, struct netbsd32_ifreq) /* add m'cast addr */
286 #define OSIOCADDMULTI32 _IOW('i', 49, struct netbsd32_oifreq) /* add m'cast addr */
287
288 #define SIOCDELMULTI32 _IOW('i', 50, struct netbsd32_ifreq) /* del m'cast addr */
289 #define OSIOCDELMULTI32 _IOW('i', 50, struct netbsd32_oifreq) /* del m'cast addr */
290
291 #define SIOCSIFMEDIA32 _IOWR('i', 53, struct netbsd32_ifreq) /* set net media */
292 #define OSIOCSIFMEDIA32 _IOWR('i', 53, struct netbsd32_oifreq) /* set net media */
293
294 #define SIOCSIFMTU32 _IOW('i', 127, struct netbsd32_ifreq) /* set ifnet mtu */
295 #define OSIOCSIFMTU32 _IOW('i', 127, struct netbsd32_oifreq) /* set ifnet mtu */
296
297 #define SIOCGIFMTU32 _IOWR('i', 126, struct netbsd32_ifreq) /* get ifnet mtu */
298 #define OSIOCGIFMTU32 _IOWR('i', 126, struct netbsd32_oifreq) /* get ifnet mtu */
299 /* was 125 SIOCSIFASYNCMAP32 */
300 /* was 124 SIOCGIFASYNCMAP32 */
301 /* from <net/bpf.h> */
302 #define BIOCGETIF32 _IOR('B',107, struct netbsd32_ifreq)
303 #define BIOCSETIF32 _IOW('B',108, struct netbsd32_ifreq)
304 /* from <netatalk/phase2.h> */
305 #define SIOCPHASE1_32 _IOW('i', 100, struct netbsd32_ifreq) /* AppleTalk phase 1 */
306 #define SIOCPHASE2_32 _IOW('i', 101, struct netbsd32_ifreq) /* AppleTalk phase 2 */
307
308 /* from <net/if.h> */
309 struct netbsd32_ifconf {
310 int ifc_len; /* size of associated buffer */
311 union {
312 netbsd32_caddr_t ifcu_buf;
313 netbsd32_ifreq_tp_t ifcu_req;
314 } ifc_ifcu;
315 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
316 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
317 };
318 /* from <sys/sockio.h> */
319 #define OOSIOCGIFCONF32 _IOWR('i', 20, struct netbsd32_ifconf) /* get ifnet list */
320 #define OSIOCGIFCONF32 _IOWR('i', 36, struct netbsd32_ifconf) /* get ifnet list */
321 #define SIOCGIFCONF32 _IOWR('i', 38, struct netbsd32_ifconf) /* get ifnet list */
322
323 /* from <net/if.h> */
324 struct netbsd32_ifmediareq {
325 char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
326 int ifm_current; /* current media options */
327 int ifm_mask; /* don't care mask */
328 int ifm_status; /* media status */
329 int ifm_active; /* active options */
330 int ifm_count; /* # entries in ifm_ulist
331 array */
332 netbsd32_intp ifm_ulist; /* media words */
333 };
334 /* from <sys/sockio.h> */
335 #define SIOCGIFMEDIA32 _IOWR('i', 54, struct netbsd32_ifmediareq) /* get net media */
336
337 /* from <net/if.h> */
338 struct netbsd32_ifdrv {
339 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
340 netbsd32_u_long ifd_cmd;
341 netbsd32_size_t ifd_len;
342 netbsd32_voidp ifd_data;
343 };
344 /* from <sys/sockio.h> */
345 #define SIOCSDRVSPEC32 _IOW('i', 123, struct netbsd32_ifdrv) /* set driver-specific */
346
347 /* from <netinet/ip_mroute.h> */
348 struct netbsd32_sioc_vif_req {
349 vifi_t vifi; /* vif number */
350 netbsd32_u_long icount; /* input packet count on vif */
351 netbsd32_u_long ocount; /* output packet count on vif */
352 netbsd32_u_long ibytes; /* input byte count on vif */
353 netbsd32_u_long obytes; /* output byte count on vif */
354 };
355 /* from <sys/sockio.h> */
356 #define SIOCGETVIFCNT32 _IOWR('u', 51, struct netbsd32_sioc_vif_req)/* vif pkt cnt */
357
358 struct netbsd32_sioc_sg_req {
359 struct in_addr src;
360 struct in_addr grp;
361 u_long pktcnt;
362 u_long bytecnt;
363 u_long wrong_if;
364 };
365 /* from <sys/sockio.h> */
366 #define SIOCGETSGCNT32 _IOWR('u', 52, struct netbsd32_sioc_sg_req) /* sg pkt cnt */
367
368 /*
369 * The next two structures are marked "__packed" as they normally end up
370 * being padded in 64-bit mode.
371 */
372 struct netbsd32_vnd_ioctl {
373 netbsd32_charp vnd_file; /* pathname of file to mount */
374 int vnd_flags; /* flags; see below */
375 struct vndgeom vnd_geom; /* geometry to emulate */
376 unsigned int vnd_osize; /* (returned) size of disk */
377 uint64_t vnd_size; /* (returned) size of disk */
378 } __packed;
379
380 struct netbsd32_vnd_user {
381 int vnu_unit; /* which vnd unit */
382 dev_t vnu_dev; /* file is on this device... */
383 ino_t vnu_ino; /* ...at this inode */
384 } __packed;
385
386 /* from <dev/vndvar.h> */
387 #define VNDIOCSET32 _IOWR('F', 0, struct netbsd32_vnd_ioctl) /* enable disk */
388 #define VNDIOCCLR32 _IOW('F', 1, struct netbsd32_vnd_ioctl) /* disable disk */
389 #define VNDIOCGET32 _IOWR('F', 3, struct netbsd32_vnd_user) /* get list */
390
391 struct netbsd32_vnd_ioctl50 {
392 netbsd32_charp vnd_file; /* pathname of file to mount */
393 int vnd_flags; /* flags; see below */
394 struct vndgeom vnd_geom; /* geometry to emulate */
395 unsigned int vnd_size; /* (returned) size of disk */
396 } __packed;
397 /* from <dev/vnd.c> */
398 #define VNDIOCSET5032 _IOWR('F', 0, struct netbsd32_vnd_ioctl50)
399 #define VNDIOCCLR5032 _IOW('F', 1, struct netbsd32_vnd_ioctl50)
400
401 #define ENVSYS_GETDICTIONARY32 _IOWR('E', 0, struct netbsd32_plistref)
402 #define ENVSYS_SETDICTIONARY32 _IOWR('E', 1, struct netbsd32_plistref)
403 #define ENVSYS_REMOVEPROPS32 _IOWR('E', 2, struct netbsd32_plistref)
404
405 /* from <sys/wdog.h> */
406 struct netbsd32_wdog_conf {
407 netbsd32_charp wc_names;
408 int wc_count;
409 };
410 #define WDOGIOC_GWDOGS32 _IOWR('w', 5, struct netbsd32_wdog_conf)
411