blob: f20c83b9f2836bc89466ec51f938257d71dc5c6f [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
paul718e3742002-12-13 20:15:29 +000022#include <zebra.h>
23
24#include "log.h"
hasso508e53e2004-05-18 18:57:06 +000025#include "memory.h"
paul718e3742002-12-13 20:15:29 +000026#include "thread.h"
27#include "linklist.h"
28#include "vty.h"
29#include "command.h"
30
hasso508e53e2004-05-18 18:57:06 +000031#include "ospf6_proto.h"
paul718e3742002-12-13 20:15:29 +000032#include "ospf6_lsa.h"
33#include "ospf6_lsdb.h"
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_message.h"
35#include "ospf6_top.h"
36#include "ospf6_area.h"
37#include "ospf6_interface.h"
38#include "ospf6_neighbor.h"
39#include "ospf6_intra.h"
hasso3b4cd3a2004-05-18 19:28:32 +000040#include "ospf6_flood.h"
hasso049207c2004-08-04 20:02:13 +000041#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000042
hasso508e53e2004-05-18 18:57:06 +000043unsigned char conf_debug_ospf6_neighbor = 0;
44
paul0c083ee2004-10-10 12:54:58 +000045const char *ospf6_neighbor_state_str[] =
hasso508e53e2004-05-18 18:57:06 +000046{ "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange",
47 "Loading", "Full", NULL };
paul718e3742002-12-13 20:15:29 +000048
Paul Jakma7aa9dce2014-09-19 14:42:23 +010049static const char *ospf6_neighbor_event_str[] =
50 {
51 "NoEvent",
52 "HelloReceived",
53 "2-WayReceived",
54 "NegotiationDone",
55 "ExchangeDone",
56 "LoadingDone",
57 "AdjOK?",
58 "SeqNumberMismatch",
59 "BadLSReq",
60 "1-WayReceived",
61 "InactivityTimer",
62 };
63
64static const char *
65ospf6_neighbor_event_string (int event)
66{
67 #define OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING "UnknownEvent"
68
69 if (event < OSPF6_NEIGHBOR_EVENT_MAX_EVENT)
70 return ospf6_neighbor_event_str[event];
71 return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING;
72}
73
paul718e3742002-12-13 20:15:29 +000074int
hasso508e53e2004-05-18 18:57:06 +000075ospf6_neighbor_cmp (void *va, void *vb)
paul718e3742002-12-13 20:15:29 +000076{
hasso508e53e2004-05-18 18:57:06 +000077 struct ospf6_neighbor *ona = (struct ospf6_neighbor *) va;
78 struct ospf6_neighbor *onb = (struct ospf6_neighbor *) vb;
hasso6452df02004-08-15 05:52:07 +000079 return (ntohl (ona->router_id) < ntohl (onb->router_id) ? -1 : 1);
paul718e3742002-12-13 20:15:29 +000080}
81
hasso508e53e2004-05-18 18:57:06 +000082struct ospf6_neighbor *
83ospf6_neighbor_lookup (u_int32_t router_id,
84 struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +000085{
hasso52dc7ee2004-09-23 19:18:23 +000086 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +000087 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +000088
paul1eb8ef22005-04-07 07:30:20 +000089 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, n, on))
90 if (on->router_id == router_id)
91 return on;
92
hasso508e53e2004-05-18 18:57:06 +000093 return (struct ospf6_neighbor *) NULL;
paul718e3742002-12-13 20:15:29 +000094}
95
96/* create ospf6_neighbor */
97struct ospf6_neighbor *
hasso508e53e2004-05-18 18:57:06 +000098ospf6_neighbor_create (u_int32_t router_id, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +000099{
hasso508e53e2004-05-18 18:57:06 +0000100 struct ospf6_neighbor *on;
101 char buf[16];
paul718e3742002-12-13 20:15:29 +0000102
hasso508e53e2004-05-18 18:57:06 +0000103 on = (struct ospf6_neighbor *)
paul718e3742002-12-13 20:15:29 +0000104 XMALLOC (MTYPE_OSPF6_NEIGHBOR, sizeof (struct ospf6_neighbor));
hasso508e53e2004-05-18 18:57:06 +0000105 if (on == NULL)
paul718e3742002-12-13 20:15:29 +0000106 {
107 zlog_warn ("neighbor: malloc failed");
108 return NULL;
109 }
110
hasso508e53e2004-05-18 18:57:06 +0000111 memset (on, 0, sizeof (struct ospf6_neighbor));
paul718e3742002-12-13 20:15:29 +0000112 inet_ntop (AF_INET, &router_id, buf, sizeof (buf));
hasso508e53e2004-05-18 18:57:06 +0000113 snprintf (on->name, sizeof (on->name), "%s%%%s",
114 buf, oi->interface->name);
115 on->ospf6_if = oi;
116 on->state = OSPF6_NEIGHBOR_DOWN;
Vincent Bernat061bc732012-05-31 20:21:15 +0200117 on->state_change = 0;
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900118 quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed);
hasso508e53e2004-05-18 18:57:06 +0000119 on->router_id = router_id;
paul718e3742002-12-13 20:15:29 +0000120
hasso6452df02004-08-15 05:52:07 +0000121 on->summary_list = ospf6_lsdb_create (on);
122 on->request_list = ospf6_lsdb_create (on);
123 on->retrans_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +0000124
hasso6452df02004-08-15 05:52:07 +0000125 on->dbdesc_list = ospf6_lsdb_create (on);
hasso6452df02004-08-15 05:52:07 +0000126 on->lsupdate_list = ospf6_lsdb_create (on);
127 on->lsack_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +0000128
hasso508e53e2004-05-18 18:57:06 +0000129 listnode_add_sort (oi->neighbor_list, on);
130 return on;
paul718e3742002-12-13 20:15:29 +0000131}
132
133void
hasso508e53e2004-05-18 18:57:06 +0000134ospf6_neighbor_delete (struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000135{
hasso3b4cd3a2004-05-18 19:28:32 +0000136 struct ospf6_lsa *lsa;
137
hasso508e53e2004-05-18 18:57:06 +0000138 ospf6_lsdb_remove_all (on->summary_list);
139 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000140 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
141 lsa = ospf6_lsdb_next (lsa))
142 {
hasso6452df02004-08-15 05:52:07 +0000143 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000144 ospf6_lsdb_remove (lsa, on->retrans_list);
145 }
paul718e3742002-12-13 20:15:29 +0000146
hasso508e53e2004-05-18 18:57:06 +0000147 ospf6_lsdb_remove_all (on->dbdesc_list);
hasso508e53e2004-05-18 18:57:06 +0000148 ospf6_lsdb_remove_all (on->lsupdate_list);
149 ospf6_lsdb_remove_all (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000150
hasso508e53e2004-05-18 18:57:06 +0000151 ospf6_lsdb_delete (on->summary_list);
152 ospf6_lsdb_delete (on->request_list);
153 ospf6_lsdb_delete (on->retrans_list);
paul718e3742002-12-13 20:15:29 +0000154
hasso508e53e2004-05-18 18:57:06 +0000155 ospf6_lsdb_delete (on->dbdesc_list);
hasso508e53e2004-05-18 18:57:06 +0000156 ospf6_lsdb_delete (on->lsupdate_list);
157 ospf6_lsdb_delete (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000158
hasso508e53e2004-05-18 18:57:06 +0000159 THREAD_OFF (on->inactivity_timer);
160
161 THREAD_OFF (on->thread_send_dbdesc);
162 THREAD_OFF (on->thread_send_lsreq);
163 THREAD_OFF (on->thread_send_lsupdate);
164 THREAD_OFF (on->thread_send_lsack);
165
166 XFREE (MTYPE_OSPF6_NEIGHBOR, on);
paul718e3742002-12-13 20:15:29 +0000167}
168
hasso508e53e2004-05-18 18:57:06 +0000169static void
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000170ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on, int event)
paul718e3742002-12-13 20:15:29 +0000171{
hasso508e53e2004-05-18 18:57:06 +0000172 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000173
hasso508e53e2004-05-18 18:57:06 +0000174 prev_state = on->state;
175 on->state = next_state;
176
177 if (prev_state == next_state)
178 return;
179
Vincent Bernat061bc732012-05-31 20:21:15 +0200180 on->state_change++;
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900181 quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed);
hasso508e53e2004-05-18 18:57:06 +0000182
183 /* log */
184 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
paul718e3742002-12-13 20:15:29 +0000185 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000186 zlog_debug ("Neighbor state change %s: [%s]->[%s] (%s)", on->name,
hassoc6487d62004-12-24 06:00:11 +0000187 ospf6_neighbor_state_str[prev_state],
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000188 ospf6_neighbor_state_str[next_state],
189 ospf6_neighbor_event_string(event));
paul718e3742002-12-13 20:15:29 +0000190 }
hasso508e53e2004-05-18 18:57:06 +0000191
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000192 /* Optionally notify about adjacency changes */
193 if (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
194 OSPF6_LOG_ADJACENCY_CHANGES) &&
195 (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
196 OSPF6_LOG_ADJACENCY_DETAIL) ||
197 (next_state == OSPF6_NEIGHBOR_FULL) || (next_state < prev_state)))
198 zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on->name,
199 ospf6_neighbor_state_str[prev_state],
200 ospf6_neighbor_state_str[next_state],
201 ospf6_neighbor_event_string(event));
202
hasso508e53e2004-05-18 18:57:06 +0000203 if (prev_state == OSPF6_NEIGHBOR_FULL || next_state == OSPF6_NEIGHBOR_FULL)
204 {
205 OSPF6_ROUTER_LSA_SCHEDULE (on->ospf6_if->area);
206 if (on->ospf6_if->state == OSPF6_INTERFACE_DR)
207 {
208 OSPF6_NETWORK_LSA_SCHEDULE (on->ospf6_if);
209 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on->ospf6_if);
hasso508e53e2004-05-18 18:57:06 +0000210 }
hasso4846ef62004-09-03 06:04:00 +0000211 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on->ospf6_if->area);
hasso508e53e2004-05-18 18:57:06 +0000212 }
213
hasso508e53e2004-05-18 18:57:06 +0000214 if ((prev_state == OSPF6_NEIGHBOR_EXCHANGE ||
215 prev_state == OSPF6_NEIGHBOR_LOADING) &&
216 (next_state != OSPF6_NEIGHBOR_EXCHANGE &&
217 next_state != OSPF6_NEIGHBOR_LOADING))
Paul Jakma932bf192006-05-15 10:42:24 +0000218 ospf6_maxage_remove (on->ospf6_if->area->ospf6);
Vincent Bernatbf836662012-06-04 14:36:12 +0200219
220#ifdef HAVE_SNMP
221 /* Terminal state or regression */
222 if ((next_state == OSPF6_NEIGHBOR_FULL) ||
223 (next_state == OSPF6_NEIGHBOR_TWOWAY) ||
224 (next_state < prev_state))
225 ospf6TrapNbrStateChange (on);
226#endif
227
paul718e3742002-12-13 20:15:29 +0000228}
229
hasso508e53e2004-05-18 18:57:06 +0000230/* RFC2328 section 10.4 */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100231static int
hasso508e53e2004-05-18 18:57:06 +0000232need_adjacency (struct ospf6_neighbor *on)
233{
234 if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT ||
235 on->ospf6_if->state == OSPF6_INTERFACE_DR ||
236 on->ospf6_if->state == OSPF6_INTERFACE_BDR)
237 return 1;
238
239 if (on->ospf6_if->drouter == on->router_id ||
240 on->ospf6_if->bdrouter == on->router_id)
241 return 1;
242
243 return 0;
244}
245
246int
247hello_received (struct thread *thread)
248{
249 struct ospf6_neighbor *on;
250
251 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
252 assert (on);
253
254 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000255 zlog_debug ("Neighbor Event %s: *HelloReceived*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000256
257 /* reset Inactivity Timer */
258 THREAD_OFF (on->inactivity_timer);
259 on->inactivity_timer = thread_add_timer (master, inactivity_timer, on,
260 on->ospf6_if->dead_interval);
261
262 if (on->state <= OSPF6_NEIGHBOR_DOWN)
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000263 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
264 OSPF6_NEIGHBOR_EVENT_HELLO_RCVD);
hasso508e53e2004-05-18 18:57:06 +0000265
266 return 0;
267}
268
269int
270twoway_received (struct thread *thread)
271{
272 struct ospf6_neighbor *on;
273
274 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
275 assert (on);
276
277 if (on->state > OSPF6_NEIGHBOR_INIT)
278 return 0;
279
280 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000281 zlog_debug ("Neighbor Event %s: *2Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000282
283 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
284
285 if (! need_adjacency (on))
286 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000287 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on,
288 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
hasso508e53e2004-05-18 18:57:06 +0000289 return 0;
290 }
291
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000292 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
293 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
hasso508e53e2004-05-18 18:57:06 +0000294 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
295 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
296 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
297
298 THREAD_OFF (on->thread_send_dbdesc);
299 on->thread_send_dbdesc =
300 thread_add_event (master, ospf6_dbdesc_send, on, 0);
301
302 return 0;
303}
304
305int
306negotiation_done (struct thread *thread)
307{
308 struct ospf6_neighbor *on;
309 struct ospf6_lsa *lsa;
310
311 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
312 assert (on);
313
314 if (on->state != OSPF6_NEIGHBOR_EXSTART)
315 return 0;
316
317 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000318 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000319
320 /* clear ls-list */
321 ospf6_lsdb_remove_all (on->summary_list);
322 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000323 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
324 lsa = ospf6_lsdb_next (lsa))
325 {
hasso6452df02004-08-15 05:52:07 +0000326 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000327 ospf6_lsdb_remove (lsa, on->retrans_list);
328 }
hasso508e53e2004-05-18 18:57:06 +0000329
330 /* Interface scoped LSAs */
331 for (lsa = ospf6_lsdb_head (on->ospf6_if->lsdb); lsa;
332 lsa = ospf6_lsdb_next (lsa))
333 {
hasso508e53e2004-05-18 18:57:06 +0000334 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000335 {
hasso6452df02004-08-15 05:52:07 +0000336 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000337 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
338 }
hasso508e53e2004-05-18 18:57:06 +0000339 else
340 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
341 }
342
343 /* Area scoped LSAs */
344 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->lsdb); lsa;
345 lsa = ospf6_lsdb_next (lsa))
346 {
hasso508e53e2004-05-18 18:57:06 +0000347 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000348 {
hasso6452df02004-08-15 05:52:07 +0000349 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000350 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
351 }
hasso508e53e2004-05-18 18:57:06 +0000352 else
353 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
354 }
355
356 /* AS scoped LSAs */
357 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->ospf6->lsdb); lsa;
358 lsa = ospf6_lsdb_next (lsa))
359 {
hasso508e53e2004-05-18 18:57:06 +0000360 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000361 {
hasso6452df02004-08-15 05:52:07 +0000362 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000363 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
364 }
hasso508e53e2004-05-18 18:57:06 +0000365 else
366 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
367 }
368
369 UNSET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000370 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE, on,
371 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE);
hasso508e53e2004-05-18 18:57:06 +0000372
373 return 0;
374}
375
376int
377exchange_done (struct thread *thread)
378{
379 struct ospf6_neighbor *on;
380
381 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
382 assert (on);
383
384 if (on->state != OSPF6_NEIGHBOR_EXCHANGE)
385 return 0;
386
387 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000388 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000389
390 THREAD_OFF (on->thread_send_dbdesc);
391 ospf6_lsdb_remove_all (on->dbdesc_list);
392
393/* XXX
394 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
395 on->ospf6_if->dead_interval);
396*/
397
398 if (on->request_list->count == 0)
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000399 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on,
400 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
hasso508e53e2004-05-18 18:57:06 +0000401 else
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000402 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000403 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on,
404 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000405
406 if (on->thread_send_lsreq == NULL)
407 on->thread_send_lsreq =
408 thread_add_event (master, ospf6_lsreq_send, on, 0);
409 }
hasso508e53e2004-05-18 18:57:06 +0000410
411 return 0;
412}
413
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000414/* Check loading state. */
415void
416ospf6_check_nbr_loading (struct ospf6_neighbor *on)
417{
418
419 /* RFC2328 Section 10.9: When the neighbor responds to these requests
420 with the proper Link State Update packet(s), the Link state request
421 list is truncated and a new Link State Request packet is sent.
422 */
423 if ((on->state == OSPF6_NEIGHBOR_LOADING) ||
424 (on->state == OSPF6_NEIGHBOR_EXCHANGE))
425 {
426 if (on->request_list->count == 0)
427 thread_add_event (master, loading_done, on, 0);
428 else if (on->last_ls_req == NULL)
429 {
430 if (on->thread_send_lsreq != NULL)
431 THREAD_OFF (on->thread_send_lsreq);
432 on->thread_send_lsreq =
433 thread_add_event (master, ospf6_lsreq_send, on, 0);
434 }
435 }
436}
437
hasso508e53e2004-05-18 18:57:06 +0000438int
439loading_done (struct thread *thread)
440{
441 struct ospf6_neighbor *on;
442
443 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
444 assert (on);
445
446 if (on->state != OSPF6_NEIGHBOR_LOADING)
447 return 0;
448
449 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000450 zlog_debug ("Neighbor Event %s: *LoadingDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000451
452 assert (on->request_list->count == 0);
453
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000454 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on,
455 OSPF6_NEIGHBOR_EVENT_LOADING_DONE);
hasso508e53e2004-05-18 18:57:06 +0000456
457 return 0;
458}
459
460int
461adj_ok (struct thread *thread)
462{
463 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000464 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000465
466 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
467 assert (on);
468
469 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000470 zlog_debug ("Neighbor Event %s: *AdjOK?*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000471
472 if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency (on))
473 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000474 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
475 OSPF6_NEIGHBOR_EVENT_ADJ_OK);
hasso508e53e2004-05-18 18:57:06 +0000476 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
477 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
478 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
479
480 THREAD_OFF (on->thread_send_dbdesc);
481 on->thread_send_dbdesc =
482 thread_add_event (master, ospf6_dbdesc_send, on, 0);
483
484 }
485 else if (on->state >= OSPF6_NEIGHBOR_EXSTART &&
486 ! need_adjacency (on))
487 {
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000488 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on,
489 OSPF6_NEIGHBOR_EVENT_ADJ_OK);
hasso508e53e2004-05-18 18:57:06 +0000490 ospf6_lsdb_remove_all (on->summary_list);
491 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000492 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
493 lsa = ospf6_lsdb_next (lsa))
494 {
hasso6452df02004-08-15 05:52:07 +0000495 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000496 ospf6_lsdb_remove (lsa, on->retrans_list);
497 }
hasso508e53e2004-05-18 18:57:06 +0000498 }
499
500 return 0;
501}
502
503int
504seqnumber_mismatch (struct thread *thread)
505{
506 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000507 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000508
509 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
510 assert (on);
511
512 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
513 return 0;
514
515 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000516 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000517
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000518 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
519 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH);
hasso508e53e2004-05-18 18:57:06 +0000520 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
521 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
522 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
523
524 ospf6_lsdb_remove_all (on->summary_list);
525 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000526 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
527 lsa = ospf6_lsdb_next (lsa))
528 {
hasso6452df02004-08-15 05:52:07 +0000529 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000530 ospf6_lsdb_remove (lsa, on->retrans_list);
531 }
hasso508e53e2004-05-18 18:57:06 +0000532
533 THREAD_OFF (on->thread_send_dbdesc);
Dinesh Dutt931b1b82013-08-25 03:03:15 +0000534 on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
535
hasso508e53e2004-05-18 18:57:06 +0000536 on->thread_send_dbdesc =
537 thread_add_event (master, ospf6_dbdesc_send, on, 0);
538
539 return 0;
540}
541
542int
543bad_lsreq (struct thread *thread)
544{
545 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000546 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000547
548 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
549 assert (on);
550
551 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
552 return 0;
553
554 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000555 zlog_debug ("Neighbor Event %s: *BadLSReq*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000556
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000557 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
558 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ);
hasso508e53e2004-05-18 18:57:06 +0000559 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
560 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
561 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
562
563 ospf6_lsdb_remove_all (on->summary_list);
564 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000565 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
566 lsa = ospf6_lsdb_next (lsa))
567 {
hasso6452df02004-08-15 05:52:07 +0000568 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000569 ospf6_lsdb_remove (lsa, on->retrans_list);
570 }
hasso508e53e2004-05-18 18:57:06 +0000571
572 THREAD_OFF (on->thread_send_dbdesc);
Dinesh Dutt931b1b82013-08-25 03:03:15 +0000573 on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
574
hasso508e53e2004-05-18 18:57:06 +0000575 on->thread_send_dbdesc =
576 thread_add_event (master, ospf6_dbdesc_send, on, 0);
577
578 return 0;
579}
580
581int
582oneway_received (struct thread *thread)
583{
584 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000585 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000586
587 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
588 assert (on);
589
590 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
591 return 0;
592
593 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000594 zlog_debug ("Neighbor Event %s: *1Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000595
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000596 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
597 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD);
hasso508e53e2004-05-18 18:57:06 +0000598 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
599
600 ospf6_lsdb_remove_all (on->summary_list);
601 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000602 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
603 lsa = ospf6_lsdb_next (lsa))
604 {
hasso6452df02004-08-15 05:52:07 +0000605 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000606 ospf6_lsdb_remove (lsa, on->retrans_list);
607 }
hasso508e53e2004-05-18 18:57:06 +0000608
609 THREAD_OFF (on->thread_send_dbdesc);
610 THREAD_OFF (on->thread_send_lsreq);
611 THREAD_OFF (on->thread_send_lsupdate);
612 THREAD_OFF (on->thread_send_lsack);
613
614 return 0;
615}
616
617int
618inactivity_timer (struct thread *thread)
619{
620 struct ospf6_neighbor *on;
621
622 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
623 assert (on);
624
625 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000626 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000627
628 on->inactivity_timer = NULL;
629 on->drouter = on->prev_drouter = 0;
630 on->bdrouter = on->prev_bdrouter = 0;
631
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000632 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on,
633 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER);
hasso508e53e2004-05-18 18:57:06 +0000634 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
635
636 listnode_delete (on->ospf6_if->neighbor_list, on);
637 ospf6_neighbor_delete (on);
638
639 return 0;
640}
641
642
David Lamparter6b0655a2014-06-04 06:53:35 +0200643
paul718e3742002-12-13 20:15:29 +0000644/* vty functions */
645/* show neighbor structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100646static void
hasso508e53e2004-05-18 18:57:06 +0000647ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000648{
649 char router_id[16];
hasso508e53e2004-05-18 18:57:06 +0000650 char duration[16];
651 struct timeval now, res;
652 char nstate[16];
653 char deadtime[16];
654 long h, m, s;
655
656 /* Router-ID (Name) */
657 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
658#ifdef HAVE_GETNAMEINFO
659 {
660 }
661#endif /*HAVE_GETNAMEINFO*/
662
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900663 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000664
665 /* Dead time */
666 h = m = s = 0;
667 if (on->inactivity_timer)
668 {
Paul Jakmac136d242007-03-08 17:50:01 +0000669 s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec;
hasso508e53e2004-05-18 18:57:06 +0000670 h = s / 3600;
671 s -= h * 3600;
672 m = s / 60;
673 s -= m * 60;
674 }
675 snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s);
676
677 /* Neighbor State */
678 if (if_is_pointopoint (on->ospf6_if->interface))
679 snprintf (nstate, sizeof (nstate), "PointToPoint");
680 else
681 {
682 if (on->router_id == on->drouter)
683 snprintf (nstate, sizeof (nstate), "DR");
684 else if (on->router_id == on->bdrouter)
685 snprintf (nstate, sizeof (nstate), "BDR");
686 else
687 snprintf (nstate, sizeof (nstate), "DROther");
688 }
689
690 /* Duration */
691 timersub (&now, &on->last_changed, &res);
692 timerstring (&res, duration, sizeof (duration));
693
694 /*
695 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
696 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
hasso049207c2004-08-04 20:02:13 +0000697 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000698 */
699
700 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
701 router_id, on->priority, deadtime,
702 ospf6_neighbor_state_str[on->state], nstate, duration,
703 on->ospf6_if->interface->name,
hasso049207c2004-08-04 20:02:13 +0000704 ospf6_interface_state_str[on->ospf6_if->state], VNL);
hasso508e53e2004-05-18 18:57:06 +0000705}
706
Paul Jakma6ac29a52008-08-15 13:45:30 +0100707static void
hasso508e53e2004-05-18 18:57:06 +0000708ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on)
709{
710 char router_id[16];
711 char drouter[16], bdrouter[16];
paul718e3742002-12-13 20:15:29 +0000712 char duration[16];
713 struct timeval now, res;
714
715/*
716 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
717 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000718 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000719*/
720
hasso508e53e2004-05-18 18:57:06 +0000721 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
722 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
723 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000724
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900725 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000726 timersub (&now, &on->last_changed, &res);
727 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000728
729 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
hasso508e53e2004-05-18 18:57:06 +0000730 router_id, ospf6_neighbor_state_str[on->state],
731 duration, drouter, bdrouter, on->ospf6_if->interface->name,
732 ospf6_interface_state_str[on->ospf6_if->state],
hasso049207c2004-08-04 20:02:13 +0000733 VNL);
paul718e3742002-12-13 20:15:29 +0000734}
735
Paul Jakma6ac29a52008-08-15 13:45:30 +0100736static void
hasso508e53e2004-05-18 18:57:06 +0000737ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000738{
hasso508e53e2004-05-18 18:57:06 +0000739 char drouter[16], bdrouter[16];
740 char linklocal_addr[64], duration[32];
paul718e3742002-12-13 20:15:29 +0000741 struct timeval now, res;
hasso508e53e2004-05-18 18:57:06 +0000742 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000743
hasso508e53e2004-05-18 18:57:06 +0000744 inet_ntop (AF_INET6, &on->linklocal_addr, linklocal_addr,
745 sizeof (linklocal_addr));
746 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
747 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000748
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900749 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000750 timersub (&now, &on->last_changed, &res);
751 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000752
hasso508e53e2004-05-18 18:57:06 +0000753 vty_out (vty, " Neighbor %s%s", on->name,
hasso049207c2004-08-04 20:02:13 +0000754 VNL);
hasso508e53e2004-05-18 18:57:06 +0000755 vty_out (vty, " Area %s via interface %s (ifindex %d)%s",
756 on->ospf6_if->area->name,
757 on->ospf6_if->interface->name,
758 on->ospf6_if->interface->ifindex,
hasso049207c2004-08-04 20:02:13 +0000759 VNL);
hasso508e53e2004-05-18 18:57:06 +0000760 vty_out (vty, " His IfIndex: %d Link-local address: %s%s",
761 on->ifindex, linklocal_addr,
hasso049207c2004-08-04 20:02:13 +0000762 VNL);
hasso508e53e2004-05-18 18:57:06 +0000763 vty_out (vty, " State %s for a duration of %s%s",
764 ospf6_neighbor_state_str[on->state], duration,
hasso049207c2004-08-04 20:02:13 +0000765 VNL);
hasso508e53e2004-05-18 18:57:06 +0000766 vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s",
767 drouter, bdrouter, on->priority,
hasso049207c2004-08-04 20:02:13 +0000768 VNL);
hasso508e53e2004-05-18 18:57:06 +0000769 vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s",
770 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""),
771 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),
772 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ?
773 "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum),
hasso049207c2004-08-04 20:02:13 +0000774 VNL);
paul718e3742002-12-13 20:15:29 +0000775
hasso508e53e2004-05-18 18:57:06 +0000776 vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count,
hasso049207c2004-08-04 20:02:13 +0000777 VNL);
hasso508e53e2004-05-18 18:57:06 +0000778 for (lsa = ospf6_lsdb_head (on->summary_list); lsa;
779 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000780 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000781
hasso508e53e2004-05-18 18:57:06 +0000782 vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count,
hasso049207c2004-08-04 20:02:13 +0000783 VNL);
hasso508e53e2004-05-18 18:57:06 +0000784 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
785 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000786 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000787
788 vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count,
hasso049207c2004-08-04 20:02:13 +0000789 VNL);
hasso508e53e2004-05-18 18:57:06 +0000790 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
791 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000792 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000793
794 timerclear (&res);
795 if (on->thread_send_dbdesc)
796 timersub (&on->thread_send_dbdesc->u.sands, &now, &res);
797 timerstring (&res, duration, sizeof (duration));
798 vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
799 on->dbdesc_list->count, duration,
800 (on->thread_send_dbdesc ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000801 VNL);
hasso508e53e2004-05-18 18:57:06 +0000802 for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa;
803 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000804 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000805
806 timerclear (&res);
807 if (on->thread_send_lsreq)
808 timersub (&on->thread_send_lsreq->u.sands, &now, &res);
809 timerstring (&res, duration, sizeof (duration));
810 vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000811 on->request_list->count, duration,
hasso508e53e2004-05-18 18:57:06 +0000812 (on->thread_send_lsreq ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000813 VNL);
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000814 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
hasso508e53e2004-05-18 18:57:06 +0000815 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000816 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000817
818 timerclear (&res);
819 if (on->thread_send_lsupdate)
820 timersub (&on->thread_send_lsupdate->u.sands, &now, &res);
821 timerstring (&res, duration, sizeof (duration));
822 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
823 on->lsupdate_list->count, duration,
824 (on->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000825 VNL);
hasso508e53e2004-05-18 18:57:06 +0000826 for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa;
827 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000828 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000829
830 timerclear (&res);
831 if (on->thread_send_lsack)
832 timersub (&on->thread_send_lsack->u.sands, &now, &res);
833 timerstring (&res, duration, sizeof (duration));
834 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
835 on->lsack_list->count, duration,
836 (on->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000837 VNL);
hasso508e53e2004-05-18 18:57:06 +0000838 for (lsa = ospf6_lsdb_head (on->lsack_list); lsa;
839 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000840 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000841
paul718e3742002-12-13 20:15:29 +0000842}
843
hasso508e53e2004-05-18 18:57:06 +0000844DEFUN (show_ipv6_ospf6_neighbor,
paul718e3742002-12-13 20:15:29 +0000845 show_ipv6_ospf6_neighbor_cmd,
846 "show ipv6 ospf6 neighbor",
847 SHOW_STR
848 IP6_STR
849 OSPF6_STR
850 "Neighbor list\n"
hasso508e53e2004-05-18 18:57:06 +0000851 )
paul718e3742002-12-13 20:15:29 +0000852{
hasso508e53e2004-05-18 18:57:06 +0000853 struct ospf6_neighbor *on;
854 struct ospf6_interface *oi;
855 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000856 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000857 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
paul718e3742002-12-13 20:15:29 +0000858
859 OSPF6_CMD_CHECK_RUNNING ();
hasso508e53e2004-05-18 18:57:06 +0000860 showfunc = ospf6_neighbor_show;
861
862 if (argc)
863 {
864 if (! strncmp (argv[0], "de", 2))
865 showfunc = ospf6_neighbor_show_detail;
866 else if (! strncmp (argv[0], "dr", 2))
867 showfunc = ospf6_neighbor_show_drchoice;
868 }
869
870 if (showfunc == ospf6_neighbor_show)
871 vty_out (vty, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s",
872 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
hasso049207c2004-08-04 20:02:13 +0000873 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000874 else if (showfunc == ospf6_neighbor_show_drchoice)
875 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
876 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000877 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000878
paul1eb8ef22005-04-07 07:30:20 +0000879 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
880 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
881 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
882 (*showfunc) (vty, on);
883
hasso508e53e2004-05-18 18:57:06 +0000884 return CMD_SUCCESS;
885}
paul718e3742002-12-13 20:15:29 +0000886
hasso508e53e2004-05-18 18:57:06 +0000887ALIAS (show_ipv6_ospf6_neighbor,
888 show_ipv6_ospf6_neighbor_detail_cmd,
889 "show ipv6 ospf6 neighbor (detail|drchoice)",
890 SHOW_STR
891 IP6_STR
892 OSPF6_STR
893 "Neighbor list\n"
894 "Display details\n"
895 "Display DR choices\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100896 )
hasso508e53e2004-05-18 18:57:06 +0000897
898DEFUN (show_ipv6_ospf6_neighbor_one,
899 show_ipv6_ospf6_neighbor_one_cmd,
900 "show ipv6 ospf6 neighbor A.B.C.D",
901 SHOW_STR
902 IP6_STR
903 OSPF6_STR
904 "Neighbor list\n"
905 "Specify Router-ID as IPv4 address notation\n"
906 )
907{
908 struct ospf6_neighbor *on;
909 struct ospf6_interface *oi;
910 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000911 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000912 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
913 u_int32_t router_id;
914
915 OSPF6_CMD_CHECK_RUNNING ();
916 showfunc = ospf6_neighbor_show_detail;
917
918 if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)
919 {
920 vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000921 VNL);
hasso508e53e2004-05-18 18:57:06 +0000922 return CMD_SUCCESS;
923 }
924
paul1eb8ef22005-04-07 07:30:20 +0000925 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
926 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
927 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
928 (*showfunc) (vty, on);
929
paul718e3742002-12-13 20:15:29 +0000930 return CMD_SUCCESS;
931}
932
933void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100934ospf6_neighbor_init (void)
paul718e3742002-12-13 20:15:29 +0000935{
936 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000937 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000938 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000939 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000940}
941
hasso508e53e2004-05-18 18:57:06 +0000942DEFUN (debug_ospf6_neighbor,
943 debug_ospf6_neighbor_cmd,
944 "debug ospf6 neighbor",
945 DEBUG_STR
946 OSPF6_STR
947 "Debug OSPFv3 Neighbor\n"
948 )
949{
950 unsigned char level = 0;
951 if (argc)
952 {
953 if (! strncmp (argv[0], "s", 1))
954 level = OSPF6_DEBUG_NEIGHBOR_STATE;
955 if (! strncmp (argv[0], "e", 1))
956 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
957 }
958 else
959 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
960
961 OSPF6_DEBUG_NEIGHBOR_ON (level);
962 return CMD_SUCCESS;
963}
964
965ALIAS (debug_ospf6_neighbor,
966 debug_ospf6_neighbor_detail_cmd,
967 "debug ospf6 neighbor (state|event)",
968 DEBUG_STR
969 OSPF6_STR
970 "Debug OSPFv3 Neighbor\n"
971 "Debug OSPFv3 Neighbor State Change\n"
972 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100973 )
hasso508e53e2004-05-18 18:57:06 +0000974
975DEFUN (no_debug_ospf6_neighbor,
976 no_debug_ospf6_neighbor_cmd,
977 "no debug ospf6 neighbor",
978 NO_STR
979 DEBUG_STR
980 OSPF6_STR
981 "Debug OSPFv3 Neighbor\n"
982 )
983{
984 unsigned char level = 0;
985 if (argc)
986 {
987 if (! strncmp (argv[0], "s", 1))
988 level = OSPF6_DEBUG_NEIGHBOR_STATE;
989 if (! strncmp (argv[0], "e", 1))
990 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
991 }
992 else
993 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
994
995 OSPF6_DEBUG_NEIGHBOR_OFF (level);
996 return CMD_SUCCESS;
997}
998
999ALIAS (no_debug_ospf6_neighbor,
1000 no_debug_ospf6_neighbor_detail_cmd,
1001 "no debug ospf6 neighbor (state|event)",
1002 NO_STR
1003 DEBUG_STR
1004 OSPF6_STR
1005 "Debug OSPFv3 Neighbor\n"
1006 "Debug OSPFv3 Neighbor State Change\n"
1007 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001008 )
hasso508e53e2004-05-18 18:57:06 +00001009
1010int
1011config_write_ospf6_debug_neighbor (struct vty *vty)
1012{
1013 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) &&
1014 IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +00001015 vty_out (vty, "debug ospf6 neighbor%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001016 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
hasso049207c2004-08-04 20:02:13 +00001017 vty_out (vty, "debug ospf6 neighbor state%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001018 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +00001019 vty_out (vty, "debug ospf6 neighbor event%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001020 return 0;
1021}
1022
1023void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001024install_element_ospf6_debug_neighbor (void)
hasso508e53e2004-05-18 18:57:06 +00001025{
1026 install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);
1027 install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);
1028 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
1029 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);
1030 install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);
1031 install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);
1032 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
1033 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);
1034}
1035
1036
paul718e3742002-12-13 20:15:29 +00001037