summaryrefslogtreecommitdiff
path: root/ares_dns.h
diff options
context:
space:
mode:
authorGisle Vanem <gvanem@broadpark.no>2005-11-12 15:15:27 +0000
committerGisle Vanem <gvanem@broadpark.no>2005-11-12 15:15:27 +0000
commitd629c2affd4bda00a09742cd1e3e0c71fb0f2d77 (patch)
tree72f137ef8cc0c40b5491fa253de6721c1a2edfd4 /ares_dns.h
parentfbb01a0ebeec7c869299d846659f74ab59113ca4 (diff)
downloadc-ares-d629c2affd4bda00a09742cd1e3e0c71fb0f2d77.tar.gz
c-ares-d629c2affd4bda00a09742cd1e3e0c71fb0f2d77.tar.bz2
c-ares-d629c2affd4bda00a09742cd1e3e0c71fb0f2d77.zip
Support big-endian machines.
Diffstat (limited to 'ares_dns.h')
-rw-r--r--ares_dns.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/ares_dns.h b/ares_dns.h
index adac9d6..3e57572 100644
--- a/ares_dns.h
+++ b/ares_dns.h
@@ -18,6 +18,7 @@
#ifndef ARES__DNS_H
#define ARES__DNS_H
+#if 0
#define DNS__16BIT(p) (((p)[0] << 8) | (p)[1])
#define DNS__32BIT(p) (((p)[0] << 24) | ((p)[1] << 16) | \
((p)[2] << 8) | (p)[3])
@@ -27,6 +28,12 @@
((p)[1] = ((v) >> 16) & 0xff), \
((p)[2] = ((v) >> 8) & 0xff), \
((p)[3] = (v) & 0xff))
+#else /* big-endian aware versions */
+#define DNS__16BIT(p) ntohs(*(unsigned short*)(p))
+#define DNS__32BIT(p) ntohl(*(unsigned long*)(p))
+#define DNS__SET16BIT(p, v) *(unsigned short*)(p) = htons(v)
+#define DNS__SET32BIT(p, v) *(unsigned long*)(p) = htonl(v)
+#endif
/* Macros for parsing a DNS header */
#define DNS_HEADER_QID(h) DNS__16BIT(h)