5 #define NETLINK_ROUTE 0
15 #define NLM_F_REQUEST 1
19 #define NLM_F_ROOT 0x100
20 #define NLM_F_MATCH 0x200
21 #define NLM_F_ATOMIC 0x400
22 #define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
24 #define NLMSG_NOOP 0x1
25 #define NLMSG_ERROR 0x2
26 #define NLMSG_DONE 0x3
27 #define NLMSG_OVERRUN 0x4
29 /* linux/rtnetlink.h */
31 #define RTM_NEWLINK 16
32 #define RTM_GETLINK 18
33 #define RTM_NEWADDR 20
34 #define RTM_GETADDR 22
37 unsigned short rta_len
;
38 unsigned short rta_type
;
42 unsigned char rtgen_family
;
46 unsigned char ifi_family
;
47 unsigned char __ifi_pad
;
48 unsigned short ifi_type
;
56 #define IFLA_ADDRESS 1
57 #define IFLA_BROADCAST 2
65 uint8_t ifa_prefixlen
;
74 #define IFA_BROADCAST 4
78 #define NETLINK_ALIGN(len) (((len)+3) & ~3)
79 #define NLMSG_DATA(nlh) ((void*)((char*)(nlh)+sizeof(struct nlmsghdr)))
80 #define NLMSG_DATALEN(nlh) ((nlh)->nlmsg_len-sizeof(struct nlmsghdr))
81 #define NLMSG_DATAEND(nlh) ((char*)(nlh)+(nlh)->nlmsg_len)
82 #define NLMSG_NEXT(nlh) (struct nlmsghdr*)((char*)(nlh)+NETLINK_ALIGN((nlh)->nlmsg_len))
83 #define NLMSG_OK(nlh,end) ((char*)(end)-(char*)(nlh) >= sizeof(struct nlmsghdr))
85 #define RTA_DATA(rta) ((void*)((char*)(rta)+sizeof(struct rtattr)))
86 #define RTA_DATALEN(rta) ((rta)->rta_len-sizeof(struct rtattr))
87 #define RTA_DATAEND(rta) ((char*)(rta)+(rta)->rta_len)
88 #define RTA_NEXT(rta) (struct rtattr*)((char*)(rta)+NETLINK_ALIGN((rta)->rta_len))
89 #define RTA_OK(nlh,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr))
91 #define NLMSG_RTA(nlh,len) ((void*)((char*)(nlh)+sizeof(struct nlmsghdr)+NETLINK_ALIGN(len)))
92 #define NLMSG_RTAOK(rta,nlh) RTA_OK(rta,NLMSG_DATAEND(nlh))
94 hidden
int __rtnetlink_enumerate(int link_af
, int addr_af
, int (*cb
)(void *ctx
, struct nlmsghdr
*h
), void *ctx
);