2004-10-11 Paul Jakma <paul@dishone.st>
* ospf_dump.c: (ospf_ip_header_dump) Assume header is in host order
remove ntohs that should have dissappeared. Take struct ip
as argument, caller has to know there's an IP header at start of
stream anyway.
* ospf_dump.h: update declaration of ospf_ip_header_dump.
* ospf_packet.c: (ospf_write) correct call to
sockopt_iphdrincl_swab_htosys which was munging the header.
(ospf_recv_packet) ip_len is needed for old OpenBSD fixup.
(ospf_read) sockopt_iphdrincl_swab_systoh ip header as soon as
we have it.
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 357d697..d62a06e 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -667,7 +667,7 @@
/* send final fragment (could be first) */
sockopt_iphdrincl_swab_htosys (&iph);
ret = sendmsg (ospf->fd, &msg, flags);
- sockopt_iphdrincl_swab_htosys (&iph);
+ sockopt_iphdrincl_swab_systoh (&iph);
if (ret < 0)
zlog_warn ("*** sendmsg in ospf_write to %s failed with %s",
@@ -2015,6 +2015,8 @@
sockopt_iphdrincl_swab_systoh (&iph);
+ ip_len = iph.ip_len;
+
#if !defined(GNU_LINUX) && (OpenBSD < 200311)
/*
* Kernel network code touches incoming IP header parameters,
@@ -2306,13 +2308,14 @@
}
iph = (struct ip *) STREAM_DATA (ibuf);
-
+ sockopt_iphdrincl_swab_systoh (iph);
+
/* prepare for next packet. */
ospf->t_read = thread_add_read (master, ospf_read, ospf, ospf->fd);
/* IP Header dump. */
if (IS_DEBUG_OSPF_PACKET(0, RECV))
- ospf_ip_header_dump (ibuf);
+ ospf_ip_header_dump (iph);
/* Self-originated packet should be discarded silently. */
if (ospf_if_lookup_by_local_addr (ospf, NULL, iph->ip_src))