Common router id.
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 6e1a864..2043ad6 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,3 +1,10 @@
+2004-10-03 James R. Leu <jleu at mindspring.com>
+
+ * ospf_zebra.c: Read router id related messages from zebra daemon.
+ Schedule router-id update thread if it's changed.
+ * ospfd.c: Remove own router-id selection function. Use router id from
+ zebra daemon if it isn't manually overriden in configuration.
+
2004-09-27 Paul Jakma <paul@dishone.st>
* ospf_dump.c: (ospf_ip_header_dump) Use HAVE_IP_HDRINCL_BSD_ORDER
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 6a675a5..3172ebc 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -54,6 +54,28 @@
/* For registering threads. */
extern struct thread_master *master;
+struct in_addr router_id_zebra;
+
+/* Router-id update message from zebra. */
+int
+ospf_router_id_update_zebra (int command, struct zclient *zclient,
+ zebra_size_t length)
+{
+ struct ospf *ospf;
+ struct prefix router_id;
+ zebra_router_id_update_read(zclient->ibuf,&router_id);
+
+ router_id_zebra = router_id.u.prefix4;
+
+ ospf = ospf_lookup ();
+ if (ospf != NULL)
+ {
+ if (ospf->t_router_id_update == NULL)
+ OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
+ OSPF_ROUTER_ID_UPDATE_DELAY);
+ }
+ return 0;
+}
/* Inteface addition message from zebra. */
int
@@ -148,20 +170,6 @@
return ifp;
}
-void
-zebra_interface_if_set_value (struct stream *s, struct interface *ifp)
-{
- /* Read interface's index. */
- ifp->ifindex = stream_getl (s);
-
- /* Read interface's value. */
- ifp->status = stream_getc (s);
- ifp->flags = stream_getl (s);
- ifp->metric = stream_getl (s);
- ifp->mtu = stream_getl (s);
- ifp->bandwidth = stream_getl (s);
-}
-
int
ospf_interface_state_up (int command, struct zclient *zclient,
zebra_size_t length)
@@ -1248,6 +1256,7 @@
/* Allocate zebra structure. */
zclient = zclient_new ();
zclient_init (zclient, ZEBRA_ROUTE_OSPF);
+ zclient->router_id_update = ospf_router_id_update_zebra;
zclient->interface_add = ospf_interface_add;
zclient->interface_delete = ospf_interface_delete;
zclient->interface_up = ospf_interface_state_up;
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index bfde503..6c6dd8d 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -61,6 +61,7 @@
struct ospf_master *om;
extern struct zclient *zclient;
+extern struct in_addr router_id_zebra;
void ospf_remove_vls_through_area (struct ospf *, struct ospf_area *);
@@ -68,33 +69,6 @@
void ospf_area_free (struct ospf_area *);
void ospf_network_run (struct ospf *, struct prefix *, struct ospf_area *);
-/* Get Router ID from ospf interface list. */
-struct in_addr
-ospf_router_id_get (struct list *if_list)
-{
- struct listnode *node;
- struct in_addr router_id;
-
- memset (&router_id, 0, sizeof (struct in_addr));
-
- for (node = listhead (if_list); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
-
- if (!if_is_up (oi->ifp) ||
- OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_PASSIVE)
- continue;
-
- /* Ignore virtual link interface. */
- if (oi->type != OSPF_IFTYPE_VIRTUALLINK &&
- oi->type != OSPF_IFTYPE_LOOPBACK)
- if (IPV4_ADDR_CMP (&router_id, &oi->address->u.prefix4) < 0)
- router_id = oi->address->u.prefix4;
- }
-
- return router_id;
-}
-
#define OSPF_EXTERNAL_LSA_ORIGINATE_DELAY 1
void
@@ -111,7 +85,7 @@
if (ospf->router_id_static.s_addr != 0)
router_id = ospf->router_id_static;
else
- router_id = ospf_router_id_get (ospf->oiflist);
+ router_id = router_id_zebra;
ospf->router_id = router_id;