Use stdlib uint* instead of u_int*
PATCH 1/1 Use stdlib uint* instead of u_int*
Use stdint as u_int* is deprecated / non-standard, it is also not exposed on some libc's.
Nathan McSween (1):
Use stdlib uint* instead of u_int*
include/libnfnetlink/libnfnetlink.h | 25 +++++----- include/libnfnetlink/linux_nfnetlink.h | 11 +++-- include/libnfnetlink/linux_nfnetlink_compat.h | 6 ++- src/iftable.c | 9 ++-- src/iftable.h | 6 ++- src/libnfnetlink.c | 71 ++++++++++++++------------- src/rtnl.c | 5 +- src/rtnl.h | 3 +- 8 files changed, 73 insertions(+), 63 deletions(-)
Signature · 1 line
2.3.1
PATCH 1/1 Use stdlib uint* instead of u_int*
--- include/libnfnetlink/libnfnetlink.h | 25 +++++----- include/libnfnetlink/linux_nfnetlink.h | 11 +++-- include/libnfnetlink/linux_nfnetlink_compat.h | 6 ++- src/iftable.c | 9 ++-- src/iftable.h | 6 ++- src/libnfnetlink.c | 71 ++++++++++++++------------- src/rtnl.c | 5 +- src/rtnl.h | 3 +- 8 files changed, 73 insertions(+), 63 deletions(-)
include/libnfnetlink/libnfnetlink.h +13 -12
@@ -15,6 +15,7 @@#define aligned_u64 unsigned long long __attribute__((aligned(8)))#endif +#include <stdint.h> #include <sys/socket.h> /* for sa_family_t */ #include <linux/netlink.h> #include <libnfnetlink/linux_nfnetlink.h>
@@ -55,7 +56,7 @@ struct nfnlhdr {struct nfnl_callback {int (*call)(struct nlmsghdr *nlh,struct nfattr *nfa[],void *data);void *data; -u_int16_t attr_count; +uint16_t attr_count; };struct nfnl_handle ;
@@ -69,7 +70,7 @@ extern struct nfnl_handle *nfnl_open(void);extern int nfnl_close (struct nfnl_handle *);extern struct nfnl_subsys_handle *nfnl_subsys_open (struct nfnl_handle *, -u_int8_t ,u_int8_t , +uint8_t ,uint8_t ,unsigned int );extern void nfnl_subsys_close (struct nfnl_subsys_handle *);
@@ -88,8 +89,8 @@ extern int nfnl_sendiov(const struct nfnl_handle *nfnlh, const struct iovec *iov, unsigned int num, unsigned int flags);extern void nfnl_fill_hdr (struct nfnl_subsys_handle *,struct nlmsghdr *, -unsigned int ,u_int8_t ,u_int16_t ,u_int16_t , -u_int16_t ); +unsigned int ,uint8_t ,uint16_t ,uint16_t , +uint16_t ); extern __attribute__((deprecated)) int nfnl_talk(struct nfnl_handle *, struct nlmsghdr *, pid_t, unsigned, struct nlmsghdr *,
@@ -103,8 +104,8 @@ nfnl_listen(struct nfnl_handle *,/* receiving */ extern ssize_t nfnl_recv (const struct nfnl_handle *h,unsigned char *buf,size_t len);extern int nfnl_callback_register (struct nfnl_subsys_handle *, -u_int8_t type,struct nfnl_callback *cb); -extern int nfnl_callback_unregister (struct nfnl_subsys_handle *,u_int8_t type); +uint8_t type,struct nfnl_callback *cb); +extern int nfnl_callback_unregister (struct nfnl_subsys_handle *,uint8_t type);extern int nfnl_handle_packet (struct nfnl_handle *,char *buf,int len);/* parsing */
@@ -180,12 +181,12 @@ extern int nfnl_query(struct nfnl_handle *h, struct nlmsghdr *nlh);/* nfnl attribute handling functions */ extern int nfnl_addattr_l (struct nlmsghdr *,int ,int ,const void *,int ); -extern int nfnl_addattr8 (struct nlmsghdr *,int ,int ,u_int8_t ); -extern int nfnl_addattr16 (struct nlmsghdr *,int ,int ,u_int16_t ); -extern int nfnl_addattr32 (struct nlmsghdr *,int ,int ,u_int32_t ); +extern int nfnl_addattr8 (struct nlmsghdr *,int ,int ,uint8_t ); +extern int nfnl_addattr16 (struct nlmsghdr *,int ,int ,uint16_t ); +extern int nfnl_addattr32 (struct nlmsghdr *,int ,int ,uint32_t );extern int nfnl_nfa_addattr_l (struct nfattr *,int ,int ,const void *,int ); -extern int nfnl_nfa_addattr16 (struct nfattr *,int ,int ,u_int16_t ); -extern int nfnl_nfa_addattr32 (struct nfattr *,int ,int ,u_int32_t ); +extern int nfnl_nfa_addattr16 (struct nfattr *,int ,int ,uint16_t ); +extern int nfnl_nfa_addattr32 (struct nfattr *,int ,int ,uint32_t );extern int nfnl_parse_attr (struct nfattr **,int ,struct nfattr *,int );#define nfnl_parse_nested (tb, max, nfa) \ nfnl_parse_attr((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa)))
@@ -197,7 +198,7 @@ extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int); ({ (tail)->nfa_len = (void *) NLMSG_TAIL(nlh) - (void *) tail; })extern void nfnl_build_nfa_iovec (struct iovec *iov,struct nfattr *nfa, -u_int16_t type,u_int32_t len, +uint16_t type,uint32_t len,unsigned char *val);extern unsigned int nfnl_rcvbufsiz (const struct nfnl_handle *h,unsigned int size);
include/libnfnetlink/linux_nfnetlink.h +6 -5
@@ -1,5 +1,6 @@#ifndef _NFNETLINK_H#define _NFNETLINK_H +#include <stdint.h> #include <linux/types.h> #include <libnfnetlink/linux_nfnetlink_compat.h>
@@ -25,9 +26,9 @@ enum nfnetlink_groups {/* General form of address family dependent message. */ struct nfgenmsg { -u_int8_t nfgen_family;/* AF_xxx */ -u_int8_t version;/* nfnetlink version */ -u_int16_t res_id;/* resource id */ +uint8_t nfgen_family;/* AF_xxx */ +uint8_t version;/* nfnetlink version */ +uint16_t res_id;/* resource id */ };#define NFNETLINK_V0 0
@@ -59,7 +60,7 @@ struct nfnl_callbackint (*call)(struct sock *nl,struct sk_buff *skb,struct nlmsghdr *nlh,struct nlattr *cda[]);const struct nla_policy *policy;/* netlink attribute policy */ -const u_int16_t attr_count;/* number of nlattr's */ +const uint16_t attr_count;/* number of nlattr's */ };struct nfnetlink_subsystem
@@ -76,7 +77,7 @@ extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);extern int nfnetlink_has_listeners (unsigned int group);extern int nfnetlink_send (struct sk_buff *skb,u32 pid,unsigned group,int echo); -extern int nfnetlink_unicast (struct sk_buff *skb,u_int32_t pid,int flags); +extern int nfnetlink_unicast (struct sk_buff *skb,uint32_t pid,int flags);#define MODULE_ALIAS_NFNL_SUBSYS (subsys) \ MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys))
include/libnfnetlink/linux_nfnetlink_compat.h +4 -2
@@ -3,6 +3,8 @@#ifndef __KERNEL__/* Old nfnetlink macros for userspace */ +#include <stdint.h> +/* nfnetlink groups: Up to 32 maximum */ #define NF_NETLINK_CONNTRACK_NEW 0x00000001#define NF_NETLINK_CONNTRACK_UPDATE 0x00000002
@@ -20,8 +22,8 @@struct nfattr { -u_int16_t nfa_len; -u_int16_t nfa_type;/* we use 15 bits for the type, and the highest +uint16_t nfa_len; +uint16_t nfa_type;/* we use 15 bits for the type, and the highest * bit to indicate whether the payload is nested */ };
src/iftable.c +5 -4
@@ -9,6 +9,7 @@/* IFINDEX handling */ #include <unistd.h> +#include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <string.h>
@@ -27,10 +28,10 @@struct ifindex_node {struct list_head head; -u_int32_t index; -u_int32_t type; -u_int32_t alen; -u_int32_t flags; +uint32_t index; +uint32_t type; +uint32_t alen; +uint32_t flags;char addr[8 ];char name[16 ]; };
src/iftable.h +4 -2
@@ -1,8 +1,10 @@#ifndef _IFTABLE_H#define _IFTABLE_H -int iftable_delete (u_int32_t dst,u_int32_t mask,u_int32_t gw,u_int32_t oif); -int iftable_insert (u_int32_t dst,u_int32_t mask,u_int32_t gw,u_int32_t oif); +#include <stdint.h> + +int iftable_delete (uint32_t dst,uint32_t mask,uint32_t gw,uint32_t oif); +int iftable_insert (uint32_t dst,uint32_t mask,uint32_t gw,uint32_t oif);int iftable_init (void );void iftable_fini (void );
src/libnfnetlink.c +36 -35
209 lines not on this page · raw message
src/rtnl.c +3 -2
@@ -11,6 +11,7 @@/* rtnetlink - routing table netlink interface */ #include <unistd.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <errno.h>
@@ -30,7 +31,7 @@#define rtnl_log (x, ...)static inline struct rtnl_handler * -find_handler (struct rtnl_handle *rtnl_handle,u_int16_t type) +find_handler (struct rtnl_handle *rtnl_handle,uint16_t type) {struct rtnl_handler *h;for (h = rtnl_handle->handlers; h; h = h->next) {
@@ -41,7 +42,7 @@ find_handler(struct rtnl_handle *rtnl_handle, u_int16_t type) }static int call_handler (struct rtnl_handle *rtnl_handle, -u_int16_t type, +uint16_t type,struct nlmsghdr *hdr) {struct rtnl_handler *h =find_handler (rtnl_handle, type);
src/rtnl.h +2 -1
@@ -1,13 +1,14 @@#ifndef _RTNL_H#define _RTNL_H +#include <stdint.h> #include <linux/types.h> #include <linux/rtnetlink.h> struct rtnl_handler {struct rtnl_handler *next; -u_int16_t nlmsg_type; +uint16_t nlmsg_type;int (*handlefn)(struct nlmsghdr *h,void *arg);void *arg; };
Signature · 1 line
2.3.1
Pablo Neira Ayuso
maintainergit am report trailing whitespace errors when applying this patch:
libnfnetlink/.git/rebase-apply/patch:38:
trailing whitespace.
uint8_t, uint8_t,
libnfnetlink/.git/rebase-apply/patch:300:
trailing whitespace.
* nfnl_nfa_addattr16 - Add uint16_t attribute to struct nfattr
libnfnetlink/.git/rebase-apply/patch:336:
trailing whitespace.
* nfnl_nfa_addattr32 - Add uint32_t attribute to struct nfattr
warning: 3 lines add whitespace errors.
Please, fix this and resend. Don't forget to include your
Signed-off-by: tag, thanks.