/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI__LINUX_NETLINK_H #define _UAPI__LINUX_NETLINK_H #include <linux/const.h> #include <linux/socket.h> /* for __kernel_sa_family_t */ #include <linux/types.h> #define NETLINK_ROUTE … #define NETLINK_UNUSED … #define NETLINK_USERSOCK … #define NETLINK_FIREWALL … #define NETLINK_SOCK_DIAG … #define NETLINK_NFLOG … #define NETLINK_XFRM … #define NETLINK_SELINUX … #define NETLINK_ISCSI … #define NETLINK_AUDIT … #define NETLINK_FIB_LOOKUP … #define NETLINK_CONNECTOR … #define NETLINK_NETFILTER … #define NETLINK_IP6_FW … #define NETLINK_DNRTMSG … #define NETLINK_KOBJECT_UEVENT … #define NETLINK_GENERIC … /* leave room for NETLINK_DM (DM Events) */ #define NETLINK_SCSITRANSPORT … #define NETLINK_ECRYPTFS … #define NETLINK_RDMA … #define NETLINK_CRYPTO … #define NETLINK_SMC … #define NETLINK_INET_DIAG … #define MAX_LINKS … struct sockaddr_nl { … }; /** * struct nlmsghdr - fixed format metadata header of Netlink messages * @nlmsg_len: Length of message including header * @nlmsg_type: Message content type * @nlmsg_flags: Additional flags * @nlmsg_seq: Sequence number * @nlmsg_pid: Sending process port ID */ struct nlmsghdr { … }; /* Flags values */ #define NLM_F_REQUEST … #define NLM_F_MULTI … #define NLM_F_ACK … #define NLM_F_ECHO … #define NLM_F_DUMP_INTR … #define NLM_F_DUMP_FILTERED … /* Modifiers to GET request */ #define NLM_F_ROOT … #define NLM_F_MATCH … #define NLM_F_ATOMIC … #define NLM_F_DUMP … /* Modifiers to NEW request */ #define NLM_F_REPLACE … #define NLM_F_EXCL … #define NLM_F_CREATE … #define NLM_F_APPEND … /* Modifiers to DELETE request */ #define NLM_F_NONREC … #define NLM_F_BULK … /* Flags for ACK message */ #define NLM_F_CAPPED … #define NLM_F_ACK_TLVS … /* 4.4BSD ADD NLM_F_CREATE|NLM_F_EXCL 4.4BSD CHANGE NLM_F_REPLACE True CHANGE NLM_F_CREATE|NLM_F_REPLACE Append NLM_F_CREATE Check NLM_F_EXCL */ #define NLMSG_ALIGNTO … #define NLMSG_ALIGN(len) … #define NLMSG_HDRLEN … #define NLMSG_LENGTH(len) … #define NLMSG_SPACE(len) … #define NLMSG_DATA(nlh) … #define NLMSG_NEXT(nlh,len) … #define NLMSG_OK(nlh,len) … #define NLMSG_PAYLOAD(nlh,len) … #define NLMSG_NOOP … #define NLMSG_ERROR … #define NLMSG_DONE … #define NLMSG_OVERRUN … #define NLMSG_MIN_TYPE … struct nlmsgerr { … }; /** * enum nlmsgerr_attrs - nlmsgerr attributes * @NLMSGERR_ATTR_UNUSED: unused * @NLMSGERR_ATTR_MSG: error message string (string) * @NLMSGERR_ATTR_OFFS: offset of the invalid attribute in the original * message, counting from the beginning of the header (u32) * @NLMSGERR_ATTR_COOKIE: arbitrary subsystem specific cookie to * be used - in the success case - to identify a created * object or operation or similar (binary) * @NLMSGERR_ATTR_POLICY: policy for a rejected attribute * @NLMSGERR_ATTR_MISS_TYPE: type of a missing required attribute, * %NLMSGERR_ATTR_MISS_NEST will not be present if the attribute was * missing at the message level * @NLMSGERR_ATTR_MISS_NEST: offset of the nest where attribute was missing * @__NLMSGERR_ATTR_MAX: number of attributes * @NLMSGERR_ATTR_MAX: highest attribute number */ enum nlmsgerr_attrs { … }; #define NETLINK_ADD_MEMBERSHIP … #define NETLINK_DROP_MEMBERSHIP … #define NETLINK_PKTINFO … #define NETLINK_BROADCAST_ERROR … #define NETLINK_NO_ENOBUFS … #ifndef __KERNEL__ #define NETLINK_RX_RING … #define NETLINK_TX_RING … #endif #define NETLINK_LISTEN_ALL_NSID … #define NETLINK_LIST_MEMBERSHIPS … #define NETLINK_CAP_ACK … #define NETLINK_EXT_ACK … #define NETLINK_GET_STRICT_CHK … struct nl_pktinfo { … }; struct nl_mmap_req { … }; struct nl_mmap_hdr { … }; #ifndef __KERNEL__ enum nl_mmap_status { NL_MMAP_STATUS_UNUSED, NL_MMAP_STATUS_RESERVED, NL_MMAP_STATUS_VALID, NL_MMAP_STATUS_COPY, NL_MMAP_STATUS_SKIP, }; #define NL_MMAP_MSG_ALIGNMENT … #define NL_MMAP_MSG_ALIGN … #define NL_MMAP_HDRLEN … #endif #define NET_MAJOR … enum { … }; /* * <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)--> * +---------------------+- - -+- - - - - - - - - -+- - -+ * | Header | Pad | Payload | Pad | * | (struct nlattr) | ing | | ing | * +---------------------+- - -+- - - - - - - - - -+- - -+ * <-------------- nlattr->nla_len --------------> */ struct nlattr { … }; /* * nla_type (16 bits) * +---+---+-------------------------------+ * | N | O | Attribute Type | * +---+---+-------------------------------+ * N := Carries nested attributes * O := Payload stored in network byte order * * Note: The N and O flag are mutually exclusive. */ #define NLA_F_NESTED … #define NLA_F_NET_BYTEORDER … #define NLA_TYPE_MASK … #define NLA_ALIGNTO … #define NLA_ALIGN(len) … #define NLA_HDRLEN … /* Generic 32 bitflags attribute content sent to the kernel. * * The value is a bitmap that defines the values being set * The selector is a bitmask that defines which value is legit * * Examples: * value = 0x0, and selector = 0x1 * implies we are selecting bit 1 and we want to set its value to 0. * * value = 0x2, and selector = 0x2 * implies we are selecting bit 2 and we want to set its value to 1. * */ struct nla_bitfield32 { … }; /* * policy descriptions - it's specific to each family how this is used * Normally, it should be retrieved via a dump inside another attribute * specifying where it applies. */ /** * enum netlink_attribute_type - type of an attribute * @NL_ATTR_TYPE_INVALID: unused * @NL_ATTR_TYPE_FLAG: flag attribute (present/not present) * @NL_ATTR_TYPE_U8: 8-bit unsigned attribute * @NL_ATTR_TYPE_U16: 16-bit unsigned attribute * @NL_ATTR_TYPE_U32: 32-bit unsigned attribute * @NL_ATTR_TYPE_U64: 64-bit unsigned attribute * @NL_ATTR_TYPE_S8: 8-bit signed attribute * @NL_ATTR_TYPE_S16: 16-bit signed attribute * @NL_ATTR_TYPE_S32: 32-bit signed attribute * @NL_ATTR_TYPE_S64: 64-bit signed attribute * @NL_ATTR_TYPE_BINARY: binary data, min/max length may be specified * @NL_ATTR_TYPE_STRING: string, min/max length may be specified * @NL_ATTR_TYPE_NUL_STRING: NUL-terminated string, * min/max length may be specified * @NL_ATTR_TYPE_NESTED: nested, i.e. the content of this attribute * consists of sub-attributes. The nested policy and maxtype * inside may be specified. * @NL_ATTR_TYPE_NESTED_ARRAY: nested array, i.e. the content of this * attribute contains sub-attributes whose type is irrelevant * (just used to separate the array entries) and each such array * entry has attributes again, the policy for those inner ones * and the corresponding maxtype may be specified. * @NL_ATTR_TYPE_BITFIELD32: &struct nla_bitfield32 attribute * @NL_ATTR_TYPE_SINT: 32-bit or 64-bit signed attribute, aligned to 4B * @NL_ATTR_TYPE_UINT: 32-bit or 64-bit unsigned attribute, aligned to 4B */ enum netlink_attribute_type { … }; /** * enum netlink_policy_type_attr - policy type attributes * @NL_POLICY_TYPE_ATTR_UNSPEC: unused * @NL_POLICY_TYPE_ATTR_TYPE: type of the attribute, * &enum netlink_attribute_type (U32) * @NL_POLICY_TYPE_ATTR_MIN_VALUE_S: minimum value for signed * integers (S64) * @NL_POLICY_TYPE_ATTR_MAX_VALUE_S: maximum value for signed * integers (S64) * @NL_POLICY_TYPE_ATTR_MIN_VALUE_U: minimum value for unsigned * integers (U64) * @NL_POLICY_TYPE_ATTR_MAX_VALUE_U: maximum value for unsigned * integers (U64) * @NL_POLICY_TYPE_ATTR_MIN_LENGTH: minimum length for binary * attributes, no minimum if not given (U32) * @NL_POLICY_TYPE_ATTR_MAX_LENGTH: maximum length for binary * attributes, no maximum if not given (U32) * @NL_POLICY_TYPE_ATTR_POLICY_IDX: sub policy for nested and * nested array types (U32) * @NL_POLICY_TYPE_ATTR_POLICY_MAXTYPE: maximum sub policy * attribute for nested and nested array types, this can * in theory be < the size of the policy pointed to by * the index, if limited inside the nesting (U32) * @NL_POLICY_TYPE_ATTR_BITFIELD32_MASK: valid mask for the * bitfield32 type (U32) * @NL_POLICY_TYPE_ATTR_MASK: mask of valid bits for unsigned integers (U64) * @NL_POLICY_TYPE_ATTR_PAD: pad attribute for 64-bit alignment * * @__NL_POLICY_TYPE_ATTR_MAX: number of attributes * @NL_POLICY_TYPE_ATTR_MAX: highest attribute number */ enum netlink_policy_type_attr { … }; #endif /* _UAPI__LINUX_NETLINK_H */