jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_adjacency.c |
| 3 | * handling of IS-IS adjacencies |
| 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 | */ |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <limits.h> |
| 26 | #include <string.h> |
| 27 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 28 | |
| 29 | #include "log.h" |
| 30 | #include "memory.h" |
| 31 | #include "hash.h" |
| 32 | #include "vty.h" |
| 33 | #include "linklist.h" |
| 34 | #include "thread.h" |
| 35 | #include "if.h" |
| 36 | #include "stream.h" |
| 37 | |
| 38 | #include "isisd/dict.h" |
| 39 | #include "isisd/include-netbsd/iso.h" |
| 40 | #include "isisd/isis_constants.h" |
| 41 | #include "isisd/isis_common.h" |
| 42 | #include "isisd/isisd.h" |
| 43 | #include "isisd/isis_circuit.h" |
| 44 | #include "isisd/isis_adjacency.h" |
| 45 | #include "isisd/isis_misc.h" |
| 46 | #include "isisd/isis_dr.h" |
| 47 | #include "isisd/isis_dynhn.h" |
| 48 | #include "isisd/isis_pdu.h" |
| 49 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 50 | extern struct isis *isis; |
| 51 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 52 | static struct isis_adjacency * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 53 | adj_alloc (u_char * id) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 54 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 55 | struct isis_adjacency *adj; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 56 | |
hasso | aac372f | 2005-09-01 17:52:33 +0000 | [diff] [blame] | 57 | adj = XCALLOC (MTYPE_ISIS_ADJACENCY, sizeof (struct isis_adjacency)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 58 | memcpy (adj->sysid, id, ISIS_SYS_ID_LEN); |
| 59 | |
| 60 | return adj; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | struct isis_adjacency * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 64 | isis_new_adj (u_char * id, u_char * snpa, int level, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 65 | struct isis_circuit *circuit) |
| 66 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 67 | struct isis_adjacency *adj; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 68 | int i; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 69 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 70 | adj = adj_alloc (id); /* P2P kludge */ |
| 71 | |
| 72 | if (adj == NULL) |
| 73 | { |
| 74 | zlog_err ("Out of memory!"); |
| 75 | return NULL; |
| 76 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 77 | |
| 78 | memcpy (adj->snpa, snpa, 6); |
| 79 | adj->circuit = circuit; |
| 80 | adj->level = level; |
| 81 | adj->flaps = 0; |
| 82 | adj->last_flap = time (NULL); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 83 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 84 | { |
| 85 | listnode_add (circuit->u.bc.adjdb[level - 1], adj); |
| 86 | adj->dischanges[level - 1] = 0; |
| 87 | for (i = 0; i < DIS_RECORDS; i++) /* clear N DIS state change records */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 88 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 89 | adj->dis_record[(i * ISIS_LEVELS) + level - 1].dis |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 90 | = ISIS_UNKNOWN_DIS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 91 | adj->dis_record[(i * ISIS_LEVELS) + level - 1].last_dis_change |
| 92 | = time (NULL); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 93 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 94 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 95 | |
| 96 | return adj; |
| 97 | } |
| 98 | |
| 99 | struct isis_adjacency * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 100 | isis_adj_lookup (u_char * sysid, struct list *adjdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 101 | { |
| 102 | struct isis_adjacency *adj; |
| 103 | struct listnode *node; |
| 104 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 105 | for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj)) |
| 106 | if (memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN) == 0) |
| 107 | return adj; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 108 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 109 | return NULL; |
| 110 | } |
| 111 | |
| 112 | |
| 113 | struct isis_adjacency * |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 114 | isis_adj_lookup_snpa (u_char * ssnpa, struct list *adjdb) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 115 | { |
| 116 | struct listnode *node; |
| 117 | struct isis_adjacency *adj; |
| 118 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 119 | for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj)) |
| 120 | if (memcmp (adj->snpa, ssnpa, ETH_ALEN) == 0) |
| 121 | return adj; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 122 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 123 | return NULL; |
| 124 | } |
| 125 | |
| 126 | /* |
| 127 | * When we recieve a NULL list, we will know its p2p |
| 128 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 129 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 130 | isis_delete_adj (struct isis_adjacency *adj, struct list *adjdb) |
| 131 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 132 | struct isis_adjacency *adj2 = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 133 | struct listnode *node; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 134 | |
| 135 | if (adjdb) |
| 136 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 137 | for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj2)) |
| 138 | if (adj2 == adj) |
| 139 | break; |
| 140 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 141 | listnode_delete (adjdb, adj); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 142 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 143 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 144 | if (adj->ipv4_addrs) |
| 145 | list_delete (adj->ipv4_addrs); |
| 146 | #ifdef HAVE_IPV6 |
| 147 | if (adj->ipv6_addrs) |
| 148 | list_delete (adj->ipv6_addrs); |
| 149 | #endif |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 150 | if (adj) |
| 151 | { |
| 152 | XFREE (MTYPE_ISIS_ADJACENCY, adj); |
| 153 | } |
| 154 | else |
| 155 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 156 | zlog_warn ("tried to delete a non-existent adjacency"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 157 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 158 | |
| 159 | return; |
| 160 | } |
| 161 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 162 | void |
| 163 | isis_adj_state_change (struct isis_adjacency *adj, enum isis_adj_state state, |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 164 | const char *reason) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 165 | { |
| 166 | int old_state; |
| 167 | int level = adj->level; |
| 168 | struct isis_circuit *circuit; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 169 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 170 | old_state = adj->adj_state; |
| 171 | adj->adj_state = state; |
| 172 | |
| 173 | circuit = adj->circuit; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 174 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 175 | if (isis->debugs & DEBUG_ADJ_PACKETS) |
| 176 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 177 | zlog_debug ("ISIS-Adj (%s): Adjacency state change %d->%d: %s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 178 | circuit->area->area_tag, |
| 179 | old_state, state, reason ? reason : "unspecified"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 180 | } |
| 181 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 182 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 183 | { |
| 184 | if (state == ISIS_ADJ_UP) |
| 185 | circuit->upadjcount[level - 1]++; |
| 186 | if (state == ISIS_ADJ_DOWN) |
| 187 | { |
| 188 | isis_delete_adj (adj, adj->circuit->u.bc.adjdb[level - 1]); |
| 189 | circuit->upadjcount[level - 1]--; |
| 190 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 191 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 192 | list_delete_all_node (circuit->u.bc.lan_neighs[level - 1]); |
| 193 | isis_adj_build_neigh_list (circuit->u.bc.adjdb[level - 1], |
| 194 | circuit->u.bc.lan_neighs[level - 1]); |
| 195 | } |
| 196 | else if (state == ISIS_ADJ_UP) |
| 197 | { /* p2p interface */ |
| 198 | if (adj->sys_type == ISIS_SYSTYPE_UNKNOWN) |
| 199 | send_hello (circuit, 1); |
| 200 | |
| 201 | /* update counter & timers for debugging purposes */ |
| 202 | adj->last_flap = time (NULL); |
| 203 | adj->flaps++; |
| 204 | |
| 205 | /* 7.3.17 - going up on P2P -> send CSNP */ |
| 206 | /* FIXME: yup, I know its wrong... but i will do it! (for now) */ |
| 207 | send_csnp (circuit, 1); |
| 208 | send_csnp (circuit, 2); |
| 209 | } |
| 210 | else if (state == ISIS_ADJ_DOWN) |
| 211 | { /* p2p interface */ |
| 212 | adj->circuit->u.p2p.neighbor = NULL; |
| 213 | isis_delete_adj (adj, NULL); |
| 214 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 215 | return; |
| 216 | } |
| 217 | |
| 218 | |
| 219 | void |
| 220 | isis_adj_print (struct isis_adjacency *adj) |
| 221 | { |
| 222 | struct isis_dynhn *dyn; |
| 223 | struct listnode *node; |
| 224 | struct in_addr *ipv4_addr; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 225 | #ifdef HAVE_IPV6 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 226 | struct in6_addr *ipv6_addr; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 227 | u_char ip6[INET6_ADDRSTRLEN]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 228 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 229 | |
| 230 | if (!adj) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 231 | return; |
| 232 | dyn = dynhn_find_by_id (adj->sysid); |
| 233 | if (dyn) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 234 | zlog_debug ("%s", dyn->name.name); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 235 | |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 236 | zlog_debug ("SystemId %20s SNPA %s, level %d\nHolding Time %d", |
| 237 | adj->sysid ? sysid_print (adj->sysid) : "unknown", |
| 238 | snpa_print (adj->snpa), adj->level, adj->hold_time); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 239 | if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0) |
| 240 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 241 | zlog_debug ("IPv4 Addresses:"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 242 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 243 | for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ipv4_addr)) |
| 244 | zlog_debug ("%s", inet_ntoa (*ipv4_addr)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 245 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 246 | |
| 247 | #ifdef HAVE_IPV6 |
| 248 | if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0) |
| 249 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 250 | zlog_debug ("IPv6 Addresses:"); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 251 | for (ALL_LIST_ELEMENTS_RO (adj->ipv6_addrs, node, ipv6_addr)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 252 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 253 | inet_ntop (AF_INET6, ipv6_addr, (char *)ip6, INET6_ADDRSTRLEN); |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 254 | zlog_debug ("%s", ip6); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 255 | } |
| 256 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 257 | #endif /* HAVE_IPV6 */ |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 258 | zlog_debug ("Speaks: %s", nlpid2string (&adj->nlpids)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 259 | |
| 260 | return; |
| 261 | } |
| 262 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 263 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 264 | isis_adj_expire (struct thread *thread) |
| 265 | { |
| 266 | struct isis_adjacency *adj; |
| 267 | int level; |
| 268 | |
| 269 | /* |
| 270 | * Get the adjacency |
| 271 | */ |
| 272 | adj = THREAD_ARG (thread); |
| 273 | assert (adj); |
| 274 | level = adj->level; |
hasso | 83fe45e | 2004-02-09 11:09:39 +0000 | [diff] [blame] | 275 | adj->t_expire = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 276 | |
| 277 | /* trigger the adj expire event */ |
| 278 | isis_adj_state_change (adj, ISIS_ADJ_DOWN, "holding time expired"); |
| 279 | |
| 280 | return 0; |
| 281 | } |
| 282 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 283 | static const char * |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 284 | adj_state2string (int state) |
| 285 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 286 | |
| 287 | switch (state) |
| 288 | { |
| 289 | case ISIS_ADJ_INITIALIZING: |
| 290 | return "Initializing"; |
| 291 | case ISIS_ADJ_UP: |
| 292 | return "Up"; |
| 293 | case ISIS_ADJ_DOWN: |
| 294 | return "Down"; |
| 295 | default: |
| 296 | return "Unknown"; |
| 297 | } |
| 298 | |
| 299 | return NULL; /* not reached */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | /* |
| 303 | * show clns/isis neighbor (detail) |
| 304 | */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 305 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 306 | isis_adj_print_vty2 (struct isis_adjacency *adj, struct vty *vty, char detail) |
| 307 | { |
| 308 | |
| 309 | #ifdef HAVE_IPV6 |
| 310 | struct in6_addr *ipv6_addr; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 311 | u_char ip6[INET6_ADDRSTRLEN]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 312 | #endif /* HAVE_IPV6 */ |
| 313 | struct in_addr *ip_addr; |
| 314 | time_t now; |
| 315 | struct isis_dynhn *dyn; |
| 316 | int level; |
| 317 | struct listnode *node; |
| 318 | |
| 319 | dyn = dynhn_find_by_id (adj->sysid); |
| 320 | if (dyn) |
| 321 | vty_out (vty, " %-20s", dyn->name.name); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 322 | else if (adj->sysid) |
| 323 | { |
| 324 | vty_out (vty, " %-20s", sysid_print (adj->sysid)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 325 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 326 | else |
| 327 | { |
| 328 | vty_out (vty, " unknown "); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 329 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 330 | |
| 331 | if (detail == ISIS_UI_LEVEL_BRIEF) |
| 332 | { |
| 333 | if (adj->circuit) |
| 334 | vty_out (vty, "%-12s", adj->circuit->interface->name); |
| 335 | else |
| 336 | vty_out (vty, "NULL circuit!"); |
| 337 | vty_out (vty, "%-3u", adj->level); /* level */ |
| 338 | vty_out (vty, "%-13s", adj_state2string (adj->adj_state)); |
| 339 | now = time (NULL); |
| 340 | if (adj->last_upd) |
| 341 | vty_out (vty, "%-9lu", adj->last_upd + adj->hold_time - now); |
| 342 | else |
| 343 | vty_out (vty, "- "); |
| 344 | vty_out (vty, "%-10s", snpa_print (adj->snpa)); |
| 345 | vty_out (vty, "%s", VTY_NEWLINE); |
| 346 | } |
| 347 | |
| 348 | if (detail == ISIS_UI_LEVEL_DETAIL) |
| 349 | { |
| 350 | level = adj->level; |
| 351 | if (adj->circuit) |
| 352 | vty_out (vty, "%s Interface: %s", VTY_NEWLINE, adj->circuit->interface->name); /* interface name */ |
| 353 | else |
| 354 | vty_out (vty, "NULL circuit!%s", VTY_NEWLINE); |
| 355 | vty_out (vty, ", Level: %u", adj->level); /* level */ |
| 356 | vty_out (vty, ", State: %s", adj_state2string (adj->adj_state)); |
| 357 | now = time (NULL); |
| 358 | if (adj->last_upd) |
| 359 | vty_out (vty, ", Expires in %s", |
| 360 | time2string (adj->last_upd + adj->hold_time - now)); |
| 361 | else |
| 362 | vty_out (vty, ", Expires in %s", time2string (adj->hold_time)); |
| 363 | vty_out (vty, "%s Adjacency flaps: %u", VTY_NEWLINE, adj->flaps); |
| 364 | vty_out (vty, ", Last: %s ago", time2string (now - adj->last_flap)); |
| 365 | vty_out (vty, "%s Circuit type: %s", |
| 366 | VTY_NEWLINE, circuit_t2string (adj->circuit_t)); |
| 367 | vty_out (vty, ", Speaks: %s", nlpid2string (&adj->nlpids)); |
| 368 | vty_out (vty, "%s SNPA: %s", VTY_NEWLINE, snpa_print (adj->snpa)); |
| 369 | dyn = dynhn_find_by_id (adj->lanid); |
| 370 | if (dyn) |
| 371 | vty_out (vty, ", LAN id: %s.%02x", |
| 372 | dyn->name.name, adj->lanid[ISIS_SYS_ID_LEN]); |
| 373 | else |
| 374 | vty_out (vty, ", LAN id: %s.%02x", |
| 375 | sysid_print (adj->lanid), adj->lanid[ISIS_SYS_ID_LEN]); |
| 376 | |
| 377 | vty_out (vty, "%s Priority: %u", |
| 378 | VTY_NEWLINE, adj->prio[adj->level - 1]); |
| 379 | |
| 380 | vty_out (vty, ", %s, DIS flaps: %u, Last: %s ago%s", |
| 381 | isis_disflag2string (adj->dis_record[ISIS_LEVELS + level - 1]. |
| 382 | dis), adj->dischanges[level - 1], |
| 383 | time2string (now - |
| 384 | (adj->dis_record[ISIS_LEVELS + level - 1]. |
| 385 | last_dis_change)), VTY_NEWLINE); |
| 386 | |
| 387 | if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0) |
| 388 | { |
| 389 | vty_out (vty, " IPv4 Addresses:%s", VTY_NEWLINE); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 390 | for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ip_addr)) |
| 391 | vty_out (vty, " %s%s", inet_ntoa (*ip_addr), VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 392 | } |
| 393 | #ifdef HAVE_IPV6 |
| 394 | if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0) |
| 395 | { |
| 396 | vty_out (vty, " IPv6 Addresses:%s", VTY_NEWLINE); |
hasso | 5d6e269 | 2005-04-12 14:48:19 +0000 | [diff] [blame] | 397 | for (ALL_LIST_ELEMENTS_RO (adj->ipv6_addrs, node, ipv6_addr)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 398 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 399 | inet_ntop (AF_INET6, ipv6_addr, (char *)ip6, INET6_ADDRSTRLEN); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 400 | vty_out (vty, " %s%s", ip6, VTY_NEWLINE); |
| 401 | } |
| 402 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 403 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 404 | vty_out (vty, "%s", VTY_NEWLINE); |
| 405 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 406 | return; |
| 407 | } |
| 408 | |
| 409 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 410 | isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty) |
| 411 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 412 | isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_BRIEF); |
| 413 | } |
| 414 | |
| 415 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 416 | isis_adj_print_vty_detail (struct isis_adjacency *adj, struct vty *vty) |
| 417 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 418 | isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_DETAIL); |
| 419 | } |
| 420 | |
| 421 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 422 | isis_adj_print_vty_extensive (struct isis_adjacency *adj, struct vty *vty) |
| 423 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 424 | isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_EXTENSIVE); |
| 425 | } |
| 426 | |
| 427 | void |
| 428 | isis_adj_p2p_print_vty (struct isis_adjacency *adj, struct vty *vty) |
| 429 | { |
| 430 | isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_BRIEF); |
| 431 | } |
| 432 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 433 | void |
| 434 | isis_adj_p2p_print_vty_detail (struct isis_adjacency *adj, struct vty *vty) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 435 | { |
| 436 | isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_DETAIL); |
| 437 | } |
| 438 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 439 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 440 | isis_adj_p2p_print_vty_extensive (struct isis_adjacency *adj, struct vty *vty) |
| 441 | { |
| 442 | isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_EXTENSIVE); |
| 443 | } |
| 444 | |
| 445 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 446 | isis_adjdb_iterate (struct list *adjdb, void (*func) (struct isis_adjacency *, |
| 447 | void *), void *arg) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 448 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 449 | struct listnode *node, *nnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 450 | struct isis_adjacency *adj; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 451 | |
| 452 | for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj)) |
| 453 | (*func) (adj, arg); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | void |
| 457 | isis_adj_build_neigh_list (struct list *adjdb, struct list *list) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 458 | { |
| 459 | struct isis_adjacency *adj; |
| 460 | struct listnode *node; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 461 | |
| 462 | if (!list) |
| 463 | { |
| 464 | zlog_warn ("isis_adj_build_neigh_list(): NULL list"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 465 | return; |
| 466 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 467 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 468 | for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 469 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 470 | if (!adj) |
| 471 | { |
| 472 | zlog_warn ("isis_adj_build_neigh_list(): NULL adj"); |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | if ((adj->adj_state == ISIS_ADJ_UP || |
| 477 | adj->adj_state == ISIS_ADJ_INITIALIZING)) |
| 478 | listnode_add (list, adj->snpa); |
| 479 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 480 | return; |
| 481 | } |
| 482 | |
| 483 | void |
| 484 | isis_adj_build_up_list (struct list *adjdb, struct list *list) |
| 485 | { |
| 486 | struct isis_adjacency *adj; |
| 487 | struct listnode *node; |
| 488 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 489 | if (!list) |
| 490 | { |
| 491 | zlog_warn ("isis_adj_build_up_list(): NULL list"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 492 | return; |
| 493 | } |
| 494 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 495 | for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 496 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 497 | if (!adj) |
| 498 | { |
| 499 | zlog_warn ("isis_adj_build_up_list(): NULL adj"); |
| 500 | return; |
| 501 | } |
| 502 | |
| 503 | if (adj->adj_state == ISIS_ADJ_UP) |
| 504 | listnode_add (list, adj); |
| 505 | } |
| 506 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 507 | return; |
| 508 | } |