lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 18.09-beta 499 lines 17 kB view raw
1From patchwork Fri Apr 3 22:04:46 2015 2Content-Type: text/plain; charset="utf-8" 3MIME-Version: 1.0 4Content-Transfer-Encoding: 7bit 5Subject: Use stdlib uint* instead of u_int* 6From: Nathan McSween <nwmcsween@gmail.com> 7X-Patchwork-Id: 458131 8X-Patchwork-Delegate: pablo@netfilter.org 9Message-Id: <1428098686-17843-1-git-send-email-nwmcsween@gmail.com> 10To: netfilter-devel@vger.kernel.org 11Cc: Nathan McSween <nwmcsween@gmail.com> 12Date: Fri, 3 Apr 2015 22:04:46 +0000 13 14Signed-off-by: Nathan McSween <nwmcsween@gmail.com> 15--- 16 include/libnfnetlink/libnfnetlink.h | 25 +++++----- 17 include/libnfnetlink/linux_nfnetlink.h | 11 +++-- 18 include/libnfnetlink/linux_nfnetlink_compat.h | 6 ++- 19 src/iftable.c | 9 ++-- 20 src/iftable.h | 6 ++- 21 src/libnfnetlink.c | 71 ++++++++++++++------------- 22 src/rtnl.c | 5 +- 23 src/rtnl.h | 3 +- 24 8 files changed, 73 insertions(+), 63 deletions(-) 25 26diff --git a/include/libnfnetlink/libnfnetlink.h b/include/libnfnetlink/libnfnetlink.h 27index 1d8c49d..cd0be3d 100644 28--- a/include/libnfnetlink/libnfnetlink.h 29+++ b/include/libnfnetlink/libnfnetlink.h 30@@ -15,6 +15,7 @@ 31 #define aligned_u64 unsigned long long __attribute__((aligned(8))) 32 #endif 33 34+#include <stdint.h> 35 #include <sys/socket.h> /* for sa_family_t */ 36 #include <linux/netlink.h> 37 #include <libnfnetlink/linux_nfnetlink.h> 38@@ -55,7 +56,7 @@ struct nfnlhdr { 39 struct nfnl_callback { 40 int (*call)(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data); 41 void *data; 42- u_int16_t attr_count; 43+ uint16_t attr_count; 44 }; 45 46 struct nfnl_handle; 47@@ -69,7 +70,7 @@ extern struct nfnl_handle *nfnl_open(void); 48 extern int nfnl_close(struct nfnl_handle *); 49 50 extern struct nfnl_subsys_handle *nfnl_subsys_open(struct nfnl_handle *, 51- u_int8_t, u_int8_t, 52+ uint8_t, uint8_t, 53 unsigned int); 54 extern void nfnl_subsys_close(struct nfnl_subsys_handle *); 55 56@@ -88,8 +89,8 @@ extern int nfnl_sendiov(const struct nfnl_handle *nfnlh, 57 const struct iovec *iov, unsigned int num, 58 unsigned int flags); 59 extern void nfnl_fill_hdr(struct nfnl_subsys_handle *, struct nlmsghdr *, 60- unsigned int, u_int8_t, u_int16_t, u_int16_t, 61- u_int16_t); 62+ unsigned int, uint8_t, uint16_t, uint16_t, 63+ uint16_t); 64 extern __attribute__((deprecated)) int 65 nfnl_talk(struct nfnl_handle *, struct nlmsghdr *, pid_t, 66 unsigned, struct nlmsghdr *, 67@@ -103,8 +104,8 @@ nfnl_listen(struct nfnl_handle *, 68 /* receiving */ 69 extern ssize_t nfnl_recv(const struct nfnl_handle *h, unsigned char *buf, size_t len); 70 extern int nfnl_callback_register(struct nfnl_subsys_handle *, 71- u_int8_t type, struct nfnl_callback *cb); 72-extern int nfnl_callback_unregister(struct nfnl_subsys_handle *, u_int8_t type); 73+ uint8_t type, struct nfnl_callback *cb); 74+extern int nfnl_callback_unregister(struct nfnl_subsys_handle *, uint8_t type); 75 extern int nfnl_handle_packet(struct nfnl_handle *, char *buf, int len); 76 77 /* parsing */ 78@@ -180,12 +181,12 @@ extern int nfnl_query(struct nfnl_handle *h, struct nlmsghdr *nlh); 79 80 /* nfnl attribute handling functions */ 81 extern int nfnl_addattr_l(struct nlmsghdr *, int, int, const void *, int); 82-extern int nfnl_addattr8(struct nlmsghdr *, int, int, u_int8_t); 83-extern int nfnl_addattr16(struct nlmsghdr *, int, int, u_int16_t); 84-extern int nfnl_addattr32(struct nlmsghdr *, int, int, u_int32_t); 85+extern int nfnl_addattr8(struct nlmsghdr *, int, int, uint8_t); 86+extern int nfnl_addattr16(struct nlmsghdr *, int, int, uint16_t); 87+extern int nfnl_addattr32(struct nlmsghdr *, int, int, uint32_t); 88 extern int nfnl_nfa_addattr_l(struct nfattr *, int, int, const void *, int); 89-extern int nfnl_nfa_addattr16(struct nfattr *, int, int, u_int16_t); 90-extern int nfnl_nfa_addattr32(struct nfattr *, int, int, u_int32_t); 91+extern int nfnl_nfa_addattr16(struct nfattr *, int, int, uint16_t); 92+extern int nfnl_nfa_addattr32(struct nfattr *, int, int, uint32_t); 93 extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int); 94 #define nfnl_parse_nested(tb, max, nfa) \ 95 nfnl_parse_attr((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa))) 96@@ -197,7 +198,7 @@ extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int); 97 ({ (tail)->nfa_len = (void *) NLMSG_TAIL(nlh) - (void *) tail; }) 98 99 extern void nfnl_build_nfa_iovec(struct iovec *iov, struct nfattr *nfa, 100- u_int16_t type, u_int32_t len, 101+ uint16_t type, uint32_t len, 102 unsigned char *val); 103 extern unsigned int nfnl_rcvbufsiz(const struct nfnl_handle *h, 104 unsigned int size); 105diff --git a/include/libnfnetlink/linux_nfnetlink.h b/include/libnfnetlink/linux_nfnetlink.h 106index 76a8550..7b843c6 100644 107--- a/include/libnfnetlink/linux_nfnetlink.h 108+++ b/include/libnfnetlink/linux_nfnetlink.h 109@@ -1,5 +1,6 @@ 110 #ifndef _NFNETLINK_H 111 #define _NFNETLINK_H 112+#include <stdint.h> 113 #include <linux/types.h> 114 #include <libnfnetlink/linux_nfnetlink_compat.h> 115 116@@ -25,9 +26,9 @@ enum nfnetlink_groups { 117 /* General form of address family dependent message. 118 */ 119 struct nfgenmsg { 120- u_int8_t nfgen_family; /* AF_xxx */ 121- u_int8_t version; /* nfnetlink version */ 122- u_int16_t res_id; /* resource id */ 123+ uint8_t nfgen_family; /* AF_xxx */ 124+ uint8_t version; /* nfnetlink version */ 125+ uint16_t res_id; /* resource id */ 126 }; 127 128 #define NFNETLINK_V0 0 129@@ -59,7 +60,7 @@ struct nfnl_callback 130 int (*call)(struct sock *nl, struct sk_buff *skb, 131 struct nlmsghdr *nlh, struct nlattr *cda[]); 132 const struct nla_policy *policy; /* netlink attribute policy */ 133- const u_int16_t attr_count; /* number of nlattr's */ 134+ const uint16_t attr_count; /* number of nlattr's */ 135 }; 136 137 struct nfnetlink_subsystem 138@@ -76,7 +77,7 @@ extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n); 139 extern int nfnetlink_has_listeners(unsigned int group); 140 extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, 141 int echo); 142-extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags); 143+extern int nfnetlink_unicast(struct sk_buff *skb, uint32_t pid, int flags); 144 145 #define MODULE_ALIAS_NFNL_SUBSYS(subsys) \ 146 MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys)) 147diff --git a/include/libnfnetlink/linux_nfnetlink_compat.h b/include/libnfnetlink/linux_nfnetlink_compat.h 148index e145176..cd094fc 100644 149--- a/include/libnfnetlink/linux_nfnetlink_compat.h 150+++ b/include/libnfnetlink/linux_nfnetlink_compat.h 151@@ -3,6 +3,8 @@ 152 #ifndef __KERNEL__ 153 /* Old nfnetlink macros for userspace */ 154 155+#include <stdint.h> 156+ 157 /* nfnetlink groups: Up to 32 maximum */ 158 #define NF_NETLINK_CONNTRACK_NEW 0x00000001 159 #define NF_NETLINK_CONNTRACK_UPDATE 0x00000002 160@@ -20,8 +22,8 @@ 161 162 struct nfattr 163 { 164- u_int16_t nfa_len; 165- u_int16_t nfa_type; /* we use 15 bits for the type, and the highest 166+ uint16_t nfa_len; 167+ uint16_t nfa_type; /* we use 15 bits for the type, and the highest 168 * bit to indicate whether the payload is nested */ 169 }; 170 171diff --git a/src/iftable.c b/src/iftable.c 172index 5976ed8..3411c4c 100644 173--- a/src/iftable.c 174+++ b/src/iftable.c 175@@ -9,6 +9,7 @@ 176 /* IFINDEX handling */ 177 178 #include <unistd.h> 179+#include <stdint.h> 180 #include <stdlib.h> 181 #include <stdio.h> 182 #include <string.h> 183@@ -27,10 +28,10 @@ 184 struct ifindex_node { 185 struct list_head head; 186 187- u_int32_t index; 188- u_int32_t type; 189- u_int32_t alen; 190- u_int32_t flags; 191+ uint32_t index; 192+ uint32_t type; 193+ uint32_t alen; 194+ uint32_t flags; 195 char addr[8]; 196 char name[16]; 197 }; 198diff --git a/src/iftable.h b/src/iftable.h 199index 8df7f24..0cc5335 100644 200--- a/src/iftable.h 201+++ b/src/iftable.h 202@@ -1,8 +1,10 @@ 203 #ifndef _IFTABLE_H 204 #define _IFTABLE_H 205 206-int iftable_delete(u_int32_t dst, u_int32_t mask, u_int32_t gw, u_int32_t oif); 207-int iftable_insert(u_int32_t dst, u_int32_t mask, u_int32_t gw, u_int32_t oif); 208+#include <stdint.h> 209+ 210+int iftable_delete(uint32_t dst, uint32_t mask, uint32_t gw, uint32_t oif); 211+int iftable_insert(uint32_t dst, uint32_t mask, uint32_t gw, uint32_t oif); 212 213 int iftable_init(void); 214 void iftable_fini(void); 215diff --git a/src/libnfnetlink.c b/src/libnfnetlink.c 216index 398b7d7..b8958dc 100644 217--- a/src/libnfnetlink.c 218+++ b/src/libnfnetlink.c 219@@ -36,6 +36,7 @@ 220 * minor cleanups 221 */ 222 223+#include <stdint.h> 224 #include <stdlib.h> 225 #include <stdio.h> 226 #include <unistd.h> 227@@ -72,9 +73,9 @@ 228 229 struct nfnl_subsys_handle { 230 struct nfnl_handle *nfnlh; 231- u_int32_t subscriptions; 232- u_int8_t subsys_id; 233- u_int8_t cb_count; 234+ uint32_t subscriptions; 235+ uint8_t subsys_id; 236+ uint8_t cb_count; 237 struct nfnl_callback *cb; /* array of callbacks */ 238 }; 239 240@@ -86,11 +87,11 @@ struct nfnl_handle { 241 int fd; 242 struct sockaddr_nl local; 243 struct sockaddr_nl peer; 244- u_int32_t subscriptions; 245- u_int32_t seq; 246- u_int32_t dump; 247- u_int32_t rcv_buffer_size; /* for nfnl_catch */ 248- u_int32_t flags; 249+ uint32_t subscriptions; 250+ uint32_t seq; 251+ uint32_t dump; 252+ uint32_t rcv_buffer_size; /* for nfnl_catch */ 253+ uint32_t flags; 254 struct nlmsghdr *last_nlhdr; 255 struct nfnl_subsys_handle subsys[NFNL_MAX_SUBSYS+1]; 256 }; 257@@ -145,7 +146,7 @@ unsigned int nfnl_portid(const struct nfnl_handle *h) 258 static int recalc_rebind_subscriptions(struct nfnl_handle *nfnlh) 259 { 260 int i, err; 261- u_int32_t new_subscriptions = nfnlh->subscriptions; 262+ uint32_t new_subscriptions = nfnlh->subscriptions; 263 264 for (i = 0; i < NFNL_MAX_SUBSYS; i++) 265 new_subscriptions |= nfnlh->subsys[i].subscriptions; 266@@ -273,8 +274,8 @@ void nfnl_set_rcv_buffer_size(struct nfnl_handle *h, unsigned int size) 267 * a valid address that points to a nfnl_subsys_handle structure is returned. 268 */ 269 struct nfnl_subsys_handle * 270-nfnl_subsys_open(struct nfnl_handle *nfnlh, u_int8_t subsys_id, 271- u_int8_t cb_count, u_int32_t subscriptions) 272+nfnl_subsys_open(struct nfnl_handle *nfnlh, uint8_t subsys_id, 273+ uint8_t cb_count, uint32_t subscriptions) 274 { 275 struct nfnl_subsys_handle *ssh; 276 277@@ -435,10 +436,10 @@ int nfnl_sendiov(const struct nfnl_handle *nfnlh, const struct iovec *iov, 278 */ 279 void nfnl_fill_hdr(struct nfnl_subsys_handle *ssh, 280 struct nlmsghdr *nlh, unsigned int len, 281- u_int8_t family, 282- u_int16_t res_id, 283- u_int16_t msg_type, 284- u_int16_t msg_flags) 285+ uint8_t family, 286+ uint16_t res_id, 287+ uint16_t msg_type, 288+ uint16_t msg_flags) 289 { 290 assert(ssh); 291 assert(nlh); 292@@ -849,14 +850,14 @@ int nfnl_nfa_addattr_l(struct nfattr *nfa, int maxlen, int type, 293 } 294 295 /** 296- * nfnl_addattr8 - Add u_int8_t attribute to nlmsghdr 297+ * nfnl_addattr8 - Add uint8_t attribute to nlmsghdr 298 * 299 * @n: netlink message header to which attribute is to be added 300 * @maxlen: maximum length of netlink message header 301 * @type: type of new attribute 302 * @data: content of new attribute 303 */ 304-int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, u_int8_t data) 305+int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, uint8_t data) 306 { 307 assert(n); 308 assert(maxlen > 0); 309@@ -866,7 +867,7 @@ int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, u_int8_t data) 310 } 311 312 /** 313- * nfnl_nfa_addattr16 - Add u_int16_t attribute to struct nfattr 314+ * nfnl_nfa_addattr16 - Add uint16_t attribute to struct nfattr 315 * 316 * @nfa: struct nfattr 317 * @maxlen: maximal length of nfattr buffer 318@@ -875,7 +876,7 @@ int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, u_int8_t data) 319 * 320 */ 321 int nfnl_nfa_addattr16(struct nfattr *nfa, int maxlen, int type, 322- u_int16_t data) 323+ uint16_t data) 324 { 325 assert(nfa); 326 assert(maxlen > 0); 327@@ -885,7 +886,7 @@ int nfnl_nfa_addattr16(struct nfattr *nfa, int maxlen, int type, 328 } 329 330 /** 331- * nfnl_addattr16 - Add u_int16_t attribute to nlmsghdr 332+ * nfnl_addattr16 - Add uint16_t attribute to nlmsghdr 333 * 334 * @n: netlink message header to which attribute is to be added 335 * @maxlen: maximum length of netlink message header 336@@ -894,7 +895,7 @@ int nfnl_nfa_addattr16(struct nfattr *nfa, int maxlen, int type, 337 * 338 */ 339 int nfnl_addattr16(struct nlmsghdr *n, int maxlen, int type, 340- u_int16_t data) 341+ uint16_t data) 342 { 343 assert(n); 344 assert(maxlen > 0); 345@@ -904,7 +905,7 @@ int nfnl_addattr16(struct nlmsghdr *n, int maxlen, int type, 346 } 347 348 /** 349- * nfnl_nfa_addattr32 - Add u_int32_t attribute to struct nfattr 350+ * nfnl_nfa_addattr32 - Add uint32_t attribute to struct nfattr 351 * 352 * @nfa: struct nfattr 353 * @maxlen: maximal length of nfattr buffer 354@@ -913,7 +914,7 @@ int nfnl_addattr16(struct nlmsghdr *n, int maxlen, int type, 355 * 356 */ 357 int nfnl_nfa_addattr32(struct nfattr *nfa, int maxlen, int type, 358- u_int32_t data) 359+ uint32_t data) 360 { 361 assert(nfa); 362 assert(maxlen > 0); 363@@ -923,7 +924,7 @@ int nfnl_nfa_addattr32(struct nfattr *nfa, int maxlen, int type, 364 } 365 366 /** 367- * nfnl_addattr32 - Add u_int32_t attribute to nlmsghdr 368+ * nfnl_addattr32 - Add uint32_t attribute to nlmsghdr 369 * 370 * @n: netlink message header to which attribute is to be added 371 * @maxlen: maximum length of netlink message header 372@@ -932,7 +933,7 @@ int nfnl_nfa_addattr32(struct nfattr *nfa, int maxlen, int type, 373 * 374 */ 375 int nfnl_addattr32(struct nlmsghdr *n, int maxlen, int type, 376- u_int32_t data) 377+ uint32_t data) 378 { 379 assert(n); 380 assert(maxlen > 0); 381@@ -980,7 +981,7 @@ int nfnl_parse_attr(struct nfattr *tb[], int max, struct nfattr *nfa, int len) 382 * 383 */ 384 void nfnl_build_nfa_iovec(struct iovec *iov, struct nfattr *nfa, 385- u_int16_t type, u_int32_t len, unsigned char *val) 386+ uint16_t type, uint32_t len, unsigned char *val) 387 { 388 assert(iov); 389 assert(nfa); 390@@ -1115,7 +1116,7 @@ struct nlmsghdr *nfnl_get_msg_next(struct nfnl_handle *h, 391 * appropiately. 392 */ 393 int nfnl_callback_register(struct nfnl_subsys_handle *ssh, 394- u_int8_t type, struct nfnl_callback *cb) 395+ uint8_t type, struct nfnl_callback *cb) 396 { 397 assert(ssh); 398 assert(cb); 399@@ -1138,7 +1139,7 @@ int nfnl_callback_register(struct nfnl_subsys_handle *ssh, 400 * On sucess, 0 is returned. On error, -1 is returned and errno is 401 * set appropiately. 402 */ 403-int nfnl_callback_unregister(struct nfnl_subsys_handle *ssh, u_int8_t type) 404+int nfnl_callback_unregister(struct nfnl_subsys_handle *ssh, uint8_t type) 405 { 406 assert(ssh); 407 408@@ -1161,8 +1162,8 @@ int nfnl_check_attributes(const struct nfnl_handle *h, 409 assert(nfa); 410 411 int min_len; 412- u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type); 413- u_int8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type); 414+ uint8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type); 415+ uint8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type); 416 const struct nfnl_subsys_handle *ssh; 417 struct nfnl_callback *cb; 418 419@@ -1212,8 +1213,8 @@ static int __nfnl_handle_msg(struct nfnl_handle *h, struct nlmsghdr *nlh, 420 int len) 421 { 422 struct nfnl_subsys_handle *ssh; 423- u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type); 424- u_int8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type); 425+ uint8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type); 426+ uint8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type); 427 int err = 0; 428 429 if (subsys_id > NFNL_MAX_SUBSYS) 430@@ -1243,7 +1244,7 @@ int nfnl_handle_packet(struct nfnl_handle *h, char *buf, int len) 431 { 432 433 while (len >= NLMSG_SPACE(0)) { 434- u_int32_t rlen; 435+ uint32_t rlen; 436 struct nlmsghdr *nlh = (struct nlmsghdr *)buf; 437 438 if (nlh->nlmsg_len < sizeof(struct nlmsghdr) 439@@ -1285,8 +1286,8 @@ static int nfnl_is_error(struct nfnl_handle *h, struct nlmsghdr *nlh) 440 static int nfnl_step(struct nfnl_handle *h, struct nlmsghdr *nlh) 441 { 442 struct nfnl_subsys_handle *ssh; 443- u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type); 444- u_int8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type); 445+ uint8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type); 446+ uint8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type); 447 448 /* Is this an error message? */ 449 if (nfnl_is_error(h, nlh)) { 450diff --git a/src/rtnl.c b/src/rtnl.c 451index 7b4ac7d..34802fe 100644 452--- a/src/rtnl.c 453+++ b/src/rtnl.c 454@@ -11,6 +11,7 @@ 455 /* rtnetlink - routing table netlink interface */ 456 457 #include <unistd.h> 458+#include <stdint.h> 459 #include <stdlib.h> 460 #include <string.h> 461 #include <errno.h> 462@@ -30,7 +31,7 @@ 463 #define rtnl_log(x, ...) 464 465 static inline struct rtnl_handler * 466-find_handler(struct rtnl_handle *rtnl_handle, u_int16_t type) 467+find_handler(struct rtnl_handle *rtnl_handle, uint16_t type) 468 { 469 struct rtnl_handler *h; 470 for (h = rtnl_handle->handlers; h; h = h->next) { 471@@ -41,7 +42,7 @@ find_handler(struct rtnl_handle *rtnl_handle, u_int16_t type) 472 } 473 474 static int call_handler(struct rtnl_handle *rtnl_handle, 475- u_int16_t type, 476+ uint16_t type, 477 struct nlmsghdr *hdr) 478 { 479 struct rtnl_handler *h = find_handler(rtnl_handle, type); 480diff --git a/src/rtnl.h b/src/rtnl.h 481index 0c403dc..9858ae5 100644 482--- a/src/rtnl.h 483+++ b/src/rtnl.h 484@@ -1,13 +1,14 @@ 485 #ifndef _RTNL_H 486 #define _RTNL_H 487 488+#include <stdint.h> 489 #include <linux/types.h> 490 #include <linux/rtnetlink.h> 491 492 struct rtnl_handler { 493 struct rtnl_handler *next; 494 495- u_int16_t nlmsg_type; 496+ uint16_t nlmsg_type; 497 int (*handlefn)(struct nlmsghdr *h, void *arg); 498 void *arg; 499 };