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