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