struct nwio_udpopt_t contains configuration information for a udp file descriptor. The uf_udpopt field of a udp file descriptor has type nwio_udpopt_t.
typedef struct nwio_udpopt
unsigned long nwuo_flags;
#define NWUO_NOFLAGS 0x0000L
#define NWUO_ACC_MASK 0x0003L
#define NWUO_EXCL 0x00000001L
#define NWUO_SHARED 0x00000002L
#define NWUO_COPY 0x00000003L
File descriptors that share the same port must have the same access permissions (i.e., their NWUO_EXCL, NWUO_SHARED, and NWUO_COPY flags are the same).
There does appear to be an error in the code, however. If the NWUO_EXCL (exclusive access) flag is set, only one udp file descriptor should have access to the common udp port (0-65535). Unfortunately, this is not the case. Also, NWUO_COPY has no significance and is never used in the code.
#define NWUO_LOCPORT_MASK 0x000CL
#define NWUO_LP_SEL 0x00000004L
#define NWUO_LP_SET 0x00000008L
#define NWUO_LP_ANY 0x0000000CL
One of the flag sets that cannot be disabled. There are three different choices:
NWUO_LP_SEL: The network service chooses the port. This port will be in the 49152-65535 range and will be unique. Note that this is inconsistent with the ip(4) documentation (which says that the port will be in the 32768-65535 range).
NWUO_LP_SET: The local port is specified in the nwuo_locport field of the nwio_udpopt_t struct (see below).
NWUO_LP_ANY: The file descriptor accepts packets destined for any port.
#define NWUO_LOCADDR_MASK 0x0010L
#define NWUO_EN_LOC 0x00000010L
#define NWUO_DI_LOC 0x00100000L
If enabled, accept packets destined for local address specified by the nwuo_locaddr field of the nwio_udpopt_t struct (see below).
#define NWUO_BROAD_MASK 0x0020L
#define NWUO_EN_BROAD 0x00000020L
#define NWUO_DI_BROAD 0x00200000L
If enabled, accept broadcast packets. If disabled, reject broadcast packets.
#define NWUO_REMPORT_MASK 0x0100L
#define NWUO_RP_SET 0x00000100L
#define NWUO_RP_ANY 0x01000000L
#define NWUO_REMADDR_MASK 0x0200L
#define NWUO_RA_SET 0x00000200L
#define NWUO_RA_ANY 0x02000000L
A udp file descriptor can be configured to only send packets to a specific udp port and ip address. If NWUO_RP_SET and NWUO_RA_SET are enabled, a remote port (nwuo_remport) and a remote address (nwuo_locaddr) must be specified. If NWUO_RP_ANY and/or NWUO_RA_ANY are/is set, the destination may be any udp port and/or any ip address. See below.
#define NWUO_RW_MASK 0x1000L
#define NWUO_RWDATONLY 0x00001000L
#define NWUO_RWDATALL 0x10000000L
If NWUO_RWDATONLY is set, only the data is sent to the ip layer. If NWUO_RWDATALL is set, the source and destination ip addresses, the source and destination udp ports, and other information (e.g., ip options) are sent (in addition to the data) to the ip layer.
#define NWUO_IPOPT_MASK 0x2000L
#define NWUO_EN_IPOPT 0x00002000L
#define NWUO_DI_IPOPT 0x20000000L
If NWUO_EN_IPOPT (ENable IP OPTions) is set, ip options are sent to the ip layer and received from the ip layer. If NWUO_DI_IPOPT (DIsable IP OPTions) is set, ip options are not sent to the ip layer and stripped from the packets received from the ip layer.
If there are any illegal combinations of flags (e.g., the NWUO_RWDATONLY and an inappropriate ..._ANY flag is set), the network service sends the user process an EBADMODE message.
EBADMODE is #define'd in /include/errno.h:
#define EBADMODE (_SIGN 53) /* badmode in ioctl */
nwuo_locport, nwuo_locaddr: The local udp port and address of the udp file descriptor.
nwuo_remport, nwuo_remaddr: (optional) The remote udp port and address of the remote system. If only a single destination is desired, these two fields are set.