netlink: Sync the macro with Linux definition
Change-Id: I0c0895fa17e167c67fb12acfdfc6dc3a7fb63b3b Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
e6c30629a1
commit
5708015674
@ -65,30 +65,32 @@
|
||||
|
||||
#define NETLINK_ROUTE 0 /* Routing/device hook for user-space
|
||||
* routing daemons (default) */
|
||||
#define NETLINK_USERSOCK 1 /* Reserved for user mode socket protocols */
|
||||
#define NETLINK_FIREWALL 2 /* Interface to receive packets from
|
||||
#define NETLINK_UNUSED 1 /* Unused number */
|
||||
#define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */
|
||||
#define NETLINK_FIREWALL 3 /* Interface to receive packets from
|
||||
* the firewall */
|
||||
#define NETLINK_SOCK_DIAG 3 /* Socket monitoring */
|
||||
#define NETLINK_NFLOG 4 /* netfilter/iptables ULOG */
|
||||
#define NETLINK_XFRM 5 /* Interface to IPsec security databases
|
||||
#define NETLINK_SOCK_DIAG 4 /* Socket monitoring */
|
||||
#define NETLINK_NFLOG 5 /* netfilter/iptables ULOG */
|
||||
#define NETLINK_XFRM 6 /* Interface to IPsec security databases
|
||||
* for key-manager daemons using the
|
||||
* Internet Key Exchange protocol. */
|
||||
#define NETLINK_ISCSI 6 /* Open-iSCSI */
|
||||
#define NETLINK_AUDIT 7 /* Interface to auditing sub-system */
|
||||
#define NETLINK_FIB_LOOKUP 8
|
||||
#define NETLINK_CONNECTOR 9
|
||||
#define NETLINK_NETFILTER 10 /* netfilter subsystem */
|
||||
#define NETLINK_IP6_FW 11 /* Interface to transport packets from
|
||||
#define NETLINK_SELINUX 7 /* SELinux event notifications */
|
||||
#define NETLINK_ISCSI 8 /* Open-iSCSI */
|
||||
#define NETLINK_AUDIT 9 /* Interface to auditing sub-system */
|
||||
#define NETLINK_FIB_LOOKUP 10
|
||||
#define NETLINK_CONNECTOR 11
|
||||
#define NETLINK_NETFILTER 12 /* netfilter subsystem */
|
||||
#define NETLINK_IP6_FW 13 /* Interface to transport packets from
|
||||
* netfilter to user-space. */
|
||||
#define NETLINK_DNRTMSG 12 /* DECnet routing messages */
|
||||
#define NETLINK_KOBJECT_UEVENT 13 /* Kernel messages to userspace */
|
||||
#define NETLINK_GENERIC 14
|
||||
#define NETLINK_DNRTMSG 14 /* DECnet routing messages */
|
||||
#define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */
|
||||
#define NETLINK_GENERIC 16
|
||||
/* NETLINK_DM (DM Events) */
|
||||
#define NETLINK_SCSITRANSPORT 16 /* SCSI Transports */
|
||||
#define NETLINK_ECRYPTFS 17
|
||||
#define NETLINK_RDMA 18
|
||||
#define NETLINK_CRYPTO 19 /* Crypto layer */
|
||||
#define NETLINK_SMC 20 /* SMC monitoring */
|
||||
#define NETLINK_SCSITRANSPORT 18 /* SCSI Transports */
|
||||
#define NETLINK_ECRYPTFS 19
|
||||
#define NETLINK_RDMA 20
|
||||
#define NETLINK_CRYPTO 21 /* Crypto layer */
|
||||
#define NETLINK_SMC 22 /* SMC monitoring */
|
||||
|
||||
/* Definitions associated with struct sockaddr_nl ***************************/
|
||||
|
||||
@ -131,16 +133,17 @@
|
||||
#define NLMSG_HDRLEN sizeof(struct nlmsghdr)
|
||||
#define NLMSG_LENGTH(n) (NLMSG_HDRLEN + (n))
|
||||
#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
|
||||
#define NLMSG_DATA(hdr) ((FAR void*)(((FAR char*)hdr) + NLMSG_HDRLEN))
|
||||
#define NLMSG_NEXT(hdr,n) \
|
||||
#define NLMSG_DATA(hdr) ((FAR void *)(((FAR char *)hdr) + NLMSG_HDRLEN))
|
||||
#define NLMSG_NEXT(hdr, n) \
|
||||
((n) -= NLMSG_ALIGN((hdr)->nlmsg_len), \
|
||||
(FAR struct nlmsghdr*) \
|
||||
(((FAR char*)(hdr)) + NLMSG_ALIGN((hdr)->nlmsg_len)))
|
||||
#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
|
||||
(FAR struct nlmsghdr *) \
|
||||
(((FAR char *)(hdr)) + NLMSG_ALIGN((hdr)->nlmsg_len)))
|
||||
#define NLMSG_OK(nlh, len) \
|
||||
((len) >= (int)sizeof(struct nlmsghdr) && \
|
||||
(nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
|
||||
(nlh)->nlmsg_len <= (len))
|
||||
#define NLMSG_PAYLOAD(hdr, len) \
|
||||
((hdr)->nlmsg_len - NLMSG_SPACE((len)))
|
||||
((hdr)->nlmsg_len - NLMSG_SPACE(len))
|
||||
|
||||
#define NLMSG_NOOP 1 /* Nothing */
|
||||
#define NLMSG_ERROR 2 /* Error */
|
||||
@ -154,14 +157,14 @@
|
||||
|
||||
#define RTA_MASK (sizeof(uint32_t) - 1)
|
||||
#define RTA_ALIGN(n) (((n) + RTA_MASK) & ~RTA_MASK)
|
||||
#define RTA_OK(rta,n) \
|
||||
#define RTA_OK(rta, n) \
|
||||
((n) >= (int)sizeof(struct rtattr) && \
|
||||
(rta)->rta_len >= sizeof(struct rtattr) && \
|
||||
(rta)->rta_len <= (n))
|
||||
#define RTA_NEXT(rta, attrlen) \
|
||||
((attrlen) -= RTA_ALIGN((rta)->rta_len), \
|
||||
(FAR struct rtattr*)(((FAR char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
|
||||
#define RTA_LENGTH(n) (RTA_ALIGN(sizeof(struct rtattr)) + (n))
|
||||
(FAR struct rtattr *)(((FAR char *)(rta)) + RTA_ALIGN((rta)->rta_len)))
|
||||
#define RTA_LENGTH(n) (sizeof(struct rtattr) + (n))
|
||||
#define RTA_SPACE(n) RTA_ALIGN(RTA_LENGTH(n))
|
||||
#define RTA_DATA(rta) ((FAR void *)(((FAR char *)(rta)) + RTA_LENGTH(0)))
|
||||
#define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
|
||||
@ -173,8 +176,8 @@
|
||||
#define RTA_SRC 2 /* Argument: Route source address */
|
||||
#define RTA_IIF 3 /* Argument: Input interface index */
|
||||
#define RTA_OIF 4 /* Argument: Output interface index */
|
||||
#define RTA_GENMASK 5 /* Argument: Network address mask of sub-net */
|
||||
#define RTA_GATEWAY 6 /* Argument: Gateway address of the route */
|
||||
#define RTA_GATEWAY 5 /* Argument: Gateway address of the route */
|
||||
#define RTA_GENMASK 6 /* Argument: Network address mask of sub-net */
|
||||
|
||||
/* NETLINK_ROUTE protocol message types *************************************/
|
||||
|
||||
@ -186,10 +189,10 @@
|
||||
* of rtattr structures.
|
||||
*/
|
||||
|
||||
#define RTM_NEWLINK 0
|
||||
#define RTM_DELLINK 1
|
||||
#define RTM_GETLINK 2
|
||||
#define RTM_SETLINK 3
|
||||
#define RTM_NEWLINK 16
|
||||
#define RTM_DELLINK 17
|
||||
#define RTM_GETLINK 18
|
||||
#define RTM_SETLINK 19
|
||||
|
||||
/* Address settings:
|
||||
*
|
||||
@ -199,9 +202,9 @@
|
||||
* followed by rtattr routing attributes.
|
||||
*/
|
||||
|
||||
#define RTM_NEWADDR 4
|
||||
#define RTM_DELADDR 5
|
||||
#define RTM_GETADDR 6
|
||||
#define RTM_NEWADDR 20
|
||||
#define RTM_DELADDR 21
|
||||
#define RTM_GETADDR 22
|
||||
|
||||
/* Routing tables:
|
||||
*
|
||||
@ -215,9 +218,9 @@
|
||||
* except rtm_table and rtm_protocol, 0 is the wildcard.
|
||||
*/
|
||||
|
||||
#define RTM_NEWROUTE 7
|
||||
#define RTM_DELROUTE 8
|
||||
#define RTM_GETROUTE 9
|
||||
#define RTM_NEWROUTE 24
|
||||
#define RTM_DELROUTE 25
|
||||
#define RTM_GETROUTE 26
|
||||
|
||||
/* Neighbor cache:
|
||||
*
|
||||
@ -226,9 +229,9 @@
|
||||
* an ARP entry). The message contains an ndmsg structure.
|
||||
*/
|
||||
|
||||
#define RTM_NEWNEIGH 10
|
||||
#define RTM_DELNEIGH 11
|
||||
#define RTM_GETNEIGH 12
|
||||
#define RTM_NEWNEIGH 28
|
||||
#define RTM_DELNEIGH 29
|
||||
#define RTM_GETNEIGH 30
|
||||
|
||||
/* Routing rules:
|
||||
*
|
||||
@ -236,9 +239,9 @@
|
||||
* Add, delete or retrieve a routing rule. Carries a struct rtmsg
|
||||
*/
|
||||
|
||||
#define RTM_NEWRULE 13
|
||||
#define RTM_DELRULE 14
|
||||
#define RTM_GETRULE 15
|
||||
#define RTM_NEWRULE 32
|
||||
#define RTM_DELRULE 33
|
||||
#define RTM_GETRULE 34
|
||||
|
||||
/* Queuing discipline settings:
|
||||
*
|
||||
@ -247,9 +250,9 @@
|
||||
* struct tcmsg and may be followed by a series of attributes.
|
||||
*/
|
||||
|
||||
#define RTM_NEWQDISC 16
|
||||
#define RTM_DELQDISC 17
|
||||
#define RTM_GETQDISC 18
|
||||
#define RTM_NEWQDISC 36
|
||||
#define RTM_DELQDISC 37
|
||||
#define RTM_GETQDISC 38
|
||||
|
||||
/* Traffic classes used with queues:
|
||||
*
|
||||
@ -258,9 +261,9 @@
|
||||
* tcmsg as described above.
|
||||
*/
|
||||
|
||||
#define RTM_NEWTCLASS 19
|
||||
#define RTM_DELTCLASS 20
|
||||
#define RTM_GETTCLASS 21
|
||||
#define RTM_NEWTCLASS 40
|
||||
#define RTM_DELTCLASS 41
|
||||
#define RTM_GETTCLASS 42
|
||||
|
||||
/* Traffic filters:
|
||||
*
|
||||
@ -269,35 +272,39 @@
|
||||
* messages contain a struct tcmsg as described above.
|
||||
*/
|
||||
|
||||
#define RTM_NEWTFILTER 22
|
||||
#define RTM_DELTFILTER 23
|
||||
#define RTM_GETTFILTER 24
|
||||
#define RTM_NEWTFILTER 44
|
||||
#define RTM_DELTFILTER 45
|
||||
#define RTM_GETTFILTER 46
|
||||
|
||||
/* Others: */
|
||||
|
||||
#define RTM_NEWACTION 25
|
||||
#define RTM_DELACTION 26
|
||||
#define RTM_GETACTION 27
|
||||
#define RTM_NEWPREFIX 28
|
||||
#define RTM_GETPREFIX 29
|
||||
#define RTM_GETMULTICAST 30
|
||||
#define RTM_GETANYCAST 31
|
||||
#define RTM_NEWNEIGHTBL 32
|
||||
#define RTM_GETNEIGHTBL 33
|
||||
#define RTM_SETNEIGHTBL 34
|
||||
#define RTM_NEWACTION 48
|
||||
#define RTM_DELACTION 49
|
||||
#define RTM_GETACTION 50
|
||||
#define RTM_NEWPREFIX 52
|
||||
#define RTM_GETMULTICAST 58
|
||||
#define RTM_GETANYCAST 62
|
||||
#define RTM_NEWNEIGHTBL 64
|
||||
#define RTM_GETNEIGHTBL 66
|
||||
#define RTM_SETNEIGHTBL 67
|
||||
|
||||
#define RTM_FIRSTMSG 0
|
||||
#define RTM_LASTMSG 34
|
||||
#define RTM_BASE 16
|
||||
#define RTM_MAX 67
|
||||
|
||||
/* Definitions for struct ifaddrmsg ****************************************/
|
||||
|
||||
#define IFA_RTA(r) ((FAR struct rtattr *) \
|
||||
(((FAR char *)(r)) + \
|
||||
NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
|
||||
#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct ifaddrmsg))
|
||||
|
||||
/* ifa_flags definitions: ifa_flags is a flag word of IFA_F_SECONDARY for
|
||||
* secondary address (old alias interface), IFA_F_PERMANENT for a permanent
|
||||
* address set by the user and other undocumented flags.
|
||||
*/
|
||||
|
||||
#define IFA_F_SECONDARY 0x01
|
||||
#define IFA_F_PERMANENT 0x02
|
||||
#define IFA_F_PERMANENT 0x80
|
||||
|
||||
/* Definitions for struct ifinfomsg *****************************************/
|
||||
|
||||
@ -342,8 +349,8 @@
|
||||
#define RTPROT_KERNEL 2 /* Route installed by kernel */
|
||||
#define RTPROT_BOOT 3 /* Route installed during boot */
|
||||
#define RTPROT_STATIC 4 /* Route installed by administrator */
|
||||
#define RTPROT_RA 5 /* RDISC/ND router advertisements */
|
||||
#define RTPROT_DHCP 6 /* DHCP client */
|
||||
#define RTPROT_RA 9 /* RDISC/ND router advertisements */
|
||||
#define RTPROT_DHCP 16 /* DHCP client */
|
||||
|
||||
/* rtm_scope */
|
||||
|
||||
@ -407,9 +414,9 @@ struct rtattr
|
||||
struct ifinfomsg
|
||||
{
|
||||
uint8_t ifi_family; /* AF_UNSPEC */
|
||||
uint8_t ifi_pid;
|
||||
uint8_t ifi_pad;
|
||||
uint16_t ifi_type; /* Device type (ARPHRD) */
|
||||
int16_t ifi_index; /* Unique interface index */
|
||||
int32_t ifi_index; /* Unique interface index */
|
||||
uint32_t ifi_flags; /* Device IFF_* flags */
|
||||
uint32_t ifi_change; /* Change mask, must always be 0xffffffff */
|
||||
};
|
||||
@ -434,7 +441,7 @@ struct ifaddrmsg
|
||||
uint8_t ifa_prefixlen; /* Prefix length of address */
|
||||
uint8_t ifa_flags; /* Address flags. See IFA_F_* definitions */
|
||||
uint8_t ifa_scope; /* Address scope */
|
||||
int16_t ifa_index; /* Unique interface index */
|
||||
int32_t ifa_index; /* Unique interface index */
|
||||
};
|
||||
|
||||
/* RTM_NEWNEIGH, RTM_DELNEIGH, RTM_GETNEIGH
|
||||
|
@ -77,7 +77,7 @@ struct netlink_response_s
|
||||
/* Message-specific data may follow */
|
||||
};
|
||||
|
||||
#define SIZEOF_NETLINK_RESPONSE_S(n) (sizeof(struct netlink_response_s) + (n) - 1)
|
||||
#define SIZEOF_NETLINK_RESPONSE_S(n) (sizeof(struct netlink_response_s) + (n))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
|
@ -79,20 +79,6 @@
|
||||
# define CONFIG_NETLINK_DISABLE_GETROUTE 1
|
||||
#endif
|
||||
|
||||
#undef NETLINK_DISABLE_NLMSGDONE
|
||||
#if defined(CONFIG_NETLINK_DISABLE_GETLINK) && \
|
||||
defined(CONFIG_NETLINK_DISABLE_GETROUTE)
|
||||
# define NETLINK_DISABLE_NLMSGDONE 1
|
||||
#endif
|
||||
|
||||
/* Helpers ******************************************************************/
|
||||
|
||||
#define IFA_RTA(r) \
|
||||
((FAR struct rtattr *)(((FAR char *)(r)) + \
|
||||
NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
|
||||
#define IFA_PAYLOAD(n) \
|
||||
NLMSG_PAYLOAD(n, sizeof(struct ifaddrmsg))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -416,7 +402,7 @@ static int netlink_device_callback(FAR struct net_driver_s *dev,
|
||||
resp->hdr.nlmsg_pid = devinfo->req->hdr.nlmsg_pid;
|
||||
|
||||
resp->iface.ifi_family = devinfo->req->gen.rtgen_family;
|
||||
resp->iface.ifi_pid = devinfo->req->hdr.nlmsg_pid;
|
||||
resp->iface.ifi_pad = 0;
|
||||
resp->iface.ifi_type = devinfo->req->hdr.nlmsg_type;
|
||||
#ifdef CONFIG_NETDEV_IFINDEX
|
||||
resp->iface.ifi_index = dev->d_ifindex;
|
||||
|
Loading…
x
Reference in New Issue
Block a user