From ea3be4c12223b00a69652a8be330961489212447 Mon Sep 17 00:00:00 2001 From: hasso Date: Mon, 26 Sep 2005 17:11:12 +0000 Subject: * isis_tlv.[ch]: Two new functions - tlv_add_te_is_neighs() and tlv_add_te_ipv4_reachs() to handle TLV's with new metric. None of them handle sub TLVs though for now. --- isisd/isis_tlv.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'isisd/isis_tlv.c') diff --git a/isisd/isis_tlv.c b/isisd/isis_tlv.c index 1850e15d..f4307246 100644 --- a/isisd/isis_tlv.c +++ b/isisd/isis_tlv.c @@ -804,6 +804,38 @@ tlv_add_is_neighs (struct list *is_neighs, struct stream *stream) return add_tlv (IS_NEIGHBOURS, pos - value, value, stream); } +int +tlv_add_te_is_neighs (struct list *te_is_neighs, struct stream *stream) +{ + struct listnode *node, *nnode; + struct te_is_neigh *te_is_neigh; + u_char value[255]; + u_char *pos = value; + int retval; + + for (ALL_LIST_ELEMENTS (te_is_neighs, node, nnode, te_is_neigh)) + { + /* FIXME: This will be wrong if we are going to add TE sub TLVs. */ + if (pos - value + IS_NEIGHBOURS_LEN > 255) + { + retval = add_tlv (TE_IS_NEIGHBOURS, pos - value, value, stream); + if (retval != ISIS_OK) + return retval; + pos = value; + } + + memcpy (pos, te_is_neigh->neigh_id, ISIS_SYS_ID_LEN + 1); + pos += ISIS_SYS_ID_LEN + 1; + memcpy (pos, te_is_neigh->te_metric, 3); + pos += 3; + /* Sub TLVs length. */ + *pos = 0; + pos++; + } + + return add_tlv (TE_IS_NEIGHBOURS, pos - value, value, stream); +} + int tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream) { @@ -970,6 +1002,39 @@ tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct stream *stream) return add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream); } +int +tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, struct stream *stream) +{ + struct listnode *node, *nnode; + struct te_ipv4_reachability *te_reach; + u_char value[255]; + u_char *pos = value; + u_char prefix_size; + int retval; + + for (ALL_LIST_ELEMENTS (te_ipv4_reachs, node, nnode, te_reach)) + { + prefix_size = ((((te_reach->control & 0x3F) - 1) >> 3) + 1); + + if (pos - value + (5 + prefix_size) > 255) + { + retval = + add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream); + if (retval != ISIS_OK) + return retval; + pos = value; + } + *(u_int32_t *) pos = te_reach->te_metric; + pos += 4; + *pos = te_reach->control; + pos++; + memcpy (pos, &te_reach->prefix_start, prefix_size); + pos += prefix_size; + } + + return add_tlv (TE_IPV4_REACHABILITY, pos - value, value, stream); +} + #ifdef HAVE_IPV6 int tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream) -- cgit v1.2.1