From 18b12c387e2bcd8a0e81a8d2635c1ef52c8a9a7d Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 5 Oct 2004 14:38:29 +0000 Subject: 2004-10-05 Paul Jakma * ospf_packet.c: replace ospf_swap_iph_to... with sockopt_iphdrincl_swab_... --- ospfd/ChangeLog | 5 +++++ ospfd/ospf_dump.c | 10 ++-------- ospfd/ospf_packet.c | 45 +++++++-------------------------------------- 3 files changed, 14 insertions(+), 46 deletions(-) (limited to 'ospfd') diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog index 2043ad61..27d72d6b 100644 --- a/ospfd/ChangeLog +++ b/ospfd/ChangeLog @@ -1,3 +1,8 @@ +2004-10-05 Paul Jakma + + * ospf_packet.c: replace ospf_swap_iph_to... with + sockopt_iphdrincl_swab_... + 2004-10-03 James R. Leu * ospf_zebra.c: Read router id related messages from zebra daemon. diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 248cfbbc..25cb525d 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -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); diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index eaf8b769..f1cb91d7 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -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, -- cgit v1.2.1