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