diff options
author | netblue30 <netblue30@yahoo.com> | 2015-08-08 19:12:30 -0400 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2015-08-08 19:12:30 -0400 |
commit | 1379851360349d6617ad32944a25ee5e2bb74fc2 (patch) | |
tree | f69b48e90708bfa3c2723d5a27ed3e024c827b43 /src/include/libnetlink.h | |
parent | delete files (diff) | |
download | firejail-1379851360349d6617ad32944a25ee5e2bb74fc2.tar.gz firejail-1379851360349d6617ad32944a25ee5e2bb74fc2.tar.zst firejail-1379851360349d6617ad32944a25ee5e2bb74fc2.zip |
Baseline firejail 0.9.28
Diffstat (limited to 'src/include/libnetlink.h')
-rw-r--r-- | src/include/libnetlink.h | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/src/include/libnetlink.h b/src/include/libnetlink.h new file mode 100644 index 000000000..e9cd6b186 --- /dev/null +++ b/src/include/libnetlink.h | |||
@@ -0,0 +1,163 @@ | |||
1 | /* file extracted from iproute2 software package | ||
2 | * | ||
3 | * Original source code: | ||
4 | * | ||
5 | * Information: | ||
6 | * http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2 | ||
7 | * | ||
8 | * Download: | ||
9 | * http://www.kernel.org/pub/linux/utils/net/iproute2/ | ||
10 | * | ||
11 | * Repository: | ||
12 | * git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git | ||
13 | * | ||
14 | * License: GPL v2 | ||
15 | */ | ||
16 | |||
17 | |||
18 | #ifndef __LIBNETLINK_H__ | ||
19 | #define __LIBNETLINK_H__ 1 | ||
20 | |||
21 | #define _GNU_SOURCE | ||
22 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <stdint.h> | ||
25 | #include <string.h> | ||
26 | #include <asm/types.h> | ||
27 | #include <linux/netlink.h> | ||
28 | #include <linux/rtnetlink.h> | ||
29 | #include <linux/if_link.h> | ||
30 | #include <linux/if_addr.h> | ||
31 | #include <linux/neighbour.h> | ||
32 | |||
33 | struct rtnl_handle | ||
34 | { | ||
35 | int fd; | ||
36 | struct sockaddr_nl local; | ||
37 | struct sockaddr_nl peer; | ||
38 | __u32 seq; | ||
39 | __u32 dump; | ||
40 | }; | ||
41 | |||
42 | extern int rcvbuf; | ||
43 | |||
44 | extern int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions); | ||
45 | extern int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, int protocol); | ||
46 | extern void rtnl_close(struct rtnl_handle *rth); | ||
47 | extern int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type); | ||
48 | extern int rtnl_wilddump_req_filter(struct rtnl_handle *rth, int fam, int type, | ||
49 | __u32 filt_mask); | ||
50 | extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len); | ||
51 | |||
52 | typedef int (*rtnl_filter_t)(const struct sockaddr_nl *, | ||
53 | struct nlmsghdr *n, void *); | ||
54 | |||
55 | struct rtnl_dump_filter_arg | ||
56 | { | ||
57 | rtnl_filter_t filter; | ||
58 | void *arg1; | ||
59 | }; | ||
60 | |||
61 | extern int rtnl_dump_filter_l(struct rtnl_handle *rth, | ||
62 | const struct rtnl_dump_filter_arg *arg); | ||
63 | extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter, | ||
64 | void *arg); | ||
65 | extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, | ||
66 | unsigned groups, struct nlmsghdr *answer); | ||
67 | extern int rtnl_send(struct rtnl_handle *rth, const void *buf, int); | ||
68 | extern int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int); | ||
69 | |||
70 | extern int addattr(struct nlmsghdr *n, int maxlen, int type); | ||
71 | extern int addattr8(struct nlmsghdr *n, int maxlen, int type, __u8 data); | ||
72 | extern int addattr16(struct nlmsghdr *n, int maxlen, int type, __u16 data); | ||
73 | extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data); | ||
74 | extern int addattr64(struct nlmsghdr *n, int maxlen, int type, __u64 data); | ||
75 | extern int addattrstrz(struct nlmsghdr *n, int maxlen, int type, const char *data); | ||
76 | |||
77 | extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen); | ||
78 | extern int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len); | ||
79 | extern struct rtattr *addattr_nest(struct nlmsghdr *n, int maxlen, int type); | ||
80 | extern int addattr_nest_end(struct nlmsghdr *n, struct rtattr *nest); | ||
81 | extern struct rtattr *addattr_nest_compat(struct nlmsghdr *n, int maxlen, int type, const void *data, int len); | ||
82 | extern int addattr_nest_compat_end(struct nlmsghdr *n, struct rtattr *nest); | ||
83 | extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data); | ||
84 | extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, const void *data, int alen); | ||
85 | |||
86 | extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len); | ||
87 | extern int parse_rtattr_flags(struct rtattr *tb[], int max, struct rtattr *rta, | ||
88 | int len, unsigned short flags); | ||
89 | extern int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int len); | ||
90 | extern int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rtattr *rta, int len); | ||
91 | |||
92 | #define parse_rtattr_nested(tb, max, rta) \ | ||
93 | (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta))) | ||
94 | |||
95 | #define parse_rtattr_nested_compat(tb, max, rta, data, len) \ | ||
96 | ({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \ | ||
97 | __parse_rtattr_nested_compat(tb, max, rta, len); }) | ||
98 | |||
99 | static inline __u8 rta_getattr_u8(const struct rtattr *rta) | ||
100 | { | ||
101 | return *(__u8 *)RTA_DATA(rta); | ||
102 | } | ||
103 | static inline __u16 rta_getattr_u16(const struct rtattr *rta) | ||
104 | { | ||
105 | return *(__u16 *)RTA_DATA(rta); | ||
106 | } | ||
107 | static inline __u32 rta_getattr_u32(const struct rtattr *rta) | ||
108 | { | ||
109 | return *(__u32 *)RTA_DATA(rta); | ||
110 | } | ||
111 | static inline __u64 rta_getattr_u64(const struct rtattr *rta) | ||
112 | { | ||
113 | __u64 tmp; | ||
114 | memcpy(&tmp, RTA_DATA(rta), sizeof(__u64)); | ||
115 | return tmp; | ||
116 | } | ||
117 | static inline const char *rta_getattr_str(const struct rtattr *rta) | ||
118 | { | ||
119 | return (const char *)RTA_DATA(rta); | ||
120 | } | ||
121 | |||
122 | extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler, | ||
123 | void *jarg); | ||
124 | extern int rtnl_from_file(FILE *, rtnl_filter_t handler, | ||
125 | void *jarg); | ||
126 | |||
127 | #define NLMSG_TAIL(nmsg) \ | ||
128 | ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) | ||
129 | |||
130 | #ifndef IFA_RTA | ||
131 | #define IFA_RTA(r) \ | ||
132 | ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) | ||
133 | #endif | ||
134 | #ifndef IFA_PAYLOAD | ||
135 | #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg)) | ||
136 | #endif | ||
137 | |||
138 | #ifndef IFLA_RTA | ||
139 | #define IFLA_RTA(r) \ | ||
140 | ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) | ||
141 | #endif | ||
142 | #ifndef IFLA_PAYLOAD | ||
143 | #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) | ||
144 | #endif | ||
145 | |||
146 | #ifndef NDA_RTA | ||
147 | #define NDA_RTA(r) \ | ||
148 | ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) | ||
149 | #endif | ||
150 | #ifndef NDA_PAYLOAD | ||
151 | #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg)) | ||
152 | #endif | ||
153 | |||
154 | #ifndef NDTA_RTA | ||
155 | #define NDTA_RTA(r) \ | ||
156 | ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndtmsg)))) | ||
157 | #endif | ||
158 | #ifndef NDTA_PAYLOAD | ||
159 | #define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg)) | ||
160 | #endif | ||
161 | |||
162 | #endif /* __LIBNETLINK_H__ */ | ||
163 | |||