From ec02e05cf4d1bbb66ee31223f9e96c28bf3ae6f1 Mon Sep 17 00:00:00 2001 From: Felix Janda Date: Sat, 16 May 2015 13:31:38 +0200 Subject: src: Use stdint types everywhere Signed-off-by: Felix Janda Signed-off-by: Pablo Neira Ayuso --- include/internal/bitops.h | 14 +-- include/internal/internal.h | 4 +- include/internal/object.h | 126 ++++++++++----------- include/internal/prototypes.h | 12 +- .../libnetfilter_conntrack.h | 84 +++++++------- 5 files changed, 120 insertions(+), 120 deletions(-) (limited to 'include') diff --git a/include/internal/bitops.h b/include/internal/bitops.h index aefff0e..34d12c3 100644 --- a/include/internal/bitops.h +++ b/include/internal/bitops.h @@ -4,28 +4,28 @@ #ifndef _NFCT_BITOPS_H_ #define _NFCT_BITOPS_H_ -static inline void set_bit(int nr, u_int32_t *addr) +static inline void set_bit(int nr, uint32_t *addr) { addr[nr >> 5] |= (1UL << (nr & 31)); } -static inline void unset_bit(int nr, u_int32_t *addr) +static inline void unset_bit(int nr, uint32_t *addr) { addr[nr >> 5] &= ~(1UL << (nr & 31)); } -static inline void set_bit_u16(int nr, u_int16_t *addr) +static inline void set_bit_u16(int nr, uint16_t *addr) { addr[nr >> 4] |= (1UL << (nr & 15)); } -static inline void unset_bit_u16(int nr, u_int16_t *addr) +static inline void unset_bit_u16(int nr, uint16_t *addr) { addr[nr >> 4] &= ~(1UL << (nr & 15)); } static inline void -set_bitmask_u32(u_int32_t *buf1, const u_int32_t *buf2, int len) +set_bitmask_u32(uint32_t *buf1, const uint32_t *buf2, int len) { int i; @@ -34,7 +34,7 @@ set_bitmask_u32(u_int32_t *buf1, const u_int32_t *buf2, int len) } static inline void -unset_bitmask_u32(u_int32_t *buf1, const u_int32_t *buf2, int len) +unset_bitmask_u32(uint32_t *buf1, const uint32_t *buf2, int len) { int i; @@ -42,7 +42,7 @@ unset_bitmask_u32(u_int32_t *buf1, const u_int32_t *buf2, int len) buf1[i] &= ~buf2[i]; } -static inline int test_bit(int nr, const u_int32_t *addr) +static inline int test_bit(int nr, const uint32_t *addr) { return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0; } diff --git a/include/internal/internal.h b/include/internal/internal.h index aaf6bd4..45b4aa7 100644 --- a/include/internal/internal.h +++ b/include/internal/internal.h @@ -78,8 +78,8 @@ /* extracted from include/linux/netfilter/nf_conntrack_tcp.h .*/ struct nf_ct_tcp_flags { - u_int8_t flags; - u_int8_t mask; + uint8_t flags; + uint8_t mask; }; #define NFCT_BITMASK_AND 0 diff --git a/include/internal/object.h b/include/internal/object.h index 1259467..6f5d2e5 100644 --- a/include/internal/object.h +++ b/include/internal/object.h @@ -58,46 +58,46 @@ struct __data_container { union __nfct_l4_src { /* Add other protocols here. */ - u_int16_t all; + uint16_t all; struct { - u_int16_t port; + uint16_t port; } tcp; struct { - u_int16_t port; + uint16_t port; } udp; struct { - u_int16_t id; + uint16_t id; } icmp; struct { - u_int16_t port; + uint16_t port; } sctp; struct { - u_int16_t port; + uint16_t port; } dccp; }; union __nfct_l4_dst { /* Add other protocols here. */ - u_int16_t all; + uint16_t all; struct { - u_int16_t port; + uint16_t port; } tcp; struct { - u_int16_t port; + uint16_t port; } udp; struct { - u_int8_t type, code; + uint8_t type, code; } icmp; struct { - u_int16_t port; + uint16_t port; } sctp; struct { - u_int16_t port; + uint16_t port; } dccp; }; union __nfct_address { - u_int32_t v4; + uint32_t v4; struct in6_addr v6; }; @@ -105,8 +105,8 @@ struct __nfct_tuple { union __nfct_address src; union __nfct_address dst; - u_int8_t l3protonum; - u_int8_t protonum; + uint8_t l3protonum; + uint8_t protonum; union __nfct_l4_src l4src; union __nfct_l4_dst l4dst; }; @@ -118,31 +118,31 @@ struct __nfct_tuple { union __nfct_protoinfo { struct { - u_int8_t state; + uint8_t state; struct { - u_int8_t value; - u_int8_t mask; + uint8_t value; + uint8_t mask; } flags[__DIR_MAX]; - u_int8_t wscale[__DIR_MAX]; + uint8_t wscale[__DIR_MAX]; } tcp; struct { - u_int8_t state; - u_int32_t vtag[__DIR_MAX]; + uint8_t state; + uint32_t vtag[__DIR_MAX]; } sctp; struct { - u_int8_t state; - u_int8_t role; - u_int64_t handshake_seq; + uint8_t state; + uint8_t role; + uint64_t handshake_seq; } dccp; }; struct __nfct_counters { - u_int64_t packets; - u_int64_t bytes; + uint64_t packets; + uint64_t bytes; }; struct __nfct_nat { - u_int32_t min_ip, max_ip; + uint32_t min_ip, max_ip; union __nfct_l4_src l4min, l4max; }; @@ -150,7 +150,7 @@ struct nfct_tuple_head { struct __nfct_tuple orig; #define __NFCT_BITSET 3 - u_int32_t set[__NFCT_BITSET]; + uint32_t set[__NFCT_BITSET]; }; struct nf_conntrack { @@ -158,13 +158,13 @@ struct nf_conntrack { struct __nfct_tuple repl; struct __nfct_tuple master; - u_int32_t timeout; - u_int32_t mark; - u_int32_t secmark; - u_int32_t status; - u_int32_t use; - u_int32_t id; - u_int16_t zone; + uint32_t timeout; + uint32_t mark; + uint32_t secmark; + uint32_t status; + uint32_t use; + uint32_t id; + uint16_t zone; char helper_name[NFCT_HELPER_NAME_MAX]; /* According to Eric Paris this field can be up to 4096 @@ -177,14 +177,14 @@ struct nf_conntrack { struct __nfct_nat dnat; struct { - u_int32_t correction_pos; - u_int32_t offset_before; - u_int32_t offset_after; + uint32_t correction_pos; + uint32_t offset_before; + uint32_t offset_after; } natseq[__DIR_MAX]; struct { - u_int64_t start; - u_int64_t stop; + uint64_t start; + uint64_t stop; } timestamp; void *helper_info; @@ -220,8 +220,8 @@ struct nfct_filter { * I doubt that anyone can reach such a limit. */ #define __FILTER_L4PROTO_MAX 255 - u_int32_t l4proto_map[IPPROTO_MAX/32]; - u_int32_t l4proto_len; + uint32_t l4proto_map[IPPROTO_MAX/32]; + uint32_t l4proto_len; struct { /* @@ -230,8 +230,8 @@ struct nfct_filter { * 10 states, SCTP has 8 state. Therefore, 16 bits is enough. */ #define __FILTER_PROTO_MAX 16 - u_int16_t map; - u_int16_t len; + uint16_t map; + uint16_t len; } l4proto_state[IPPROTO_MAX]; #define __FILTER_ADDR_SRC 0 @@ -243,11 +243,11 @@ struct nfct_filter { * (two BSF lines per comparison) and the fact that the maximum * jump offset is 0xff which is 255. */ - u_int32_t l3proto_elems[2]; + uint32_t l3proto_elems[2]; struct { #define __FILTER_ADDR_MAX 127 - u_int32_t addr; - u_int32_t mask; + uint32_t addr; + uint32_t mask; } l3proto[2][__FILTER_ADDR_MAX]; /* @@ -256,21 +256,21 @@ struct nfct_filter { * more than that for performance reasons. It seems that oprofile * shows bad numbers for very large BSF code. */ - u_int32_t l3proto_elems_ipv6[2]; + uint32_t l3proto_elems_ipv6[2]; struct { #define __FILTER_IPV6_MAX 20 - u_int32_t addr[4]; - u_int32_t mask[4]; + uint32_t addr[4]; + uint32_t mask[4]; } l3proto_ipv6[2][__FILTER_IPV6_MAX]; - u_int32_t mark_elems; + uint32_t mark_elems; struct { #define __FILTER_MARK_MAX 127 - u_int32_t val; - u_int32_t mask; + uint32_t val; + uint32_t mask; } mark[__FILTER_MARK_MAX]; - u_int32_t set[1]; + uint32_t set[1]; }; /* @@ -279,8 +279,8 @@ struct nfct_filter { struct nfct_filter_dump { struct nfct_filter_dump_mark mark; - u_int8_t l3num; - u_int32_t set; + uint8_t l3num; + uint32_t set; }; /* @@ -295,16 +295,16 @@ struct nf_expect { struct nfct_tuple_head mask; struct nfct_tuple_head nat; - u_int32_t timeout; - u_int32_t id; - u_int16_t zone; - u_int32_t flags; - u_int32_t class; + uint32_t timeout; + uint32_t id; + uint16_t zone; + uint32_t flags; + uint32_t class; char helper_name[NFCT_HELPER_NAME_MAX]; - u_int32_t nat_dir; + uint32_t nat_dir; char expectfn[__NFCT_EXPECTFN_MAX]; - u_int32_t set[1]; + uint32_t set[1]; }; /* diff --git a/include/internal/prototypes.h b/include/internal/prototypes.h index 21aa7f3..a984a2f 100644 --- a/include/internal/prototypes.h +++ b/include/internal/prototypes.h @@ -4,11 +4,11 @@ /* * conntrack internal prototypes */ -int __build_conntrack(struct nfnl_subsys_handle *ssh, struct nfnlhdr *req, size_t size, u_int16_t type, u_int16_t flags, const struct nf_conntrack *ct); +int __build_conntrack(struct nfnl_subsys_handle *ssh, struct nfnlhdr *req, size_t size, uint16_t type, uint16_t flags, const struct nf_conntrack *ct); void __build_tuple(struct nfnlhdr *req, size_t size, const struct __nfct_tuple *t, const int type); int __parse_message_type(const struct nlmsghdr *nlh); void __parse_conntrack(const struct nlmsghdr *nlh, struct nfattr *cda[], struct nf_conntrack *ct); -void __parse_tuple(const struct nfattr *attr, struct __nfct_tuple *tuple, int dir, u_int32_t *set); +void __parse_tuple(const struct nfattr *attr, struct __nfct_tuple *tuple, int dir, uint32_t *set); int __snprintf_conntrack(char *buf, unsigned int len, const struct nf_conntrack *ct, unsigned int type, unsigned int msg_output, unsigned int flags, struct nfct_labelmap *); int __snprintf_address(char *buf, unsigned int len, const struct __nfct_tuple *tuple, const char *src_tag, const char *dst_tag); int __snprintf_protocol(char *buf, unsigned int len, const struct nf_conntrack *ct); @@ -25,8 +25,8 @@ int __snprintf_addr_xml(char *buf, unsigned int len, const struct __nfct_tuple * int __snprintf_proto_xml(char *buf, unsigned int len, const struct __nfct_tuple *tuple, enum __nfct_addr type); int __snprintf_localtime_xml(char *buf, unsigned int len, const struct tm *tm); -const char *__proto2str(u_int8_t protonum); -const char *__l3proto2str(u_int8_t protonum); +const char *__proto2str(uint8_t protonum); +const char *__l3proto2str(uint8_t protonum); int __callback(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data); @@ -41,12 +41,12 @@ int __setup_netlink_socket_filter(int fd, struct nfct_filter *filter); void __build_filter_dump(struct nfnlhdr *req, size_t size, const struct nfct_filter_dump *filter_dump); int nfct_build_tuple(struct nlmsghdr *nlh, const struct __nfct_tuple *t, int type); -int nfct_parse_tuple(const struct nlattr *attr, struct __nfct_tuple *tuple, int dir, u_int32_t *set); +int nfct_parse_tuple(const struct nlattr *attr, struct __nfct_tuple *tuple, int dir, uint32_t *set); /* * expectation internal prototypes */ -int __build_expect(struct nfnl_subsys_handle *ssh, struct nfnlhdr *req, size_t size, u_int16_t type, u_int16_t flags, const struct nf_expect *exp); +int __build_expect(struct nfnl_subsys_handle *ssh, struct nfnlhdr *req, size_t size, uint16_t type, uint16_t flags, const struct nf_expect *exp); int __parse_expect_message_type(const struct nlmsghdr *nlh); void __parse_expect(const struct nlmsghdr *nlh, struct nfattr *cda[], struct nf_expect *exp); int __expect_callback(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data); diff --git a/include/libnetfilter_conntrack/libnetfilter_conntrack.h b/include/libnetfilter_conntrack/libnetfilter_conntrack.h index cea9a78..3a0a131 100644 --- a/include/libnetfilter_conntrack/libnetfilter_conntrack.h +++ b/include/libnetfilter_conntrack/libnetfilter_conntrack.h @@ -38,9 +38,9 @@ struct nfct_handle; /* * [Open|close] a conntrack handler */ -extern struct nfct_handle *nfct_open(u_int8_t, unsigned); +extern struct nfct_handle *nfct_open(uint8_t, unsigned); extern struct nfct_handle *nfct_open_nfnl(struct nfnl_handle *nfnlh, - u_int8_t subsys_id, + uint8_t subsys_id, unsigned int subscriptions); extern int nfct_close(struct nfct_handle *cth); @@ -161,31 +161,31 @@ enum nf_conntrack_attr_grp { }; struct nfct_attr_grp_ipv4 { - u_int32_t src, dst; + uint32_t src, dst; }; struct nfct_attr_grp_ipv6 { - u_int32_t src[4], dst[4]; + uint32_t src[4], dst[4]; }; struct nfct_attr_grp_port { - u_int16_t sport, dport; + uint16_t sport, dport; }; struct nfct_attr_grp_icmp { - u_int16_t id; - u_int8_t code, type; + uint16_t id; + uint8_t code, type; }; struct nfct_attr_grp_ctrs { - u_int64_t packets; - u_int64_t bytes; + uint64_t packets; + uint64_t bytes; }; union nfct_attr_grp_addr { - u_int32_t ip; - u_int32_t ip6[4]; - u_int32_t addr[4]; + uint32_t ip; + uint32_t ip6[4]; + uint32_t addr[4]; }; /* message type */ @@ -305,19 +305,19 @@ extern void nfct_set_attr(struct nf_conntrack *ct, extern void nfct_set_attr_u8(struct nf_conntrack *ct, const enum nf_conntrack_attr type, - u_int8_t value); + uint8_t value); extern void nfct_set_attr_u16(struct nf_conntrack *ct, const enum nf_conntrack_attr type, - u_int16_t value); + uint16_t value); extern void nfct_set_attr_u32(struct nf_conntrack *ct, const enum nf_conntrack_attr type, - u_int32_t value); + uint32_t value); extern void nfct_set_attr_u64(struct nf_conntrack *ct, const enum nf_conntrack_attr type, - u_int64_t value); + uint64_t value); extern void nfct_set_attr_l(struct nf_conntrack *ct, const enum nf_conntrack_attr type, @@ -328,16 +328,16 @@ extern void nfct_set_attr_l(struct nf_conntrack *ct, extern const void *nfct_get_attr(const struct nf_conntrack *ct, const enum nf_conntrack_attr type); -extern u_int8_t nfct_get_attr_u8(const struct nf_conntrack *ct, +extern uint8_t nfct_get_attr_u8(const struct nf_conntrack *ct, const enum nf_conntrack_attr type); -extern u_int16_t nfct_get_attr_u16(const struct nf_conntrack *ct, +extern uint16_t nfct_get_attr_u16(const struct nf_conntrack *ct, const enum nf_conntrack_attr type); -extern u_int32_t nfct_get_attr_u32(const struct nf_conntrack *ct, +extern uint32_t nfct_get_attr_u32(const struct nf_conntrack *ct, const enum nf_conntrack_attr type); -extern u_int64_t nfct_get_attr_u64(const struct nf_conntrack *ct, +extern uint64_t nfct_get_attr_u64(const struct nf_conntrack *ct, const enum nf_conntrack_attr type); /* checker */ @@ -480,20 +480,20 @@ extern struct nfct_filter *nfct_filter_create(void); extern void nfct_filter_destroy(struct nfct_filter *filter); struct nfct_filter_proto { - u_int16_t proto; - u_int16_t state; + uint16_t proto; + uint16_t state; }; struct nfct_filter_ipv4 { - u_int32_t addr; - u_int32_t mask; + uint32_t addr; + uint32_t mask; }; struct nfct_filter_ipv6 { - u_int32_t addr[4]; - u_int32_t mask[4]; + uint32_t addr[4]; + uint32_t mask[4]; }; enum nfct_filter_attr { - NFCT_FILTER_L4PROTO = 0, /* u_int32_t */ + NFCT_FILTER_L4PROTO = 0, /* uint32_t */ NFCT_FILTER_L4PROTO_STATE, /* struct nfct_filter_proto */ NFCT_FILTER_SRC_IPV4, /* struct nfct_filter_ipv4 */ NFCT_FILTER_DST_IPV4, /* struct nfct_filter_ipv4 */ @@ -509,7 +509,7 @@ extern void nfct_filter_add_attr(struct nfct_filter *filter, extern void nfct_filter_add_attr_u32(struct nfct_filter *filter, const enum nfct_filter_attr attr, - const u_int32_t value); + const uint32_t value); enum nfct_filter_logic { NFCT_FILTER_LOGIC_POSITIVE, @@ -529,13 +529,13 @@ extern int nfct_filter_detach(int fd); struct nfct_filter_dump; struct nfct_filter_dump_mark { - u_int32_t val; - u_int32_t mask; + uint32_t val; + uint32_t mask; }; enum nfct_filter_dump_attr { NFCT_FILTER_DUMP_MARK = 0, /* struct nfct_filter_dump_mark */ - NFCT_FILTER_DUMP_L3NUM, /* u_int8_t */ + NFCT_FILTER_DUMP_L3NUM, /* uint8_t */ NFCT_FILTER_DUMP_MAX }; @@ -549,7 +549,7 @@ void nfct_filter_dump_set_attr(struct nfct_filter_dump *filter_dump, void nfct_filter_dump_set_attr_u8(struct nfct_filter_dump *filter_dump, const enum nfct_filter_dump_attr type, - u_int8_t data); + uint8_t data); /* low level API: netlink functions */ @@ -557,8 +557,8 @@ extern __attribute__((deprecated)) int nfct_build_conntrack(struct nfnl_subsys_handle *ssh, void *req, size_t size, - u_int16_t type, - u_int16_t flags, + uint16_t type, + uint16_t flags, const struct nf_conntrack *ct); extern __attribute__((deprecated)) @@ -644,27 +644,27 @@ extern void nfexp_set_attr(struct nf_expect *exp, extern void nfexp_set_attr_u8(struct nf_expect *exp, const enum nf_expect_attr type, - u_int8_t value); + uint8_t value); extern void nfexp_set_attr_u16(struct nf_expect *exp, const enum nf_expect_attr type, - u_int16_t value); + uint16_t value); extern void nfexp_set_attr_u32(struct nf_expect *exp, const enum nf_expect_attr type, - u_int32_t value); + uint32_t value); /* getter */ extern const void *nfexp_get_attr(const struct nf_expect *exp, const enum nf_expect_attr type); -extern u_int8_t nfexp_get_attr_u8(const struct nf_expect *exp, +extern uint8_t nfexp_get_attr_u8(const struct nf_expect *exp, const enum nf_expect_attr type); -extern u_int16_t nfexp_get_attr_u16(const struct nf_expect *exp, +extern uint16_t nfexp_get_attr_u16(const struct nf_expect *exp, const enum nf_expect_attr type); -extern u_int32_t nfexp_get_attr_u32(const struct nf_expect *exp, +extern uint32_t nfexp_get_attr_u32(const struct nf_expect *exp, const enum nf_expect_attr type); /* checker */ @@ -704,8 +704,8 @@ extern __attribute__((deprecated)) int nfexp_build_expect(struct nfnl_subsys_handle *ssh, void *req, size_t size, - u_int16_t type, - u_int16_t flags, + uint16_t type, + uint16_t flags, const struct nf_expect *exp); extern __attribute__((deprecated)) -- cgit v1.2.3