From: Warner Losh <imp@bsdimp.com>
To: qemu-devel@nongnu.org
Cc: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>,
Stacey Son <sson@FreeBSD.org>,
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Subject: [PATCH 10/25] bsd-user: Add FreeBSD socket ioctl definitions
Date: Wed, 6 May 2026 20:22:04 -0600 [thread overview]
Message-ID: <20260507022219.44171-11-imp@bsdimp.com> (raw)
In-Reply-To: <20260507022219.44171-1-imp@bsdimp.com>
From: Stacey Son <sson@FreeBSD.org>
Add os-ioctl-sockio.h with network socket and interface control ioctl
definitions including SIOCGIFADDR, SIOCSIFADDR, SIOCGIFCONF, and
related network interface ioctls with target_ structure definitions.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/freebsd/os-ioctl-sockio.h | 246 +++++++++++++++++++++++++++++
1 file changed, 246 insertions(+)
create mode 100644 bsd-user/freebsd/os-ioctl-sockio.h
diff --git a/bsd-user/freebsd/os-ioctl-sockio.h b/bsd-user/freebsd/os-ioctl-sockio.h
new file mode 100644
index 0000000000..5c1a619400
--- /dev/null
+++ b/bsd-user/freebsd/os-ioctl-sockio.h
@@ -0,0 +1,246 @@
+/*
+ * FreeBSD sockio.h definitions for ioctl(2) emulation
+ *
+ * Copyright (c) 2015 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef OS_IOCTL_SOCKIO_H
+#define OS_IOCTL_SOCKIO_H
+
+/* See sys/sockio.h */
+#define TARGET_SIOCSHIWAT TARGET_IOW('s', 0, int32_t)
+#define TARGET_SIOCGHIWAT TARGET_IOR('s', 1, int32_t)
+#define TARGET_SIOCSLOWAT TARGET_IOW('s', 2, int32_t)
+#define TARGET_SIOCGLOWAT TARGET_IOR('s', 3, int32_t)
+#define TARGET_SIOCATMARK TARGET_IOR('s', 7, int32_t)
+#define TARGET_SIOCSPGRP TARGET_IOW('s', 8, int32_t)
+#define TARGET_SIOCGPGRP TARGET_IOR('s', 9, int32_t)
+
+/* See net/if.h */
+struct target_ifreq_buffer {
+ abi_ulong length;
+ abi_ulong buffer;
+};
+
+struct target_ifreq_nv_req {
+ abi_uint buf_length; /* Total size of buffer */
+ abi_uint length; /* Length of the filled part */
+ abi_ulong buffer; /* Buffer itself, containing packed nv */
+};
+
+#define TARGET_IFNAMSIZ 16
+
+struct target_ifreq {
+ char ifr_name[TARGET_IFNAMSIZ];
+ union {
+ struct target_sockaddr ifru_addr;
+ struct target_sockaddr ifru_dstaddr;
+ struct target_sockaddr ifru_broadaddr;
+ struct target_ifreq_buffer ifru_buffer;
+ abi_short ifru_flags[2];
+ abi_short ifru_index;
+ abi_int ifru_jid;
+ abi_int ifru_metric;
+ abi_int ifru_mtu;
+ abi_int ifru_phys;
+ abi_int ifru_media;
+ abi_ulong ifru_data;
+ abi_int ifru_cap[2];
+ uint32_t ifru_fib;
+ uint8_t ifru_vlan_pcp;
+ struct target_ifreq_nv_req ifru_nv;
+ } ifr_ifru;
+};
+
+
+#define TARGET_SIOCSIFADDR TARGET_IOW('i', 12, struct target_ifreq)
+#define TARGET_SIOCGIFADDR TARGET_IOWR('i', 33, struct target_ifreq)
+#define TARGET_SIOCSIFDSTADDR TARGET_IOW('i', 14, struct target_ifreq)
+#define TARGET_SIOCGIFDSTADDR TARGET_IOWR('i', 34, struct target_ifreq)
+#define TARGET_SIOCSIFFLAGS TARGET_IOW('i', 16, struct target_ifreq)
+#define TARGET_SIOCGIFFLAGS TARGET_IOWR('i', 17, struct target_ifreq)
+#define TARGET_SIOCGIFBRDADDR TARGET_IOWR('i', 35, struct target_ifreq)
+#define TARGET_SIOCSIFBRDADDR TARGET_IOW('i', 19, struct target_ifreq)
+#define TARGET_SIOCGIFNETMASK TARGET_IOWR('i', 37, struct target_ifreq)
+#define TARGET_SIOCSIFNETMASK TARGET_IOW('i', 22, struct target_ifreq)
+#define TARGET_SIOCGIFMETRIC TARGET_IOWR('i', 23, struct target_ifreq)
+#define TARGET_SIOCSIFMETRIC TARGET_IOW('i', 24, struct target_ifreq)
+#define TARGET_SIOCDIFADDR TARGET_IOW('i', 25, struct target_ifreq)
+#define TARGET_SIOCSIFCAP TARGET_IOW('i', 30, struct target_ifreq)
+#define TARGET_SIOCGIFCAP TARGET_IOWR('i', 31, struct target_ifreq)
+#define TARGET_SIOCGIFINDEX TARGET_IOWR('i', 32, struct target_ifreq)
+#define TARGET_SIOCGIFMAC TARGET_IOWR('i', 38, struct target_ifreq)
+#define TARGET_SIOCSIFMAC TARGET_IOW('i', 39, struct target_ifreq)
+#define TARGET_SIOCSIFNAME TARGET_IOW('i', 40, struct target_ifreq)
+#define TARGET_SIOCSIFDESCR TARGET_IOW('i', 41, struct target_ifreq)
+#define TARGET_SIOCGIFDESCR TARGET_IOWR('i', 42, struct target_ifreq)
+#define TARGET_SIOCADDMULTI TARGET_IOW('i', 49, struct target_ifreq)
+#define TARGET_SIOCDELMULTI TARGET_IOW('i', 50, struct target_ifreq)
+#define TARGET_SIOCGIFMTU TARGET_IOWR('i', 51, struct target_ifreq)
+#define TARGET_SIOCSIFMTU TARGET_IOW('i', 52, struct target_ifreq)
+#define TARGET_SIOCGIFPHYS TARGET_IOWR('i', 53, struct target_ifreq)
+#define TARGET_SIOCSIFPHYS TARGET_IOW('i', 54, struct target_ifreq)
+#define TARGET_SIOCSIFMEDIA TARGET_IOWR('i', 55, struct target_ifreq)
+#define TARGET_SIOCSIFGENERIC TARGET_IOW('i', 57, struct target_ifreq)
+#define TARGET_SIOCGIFGENERIC TARGET_IOWR('i', 58, struct target_ifreq)
+#define TARGET_SIOCSIFLLADDR TARGET_IOW('i', 60, struct target_ifreq)
+#define TARGET_SIOCGIFPSRCADDR TARGET_IOWR('i', 71, struct target_ifreq)
+#define TARGET_SIOCGIFPDSTADDR TARGET_IOWR('i', 72, struct target_ifreq)
+#define TARGET_SIOCDIFPHYADDR TARGET_IOW('i', 73, struct target_ifreq)
+#define TARGET_SIOCGPRIVATE_0 TARGET_IOWR('i', 80, struct target_ifreq)
+#define TARGET_SIOCGPRIVATE_1 TARGET_IOWR('i', 81, struct target_ifreq)
+#define TARGET_SIOCSIFVNET TARGET_IOWR('i', 90, struct target_ifreq)
+#define TARGET_SIOCSIFRVNET TARGET_IOWR('i', 91, struct target_ifreq)
+#define TARGET_SIOCGIFFIB TARGET_IOWR('i', 92, struct target_ifreq)
+#define TARGET_SIOCSIFFIB TARGET_IOW('i', 93, struct target_ifreq)
+#define TARGET_SIOCGTUNFIB TARGET_IOWR('i', 94, struct target_ifreq)
+#define TARGET_SIOCIFCREATE TARGET_IOWR('i', 122, struct target_ifreq)
+#define TARGET_SIOCIFCREATE2 TARGET_IOWR('i', 124, struct target_ifreq)
+#define TARGET_SIOCIFDESTROY TARGET_IOW('i', 121, struct target_ifreq)
+
+/* net/if_gre.h */
+#define TARGET_GREGKEY TARGET_IOWR('i', 107, struct target_ifreq)
+#define TARGET_GREGOPTS TARGET_IOWR('i', 109, struct target_ifreq)
+
+/* net/if_gif.h */
+#define TARGET_GIFGOPTS TARGET_IOWR('i', 150, struct target_ifreq)
+
+/* netinet/ip_carp.h */
+#define TARGET_SIOCGVH TARGET_IOWR('i', 246, struct target_ifreq)
+
+/* net/if_pfsync.h */
+#define TARGET_SIOCGETPFSYNC TARGET_IOWR('i', 248, struct target_ifreq)
+
+
+/* See net/if.h */
+struct target_ifconf {
+ int32_t ifc_len;
+ union {
+ abi_ulong ifcu_buf;
+ abi_ulong ifcu_req;
+ } ifc_ifcu;
+};
+
+#define TARGET_SIOCGIFCONF TARGET_IOWR('i', 36, struct target_ifconf)
+
+/* See net/if.h */
+struct target_ifdrv {
+ char ifd_name[TARGET_IFNAMSIZ];
+ abi_ulong ifd_cmd;
+ abi_ulong ifd_len;
+ abi_ulong ifd_data;
+};
+
+#define TARGET_SIOCSDRVSPEC TARGET_IOW('i', 123, struct target_ifdrv)
+#define TARGET_SIOCGDRVSPEC TARGET_IOWR('i', 123, struct target_ifdrv)
+
+/* See net/if.h */
+struct target_ifg_req {
+ union {
+ char ifgrqu_group[TARGET_IFNAMSIZ];
+ char ifgrqu_member[TARGET_IFNAMSIZ];
+ } ifgrq_ifgrqu;
+};
+
+struct target_ifgroupreq {
+ char ifgr_name[TARGET_IFNAMSIZ];
+ uint32_t ifgr_len;
+ union {
+ char ifgru_group[TARGET_IFNAMSIZ];
+ abi_ulong ifgru_groups;
+ } ifgr_ifgru;
+};
+
+#define TARGET_SIOCGIFGROUP TARGET_IOWR('i', 136, struct target_ifgroupreq)
+
+struct target_ifmediareq {
+ char ifm_name[TARGET_IFNAMSIZ];
+ int32_t ifm_current;
+ int32_t ifm_mask;
+ int32_t ifm_status;
+ int32_t ifm_active;
+ int32_t ifm_count;
+ abi_ulong ifm_ulist;
+};
+
+#define TARGET_SIOCGIFMEDIA TARGET_IOWR('i', 56, struct target_ifmediareq)
+#define TARGET_SIOCGIFXMEDIA TARGET_IOWR('i', 139, struct target_ifmediareq)
+
+#define TARGET_IFSTATMAX 800
+struct target_ifstat {
+ char ifs_name[TARGET_IFNAMSIZ];
+ char ascii[TARGET_IFSTATMAX + 1];
+};
+
+#define TARGET_SIOCGIFSTATUS TARGET_IOWR('i', 59, struct target_ifstat)
+
+/* net80211/ieee80211_ioctl.h */
+struct target_ieee80211req {
+ char i_name[TARGET_IFNAMSIZ];
+ uint16_t i_type;
+ int16_t i_val;
+ uint16_t i_len;
+ abi_ulong i_data;
+};
+
+#define TARGET_SIOCG80211 TARGET_IOWR('i', 235, struct target_ieee80211req)
+
+/* net/if_lagg.h */
+struct target_lacp_opreq {
+ uint16_t actor_prio;
+ uint8_t actor_mac[ETHER_ADDR_LEN];
+ uint16_t actor_key;
+ uint16_t actor_portprio;
+ uint16_t actor_portno;
+ uint8_t actor_state;
+ uint16_t partner_prio;
+ uint8_t partner_mac[ETHER_ADDR_LEN];
+ uint16_t partner_key;
+ uint16_t partner_portprio;
+ uint16_t partner_portno;
+ uint8_t partner_state;
+};
+
+struct target_lagg_reqport {
+ char rp_ifname[TARGET_IFNAMSIZ];
+ char rp_portname[TARGET_IFNAMSIZ];
+ u_int32_t rp_prio;
+ u_int32_t rp_flags;
+ union {
+ struct target_lacp_opreq rpsc_lacp;
+ } rp_psc;
+};
+#define TARGET_SIOCGLAGGPORT TARGET_IOWR('i', 140, struct target_lagg_reqport)
+
+struct target_lagg_reqall {
+ char ra_ifname[TARGET_IFNAMSIZ];
+ abi_uint ra_proto;
+
+ abi_ulong ra_size;
+ abi_ulong ra_port;
+ abi_int ra_ports;
+ union {
+ struct target_lacp_opreq rpsc_lacp;
+ } ra_psc;
+};
+#define TARGET_SIOCGLAGG TARGET_IOWR('i', 143, struct target_lagg_reqall)
+
+struct target_lagg_reqflags {
+ char rf_ifname[TARGET_IFNAMSIZ];
+ uint32_t rf_flags;
+};
+#define TARGET_SIOCGLAGGFLAGS TARGET_IOWR('i', 145, struct target_lagg_reqflags)
+
+struct target_lagg_reqopts {
+ char ro_ifname[TARGET_IFNAMSIZ];
+ abi_int ro_opts;
+ abi_uint ro_count;
+ abi_uint ro_active;
+ abi_uint ro_flapping;
+ abi_int ro_flowid_shift;
+ uint32_t ro_bkt;
+};
+#define TARGET_SIOCGLAGGOPTS TARGET_IOWR('i', 152, struct target_lagg_reqopts)
+
+#endif /* OS_IOCTL_SOCKIO_H */
--
2.52.0
next prev parent reply other threads:[~2026-05-07 2:27 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 2:21 [PATCH 00/25] bsd-user May 2026 pull request Warner Losh
2026-05-07 2:21 ` [PATCH 01/25] bsd-user: Switch to SPDX-License-Expression Warner Losh
2026-05-07 2:21 ` [PATCH 02/25] bsd-user: Add syscall header generator for FreeBSD Warner Losh
2026-05-07 2:21 ` [PATCH 03/25] bsd-user: Delete sbrk and sstk system calls Warner Losh
2026-05-07 2:21 ` [PATCH 04/25] bsd-user: Create os-syscall.h Warner Losh
2026-05-07 2:21 ` [PATCH 05/25] bsd-user: Switch to generated syscall_nr.h Warner Losh
2026-05-07 2:22 ` [PATCH 06/25] bsd-user: Copy linux-user/thunk.c to bsd-user Warner Losh
2026-05-07 2:22 ` [PATCH 07/25] bsd-user: ioctl: add common definitions Warner Losh
2026-05-07 2:22 ` [PATCH 08/25] bsd-user: Add FreeBSD tty ioctl definitions Warner Losh
2026-05-07 2:22 ` [PATCH 09/25] bsd-user: Add FreeBSD file I/O " Warner Losh
2026-05-07 2:22 ` Warner Losh [this message]
2026-05-07 2:22 ` [PATCH 11/25] bsd-user: Add FreeBSD cryptodev " Warner Losh
2026-05-07 2:22 ` [PATCH 12/25] bsd-user: Add FreeBSD disk " Warner Losh
2026-05-07 2:22 ` [PATCH 13/25] bsd-user: Add FreeBSD IPv6 " Warner Losh
2026-05-07 2:22 ` [PATCH 14/25] bsd-user: Add FreeBSD ioctl type definitions Warner Losh
2026-05-07 2:22 ` [PATCH 15/25] bsd-user: Add FreeBSD ioctl command table Warner Losh
2026-05-07 2:22 ` [PATCH 16/25] bsd-user: Add bsd-ioctl.h header Warner Losh
2026-05-07 2:22 ` [PATCH 17/25] bsd-user: Add target_sockaddr and safe_ioctl to syscall_defs.h Warner Losh
2026-05-07 2:22 ` [PATCH 18/25] bsd-user: Add bsd-ioctl.c infrastructure and termios conversion Warner Losh
2026-05-07 2:22 ` [PATCH 19/25] bsd-user: Add log_unsupported_ioctl function Warner Losh
2026-05-07 2:22 ` [PATCH 20/25] bsd-user: Add do_ioctl_unsupported function Warner Losh
2026-05-07 2:22 ` [PATCH 21/25] bsd-user: Add target_to_host_sockaddr_in6 function Warner Losh
2026-05-07 2:22 ` [PATCH 22/25] bsd-user: Add do_ioctl_in6_ifreq_sockaddr_int function Warner Losh
2026-05-07 2:22 ` [PATCH 23/25] bsd-user: Add do_bsd_ioctl main function Warner Losh
2026-05-07 2:22 ` [PATCH 24/25] bsd-user: Add init_bsd_ioctl function Warner Losh
2026-05-07 2:22 ` [PATCH 25/25] bsd-user: Add call to do_bsd_ioctl and add bsd-ioctl.c to the build Warner Losh
2026-05-07 2:31 ` [PATCH 00/25] bsd-user May 2026 pull request Warner Losh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260507022219.44171-11-imp@bsdimp.com \
--to=imp@bsdimp.com \
--cc=kevans@freebsd.org \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=sson@FreeBSD.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.