]> git.puffer.fish Git - matthieu/frr.git/commitdiff
2004-10-05 Paul Jakma <paul@dishone.st>
authorpaul <paul>
Tue, 5 Oct 2004 14:38:29 +0000 (14:38 +0000)
committerpaul <paul>
Tue, 5 Oct 2004 14:38:29 +0000 (14:38 +0000)
* ospf_packet.c: replace ospf_swap_iph_to... with
          sockopt_iphdrincl_swab_...

ospfd/ChangeLog
ospfd/ospf_dump.c
ospfd/ospf_packet.c

index 2043ad6148f8a9783a2588095d09e310348a4d2b..27d72d6b1b69c6a1735462cb87bb5e3e420ed789 100644 (file)
@@ -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.
index 248cfbbc628d806c262ab4c62d0982d91336ee4e..25cb525d9f8ac2a7250ef421cedc9a549d8d9457 100644 (file)
@@ -607,14 +607,8 @@ ospf_ip_header_dump (struct stream *s)
 
   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);
index eaf8b76979be0ec0a47f957a1516f9c5ebe612e0..f1cb91d7d4bdfe21708088b9276a4feed11350d9 100644 (file)
@@ -482,33 +482,6 @@ ospf_ls_ack_timer (struct thread *thread)
   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 @@ ospf_write_frags (int fd, struct ospf_packet *op, struct ip *iph,
       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 @@ ospf_write (struct thread *thread)
 #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 @@ ospf_recv_packet (int fd, struct interface **ifp)
       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,