summaryrefslogtreecommitdiffstats
path: root/lib/sockopt.c
diff options
context:
space:
mode:
authorpaul <paul>2004-10-05 14:33:43 +0000
committerpaul <paul>2004-10-05 14:33:43 +0000
commit00324aa4ea7a610016c561f90ca4d051e8f76659 (patch)
treefc1da26f616616a17ec0cc5fe4da51fa72b3fb5d /lib/sockopt.c
parent7b53574d4487b11541c431c04307d99821950ebe (diff)
downloadquagga-00324aa4ea7a610016c561f90ca4d051e8f76659.tar.bz2
quagga-00324aa4ea7a610016c561f90ca4d051e8f76659.tar.xz
2004-10-05 Paul Jakma <paul@dishone.st>
* sockopt.{c,h}: add sockopt_iphdrincl_swab_{htosys,systoh}, functions to change byte order between system IP_HDRINCL order and host order.
Diffstat (limited to 'lib/sockopt.c')
-rw-r--r--lib/sockopt.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/sockopt.c b/lib/sockopt.c
index 1a7524b5..5936d661 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -360,3 +360,29 @@ getsockopt_ifindex (int af, struct msghdr *msgh)
return (ifindex = 0);
}
}
+
+/* swab iph between order system uses for IP_HDRINCL and host order */
+void
+sockopt_iphdrincl_swab_htosys (struct ip *iph)
+{
+ /* BSD and derived take iph in network order, except for
+ * ip_len and ip_off
+ */
+#ifndef HAVE_IP_HDRINCL_BSD_ORDER
+ iph->ip_len = htons(iph->ip_len);
+ iph->ip_off = htons(iph->ip_off);
+#endif /* HAVE_IP_HDRINCL_BSD_ORDER */
+
+ iph->ip_id = htons(iph->ip_id);
+}
+
+void
+sockopt_iphdrincl_swab_systoh (struct ip *iph)
+{
+#ifndef HAVE_IP_HDRINCL_BSD_ORDER
+ iph->ip_len = ntohs(iph->ip_len);
+ iph->ip_off = ntohs(iph->ip_off);
+#endif /* HAVE_IP_HDRINCL_BSD_ORDER */
+
+ iph->ip_id = ntohs(iph->ip_id);
+}