blob: 84f0b002c4a682f842453b165ac3c09ff94ba4f4 [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
49int
hasso508e53e2004-05-18 18:57:06 +000050ospf6_neighbor_cmp (void *va, void *vb)
paul718e3742002-12-13 20:15:29 +000051{
hasso508e53e2004-05-18 18:57:06 +000052 struct ospf6_neighbor *ona = (struct ospf6_neighbor *) va;
53 struct ospf6_neighbor *onb = (struct ospf6_neighbor *) vb;
hasso6452df02004-08-15 05:52:07 +000054 return (ntohl (ona->router_id) < ntohl (onb->router_id) ? -1 : 1);
paul718e3742002-12-13 20:15:29 +000055}
56
hasso508e53e2004-05-18 18:57:06 +000057struct ospf6_neighbor *
58ospf6_neighbor_lookup (u_int32_t router_id,
59 struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +000060{
hasso52dc7ee2004-09-23 19:18:23 +000061 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +000062 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +000063
paul1eb8ef22005-04-07 07:30:20 +000064 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, n, on))
65 if (on->router_id == router_id)
66 return on;
67
hasso508e53e2004-05-18 18:57:06 +000068 return (struct ospf6_neighbor *) NULL;
paul718e3742002-12-13 20:15:29 +000069}
70
71/* create ospf6_neighbor */
72struct ospf6_neighbor *
hasso508e53e2004-05-18 18:57:06 +000073ospf6_neighbor_create (u_int32_t router_id, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +000074{
hasso508e53e2004-05-18 18:57:06 +000075 struct ospf6_neighbor *on;
76 char buf[16];
paul718e3742002-12-13 20:15:29 +000077
hasso508e53e2004-05-18 18:57:06 +000078 on = (struct ospf6_neighbor *)
paul718e3742002-12-13 20:15:29 +000079 XMALLOC (MTYPE_OSPF6_NEIGHBOR, sizeof (struct ospf6_neighbor));
hasso508e53e2004-05-18 18:57:06 +000080 if (on == NULL)
paul718e3742002-12-13 20:15:29 +000081 {
82 zlog_warn ("neighbor: malloc failed");
83 return NULL;
84 }
85
hasso508e53e2004-05-18 18:57:06 +000086 memset (on, 0, sizeof (struct ospf6_neighbor));
paul718e3742002-12-13 20:15:29 +000087 inet_ntop (AF_INET, &router_id, buf, sizeof (buf));
hasso508e53e2004-05-18 18:57:06 +000088 snprintf (on->name, sizeof (on->name), "%s%%%s",
89 buf, oi->interface->name);
90 on->ospf6_if = oi;
91 on->state = OSPF6_NEIGHBOR_DOWN;
Vincent Bernat061bc732012-05-31 20:21:15 +020092 on->state_change = 0;
Takashi Sogabe86f72dc2009-06-22 13:07:02 +090093 quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed);
hasso508e53e2004-05-18 18:57:06 +000094 on->router_id = router_id;
paul718e3742002-12-13 20:15:29 +000095
hasso6452df02004-08-15 05:52:07 +000096 on->summary_list = ospf6_lsdb_create (on);
97 on->request_list = ospf6_lsdb_create (on);
98 on->retrans_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +000099
hasso6452df02004-08-15 05:52:07 +0000100 on->dbdesc_list = ospf6_lsdb_create (on);
hasso6452df02004-08-15 05:52:07 +0000101 on->lsupdate_list = ospf6_lsdb_create (on);
102 on->lsack_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +0000103
hasso508e53e2004-05-18 18:57:06 +0000104 listnode_add_sort (oi->neighbor_list, on);
105 return on;
paul718e3742002-12-13 20:15:29 +0000106}
107
108void
hasso508e53e2004-05-18 18:57:06 +0000109ospf6_neighbor_delete (struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000110{
hasso3b4cd3a2004-05-18 19:28:32 +0000111 struct ospf6_lsa *lsa;
112
hasso508e53e2004-05-18 18:57:06 +0000113 ospf6_lsdb_remove_all (on->summary_list);
114 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000115 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
116 lsa = ospf6_lsdb_next (lsa))
117 {
hasso6452df02004-08-15 05:52:07 +0000118 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000119 ospf6_lsdb_remove (lsa, on->retrans_list);
120 }
paul718e3742002-12-13 20:15:29 +0000121
hasso508e53e2004-05-18 18:57:06 +0000122 ospf6_lsdb_remove_all (on->dbdesc_list);
hasso508e53e2004-05-18 18:57:06 +0000123 ospf6_lsdb_remove_all (on->lsupdate_list);
124 ospf6_lsdb_remove_all (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000125
hasso508e53e2004-05-18 18:57:06 +0000126 ospf6_lsdb_delete (on->summary_list);
127 ospf6_lsdb_delete (on->request_list);
128 ospf6_lsdb_delete (on->retrans_list);
paul718e3742002-12-13 20:15:29 +0000129
hasso508e53e2004-05-18 18:57:06 +0000130 ospf6_lsdb_delete (on->dbdesc_list);
hasso508e53e2004-05-18 18:57:06 +0000131 ospf6_lsdb_delete (on->lsupdate_list);
132 ospf6_lsdb_delete (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000133
hasso508e53e2004-05-18 18:57:06 +0000134 THREAD_OFF (on->inactivity_timer);
135
136 THREAD_OFF (on->thread_send_dbdesc);
137 THREAD_OFF (on->thread_send_lsreq);
138 THREAD_OFF (on->thread_send_lsupdate);
139 THREAD_OFF (on->thread_send_lsack);
140
141 XFREE (MTYPE_OSPF6_NEIGHBOR, on);
paul718e3742002-12-13 20:15:29 +0000142}
143
hasso508e53e2004-05-18 18:57:06 +0000144static void
145ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000146{
hasso508e53e2004-05-18 18:57:06 +0000147 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000148
hasso508e53e2004-05-18 18:57:06 +0000149 prev_state = on->state;
150 on->state = next_state;
151
152 if (prev_state == next_state)
153 return;
154
Vincent Bernat061bc732012-05-31 20:21:15 +0200155 on->state_change++;
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900156 quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed);
hasso508e53e2004-05-18 18:57:06 +0000157
158 /* log */
159 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
paul718e3742002-12-13 20:15:29 +0000160 {
hassoc6487d62004-12-24 06:00:11 +0000161 zlog_debug ("Neighbor state change %s: [%s]->[%s]", on->name,
162 ospf6_neighbor_state_str[prev_state],
163 ospf6_neighbor_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000164 }
hasso508e53e2004-05-18 18:57:06 +0000165
166 if (prev_state == OSPF6_NEIGHBOR_FULL || next_state == OSPF6_NEIGHBOR_FULL)
167 {
168 OSPF6_ROUTER_LSA_SCHEDULE (on->ospf6_if->area);
169 if (on->ospf6_if->state == OSPF6_INTERFACE_DR)
170 {
171 OSPF6_NETWORK_LSA_SCHEDULE (on->ospf6_if);
172 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on->ospf6_if);
hasso508e53e2004-05-18 18:57:06 +0000173 }
hasso4846ef62004-09-03 06:04:00 +0000174 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on->ospf6_if->area);
hasso508e53e2004-05-18 18:57:06 +0000175 }
176
hasso508e53e2004-05-18 18:57:06 +0000177 if ((prev_state == OSPF6_NEIGHBOR_EXCHANGE ||
178 prev_state == OSPF6_NEIGHBOR_LOADING) &&
179 (next_state != OSPF6_NEIGHBOR_EXCHANGE &&
180 next_state != OSPF6_NEIGHBOR_LOADING))
Paul Jakma932bf192006-05-15 10:42:24 +0000181 ospf6_maxage_remove (on->ospf6_if->area->ospf6);
Vincent Bernatbf836662012-06-04 14:36:12 +0200182
183#ifdef HAVE_SNMP
184 /* Terminal state or regression */
185 if ((next_state == OSPF6_NEIGHBOR_FULL) ||
186 (next_state == OSPF6_NEIGHBOR_TWOWAY) ||
187 (next_state < prev_state))
188 ospf6TrapNbrStateChange (on);
189#endif
190
paul718e3742002-12-13 20:15:29 +0000191}
192
hasso508e53e2004-05-18 18:57:06 +0000193/* RFC2328 section 10.4 */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100194static int
hasso508e53e2004-05-18 18:57:06 +0000195need_adjacency (struct ospf6_neighbor *on)
196{
197 if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT ||
198 on->ospf6_if->state == OSPF6_INTERFACE_DR ||
199 on->ospf6_if->state == OSPF6_INTERFACE_BDR)
200 return 1;
201
202 if (on->ospf6_if->drouter == on->router_id ||
203 on->ospf6_if->bdrouter == on->router_id)
204 return 1;
205
206 return 0;
207}
208
209int
210hello_received (struct thread *thread)
211{
212 struct ospf6_neighbor *on;
213
214 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
215 assert (on);
216
217 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000218 zlog_debug ("Neighbor Event %s: *HelloReceived*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000219
220 /* reset Inactivity Timer */
221 THREAD_OFF (on->inactivity_timer);
222 on->inactivity_timer = thread_add_timer (master, inactivity_timer, on,
223 on->ospf6_if->dead_interval);
224
225 if (on->state <= OSPF6_NEIGHBOR_DOWN)
226 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
227
228 return 0;
229}
230
231int
232twoway_received (struct thread *thread)
233{
234 struct ospf6_neighbor *on;
235
236 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
237 assert (on);
238
239 if (on->state > OSPF6_NEIGHBOR_INIT)
240 return 0;
241
242 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000243 zlog_debug ("Neighbor Event %s: *2Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000244
245 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
246
247 if (! need_adjacency (on))
248 {
249 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
250 return 0;
251 }
252
253 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
254 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
255 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
256 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
257
258 THREAD_OFF (on->thread_send_dbdesc);
259 on->thread_send_dbdesc =
260 thread_add_event (master, ospf6_dbdesc_send, on, 0);
261
262 return 0;
263}
264
265int
266negotiation_done (struct thread *thread)
267{
268 struct ospf6_neighbor *on;
269 struct ospf6_lsa *lsa;
270
271 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
272 assert (on);
273
274 if (on->state != OSPF6_NEIGHBOR_EXSTART)
275 return 0;
276
277 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000278 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000279
280 /* clear ls-list */
281 ospf6_lsdb_remove_all (on->summary_list);
282 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000283 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
284 lsa = ospf6_lsdb_next (lsa))
285 {
hasso6452df02004-08-15 05:52:07 +0000286 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000287 ospf6_lsdb_remove (lsa, on->retrans_list);
288 }
hasso508e53e2004-05-18 18:57:06 +0000289
290 /* Interface scoped LSAs */
291 for (lsa = ospf6_lsdb_head (on->ospf6_if->lsdb); lsa;
292 lsa = ospf6_lsdb_next (lsa))
293 {
hasso508e53e2004-05-18 18:57:06 +0000294 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000295 {
hasso6452df02004-08-15 05:52:07 +0000296 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000297 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
298 }
hasso508e53e2004-05-18 18:57:06 +0000299 else
300 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
301 }
302
303 /* Area scoped LSAs */
304 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->lsdb); lsa;
305 lsa = ospf6_lsdb_next (lsa))
306 {
hasso508e53e2004-05-18 18:57:06 +0000307 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000308 {
hasso6452df02004-08-15 05:52:07 +0000309 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000310 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
311 }
hasso508e53e2004-05-18 18:57:06 +0000312 else
313 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
314 }
315
316 /* AS scoped LSAs */
317 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->ospf6->lsdb); lsa;
318 lsa = ospf6_lsdb_next (lsa))
319 {
hasso508e53e2004-05-18 18:57:06 +0000320 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000321 {
hasso6452df02004-08-15 05:52:07 +0000322 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000323 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
324 }
hasso508e53e2004-05-18 18:57:06 +0000325 else
326 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
327 }
328
329 UNSET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
330 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE, on);
331
332 return 0;
333}
334
335int
336exchange_done (struct thread *thread)
337{
338 struct ospf6_neighbor *on;
339
340 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
341 assert (on);
342
343 if (on->state != OSPF6_NEIGHBOR_EXCHANGE)
344 return 0;
345
346 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000347 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000348
349 THREAD_OFF (on->thread_send_dbdesc);
350 ospf6_lsdb_remove_all (on->dbdesc_list);
351
352/* XXX
353 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
354 on->ospf6_if->dead_interval);
355*/
356
357 if (on->request_list->count == 0)
358 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
359 else
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000360 {
361 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on);
362
363 if (on->thread_send_lsreq == NULL)
364 on->thread_send_lsreq =
365 thread_add_event (master, ospf6_lsreq_send, on, 0);
366 }
hasso508e53e2004-05-18 18:57:06 +0000367
368 return 0;
369}
370
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000371/* Check loading state. */
372void
373ospf6_check_nbr_loading (struct ospf6_neighbor *on)
374{
375
376 /* RFC2328 Section 10.9: When the neighbor responds to these requests
377 with the proper Link State Update packet(s), the Link state request
378 list is truncated and a new Link State Request packet is sent.
379 */
380 if ((on->state == OSPF6_NEIGHBOR_LOADING) ||
381 (on->state == OSPF6_NEIGHBOR_EXCHANGE))
382 {
383 if (on->request_list->count == 0)
384 thread_add_event (master, loading_done, on, 0);
385 else if (on->last_ls_req == NULL)
386 {
387 if (on->thread_send_lsreq != NULL)
388 THREAD_OFF (on->thread_send_lsreq);
389 on->thread_send_lsreq =
390 thread_add_event (master, ospf6_lsreq_send, on, 0);
391 }
392 }
393}
394
hasso508e53e2004-05-18 18:57:06 +0000395int
396loading_done (struct thread *thread)
397{
398 struct ospf6_neighbor *on;
399
400 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
401 assert (on);
402
403 if (on->state != OSPF6_NEIGHBOR_LOADING)
404 return 0;
405
406 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000407 zlog_debug ("Neighbor Event %s: *LoadingDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000408
409 assert (on->request_list->count == 0);
410
411 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
412
413 return 0;
414}
415
416int
417adj_ok (struct thread *thread)
418{
419 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000420 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000421
422 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
423 assert (on);
424
425 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000426 zlog_debug ("Neighbor Event %s: *AdjOK?*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000427
428 if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency (on))
429 {
430 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
431 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
432 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
433 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
434
435 THREAD_OFF (on->thread_send_dbdesc);
436 on->thread_send_dbdesc =
437 thread_add_event (master, ospf6_dbdesc_send, on, 0);
438
439 }
440 else if (on->state >= OSPF6_NEIGHBOR_EXSTART &&
441 ! need_adjacency (on))
442 {
443 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
444 ospf6_lsdb_remove_all (on->summary_list);
445 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000446 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
447 lsa = ospf6_lsdb_next (lsa))
448 {
hasso6452df02004-08-15 05:52:07 +0000449 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000450 ospf6_lsdb_remove (lsa, on->retrans_list);
451 }
hasso508e53e2004-05-18 18:57:06 +0000452 }
453
454 return 0;
455}
456
457int
458seqnumber_mismatch (struct thread *thread)
459{
460 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000461 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000462
463 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
464 assert (on);
465
466 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
467 return 0;
468
469 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000470 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000471
472 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
473 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
474 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
475 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
476
477 ospf6_lsdb_remove_all (on->summary_list);
478 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000479 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
480 lsa = ospf6_lsdb_next (lsa))
481 {
hasso6452df02004-08-15 05:52:07 +0000482 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000483 ospf6_lsdb_remove (lsa, on->retrans_list);
484 }
hasso508e53e2004-05-18 18:57:06 +0000485
486 THREAD_OFF (on->thread_send_dbdesc);
487 on->thread_send_dbdesc =
488 thread_add_event (master, ospf6_dbdesc_send, on, 0);
489
490 return 0;
491}
492
493int
494bad_lsreq (struct thread *thread)
495{
496 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000497 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000498
499 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
500 assert (on);
501
502 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
503 return 0;
504
505 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000506 zlog_debug ("Neighbor Event %s: *BadLSReq*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000507
508 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
509 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
510 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
511 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
512
513 ospf6_lsdb_remove_all (on->summary_list);
514 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000515 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
516 lsa = ospf6_lsdb_next (lsa))
517 {
hasso6452df02004-08-15 05:52:07 +0000518 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000519 ospf6_lsdb_remove (lsa, on->retrans_list);
520 }
hasso508e53e2004-05-18 18:57:06 +0000521
522 THREAD_OFF (on->thread_send_dbdesc);
523 on->thread_send_dbdesc =
524 thread_add_event (master, ospf6_dbdesc_send, on, 0);
525
526 return 0;
527}
528
529int
530oneway_received (struct thread *thread)
531{
532 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000533 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000534
535 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
536 assert (on);
537
538 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
539 return 0;
540
541 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000542 zlog_debug ("Neighbor Event %s: *1Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000543
544 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
545 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
546
547 ospf6_lsdb_remove_all (on->summary_list);
548 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000549 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
550 lsa = ospf6_lsdb_next (lsa))
551 {
hasso6452df02004-08-15 05:52:07 +0000552 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000553 ospf6_lsdb_remove (lsa, on->retrans_list);
554 }
hasso508e53e2004-05-18 18:57:06 +0000555
556 THREAD_OFF (on->thread_send_dbdesc);
557 THREAD_OFF (on->thread_send_lsreq);
558 THREAD_OFF (on->thread_send_lsupdate);
559 THREAD_OFF (on->thread_send_lsack);
560
561 return 0;
562}
563
564int
565inactivity_timer (struct thread *thread)
566{
567 struct ospf6_neighbor *on;
568
569 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
570 assert (on);
571
572 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000573 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000574
575 on->inactivity_timer = NULL;
576 on->drouter = on->prev_drouter = 0;
577 on->bdrouter = on->prev_bdrouter = 0;
578
579 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on);
580 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
581
582 listnode_delete (on->ospf6_if->neighbor_list, on);
583 ospf6_neighbor_delete (on);
584
585 return 0;
586}
587
588
paul718e3742002-12-13 20:15:29 +0000589
590/* vty functions */
591/* show neighbor structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100592static void
hasso508e53e2004-05-18 18:57:06 +0000593ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000594{
595 char router_id[16];
hasso508e53e2004-05-18 18:57:06 +0000596 char duration[16];
597 struct timeval now, res;
598 char nstate[16];
599 char deadtime[16];
600 long h, m, s;
601
602 /* Router-ID (Name) */
603 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
604#ifdef HAVE_GETNAMEINFO
605 {
606 }
607#endif /*HAVE_GETNAMEINFO*/
608
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900609 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000610
611 /* Dead time */
612 h = m = s = 0;
613 if (on->inactivity_timer)
614 {
Paul Jakmac136d242007-03-08 17:50:01 +0000615 s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec;
hasso508e53e2004-05-18 18:57:06 +0000616 h = s / 3600;
617 s -= h * 3600;
618 m = s / 60;
619 s -= m * 60;
620 }
621 snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s);
622
623 /* Neighbor State */
624 if (if_is_pointopoint (on->ospf6_if->interface))
625 snprintf (nstate, sizeof (nstate), "PointToPoint");
626 else
627 {
628 if (on->router_id == on->drouter)
629 snprintf (nstate, sizeof (nstate), "DR");
630 else if (on->router_id == on->bdrouter)
631 snprintf (nstate, sizeof (nstate), "BDR");
632 else
633 snprintf (nstate, sizeof (nstate), "DROther");
634 }
635
636 /* Duration */
637 timersub (&now, &on->last_changed, &res);
638 timerstring (&res, duration, sizeof (duration));
639
640 /*
641 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
642 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
hasso049207c2004-08-04 20:02:13 +0000643 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000644 */
645
646 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
647 router_id, on->priority, deadtime,
648 ospf6_neighbor_state_str[on->state], nstate, duration,
649 on->ospf6_if->interface->name,
hasso049207c2004-08-04 20:02:13 +0000650 ospf6_interface_state_str[on->ospf6_if->state], VNL);
hasso508e53e2004-05-18 18:57:06 +0000651}
652
Paul Jakma6ac29a52008-08-15 13:45:30 +0100653static void
hasso508e53e2004-05-18 18:57:06 +0000654ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on)
655{
656 char router_id[16];
657 char drouter[16], bdrouter[16];
paul718e3742002-12-13 20:15:29 +0000658 char duration[16];
659 struct timeval now, res;
660
661/*
662 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
663 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000664 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000665*/
666
hasso508e53e2004-05-18 18:57:06 +0000667 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
668 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
669 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000670
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900671 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000672 timersub (&now, &on->last_changed, &res);
673 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000674
675 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
hasso508e53e2004-05-18 18:57:06 +0000676 router_id, ospf6_neighbor_state_str[on->state],
677 duration, drouter, bdrouter, on->ospf6_if->interface->name,
678 ospf6_interface_state_str[on->ospf6_if->state],
hasso049207c2004-08-04 20:02:13 +0000679 VNL);
paul718e3742002-12-13 20:15:29 +0000680}
681
Paul Jakma6ac29a52008-08-15 13:45:30 +0100682static void
hasso508e53e2004-05-18 18:57:06 +0000683ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000684{
hasso508e53e2004-05-18 18:57:06 +0000685 char drouter[16], bdrouter[16];
686 char linklocal_addr[64], duration[32];
paul718e3742002-12-13 20:15:29 +0000687 struct timeval now, res;
hasso508e53e2004-05-18 18:57:06 +0000688 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000689
hasso508e53e2004-05-18 18:57:06 +0000690 inet_ntop (AF_INET6, &on->linklocal_addr, linklocal_addr,
691 sizeof (linklocal_addr));
692 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
693 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000694
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900695 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000696 timersub (&now, &on->last_changed, &res);
697 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000698
hasso508e53e2004-05-18 18:57:06 +0000699 vty_out (vty, " Neighbor %s%s", on->name,
hasso049207c2004-08-04 20:02:13 +0000700 VNL);
hasso508e53e2004-05-18 18:57:06 +0000701 vty_out (vty, " Area %s via interface %s (ifindex %d)%s",
702 on->ospf6_if->area->name,
703 on->ospf6_if->interface->name,
704 on->ospf6_if->interface->ifindex,
hasso049207c2004-08-04 20:02:13 +0000705 VNL);
hasso508e53e2004-05-18 18:57:06 +0000706 vty_out (vty, " His IfIndex: %d Link-local address: %s%s",
707 on->ifindex, linklocal_addr,
hasso049207c2004-08-04 20:02:13 +0000708 VNL);
hasso508e53e2004-05-18 18:57:06 +0000709 vty_out (vty, " State %s for a duration of %s%s",
710 ospf6_neighbor_state_str[on->state], duration,
hasso049207c2004-08-04 20:02:13 +0000711 VNL);
hasso508e53e2004-05-18 18:57:06 +0000712 vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s",
713 drouter, bdrouter, on->priority,
hasso049207c2004-08-04 20:02:13 +0000714 VNL);
hasso508e53e2004-05-18 18:57:06 +0000715 vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s",
716 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""),
717 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),
718 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ?
719 "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum),
hasso049207c2004-08-04 20:02:13 +0000720 VNL);
paul718e3742002-12-13 20:15:29 +0000721
hasso508e53e2004-05-18 18:57:06 +0000722 vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count,
hasso049207c2004-08-04 20:02:13 +0000723 VNL);
hasso508e53e2004-05-18 18:57:06 +0000724 for (lsa = ospf6_lsdb_head (on->summary_list); lsa;
725 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000726 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000727
hasso508e53e2004-05-18 18:57:06 +0000728 vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count,
hasso049207c2004-08-04 20:02:13 +0000729 VNL);
hasso508e53e2004-05-18 18:57:06 +0000730 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
731 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000732 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000733
734 vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count,
hasso049207c2004-08-04 20:02:13 +0000735 VNL);
hasso508e53e2004-05-18 18:57:06 +0000736 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
737 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000738 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000739
740 timerclear (&res);
741 if (on->thread_send_dbdesc)
742 timersub (&on->thread_send_dbdesc->u.sands, &now, &res);
743 timerstring (&res, duration, sizeof (duration));
744 vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
745 on->dbdesc_list->count, duration,
746 (on->thread_send_dbdesc ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000747 VNL);
hasso508e53e2004-05-18 18:57:06 +0000748 for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa;
749 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000750 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000751
752 timerclear (&res);
753 if (on->thread_send_lsreq)
754 timersub (&on->thread_send_lsreq->u.sands, &now, &res);
755 timerstring (&res, duration, sizeof (duration));
756 vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000757 on->request_list->count, duration,
hasso508e53e2004-05-18 18:57:06 +0000758 (on->thread_send_lsreq ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000759 VNL);
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000760 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
hasso508e53e2004-05-18 18:57:06 +0000761 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000762 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000763
764 timerclear (&res);
765 if (on->thread_send_lsupdate)
766 timersub (&on->thread_send_lsupdate->u.sands, &now, &res);
767 timerstring (&res, duration, sizeof (duration));
768 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
769 on->lsupdate_list->count, duration,
770 (on->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000771 VNL);
hasso508e53e2004-05-18 18:57:06 +0000772 for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa;
773 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000774 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000775
776 timerclear (&res);
777 if (on->thread_send_lsack)
778 timersub (&on->thread_send_lsack->u.sands, &now, &res);
779 timerstring (&res, duration, sizeof (duration));
780 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
781 on->lsack_list->count, duration,
782 (on->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000783 VNL);
hasso508e53e2004-05-18 18:57:06 +0000784 for (lsa = ospf6_lsdb_head (on->lsack_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
paul718e3742002-12-13 20:15:29 +0000788}
789
hasso508e53e2004-05-18 18:57:06 +0000790DEFUN (show_ipv6_ospf6_neighbor,
paul718e3742002-12-13 20:15:29 +0000791 show_ipv6_ospf6_neighbor_cmd,
792 "show ipv6 ospf6 neighbor",
793 SHOW_STR
794 IP6_STR
795 OSPF6_STR
796 "Neighbor list\n"
hasso508e53e2004-05-18 18:57:06 +0000797 )
paul718e3742002-12-13 20:15:29 +0000798{
hasso508e53e2004-05-18 18:57:06 +0000799 struct ospf6_neighbor *on;
800 struct ospf6_interface *oi;
801 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000802 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000803 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
paul718e3742002-12-13 20:15:29 +0000804
805 OSPF6_CMD_CHECK_RUNNING ();
hasso508e53e2004-05-18 18:57:06 +0000806 showfunc = ospf6_neighbor_show;
807
808 if (argc)
809 {
810 if (! strncmp (argv[0], "de", 2))
811 showfunc = ospf6_neighbor_show_detail;
812 else if (! strncmp (argv[0], "dr", 2))
813 showfunc = ospf6_neighbor_show_drchoice;
814 }
815
816 if (showfunc == ospf6_neighbor_show)
817 vty_out (vty, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s",
818 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
hasso049207c2004-08-04 20:02:13 +0000819 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000820 else if (showfunc == ospf6_neighbor_show_drchoice)
821 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
822 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000823 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000824
paul1eb8ef22005-04-07 07:30:20 +0000825 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
826 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
827 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
828 (*showfunc) (vty, on);
829
hasso508e53e2004-05-18 18:57:06 +0000830 return CMD_SUCCESS;
831}
paul718e3742002-12-13 20:15:29 +0000832
hasso508e53e2004-05-18 18:57:06 +0000833ALIAS (show_ipv6_ospf6_neighbor,
834 show_ipv6_ospf6_neighbor_detail_cmd,
835 "show ipv6 ospf6 neighbor (detail|drchoice)",
836 SHOW_STR
837 IP6_STR
838 OSPF6_STR
839 "Neighbor list\n"
840 "Display details\n"
841 "Display DR choices\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100842 )
hasso508e53e2004-05-18 18:57:06 +0000843
844DEFUN (show_ipv6_ospf6_neighbor_one,
845 show_ipv6_ospf6_neighbor_one_cmd,
846 "show ipv6 ospf6 neighbor A.B.C.D",
847 SHOW_STR
848 IP6_STR
849 OSPF6_STR
850 "Neighbor list\n"
851 "Specify Router-ID as IPv4 address notation\n"
852 )
853{
854 struct ospf6_neighbor *on;
855 struct ospf6_interface *oi;
856 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000857 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000858 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
859 u_int32_t router_id;
860
861 OSPF6_CMD_CHECK_RUNNING ();
862 showfunc = ospf6_neighbor_show_detail;
863
864 if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)
865 {
866 vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000867 VNL);
hasso508e53e2004-05-18 18:57:06 +0000868 return CMD_SUCCESS;
869 }
870
paul1eb8ef22005-04-07 07:30:20 +0000871 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
872 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
873 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
874 (*showfunc) (vty, on);
875
paul718e3742002-12-13 20:15:29 +0000876 return CMD_SUCCESS;
877}
878
879void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100880ospf6_neighbor_init (void)
paul718e3742002-12-13 20:15:29 +0000881{
882 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000883 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000884 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000885 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000886}
887
hasso508e53e2004-05-18 18:57:06 +0000888DEFUN (debug_ospf6_neighbor,
889 debug_ospf6_neighbor_cmd,
890 "debug ospf6 neighbor",
891 DEBUG_STR
892 OSPF6_STR
893 "Debug OSPFv3 Neighbor\n"
894 )
895{
896 unsigned char level = 0;
897 if (argc)
898 {
899 if (! strncmp (argv[0], "s", 1))
900 level = OSPF6_DEBUG_NEIGHBOR_STATE;
901 if (! strncmp (argv[0], "e", 1))
902 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
903 }
904 else
905 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
906
907 OSPF6_DEBUG_NEIGHBOR_ON (level);
908 return CMD_SUCCESS;
909}
910
911ALIAS (debug_ospf6_neighbor,
912 debug_ospf6_neighbor_detail_cmd,
913 "debug ospf6 neighbor (state|event)",
914 DEBUG_STR
915 OSPF6_STR
916 "Debug OSPFv3 Neighbor\n"
917 "Debug OSPFv3 Neighbor State Change\n"
918 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100919 )
hasso508e53e2004-05-18 18:57:06 +0000920
921DEFUN (no_debug_ospf6_neighbor,
922 no_debug_ospf6_neighbor_cmd,
923 "no debug ospf6 neighbor",
924 NO_STR
925 DEBUG_STR
926 OSPF6_STR
927 "Debug OSPFv3 Neighbor\n"
928 )
929{
930 unsigned char level = 0;
931 if (argc)
932 {
933 if (! strncmp (argv[0], "s", 1))
934 level = OSPF6_DEBUG_NEIGHBOR_STATE;
935 if (! strncmp (argv[0], "e", 1))
936 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
937 }
938 else
939 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
940
941 OSPF6_DEBUG_NEIGHBOR_OFF (level);
942 return CMD_SUCCESS;
943}
944
945ALIAS (no_debug_ospf6_neighbor,
946 no_debug_ospf6_neighbor_detail_cmd,
947 "no debug ospf6 neighbor (state|event)",
948 NO_STR
949 DEBUG_STR
950 OSPF6_STR
951 "Debug OSPFv3 Neighbor\n"
952 "Debug OSPFv3 Neighbor State Change\n"
953 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100954 )
hasso508e53e2004-05-18 18:57:06 +0000955
956int
957config_write_ospf6_debug_neighbor (struct vty *vty)
958{
959 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) &&
960 IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000961 vty_out (vty, "debug ospf6 neighbor%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000962 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
hasso049207c2004-08-04 20:02:13 +0000963 vty_out (vty, "debug ospf6 neighbor state%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000964 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000965 vty_out (vty, "debug ospf6 neighbor event%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000966 return 0;
967}
968
969void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100970install_element_ospf6_debug_neighbor (void)
hasso508e53e2004-05-18 18:57:06 +0000971{
972 install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);
973 install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);
974 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
975 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);
976 install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);
977 install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);
978 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
979 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);
980}
981
982
paul718e3742002-12-13 20:15:29 +0000983