2004-10-05 Paul Jakma <paul@dishone.st>

	* ospf_packet.c: replace ospf_swap_iph_to... with
          sockopt_iphdrincl_swab_...
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 2043ad6..27d72d6 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-05 Paul Jakma <paul@dishone.st>
+
+	* ospf_packet.c: replace ospf_swap_iph_to... with
+          sockopt_iphdrincl_swab_...
+
 2004-10-03 James R. Leu <jleu at mindspring.com>
 
 	* ospf_zebra.c: Read router id related messages from zebra daemon.
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c
index 248cfbb..25cb525 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -607,14 +607,8 @@
 
   iph = (struct ip *) STREAM_PNT (s);
 
-#ifdef HAVE_IP_HDRINCL_BSD_ORDER
-  length = iph->ip_len;
-  offset = iph->ip_off;
-#else /* !HAVE_IP_HDRINCL_BSD_ORDER */
-  length = ntohs (iph->ip_len);
-  offset = ntohs (iph->ip_off);
-#endif /* HAVE_IP_HDRINCL_BSD_ORDER */
-
+  sockopt_iphdrincl_swab_systoh (iph);
+  
   /* IP Header dump. */
   zlog_info ("ip_v %d", iph->ip_v);
   zlog_info ("ip_hl %d", iph->ip_hl);
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index eaf8b76..f1cb91d 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -482,33 +482,6 @@
   return 0;
 }
 
-/* swab ip header fields to required order for sendmsg */
-void
-ospf_swab_iph_ton (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);
-}
-
-/* swab ip header fields to host order, as required */
-void
-ospf_swab_iph_toh (struct ip *iph)
-{
-#ifdef 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);
-}
-
 #ifdef WANT_OSPF_WRITE_FRAGMENT
 void
 ospf_write_frags (int fd, struct ospf_packet *op, struct ip *iph, 
@@ -549,11 +522,11 @@
       iph->ip_len = iov[1]->iov_len + sizeof (struct ip);
       assert (iph->ip_len <= mtu);
 
-      ospf_swab_iph_ton (iph);
+      sockopt_iphdrincl_swab_htosys (iph);
 
       ret = sendmsg (fd, msg, flags);
       
-      ospf_swab_iph_toh (iph);
+      sockopt_iphdrincl_swab_systoh (iph);
       
       if (ret < 0)
         zlog_warn ("*** sendmsg in ospf_write to %s,"
@@ -692,9 +665,9 @@
 #endif /* WANT_OSPF_WRITE_FRAGMENT */
 
   /* send final fragment (could be first) */
-  ospf_swab_iph_ton (&iph);
+  sockopt_iphdrincl_swab_htosys (&iph);
   ret = sendmsg (ospf->fd, &msg, flags);
-  ospf_swab_iph_toh (&iph);
+  sockopt_iphdrincl_swab_htosys (&iph);
   
   if (ret < 0)
     zlog_warn ("*** sendmsg in ospf_write to %s failed with %s",
@@ -2040,13 +2013,9 @@
       zlog_warn ("ospf_recv_packet packet smaller than ip header");
       return NULL;
     }
-
-#ifdef HAVE_IP_HDRINCL_BSD_ORDER
-  ip_len = iph.ip_len;
-#else
-  ip_len = ntohs (iph.ip_len);
-#endif
-
+  
+  sockopt_iphdrincl_swab_systoh (&iph);
+  
 #if !defined(GNU_LINUX) && (OpenBSD < 200311)
   /*
    * Kernel network code touches incoming IP header parameters,