]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add a macro version of htonl(3).
authorRoy Marples <roy@marples.name>
Fri, 12 Jun 2015 20:25:04 +0000 (20:25 +0000)
committerRoy Marples <roy@marples.name>
Fri, 12 Jun 2015 20:25:04 +0000 (20:25 +0000)
ipv4.h

diff --git a/ipv4.h b/ipv4.h
index 83ef4a83382af6e34e4427beb32b9d3209c0d2c8..fa5589608c1ac7f2080ae3f9117f2f05e18e6993 100644 (file)
--- a/ipv4.h
+++ b/ipv4.h
         (IN_IFF_TENTATIVE | IN_IFF_DUPLICATED | IN_IFF_DETACHED)
 #endif
 
+#ifndef HTONL
+#if BYTE_ORDER == BIG_ENDIAN
+#define HTONL(A) (A)
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define HTONL(A) \
+    ((((uint32_t)(A) & 0xff000000) >> 24) | \
+    (((uint32_t)(A) & 0x00ff0000) >> 8) | \
+    (((uint32_t)(A) & 0x0000ff00) << 8) | \
+    (((uint32_t)(A) & 0x000000ff) << 24))
+#endif
+#else
+#error Endian unknown
+#endif /* HTONL */
+
 struct rt {
        TAILQ_ENTRY(rt) next;
        struct in_addr dest;