From: Davide Caratti Date: Tue, 6 Sep 2016 09:17:47 +0000 (+0200) Subject: remove multiple implementations of htonll(), ntohll() X-Git-Tag: libnl3_2_29rc1~18^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a355b9a53b5602df3895fc04a943b50092e9854c;p=libnl remove multiple implementations of htonll(), ntohll() use a single #define in include/netlink-private/utils.h Signed-off-by: Davide Caratti --- diff --git a/include/netlink-private/utils.h b/include/netlink-private/utils.h index 77aadb3..d9c55d0 100644 --- a/include/netlink-private/utils.h +++ b/include/netlink-private/utils.h @@ -12,6 +12,14 @@ #ifndef NETLINK_UTILS_PRIV_H_ #define NETLINK_UTILS_PRIV_H_ +#include +#if __BYTE_ORDER == __BIG_ENDIAN +#define ntohll(x) (x) +#elif __BYTE_ORDER == __LITTLE_ENDIAN +#define ntohll(x) bswap_64((x)) +#endif +#define htonll(x) ntohll(x) + extern const char * nl_strerror_l(int err); #endif diff --git a/lib/netfilter/ct.c b/lib/netfilter/ct.c index 62ee77f..1b29cf6 100644 --- a/lib/netfilter/ct.c +++ b/lib/netfilter/ct.c @@ -27,20 +27,10 @@ #include #include #include +#include static struct nl_cache_ops nfnl_ct_ops; -#if __BYTE_ORDER == __BIG_ENDIAN -static uint64_t ntohll(uint64_t x) -{ - return x; -} -#elif __BYTE_ORDER == __LITTLE_ENDIAN -static uint64_t ntohll(uint64_t x) -{ - return bswap_64(x); -} -#endif static struct nla_policy ct_policy[CTA_MAX+1] = { [CTA_TUPLE_ORIG] = { .type = NLA_NESTED }, diff --git a/lib/netfilter/log_msg.c b/lib/netfilter/log_msg.c index 5ffdaf8..30fb8b3 100644 --- a/lib/netfilter/log_msg.c +++ b/lib/netfilter/log_msg.c @@ -26,19 +26,7 @@ #include #include #include -#include - -#if __BYTE_ORDER == __BIG_ENDIAN -static uint64_t ntohll(uint64_t x) -{ - return x; -} -#elif __BYTE_ORDER == __LITTLE_ENDIAN -static uint64_t ntohll(uint64_t x) -{ - return bswap_64(x); -} -#endif +#include static struct nla_policy log_msg_policy[NFULA_MAX+1] = { [NFULA_PACKET_HDR] = { diff --git a/lib/netfilter/queue_msg.c b/lib/netfilter/queue_msg.c index 3388923..1947ab7 100644 --- a/lib/netfilter/queue_msg.c +++ b/lib/netfilter/queue_msg.c @@ -24,22 +24,10 @@ #include #include #include -#include +#include static struct nl_cache_ops nfnl_queue_msg_ops; -#if __BYTE_ORDER == __BIG_ENDIAN -static uint64_t ntohll(uint64_t x) -{ - return x; -} -#elif __BYTE_ORDER == __LITTLE_ENDIAN -static uint64_t ntohll(uint64_t x) -{ - return bswap_64(x); -} -#endif - static struct nla_policy queue_policy[NFQA_MAX+1] = { [NFQA_PACKET_HDR] = { .minlen = sizeof(struct nfqnl_msg_packet_hdr), diff --git a/lib/route/link/macsec.c b/lib/route/link/macsec.c index b43f176..186e8d1 100644 --- a/lib/route/link/macsec.c +++ b/lib/route/link/macsec.c @@ -16,24 +16,10 @@ #include #include #include +#include #include -#include - -#if __BYTE_ORDER == __BIG_ENDIAN -static uint64_t ntohll(uint64_t x) -{ - return x; -} -#elif __BYTE_ORDER == __LITTLE_ENDIAN -static uint64_t ntohll(uint64_t x) -{ - return bswap_64(x); -} -#endif -#define htonll(x) ntohll(x) - #define MACSEC_ATTR_SCI (1 << 0) #define MACSEC_ATTR_ICV_LEN (1 << 1) #define MACSEC_ATTR_CIPHER_SUITE (1 << 2)