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