blob: a3524362e7925f11c15c52677eec8e25f93a1bde [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
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
jardineb5d44e2003-12-23 08:09:43 +000024#include <zebra.h>
jardineb5d44e2003-12-23 08:09:43 +000025
26#include "log.h"
27#include "memory.h"
28#include "hash.h"
29#include "vty.h"
30#include "linklist.h"
31#include "thread.h"
32#include "if.h"
33#include "stream.h"
34
35#include "isisd/dict.h"
36#include "isisd/include-netbsd/iso.h"
37#include "isisd/isis_constants.h"
38#include "isisd/isis_common.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070039#include "isisd/isis_flags.h"
jardineb5d44e2003-12-23 08:09:43 +000040#include "isisd/isisd.h"
41#include "isisd/isis_circuit.h"
42#include "isisd/isis_adjacency.h"
43#include "isisd/isis_misc.h"
44#include "isisd/isis_dr.h"
45#include "isisd/isis_dynhn.h"
46#include "isisd/isis_pdu.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070047#include "isisd/isis_tlv.h"
48#include "isisd/isis_lsp.h"
49#include "isisd/isis_spf.h"
50#include "isisd/isis_events.h"
jardineb5d44e2003-12-23 08:09:43 +000051
jardineb5d44e2003-12-23 08:09:43 +000052extern struct isis *isis;
53
hasso92365882005-01-18 13:53:33 +000054static struct isis_adjacency *
hassof390d2c2004-09-10 20:48:21 +000055adj_alloc (u_char * id)
jardineb5d44e2003-12-23 08:09:43 +000056{
hassof390d2c2004-09-10 20:48:21 +000057 struct isis_adjacency *adj;
jardineb5d44e2003-12-23 08:09:43 +000058
hassoaac372f2005-09-01 17:52:33 +000059 adj = XCALLOC (MTYPE_ISIS_ADJACENCY, sizeof (struct isis_adjacency));
hassof390d2c2004-09-10 20:48:21 +000060 memcpy (adj->sysid, id, ISIS_SYS_ID_LEN);
61
62 return adj;
jardineb5d44e2003-12-23 08:09:43 +000063}
64
65struct isis_adjacency *
hassof390d2c2004-09-10 20:48:21 +000066isis_new_adj (u_char * id, u_char * snpa, int level,
jardineb5d44e2003-12-23 08:09:43 +000067 struct isis_circuit *circuit)
68{
jardineb5d44e2003-12-23 08:09:43 +000069 struct isis_adjacency *adj;
hassof390d2c2004-09-10 20:48:21 +000070 int i;
jardineb5d44e2003-12-23 08:09:43 +000071
hassof390d2c2004-09-10 20:48:21 +000072 adj = adj_alloc (id); /* P2P kludge */
73
74 if (adj == NULL)
75 {
76 zlog_err ("Out of memory!");
77 return NULL;
78 }
jardineb5d44e2003-12-23 08:09:43 +000079
Paul Jakma41b36e92006-12-08 01:09:50 +000080 if (snpa) {
Josh Bailey3f045a02012-03-24 08:35:20 -070081 memcpy (adj->snpa, snpa, ETH_ALEN);
Paul Jakma41b36e92006-12-08 01:09:50 +000082 } else {
Josh Bailey3f045a02012-03-24 08:35:20 -070083 memset (adj->snpa, ' ', ETH_ALEN);
Paul Jakma41b36e92006-12-08 01:09:50 +000084 }
85
jardineb5d44e2003-12-23 08:09:43 +000086 adj->circuit = circuit;
87 adj->level = level;
88 adj->flaps = 0;
89 adj->last_flap = time (NULL);
hassof390d2c2004-09-10 20:48:21 +000090 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
91 {
92 listnode_add (circuit->u.bc.adjdb[level - 1], adj);
93 adj->dischanges[level - 1] = 0;
94 for (i = 0; i < DIS_RECORDS; i++) /* clear N DIS state change records */
jardineb5d44e2003-12-23 08:09:43 +000095 {
hassof390d2c2004-09-10 20:48:21 +000096 adj->dis_record[(i * ISIS_LEVELS) + level - 1].dis
jardineb5d44e2003-12-23 08:09:43 +000097 = ISIS_UNKNOWN_DIS;
hassof390d2c2004-09-10 20:48:21 +000098 adj->dis_record[(i * ISIS_LEVELS) + level - 1].last_dis_change
99 = time (NULL);
jardineb5d44e2003-12-23 08:09:43 +0000100 }
hassof390d2c2004-09-10 20:48:21 +0000101 }
jardineb5d44e2003-12-23 08:09:43 +0000102
103 return adj;
104}
105
106struct isis_adjacency *
hassof390d2c2004-09-10 20:48:21 +0000107isis_adj_lookup (u_char * sysid, struct list *adjdb)
jardineb5d44e2003-12-23 08:09:43 +0000108{
109 struct isis_adjacency *adj;
110 struct listnode *node;
111
paul1eb8ef22005-04-07 07:30:20 +0000112 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
113 if (memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN) == 0)
114 return adj;
hassof390d2c2004-09-10 20:48:21 +0000115
jardineb5d44e2003-12-23 08:09:43 +0000116 return NULL;
117}
118
jardineb5d44e2003-12-23 08:09:43 +0000119struct isis_adjacency *
hassof390d2c2004-09-10 20:48:21 +0000120isis_adj_lookup_snpa (u_char * ssnpa, struct list *adjdb)
jardineb5d44e2003-12-23 08:09:43 +0000121{
122 struct listnode *node;
123 struct isis_adjacency *adj;
124
paul1eb8ef22005-04-07 07:30:20 +0000125 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
126 if (memcmp (adj->snpa, ssnpa, ETH_ALEN) == 0)
127 return adj;
hassof390d2c2004-09-10 20:48:21 +0000128
jardineb5d44e2003-12-23 08:09:43 +0000129 return NULL;
130}
131
hassof390d2c2004-09-10 20:48:21 +0000132void
Josh Bailey3f045a02012-03-24 08:35:20 -0700133isis_delete_adj (void *arg)
jardineb5d44e2003-12-23 08:09:43 +0000134{
Josh Bailey3f045a02012-03-24 08:35:20 -0700135 struct isis_adjacency *adj = arg;
136
hasso3fdb2dd2005-09-28 18:45:54 +0000137 if (!adj)
138 return;
hassof390d2c2004-09-10 20:48:21 +0000139
Josh Bailey3f045a02012-03-24 08:35:20 -0700140 THREAD_TIMER_OFF (adj->t_expire);
hasso13fb40a2005-10-01 06:03:04 +0000141
Josh Bailey3f045a02012-03-24 08:35:20 -0700142 /* remove from SPF trees */
143 spftree_area_adj_del (adj->circuit->area, adj);
144
145 if (adj->area_addrs)
146 list_delete (adj->area_addrs);
jardineb5d44e2003-12-23 08:09:43 +0000147 if (adj->ipv4_addrs)
148 list_delete (adj->ipv4_addrs);
149#ifdef HAVE_IPV6
150 if (adj->ipv6_addrs)
151 list_delete (adj->ipv6_addrs);
152#endif
Josh Bailey3f045a02012-03-24 08:35:20 -0700153
hasso3fdb2dd2005-09-28 18:45:54 +0000154 XFREE (MTYPE_ISIS_ADJACENCY, adj);
jardineb5d44e2003-12-23 08:09:43 +0000155 return;
156}
157
Josh Bailey3f045a02012-03-24 08:35:20 -0700158static const char *
159adj_state2string (int state)
160{
161
162 switch (state)
163 {
164 case ISIS_ADJ_INITIALIZING:
165 return "Initializing";
166 case ISIS_ADJ_UP:
167 return "Up";
168 case ISIS_ADJ_DOWN:
169 return "Down";
170 default:
171 return "Unknown";
172 }
173
174 return NULL; /* not reached */
175}
176
hassof390d2c2004-09-10 20:48:21 +0000177void
Josh Bailey3f045a02012-03-24 08:35:20 -0700178isis_adj_state_change (struct isis_adjacency *adj, enum isis_adj_state new_state,
hasso1cd80842004-10-07 20:07:40 +0000179 const char *reason)
jardineb5d44e2003-12-23 08:09:43 +0000180{
181 int old_state;
Josh Bailey3f045a02012-03-24 08:35:20 -0700182 int level;
jardineb5d44e2003-12-23 08:09:43 +0000183 struct isis_circuit *circuit;
hassof390d2c2004-09-10 20:48:21 +0000184
jardineb5d44e2003-12-23 08:09:43 +0000185 old_state = adj->adj_state;
Josh Bailey3f045a02012-03-24 08:35:20 -0700186 adj->adj_state = new_state;
jardineb5d44e2003-12-23 08:09:43 +0000187
188 circuit = adj->circuit;
jardineb5d44e2003-12-23 08:09:43 +0000189
hassof390d2c2004-09-10 20:48:21 +0000190 if (isis->debugs & DEBUG_ADJ_PACKETS)
191 {
hasso529d65b2004-12-24 00:14:50 +0000192 zlog_debug ("ISIS-Adj (%s): Adjacency state change %d->%d: %s",
hassof390d2c2004-09-10 20:48:21 +0000193 circuit->area->area_tag,
Josh Bailey3f045a02012-03-24 08:35:20 -0700194 old_state, new_state, reason ? reason : "unspecified");
195 }
196
197 if (circuit->area->log_adj_changes)
198 {
199 const char *adj_name;
200 struct isis_dynhn *dyn;
201
202 dyn = dynhn_find_by_id (adj->sysid);
203 if (dyn)
204 adj_name = (const char *)dyn->name.name;
205 else
206 adj_name = adj->sysid ? sysid_print (adj->sysid) : "unknown";
207
208 zlog_info ("%%ADJCHANGE: Adjacency to %s (%s) changed from %s to %s, %s",
209 adj_name,
David Lampartere8aca322012-11-27 01:10:30 +0000210 adj->circuit->interface->name,
Josh Bailey3f045a02012-03-24 08:35:20 -0700211 adj_state2string (old_state),
212 adj_state2string (new_state),
213 reason ? reason : "unspecified");
jardineb5d44e2003-12-23 08:09:43 +0000214 }
215
hassof390d2c2004-09-10 20:48:21 +0000216 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
217 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700218 for (level = IS_LEVEL_1; level <= IS_LEVEL_2; level++)
219 {
220 if ((adj->level & level) == 0)
221 continue;
222 if (new_state == ISIS_ADJ_UP)
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700223 {
224 circuit->upadjcount[level - 1]++;
225 isis_event_adjacency_state_change (adj, new_state);
226 /* update counter & timers for debugging purposes */
227 adj->last_flap = time (NULL);
228 adj->flaps++;
229 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700230 else if (new_state == ISIS_ADJ_DOWN)
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700231 {
232 listnode_delete (circuit->u.bc.adjdb[level - 1], adj);
233 circuit->upadjcount[level - 1]--;
234 if (circuit->upadjcount[level - 1] == 0)
235 {
236 /* Clean lsp_queue when no adj is up. */
237 if (circuit->lsp_queue)
238 list_delete_all_node (circuit->lsp_queue);
239 }
240 isis_event_adjacency_state_change (adj, new_state);
241 isis_delete_adj (adj);
242 }
243
244 if (circuit->u.bc.lan_neighs[level - 1])
245 {
246 list_delete_all_node (circuit->u.bc.lan_neighs[level - 1]);
247 isis_adj_build_neigh_list (circuit->u.bc.adjdb[level - 1],
248 circuit->u.bc.lan_neighs[level - 1]);
249 }
jardineb5d44e2003-12-23 08:09:43 +0000250
Josh Bailey3f045a02012-03-24 08:35:20 -0700251 /* On adjacency state change send new pseudo LSP if we are the DR */
252 if (circuit->u.bc.is_dr[level - 1])
253 lsp_regenerate_schedule_pseudo (circuit, level);
254 }
hassof390d2c2004-09-10 20:48:21 +0000255 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700256 else if (circuit->circ_type == CIRCUIT_T_P2P)
257 {
258 for (level = IS_LEVEL_1; level <= IS_LEVEL_2; level++)
259 {
260 if ((adj->level & level) == 0)
261 continue;
262 if (new_state == ISIS_ADJ_UP)
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700263 {
264 circuit->upadjcount[level - 1]++;
265 isis_event_adjacency_state_change (adj, new_state);
hassof390d2c2004-09-10 20:48:21 +0000266
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700267 if (adj->sys_type == ISIS_SYSTYPE_UNKNOWN)
268 send_hello (circuit, level);
hassof390d2c2004-09-10 20:48:21 +0000269
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700270 /* update counter & timers for debugging purposes */
271 adj->last_flap = time (NULL);
272 adj->flaps++;
Josh Bailey3f045a02012-03-24 08:35:20 -0700273
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700274 /* 7.3.17 - going up on P2P -> send CSNP */
275 /* FIXME: yup, I know its wrong... but i will do it! (for now) */
276 send_csnp (circuit, level);
277 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700278 else if (new_state == ISIS_ADJ_DOWN)
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700279 {
280 if (adj->circuit->u.p2p.neighbor == adj)
281 adj->circuit->u.p2p.neighbor = NULL;
282 circuit->upadjcount[level - 1]--;
283 if (circuit->upadjcount[level - 1] == 0)
284 {
285 /* Clean lsp_queue when no adj is up. */
286 if (circuit->lsp_queue)
287 list_delete_all_node (circuit->lsp_queue);
288 }
289 isis_event_adjacency_state_change (adj, new_state);
290 isis_delete_adj (adj);
291 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700292 }
hassof390d2c2004-09-10 20:48:21 +0000293 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700294
jardineb5d44e2003-12-23 08:09:43 +0000295 return;
296}
297
298
299void
300isis_adj_print (struct isis_adjacency *adj)
301{
302 struct isis_dynhn *dyn;
303 struct listnode *node;
304 struct in_addr *ipv4_addr;
hassof390d2c2004-09-10 20:48:21 +0000305#ifdef HAVE_IPV6
jardineb5d44e2003-12-23 08:09:43 +0000306 struct in6_addr *ipv6_addr;
hassof390d2c2004-09-10 20:48:21 +0000307 u_char ip6[INET6_ADDRSTRLEN];
jardineb5d44e2003-12-23 08:09:43 +0000308#endif /* HAVE_IPV6 */
hassof390d2c2004-09-10 20:48:21 +0000309
310 if (!adj)
jardineb5d44e2003-12-23 08:09:43 +0000311 return;
312 dyn = dynhn_find_by_id (adj->sysid);
313 if (dyn)
hasso529d65b2004-12-24 00:14:50 +0000314 zlog_debug ("%s", dyn->name.name);
jardineb5d44e2003-12-23 08:09:43 +0000315
hasso529d65b2004-12-24 00:14:50 +0000316 zlog_debug ("SystemId %20s SNPA %s, level %d\nHolding Time %d",
317 adj->sysid ? sysid_print (adj->sysid) : "unknown",
318 snpa_print (adj->snpa), adj->level, adj->hold_time);
hassof390d2c2004-09-10 20:48:21 +0000319 if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0)
320 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700321 zlog_debug ("IPv4 Address(es):");
hassof390d2c2004-09-10 20:48:21 +0000322
paul1eb8ef22005-04-07 07:30:20 +0000323 for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ipv4_addr))
324 zlog_debug ("%s", inet_ntoa (*ipv4_addr));
jardineb5d44e2003-12-23 08:09:43 +0000325 }
hassof390d2c2004-09-10 20:48:21 +0000326
327#ifdef HAVE_IPV6
328 if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0)
329 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700330 zlog_debug ("IPv6 Address(es):");
paul1eb8ef22005-04-07 07:30:20 +0000331 for (ALL_LIST_ELEMENTS_RO (adj->ipv6_addrs, node, ipv6_addr))
hassof390d2c2004-09-10 20:48:21 +0000332 {
hassof7c43dc2004-09-26 16:24:14 +0000333 inet_ntop (AF_INET6, ipv6_addr, (char *)ip6, INET6_ADDRSTRLEN);
hasso529d65b2004-12-24 00:14:50 +0000334 zlog_debug ("%s", ip6);
hassof390d2c2004-09-10 20:48:21 +0000335 }
336 }
jardineb5d44e2003-12-23 08:09:43 +0000337#endif /* HAVE_IPV6 */
hasso529d65b2004-12-24 00:14:50 +0000338 zlog_debug ("Speaks: %s", nlpid2string (&adj->nlpids));
jardineb5d44e2003-12-23 08:09:43 +0000339
340 return;
341}
342
hassof390d2c2004-09-10 20:48:21 +0000343int
jardineb5d44e2003-12-23 08:09:43 +0000344isis_adj_expire (struct thread *thread)
345{
346 struct isis_adjacency *adj;
jardineb5d44e2003-12-23 08:09:43 +0000347
348 /*
349 * Get the adjacency
350 */
351 adj = THREAD_ARG (thread);
352 assert (adj);
hasso83fe45e2004-02-09 11:09:39 +0000353 adj->t_expire = NULL;
jardineb5d44e2003-12-23 08:09:43 +0000354
355 /* trigger the adj expire event */
356 isis_adj_state_change (adj, ISIS_ADJ_DOWN, "holding time expired");
357
358 return 0;
359}
360
jardineb5d44e2003-12-23 08:09:43 +0000361/*
Josh Bailey3f045a02012-03-24 08:35:20 -0700362 * show isis neighbor [detail]
jardineb5d44e2003-12-23 08:09:43 +0000363 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700364void
365isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty, char detail)
jardineb5d44e2003-12-23 08:09:43 +0000366{
jardineb5d44e2003-12-23 08:09:43 +0000367#ifdef HAVE_IPV6
368 struct in6_addr *ipv6_addr;
hassof390d2c2004-09-10 20:48:21 +0000369 u_char ip6[INET6_ADDRSTRLEN];
jardineb5d44e2003-12-23 08:09:43 +0000370#endif /* HAVE_IPV6 */
371 struct in_addr *ip_addr;
372 time_t now;
373 struct isis_dynhn *dyn;
374 int level;
375 struct listnode *node;
376
377 dyn = dynhn_find_by_id (adj->sysid);
378 if (dyn)
379 vty_out (vty, " %-20s", dyn->name.name);
hassof390d2c2004-09-10 20:48:21 +0000380 else if (adj->sysid)
381 {
382 vty_out (vty, " %-20s", sysid_print (adj->sysid));
jardineb5d44e2003-12-23 08:09:43 +0000383 }
hassof390d2c2004-09-10 20:48:21 +0000384 else
385 {
386 vty_out (vty, " unknown ");
jardineb5d44e2003-12-23 08:09:43 +0000387 }
hassof390d2c2004-09-10 20:48:21 +0000388
389 if (detail == ISIS_UI_LEVEL_BRIEF)
390 {
391 if (adj->circuit)
392 vty_out (vty, "%-12s", adj->circuit->interface->name);
393 else
394 vty_out (vty, "NULL circuit!");
395 vty_out (vty, "%-3u", adj->level); /* level */
396 vty_out (vty, "%-13s", adj_state2string (adj->adj_state));
397 now = time (NULL);
398 if (adj->last_upd)
David Lamparteref008d22015-03-03 08:48:11 +0100399 vty_out (vty, "%-9llu",
400 (unsigned long long)adj->last_upd + adj->hold_time - now);
hassof390d2c2004-09-10 20:48:21 +0000401 else
402 vty_out (vty, "- ");
403 vty_out (vty, "%-10s", snpa_print (adj->snpa));
404 vty_out (vty, "%s", VTY_NEWLINE);
405 }
406
407 if (detail == ISIS_UI_LEVEL_DETAIL)
408 {
409 level = adj->level;
Josh Bailey3f045a02012-03-24 08:35:20 -0700410 vty_out (vty, "%s", VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +0000411 if (adj->circuit)
Josh Bailey3f045a02012-03-24 08:35:20 -0700412 vty_out (vty, " Interface: %s", adj->circuit->interface->name);
hassof390d2c2004-09-10 20:48:21 +0000413 else
Josh Bailey3f045a02012-03-24 08:35:20 -0700414 vty_out (vty, " Interface: NULL circuit");
hassof390d2c2004-09-10 20:48:21 +0000415 vty_out (vty, ", Level: %u", adj->level); /* level */
416 vty_out (vty, ", State: %s", adj_state2string (adj->adj_state));
417 now = time (NULL);
418 if (adj->last_upd)
419 vty_out (vty, ", Expires in %s",
420 time2string (adj->last_upd + adj->hold_time - now));
421 else
422 vty_out (vty, ", Expires in %s", time2string (adj->hold_time));
Josh Bailey3f045a02012-03-24 08:35:20 -0700423 vty_out (vty, "%s", VTY_NEWLINE);
424 vty_out (vty, " Adjacency flaps: %u", adj->flaps);
hassof390d2c2004-09-10 20:48:21 +0000425 vty_out (vty, ", Last: %s ago", time2string (now - adj->last_flap));
Josh Bailey3f045a02012-03-24 08:35:20 -0700426 vty_out (vty, "%s", VTY_NEWLINE);
427 vty_out (vty, " Circuit type: %s", circuit_t2string (adj->circuit_t));
hassof390d2c2004-09-10 20:48:21 +0000428 vty_out (vty, ", Speaks: %s", nlpid2string (&adj->nlpids));
Josh Bailey3f045a02012-03-24 08:35:20 -0700429 vty_out (vty, "%s", VTY_NEWLINE);
430 vty_out (vty, " SNPA: %s", snpa_print (adj->snpa));
David Lampartere8aca322012-11-27 01:10:30 +0000431 if (adj->circuit && (adj->circuit->circ_type == CIRCUIT_T_BROADCAST))
Josh Bailey3f045a02012-03-24 08:35:20 -0700432 {
433 dyn = dynhn_find_by_id (adj->lanid);
434 if (dyn)
435 vty_out (vty, ", LAN id: %s.%02x",
436 dyn->name.name, adj->lanid[ISIS_SYS_ID_LEN]);
437 else
438 vty_out (vty, ", LAN id: %s.%02x",
439 sysid_print (adj->lanid), adj->lanid[ISIS_SYS_ID_LEN]);
hassof390d2c2004-09-10 20:48:21 +0000440
Josh Bailey3f045a02012-03-24 08:35:20 -0700441 vty_out (vty, "%s", VTY_NEWLINE);
442 vty_out (vty, " LAN Priority: %u", adj->prio[adj->level - 1]);
hassof390d2c2004-09-10 20:48:21 +0000443
Josh Bailey3f045a02012-03-24 08:35:20 -0700444 vty_out (vty, ", %s, DIS flaps: %u, Last: %s ago",
445 isis_disflag2string (adj->dis_record[ISIS_LEVELS + level - 1].
446 dis), adj->dischanges[level - 1],
447 time2string (now -
448 (adj->dis_record[ISIS_LEVELS + level - 1].
449 last_dis_change)));
450 }
451 vty_out (vty, "%s", VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +0000452
Josh Bailey3f045a02012-03-24 08:35:20 -0700453 if (adj->area_addrs && listcount (adj->area_addrs) > 0)
454 {
455 struct area_addr *area_addr;
456 vty_out (vty, " Area Address(es):%s", VTY_NEWLINE);
457 for (ALL_LIST_ELEMENTS_RO (adj->area_addrs, node, area_addr))
458 vty_out (vty, " %s%s", isonet_print (area_addr->area_addr,
459 area_addr->addr_len), VTY_NEWLINE);
460 }
hassof390d2c2004-09-10 20:48:21 +0000461 if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0)
462 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700463 vty_out (vty, " IPv4 Address(es):%s", VTY_NEWLINE);
paul1eb8ef22005-04-07 07:30:20 +0000464 for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ip_addr))
465 vty_out (vty, " %s%s", inet_ntoa (*ip_addr), VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +0000466 }
467#ifdef HAVE_IPV6
468 if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0)
469 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700470 vty_out (vty, " IPv6 Address(es):%s", VTY_NEWLINE);
hasso5d6e2692005-04-12 14:48:19 +0000471 for (ALL_LIST_ELEMENTS_RO (adj->ipv6_addrs, node, ipv6_addr))
hassof390d2c2004-09-10 20:48:21 +0000472 {
hassof7c43dc2004-09-26 16:24:14 +0000473 inet_ntop (AF_INET6, ipv6_addr, (char *)ip6, INET6_ADDRSTRLEN);
hassof390d2c2004-09-10 20:48:21 +0000474 vty_out (vty, " %s%s", ip6, VTY_NEWLINE);
475 }
476 }
jardineb5d44e2003-12-23 08:09:43 +0000477#endif /* HAVE_IPV6 */
hassof390d2c2004-09-10 20:48:21 +0000478 vty_out (vty, "%s", VTY_NEWLINE);
479 }
jardineb5d44e2003-12-23 08:09:43 +0000480 return;
481}
482
483void
jardineb5d44e2003-12-23 08:09:43 +0000484isis_adj_build_neigh_list (struct list *adjdb, struct list *list)
jardineb5d44e2003-12-23 08:09:43 +0000485{
486 struct isis_adjacency *adj;
487 struct listnode *node;
hassof390d2c2004-09-10 20:48:21 +0000488
489 if (!list)
490 {
491 zlog_warn ("isis_adj_build_neigh_list(): NULL list");
jardineb5d44e2003-12-23 08:09:43 +0000492 return;
493 }
hassof390d2c2004-09-10 20:48:21 +0000494
paul1eb8ef22005-04-07 07:30:20 +0000495 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
hassof390d2c2004-09-10 20:48:21 +0000496 {
hassof390d2c2004-09-10 20:48:21 +0000497 if (!adj)
498 {
499 zlog_warn ("isis_adj_build_neigh_list(): NULL adj");
500 return;
501 }
502
503 if ((adj->adj_state == ISIS_ADJ_UP ||
504 adj->adj_state == ISIS_ADJ_INITIALIZING))
505 listnode_add (list, adj->snpa);
506 }
jardineb5d44e2003-12-23 08:09:43 +0000507 return;
508}
509
510void
511isis_adj_build_up_list (struct list *adjdb, struct list *list)
512{
513 struct isis_adjacency *adj;
514 struct listnode *node;
515
hassof390d2c2004-09-10 20:48:21 +0000516 if (!list)
517 {
518 zlog_warn ("isis_adj_build_up_list(): NULL list");
jardineb5d44e2003-12-23 08:09:43 +0000519 return;
520 }
521
paul1eb8ef22005-04-07 07:30:20 +0000522 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
hassof390d2c2004-09-10 20:48:21 +0000523 {
hassof390d2c2004-09-10 20:48:21 +0000524 if (!adj)
525 {
526 zlog_warn ("isis_adj_build_up_list(): NULL adj");
527 return;
528 }
529
530 if (adj->adj_state == ISIS_ADJ_UP)
531 listnode_add (list, adj);
532 }
533
jardineb5d44e2003-12-23 08:09:43 +0000534 return;
535}