]> git.proxmox.com Git - mirror_frr.git/commitdiff
2004-10-05 Paul Jakma <paul@dishone.st>
authorpaul <paul>
Tue, 5 Oct 2004 14:33:43 +0000 (14:33 +0000)
committerpaul <paul>
Tue, 5 Oct 2004 14:33:43 +0000 (14:33 +0000)
* sockopt.{c,h}: add sockopt_iphdrincl_swab_{htosys,systoh},
          functions to change byte order between system IP_HDRINCL order
          and host order.

lib/ChangeLog
lib/sockopt.c
lib/sockopt.h

index eec006c953e9b73c2070d326b65d13d8e1520e98..2bbda12be3a949f263f6ec3f004844f5e581682e 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2004-10-04 Hasso Tepper <hasso at quagga.net>
 
        * memory.c, memory.h: Make char * argument of strdup functions const.
index 1a7524b5dccdb8e23fe7c96c3f281ab6189f63dd..5936d6610ea5bddacea02ce3d21a7b8c7c66df76 100644 (file)
@@ -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);
+}
index 3f4a7050cbd6680f2354c0345b53c96f0c4f92ba..f6a43158eba996cd0bef59b944118028da140c12 100644 (file)
@@ -92,4 +92,11 @@ int setsockopt_pktinfo (int, int, int);
 /* Ask for, and get, ifindex, by whatever method is supported. */
 int setsockopt_ifindex (int, int, int);
 int getsockopt_ifindex (int, struct msghdr *);
+
+/* swab the fields in iph between the host order and system order expected 
+ * for IP_HDRINCL.
+ */
+void sockopt_iphdrincl_swab_htosys (struct ip *iph);
+void sockopt_iphdrincl_swab_systoh (struct ip *iph);
+
 #endif /*_ZEBRA_SOCKOPT_H */