jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_lsp.c |
| 3 | * LSP processing |
| 4 | * |
| 5 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 6 | * Tampere University of Technology |
| 7 | * Institute of Communications Engineering |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public Licenseas published by the Free |
| 11 | * Software Foundation; either version 2 of the License, or (at your option) |
| 12 | * any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 17 | * more details. |
| 18 | |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | */ |
paul | 15935e9 | 2005-05-03 09:27:23 +0000 | [diff] [blame] | 23 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 24 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 25 | |
| 26 | #include "linklist.h" |
| 27 | #include "thread.h" |
| 28 | #include "vty.h" |
| 29 | #include "stream.h" |
| 30 | #include "memory.h" |
| 31 | #include "log.h" |
| 32 | #include "prefix.h" |
| 33 | #include "command.h" |
| 34 | #include "hash.h" |
| 35 | #include "if.h" |
Jingjing Duan | 6a270cd | 2008-08-13 19:09:10 +0100 | [diff] [blame] | 36 | #include "checksum.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 37 | |
| 38 | #include "isisd/dict.h" |
| 39 | #include "isisd/isis_constants.h" |
| 40 | #include "isisd/isis_common.h" |
| 41 | #include "isisd/isis_circuit.h" |
| 42 | #include "isisd/isisd.h" |
| 43 | #include "isisd/isis_tlv.h" |
| 44 | #include "isisd/isis_lsp.h" |
| 45 | #include "isisd/isis_pdu.h" |
| 46 | #include "isisd/isis_dynhn.h" |
| 47 | #include "isisd/isis_misc.h" |
| 48 | #include "isisd/isis_flags.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 49 | #include "isisd/isis_csm.h" |
| 50 | #include "isisd/isis_adjacency.h" |
| 51 | #include "isisd/isis_spf.h" |
| 52 | |
| 53 | #ifdef TOPOLOGY_GENERATE |
| 54 | #include "spgrid.h" |
| 55 | #endif |
| 56 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 57 | #define LSP_MEMORY_PREASSIGN |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 58 | |
| 59 | extern struct isis *isis; |
| 60 | extern struct thread_master *master; |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 61 | extern struct in_addr router_id_zebra; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 62 | |
hasso | 73d1aea | 2004-09-24 10:45:28 +0000 | [diff] [blame] | 63 | /* staticly assigned vars for printing purposes */ |
| 64 | char lsp_bits_string[200]; /* FIXME: enough ? */ |
| 65 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 66 | int |
| 67 | lsp_id_cmp (u_char * id1, u_char * id2) |
| 68 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 69 | return memcmp (id1, id2, ISIS_SYS_ID_LEN + 2); |
| 70 | } |
| 71 | |
| 72 | dict_t * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 73 | lsp_db_init (void) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 74 | { |
| 75 | dict_t *dict; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 76 | |
| 77 | dict = dict_create (DICTCOUNT_T_MAX, (dict_comp_t) lsp_id_cmp); |
| 78 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 79 | return dict; |
| 80 | } |
| 81 | |
| 82 | struct isis_lsp * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 83 | lsp_search (u_char * id, dict_t * lspdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 84 | { |
| 85 | dnode_t *node; |
| 86 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 87 | #ifdef EXTREME_DEBUG |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 88 | dnode_t *dn; |
| 89 | |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 90 | zlog_debug ("searching db"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 91 | for (dn = dict_first (lspdb); dn; dn = dict_next (lspdb, dn)) |
| 92 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 93 | zlog_debug ("%s\t%pX", rawlspid_print ((char *) dnode_getkey (dn)), |
| 94 | dnode_get (dn)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 95 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 96 | #endif /* EXTREME DEBUG */ |
| 97 | |
| 98 | node = dict_lookup (lspdb, id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 99 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 100 | if (node) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 101 | return (struct isis_lsp *) dnode_get (node); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 102 | |
| 103 | return NULL; |
| 104 | } |
| 105 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 106 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 107 | lsp_clear_data (struct isis_lsp *lsp) |
| 108 | { |
| 109 | if (!lsp) |
| 110 | return; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 111 | |
| 112 | if (lsp->own_lsp) |
| 113 | { |
| 114 | if (lsp->tlv_data.nlpids) |
| 115 | XFREE (MTYPE_ISIS_TLV, lsp->tlv_data.nlpids); |
| 116 | if (lsp->tlv_data.hostname) |
| 117 | XFREE (MTYPE_ISIS_TLV, lsp->tlv_data.hostname); |
| 118 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 119 | if (lsp->tlv_data.is_neighs) |
| 120 | list_delete (lsp->tlv_data.is_neighs); |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 121 | if (lsp->tlv_data.te_is_neighs) |
| 122 | list_delete (lsp->tlv_data.te_is_neighs); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 123 | if (lsp->tlv_data.area_addrs) |
| 124 | list_delete (lsp->tlv_data.area_addrs); |
| 125 | if (lsp->tlv_data.es_neighs) |
| 126 | list_delete (lsp->tlv_data.es_neighs); |
| 127 | if (lsp->tlv_data.ipv4_addrs) |
| 128 | list_delete (lsp->tlv_data.ipv4_addrs); |
| 129 | if (lsp->tlv_data.ipv4_int_reachs) |
| 130 | list_delete (lsp->tlv_data.ipv4_int_reachs); |
| 131 | if (lsp->tlv_data.ipv4_ext_reachs) |
| 132 | list_delete (lsp->tlv_data.ipv4_ext_reachs); |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 133 | if (lsp->tlv_data.te_ipv4_reachs) |
| 134 | list_delete (lsp->tlv_data.te_ipv4_reachs); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 135 | #ifdef HAVE_IPV6 |
| 136 | if (lsp->tlv_data.ipv6_addrs) |
| 137 | list_delete (lsp->tlv_data.ipv6_addrs); |
| 138 | if (lsp->tlv_data.ipv6_reachs) |
| 139 | list_delete (lsp->tlv_data.ipv6_reachs); |
| 140 | #endif /* HAVE_IPV6 */ |
| 141 | |
| 142 | memset (&lsp->tlv_data, 0, sizeof (struct tlvs)); |
| 143 | |
| 144 | return; |
| 145 | } |
| 146 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 147 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 148 | lsp_destroy (struct isis_lsp *lsp) |
| 149 | { |
| 150 | if (!lsp) |
| 151 | return; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 152 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 153 | lsp_clear_data (lsp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 154 | |
| 155 | if (LSP_FRAGMENT (lsp->lsp_header->lsp_id) == 0 && lsp->lspu.frags) |
| 156 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 157 | list_delete (lsp->lspu.frags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 158 | } |
| 159 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 160 | if (lsp->pdu) |
| 161 | stream_free (lsp->pdu); |
| 162 | XFREE (MTYPE_ISIS_LSP, lsp); |
| 163 | } |
| 164 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 165 | void |
| 166 | lsp_db_destroy (dict_t * lspdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 167 | { |
| 168 | dnode_t *dnode, *next; |
| 169 | struct isis_lsp *lsp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 170 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 171 | dnode = dict_first (lspdb); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 172 | while (dnode) |
| 173 | { |
| 174 | next = dict_next (lspdb, dnode); |
| 175 | lsp = dnode_get (dnode); |
| 176 | lsp_destroy (lsp); |
| 177 | dict_delete_free (lspdb, dnode); |
| 178 | dnode = next; |
| 179 | } |
| 180 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 181 | dict_free (lspdb); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 182 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 183 | return; |
| 184 | } |
| 185 | |
| 186 | /* |
| 187 | * Remove all the frags belonging to the given lsp |
| 188 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 189 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 190 | lsp_remove_frags (struct list *frags, dict_t * lspdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 191 | { |
| 192 | dnode_t *dnode; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 193 | struct listnode *lnode, *lnnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 194 | struct isis_lsp *lsp; |
| 195 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 196 | for (ALL_LIST_ELEMENTS (frags, lnode, lnnode, lsp)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 197 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 198 | dnode = dict_lookup (lspdb, lsp->lsp_header->lsp_id); |
| 199 | lsp_destroy (lsp); |
| 200 | dnode_destroy (dict_delete (lspdb, dnode)); |
| 201 | } |
| 202 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 203 | list_delete_all_node (frags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 204 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 205 | return; |
| 206 | } |
| 207 | |
| 208 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 209 | lsp_search_and_destroy (u_char * id, dict_t * lspdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 210 | { |
| 211 | dnode_t *node; |
| 212 | struct isis_lsp *lsp; |
| 213 | |
| 214 | node = dict_lookup (lspdb, id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 215 | if (node) |
| 216 | { |
| 217 | node = dict_delete (lspdb, node); |
| 218 | lsp = dnode_get (node); |
| 219 | /* |
| 220 | * If this is a zero lsp, remove all the frags now |
| 221 | */ |
| 222 | if (LSP_FRAGMENT (lsp->lsp_header->lsp_id) == 0) |
| 223 | { |
| 224 | if (lsp->lspu.frags) |
| 225 | lsp_remove_frags (lsp->lspu.frags, lspdb); |
| 226 | } |
| 227 | else |
| 228 | { |
| 229 | /* |
| 230 | * else just remove this frag, from the zero lsps' frag list |
| 231 | */ |
| 232 | if (lsp->lspu.zero_lsp && lsp->lspu.zero_lsp->lspu.frags) |
| 233 | listnode_delete (lsp->lspu.zero_lsp->lspu.frags, lsp); |
| 234 | } |
| 235 | lsp_destroy (lsp); |
| 236 | dnode_destroy (node); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 237 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /* |
| 241 | * Compares a LSP to given values |
| 242 | * Params are given in net order |
| 243 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 244 | int |
| 245 | lsp_compare (char *areatag, struct isis_lsp *lsp, u_int32_t seq_num, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 246 | u_int16_t checksum, u_int16_t rem_lifetime) |
| 247 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 248 | /* no point in double ntohl on seqnum */ |
| 249 | if (lsp->lsp_header->seq_num == seq_num && |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 250 | lsp->lsp_header->checksum == checksum && |
| 251 | /*comparing with 0, no need to do ntohl */ |
| 252 | ((lsp->lsp_header->rem_lifetime == 0 && rem_lifetime == 0) || |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 253 | (lsp->lsp_header->rem_lifetime != 0 && rem_lifetime != 0))) |
| 254 | { |
| 255 | if (isis->debugs & DEBUG_SNP_PACKETS) |
| 256 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 257 | zlog_debug ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x," |
| 258 | " lifetime %us", |
| 259 | areatag, |
| 260 | rawlspid_print (lsp->lsp_header->lsp_id), |
| 261 | ntohl (lsp->lsp_header->seq_num), |
| 262 | ntohs (lsp->lsp_header->checksum), |
| 263 | ntohs (lsp->lsp_header->rem_lifetime)); |
| 264 | zlog_debug ("ISIS-Snp (%s): is equal to ours seq 0x%08x," |
| 265 | " cksum 0x%04x, lifetime %us", |
| 266 | areatag, |
| 267 | ntohl (seq_num), ntohs (checksum), ntohs (rem_lifetime)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 268 | } |
| 269 | return LSP_EQUAL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 270 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 271 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 272 | if (ntohl (seq_num) >= ntohl (lsp->lsp_header->seq_num)) |
| 273 | { |
| 274 | if (isis->debugs & DEBUG_SNP_PACKETS) |
| 275 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 276 | zlog_debug ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x," |
| 277 | " lifetime %us", |
| 278 | areatag, |
| 279 | rawlspid_print (lsp->lsp_header->lsp_id), |
| 280 | ntohl (seq_num), ntohs (checksum), ntohs (rem_lifetime)); |
| 281 | zlog_debug ("ISIS-Snp (%s): is newer than ours seq 0x%08x, " |
| 282 | "cksum 0x%04x, lifetime %us", |
| 283 | areatag, |
| 284 | ntohl (lsp->lsp_header->seq_num), |
| 285 | ntohs (lsp->lsp_header->checksum), |
| 286 | ntohs (lsp->lsp_header->rem_lifetime)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 287 | } |
| 288 | return LSP_NEWER; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 289 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 290 | if (isis->debugs & DEBUG_SNP_PACKETS) |
| 291 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 292 | zlog_debug |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 293 | ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x, lifetime %us", |
| 294 | areatag, rawlspid_print (lsp->lsp_header->lsp_id), ntohl (seq_num), |
| 295 | ntohs (checksum), ntohs (rem_lifetime)); |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 296 | zlog_debug ("ISIS-Snp (%s): is older than ours seq 0x%08x," |
| 297 | " cksum 0x%04x, lifetime %us", areatag, |
| 298 | ntohl (lsp->lsp_header->seq_num), |
| 299 | ntohs (lsp->lsp_header->checksum), |
| 300 | ntohs (lsp->lsp_header->rem_lifetime)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 301 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 302 | |
| 303 | return LSP_OLDER; |
| 304 | } |
| 305 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 306 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 307 | lsp_inc_seqnum (struct isis_lsp *lsp, u_int32_t seq_num) |
| 308 | { |
| 309 | u_int32_t newseq; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 310 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 311 | if (seq_num == 0 || ntohl (lsp->lsp_header->seq_num) > seq_num) |
| 312 | newseq = ntohl (lsp->lsp_header->seq_num) + 1; |
| 313 | else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 314 | newseq = seq_num++; |
| 315 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 316 | lsp->lsp_header->seq_num = htonl (newseq); |
Jingjing Duan | 6a270cd | 2008-08-13 19:09:10 +0100 | [diff] [blame] | 317 | fletcher_checksum (STREAM_DATA (lsp->pdu) + 12, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 318 | ntohs (lsp->lsp_header->pdu_len) - 12, 12); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 319 | |
| 320 | return; |
| 321 | } |
| 322 | |
| 323 | /* |
| 324 | * Genetates checksum for LSP and its frags |
| 325 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 326 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 327 | lsp_seqnum_update (struct isis_lsp *lsp0) |
| 328 | { |
| 329 | struct isis_lsp *lsp; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 330 | struct listnode *node; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 331 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 332 | lsp_inc_seqnum (lsp0, 0); |
| 333 | |
| 334 | if (!lsp0->lspu.frags) |
| 335 | return; |
| 336 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 337 | for (ALL_LIST_ELEMENTS_RO (lsp0->lspu.frags, node, lsp)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 338 | lsp_inc_seqnum (lsp, 0); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 339 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 340 | return; |
| 341 | } |
| 342 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 343 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 344 | isis_lsp_authinfo_check (struct stream *stream, struct isis_area *area, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 345 | int pdulen, struct isis_passwd *passwd) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 346 | { |
| 347 | uint32_t expected = 0, found; |
| 348 | struct tlvs tlvs; |
| 349 | int retval = 0; |
| 350 | |
| 351 | expected |= TLVFLAG_AUTH_INFO; |
| 352 | retval = parse_tlvs (area->area_tag, stream->data + |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 353 | ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN, |
| 354 | pdulen - ISIS_FIXED_HDR_LEN |
| 355 | - ISIS_LSP_HDR_LEN, &expected, &found, &tlvs); |
Fritz Reichmann | e6b03b7 | 2011-10-01 17:49:48 +0400 | [diff] [blame^] | 356 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 357 | if (retval || !(found & TLVFLAG_AUTH_INFO)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 358 | return 1; /* Auth fail (parsing failed or no auth-tlv) */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 359 | |
Fritz Reichmann | e6b03b7 | 2011-10-01 17:49:48 +0400 | [diff] [blame^] | 360 | switch (tlvs.auth_info.type) |
| 361 | { |
| 362 | case ISIS_PASSWD_TYPE_HMAC_MD5: |
| 363 | zlog_debug("Got LSP with ISIS_PASSWD_TYPE_HMAC_MD5"); |
| 364 | break; |
| 365 | case ISIS_PASSWD_TYPE_CLEARTXT: |
| 366 | zlog_debug("Got LSP with ISIS_PASSWD_TYPE_CLEARTXT"); |
| 367 | break; |
| 368 | default: |
| 369 | zlog_debug("Unknown authentication type in LSP"); |
| 370 | break; |
| 371 | } |
| 372 | |
| 373 | return 0; |
| 374 | /* return authentication_check (passwd, &tlvs.auth_info);*/ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 375 | } |
| 376 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 377 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 378 | lsp_update_data (struct isis_lsp *lsp, struct stream *stream, |
| 379 | struct isis_area *area) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 380 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 381 | uint32_t expected = 0, found; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 382 | int retval; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 383 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 384 | /* copying only the relevant part of our stream */ |
paul | 15935e9 | 2005-05-03 09:27:23 +0000 | [diff] [blame] | 385 | lsp->pdu = stream_dup (stream); |
| 386 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 387 | /* setting pointers to the correct place */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 388 | lsp->isis_header = (struct isis_fixed_hdr *) (STREAM_DATA (lsp->pdu)); |
| 389 | lsp->lsp_header = (struct isis_link_state_hdr *) (STREAM_DATA (lsp->pdu) + |
| 390 | ISIS_FIXED_HDR_LEN); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 391 | lsp->age_out = ZERO_AGE_LIFETIME; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 392 | lsp->installed = time (NULL); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 393 | /* |
| 394 | * Get LSP data i.e. TLVs |
| 395 | */ |
| 396 | expected |= TLVFLAG_AUTH_INFO; |
| 397 | expected |= TLVFLAG_AREA_ADDRS; |
| 398 | expected |= TLVFLAG_IS_NEIGHS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 399 | if ((lsp->lsp_header->lsp_bits & 3) == 3) /* a level 2 LSP */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 400 | expected |= TLVFLAG_PARTITION_DESIG_LEVEL2_IS; |
| 401 | expected |= TLVFLAG_NLPID; |
| 402 | if (area->dynhostname) |
| 403 | expected |= TLVFLAG_DYN_HOSTNAME; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 404 | if (area->newmetric) |
| 405 | { |
| 406 | expected |= TLVFLAG_TE_IS_NEIGHS; |
| 407 | expected |= TLVFLAG_TE_IPV4_REACHABILITY; |
| 408 | expected |= TLVFLAG_TE_ROUTER_ID; |
| 409 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 410 | expected |= TLVFLAG_IPV4_ADDR; |
| 411 | expected |= TLVFLAG_IPV4_INT_REACHABILITY; |
| 412 | expected |= TLVFLAG_IPV4_EXT_REACHABILITY; |
| 413 | #ifdef HAVE_IPV6 |
| 414 | expected |= TLVFLAG_IPV6_ADDR; |
| 415 | expected |= TLVFLAG_IPV6_REACHABILITY; |
| 416 | #endif /* HAVE_IPV6 */ |
| 417 | |
| 418 | retval = parse_tlvs (area->area_tag, lsp->pdu->data + |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 419 | ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN, |
| 420 | ntohs (lsp->lsp_header->pdu_len) - ISIS_FIXED_HDR_LEN |
| 421 | - ISIS_LSP_HDR_LEN, &expected, &found, &lsp->tlv_data); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 422 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 423 | if (found & TLVFLAG_DYN_HOSTNAME) |
| 424 | { |
| 425 | if (area->dynhostname) |
| 426 | isis_dynhn_insert (lsp->lsp_header->lsp_id, lsp->tlv_data.hostname, |
| 427 | (lsp->lsp_header->lsp_bits & LSPBIT_IST) == |
| 428 | IS_LEVEL_1_AND_2 ? IS_LEVEL_2 : |
| 429 | (lsp->lsp_header->lsp_bits & LSPBIT_IST)); |
| 430 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 431 | |
| 432 | } |
| 433 | |
| 434 | void |
| 435 | lsp_update (struct isis_lsp *lsp, struct isis_link_state_hdr *lsp_hdr, |
hasso | a96d8d1 | 2005-09-16 14:44:23 +0000 | [diff] [blame] | 436 | struct stream *stream, struct isis_area *area, int level) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 437 | { |
hasso | 4eda93a | 2005-09-18 17:51:02 +0000 | [diff] [blame] | 438 | dnode_t *dnode = NULL; |
hasso | a96d8d1 | 2005-09-16 14:44:23 +0000 | [diff] [blame] | 439 | |
| 440 | /* Remove old LSP from LSP database. */ |
hasso | 4eda93a | 2005-09-18 17:51:02 +0000 | [diff] [blame] | 441 | dnode = dict_lookup (area->lspdb[level - 1], lsp->lsp_header->lsp_id); |
| 442 | if (dnode) |
| 443 | dnode_destroy (dict_delete (area->lspdb[level - 1], dnode)); |
hasso | a96d8d1 | 2005-09-16 14:44:23 +0000 | [diff] [blame] | 444 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 445 | /* free the old lsp data */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 446 | XFREE (MTYPE_STREAM_DATA, lsp->pdu); |
| 447 | lsp_clear_data (lsp); |
| 448 | |
| 449 | /* rebuild the lsp data */ |
| 450 | lsp_update_data (lsp, stream, area); |
| 451 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 452 | /* set the new values for lsp header */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 453 | memcpy (lsp->lsp_header, lsp_hdr, ISIS_LSP_HDR_LEN); |
hasso | a96d8d1 | 2005-09-16 14:44:23 +0000 | [diff] [blame] | 454 | |
hasso | 4eda93a | 2005-09-18 17:51:02 +0000 | [diff] [blame] | 455 | if (dnode) |
| 456 | lsp_insert (lsp, area->lspdb[level - 1]); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 457 | } |
| 458 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 459 | /* creation of LSP directly from what we received */ |
| 460 | struct isis_lsp * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 461 | lsp_new_from_stream_ptr (struct stream *stream, |
| 462 | u_int16_t pdu_len, struct isis_lsp *lsp0, |
| 463 | struct isis_area *area) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 464 | { |
| 465 | struct isis_lsp *lsp; |
| 466 | |
hasso | aac372f | 2005-09-01 17:52:33 +0000 | [diff] [blame] | 467 | lsp = XCALLOC (MTYPE_ISIS_LSP, sizeof (struct isis_lsp)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 468 | lsp_update_data (lsp, stream, area); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 469 | |
| 470 | if (lsp0 == NULL) |
| 471 | { |
| 472 | /* |
| 473 | * zero lsp -> create the list for fragments |
| 474 | */ |
| 475 | lsp->lspu.frags = list_new (); |
| 476 | } |
| 477 | else |
| 478 | { |
| 479 | /* |
| 480 | * a fragment -> set the backpointer and add this to zero lsps frag list |
| 481 | */ |
| 482 | lsp->lspu.zero_lsp = lsp0; |
| 483 | listnode_add (lsp0->lspu.frags, lsp); |
| 484 | } |
| 485 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 486 | return lsp; |
| 487 | } |
| 488 | |
| 489 | struct isis_lsp * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 490 | lsp_new (u_char * lsp_id, u_int16_t rem_lifetime, u_int32_t seq_num, |
| 491 | u_int8_t lsp_bits, u_int16_t checksum, int level) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 492 | { |
| 493 | struct isis_lsp *lsp; |
| 494 | |
hasso | aac372f | 2005-09-01 17:52:33 +0000 | [diff] [blame] | 495 | lsp = XCALLOC (MTYPE_ISIS_LSP, sizeof (struct isis_lsp)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 496 | if (!lsp) |
| 497 | { |
| 498 | /* FIXME: set lspdbol bit */ |
| 499 | zlog_warn ("lsp_new(): out of memory"); |
| 500 | return NULL; |
| 501 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 502 | #ifdef LSP_MEMORY_PREASSIGN |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 503 | lsp->pdu = stream_new (1514); /*Should be minimal mtu? yup... */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 504 | #else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 505 | /* We need to do realloc on TLVs additions */ |
| 506 | lsp->pdu = malloc (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 507 | #endif /* LSP_MEMORY_PREASSIGN */ |
| 508 | if (LSP_FRAGMENT (lsp_id) == 0) |
| 509 | lsp->lspu.frags = list_new (); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 510 | lsp->isis_header = (struct isis_fixed_hdr *) (STREAM_DATA (lsp->pdu)); |
| 511 | lsp->lsp_header = (struct isis_link_state_hdr *) |
| 512 | (STREAM_DATA (lsp->pdu) + ISIS_FIXED_HDR_LEN); |
| 513 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 514 | /* at first we fill the FIXED HEADER */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 515 | (level == 1) ? fill_fixed_hdr (lsp->isis_header, L1_LINK_STATE) : |
| 516 | fill_fixed_hdr (lsp->isis_header, L2_LINK_STATE); |
| 517 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 518 | /* now for the LSP HEADER */ |
| 519 | /* Minimal LSP PDU size */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 520 | lsp->lsp_header->pdu_len = htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 521 | memcpy (lsp->lsp_header->lsp_id, lsp_id, ISIS_SYS_ID_LEN + 2); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 522 | lsp->lsp_header->checksum = checksum; /* Provided in network order */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 523 | lsp->lsp_header->seq_num = htonl (seq_num); |
| 524 | lsp->lsp_header->rem_lifetime = htons (rem_lifetime); |
| 525 | lsp->lsp_header->lsp_bits = lsp_bits; |
| 526 | lsp->level = level; |
| 527 | lsp->age_out = ZERO_AGE_LIFETIME; |
| 528 | |
paul | 9985f83 | 2005-02-09 15:51:56 +0000 | [diff] [blame] | 529 | stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 530 | |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 531 | if (isis->debugs & DEBUG_EVENTS) |
| 532 | zlog_debug ("New LSP with ID %s-%02x-%02x seqnum %08x", |
| 533 | sysid_print (lsp_id), LSP_PSEUDO_ID (lsp->lsp_header->lsp_id), |
| 534 | LSP_FRAGMENT (lsp->lsp_header->lsp_id), |
| 535 | ntohl (lsp->lsp_header->seq_num)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 536 | |
| 537 | return lsp; |
| 538 | } |
| 539 | |
| 540 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 541 | lsp_insert (struct isis_lsp *lsp, dict_t * lspdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 542 | { |
| 543 | dict_alloc_insert (lspdb, lsp->lsp_header->lsp_id, lsp); |
| 544 | } |
| 545 | |
| 546 | /* |
| 547 | * Build a list of LSPs with non-zero ht bounded by start and stop ids |
| 548 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 549 | void |
| 550 | lsp_build_list_nonzero_ht (u_char * start_id, u_char * stop_id, |
| 551 | struct list *list, dict_t * lspdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 552 | { |
| 553 | dnode_t *first, *last, *curr; |
| 554 | |
| 555 | first = dict_lower_bound (lspdb, start_id); |
| 556 | if (!first) |
| 557 | return; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 558 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 559 | last = dict_upper_bound (lspdb, stop_id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 560 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 561 | curr = first; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 562 | |
| 563 | if (((struct isis_lsp *) (curr->dict_data))->lsp_header->rem_lifetime) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 564 | listnode_add (list, first->dict_data); |
| 565 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 566 | while (curr) |
| 567 | { |
| 568 | curr = dict_next (lspdb, curr); |
| 569 | if (curr && |
| 570 | ((struct isis_lsp *) (curr->dict_data))->lsp_header->rem_lifetime) |
| 571 | listnode_add (list, curr->dict_data); |
| 572 | if (curr == last) |
| 573 | break; |
| 574 | } |
| 575 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 576 | return; |
| 577 | } |
| 578 | |
| 579 | /* |
| 580 | * Build a list of all LSPs bounded by start and stop ids |
| 581 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 582 | void |
| 583 | lsp_build_list (u_char * start_id, u_char * stop_id, |
| 584 | struct list *list, dict_t * lspdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 585 | { |
| 586 | dnode_t *first, *last, *curr; |
| 587 | |
| 588 | first = dict_lower_bound (lspdb, start_id); |
| 589 | if (!first) |
| 590 | return; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 591 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 592 | last = dict_upper_bound (lspdb, stop_id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 593 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 594 | curr = first; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 595 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 596 | listnode_add (list, first->dict_data); |
| 597 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 598 | while (curr) |
| 599 | { |
| 600 | curr = dict_next (lspdb, curr); |
| 601 | if (curr) |
| 602 | listnode_add (list, curr->dict_data); |
| 603 | if (curr == last) |
| 604 | break; |
| 605 | } |
| 606 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 607 | return; |
| 608 | } |
| 609 | |
| 610 | /* |
| 611 | * Build a list of LSPs with SSN flag set for the given circuit |
| 612 | */ |
| 613 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 614 | lsp_build_list_ssn (struct isis_circuit *circuit, struct list *list, |
| 615 | dict_t * lspdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 616 | { |
| 617 | dnode_t *dnode, *next; |
| 618 | struct isis_lsp *lsp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 619 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 620 | dnode = dict_first (lspdb); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 621 | while (dnode != NULL) |
| 622 | { |
| 623 | next = dict_next (lspdb, dnode); |
| 624 | lsp = dnode_get (dnode); |
| 625 | if (ISIS_CHECK_FLAG (lsp->SSNflags, circuit)) |
| 626 | listnode_add (list, lsp); |
| 627 | dnode = next; |
| 628 | } |
| 629 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 630 | return; |
| 631 | } |
| 632 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 633 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 634 | lsp_set_time (struct isis_lsp *lsp) |
| 635 | { |
| 636 | assert (lsp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 637 | |
| 638 | if (lsp->lsp_header->rem_lifetime == 0) |
| 639 | { |
| 640 | if (lsp->age_out != 0) |
| 641 | lsp->age_out--; |
| 642 | return; |
| 643 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 644 | |
| 645 | /* If we are turning 0 */ |
| 646 | /* ISO 10589 - 7.3.16.4 first paragraph */ |
| 647 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 648 | if (ntohs (lsp->lsp_header->rem_lifetime) == 1) |
| 649 | { |
| 650 | /* 7.3.16.4 a) set SRM flags on all */ |
| 651 | ISIS_FLAGS_SET_ALL (lsp->SRMflags); |
| 652 | /* 7.3.16.4 b) retain only the header FIXME */ |
| 653 | /* 7.3.16.4 c) record the time to purge FIXME (other way to do it) */ |
| 654 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 655 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 656 | lsp->lsp_header->rem_lifetime = |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 657 | htons (ntohs (lsp->lsp_header->rem_lifetime) - 1); |
| 658 | } |
| 659 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 660 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 661 | lspid_print (u_char * lsp_id, u_char * trg, char dynhost, char frag) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 662 | { |
| 663 | struct isis_dynhn *dyn = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 664 | u_char id[SYSID_STRLEN]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 665 | |
| 666 | if (dynhost) |
| 667 | dyn = dynhn_find_by_id (lsp_id); |
| 668 | else |
| 669 | dyn = NULL; |
| 670 | |
| 671 | if (dyn) |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 672 | sprintf ((char *)id, "%.14s", dyn->name.name); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 673 | else if (!memcmp (isis->sysid, lsp_id, ISIS_SYS_ID_LEN) & dynhost) |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 674 | sprintf ((char *)id, "%.14s", unix_hostname ()); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 675 | else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 676 | { |
| 677 | memcpy (id, sysid_print (lsp_id), 15); |
| 678 | } |
| 679 | if (frag) |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 680 | sprintf ((char *)trg, "%s.%02x-%02x", id, LSP_PSEUDO_ID (lsp_id), |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 681 | LSP_FRAGMENT (lsp_id)); |
| 682 | else |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 683 | sprintf ((char *)trg, "%s.%02x", id, LSP_PSEUDO_ID (lsp_id)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 684 | } |
| 685 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 686 | /* Convert the lsp attribute bits to attribute string */ |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 687 | const char * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 688 | lsp_bits2string (u_char * lsp_bits) |
| 689 | { |
| 690 | char *pos = lsp_bits_string; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 691 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 692 | if (!*lsp_bits) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 693 | return " none"; |
| 694 | |
| 695 | /* we only focus on the default metric */ |
| 696 | pos += sprintf (pos, "%d/", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 697 | ISIS_MASK_LSP_ATT_DEFAULT_BIT (*lsp_bits) ? 1 : 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 698 | |
| 699 | pos += sprintf (pos, "%d/", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 700 | ISIS_MASK_LSP_PARTITION_BIT (*lsp_bits) ? 1 : 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 701 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 702 | pos += sprintf (pos, "%d", ISIS_MASK_LSP_OL_BIT (*lsp_bits) ? 1 : 0); |
| 703 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 704 | *(pos) = '\0'; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 705 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 706 | return lsp_bits_string; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | /* this function prints the lsp on show isis database */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 710 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 711 | lsp_print (dnode_t * node, struct vty *vty, char dynhost) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 712 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 713 | struct isis_lsp *lsp = dnode_get (node); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 714 | u_char LSPid[255]; |
| 715 | |
| 716 | lspid_print (lsp->lsp_header->lsp_id, LSPid, dynhost, 1); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 717 | vty_out (vty, "%-21s%c ", LSPid, lsp->own_lsp ? '*' : ' '); |
| 718 | vty_out (vty, "0x%08x ", ntohl (lsp->lsp_header->seq_num)); |
| 719 | vty_out (vty, "0x%04x ", ntohs (lsp->lsp_header->checksum)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 720 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 721 | if (ntohs (lsp->lsp_header->rem_lifetime) == 0) |
| 722 | vty_out (vty, " (%2u)", lsp->age_out); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 723 | else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 724 | vty_out (vty, "%5u", ntohs (lsp->lsp_header->rem_lifetime)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 725 | |
| 726 | vty_out (vty, " %s%s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 727 | lsp_bits2string (&lsp->lsp_header->lsp_bits), VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 728 | } |
| 729 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 730 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 731 | lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 732 | { |
| 733 | struct isis_lsp *lsp = dnode_get (node); |
| 734 | struct area_addr *area_addr; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 735 | int i; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 736 | struct listnode *lnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 737 | struct is_neigh *is_neigh; |
| 738 | struct te_is_neigh *te_is_neigh; |
| 739 | struct ipv4_reachability *ipv4_reach; |
| 740 | struct in_addr *ipv4_addr; |
| 741 | struct te_ipv4_reachability *te_ipv4_reach; |
| 742 | #ifdef HAVE_IPV6 |
| 743 | struct ipv6_reachability *ipv6_reach; |
| 744 | struct in6_addr in6; |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 745 | u_char buff[BUFSIZ]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 746 | #endif |
| 747 | u_char LSPid[255]; |
| 748 | u_char hostname[255]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 749 | u_char ipv4_reach_prefix[20]; |
| 750 | u_char ipv4_reach_mask[20]; |
| 751 | u_char ipv4_address[20]; |
| 752 | |
| 753 | lspid_print (lsp->lsp_header->lsp_id, LSPid, dynhost, 1); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 754 | lsp_print (node, vty, dynhost); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 755 | |
| 756 | /* for all area address */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 757 | if (lsp->tlv_data.area_addrs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 758 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.area_addrs, lnode, area_addr)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 759 | { |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 760 | vty_out (vty, " Area Address: %s%s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 761 | isonet_print (area_addr->area_addr, area_addr->addr_len), |
| 762 | VTY_NEWLINE); |
| 763 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 764 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 765 | /* for the nlpid tlv */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 766 | if (lsp->tlv_data.nlpids) |
| 767 | { |
| 768 | for (i = 0; i < lsp->tlv_data.nlpids->count; i++) |
| 769 | { |
| 770 | switch (lsp->tlv_data.nlpids->nlpids[i]) |
| 771 | { |
| 772 | case NLPID_IP: |
| 773 | case NLPID_IPV6: |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 774 | vty_out (vty, " NLPID: 0x%X%s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 775 | lsp->tlv_data.nlpids->nlpids[i], VTY_NEWLINE); |
| 776 | break; |
| 777 | default: |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 778 | vty_out (vty, " NLPID: %s%s", "unknown", VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 779 | break; |
| 780 | } |
| 781 | } |
| 782 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 783 | |
| 784 | /* for the hostname tlv */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 785 | if (lsp->tlv_data.hostname) |
| 786 | { |
Jeremy Jackson | ec5e42b | 2009-01-21 20:51:57 -0500 | [diff] [blame] | 787 | memset (hostname, 0, sizeof (hostname)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 788 | memcpy (hostname, lsp->tlv_data.hostname->name, |
| 789 | lsp->tlv_data.hostname->namelen); |
| 790 | vty_out (vty, " Hostname: %s%s", hostname, VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 791 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 792 | |
| 793 | if (lsp->tlv_data.ipv4_addrs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 794 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_addrs, lnode, ipv4_addr)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 795 | { |
| 796 | memcpy (ipv4_address, inet_ntoa (*ipv4_addr), sizeof (ipv4_address)); |
| 797 | vty_out (vty, " IP: %s%s", ipv4_address, VTY_NEWLINE); |
| 798 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 799 | |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 800 | /* TE router id */ |
| 801 | if (lsp->tlv_data.router_id) |
| 802 | { |
| 803 | memcpy (ipv4_address, inet_ntoa (lsp->tlv_data.router_id->id), |
| 804 | sizeof (ipv4_address)); |
| 805 | vty_out (vty, " Router ID: %s%s", ipv4_address, VTY_NEWLINE); |
| 806 | } |
| 807 | |
| 808 | /* for the IS neighbor tlv */ |
| 809 | if (lsp->tlv_data.is_neighs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 810 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.is_neighs, lnode, is_neigh)) |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 811 | { |
| 812 | lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0); |
hasso | 96e3038 | 2005-09-19 06:35:47 +0000 | [diff] [blame] | 813 | vty_out (vty, " Metric: %-10d IS %s%s", |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 814 | is_neigh->metrics.metric_default, LSPid, VTY_NEWLINE); |
| 815 | } |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 816 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 817 | /* for the internal reachable tlv */ |
| 818 | if (lsp->tlv_data.ipv4_int_reachs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 819 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_int_reachs, lnode, |
| 820 | ipv4_reach)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 821 | { |
| 822 | memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix), |
| 823 | sizeof (ipv4_reach_prefix)); |
| 824 | memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), |
| 825 | sizeof (ipv4_reach_mask)); |
hasso | 96e3038 | 2005-09-19 06:35:47 +0000 | [diff] [blame] | 826 | vty_out (vty, " Metric: %-10d IP-Internal %s %s%s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 827 | ipv4_reach->metrics.metric_default, ipv4_reach_prefix, |
| 828 | ipv4_reach_mask, VTY_NEWLINE); |
| 829 | } |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 830 | |
| 831 | /* for the external reachable tlv */ |
| 832 | if (lsp->tlv_data.ipv4_ext_reachs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 833 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_ext_reachs, lnode, |
| 834 | ipv4_reach)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 835 | { |
| 836 | memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix), |
| 837 | sizeof (ipv4_reach_prefix)); |
| 838 | memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), |
| 839 | sizeof (ipv4_reach_mask)); |
hasso | 96e3038 | 2005-09-19 06:35:47 +0000 | [diff] [blame] | 840 | vty_out (vty, " Metric: %-10d IP-External %s %s%s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 841 | ipv4_reach->metrics.metric_default, ipv4_reach_prefix, |
| 842 | ipv4_reach_mask, VTY_NEWLINE); |
| 843 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 844 | |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 845 | /* IPv6 tlv */ |
| 846 | #ifdef HAVE_IPV6 |
| 847 | if (lsp->tlv_data.ipv6_reachs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 848 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv6_reachs, lnode, ipv6_reach)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 849 | { |
| 850 | memset (&in6, 0, sizeof (in6)); |
| 851 | memcpy (in6.s6_addr, ipv6_reach->prefix, |
| 852 | PSIZE (ipv6_reach->prefix_len)); |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 853 | inet_ntop (AF_INET6, &in6, (char *)buff, BUFSIZ); |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 854 | if ((ipv6_reach->control_info && |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 855 | CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL) |
hasso | 96e3038 | 2005-09-19 06:35:47 +0000 | [diff] [blame] | 856 | vty_out (vty, " Metric: %-10d IPv6-Internal %s/%d%s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 857 | ntohl (ipv6_reach->metric), |
| 858 | buff, ipv6_reach->prefix_len, VTY_NEWLINE); |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 859 | else |
hasso | 96e3038 | 2005-09-19 06:35:47 +0000 | [diff] [blame] | 860 | vty_out (vty, " Metric: %-10d IPv6-External %s/%d%s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 861 | ntohl (ipv6_reach->metric), |
| 862 | buff, ipv6_reach->prefix_len, VTY_NEWLINE); |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 863 | } |
| 864 | #endif |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 865 | |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 866 | /* TE IS neighbor tlv */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 867 | if (lsp->tlv_data.te_is_neighs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 868 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.te_is_neighs, lnode, te_is_neigh)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 869 | { |
hasso | 96e3038 | 2005-09-19 06:35:47 +0000 | [diff] [blame] | 870 | uint32_t metric; |
| 871 | memcpy (&metric, te_is_neigh->te_metric, 3); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 872 | lspid_print (te_is_neigh->neigh_id, LSPid, dynhost, 0); |
hasso | 96e3038 | 2005-09-19 06:35:47 +0000 | [diff] [blame] | 873 | vty_out (vty, " Metric: %-10d IS-Extended %s%s", |
| 874 | ntohl (metric << 8), LSPid, VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 875 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 876 | |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 877 | /* TE IPv4 tlv */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 878 | if (lsp->tlv_data.te_ipv4_reachs) |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 879 | for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.te_ipv4_reachs, lnode, |
| 880 | te_ipv4_reach)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 881 | { |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 882 | /* FIXME: There should be better way to output this stuff. */ |
hasso | 96e3038 | 2005-09-19 06:35:47 +0000 | [diff] [blame] | 883 | vty_out (vty, " Metric: %-10d IP-Extended %s/%d%s", |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 884 | ntohl (te_ipv4_reach->te_metric), |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 885 | inet_ntoa (newprefix2inaddr (&te_ipv4_reach->prefix_start, |
| 886 | te_ipv4_reach->control)), |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 887 | te_ipv4_reach->control & 0x3F, VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 888 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 889 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 890 | return; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | /* print all the lsps info in the local lspdb */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 894 | int |
| 895 | lsp_print_all (struct vty *vty, dict_t * lspdb, char detail, char dynhost) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 896 | { |
| 897 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 898 | dnode_t *node = dict_first (lspdb), *next; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 899 | int lsp_count = 0; |
| 900 | |
| 901 | /* print the title, for both modes */ |
| 902 | vty_out (vty, "LSP ID LSP Seq Num LSP Checksum " |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 903 | "LSP Holdtime ATT/P/OL%s", VTY_NEWLINE); |
| 904 | |
| 905 | if (detail == ISIS_UI_LEVEL_BRIEF) |
| 906 | { |
| 907 | while (node != NULL) |
| 908 | { |
| 909 | /* I think it is unnecessary, so I comment it out */ |
| 910 | /* dict_contains (lspdb, node); */ |
| 911 | next = dict_next (lspdb, node); |
| 912 | lsp_print (node, vty, dynhost); |
| 913 | node = next; |
| 914 | lsp_count++; |
| 915 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 916 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 917 | else if (detail == ISIS_UI_LEVEL_DETAIL) |
| 918 | { |
| 919 | while (node != NULL) |
| 920 | { |
| 921 | next = dict_next (lspdb, node); |
| 922 | lsp_print_detail (node, vty, dynhost); |
| 923 | node = next; |
| 924 | lsp_count++; |
| 925 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 926 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 927 | |
| 928 | return lsp_count; |
| 929 | } |
| 930 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 931 | #define FRAG_THOLD(S,T) \ |
| 932 | ((STREAM_SIZE(S)*T)/100) |
| 933 | |
| 934 | /* stream*, area->lsp_frag_threshold, increment */ |
| 935 | #define FRAG_NEEDED(S,T,I) \ |
| 936 | (STREAM_SIZE(S)-STREAM_REMAIN(S)+(I) > FRAG_THOLD(S,T)) |
| 937 | |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 938 | /* FIXME: It shouldn't be necessary to pass tlvsize here, TLVs can have |
| 939 | * variable length (TE TLVs, sub TLVs). */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 940 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 941 | lsp_tlv_fit (struct isis_lsp *lsp, struct list **from, struct list **to, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 942 | int tlvsize, int frag_thold, |
| 943 | int tlv_build_func (struct list *, struct stream *)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 944 | { |
| 945 | int count, i; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 946 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 947 | /* can we fit all ? */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 948 | if (!FRAG_NEEDED (lsp->pdu, frag_thold, listcount (*from) * tlvsize + 2)) |
| 949 | { |
| 950 | tlv_build_func (*from, lsp->pdu); |
| 951 | *to = *from; |
| 952 | *from = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 953 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 954 | else if (!FRAG_NEEDED (lsp->pdu, frag_thold, tlvsize + 2)) |
| 955 | { |
| 956 | /* fit all we can */ |
| 957 | count = FRAG_THOLD (lsp->pdu, frag_thold) - 2 - |
| 958 | (STREAM_SIZE (lsp->pdu) - STREAM_REMAIN (lsp->pdu)); |
| 959 | if (count) |
| 960 | count = count / tlvsize; |
| 961 | for (i = 0; i < count; i++) |
| 962 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 963 | listnode_add (*to, listgetdata (listhead (*from))); |
| 964 | listnode_delete (*from, listgetdata (listhead (*from))); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 965 | } |
| 966 | tlv_build_func (*to, lsp->pdu); |
| 967 | } |
paul | 9985f83 | 2005-02-09 15:51:56 +0000 | [diff] [blame] | 968 | lsp->lsp_header->pdu_len = htons (stream_get_endp (lsp->pdu)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 969 | return; |
| 970 | } |
| 971 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 972 | static struct isis_lsp * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 973 | lsp_next_frag (u_char frag_num, struct isis_lsp *lsp0, struct isis_area *area, |
| 974 | int level) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 975 | { |
| 976 | struct isis_lsp *lsp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 977 | u_char frag_id[ISIS_SYS_ID_LEN + 2]; |
| 978 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 979 | memcpy (frag_id, lsp0->lsp_header->lsp_id, ISIS_SYS_ID_LEN + 1); |
| 980 | LSP_FRAGMENT (frag_id) = frag_num; |
| 981 | lsp = lsp_search (frag_id, area->lspdb[level - 1]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 982 | if (lsp) |
| 983 | { |
| 984 | /* |
| 985 | * Clear the TLVs, but inherit the authinfo |
| 986 | */ |
| 987 | lsp_clear_data (lsp); |
| 988 | if (lsp0->tlv_data.auth_info.type) |
| 989 | { |
| 990 | memcpy (&lsp->tlv_data.auth_info, &lsp->tlv_data.auth_info, |
| 991 | sizeof (struct isis_passwd)); |
| 992 | tlv_add_authinfo (lsp->tlv_data.auth_info.type, |
| 993 | lsp->tlv_data.auth_info.len, |
| 994 | lsp->tlv_data.auth_info.passwd, lsp->pdu); |
| 995 | } |
| 996 | return lsp; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 997 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 998 | lsp = lsp_new (frag_id, area->max_lsp_lifetime[level - 1], 0, area->is_type, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 999 | 0, level); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1000 | lsp->own_lsp = 1; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1001 | lsp_insert (lsp, area->lspdb[level - 1]); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1002 | listnode_add (lsp0->lspu.frags, lsp); |
| 1003 | lsp->lspu.zero_lsp = lsp0; |
| 1004 | /* |
| 1005 | * Copy the authinfo from zero LSP |
| 1006 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1007 | if (lsp0->tlv_data.auth_info.type) |
| 1008 | { |
| 1009 | memcpy (&lsp->tlv_data.auth_info, &lsp->tlv_data.auth_info, |
| 1010 | sizeof (struct isis_passwd)); |
| 1011 | tlv_add_authinfo (lsp->tlv_data.auth_info.type, |
| 1012 | lsp->tlv_data.auth_info.len, |
| 1013 | lsp->tlv_data.auth_info.passwd, lsp->pdu); |
| 1014 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1015 | return lsp; |
| 1016 | } |
| 1017 | |
| 1018 | /* |
| 1019 | * Builds the LSP data part. This func creates a new frag whenever |
| 1020 | * area->lsp_frag_threshold is exceeded. |
| 1021 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1022 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1023 | lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area) |
| 1024 | { |
| 1025 | struct is_neigh *is_neigh; |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1026 | struct te_is_neigh *te_is_neigh; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1027 | struct listnode *node, *ipnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1028 | int level = lsp->level; |
| 1029 | struct isis_circuit *circuit; |
| 1030 | struct prefix_ipv4 *ipv4; |
| 1031 | struct ipv4_reachability *ipreach; |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1032 | struct te_ipv4_reachability *te_ipreach; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1033 | struct isis_adjacency *nei; |
| 1034 | #ifdef HAVE_IPV6 |
hasso | 6785157 | 2004-09-21 14:17:04 +0000 | [diff] [blame] | 1035 | struct prefix_ipv6 *ipv6, *ip6prefix; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1036 | struct ipv6_reachability *ip6reach; |
| 1037 | #endif /* HAVE_IPV6 */ |
| 1038 | struct tlvs tlv_data; |
| 1039 | struct isis_lsp *lsp0 = lsp; |
| 1040 | struct isis_passwd *passwd; |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 1041 | struct in_addr *routerid; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1042 | |
| 1043 | /* |
| 1044 | * First add the tlvs related to area |
| 1045 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1046 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1047 | /* Area addresses */ |
| 1048 | if (lsp->tlv_data.area_addrs == NULL) |
| 1049 | lsp->tlv_data.area_addrs = list_new (); |
| 1050 | list_add_list (lsp->tlv_data.area_addrs, area->area_addrs); |
| 1051 | /* Protocols Supported */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1052 | if (area->ip_circuits > 0 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1053 | #ifdef HAVE_IPV6 |
| 1054 | || area->ipv6_circuits > 0 |
| 1055 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1056 | ) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1057 | { |
hasso | aac372f | 2005-09-01 17:52:33 +0000 | [diff] [blame] | 1058 | lsp->tlv_data.nlpids = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct nlpids)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1059 | lsp->tlv_data.nlpids->count = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1060 | if (area->ip_circuits > 0) |
| 1061 | { |
| 1062 | lsp->tlv_data.nlpids->count++; |
| 1063 | lsp->tlv_data.nlpids->nlpids[0] = NLPID_IP; |
| 1064 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1065 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1066 | if (area->ipv6_circuits > 0) |
| 1067 | { |
| 1068 | lsp->tlv_data.nlpids->count++; |
| 1069 | lsp->tlv_data.nlpids->nlpids[lsp->tlv_data.nlpids->count - 1] = |
| 1070 | NLPID_IPV6; |
| 1071 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1072 | #endif /* HAVE_IPV6 */ |
| 1073 | } |
| 1074 | /* Dynamic Hostname */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1075 | if (area->dynhostname) |
| 1076 | { |
| 1077 | lsp->tlv_data.hostname = XMALLOC (MTYPE_ISIS_TLV, |
| 1078 | sizeof (struct hostname)); |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 1079 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1080 | memcpy (lsp->tlv_data.hostname->name, unix_hostname (), |
| 1081 | strlen (unix_hostname ())); |
| 1082 | lsp->tlv_data.hostname->namelen = strlen (unix_hostname ()); |
| 1083 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1084 | |
| 1085 | /* |
| 1086 | * Building the zero lsp |
| 1087 | */ |
hasso | aac372f | 2005-09-01 17:52:33 +0000 | [diff] [blame] | 1088 | |
| 1089 | /* Reset stream endp. Stream is always there and on every LSP refresh only |
| 1090 | * TLV part of it is overwritten. So we must seek past header we will not |
| 1091 | * touch. */ |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 1092 | stream_reset (lsp->pdu); |
hasso | aac372f | 2005-09-01 17:52:33 +0000 | [diff] [blame] | 1093 | stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); |
| 1094 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1095 | /* |
| 1096 | * Add the authentication info if its present |
| 1097 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1098 | (level == 1) ? (passwd = &area->area_passwd) : |
| 1099 | (passwd = &area->domain_passwd); |
| 1100 | if (passwd->type) |
| 1101 | { |
| 1102 | memcpy (&lsp->tlv_data.auth_info, passwd, sizeof (struct isis_passwd)); |
| 1103 | tlv_add_authinfo (passwd->type, passwd->len, passwd->passwd, lsp->pdu); |
| 1104 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1105 | if (lsp->tlv_data.nlpids) |
| 1106 | tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu); |
| 1107 | if (lsp->tlv_data.hostname) |
| 1108 | tlv_add_dynamic_hostname (lsp->tlv_data.hostname, lsp->pdu); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1109 | if (lsp->tlv_data.area_addrs && listcount (lsp->tlv_data.area_addrs) > 0) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1110 | tlv_add_area_addrs (lsp->tlv_data.area_addrs, lsp->pdu); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1111 | |
hasso | 81ad8f6 | 2005-09-26 17:58:24 +0000 | [diff] [blame] | 1112 | /* IPv4 address and TE router ID TLVs. In case of the first one we don't |
| 1113 | * follow "C" vendor, but "J" vendor behavior - one IPv4 address is put into |
| 1114 | * LSP and this address is same as router id. */ |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 1115 | if (router_id_zebra.s_addr != 0) |
| 1116 | { |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 1117 | if (lsp->tlv_data.ipv4_addrs == NULL) |
hasso | be7d65d | 2005-09-02 01:38:16 +0000 | [diff] [blame] | 1118 | { |
| 1119 | lsp->tlv_data.ipv4_addrs = list_new (); |
| 1120 | lsp->tlv_data.ipv4_addrs->del = free_tlv; |
| 1121 | } |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 1122 | |
| 1123 | routerid = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct in_addr)); |
| 1124 | routerid->s_addr = router_id_zebra.s_addr; |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 1125 | listnode_add (lsp->tlv_data.ipv4_addrs, routerid); |
hasso | 81ad8f6 | 2005-09-26 17:58:24 +0000 | [diff] [blame] | 1126 | tlv_add_in_addr (routerid, lsp->pdu, IPV4_ADDR); |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 1127 | |
hasso | 81ad8f6 | 2005-09-26 17:58:24 +0000 | [diff] [blame] | 1128 | /* Exactly same data is put into TE router ID TLV, but only if new style |
| 1129 | * TLV's are in use. */ |
| 1130 | if (area->newmetric) |
| 1131 | { |
| 1132 | lsp->tlv_data.router_id = XMALLOC (MTYPE_ISIS_TLV, |
| 1133 | sizeof (struct in_addr)); |
| 1134 | lsp->tlv_data.router_id->id.s_addr = router_id_zebra.s_addr; |
| 1135 | tlv_add_in_addr (&lsp->tlv_data.router_id->id, lsp->pdu, TE_ROUTER_ID); |
| 1136 | } |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 1137 | } |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 1138 | |
hasso | 81ad8f6 | 2005-09-26 17:58:24 +0000 | [diff] [blame] | 1139 | memset (&tlv_data, 0, sizeof (struct tlvs)); |
| 1140 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 1141 | #ifdef TOPOLOGY_GENERATE |
| 1142 | /* If topology exists (and we create topology for level 1 only), create |
| 1143 | * (hardcoded) link to topology. */ |
| 1144 | if (area->topology && level == 1) |
| 1145 | { |
| 1146 | if (tlv_data.is_neighs == NULL) |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1147 | { |
| 1148 | tlv_data.is_neighs = list_new (); |
| 1149 | tlv_data.is_neighs->del = free_tlv; |
| 1150 | } |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1151 | is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 1152 | |
| 1153 | memcpy (&is_neigh->neigh_id, area->topology_baseis, ISIS_SYS_ID_LEN); |
| 1154 | is_neigh->neigh_id[ISIS_SYS_ID_LEN - 1] = (1 & 0xFF); |
| 1155 | is_neigh->neigh_id[ISIS_SYS_ID_LEN - 2] = ((1 >> 8) & 0xFF); |
| 1156 | is_neigh->metrics.metric_default = 0x01; |
| 1157 | is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED; |
| 1158 | is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED; |
| 1159 | is_neigh->metrics.metric_error = METRICS_UNSUPPORTED; |
| 1160 | listnode_add (tlv_data.is_neighs, is_neigh); |
| 1161 | } |
| 1162 | #endif /* TOPOLOGY_GENERATE */ |
| 1163 | |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 1164 | /* |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1165 | * Then build lists of tlvs related to circuits |
| 1166 | */ |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1167 | for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1168 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1169 | if (circuit->state != C_STATE_UP) |
| 1170 | continue; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1171 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1172 | /* |
| 1173 | * Add IPv4 internal reachability of this circuit |
| 1174 | */ |
| 1175 | if (circuit->ip_router && circuit->ip_addrs && |
| 1176 | circuit->ip_addrs->count > 0) |
| 1177 | { |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1178 | if (area->oldmetric) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1179 | { |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1180 | if (tlv_data.ipv4_int_reachs == NULL) |
| 1181 | { |
| 1182 | tlv_data.ipv4_int_reachs = list_new (); |
| 1183 | tlv_data.ipv4_int_reachs->del = free_tlv; |
| 1184 | } |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1185 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, ipnode, ipv4)) |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1186 | { |
| 1187 | ipreach = |
| 1188 | XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability)); |
| 1189 | ipreach->metrics = circuit->metrics[level - 1]; |
| 1190 | masklen2ip (ipv4->prefixlen, &ipreach->mask); |
| 1191 | ipreach->prefix.s_addr = ((ipreach->mask.s_addr) & |
| 1192 | (ipv4->prefix.s_addr)); |
| 1193 | listnode_add (tlv_data.ipv4_int_reachs, ipreach); |
| 1194 | } |
hasso | be7d65d | 2005-09-02 01:38:16 +0000 | [diff] [blame] | 1195 | tlv_data.ipv4_int_reachs->del = free_tlv; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1196 | } |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1197 | if (area->newmetric) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1198 | { |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1199 | if (tlv_data.te_ipv4_reachs == NULL) |
| 1200 | { |
| 1201 | tlv_data.te_ipv4_reachs = list_new (); |
| 1202 | tlv_data.te_ipv4_reachs->del = free_tlv; |
| 1203 | } |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1204 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, ipnode, ipv4)) |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1205 | { |
| 1206 | /* FIXME All this assumes that we have no sub TLVs. */ |
| 1207 | te_ipreach = XCALLOC (MTYPE_ISIS_TLV, |
| 1208 | sizeof (struct te_ipv4_reachability) + |
| 1209 | ((ipv4->prefixlen + 7)/8) - 1); |
hasso | 309ddb1 | 2005-09-26 18:06:47 +0000 | [diff] [blame] | 1210 | |
| 1211 | if (area->oldmetric) |
| 1212 | te_ipreach->te_metric = htonl (circuit->metrics[level - 1].metric_default); |
| 1213 | else |
| 1214 | te_ipreach->te_metric = htonl (circuit->te_metric[level - 1]); |
| 1215 | |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1216 | te_ipreach->control = (ipv4->prefixlen & 0x3F); |
| 1217 | memcpy (&te_ipreach->prefix_start, &ipv4->prefix.s_addr, |
| 1218 | (ipv4->prefixlen + 7)/8); |
| 1219 | listnode_add (tlv_data.te_ipv4_reachs, te_ipreach); |
| 1220 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1221 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1222 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1223 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1224 | /* |
| 1225 | * Add IPv6 reachability of this circuit |
| 1226 | */ |
| 1227 | if (circuit->ipv6_router && circuit->ipv6_non_link && |
| 1228 | circuit->ipv6_non_link->count > 0) |
| 1229 | { |
| 1230 | |
| 1231 | if (tlv_data.ipv6_reachs == NULL) |
| 1232 | { |
| 1233 | tlv_data.ipv6_reachs = list_new (); |
hasso | be7d65d | 2005-09-02 01:38:16 +0000 | [diff] [blame] | 1234 | tlv_data.ipv6_reachs->del = free_tlv; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1235 | } |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1236 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, ipnode, ipv6)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1237 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1238 | ip6reach = |
hasso | aac372f | 2005-09-01 17:52:33 +0000 | [diff] [blame] | 1239 | XCALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability)); |
hasso | 309ddb1 | 2005-09-26 18:06:47 +0000 | [diff] [blame] | 1240 | |
| 1241 | if (area->oldmetric) |
| 1242 | ip6reach->metric = |
| 1243 | htonl (circuit->metrics[level - 1].metric_default); |
| 1244 | else |
| 1245 | ip6reach->metric = htonl (circuit->te_metric[level - 1]); |
| 1246 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1247 | ip6reach->control_info = 0; |
| 1248 | ip6reach->prefix_len = ipv6->prefixlen; |
hasso | 6785157 | 2004-09-21 14:17:04 +0000 | [diff] [blame] | 1249 | memcpy (&ip6prefix, &ipv6, sizeof(ip6prefix)); |
| 1250 | apply_mask_ipv6 (ip6prefix); |
| 1251 | memcpy (ip6reach->prefix, ip6prefix->prefix.s6_addr, |
| 1252 | sizeof (ip6reach->prefix)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1253 | listnode_add (tlv_data.ipv6_reachs, ip6reach); |
| 1254 | } |
| 1255 | } |
| 1256 | #endif /* HAVE_IPV6 */ |
| 1257 | |
| 1258 | switch (circuit->circ_type) |
| 1259 | { |
| 1260 | case CIRCUIT_T_BROADCAST: |
| 1261 | if (level & circuit->circuit_is_type) |
| 1262 | { |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1263 | if (area->oldmetric) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1264 | { |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1265 | if (tlv_data.is_neighs == NULL) |
| 1266 | { |
| 1267 | tlv_data.is_neighs = list_new (); |
| 1268 | tlv_data.is_neighs->del = free_tlv; |
| 1269 | } |
| 1270 | is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); |
| 1271 | if (level == 1) |
| 1272 | memcpy (is_neigh->neigh_id, |
| 1273 | circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1); |
| 1274 | else |
| 1275 | memcpy (is_neigh->neigh_id, |
| 1276 | circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1); |
| 1277 | is_neigh->metrics = circuit->metrics[level - 1]; |
| 1278 | listnode_add (tlv_data.is_neighs, is_neigh); |
hasso | be7d65d | 2005-09-02 01:38:16 +0000 | [diff] [blame] | 1279 | tlv_data.is_neighs->del = free_tlv; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1280 | } |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1281 | if (area->newmetric) |
| 1282 | { |
| 1283 | uint32_t metric; |
| 1284 | |
| 1285 | if (tlv_data.te_is_neighs == NULL) |
| 1286 | { |
| 1287 | tlv_data.te_is_neighs = list_new (); |
| 1288 | tlv_data.te_is_neighs->del = free_tlv; |
| 1289 | } |
| 1290 | te_is_neigh = XCALLOC (MTYPE_ISIS_TLV, |
| 1291 | sizeof (struct te_is_neigh)); |
| 1292 | if (level == 1) |
| 1293 | memcpy (te_is_neigh->neigh_id, |
| 1294 | circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1); |
| 1295 | else |
| 1296 | memcpy (te_is_neigh->neigh_id, |
| 1297 | circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1); |
hasso | 309ddb1 | 2005-09-26 18:06:47 +0000 | [diff] [blame] | 1298 | if (area->oldmetric) |
| 1299 | metric = |
| 1300 | ((htonl(circuit->metrics[level - 1].metric_default) >> 8) |
| 1301 | & 0xffffff); |
| 1302 | else |
| 1303 | metric = ((htonl(*circuit->te_metric) >> 8) & 0xffffff); |
| 1304 | |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1305 | memcpy (te_is_neigh->te_metric, &metric, 3); |
| 1306 | listnode_add (tlv_data.te_is_neighs, te_is_neigh); |
| 1307 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1308 | } |
| 1309 | break; |
| 1310 | case CIRCUIT_T_P2P: |
| 1311 | nei = circuit->u.p2p.neighbor; |
| 1312 | if (nei && (level & nei->circuit_t)) |
| 1313 | { |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1314 | if (area->oldmetric) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1315 | { |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1316 | if (tlv_data.is_neighs == NULL) |
| 1317 | { |
| 1318 | tlv_data.is_neighs = list_new (); |
| 1319 | tlv_data.is_neighs->del = free_tlv; |
| 1320 | } |
| 1321 | is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); |
| 1322 | memcpy (is_neigh->neigh_id, nei->sysid, ISIS_SYS_ID_LEN); |
| 1323 | is_neigh->metrics = circuit->metrics[level - 1]; |
| 1324 | listnode_add (tlv_data.is_neighs, is_neigh); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1325 | } |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1326 | if (area->newmetric) |
| 1327 | { |
| 1328 | uint32_t metric; |
| 1329 | |
| 1330 | if (tlv_data.te_is_neighs == NULL) |
| 1331 | { |
| 1332 | tlv_data.te_is_neighs = list_new (); |
| 1333 | tlv_data.te_is_neighs->del = free_tlv; |
| 1334 | } |
| 1335 | te_is_neigh = XCALLOC (MTYPE_ISIS_TLV, |
| 1336 | sizeof (struct te_is_neigh)); |
| 1337 | memcpy (te_is_neigh->neigh_id, nei->sysid, ISIS_SYS_ID_LEN); |
| 1338 | metric = ((htonl(*circuit->te_metric) >> 8) & 0xffffff); |
| 1339 | memcpy (te_is_neigh->te_metric, &metric, 3); |
| 1340 | listnode_add (tlv_data.te_is_neighs, te_is_neigh); |
| 1341 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1342 | } |
| 1343 | break; |
| 1344 | case CIRCUIT_T_STATIC_IN: |
| 1345 | zlog_warn ("lsp_area_create: unsupported circuit type"); |
| 1346 | break; |
| 1347 | case CIRCUIT_T_STATIC_OUT: |
| 1348 | zlog_warn ("lsp_area_create: unsupported circuit type"); |
| 1349 | break; |
| 1350 | case CIRCUIT_T_DA: |
| 1351 | zlog_warn ("lsp_area_create: unsupported circuit type"); |
| 1352 | break; |
| 1353 | default: |
| 1354 | zlog_warn ("lsp_area_create: unknown circuit type"); |
| 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | while (tlv_data.ipv4_int_reachs && listcount (tlv_data.ipv4_int_reachs)) |
| 1359 | { |
| 1360 | if (lsp->tlv_data.ipv4_int_reachs == NULL) |
| 1361 | lsp->tlv_data.ipv4_int_reachs = list_new (); |
| 1362 | lsp_tlv_fit (lsp, &tlv_data.ipv4_int_reachs, |
| 1363 | &lsp->tlv_data.ipv4_int_reachs, |
| 1364 | IPV4_REACH_LEN, area->lsp_frag_threshold, |
| 1365 | tlv_add_ipv4_reachs); |
| 1366 | if (tlv_data.ipv4_int_reachs && listcount (tlv_data.ipv4_int_reachs)) |
| 1367 | lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1, |
| 1368 | lsp0, area, level); |
| 1369 | } |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1370 | /* FIXME: We pass maximum te_ipv4_reachability length to the lsp_tlv_fit() |
| 1371 | * for now. lsp_tlv_fit() needs to be fixed to deal with variable length |
| 1372 | * TLVs (sub TLVs!). */ |
| 1373 | while (tlv_data.te_ipv4_reachs && listcount (tlv_data.te_ipv4_reachs)) |
| 1374 | { |
| 1375 | if (lsp->tlv_data.te_ipv4_reachs == NULL) |
| 1376 | lsp->tlv_data.te_ipv4_reachs = list_new (); |
| 1377 | lsp_tlv_fit (lsp, &tlv_data.te_ipv4_reachs, |
| 1378 | &lsp->tlv_data.te_ipv4_reachs, |
| 1379 | 9, area->lsp_frag_threshold, tlv_add_te_ipv4_reachs); |
| 1380 | if (tlv_data.te_ipv4_reachs && listcount (tlv_data.te_ipv4_reachs)) |
| 1381 | lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1, |
| 1382 | lsp0, area, level); |
| 1383 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1384 | |
| 1385 | #ifdef HAVE_IPV6 |
| 1386 | while (tlv_data.ipv6_reachs && listcount (tlv_data.ipv6_reachs)) |
| 1387 | { |
| 1388 | if (lsp->tlv_data.ipv6_reachs == NULL) |
| 1389 | lsp->tlv_data.ipv6_reachs = list_new (); |
| 1390 | lsp_tlv_fit (lsp, &tlv_data.ipv6_reachs, |
| 1391 | &lsp->tlv_data.ipv6_reachs, |
| 1392 | IPV6_REACH_LEN, area->lsp_frag_threshold, |
| 1393 | tlv_add_ipv6_reachs); |
| 1394 | if (tlv_data.ipv6_reachs && listcount (tlv_data.ipv6_reachs)) |
| 1395 | lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1, |
| 1396 | lsp0, area, level); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1397 | } |
| 1398 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1399 | |
| 1400 | while (tlv_data.is_neighs && listcount (tlv_data.is_neighs)) |
| 1401 | { |
| 1402 | if (lsp->tlv_data.is_neighs == NULL) |
| 1403 | lsp->tlv_data.is_neighs = list_new (); |
| 1404 | lsp_tlv_fit (lsp, &tlv_data.is_neighs, |
| 1405 | &lsp->tlv_data.is_neighs, |
| 1406 | IS_NEIGHBOURS_LEN, area->lsp_frag_threshold, |
| 1407 | tlv_add_is_neighs); |
| 1408 | if (tlv_data.is_neighs && listcount (tlv_data.is_neighs)) |
| 1409 | lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1, |
| 1410 | lsp0, area, level); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1411 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1412 | |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1413 | while (tlv_data.te_is_neighs && listcount (tlv_data.te_is_neighs)) |
| 1414 | { |
| 1415 | if (lsp->tlv_data.te_is_neighs == NULL) |
| 1416 | lsp->tlv_data.te_is_neighs = list_new (); |
| 1417 | lsp_tlv_fit (lsp, &tlv_data.te_is_neighs, &lsp->tlv_data.te_is_neighs, |
| 1418 | IS_NEIGHBOURS_LEN, area->lsp_frag_threshold, |
| 1419 | tlv_add_te_is_neighs); |
| 1420 | if (tlv_data.te_is_neighs && listcount (tlv_data.te_is_neighs)) |
| 1421 | lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1, |
| 1422 | lsp0, area, level); |
| 1423 | } |
| 1424 | |
| 1425 | free_tlvs (&tlv_data); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1426 | return; |
| 1427 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1428 | |
| 1429 | /* |
| 1430 | * 7.3.7 Generation on non-pseudonode LSPs |
| 1431 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1432 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1433 | lsp_generate_non_pseudo (struct isis_area *area, int level) |
| 1434 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1435 | struct isis_lsp *oldlsp, *newlsp; |
| 1436 | u_int32_t seq_num = 0; |
| 1437 | u_char lspid[ISIS_SYS_ID_LEN + 2]; |
| 1438 | |
| 1439 | memset (&lspid, 0, ISIS_SYS_ID_LEN + 2); |
| 1440 | memcpy (&lspid, isis->sysid, ISIS_SYS_ID_LEN); |
| 1441 | |
| 1442 | /* only builds the lsp if the area shares the level */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1443 | if ((area->is_type & level) == level) |
| 1444 | { |
| 1445 | oldlsp = lsp_search (lspid, area->lspdb[level - 1]); |
| 1446 | if (oldlsp) |
| 1447 | { |
| 1448 | seq_num = ntohl (oldlsp->lsp_header->seq_num); |
| 1449 | lsp_search_and_destroy (oldlsp->lsp_header->lsp_id, |
| 1450 | area->lspdb[level - 1]); |
| 1451 | /* FIXME: we should actually initiate a purge */ |
| 1452 | } |
| 1453 | newlsp = lsp_new (lspid, area->max_lsp_lifetime[level - 1], seq_num, |
| 1454 | area->is_type, 0, level); |
| 1455 | newlsp->own_lsp = 1; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1456 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1457 | lsp_insert (newlsp, area->lspdb[level - 1]); |
| 1458 | /* build_lsp_data (newlsp, area); */ |
| 1459 | lsp_build_nonpseudo (newlsp, area); |
| 1460 | /* time to calculate our checksum */ |
| 1461 | lsp_seqnum_update (newlsp); |
| 1462 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1463 | |
| 1464 | /* DEBUG_ADJ_PACKETS */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1465 | if (isis->debugs & DEBUG_ADJ_PACKETS) |
| 1466 | { |
| 1467 | /* FIXME: is this place right? fix missing info */ |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1468 | zlog_debug ("ISIS-Upd (%s): Building L%d LSP", area->area_tag, level); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1469 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1470 | |
| 1471 | return ISIS_OK; |
| 1472 | } |
| 1473 | |
| 1474 | /* |
| 1475 | * 7.3.9 Generation of level 1 LSPs (non-pseudonode) |
| 1476 | */ |
| 1477 | int |
| 1478 | lsp_l1_generate (struct isis_area *area) |
| 1479 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1480 | THREAD_TIMER_ON (master, area->t_lsp_refresh[0], lsp_refresh_l1, area, |
| 1481 | MAX_LSP_GEN_INTERVAL); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1482 | |
| 1483 | return lsp_generate_non_pseudo (area, 1); |
| 1484 | } |
| 1485 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1486 | /* |
| 1487 | * 7.3.9 Generation of level 2 LSPs (non-pseudonode) |
| 1488 | */ |
| 1489 | int |
| 1490 | lsp_l2_generate (struct isis_area *area) |
| 1491 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1492 | THREAD_TIMER_ON (master, area->t_lsp_refresh[1], lsp_refresh_l2, area, |
| 1493 | MAX_LSP_GEN_INTERVAL); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1494 | |
| 1495 | return lsp_generate_non_pseudo (area, 2); |
| 1496 | } |
| 1497 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1498 | static int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1499 | lsp_non_pseudo_regenerate (struct isis_area *area, int level) |
| 1500 | { |
| 1501 | dict_t *lspdb = area->lspdb[level - 1]; |
| 1502 | struct isis_lsp *lsp, *frag; |
| 1503 | struct listnode *node; |
| 1504 | u_char lspid[ISIS_SYS_ID_LEN + 2]; |
| 1505 | |
| 1506 | memset (lspid, 0, ISIS_SYS_ID_LEN + 2); |
| 1507 | memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1508 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1509 | lsp = lsp_search (lspid, lspdb); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1510 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1511 | if (!lsp) |
| 1512 | { |
| 1513 | zlog_err |
| 1514 | ("ISIS-Upd (%s): lsp_non_pseudo_regenerate(): no L%d LSP found!", |
| 1515 | area->area_tag, level); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1516 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1517 | return ISIS_ERROR; |
| 1518 | } |
| 1519 | |
| 1520 | lsp_clear_data (lsp); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1521 | lsp_build_nonpseudo (lsp, area); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1522 | lsp->lsp_header->rem_lifetime = htons (isis_jitter |
| 1523 | (area->max_lsp_lifetime[level - 1], |
| 1524 | MAX_AGE_JITTER)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1525 | lsp_seqnum_update (lsp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1526 | |
| 1527 | if (isis->debugs & DEBUG_UPDATE_PACKETS) |
| 1528 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1529 | zlog_debug ("ISIS-Upd (%s): refreshing our L%d LSP %s, " |
| 1530 | "seq 0x%08x, cksum 0x%04x lifetime %us", |
| 1531 | area->area_tag, |
| 1532 | level, |
| 1533 | rawlspid_print (lsp->lsp_header->lsp_id), |
| 1534 | ntohl (lsp->lsp_header->seq_num), |
| 1535 | ntohs (lsp->lsp_header->checksum), |
| 1536 | ntohs (lsp->lsp_header->rem_lifetime)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1537 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1538 | |
| 1539 | lsp->last_generated = time (NULL); |
| 1540 | area->lsp_regenerate_pending[level - 1] = 0; |
| 1541 | ISIS_FLAGS_SET_ALL (lsp->SRMflags); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1542 | for (ALL_LIST_ELEMENTS_RO (lsp->lspu.frags, node, frag)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1543 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1544 | frag->lsp_header->rem_lifetime = htons (isis_jitter |
| 1545 | (area-> |
| 1546 | max_lsp_lifetime[level - 1], |
| 1547 | MAX_AGE_JITTER)); |
| 1548 | ISIS_FLAGS_SET_ALL (frag->SRMflags); |
| 1549 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1550 | |
| 1551 | if (area->ip_circuits) |
| 1552 | isis_spf_schedule (area, level); |
| 1553 | #ifdef HAVE_IPV6 |
| 1554 | if (area->ipv6_circuits) |
| 1555 | isis_spf_schedule6 (area, level); |
| 1556 | #endif |
| 1557 | return ISIS_OK; |
| 1558 | } |
| 1559 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1560 | /* |
| 1561 | * Done at least every MAX_LSP_GEN_INTERVAL. Search own LSPs, update holding |
| 1562 | * time and set SRM |
| 1563 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1564 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1565 | lsp_refresh_l1 (struct thread *thread) |
| 1566 | { |
| 1567 | struct isis_area *area; |
| 1568 | unsigned long ref_time; |
| 1569 | |
| 1570 | area = THREAD_ARG (thread); |
| 1571 | assert (area); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1572 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1573 | area->t_lsp_refresh[0] = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1574 | if (area->is_type & IS_LEVEL_1) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1575 | lsp_non_pseudo_regenerate (area, 1); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1576 | |
| 1577 | ref_time = area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ? |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1578 | MAX_LSP_GEN_INTERVAL : area->lsp_refresh[0]; |
| 1579 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1580 | THREAD_TIMER_ON (master, area->t_lsp_refresh[0], lsp_refresh_l1, area, |
| 1581 | isis_jitter (ref_time, MAX_AGE_JITTER)); |
hasso | d70f99e | 2004-02-11 20:26:31 +0000 | [diff] [blame] | 1582 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1583 | return ISIS_OK; |
| 1584 | } |
| 1585 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1586 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1587 | lsp_refresh_l2 (struct thread *thread) |
| 1588 | { |
| 1589 | struct isis_area *area; |
| 1590 | unsigned long ref_time; |
| 1591 | |
| 1592 | area = THREAD_ARG (thread); |
| 1593 | assert (area); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1594 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1595 | area->t_lsp_refresh[1] = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1596 | if (area->is_type & IS_LEVEL_2) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1597 | lsp_non_pseudo_regenerate (area, 2); |
| 1598 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1599 | ref_time = area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ? |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1600 | MAX_LSP_GEN_INTERVAL : area->lsp_refresh[1]; |
| 1601 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1602 | THREAD_TIMER_ON (master, area->t_lsp_refresh[1], lsp_refresh_l2, area, |
| 1603 | isis_jitter (ref_time, MAX_AGE_JITTER)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1604 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1605 | return ISIS_OK; |
| 1606 | } |
| 1607 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1608 | /* |
| 1609 | * Something has changed -> regenerate LSP |
| 1610 | */ |
| 1611 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1612 | static int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1613 | lsp_l1_regenerate (struct thread *thread) |
| 1614 | { |
| 1615 | struct isis_area *area; |
| 1616 | |
| 1617 | area = THREAD_ARG (thread); |
| 1618 | area->lsp_regenerate_pending[0] = 0; |
| 1619 | |
| 1620 | return lsp_non_pseudo_regenerate (area, 1); |
| 1621 | } |
| 1622 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1623 | static int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1624 | lsp_l2_regenerate (struct thread *thread) |
| 1625 | { |
| 1626 | struct isis_area *area; |
| 1627 | |
| 1628 | area = THREAD_ARG (thread); |
| 1629 | area->lsp_regenerate_pending[1] = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1630 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1631 | return lsp_non_pseudo_regenerate (area, 2); |
| 1632 | } |
| 1633 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1634 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1635 | lsp_regenerate_schedule (struct isis_area *area) |
| 1636 | { |
| 1637 | struct isis_lsp *lsp; |
| 1638 | u_char id[ISIS_SYS_ID_LEN + 2]; |
| 1639 | time_t now, diff; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1640 | memcpy (id, isis->sysid, ISIS_SYS_ID_LEN); |
| 1641 | LSP_PSEUDO_ID (id) = LSP_FRAGMENT (id) = 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1642 | now = time (NULL); |
| 1643 | /* |
| 1644 | * First level 1 |
| 1645 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1646 | if (area->is_type & IS_LEVEL_1) |
| 1647 | { |
| 1648 | lsp = lsp_search (id, area->lspdb[0]); |
| 1649 | if (!lsp || area->lsp_regenerate_pending[0]) |
| 1650 | goto L2; |
| 1651 | /* |
| 1652 | * Throttle avoidance |
| 1653 | */ |
| 1654 | diff = now - lsp->last_generated; |
| 1655 | if (diff < MIN_LSP_GEN_INTERVAL) |
| 1656 | { |
| 1657 | area->lsp_regenerate_pending[0] = 1; |
Fritz Reichmann | 5574999 | 2011-09-14 19:31:51 +0400 | [diff] [blame] | 1658 | area->t_lsp_l1_regenerate=thread_add_timer (master, lsp_l1_regenerate, area, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1659 | MIN_LSP_GEN_INTERVAL - diff); |
hasso | 12a5cae | 2004-09-19 19:39:26 +0000 | [diff] [blame] | 1660 | goto L2; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1661 | } |
| 1662 | else |
| 1663 | lsp_non_pseudo_regenerate (area, 1); |
| 1664 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1665 | /* |
| 1666 | * then 2 |
| 1667 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1668 | L2: |
| 1669 | if (area->is_type & IS_LEVEL_2) |
| 1670 | { |
| 1671 | lsp = lsp_search (id, area->lspdb[1]); |
| 1672 | if (!lsp || area->lsp_regenerate_pending[1]) |
| 1673 | return ISIS_OK; |
| 1674 | /* |
| 1675 | * Throttle avoidance |
| 1676 | */ |
| 1677 | diff = now - lsp->last_generated; |
| 1678 | if (diff < MIN_LSP_GEN_INTERVAL) |
| 1679 | { |
| 1680 | area->lsp_regenerate_pending[1] = 1; |
Fritz Reichmann | 5574999 | 2011-09-14 19:31:51 +0400 | [diff] [blame] | 1681 | area->t_lsp_l2_regenerate=thread_add_timer (master, lsp_l2_regenerate, area, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1682 | MIN_LSP_GEN_INTERVAL - diff); |
| 1683 | return ISIS_OK; |
| 1684 | } |
| 1685 | else |
| 1686 | lsp_non_pseudo_regenerate (area, 2); |
| 1687 | } |
| 1688 | |
| 1689 | return ISIS_OK; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1690 | } |
| 1691 | |
| 1692 | /* |
| 1693 | * Funcs for pseudonode LSPs |
| 1694 | */ |
| 1695 | |
| 1696 | /* |
| 1697 | * 7.3.8 and 7.3.10 Generation of level 1 and 2 pseudonode LSPs |
| 1698 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1699 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1700 | lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit, |
| 1701 | int level) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1702 | { |
| 1703 | struct isis_adjacency *adj; |
| 1704 | struct is_neigh *is_neigh; |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1705 | struct te_is_neigh *te_is_neigh; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1706 | struct es_neigh *es_neigh; |
| 1707 | struct list *adj_list; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1708 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1709 | struct isis_passwd *passwd; |
| 1710 | |
| 1711 | assert (circuit); |
| 1712 | assert (circuit->circ_type == CIRCUIT_T_BROADCAST); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1713 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1714 | if (!circuit->u.bc.is_dr[level - 1]) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1715 | return; /* we are not DIS on this circuit */ |
| 1716 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1717 | lsp->level = level; |
| 1718 | if (level == 1) |
| 1719 | lsp->lsp_header->lsp_bits |= IS_LEVEL_1; |
| 1720 | else |
| 1721 | lsp->lsp_header->lsp_bits |= IS_LEVEL_2; |
| 1722 | |
| 1723 | /* |
| 1724 | * add self to IS neighbours |
| 1725 | */ |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1726 | if (circuit->area->oldmetric) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1727 | { |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1728 | if (lsp->tlv_data.is_neighs == NULL) |
| 1729 | { |
| 1730 | lsp->tlv_data.is_neighs = list_new (); |
| 1731 | lsp->tlv_data.is_neighs->del = free_tlv; |
| 1732 | } |
| 1733 | is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); |
paul | 15935e9 | 2005-05-03 09:27:23 +0000 | [diff] [blame] | 1734 | |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1735 | memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN); |
| 1736 | listnode_add (lsp->tlv_data.is_neighs, is_neigh); |
| 1737 | } |
| 1738 | if (circuit->area->newmetric) |
| 1739 | { |
| 1740 | if (lsp->tlv_data.te_is_neighs == NULL) |
| 1741 | { |
| 1742 | lsp->tlv_data.te_is_neighs = list_new (); |
| 1743 | lsp->tlv_data.te_is_neighs->del = free_tlv; |
| 1744 | } |
| 1745 | te_is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct te_is_neigh)); |
| 1746 | |
| 1747 | memcpy (&te_is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN); |
| 1748 | listnode_add (lsp->tlv_data.te_is_neighs, te_is_neigh); |
| 1749 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1750 | |
| 1751 | adj_list = list_new (); |
| 1752 | isis_adj_build_up_list (circuit->u.bc.adjdb[level - 1], adj_list); |
| 1753 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1754 | for (ALL_LIST_ELEMENTS_RO (adj_list, node, adj)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1755 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1756 | if (adj->circuit_t & level) |
| 1757 | { |
| 1758 | if ((level == 1 && adj->sys_type == ISIS_SYSTYPE_L1_IS) || |
| 1759 | (level == 1 && adj->sys_type == ISIS_SYSTYPE_L2_IS && |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1760 | adj->adj_usage == ISIS_ADJ_LEVEL1AND2) || |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1761 | (level == 2 && adj->sys_type == ISIS_SYSTYPE_L2_IS)) |
| 1762 | { |
| 1763 | /* an IS neighbour -> add it */ |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1764 | if (circuit->area->oldmetric) |
| 1765 | { |
| 1766 | is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); |
paul | 15935e9 | 2005-05-03 09:27:23 +0000 | [diff] [blame] | 1767 | |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1768 | memcpy (&is_neigh->neigh_id, adj->sysid, ISIS_SYS_ID_LEN); |
| 1769 | listnode_add (lsp->tlv_data.is_neighs, is_neigh); |
| 1770 | } |
| 1771 | if (circuit->area->newmetric) |
| 1772 | { |
| 1773 | te_is_neigh = XCALLOC (MTYPE_ISIS_TLV, |
| 1774 | sizeof (struct te_is_neigh)); |
| 1775 | memcpy (&te_is_neigh->neigh_id, adj->sysid, ISIS_SYS_ID_LEN); |
| 1776 | listnode_add (lsp->tlv_data.te_is_neighs, te_is_neigh); |
| 1777 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1778 | } |
| 1779 | else if (level == 1 && adj->sys_type == ISIS_SYSTYPE_ES) |
| 1780 | { |
| 1781 | /* an ES neigbour add it, if we are building level 1 LSP */ |
| 1782 | /* FIXME: the tlv-format is hard to use here */ |
| 1783 | if (lsp->tlv_data.es_neighs == NULL) |
| 1784 | { |
| 1785 | lsp->tlv_data.es_neighs = list_new (); |
| 1786 | lsp->tlv_data.es_neighs->del = free_tlv; |
| 1787 | } |
paul | 15935e9 | 2005-05-03 09:27:23 +0000 | [diff] [blame] | 1788 | es_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct es_neigh)); |
| 1789 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1790 | memcpy (&es_neigh->first_es_neigh, adj->sysid, ISIS_SYS_ID_LEN); |
hasso | aac372f | 2005-09-01 17:52:33 +0000 | [diff] [blame] | 1791 | listnode_add (lsp->tlv_data.es_neighs, es_neigh); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1792 | } |
| 1793 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1794 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1795 | |
hasso | c0fb2a5 | 2005-09-03 16:29:40 +0000 | [diff] [blame] | 1796 | /* Reset endp of stream to overwrite only TLV part of it. */ |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 1797 | stream_reset (lsp->pdu); |
hasso | c0fb2a5 | 2005-09-03 16:29:40 +0000 | [diff] [blame] | 1798 | stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); |
| 1799 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1800 | /* |
| 1801 | * Add the authentication info if it's present |
| 1802 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1803 | (level == 1) ? (passwd = &circuit->area->area_passwd) : |
| 1804 | (passwd = &circuit->area->domain_passwd); |
| 1805 | if (passwd->type) |
| 1806 | { |
| 1807 | memcpy (&lsp->tlv_data.auth_info, passwd, sizeof (struct isis_passwd)); |
| 1808 | tlv_add_authinfo (passwd->type, passwd->len, passwd->passwd, lsp->pdu); |
| 1809 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1810 | |
| 1811 | if (lsp->tlv_data.is_neighs && listcount (lsp->tlv_data.is_neighs) > 0) |
| 1812 | tlv_add_is_neighs (lsp->tlv_data.is_neighs, lsp->pdu); |
| 1813 | |
hasso | aa4376e | 2005-09-26 17:39:48 +0000 | [diff] [blame] | 1814 | if (lsp->tlv_data.te_is_neighs && listcount (lsp->tlv_data.te_is_neighs) > 0) |
| 1815 | tlv_add_te_is_neighs (lsp->tlv_data.te_is_neighs, lsp->pdu); |
| 1816 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1817 | if (lsp->tlv_data.es_neighs && listcount (lsp->tlv_data.es_neighs) > 0) |
| 1818 | tlv_add_is_neighs (lsp->tlv_data.es_neighs, lsp->pdu); |
| 1819 | |
paul | 9985f83 | 2005-02-09 15:51:56 +0000 | [diff] [blame] | 1820 | lsp->lsp_header->pdu_len = htons (stream_get_endp (lsp->pdu)); |
Jingjing Duan | 6a270cd | 2008-08-13 19:09:10 +0100 | [diff] [blame] | 1821 | fletcher_checksum (STREAM_DATA (lsp->pdu) + 12, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1822 | ntohs (lsp->lsp_header->pdu_len) - 12, 12); |
| 1823 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1824 | list_delete (adj_list); |
| 1825 | |
| 1826 | return; |
| 1827 | } |
| 1828 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 1829 | static int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1830 | lsp_pseudo_regenerate (struct isis_circuit *circuit, int level) |
| 1831 | { |
| 1832 | dict_t *lspdb = circuit->area->lspdb[level - 1]; |
| 1833 | struct isis_lsp *lsp; |
| 1834 | u_char lsp_id[ISIS_SYS_ID_LEN + 2]; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1835 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1836 | memcpy (lsp_id, isis->sysid, ISIS_SYS_ID_LEN); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1837 | LSP_PSEUDO_ID (lsp_id) = circuit->circuit_id; |
| 1838 | LSP_FRAGMENT (lsp_id) = 0; |
| 1839 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1840 | lsp = lsp_search (lsp_id, lspdb); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1841 | |
| 1842 | if (!lsp) |
| 1843 | { |
| 1844 | zlog_err ("lsp_pseudo_regenerate(): no l%d LSP %s found!", level, |
| 1845 | rawlspid_print (lsp_id)); |
| 1846 | return ISIS_ERROR; |
| 1847 | } |
| 1848 | lsp_clear_data (lsp); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1849 | |
| 1850 | lsp_build_pseudo (lsp, circuit, level); |
| 1851 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1852 | lsp->lsp_header->rem_lifetime = |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1853 | htons (isis_jitter (circuit->area->max_lsp_lifetime[level - 1], |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1854 | MAX_AGE_JITTER)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1855 | |
| 1856 | lsp_inc_seqnum (lsp, 0); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1857 | |
| 1858 | if (isis->debugs & DEBUG_UPDATE_PACKETS) |
| 1859 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 1860 | zlog_debug ("ISIS-Upd (%s): refreshing pseudo LSP L%d %s", |
| 1861 | circuit->area->area_tag, level, |
| 1862 | rawlspid_print (lsp->lsp_header->lsp_id)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1863 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1864 | |
| 1865 | lsp->last_generated = time (NULL); |
| 1866 | ISIS_FLAGS_SET_ALL (lsp->SRMflags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1867 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1868 | return ISIS_OK; |
| 1869 | } |
| 1870 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1871 | int |
| 1872 | lsp_l1_refresh_pseudo (struct thread *thread) |
| 1873 | { |
| 1874 | struct isis_circuit *circuit; |
| 1875 | int retval; |
| 1876 | unsigned long ref_time; |
| 1877 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1878 | circuit = THREAD_ARG (thread); |
| 1879 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1880 | if (!circuit->u.bc.is_dr[0]) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1881 | return ISIS_ERROR; /* FIXME: purge and such */ |
| 1882 | |
hasso | 13c48f7 | 2004-09-10 21:19:13 +0000 | [diff] [blame] | 1883 | circuit->u.bc.t_refresh_pseudo_lsp[0] = NULL; |
| 1884 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1885 | retval = lsp_pseudo_regenerate (circuit, 1); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1886 | |
| 1887 | ref_time = circuit->area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ? |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1888 | MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[0]; |
| 1889 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1890 | THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[0], |
| 1891 | lsp_l1_refresh_pseudo, circuit, |
| 1892 | isis_jitter (ref_time, MAX_AGE_JITTER)); |
| 1893 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1894 | return retval; |
| 1895 | } |
| 1896 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1897 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1898 | lsp_l1_pseudo_generate (struct isis_circuit *circuit) |
| 1899 | { |
| 1900 | struct isis_lsp *lsp; |
| 1901 | u_char id[ISIS_SYS_ID_LEN + 2]; |
| 1902 | unsigned long ref_time; |
| 1903 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1904 | memcpy (id, isis->sysid, ISIS_SYS_ID_LEN); |
| 1905 | LSP_FRAGMENT (id) = 0; |
| 1906 | LSP_PSEUDO_ID (id) = circuit->circuit_id; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1907 | |
| 1908 | /* |
| 1909 | * If for some reason have a pseudo LSP in the db already -> regenerate |
| 1910 | */ |
| 1911 | if (lsp_search (id, circuit->area->lspdb[0])) |
| 1912 | return lsp_pseudo_regenerate (circuit, 1); |
| 1913 | lsp = lsp_new (id, circuit->area->max_lsp_lifetime[0], |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1914 | 1, circuit->area->is_type, 0, 1); |
| 1915 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1916 | lsp_build_pseudo (lsp, circuit, 1); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1917 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1918 | lsp->own_lsp = 1; |
| 1919 | lsp_insert (lsp, circuit->area->lspdb[0]); |
| 1920 | ISIS_FLAGS_SET_ALL (lsp->SRMflags); |
| 1921 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1922 | ref_time = circuit->area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ? |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1923 | MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[0]; |
| 1924 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1925 | THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[0], |
| 1926 | lsp_l1_refresh_pseudo, circuit, |
| 1927 | isis_jitter (ref_time, MAX_AGE_JITTER)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1928 | |
| 1929 | return lsp_regenerate_schedule (circuit->area); |
| 1930 | } |
| 1931 | |
| 1932 | int |
| 1933 | lsp_l2_refresh_pseudo (struct thread *thread) |
| 1934 | { |
| 1935 | struct isis_circuit *circuit; |
| 1936 | int retval; |
| 1937 | unsigned long ref_time; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1938 | circuit = THREAD_ARG (thread); |
| 1939 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1940 | if (!circuit->u.bc.is_dr[1]) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1941 | return ISIS_ERROR; /* FIXME: purge and such */ |
| 1942 | |
hasso | 13c48f7 | 2004-09-10 21:19:13 +0000 | [diff] [blame] | 1943 | circuit->u.bc.t_refresh_pseudo_lsp[1] = NULL; |
| 1944 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1945 | retval = lsp_pseudo_regenerate (circuit, 2); |
| 1946 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1947 | ref_time = circuit->area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ? |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1948 | MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[1]; |
| 1949 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1950 | THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[1], |
| 1951 | lsp_l2_refresh_pseudo, circuit, |
| 1952 | isis_jitter (ref_time, MAX_AGE_JITTER)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1953 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1954 | return retval; |
| 1955 | } |
| 1956 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1957 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1958 | lsp_l2_pseudo_generate (struct isis_circuit *circuit) |
| 1959 | { |
| 1960 | struct isis_lsp *lsp; |
| 1961 | u_char id[ISIS_SYS_ID_LEN + 2]; |
| 1962 | unsigned long ref_time; |
| 1963 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1964 | memcpy (id, isis->sysid, ISIS_SYS_ID_LEN); |
| 1965 | LSP_FRAGMENT (id) = 0; |
| 1966 | LSP_PSEUDO_ID (id) = circuit->circuit_id; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1967 | |
| 1968 | if (lsp_search (id, circuit->area->lspdb[1])) |
| 1969 | return lsp_pseudo_regenerate (circuit, 2); |
| 1970 | |
| 1971 | lsp = lsp_new (id, circuit->area->max_lsp_lifetime[1], |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1972 | 1, circuit->area->is_type, 0, 2); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1973 | |
| 1974 | lsp_build_pseudo (lsp, circuit, 2); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1975 | |
| 1976 | ref_time = circuit->area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ? |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1977 | MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[1]; |
| 1978 | |
| 1979 | |
| 1980 | lsp->own_lsp = 1; |
| 1981 | lsp_insert (lsp, circuit->area->lspdb[1]); |
| 1982 | ISIS_FLAGS_SET_ALL (lsp->SRMflags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1983 | |
| 1984 | THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[1], |
| 1985 | lsp_l2_refresh_pseudo, circuit, |
| 1986 | isis_jitter (ref_time, MAX_AGE_JITTER)); |
| 1987 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1988 | return lsp_regenerate_schedule (circuit->area); |
| 1989 | } |
| 1990 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1991 | /* |
| 1992 | * Walk through LSPs for an area |
| 1993 | * - set remaining lifetime |
| 1994 | * - set LSPs with SRMflag set for sending |
| 1995 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1996 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1997 | lsp_tick (struct thread *thread) |
| 1998 | { |
| 1999 | struct isis_area *area; |
| 2000 | struct isis_circuit *circuit; |
| 2001 | struct isis_lsp *lsp; |
| 2002 | struct list *lsp_list; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 2003 | struct listnode *lspnode, *cnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2004 | dnode_t *dnode, *dnode_next; |
| 2005 | int level; |
| 2006 | |
| 2007 | lsp_list = list_new (); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2008 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2009 | area = THREAD_ARG (thread); |
| 2010 | assert (area); |
hasso | 13c48f7 | 2004-09-10 21:19:13 +0000 | [diff] [blame] | 2011 | area->t_tick = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2012 | THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2013 | |
| 2014 | /* |
| 2015 | * Build a list of LSPs with (any) SRMflag set |
| 2016 | * and removed the ones that have aged out |
| 2017 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2018 | for (level = 0; level < ISIS_LEVELS; level++) |
| 2019 | { |
| 2020 | if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0) |
| 2021 | { |
| 2022 | dnode = dict_first (area->lspdb[level]); |
| 2023 | while (dnode != NULL) |
| 2024 | { |
| 2025 | dnode_next = dict_next (area->lspdb[level], dnode); |
| 2026 | lsp = dnode_get (dnode); |
| 2027 | lsp_set_time (lsp); |
| 2028 | if (lsp->age_out == 0) |
| 2029 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2030 | |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 2031 | zlog_debug ("ISIS-Upd (%s): L%u LSP %s seq 0x%08x aged out", |
| 2032 | area->area_tag, |
| 2033 | lsp->level, |
| 2034 | rawlspid_print (lsp->lsp_header->lsp_id), |
| 2035 | ntohl (lsp->lsp_header->seq_num)); |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2036 | #ifdef TOPOLOGY_GENERATE |
| 2037 | if (lsp->from_topology) |
| 2038 | THREAD_TIMER_OFF (lsp->t_lsp_top_ref); |
| 2039 | #endif /* TOPOLOGY_GENERATE */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2040 | lsp_destroy (lsp); |
| 2041 | dict_delete (area->lspdb[level], dnode); |
| 2042 | } |
| 2043 | else if (flags_any_set (lsp->SRMflags)) |
| 2044 | listnode_add (lsp_list, lsp); |
| 2045 | dnode = dnode_next; |
| 2046 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2047 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2048 | /* |
| 2049 | * Send LSPs on circuits indicated by the SRMflags |
| 2050 | */ |
| 2051 | if (listcount (lsp_list) > 0) |
| 2052 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2053 | for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2054 | { |
Peter Szilagyi | 7fd6cd8 | 2011-10-01 17:11:45 +0400 | [diff] [blame] | 2055 | if (circuit->state != C_STATE_UP) |
| 2056 | continue; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 2057 | for (ALL_LIST_ELEMENTS_RO (lsp_list, lspnode, lsp)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2058 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2059 | if (ISIS_CHECK_FLAG (lsp->SRMflags, circuit)) |
| 2060 | { |
| 2061 | /* FIXME: if same or elder lsp is already in lsp |
| 2062 | * queue */ |
| 2063 | listnode_add (circuit->lsp_queue, lsp); |
| 2064 | thread_add_event (master, send_lsp, circuit, 0); |
| 2065 | } |
| 2066 | } |
| 2067 | } |
| 2068 | } |
| 2069 | list_delete_all_node (lsp_list); |
| 2070 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2071 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2072 | |
| 2073 | list_delete (lsp_list); |
| 2074 | |
| 2075 | return ISIS_OK; |
| 2076 | } |
| 2077 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2078 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2079 | lsp_purge_dr (u_char * id, struct isis_circuit *circuit, int level) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2080 | { |
| 2081 | struct isis_lsp *lsp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2082 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2083 | lsp = lsp_search (id, circuit->area->lspdb[level - 1]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2084 | |
| 2085 | if (lsp && lsp->purged == 0) |
| 2086 | { |
| 2087 | lsp->lsp_header->rem_lifetime = htons (0); |
| 2088 | lsp->lsp_header->pdu_len = |
| 2089 | htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); |
| 2090 | lsp->purged = 0; |
Jingjing Duan | 6a270cd | 2008-08-13 19:09:10 +0100 | [diff] [blame] | 2091 | fletcher_checksum (STREAM_DATA (lsp->pdu) + 12, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2092 | ntohs (lsp->lsp_header->pdu_len) - 12, 12); |
| 2093 | ISIS_FLAGS_SET_ALL (lsp->SRMflags); |
| 2094 | } |
| 2095 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2096 | return; |
| 2097 | } |
| 2098 | |
| 2099 | /* |
| 2100 | * Purge own LSP that is received and we don't have. |
| 2101 | * -> Do as in 7.3.16.4 |
| 2102 | */ |
| 2103 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2104 | lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr, |
| 2105 | struct isis_area *area) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2106 | { |
| 2107 | struct isis_lsp *lsp; |
| 2108 | |
| 2109 | /* |
| 2110 | * We need to create the LSP to be purged |
| 2111 | */ |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 2112 | zlog_debug ("LSP PURGE NON EXIST"); |
hasso | aac372f | 2005-09-01 17:52:33 +0000 | [diff] [blame] | 2113 | lsp = XCALLOC (MTYPE_ISIS_LSP, sizeof (struct isis_lsp)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2114 | /*FIXME: BUG BUG BUG! the lsp doesn't exist here! */ |
| 2115 | /*did smt here, maybe good probably not */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2116 | lsp->level = ((lsp_hdr->lsp_bits & LSPBIT_IST) == IS_LEVEL_1) ? 1 : 2; |
| 2117 | lsp->pdu = stream_new (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2118 | lsp->isis_header = (struct isis_fixed_hdr *) STREAM_DATA (lsp->pdu); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2119 | fill_fixed_hdr (lsp->isis_header, (lsp->level == 1) ? L1_LINK_STATE |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2120 | : L2_LINK_STATE); |
| 2121 | lsp->lsp_header = (struct isis_link_state_hdr *) (STREAM_DATA (lsp->pdu) + |
| 2122 | ISIS_FIXED_HDR_LEN); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2123 | memcpy (lsp->lsp_header, lsp_hdr, ISIS_LSP_HDR_LEN); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2124 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2125 | /* |
| 2126 | * Retain only LSP header |
| 2127 | */ |
| 2128 | lsp->lsp_header->pdu_len = htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); |
| 2129 | /* |
| 2130 | * Set the remaining lifetime to 0 |
| 2131 | */ |
| 2132 | lsp->lsp_header->rem_lifetime = 0; |
| 2133 | /* |
| 2134 | * Put the lsp into LSPdb |
| 2135 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2136 | lsp_insert (lsp, area->lspdb[lsp->level - 1]); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2137 | |
| 2138 | /* |
| 2139 | * Send in to whole area |
| 2140 | */ |
| 2141 | ISIS_FLAGS_SET_ALL (lsp->SRMflags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2142 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2143 | return; |
| 2144 | } |
| 2145 | |
| 2146 | #ifdef TOPOLOGY_GENERATE |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 2147 | static int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2148 | top_lsp_refresh (struct thread *thread) |
| 2149 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2150 | struct isis_lsp *lsp; |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2151 | unsigned long ref_time; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2152 | |
| 2153 | lsp = THREAD_ARG (thread); |
| 2154 | assert (lsp); |
| 2155 | |
| 2156 | lsp->t_lsp_top_ref = NULL; |
| 2157 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2158 | lsp_seqnum_update (lsp); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2159 | |
| 2160 | ISIS_FLAGS_SET_ALL (lsp->SRMflags); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2161 | if (isis->debugs & DEBUG_UPDATE_PACKETS) |
| 2162 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 2163 | zlog_debug ("ISIS-Upd (): refreshing Topology L1 %s", |
| 2164 | rawlspid_print (lsp->lsp_header->lsp_id)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2165 | } |
hasso | d3d7474 | 2005-09-28 18:30:51 +0000 | [diff] [blame] | 2166 | /* Refresh dynamic hostname in the cache. */ |
| 2167 | isis_dynhn_insert (lsp->lsp_header->lsp_id, lsp->tlv_data.hostname, |
| 2168 | IS_LEVEL_1); |
| 2169 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2170 | lsp->lsp_header->rem_lifetime = |
| 2171 | htons (isis_jitter (lsp->area->max_lsp_lifetime[0], MAX_AGE_JITTER)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2172 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2173 | ref_time = lsp->area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ? |
| 2174 | MAX_LSP_GEN_INTERVAL : lsp->area->lsp_refresh[0]; |
| 2175 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2176 | THREAD_TIMER_ON (master, lsp->t_lsp_top_ref, top_lsp_refresh, lsp, |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2177 | isis_jitter (ref_time, MAX_LSP_GEN_JITTER)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2178 | |
| 2179 | return ISIS_OK; |
| 2180 | } |
| 2181 | |
| 2182 | void |
| 2183 | generate_topology_lsps (struct isis_area *area) |
| 2184 | { |
| 2185 | struct listnode *node; |
| 2186 | int i, max = 0; |
| 2187 | struct arc *arc; |
| 2188 | u_char lspid[ISIS_SYS_ID_LEN + 2]; |
| 2189 | struct isis_lsp *lsp; |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2190 | unsigned long ref_time; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2191 | |
| 2192 | /* first we find the maximal node */ |
paul | a8f03df | 2005-04-10 15:58:10 +0000 | [diff] [blame] | 2193 | for (ALL_LIST_ELEMENTS_RO (area->topology, node, arc)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2194 | { |
| 2195 | if (arc->from_node > max) |
| 2196 | max = arc->from_node; |
| 2197 | if (arc->to_node > max) |
| 2198 | max = arc->to_node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2199 | } |
| 2200 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2201 | for (i = 1; i < (max + 1); i++) |
| 2202 | { |
| 2203 | memcpy (lspid, area->topology_baseis, ISIS_SYS_ID_LEN); |
| 2204 | LSP_PSEUDO_ID (lspid) = 0x00; |
| 2205 | LSP_FRAGMENT (lspid) = 0x00; |
| 2206 | lspid[ISIS_SYS_ID_LEN - 1] = (i & 0xFF); |
| 2207 | lspid[ISIS_SYS_ID_LEN - 2] = ((i >> 8) & 0xFF); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2208 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2209 | lsp = lsp_new (lspid, isis_jitter (area->max_lsp_lifetime[0], |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2210 | MAX_AGE_JITTER), 1, IS_LEVEL_1, 0, 1); |
| 2211 | if (!lsp) |
| 2212 | return; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2213 | lsp->from_topology = 1; |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2214 | lsp->area = area; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2215 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2216 | /* Creating LSP data based on topology info. */ |
| 2217 | build_topology_lsp_data (lsp, area, i); |
| 2218 | /* Checksum is also calculated here. */ |
| 2219 | lsp_seqnum_update (lsp); |
hasso | 9551eea | 2005-09-28 18:26:25 +0000 | [diff] [blame] | 2220 | /* Take care of inserting dynamic hostname into cache. */ |
| 2221 | isis_dynhn_insert (lspid, lsp->tlv_data.hostname, IS_LEVEL_1); |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2222 | |
| 2223 | ref_time = area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ? |
| 2224 | MAX_LSP_GEN_INTERVAL : area->lsp_refresh[0]; |
| 2225 | |
| 2226 | THREAD_TIMER_ON (master, lsp->t_lsp_top_ref, top_lsp_refresh, lsp, |
| 2227 | isis_jitter (ref_time, MAX_LSP_GEN_JITTER)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2228 | ISIS_FLAGS_SET_ALL (lsp->SRMflags); |
| 2229 | lsp_insert (lsp, area->lspdb[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2230 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2231 | } |
| 2232 | |
| 2233 | void |
| 2234 | remove_topology_lsps (struct isis_area *area) |
| 2235 | { |
| 2236 | struct isis_lsp *lsp; |
| 2237 | dnode_t *dnode, *dnode_next; |
| 2238 | |
| 2239 | dnode = dict_first (area->lspdb[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2240 | while (dnode != NULL) |
| 2241 | { |
| 2242 | dnode_next = dict_next (area->lspdb[0], dnode); |
| 2243 | lsp = dnode_get (dnode); |
| 2244 | if (lsp->from_topology) |
| 2245 | { |
| 2246 | THREAD_TIMER_OFF (lsp->t_lsp_top_ref); |
| 2247 | lsp_destroy (lsp); |
| 2248 | dict_delete (area->lspdb[0], dnode); |
| 2249 | } |
| 2250 | dnode = dnode_next; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2251 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2252 | } |
| 2253 | |
| 2254 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2255 | build_topology_lsp_data (struct isis_lsp *lsp, struct isis_area *area, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2256 | int lsp_top_num) |
| 2257 | { |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 2258 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2259 | struct arc *arc; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2260 | struct is_neigh *is_neigh; |
hasso | 9551eea | 2005-09-28 18:26:25 +0000 | [diff] [blame] | 2261 | struct te_is_neigh *te_is_neigh; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2262 | char buff[200]; |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2263 | struct tlvs tlv_data; |
| 2264 | struct isis_lsp *lsp0 = lsp; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2265 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2266 | /* Add area addresses. FIXME: Is it needed at all? */ |
| 2267 | if (lsp->tlv_data.area_addrs == NULL) |
| 2268 | lsp->tlv_data.area_addrs = list_new (); |
| 2269 | list_add_list (lsp->tlv_data.area_addrs, area->area_addrs); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2270 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2271 | if (lsp->tlv_data.nlpids == NULL) |
| 2272 | lsp->tlv_data.nlpids = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct nlpids)); |
| 2273 | lsp->tlv_data.nlpids->count = 1; |
| 2274 | lsp->tlv_data.nlpids->nlpids[0] = NLPID_IP; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2275 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2276 | if (area->dynhostname) |
| 2277 | { |
| 2278 | lsp->tlv_data.hostname = XMALLOC (MTYPE_ISIS_TLV, |
| 2279 | sizeof (struct hostname)); |
| 2280 | memset (buff, 0x00, 200); |
| 2281 | sprintf (buff, "%s%d", area->topology_basedynh ? area->topology_basedynh : |
| 2282 | "feedme", lsp_top_num); |
| 2283 | memcpy (lsp->tlv_data.hostname->name, buff, strlen (buff)); |
| 2284 | lsp->tlv_data.hostname->namelen = strlen (buff); |
| 2285 | } |
| 2286 | |
| 2287 | if (lsp->tlv_data.nlpids) |
| 2288 | tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu); |
| 2289 | if (lsp->tlv_data.hostname) |
| 2290 | tlv_add_dynamic_hostname (lsp->tlv_data.hostname, lsp->pdu); |
| 2291 | if (lsp->tlv_data.area_addrs && listcount (lsp->tlv_data.area_addrs) > 0) |
| 2292 | tlv_add_area_addrs (lsp->tlv_data.area_addrs, lsp->pdu); |
| 2293 | |
| 2294 | memset (&tlv_data, 0, sizeof (struct tlvs)); |
| 2295 | if (tlv_data.is_neighs == NULL) |
hasso | 9551eea | 2005-09-28 18:26:25 +0000 | [diff] [blame] | 2296 | { |
| 2297 | tlv_data.is_neighs = list_new (); |
| 2298 | tlv_data.is_neighs->del = free_tlv; |
| 2299 | } |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2300 | |
| 2301 | /* Add reachability for this IS for simulated 1. */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2302 | if (lsp_top_num == 1) |
| 2303 | { |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 2304 | is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2305 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2306 | memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2307 | LSP_PSEUDO_ID (is_neigh->neigh_id) = 0x00; |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2308 | /* Metric MUST NOT be 0, unless it's not alias TLV. */ |
| 2309 | is_neigh->metrics.metric_default = 0x01; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2310 | is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED; |
| 2311 | is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED; |
| 2312 | is_neigh->metrics.metric_error = METRICS_UNSUPPORTED; |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2313 | listnode_add (tlv_data.is_neighs, is_neigh); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2314 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2315 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2316 | /* Add IS reachabilities. */ |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 2317 | for (ALL_LIST_ELEMENTS_RO (area->topology, node, arc)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2318 | { |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2319 | int to_lsp = 0; |
| 2320 | |
| 2321 | if ((lsp_top_num != arc->from_node) && (lsp_top_num != arc->to_node)) |
| 2322 | continue; |
| 2323 | |
| 2324 | if (lsp_top_num == arc->from_node) |
| 2325 | to_lsp = arc->to_node; |
| 2326 | else |
| 2327 | to_lsp = arc->from_node; |
| 2328 | |
hasso | 9551eea | 2005-09-28 18:26:25 +0000 | [diff] [blame] | 2329 | if (area->oldmetric) |
| 2330 | { |
| 2331 | is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2332 | |
hasso | 9551eea | 2005-09-28 18:26:25 +0000 | [diff] [blame] | 2333 | memcpy (&is_neigh->neigh_id, area->topology_baseis, ISIS_SYS_ID_LEN); |
| 2334 | is_neigh->neigh_id[ISIS_SYS_ID_LEN - 1] = (to_lsp & 0xFF); |
| 2335 | is_neigh->neigh_id[ISIS_SYS_ID_LEN - 2] = ((to_lsp >> 8) & 0xFF); |
| 2336 | is_neigh->metrics.metric_default = arc->distance; |
| 2337 | is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED; |
| 2338 | is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED; |
| 2339 | is_neigh->metrics.metric_error = METRICS_UNSUPPORTED; |
| 2340 | listnode_add (tlv_data.is_neighs, is_neigh); |
| 2341 | } |
| 2342 | |
| 2343 | if (area->newmetric) |
| 2344 | { |
| 2345 | uint32_t metric; |
| 2346 | |
| 2347 | if (tlv_data.te_is_neighs == NULL) |
| 2348 | { |
| 2349 | tlv_data.te_is_neighs = list_new (); |
| 2350 | tlv_data.te_is_neighs->del = free_tlv; |
| 2351 | } |
| 2352 | te_is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct te_is_neigh)); |
| 2353 | memcpy (&te_is_neigh->neigh_id, area->topology_baseis, |
| 2354 | ISIS_SYS_ID_LEN); |
| 2355 | te_is_neigh->neigh_id[ISIS_SYS_ID_LEN - 1] = (to_lsp & 0xFF); |
| 2356 | te_is_neigh->neigh_id[ISIS_SYS_ID_LEN - 2] = ((to_lsp >> 8) & 0xFF); |
| 2357 | metric = ((htonl(arc->distance) >> 8) & 0xffffff); |
| 2358 | memcpy (te_is_neigh->te_metric, &metric, 3); |
| 2359 | listnode_add (tlv_data.te_is_neighs, te_is_neigh); |
| 2360 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2361 | } |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2362 | |
| 2363 | while (tlv_data.is_neighs && listcount (tlv_data.is_neighs)) |
| 2364 | { |
| 2365 | if (lsp->tlv_data.is_neighs == NULL) |
| 2366 | lsp->tlv_data.is_neighs = list_new (); |
hasso | 9551eea | 2005-09-28 18:26:25 +0000 | [diff] [blame] | 2367 | lsp_tlv_fit (lsp, &tlv_data.is_neighs, &lsp->tlv_data.is_neighs, |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2368 | IS_NEIGHBOURS_LEN, area->lsp_frag_threshold, |
| 2369 | tlv_add_is_neighs); |
| 2370 | if (tlv_data.is_neighs && listcount (tlv_data.is_neighs)) |
| 2371 | lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1, |
| 2372 | lsp0, area, IS_LEVEL_1); |
| 2373 | } |
| 2374 | |
hasso | 9551eea | 2005-09-28 18:26:25 +0000 | [diff] [blame] | 2375 | while (tlv_data.te_is_neighs && listcount (tlv_data.te_is_neighs)) |
| 2376 | { |
| 2377 | if (lsp->tlv_data.te_is_neighs == NULL) |
| 2378 | lsp->tlv_data.te_is_neighs = list_new (); |
| 2379 | lsp_tlv_fit (lsp, &tlv_data.te_is_neighs, &lsp->tlv_data.te_is_neighs, |
| 2380 | IS_NEIGHBOURS_LEN, area->lsp_frag_threshold, |
| 2381 | tlv_add_te_is_neighs); |
| 2382 | if (tlv_data.te_is_neighs && listcount (tlv_data.te_is_neighs)) |
| 2383 | lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1, |
| 2384 | lsp0, area, IS_LEVEL_1); |
| 2385 | } |
| 2386 | |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 2387 | free_tlvs (&tlv_data); |
| 2388 | return; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2389 | } |
| 2390 | #endif /* TOPOLOGY_GENERATE */ |