summaryrefslogtreecommitdiff
path: root/ospfd
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ChangeLog13
-rw-r--r--ospfd/ospf_dump.c17
-rw-r--r--ospfd/ospf_dump.h2
-rw-r--r--ospfd/ospf_packet.c9
4 files changed, 25 insertions, 16 deletions
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index f326f72f..34bf6405 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,3 +1,16 @@
+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.
+
2004-10-08 Hasso Tepper <hasso at quagga.net>
* *.[c|h]: Fix compiler warnings: make some strings const, signed ->
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c
index e34f3f62..e3ca1a02 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -599,27 +599,20 @@ ospf_packet_ls_ack_dump (struct stream *s, u_int16_t length)
stream_set_getp (s, sp);
}
+/* Expects header to be in host order */
void
-ospf_ip_header_dump (struct stream *s)
+ospf_ip_header_dump (struct ip *iph)
{
- u_int16_t length;
- u_int16_t offset;
- struct ip *iph;
-
- iph = (struct ip *) STREAM_PNT (s);
-
- sockopt_iphdrincl_swab_systoh (iph);
-
/* IP Header dump. */
zlog_info ("ip_v %d", iph->ip_v);
zlog_info ("ip_hl %d", iph->ip_hl);
zlog_info ("ip_tos %d", iph->ip_tos);
- zlog_info ("ip_len %d", length);
+ zlog_info ("ip_len %d", iph->ip_len);
zlog_info ("ip_id %u", (u_int32_t) iph->ip_id);
- zlog_info ("ip_off %u", (u_int32_t) offset);
+ zlog_info ("ip_off %u", (u_int32_t) iph->ip_off);
zlog_info ("ip_ttl %d", iph->ip_ttl);
zlog_info ("ip_p %d", iph->ip_p);
- zlog_info ("ip_sum 0x%x", (u_int32_t) ntohs (iph->ip_sum));
+ zlog_info ("ip_sum 0x%x", (u_int32_t) iph->ip_sum);
zlog_info ("ip_src %s", inet_ntoa (iph->ip_src));
zlog_info ("ip_dst %s", inet_ntoa (iph->ip_dst));
}
diff --git a/ospfd/ospf_dump.h b/ospfd/ospf_dump.h
index 5f625ca8..50e61e62 100644
--- a/ospfd/ospf_dump.h
+++ b/ospfd/ospf_dump.h
@@ -131,7 +131,7 @@ const char *ospf_if_name_string (struct ospf_interface *);
void ospf_nbr_state_message (struct ospf_neighbor *, char *, size_t);
char *ospf_options_dump (u_char);
const char *ospf_timer_dump (struct thread *, char *, size_t);
-void ospf_ip_header_dump (struct stream *);
+void ospf_ip_header_dump (struct ip *);
void ospf_packet_dump (struct stream *);
void ospf_lsa_header_dump (struct lsa_header *);
void debug_init ();
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 357d697f..d62a06ed 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -667,7 +667,7 @@ ospf_write (struct thread *thread)
/* 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 @@ ospf_recv_packet (int fd, struct interface **ifp)
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 @@ ospf_read (struct thread *thread)
}
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))