netlink.h revision de3d12f48ac1869fc9f9cb442b2d692b027d8a14
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#ifndef __LINUX_NETLINK_H 28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define __LINUX_NETLINK_H 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <linux/socket.h> /* for sa_family_t */ 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#include <linux/types.h> 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_ROUTE 0 /* Routing/device hook */ 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_UNUSED 1 /* Unused number */ 9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */ 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_FIREWALL 3 /* Firewalling hook */ 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_INET_DIAG 4 /* INET socket monitoring */ 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_NFLOG 5 /* netfilter/iptables ULOG */ 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_XFRM 6 /* ipsec */ 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_SELINUX 7 /* SELinux event notifications */ 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_ISCSI 8 /* Open-iSCSI */ 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_AUDIT 9 /* auditing */ 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_FIB_LOOKUP 10 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_CONNECTOR 11 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_NETFILTER 12 /* netfilter subsystem */ 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_IP6_FW 13 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_DNRTMSG 14 /* DECnet routing messages */ 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */ 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_GENERIC 16 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* leave room for NETLINK_DM (DM Events) */ 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_SCSITRANSPORT 18 /* SCSI Transports */ 269aa8b32233702b19b97bebdc2c702e0c53407d45reed@android.com#define NETLINK_ECRYPTFS 19 279aa8b32233702b19b97bebdc2c702e0c53407d45reed@android.com 289aa8b32233702b19b97bebdc2c702e0c53407d45reed@android.com#define MAX_LINKS 32 299aa8b32233702b19b97bebdc2c702e0c53407d45reed@android.com 309aa8b32233702b19b97bebdc2c702e0c53407d45reed@android.comstruct sockaddr_nl 319aa8b32233702b19b97bebdc2c702e0c53407d45reed@android.com{ 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com sa_family_t nl_family; /* AF_NETLINK */ 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com unsigned short nl_pad; /* zero */ 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com __u32 nl_pid; /* port ID */ 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com __u32 nl_groups; /* multicast groups mask */ 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct nlmsghdr 39de916c8ac866378cee9af2bf161c79f528d9ccd5reed@google.com{ 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com __u32 nlmsg_len; /* Length of message including header */ 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com __u16 nlmsg_type; /* Message content */ 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com __u16 nlmsg_flags; /* Additional flags */ 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com __u32 nlmsg_seq; /* Sequence number */ 44de916c8ac866378cee9af2bf161c79f528d9ccd5reed@google.com __u32 nlmsg_pid; /* Sending process port ID */ 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* Flags values */ 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLM_F_REQUEST 1 /* It is request message. */ 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLM_F_MULTI 2 /* Multipart message, terminated by NLMSG_DONE */ 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLM_F_ACK 4 /* Reply with ack, with zero or error code */ 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLM_F_ECHO 8 /* Echo this request */ 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* Modifiers to GET request */ 557ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.org#define NLM_F_ROOT 0x100 /* specify tree root */ 568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLM_F_MATCH 0x200 /* return all matching */ 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLM_F_ATOMIC 0x400 /* atomic GET */ 58de916c8ac866378cee9af2bf161c79f528d9ccd5reed@google.com#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH) 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* Modifiers to NEW request */ 618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLM_F_REPLACE 0x100 /* Override existing */ 62de916c8ac866378cee9af2bf161c79f528d9ccd5reed@google.com#define NLM_F_EXCL 0x200 /* Do not touch, if it exists */ 638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLM_F_CREATE 0x400 /* Create, if it does not exist */ 648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLM_F_APPEND 0x800 /* Add to end of list */ 65de916c8ac866378cee9af2bf161c79f528d9ccd5reed@google.com 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 674516f4786f5dda1b86a8f825b9e8e910d9c2363creed@android.com 4.4BSD ADD NLM_F_CREATE|NLM_F_EXCL 684516f4786f5dda1b86a8f825b9e8e910d9c2363creed@android.com 4.4BSD CHANGE NLM_F_REPLACE 694516f4786f5dda1b86a8f825b9e8e910d9c2363creed@android.com 704516f4786f5dda1b86a8f825b9e8e910d9c2363creed@android.com True CHANGE NLM_F_CREATE|NLM_F_REPLACE 714516f4786f5dda1b86a8f825b9e8e910d9c2363creed@android.com Append NLM_F_CREATE 72bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com Check NLM_F_EXCL 73bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com */ 74bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com 75bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com#define NLMSG_ALIGNTO 4 76bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) ) 77bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr))) 78bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN)) 79bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len)) 80bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0))) 81bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ 82bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) 83bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ 84bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ 85bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com (nlh)->nlmsg_len <= (len)) 86bdf736133b513bb13f7c66e01c8c37ac526ce8d4reed@google.com#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len))) 878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLMSG_NOOP 0x1 /* Nothing. */ 898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLMSG_ERROR 0x2 /* Error */ 908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLMSG_DONE 0x3 /* End of a dump */ 918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLMSG_OVERRUN 0x4 /* Data lost */ 928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NLMSG_MIN_TYPE 0x10 /* < 0x10: reserved control messages */ 948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct nlmsgerr 960c00f21fee3f5cfa3aa7e5d46ff94cb8cf340451tomhudson@google.com{ 978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int error; 988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com struct nlmsghdr msg; 998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_ADD_MEMBERSHIP 1 1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_DROP_MEMBERSHIP 2 1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NETLINK_PKTINFO 3 1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1050c00f21fee3f5cfa3aa7e5d46ff94cb8cf340451tomhudson@google.comstruct nl_pktinfo 1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com{ 1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com __u32 group; 1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define NET_MAJOR 36 /* Major 36 is reserved for networking */ 1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comenum { 1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com NETLINK_UNCONNECTED = 0, 1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com NETLINK_CONNECTED, 11576f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com}; 11676f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com 11776f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com/* 11876f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com * <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)--> 11976f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com * +---------------------+- - -+- - - - - - - - - -+- - -+ 12076f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com * | Header | Pad | Payload | Pad | 12176f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com * | (struct nlattr) | ing | | ing | 12276f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com * +---------------------+- - -+- - - - - - - - - -+- - -+ 12376f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com * <-------------- nlattr->nla_len --------------> 12476f9e938df0b5826fd4c80b854ceafaf385cfbe1robertphillips@google.com */ 12528be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org 12628be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.orgstruct nlattr 12728be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org{ 12828be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org __u16 nla_len; 12928be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org __u16 nla_type; 13028be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org}; 13128be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org 13249a5b1967ac5bbc6699bee9a2c66088c42aef6fdreed@google.com#define NLA_ALIGNTO 4 13349a5b1967ac5bbc6699bee9a2c66088c42aef6fdreed@google.com#define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1)) 13449a5b1967ac5bbc6699bee9a2c66088c42aef6fdreed@google.com#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr))) 13549a5b1967ac5bbc6699bee9a2c66088c42aef6fdreed@google.com 13649a5b1967ac5bbc6699bee9a2c66088c42aef6fdreed@google.com 13749a5b1967ac5bbc6699bee9a2c66088c42aef6fdreed@google.com#endif /* __LINUX_NETLINK_H */ 13849a5b1967ac5bbc6699bee9a2c66088c42aef6fdreed@google.com