From 42878e88e5b72d3120434564942417cae3723385 Mon Sep 17 00:00:00 2001 From: Felix Janda Date: Sat, 16 May 2015 14:01:00 +0200 Subject: src: Use stdint types everywhere Signed-off-by: Felix Janda Signed-off-by: Pablo Neira Ayuso --- src/libnetfilter_log.c | 92 +++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'src/libnetfilter_log.c') diff --git a/src/libnetfilter_log.c b/src/libnetfilter_log.c index 76ed436..e92576b 100644 --- a/src/libnetfilter_log.c +++ b/src/libnetfilter_log.c @@ -72,7 +72,7 @@ struct nflog_g_handle { struct nflog_g_handle *next; struct nflog_handle *h; - u_int16_t id; + uint16_t id; nflog_callback *cb; void *data; @@ -111,7 +111,7 @@ static void add_gh(struct nflog_g_handle *gh) gh->h->gh_list = gh; } -static struct nflog_g_handle *find_gh(struct nflog_handle *h, u_int16_t group) +static struct nflog_g_handle *find_gh(struct nflog_handle *h, uint16_t group) { struct nflog_g_handle *gh; @@ -124,8 +124,8 @@ static struct nflog_g_handle *find_gh(struct nflog_handle *h, u_int16_t group) /* build a NFULNL_MSG_CONFIG message */ static int -__build_send_cfg_msg(struct nflog_handle *h, u_int8_t command, - u_int16_t groupnum, u_int8_t pf) +__build_send_cfg_msg(struct nflog_handle *h, uint8_t command, + uint16_t groupnum, uint8_t pf) { union { char buf[NFNL_HEADER_LEN @@ -148,7 +148,7 @@ static int __nflog_rcv_pkt(struct nlmsghdr *nlh, struct nfattr *nfa[], { struct nfgenmsg *nfmsg = NLMSG_DATA(nlh); struct nflog_handle *h = data; - u_int16_t group = ntohs(nfmsg->res_id); + uint16_t group = ntohs(nfmsg->res_id); struct nflog_g_handle *gh = find_gh(h, group); struct nflog_data nfldata; @@ -359,7 +359,7 @@ int nflog_close(struct nflog_handle *h) * * \return integer inferior to 0 in case of failure */ -int nflog_bind_pf(struct nflog_handle *h, u_int16_t pf) +int nflog_bind_pf(struct nflog_handle *h, uint16_t pf) { return __build_send_cfg_msg(h, NFULNL_CFG_CMD_PF_BIND, 0, pf); } @@ -373,7 +373,7 @@ int nflog_bind_pf(struct nflog_handle *h, u_int16_t pf) * Unbinds the given nflog handle from processing packets belonging * to the given protocol family. */ -int nflog_unbind_pf(struct nflog_handle *h, u_int16_t pf) +int nflog_unbind_pf(struct nflog_handle *h, uint16_t pf) { return __build_send_cfg_msg(h, NFULNL_CFG_CMD_PF_UNBIND, 0, pf); } @@ -395,7 +395,7 @@ int nflog_unbind_pf(struct nflog_handle *h, u_int16_t pf) * \return a nflog_g_handle pointing to the newly created group */ struct nflog_g_handle * -nflog_bind_group(struct nflog_handle *h, u_int16_t num) +nflog_bind_group(struct nflog_handle *h, uint16_t num) { struct nflog_g_handle *gh; @@ -461,7 +461,7 @@ int nflog_unbind_group(struct nflog_g_handle *gh) * \return -1 on error; >= otherwise. */ int nflog_set_mode(struct nflog_g_handle *gh, - u_int8_t mode, u_int32_t range) + uint8_t mode, uint32_t range) { union { char buf[NFNL_HEADER_LEN @@ -493,10 +493,10 @@ int nflog_set_mode(struct nflog_g_handle *gh, * * \return -1 in case of error and errno is explicity set. */ -int nflog_set_timeout(struct nflog_g_handle *gh, u_int32_t timeout) +int nflog_set_timeout(struct nflog_g_handle *gh, uint32_t timeout) { union { - char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(u_int32_t))]; + char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(uint32_t))]; struct nlmsghdr nmh; } u; @@ -518,10 +518,10 @@ int nflog_set_timeout(struct nflog_g_handle *gh, u_int32_t timeout) * * \return -1 in case of error and errno is explicity set. */ -int nflog_set_qthresh(struct nflog_g_handle *gh, u_int32_t qthresh) +int nflog_set_qthresh(struct nflog_g_handle *gh, uint32_t qthresh) { union { - char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(u_int32_t))]; + char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(uint32_t))]; struct nlmsghdr nmh; } u; @@ -547,10 +547,10 @@ int nflog_set_qthresh(struct nflog_g_handle *gh, u_int32_t qthresh) * * \return -1 in case of error and errno is explicity set. */ -int nflog_set_nlbufsiz(struct nflog_g_handle *gh, u_int32_t nlbufsiz) +int nflog_set_nlbufsiz(struct nflog_g_handle *gh, uint32_t nlbufsiz) { union { - char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(u_int32_t))]; + char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(uint32_t))]; struct nlmsghdr nmh; } u; int status; @@ -581,10 +581,10 @@ int nflog_set_nlbufsiz(struct nflog_g_handle *gh, u_int32_t nlbufsiz) * * \return -1 in case of error and errno is explicity set. */ -int nflog_set_flags(struct nflog_g_handle *gh, u_int16_t flags) +int nflog_set_flags(struct nflog_g_handle *gh, uint16_t flags) { union { - char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(u_int16_t))]; + char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(uint16_t))]; struct nlmsghdr nmh; } u; @@ -616,9 +616,9 @@ int nflog_set_flags(struct nflog_g_handle *gh, u_int16_t flags) * The nfulnl_msg_packet_hdr structure is defined in libnetfilter_log.h as: *\verbatim struct nfulnl_msg_packet_hdr { - u_int16_t hw_protocol; // hw protocol (network order) - u_int8_t hook; // netfilter hook - u_int8_t _pad; + uint16_t hw_protocol; // hw protocol (network order) + uint8_t hook; // netfilter hook + uint8_t _pad; } __attribute__ ((packed)); \endverbatim */ @@ -634,9 +634,9 @@ struct nfulnl_msg_packet_hdr *nflog_get_msg_packet_hdr(struct nflog_data *nfad) * * \return the hardware link layer type. */ -u_int16_t nflog_get_hwtype(struct nflog_data *nfad) +uint16_t nflog_get_hwtype(struct nflog_data *nfad) { - return ntohs(nfnl_get_data(nfad->nfa, NFULA_HWTYPE, u_int16_t)); + return ntohs(nfnl_get_data(nfad->nfa, NFULA_HWTYPE, uint16_t)); } /** @@ -645,9 +645,9 @@ u_int16_t nflog_get_hwtype(struct nflog_data *nfad) * * \return the size of the hardware link layer header */ -u_int16_t nflog_get_msg_packet_hwhdrlen(struct nflog_data *nfad) +uint16_t nflog_get_msg_packet_hwhdrlen(struct nflog_data *nfad) { - return ntohs(nfnl_get_data(nfad->nfa, NFULA_HWLEN, u_int16_t)); + return ntohs(nfnl_get_data(nfad->nfa, NFULA_HWLEN, uint16_t)); } /** @@ -667,9 +667,9 @@ char *nflog_get_msg_packet_hwhdr(struct nflog_data *nfad) * * \return the netfilter mark currently assigned to the logged packet. */ -u_int32_t nflog_get_nfmark(struct nflog_data *nfad) +uint32_t nflog_get_nfmark(struct nflog_data *nfad) { - return ntohl(nfnl_get_data(nfad->nfa, NFULA_MARK, u_int32_t)); + return ntohl(nfnl_get_data(nfad->nfa, NFULA_MARK, uint32_t)); } /** @@ -707,9 +707,9 @@ int nflog_get_timestamp(struct nflog_data *nfad, struct timeval *tv) * \warning all nflog_get_dev() functions return 0 if not set, since linux * only allows ifindex >= 1, see net/core/dev.c:2600 (in 2.6.13.1) */ -u_int32_t nflog_get_indev(struct nflog_data *nfad) +uint32_t nflog_get_indev(struct nflog_data *nfad) { - return ntohl(nfnl_get_data(nfad->nfa, NFULA_IFINDEX_INDEV, u_int32_t)); + return ntohl(nfnl_get_data(nfad->nfa, NFULA_IFINDEX_INDEV, uint32_t)); } /** @@ -720,9 +720,9 @@ u_int32_t nflog_get_indev(struct nflog_data *nfad) * If the returned index is 0, the packet was locally generated or the * physical input interface is no longer known (ie. POSTROUTING?). */ -u_int32_t nflog_get_physindev(struct nflog_data *nfad) +uint32_t nflog_get_physindev(struct nflog_data *nfad) { - return ntohl(nfnl_get_data(nfad->nfa, NFULA_IFINDEX_PHYSINDEV, u_int32_t)); + return ntohl(nfnl_get_data(nfad->nfa, NFULA_IFINDEX_PHYSINDEV, uint32_t)); } /** @@ -733,9 +733,9 @@ u_int32_t nflog_get_physindev(struct nflog_data *nfad) * returned index is 0, the packet is destined for localhost or the output * interface is not yet known (ie. PREROUTING?). */ -u_int32_t nflog_get_outdev(struct nflog_data *nfad) +uint32_t nflog_get_outdev(struct nflog_data *nfad) { - return ntohl(nfnl_get_data(nfad->nfa, NFULA_IFINDEX_OUTDEV, u_int32_t)); + return ntohl(nfnl_get_data(nfad->nfa, NFULA_IFINDEX_OUTDEV, uint32_t)); } /** @@ -749,9 +749,9 @@ u_int32_t nflog_get_outdev(struct nflog_data *nfad) * \return The index of physical interface that the packet output will be * routed out. */ -u_int32_t nflog_get_physoutdev(struct nflog_data *nfad) +uint32_t nflog_get_physoutdev(struct nflog_data *nfad) { - return ntohl(nfnl_get_data(nfad->nfa, NFULA_IFINDEX_PHYSOUTDEV, u_int32_t)); + return ntohl(nfnl_get_data(nfad->nfa, NFULA_IFINDEX_PHYSOUTDEV, uint32_t)); } /** @@ -767,9 +767,9 @@ u_int32_t nflog_get_physoutdev(struct nflog_data *nfad) * The nfulnl_msg_packet_hw structure is defined in libnetfilter_log.h as: * \verbatim struct nfulnl_msg_packet_hw { - u_int16_t hw_addrlen; - u_int16_t _pad; - u_int8_t hw_addr[8]; + uint16_t hw_addrlen; + uint16_t _pad; + uint8_t hw_addr[8]; } __attribute__ ((packed)); \endverbatim */ @@ -817,12 +817,12 @@ char *nflog_get_prefix(struct nflog_data *nfad) * * \return the UID of the user that has genered the packet, if any. */ -int nflog_get_uid(struct nflog_data *nfad, u_int32_t *uid) +int nflog_get_uid(struct nflog_data *nfad, uint32_t *uid) { if (!nfnl_attr_present(nfad->nfa, NFULA_UID)) return -1; - *uid = ntohl(nfnl_get_data(nfad->nfa, NFULA_UID, u_int32_t)); + *uid = ntohl(nfnl_get_data(nfad->nfa, NFULA_UID, uint32_t)); return 0; } @@ -832,12 +832,12 @@ int nflog_get_uid(struct nflog_data *nfad, u_int32_t *uid) * * \return the GID of the user that has genered the packet, if any. */ -int nflog_get_gid(struct nflog_data *nfad, u_int32_t *gid) +int nflog_get_gid(struct nflog_data *nfad, uint32_t *gid) { if (!nfnl_attr_present(nfad->nfa, NFULA_GID)) return -1; - *gid = ntohl(nfnl_get_data(nfad->nfa, NFULA_GID, u_int32_t)); + *gid = ntohl(nfnl_get_data(nfad->nfa, NFULA_GID, uint32_t)); return 0; } @@ -849,12 +849,12 @@ int nflog_get_gid(struct nflog_data *nfad, u_int32_t *gid) * * \return the local nflog sequence number. */ -int nflog_get_seq(struct nflog_data *nfad, u_int32_t *seq) +int nflog_get_seq(struct nflog_data *nfad, uint32_t *seq) { if (!nfnl_attr_present(nfad->nfa, NFULA_SEQ)) return -1; - *seq = ntohl(nfnl_get_data(nfad->nfa, NFULA_SEQ, u_int32_t)); + *seq = ntohl(nfnl_get_data(nfad->nfa, NFULA_SEQ, uint32_t)); return 0; } @@ -866,12 +866,12 @@ int nflog_get_seq(struct nflog_data *nfad, u_int32_t *seq) * * \return the global nflog sequence number. */ -int nflog_get_seq_global(struct nflog_data *nfad, u_int32_t *seq) +int nflog_get_seq_global(struct nflog_data *nfad, uint32_t *seq) { if (!nfnl_attr_present(nfad->nfa, NFULA_SEQ_GLOBAL)) return -1; - *seq = ntohl(nfnl_get_data(nfad->nfa, NFULA_SEQ_GLOBAL, u_int32_t)); + *seq = ntohl(nfnl_get_data(nfad->nfa, NFULA_SEQ_GLOBAL, uint32_t)); return 0; } @@ -923,7 +923,7 @@ int nflog_snprintf_xml(char *buf, size_t rem, struct nflog_data *tb, int flags) { struct nfulnl_msg_packet_hdr *ph; struct nfulnl_msg_packet_hw *hwph; - u_int32_t mark, ifi; + uint32_t mark, ifi; int size, offset = 0, len = 0, ret; char *data; -- cgit v1.2.3