summaryrefslogtreecommitdiff
path: root/ospfd
diff options
context:
space:
mode:
authorpaul <paul>2004-09-27 12:56:30 +0000
committerpaul <paul>2004-09-27 12:56:30 +0000
commit6a99f83175d7b5b5868fb82328d569672b8bb9a4 (patch)
tree447f98abc31a7260bb2b354809312e4e6fdfda96 /ospfd
parent9172ee0e5dc8c6f6929821fb1433699700e53114 (diff)
2004-09-27 Paul Jakma <paul@dishone.st>
* ospf_dump.c: (ospf_ip_header_dump) Use HAVE_IP_HDRINCL_BSD_ORDER Apply to offset too. Print ip_cksum, lets not worry about possible 2.0.37 compile problems. * ospf_packet.c: (ospf_swap_iph_to{n,h}) Use HAVE_IP_HDRINCL_BSD_ORDER. (ospf_recv_packet) ditto. (ospf_write) Fixup iov argument to ospf_write_frags.
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ChangeLog10
-rw-r--r--ospfd/ospf_dump.c17
-rw-r--r--ospfd/ospf_packet.c33
3 files changed, 38 insertions, 22 deletions
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 3724e360..6e1a8646 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,7 +1,13 @@
2004-09-27 Paul Jakma <paul@dishone.st>
- * ospf_packet.c: (ospf_write) (struct msghdr).msg_name is caddr_t
- on most platforms.
+ * ospf_dump.c: (ospf_ip_header_dump) Use HAVE_IP_HDRINCL_BSD_ORDER
+ Apply to offset too. Print ip_cksum, lets not worry about
+ possible 2.0.37 compile problems.
+ * ospf_packet.c: (ospf_swap_iph_to{n,h}) Use
+ HAVE_IP_HDRINCL_BSD_ORDER.
+ (ospf_recv_packet) ditto.
+ (ospf_write) Fixup iov argument to ospf_write_frags.
+ (struct msghdr).msg_name is caddr_t on most platforms.
(ospf_recv_packet) ditto. And msg_flags is not always there
memset struct then set fields we care about rather than
initialise all fields individually.
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c
index 958baa40..248cfbbc 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -602,15 +602,18 @@ void
ospf_ip_header_dump (struct stream *s)
{
u_int16_t length;
+ u_int16_t offset;
struct ip *iph;
iph = (struct ip *) STREAM_PNT (s);
-#ifdef GNU_LINUX
- length = ntohs (iph->ip_len);
-#else /* GNU_LINUX */
+#ifdef HAVE_IP_HDRINCL_BSD_ORDER
length = iph->ip_len;
-#endif /* GNU_LINUX */
+ 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 */
/* IP Header dump. */
zlog_info ("ip_v %d", iph->ip_v);
@@ -618,12 +621,10 @@ ospf_ip_header_dump (struct stream *s)
zlog_info ("ip_tos %d", iph->ip_tos);
zlog_info ("ip_len %d", length);
zlog_info ("ip_id %u", (u_int32_t) iph->ip_id);
- zlog_info ("ip_off %u", (u_int32_t) iph->ip_off);
+ zlog_info ("ip_off %u", (u_int32_t) offset);
zlog_info ("ip_ttl %d", iph->ip_ttl);
zlog_info ("ip_p %d", iph->ip_p);
- /* There is a report that Linux 2.0.37 does not have ip_sum. But
- I'm not sure. Temporary commented out by kunihiro. */
- /* zlog_info ("ip_sum 0x%x", (u_int32_t) ntohs (iph->ip_sum)); */
+ zlog_info ("ip_sum 0x%x", (u_int32_t) ntohs (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_packet.c b/ospfd/ospf_packet.c
index c362b9fd..eaf8b769 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -489,10 +489,11 @@ ospf_swab_iph_ton (struct ip *iph)
/* BSD and derived take iph in network order, except for
* ip_len and ip_off
*/
-#ifdef GNU_LINUX
+#ifndef HAVE_IP_HDRINCL_BSD_ORDER
iph->ip_len = htons(iph->ip_len);
iph->ip_off = htons(iph->ip_off);
-#endif
+#endif /* HAVE_IP_HDRINCL_BSD_ORDER */
+
iph->ip_id = htons(iph->ip_id);
}
@@ -500,19 +501,23 @@ ospf_swab_iph_ton (struct ip *iph)
void
ospf_swab_iph_toh (struct ip *iph)
{
-#ifdef GNU_LINUX
+#ifdef HAVE_IP_HDRINCL_BSD_ORDER
iph->ip_len = ntohs(iph->ip_len);
iph->ip_off = ntohs(iph->ip_off);
-#endif
+#endif /* HAVE_IP_HDRINCL_BSD_ORDER */
+
iph->ip_id = ntohs(iph->ip_id);
}
#ifdef WANT_OSPF_WRITE_FRAGMENT
void
-ospf_write_frags (struct ospf_packet *op, struct ip *ip, struct msghdr *msg,
- struct iovec *iov, int maxdatasize);
+ospf_write_frags (int fd, struct ospf_packet *op, struct ip *iph,
+ struct msghdr *msg, struct iovec **iov,
+ int maxdatasize, int mtu, int flags)
{
#define OSPF_WRITE_FRAG_SHIFT 3
+ u_int16_t offset;
+ int ret;
assert ( op->length == stream_get_endp(op->s) );
@@ -542,11 +547,11 @@ ospf_write_frags (struct ospf_packet *op, struct ip *ip, struct msghdr *msg,
/* data length of this frag is to next offset value */
iov[1]->iov_len = offset << OSPF_WRITE_FRAG_SHIFT;
iph->ip_len = iov[1]->iov_len + sizeof (struct ip);
- assert (iph->ip_len <= oi->ifp->mtu);
+ assert (iph->ip_len <= mtu);
ospf_swab_iph_ton (iph);
- ret = sendmsg (ospf->fd, msg, flags);
+ ret = sendmsg (fd, msg, flags);
ospf_swab_iph_toh (iph);
@@ -580,7 +585,7 @@ ospf_write (struct thread *thread)
struct sockaddr_in sa_dst;
struct ip iph;
struct msghdr msg;
- struct iovec iov[2];
+ struct iovec iov[2], *iovp;
u_char type;
int ret;
int flags = 0;
@@ -588,7 +593,7 @@ ospf_write (struct thread *thread)
#ifdef WANT_OSPF_WRITE_FRAGMENT
static u_int16_t ipid = 0;
#endif /* WANT_OSPF_WRITE_FRAGMENT */
- u_int16_t maxdatasize, offset;
+ u_int16_t maxdatasize;
#define OSPF_WRITE_IPHL_SHIFT 2
ospf->t_write = NULL;
@@ -679,7 +684,11 @@ ospf_write (struct thread *thread)
*/
#ifdef WANT_OSPF_WRITE_FRAGMENT
if ( op->length > maxdatasize )
- ospf_write_frags (&op, &ip, &msg, &iov, maxdatasize);
+ {
+ iovp = iov;
+ ospf_write_frags (ospf->fd, op, &iph, &msg, &iovp, maxdatasize,
+ oi->ifp->mtu, flags);
+ }
#endif /* WANT_OSPF_WRITE_FRAGMENT */
/* send final fragment (could be first) */
@@ -2032,7 +2041,7 @@ ospf_recv_packet (int fd, struct interface **ifp)
return NULL;
}
-#if defined(__NetBSD__) || defined(__FreeBSD__) || (defined(__OpenBSD__) && (OpenBSD < 200311))
+#ifdef HAVE_IP_HDRINCL_BSD_ORDER
ip_len = iph.ip_len;
#else
ip_len = ntohs (iph.ip_len);