From: Roy Marples Date: Fri, 12 Jun 2015 20:25:04 +0000 (+0000) Subject: Add a macro version of htonl(3). X-Git-Tag: v6.9.1~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e30df8ca83123cef41b7cbf50f8b965eaf47fcb6;p=thirdparty%2Fdhcpcd.git Add a macro version of htonl(3). --- diff --git a/ipv4.h b/ipv4.h index 83ef4a83..fa558960 100644 --- a/ipv4.h +++ b/ipv4.h @@ -35,6 +35,20 @@ (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;