@@ -13,6 +13,27 @@
#include <linux/netconf.h>
#include <arpa/inet.h>
+static inline uint64_t
+htonll(uint64_t x)
+{
+ if (1 == htonl(1)) /* is this a big endian cpu? */
+ return x;
+ else
+ return ((uint64_t)htonl(x & 0xFFFFFFFF) << 32) |
+ (htonl(x >> 32));
+}
+
+static inline uint64_t
+ntohll(uint64_t x)
+{
+ if (1 == ntohl(1)) /* is this a big endian cpu? */
+ return x;
+ else
+ return ((uint64_t)ntohl(x & 0xFFFFFFFF) << 32) |
+ (ntohl(x >> 32));
+}
+
+
struct rtnl_handle {
int fd;
struct sockaddr_nl local;
@@ -277,7 +298,7 @@ static inline __u64 rta_getattr_uint(const struct rtattr *rta)
static inline __be64 rta_getattr_be64(const struct rtattr *rta)
{
- return htobe64(rta_getattr_u64(rta));
+ return htonll(rta_getattr_u64(rta));
}
static inline __s32 rta_getattr_s32(const struct rtattr *rta)
@@ -303,9 +303,6 @@ unsigned int print_name_and_link(const char *fmt,
#define _textify(x) #x
#define textify(x) _textify(x)
-#define htonll(x) ((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
-#define ntohll(x) ((1==ntohl(1)) ? (x) : ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
-
extern int cmdlineno;
char *int_to_str(int val, char *buf);
The PDCP code introduced rte_getattr_be64 and that introduced a dependency on htobe64. But iproute2 already hadn htonll macro. Move the macro into an inline function in libnetlink.h Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- include/libnetlink.h | 23 ++++++++++++++++++++++- include/utils.h | 3 --- 2 files changed, 22 insertions(+), 4 deletions(-)