]> granicus.if.org Git - libnl/commitdiff
remove multiple implementations of htonll(), ntohll()
authorDavide Caratti <davide.caratti@gmail.com>
Tue, 6 Sep 2016 09:17:47 +0000 (11:17 +0200)
committerDavide Caratti <davide.caratti@gmail.com>
Tue, 6 Sep 2016 09:21:48 +0000 (11:21 +0200)
use a single #define in include/netlink-private/utils.h

Signed-off-by: Davide Caratti <davide.caratti@gmail.com>
include/netlink-private/utils.h
lib/netfilter/ct.c
lib/netfilter/log_msg.c
lib/netfilter/queue_msg.c
lib/route/link/macsec.c

index 77aadb3b465587dd9c14489e37926aa589fabfaa..d9c55d013d1760ab9d14429e0cea4ff580e9c47e 100644 (file)
 #ifndef NETLINK_UTILS_PRIV_H_
 #define NETLINK_UTILS_PRIV_H_
 
+#include <byteswap.h>
+#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
index 62ee77f3b5144d245ad58fc7e4c3393de7d3d879..1b29cf6f80903f5045ebf37c0a44cc04cc70ff5b 100644 (file)
 #include <netlink/attr.h>
 #include <netlink/netfilter/nfnl.h>
 #include <netlink/netfilter/ct.h>
+#include <netlink-private/utils.h>
 
 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 },
index 5ffdaf80e0edf0dc88873bc369d87119f5448cbb..30fb8b32db077d18eaa08aac0e477bacfce6bace 100644 (file)
 #include <netlink/attr.h>
 #include <netlink/netfilter/nfnl.h>
 #include <netlink/netfilter/log_msg.h>
-#include <byteswap.h>
-
-#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 <netlink-private/utils.h>
 
 static struct nla_policy log_msg_policy[NFULA_MAX+1] = {
        [NFULA_PACKET_HDR]              = {
index 338892333fb8104014ae5d32bf80393f264fae2b..1947ab7b63503a54fc97fc76d2b76d7d6b8c54a5 100644 (file)
 #include <netlink/attr.h>
 #include <netlink/netfilter/nfnl.h>
 #include <netlink/netfilter/queue_msg.h>
-#include <byteswap.h>
+#include <netlink-private/utils.h>
 
 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),
index b43f1767285b89f77336eac51417cdc404207e3a..186e8d125afeb39b5aa740f4fc18d8a79a9aa698 100644 (file)
 #include <netlink/object.h>
 #include <netlink/route/rtnl.h>
 #include <netlink-private/route/link/api.h>
+#include <netlink-private/utils.h>
 
 #include <linux/if_macsec.h>
 
-#include <byteswap.h>
-
-#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)