From 18a6dce6f83dd20caf1f36c8e840868ff0bf6dbd Mon Sep 17 00:00:00 2001 From: hasso Date: Sun, 3 Oct 2004 18:18:34 +0000 Subject: Common router id. --- isisd/ChangeLog | 7 +++++++ isisd/isis_lsp.c | 26 ++++++++++++++++++++++++++ isisd/isis_tlv.h | 1 + isisd/isis_zebra.c | 30 +++++++++++++++++------------- 4 files changed, 51 insertions(+), 13 deletions(-) (limited to 'isisd') diff --git a/isisd/ChangeLog b/isisd/ChangeLog index b95bdbf9..c280bf26 100644 --- a/isisd/ChangeLog +++ b/isisd/ChangeLog @@ -1,3 +1,10 @@ +2004-10-03 Hasso Tepper + + * isis_zebra.c: Read router id related messages from zebra daemon. + * isis_lsp.c: Use router id in IP address TLV in LSP's. It's how Junos + routers behave as well. + * isis_tlv.h: Export add_tlv() function. + 2004-09-27 Hasso Tepper * isis_pdu.c: Fix accessing NULL found by valgrind. diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 2f185437..567afa3b 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -59,6 +59,7 @@ extern struct isis *isis; extern struct thread_master *master; +extern struct in_addr router_id_zebra; /* staticly assigned vars for printing purposes */ char lsp_bits_string[200]; /* FIXME: enough ? */ @@ -1380,6 +1381,7 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area) struct tlvs tlv_data; struct isis_lsp *lsp0 = lsp; struct isis_passwd *passwd; + struct in_addr *routerid; /* * First add the tlvs related to area @@ -1445,6 +1447,30 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area) tlv_add_area_addrs (lsp->tlv_data.area_addrs, lsp->pdu); memset (&tlv_data, 0, sizeof (struct tlvs)); + /* + * IPv4 address TLV. We don't follow "C" vendor, but "J" vendor behavior - + * one IPv4 address is put into LSP and this address is same as router id. + */ + if (router_id_zebra.s_addr != 0) + { + u_char value[4]; + + if (lsp->tlv_data.ipv4_addrs == NULL) + lsp->tlv_data.ipv4_addrs = list_new (); + + routerid = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct in_addr)); + routerid->s_addr = router_id_zebra.s_addr; + + listnode_add (lsp->tlv_data.ipv4_addrs, routerid); + + /* + * FIXME: Using add_tlv() directly is hack, but tlv_add_ip_addrs() + * expects list of prefix_ipv4 structures, but we have list of + * in_addr structures. + */ + add_tlv (IPV4_ADDR, IPV4_MAX_BYTELEN, (u_char *) &routerid->s_addr, + lsp->pdu); + } /* * Then build lists of tlvs related to circuits */ diff --git a/isisd/isis_tlv.h b/isisd/isis_tlv.h index 72f883db..b82be5b1 100644 --- a/isisd/isis_tlv.h +++ b/isisd/isis_tlv.h @@ -260,6 +260,7 @@ int parse_tlvs (char *areatag, u_char * stream, int size, u_int32_t * expected, u_int32_t * found, struct tlvs *tlvs); void free_tlv (void *val); +int add_tlv (u_char, u_char, u_char *, struct stream *); int tlv_add_area_addrs (struct list *area_addrs, struct stream *stream); int tlv_add_is_neighs (struct list *is_neighs, struct stream *stream); int tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream); diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index 8e122082..f56c5d49 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -43,6 +43,22 @@ struct zclient *zclient = NULL; extern struct thread_master *master; +struct in_addr router_id_zebra; + +/* Router-id update message from zebra. */ +int +isis_router_id_update_zebra (int command, struct zclient *zclient, + zebra_size_t length) +{ + struct prefix router_id; + char buf[BUFSIZ]; + + zebra_router_id_update_read (zclient->ibuf,&router_id); + router_id_zebra = router_id.u.prefix4; + + /* FIXME: Do we react somehow? */ + return 0; +} int isis_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length) @@ -106,19 +122,6 @@ zebra_interface_if_lookup (struct stream *s) 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->flags = stream_getl (s); - ifp->metric = stream_getl (s); - ifp->mtu = stream_getl (s); - ifp->bandwidth = stream_getl (s); -} - int isis_zebra_if_state_up (int command, struct zclient *zclient, zebra_size_t length) @@ -591,6 +594,7 @@ isis_zebra_init () { zclient = zclient_new (); zclient_init (zclient, ZEBRA_ROUTE_ISIS); + zclient->router_id_update = isis_router_id_update_zebra; zclient->interface_add = isis_zebra_if_add; zclient->interface_delete = isis_zebra_if_del; zclient->interface_up = isis_zebra_if_state_up; -- cgit v1.2.1