summaryrefslogtreecommitdiff
path: root/utils.h
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-16 00:00:01 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-16 00:00:01 +0200
commitac2754e0eb9862081e00e5ae886783db08541944 (patch)
treec193a9cb77751d63af3db214d4ffb740daa317ef /utils.h
parent4492ad9328e59edc4c8d3db8cd881941b7903741 (diff)
Add working igmp implementation
Diffstat (limited to 'utils.h')
-rw-r--r--utils.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/utils.h b/utils.h
index 8317e22..48faef4 100644
--- a/utils.h
+++ b/utils.h
@@ -77,6 +77,18 @@ static inline bool empty_str(const char *str)
return false;
}
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define chtobe32(x) __bswap_constant_32(x)
+#else
+#define chtobe32(x) (x)
+#endif
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define cinet_addr(a,b,c,d) ((uint32_t)((a)<<0|(b)<<8|(c)<<16|(d)<<24))
+#else
+#define cinet_addr(a,b,c,d) ((uint32_t)((a)<<24|(b)<<16|(c)<<8|(d)<<0))
+#endif
+
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)