summaryrefslogtreecommitdiff
path: root/libnfnetlink/0006-src-Use-stdint-types-everywhere.patch
blob: 72c9987d1ee44b3704ef9722e7b7067899041157 (plain)
    1 From 5cb589e246c91331ee6b3926b15f5e6cfc8ad95e Mon Sep 17 00:00:00 2001
    2 From: Felix Janda <felix.janda@posteo.de>
    3 Date: Sat, 16 May 2015 14:59:57 +0200
    4 Subject: [PATCH 6/6] src: Use stdint types everywhere
    5 
    6 Signed-off-by: Felix Janda <felix.janda@posteo.de>
    7 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    8 ---
    9  include/libnfnetlink/libnfnetlink.h | 25 ++++++-------
   10  src/iftable.c                       |  8 ++---
   11  src/iftable.h                       |  4 +--
   12  src/libnfnetlink.c                  | 72 ++++++++++++++++++-------------------
   13  src/rtnl.c                          |  4 +--
   14  src/rtnl.h                          |  2 +-
   15  6 files changed, 58 insertions(+), 57 deletions(-)
   16 
   17 diff --git a/include/libnfnetlink/libnfnetlink.h b/include/libnfnetlink/libnfnetlink.h
   18 index 1d8c49d..cd0be3d 100644
   19 --- a/include/libnfnetlink/libnfnetlink.h
   20 +++ b/include/libnfnetlink/libnfnetlink.h
   21 @@ -15,6 +15,7 @@
   22  #define aligned_u64 unsigned long long __attribute__((aligned(8)))
   23  #endif
   24  
   25 +#include <stdint.h>
   26  #include <sys/socket.h>	/* for sa_family_t */
   27  #include <linux/netlink.h>
   28  #include <libnfnetlink/linux_nfnetlink.h>
   29 @@ -55,7 +56,7 @@ struct nfnlhdr {
   30  struct nfnl_callback {
   31  	int (*call)(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data);
   32  	void *data;
   33 -	u_int16_t attr_count;
   34 +	uint16_t attr_count;
   35  };
   36  
   37  struct nfnl_handle;
   38 @@ -69,7 +70,7 @@ extern struct nfnl_handle *nfnl_open(void);
   39  extern int nfnl_close(struct nfnl_handle *);
   40  
   41  extern struct nfnl_subsys_handle *nfnl_subsys_open(struct nfnl_handle *, 
   42 -						   u_int8_t, u_int8_t, 
   43 +						   uint8_t, uint8_t,
   44  						   unsigned int);
   45  extern void nfnl_subsys_close(struct nfnl_subsys_handle *);
   46  
   47 @@ -88,8 +89,8 @@ extern int nfnl_sendiov(const struct nfnl_handle *nfnlh,
   48  			const struct iovec *iov, unsigned int num,
   49  			unsigned int flags);
   50  extern void nfnl_fill_hdr(struct nfnl_subsys_handle *, struct nlmsghdr *,
   51 -			  unsigned int, u_int8_t, u_int16_t, u_int16_t,
   52 -			  u_int16_t);
   53 +			  unsigned int, uint8_t, uint16_t, uint16_t,
   54 +			  uint16_t);
   55  extern __attribute__((deprecated)) int
   56  nfnl_talk(struct nfnl_handle *, struct nlmsghdr *, pid_t,
   57            unsigned, struct nlmsghdr *,
   58 @@ -103,8 +104,8 @@ nfnl_listen(struct nfnl_handle *,
   59  /* receiving */
   60  extern ssize_t nfnl_recv(const struct nfnl_handle *h, unsigned char *buf, size_t len);
   61  extern int nfnl_callback_register(struct nfnl_subsys_handle *,
   62 -				  u_int8_t type, struct nfnl_callback *cb);
   63 -extern int nfnl_callback_unregister(struct nfnl_subsys_handle *, u_int8_t type);
   64 +				  uint8_t type, struct nfnl_callback *cb);
   65 +extern int nfnl_callback_unregister(struct nfnl_subsys_handle *, uint8_t type);
   66  extern int nfnl_handle_packet(struct nfnl_handle *, char *buf, int len);
   67  
   68  /* parsing */
   69 @@ -180,12 +181,12 @@ extern int nfnl_query(struct nfnl_handle *h, struct nlmsghdr *nlh);
   70  
   71  /* nfnl attribute handling functions */
   72  extern int nfnl_addattr_l(struct nlmsghdr *, int, int, const void *, int);
   73 -extern int nfnl_addattr8(struct nlmsghdr *, int, int, u_int8_t);
   74 -extern int nfnl_addattr16(struct nlmsghdr *, int, int, u_int16_t);
   75 -extern int nfnl_addattr32(struct nlmsghdr *, int, int, u_int32_t);
   76 +extern int nfnl_addattr8(struct nlmsghdr *, int, int, uint8_t);
   77 +extern int nfnl_addattr16(struct nlmsghdr *, int, int, uint16_t);
   78 +extern int nfnl_addattr32(struct nlmsghdr *, int, int, uint32_t);
   79  extern int nfnl_nfa_addattr_l(struct nfattr *, int, int, const void *, int);
   80 -extern int nfnl_nfa_addattr16(struct nfattr *, int, int, u_int16_t);
   81 -extern int nfnl_nfa_addattr32(struct nfattr *, int, int, u_int32_t);
   82 +extern int nfnl_nfa_addattr16(struct nfattr *, int, int, uint16_t);
   83 +extern int nfnl_nfa_addattr32(struct nfattr *, int, int, uint32_t);
   84  extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int);
   85  #define nfnl_parse_nested(tb, max, nfa) \
   86  	nfnl_parse_attr((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa)))
   87 @@ -197,7 +198,7 @@ extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int);
   88  ({	(tail)->nfa_len = (void *) NLMSG_TAIL(nlh) - (void *) tail; })
   89  
   90  extern void nfnl_build_nfa_iovec(struct iovec *iov, struct nfattr *nfa, 
   91 -				 u_int16_t type, u_int32_t len,
   92 +				 uint16_t type, uint32_t len,
   93  				 unsigned char *val);
   94  extern unsigned int nfnl_rcvbufsiz(const struct nfnl_handle *h, 
   95  				   unsigned int size);
   96 diff --git a/src/iftable.c b/src/iftable.c
   97 index 5976ed8..157f97b 100644
   98 --- a/src/iftable.c
   99 +++ b/src/iftable.c
  100 @@ -27,10 +27,10 @@
  101  struct ifindex_node {
  102  	struct list_head head;
  103  
  104 -	u_int32_t	index;
  105 -	u_int32_t	type;
  106 -	u_int32_t	alen;
  107 -	u_int32_t	flags;
  108 +	uint32_t	index;
  109 +	uint32_t	type;
  110 +	uint32_t	alen;
  111 +	uint32_t	flags;
  112  	char		addr[8];
  113  	char		name[16];
  114  };
  115 diff --git a/src/iftable.h b/src/iftable.h
  116 index 8df7f24..655df6b 100644
  117 --- a/src/iftable.h
  118 +++ b/src/iftable.h
  119 @@ -1,8 +1,8 @@
  120  #ifndef _IFTABLE_H
  121  #define _IFTABLE_H
  122  
  123 -int iftable_delete(u_int32_t dst, u_int32_t mask, u_int32_t gw, u_int32_t oif);
  124 -int iftable_insert(u_int32_t dst, u_int32_t mask, u_int32_t gw, u_int32_t oif);
  125 +int iftable_delete(uint32_t dst, uint32_t mask, uint32_t gw, uint32_t oif);
  126 +int iftable_insert(uint32_t dst, uint32_t mask, uint32_t gw, uint32_t oif);
  127  
  128  int iftable_init(void);
  129  void iftable_fini(void);
  130 diff --git a/src/libnfnetlink.c b/src/libnfnetlink.c
  131 index 398b7d7..df57533 100644
  132 --- a/src/libnfnetlink.c
  133 +++ b/src/libnfnetlink.c
  134 @@ -72,9 +72,9 @@
  135  
  136  struct nfnl_subsys_handle {
  137  	struct nfnl_handle 	*nfnlh;
  138 -	u_int32_t		subscriptions;
  139 -	u_int8_t		subsys_id;
  140 -	u_int8_t		cb_count;
  141 +	uint32_t		subscriptions;
  142 +	uint8_t			subsys_id;
  143 +	uint8_t			cb_count;
  144  	struct nfnl_callback 	*cb;	/* array of callbacks */
  145  };
  146  
  147 @@ -86,11 +86,11 @@ struct nfnl_handle {
  148  	int			fd;
  149  	struct sockaddr_nl	local;
  150  	struct sockaddr_nl	peer;
  151 -	u_int32_t		subscriptions;
  152 -	u_int32_t		seq;
  153 -	u_int32_t		dump;
  154 -	u_int32_t		rcv_buffer_size;	/* for nfnl_catch */
  155 -	u_int32_t		flags;
  156 +	uint32_t		subscriptions;
  157 +	uint32_t		seq;
  158 +	uint32_t		dump;
  159 +	uint32_t		rcv_buffer_size;	/* for nfnl_catch */
  160 +	uint32_t		flags;
  161  	struct nlmsghdr 	*last_nlhdr;
  162  	struct nfnl_subsys_handle subsys[NFNL_MAX_SUBSYS+1];
  163  };
  164 @@ -145,7 +145,7 @@ unsigned int nfnl_portid(const struct nfnl_handle *h)
  165  static int recalc_rebind_subscriptions(struct nfnl_handle *nfnlh)
  166  {
  167  	int i, err;
  168 -	u_int32_t new_subscriptions = nfnlh->subscriptions;
  169 +	uint32_t new_subscriptions = nfnlh->subscriptions;
  170  
  171  	for (i = 0; i < NFNL_MAX_SUBSYS; i++)
  172  		new_subscriptions |= nfnlh->subsys[i].subscriptions;
  173 @@ -273,8 +273,8 @@ void nfnl_set_rcv_buffer_size(struct nfnl_handle *h, unsigned int size)
  174   * a valid address that points to a nfnl_subsys_handle structure is returned.
  175   */
  176  struct nfnl_subsys_handle *
  177 -nfnl_subsys_open(struct nfnl_handle *nfnlh, u_int8_t subsys_id,
  178 -		 u_int8_t cb_count, u_int32_t subscriptions)
  179 +nfnl_subsys_open(struct nfnl_handle *nfnlh, uint8_t subsys_id,
  180 +		 uint8_t cb_count, uint32_t subscriptions)
  181  {
  182  	struct nfnl_subsys_handle *ssh;
  183  
  184 @@ -435,10 +435,10 @@ int nfnl_sendiov(const struct nfnl_handle *nfnlh, const struct iovec *iov,
  185   */
  186  void nfnl_fill_hdr(struct nfnl_subsys_handle *ssh,
  187  		    struct nlmsghdr *nlh, unsigned int len, 
  188 -		    u_int8_t family,
  189 -		    u_int16_t res_id,
  190 -		    u_int16_t msg_type,
  191 -		    u_int16_t msg_flags)
  192 +		    uint8_t family,
  193 +		    uint16_t res_id,
  194 +		    uint16_t msg_type,
  195 +		    uint16_t msg_flags)
  196  {
  197  	assert(ssh);
  198  	assert(nlh);
  199 @@ -815,7 +815,7 @@ int nfnl_addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
  200  }
  201  
  202  /**
  203 - * nfnl_nfa_addattr_l - Add variable length attribute to struct nfattr 
  204 + * nfnl_nfa_addattr_l - Add variable length attribute to struct nfattr
  205   *
  206   * @nfa: struct nfattr
  207   * @maxlen: maximal length of nfattr buffer
  208 @@ -849,14 +849,14 @@ int nfnl_nfa_addattr_l(struct nfattr *nfa, int maxlen, int type,
  209  }
  210  
  211  /**
  212 - * nfnl_addattr8 - Add u_int8_t attribute to nlmsghdr
  213 + * nfnl_addattr8 - Add uint8_t attribute to nlmsghdr
  214   *
  215   * @n: netlink message header to which attribute is to be added
  216   * @maxlen: maximum length of netlink message header
  217   * @type: type of new attribute
  218   * @data: content of new attribute
  219   */
  220 -int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, u_int8_t data)
  221 +int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, uint8_t data)
  222  {
  223  	assert(n);
  224  	assert(maxlen > 0);
  225 @@ -866,7 +866,7 @@ int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, u_int8_t data)
  226  }
  227  
  228  /**
  229 - * nfnl_nfa_addattr16 - Add u_int16_t attribute to struct nfattr 
  230 + * nfnl_nfa_addattr16 - Add uint16_t attribute to struct nfattr
  231   *
  232   * @nfa: struct nfattr
  233   * @maxlen: maximal length of nfattr buffer
  234 @@ -875,7 +875,7 @@ int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, u_int8_t data)
  235   *
  236   */
  237  int nfnl_nfa_addattr16(struct nfattr *nfa, int maxlen, int type, 
  238 -		       u_int16_t data)
  239 +		       uint16_t data)
  240  {
  241  	assert(nfa);
  242  	assert(maxlen > 0);
  243 @@ -885,7 +885,7 @@ int nfnl_nfa_addattr16(struct nfattr *nfa, int maxlen, int type,
  244  }
  245  
  246  /**
  247 - * nfnl_addattr16 - Add u_int16_t attribute to nlmsghdr
  248 + * nfnl_addattr16 - Add uint16_t attribute to nlmsghdr
  249   *
  250   * @n: netlink message header to which attribute is to be added
  251   * @maxlen: maximum length of netlink message header
  252 @@ -894,7 +894,7 @@ int nfnl_nfa_addattr16(struct nfattr *nfa, int maxlen, int type,
  253   *
  254   */
  255  int nfnl_addattr16(struct nlmsghdr *n, int maxlen, int type,
  256 -		   u_int16_t data)
  257 +		   uint16_t data)
  258  {
  259  	assert(n);
  260  	assert(maxlen > 0);
  261 @@ -904,7 +904,7 @@ int nfnl_addattr16(struct nlmsghdr *n, int maxlen, int type,
  262  }
  263  
  264  /**
  265 - * nfnl_nfa_addattr32 - Add u_int32_t attribute to struct nfattr 
  266 + * nfnl_nfa_addattr32 - Add uint32_t attribute to struct nfattr
  267   *
  268   * @nfa: struct nfattr
  269   * @maxlen: maximal length of nfattr buffer
  270 @@ -913,7 +913,7 @@ int nfnl_addattr16(struct nlmsghdr *n, int maxlen, int type,
  271   *
  272   */
  273  int nfnl_nfa_addattr32(struct nfattr *nfa, int maxlen, int type, 
  274 -		       u_int32_t data)
  275 +		       uint32_t data)
  276  {
  277  	assert(nfa);
  278  	assert(maxlen > 0);
  279 @@ -923,7 +923,7 @@ int nfnl_nfa_addattr32(struct nfattr *nfa, int maxlen, int type,
  280  }
  281  
  282  /**
  283 - * nfnl_addattr32 - Add u_int32_t attribute to nlmsghdr
  284 + * nfnl_addattr32 - Add uint32_t attribute to nlmsghdr
  285   *
  286   * @n: netlink message header to which attribute is to be added
  287   * @maxlen: maximum length of netlink message header
  288 @@ -932,7 +932,7 @@ int nfnl_nfa_addattr32(struct nfattr *nfa, int maxlen, int type,
  289   *
  290   */
  291  int nfnl_addattr32(struct nlmsghdr *n, int maxlen, int type,
  292 -		   u_int32_t data)
  293 +		   uint32_t data)
  294  {
  295  	assert(n);
  296  	assert(maxlen > 0);
  297 @@ -980,7 +980,7 @@ int nfnl_parse_attr(struct nfattr *tb[], int max, struct nfattr *nfa, int len)
  298   *
  299   */ 
  300  void nfnl_build_nfa_iovec(struct iovec *iov, struct nfattr *nfa, 
  301 -			  u_int16_t type, u_int32_t len, unsigned char *val)
  302 +			  uint16_t type, uint32_t len, unsigned char *val)
  303  {
  304  	assert(iov);
  305  	assert(nfa);
  306 @@ -1115,7 +1115,7 @@ struct nlmsghdr *nfnl_get_msg_next(struct nfnl_handle *h,
  307   * appropiately.
  308   */
  309  int nfnl_callback_register(struct nfnl_subsys_handle *ssh,
  310 -			   u_int8_t type, struct nfnl_callback *cb)
  311 +			   uint8_t type, struct nfnl_callback *cb)
  312  {
  313  	assert(ssh);
  314  	assert(cb);
  315 @@ -1138,7 +1138,7 @@ int nfnl_callback_register(struct nfnl_subsys_handle *ssh,
  316   * On sucess, 0 is returned. On error, -1 is returned and errno is
  317   * set appropiately.
  318   */
  319 -int nfnl_callback_unregister(struct nfnl_subsys_handle *ssh, u_int8_t type)
  320 +int nfnl_callback_unregister(struct nfnl_subsys_handle *ssh, uint8_t type)
  321  {
  322  	assert(ssh);
  323  
  324 @@ -1161,8 +1161,8 @@ int nfnl_check_attributes(const struct nfnl_handle *h,
  325  	assert(nfa);
  326  
  327  	int min_len;
  328 -	u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
  329 -	u_int8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
  330 +	uint8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
  331 +	uint8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
  332  	const struct nfnl_subsys_handle *ssh;
  333  	struct nfnl_callback *cb;
  334  
  335 @@ -1212,8 +1212,8 @@ static int __nfnl_handle_msg(struct nfnl_handle *h, struct nlmsghdr *nlh,
  336  			     int len)
  337  {
  338  	struct nfnl_subsys_handle *ssh;
  339 -	u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
  340 -	u_int8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
  341 +	uint8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
  342 +	uint8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
  343  	int err = 0;
  344  
  345  	if (subsys_id > NFNL_MAX_SUBSYS)
  346 @@ -1243,7 +1243,7 @@ int nfnl_handle_packet(struct nfnl_handle *h, char *buf, int len)
  347  {
  348  
  349  	while (len >= NLMSG_SPACE(0)) {
  350 -		u_int32_t rlen;
  351 +		uint32_t rlen;
  352  		struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
  353  
  354  		if (nlh->nlmsg_len < sizeof(struct nlmsghdr)
  355 @@ -1285,8 +1285,8 @@ static int nfnl_is_error(struct nfnl_handle *h, struct nlmsghdr *nlh)
  356  static int nfnl_step(struct nfnl_handle *h, struct nlmsghdr *nlh)
  357  {
  358  	struct nfnl_subsys_handle *ssh;
  359 -	u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
  360 -	u_int8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
  361 +	uint8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
  362 +	uint8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
  363  
  364  	/* Is this an error message? */
  365  	if (nfnl_is_error(h, nlh)) {
  366 diff --git a/src/rtnl.c b/src/rtnl.c
  367 index 7b4ac7d..284eecd 100644
  368 --- a/src/rtnl.c
  369 +++ b/src/rtnl.c
  370 @@ -30,7 +30,7 @@
  371  #define rtnl_log(x, ...)
  372  
  373  static inline struct rtnl_handler *
  374 -find_handler(struct rtnl_handle *rtnl_handle, u_int16_t type)
  375 +find_handler(struct rtnl_handle *rtnl_handle, uint16_t type)
  376  {
  377  	struct rtnl_handler *h;
  378  	for (h = rtnl_handle->handlers; h; h = h->next) {
  379 @@ -41,7 +41,7 @@ find_handler(struct rtnl_handle *rtnl_handle, u_int16_t type)
  380  }
  381  
  382  static int call_handler(struct rtnl_handle *rtnl_handle,
  383 -			u_int16_t type,
  384 +			uint16_t type,
  385  			struct nlmsghdr *hdr)
  386  {
  387  	struct rtnl_handler *h = find_handler(rtnl_handle, type);
  388 diff --git a/src/rtnl.h b/src/rtnl.h
  389 index 0c403dc..2cb22a8 100644
  390 --- a/src/rtnl.h
  391 +++ b/src/rtnl.h
  392 @@ -7,7 +7,7 @@
  393  struct rtnl_handler {
  394  	struct rtnl_handler *next;
  395  
  396 -	u_int16_t	nlmsg_type;
  397 +	uint16_t	nlmsg_type;
  398  	int		(*handlefn)(struct nlmsghdr *h, void *arg);
  399  	void		*arg;
  400  };
  401 -- 
  402 2.12.1

Generated by cgit