summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2008-12-28 20:08:32 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2008-12-28 20:08:32 +0000
commit5738404fe5b15b22843f21e01b938a6680cee90a (patch)
treea151f39d1ba4c2f9b0c6c4e1e54f16e2f437c397
parent35eb64bb541de813192e9fb9e814f9dc16a4cba4 (diff)
area_ospf_options() should not return network byte order options. Instead
the callers should take care of getting the byte order right. While there remove the opts[123] from the hello_hdr and use LSA_24_* to handle this nasty fields instead. Now router LSA have the correct flags set.
-rw-r--r--usr.sbin/ospf6d/area.c4
-rw-r--r--usr.sbin/ospf6d/database.c5
-rw-r--r--usr.sbin/ospf6d/hello.c29
-rw-r--r--usr.sbin/ospf6d/ospf6.h7
-rw-r--r--usr.sbin/ospf6d/ospfe.c3
5 files changed, 23 insertions, 25 deletions
diff --git a/usr.sbin/ospf6d/area.c b/usr.sbin/ospf6d/area.c
index 3ea0943cf2e..257fc43e637 100644
--- a/usr.sbin/ospf6d/area.c
+++ b/usr.sbin/ospf6d/area.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: area.c,v 1.3 2007/10/11 19:06:41 claudio Exp $ */
+/* $OpenBSD: area.c,v 1.4 2008/12/28 20:08:31 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
@@ -124,5 +124,5 @@ area_ospf_options(struct area *area)
if (area && !area->stub)
opt |= OSPF_OPTION_E;
- return (htonl(opt));
+ return opt;
}
diff --git a/usr.sbin/ospf6d/database.c b/usr.sbin/ospf6d/database.c
index 5000a2f7007..20c818eb55f 100644
--- a/usr.sbin/ospf6d/database.c
+++ b/usr.sbin/ospf6d/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.8 2008/12/28 17:44:45 claudio Exp $ */
+/* $OpenBSD: database.c,v 1.9 2008/12/28 20:08:31 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -136,7 +136,8 @@ send_db_description(struct nbr *nbr)
fatalx("send_db_description: unknown interface type");
}
- dd_hdr.opts = area_ospf_options(area_find(oeconf, nbr->iface->area_id));
+ dd_hdr.opts = htonl(area_ospf_options(area_find(oeconf,
+ nbr->iface->area_id)));
dd_hdr.bits = bits;
dd_hdr.dd_seq_num = htonl(nbr->dd_seq_num);
diff --git a/usr.sbin/ospf6d/hello.c b/usr.sbin/ospf6d/hello.c
index b4037c5ba5a..56fd8c8dd3f 100644
--- a/usr.sbin/ospf6d/hello.c
+++ b/usr.sbin/ospf6d/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.10 2008/12/28 17:56:16 claudio Exp $ */
+/* $OpenBSD: hello.c,v 1.11 2008/12/28 20:08:31 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -72,12 +72,10 @@ send_hello(struct iface *iface)
/* hello header */
hello.iface_id = htonl(iface->ifindex);
- hello.rtr_priority = iface->priority;
-
- opts = ntohl(area_ospf_options(area_find(oeconf, iface->area_id)));
- hello.opts1 = (opts >> 16) & 0xff;
- hello.opts2 = (opts >> 8) & 0xff;
- hello.opts3 = opts & 0xff;
+ LSA_24_SETHI(hello.opts, iface->priority);
+ opts = area_ospf_options(area_find(oeconf, iface->area_id));
+ LSA_24_SETLO(hello.opts, opts);
+ hello.opts = htonl(hello.opts);
hello.hello_interval = htons(iface->hello_interval);
hello.rtr_dead_interval = htons(iface->dead_interval);
@@ -124,7 +122,7 @@ recv_hello(struct iface *iface, struct in6_addr *src, u_int32_t rtr_id,
struct hello_hdr hello;
struct nbr *nbr = NULL, *dr;
struct area *area;
- u_int32_t nbr_id;
+ u_int32_t nbr_id, opts;
int nbr_change = 0;
if (len < sizeof(hello) && (len & 0x03)) {
@@ -154,8 +152,9 @@ recv_hello(struct iface *iface, struct in6_addr *src, u_int32_t rtr_id,
if ((area = area_find(oeconf, iface->area_id)) == NULL)
fatalx("interface lost area");
- if ((hello.opts3 & OSPF_OPTION_E && area->stub) || /* XXX */
- ((hello.opts3 & OSPF_OPTION_E) == 0 && !area->stub)) { /* XXX */
+ opts = LSA_24_GETLO(ntohl(hello.opts));
+ if ((opts & OSPF_OPTION_E && area->stub) ||
+ ((opts & OSPF_OPTION_E) == 0 && !area->stub)) {
log_warnx("recv_hello: ExternalRoutingCapability mismatch, "
"interface %s", iface->name);
return;
@@ -192,13 +191,13 @@ recv_hello(struct iface *iface, struct in6_addr *src, u_int32_t rtr_id,
/* set neighbor parameters */
nbr->dr.s_addr = hello.d_rtr;
nbr->bdr.s_addr = hello.bd_rtr;
- nbr->priority = hello.rtr_priority;
+ nbr->priority = LSA_24_GETHI(ntohl(hello.opts));
nbr_change = 1;
}
/* actually the neighbor address shouldn't be stored on virtual links */
nbr->addr = *src;
- nbr->options = (hello.opts1 << 16) | (hello.opts2 << 8) | hello.opts3;
+ nbr->options = opts;
nbr_fsm(nbr, NBR_EVT_HELLO_RCVD);
@@ -219,13 +218,13 @@ recv_hello(struct iface *iface, struct in6_addr *src, u_int32_t rtr_id,
/* set neighbor parameters */
nbr->dr.s_addr = hello.d_rtr;
nbr->bdr.s_addr = hello.bd_rtr;
- nbr->priority = hello.rtr_priority;
+ nbr->priority = LSA_24_GETHI(ntohl(hello.opts));
nbr->iface_id = ntohl(hello.iface_id);
return;
}
- if (nbr->priority != hello.rtr_priority) {
- nbr->priority = hello.rtr_priority;
+ if (nbr->priority != LSA_24_GETHI(ntohl(hello.opts))) {
+ nbr->priority = LSA_24_GETHI(ntohl(hello.opts));
nbr_change = 1;
}
diff --git a/usr.sbin/ospf6d/ospf6.h b/usr.sbin/ospf6d/ospf6.h
index c6f4623953c..c233f6b3af9 100644
--- a/usr.sbin/ospf6d/ospf6.h
+++ b/usr.sbin/ospf6d/ospf6.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6.h,v 1.9 2008/12/28 18:30:55 claudio Exp $ */
+/* $OpenBSD: ospf6.h,v 1.10 2008/12/28 20:08:31 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
@@ -118,10 +118,7 @@ struct ospf_hdr {
/* Hello header (type 1) */
struct hello_hdr {
u_int32_t iface_id;
- u_int8_t rtr_priority;
- u_int8_t opts1;
- u_int8_t opts2;
- u_int8_t opts3;
+ u_int32_t opts; /* 8bit rtr_priority + 24bits options */
u_int16_t hello_interval;
u_int16_t rtr_dead_interval;
u_int32_t d_rtr;
diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c
index d9b5748a21c..3fbd29d8a76 100644
--- a/usr.sbin/ospf6d/ospfe.c
+++ b/usr.sbin/ospf6d/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.9 2008/12/28 19:36:44 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.10 2008/12/28 20:08:31 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -887,6 +887,7 @@ orig_rtr_lsa_area(struct area *area)
LSA_24_SETLO(lsa_rtr.opts, area_ospf_options(area));
LSA_24_SETHI(lsa_rtr.opts, flags);
+ lsa_rtr.opts = htonl(lsa_rtr.opts);
memcpy(buf_seek(buf, sizeof(lsa_hdr), sizeof(lsa_rtr)),
&lsa_rtr, sizeof(lsa_rtr));