blob: b7d2e40dbd7a160b278dcbb84dfca988eecda0ff [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);
Dinesh Dutt931b1b82013-08-25 03:03:15 +0000487 on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
488
hasso508e53e2004-05-18 18:57:06 +0000489 on->thread_send_dbdesc =
490 thread_add_event (master, ospf6_dbdesc_send, on, 0);
491
492 return 0;
493}
494
495int
496bad_lsreq (struct thread *thread)
497{
498 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000499 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000500
501 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
502 assert (on);
503
504 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
505 return 0;
506
507 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000508 zlog_debug ("Neighbor Event %s: *BadLSReq*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000509
510 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
511 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
512 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
513 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
514
515 ospf6_lsdb_remove_all (on->summary_list);
516 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000517 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
518 lsa = ospf6_lsdb_next (lsa))
519 {
hasso6452df02004-08-15 05:52:07 +0000520 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000521 ospf6_lsdb_remove (lsa, on->retrans_list);
522 }
hasso508e53e2004-05-18 18:57:06 +0000523
524 THREAD_OFF (on->thread_send_dbdesc);
Dinesh Dutt931b1b82013-08-25 03:03:15 +0000525 on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
526
hasso508e53e2004-05-18 18:57:06 +0000527 on->thread_send_dbdesc =
528 thread_add_event (master, ospf6_dbdesc_send, on, 0);
529
530 return 0;
531}
532
533int
534oneway_received (struct thread *thread)
535{
536 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000537 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000538
539 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
540 assert (on);
541
542 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
543 return 0;
544
545 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000546 zlog_debug ("Neighbor Event %s: *1Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000547
548 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
549 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
550
551 ospf6_lsdb_remove_all (on->summary_list);
552 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000553 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
554 lsa = ospf6_lsdb_next (lsa))
555 {
hasso6452df02004-08-15 05:52:07 +0000556 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000557 ospf6_lsdb_remove (lsa, on->retrans_list);
558 }
hasso508e53e2004-05-18 18:57:06 +0000559
560 THREAD_OFF (on->thread_send_dbdesc);
561 THREAD_OFF (on->thread_send_lsreq);
562 THREAD_OFF (on->thread_send_lsupdate);
563 THREAD_OFF (on->thread_send_lsack);
564
565 return 0;
566}
567
568int
569inactivity_timer (struct thread *thread)
570{
571 struct ospf6_neighbor *on;
572
573 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
574 assert (on);
575
576 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000577 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000578
579 on->inactivity_timer = NULL;
580 on->drouter = on->prev_drouter = 0;
581 on->bdrouter = on->prev_bdrouter = 0;
582
583 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on);
584 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
585
586 listnode_delete (on->ospf6_if->neighbor_list, on);
587 ospf6_neighbor_delete (on);
588
589 return 0;
590}
591
592
paul718e3742002-12-13 20:15:29 +0000593
594/* vty functions */
595/* show neighbor structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100596static void
hasso508e53e2004-05-18 18:57:06 +0000597ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000598{
599 char router_id[16];
hasso508e53e2004-05-18 18:57:06 +0000600 char duration[16];
601 struct timeval now, res;
602 char nstate[16];
603 char deadtime[16];
604 long h, m, s;
605
606 /* Router-ID (Name) */
607 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
608#ifdef HAVE_GETNAMEINFO
609 {
610 }
611#endif /*HAVE_GETNAMEINFO*/
612
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900613 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000614
615 /* Dead time */
616 h = m = s = 0;
617 if (on->inactivity_timer)
618 {
Paul Jakmac136d242007-03-08 17:50:01 +0000619 s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec;
hasso508e53e2004-05-18 18:57:06 +0000620 h = s / 3600;
621 s -= h * 3600;
622 m = s / 60;
623 s -= m * 60;
624 }
625 snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s);
626
627 /* Neighbor State */
628 if (if_is_pointopoint (on->ospf6_if->interface))
629 snprintf (nstate, sizeof (nstate), "PointToPoint");
630 else
631 {
632 if (on->router_id == on->drouter)
633 snprintf (nstate, sizeof (nstate), "DR");
634 else if (on->router_id == on->bdrouter)
635 snprintf (nstate, sizeof (nstate), "BDR");
636 else
637 snprintf (nstate, sizeof (nstate), "DROther");
638 }
639
640 /* Duration */
641 timersub (&now, &on->last_changed, &res);
642 timerstring (&res, duration, sizeof (duration));
643
644 /*
645 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
646 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
hasso049207c2004-08-04 20:02:13 +0000647 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000648 */
649
650 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
651 router_id, on->priority, deadtime,
652 ospf6_neighbor_state_str[on->state], nstate, duration,
653 on->ospf6_if->interface->name,
hasso049207c2004-08-04 20:02:13 +0000654 ospf6_interface_state_str[on->ospf6_if->state], VNL);
hasso508e53e2004-05-18 18:57:06 +0000655}
656
Paul Jakma6ac29a52008-08-15 13:45:30 +0100657static void
hasso508e53e2004-05-18 18:57:06 +0000658ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on)
659{
660 char router_id[16];
661 char drouter[16], bdrouter[16];
paul718e3742002-12-13 20:15:29 +0000662 char duration[16];
663 struct timeval now, res;
664
665/*
666 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
667 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000668 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000669*/
670
hasso508e53e2004-05-18 18:57:06 +0000671 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
672 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
673 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000674
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900675 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000676 timersub (&now, &on->last_changed, &res);
677 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000678
679 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
hasso508e53e2004-05-18 18:57:06 +0000680 router_id, ospf6_neighbor_state_str[on->state],
681 duration, drouter, bdrouter, on->ospf6_if->interface->name,
682 ospf6_interface_state_str[on->ospf6_if->state],
hasso049207c2004-08-04 20:02:13 +0000683 VNL);
paul718e3742002-12-13 20:15:29 +0000684}
685
Paul Jakma6ac29a52008-08-15 13:45:30 +0100686static void
hasso508e53e2004-05-18 18:57:06 +0000687ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000688{
hasso508e53e2004-05-18 18:57:06 +0000689 char drouter[16], bdrouter[16];
690 char linklocal_addr[64], duration[32];
paul718e3742002-12-13 20:15:29 +0000691 struct timeval now, res;
hasso508e53e2004-05-18 18:57:06 +0000692 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000693
hasso508e53e2004-05-18 18:57:06 +0000694 inet_ntop (AF_INET6, &on->linklocal_addr, linklocal_addr,
695 sizeof (linklocal_addr));
696 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
697 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000698
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900699 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000700 timersub (&now, &on->last_changed, &res);
701 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000702
hasso508e53e2004-05-18 18:57:06 +0000703 vty_out (vty, " Neighbor %s%s", on->name,
hasso049207c2004-08-04 20:02:13 +0000704 VNL);
hasso508e53e2004-05-18 18:57:06 +0000705 vty_out (vty, " Area %s via interface %s (ifindex %d)%s",
706 on->ospf6_if->area->name,
707 on->ospf6_if->interface->name,
708 on->ospf6_if->interface->ifindex,
hasso049207c2004-08-04 20:02:13 +0000709 VNL);
hasso508e53e2004-05-18 18:57:06 +0000710 vty_out (vty, " His IfIndex: %d Link-local address: %s%s",
711 on->ifindex, linklocal_addr,
hasso049207c2004-08-04 20:02:13 +0000712 VNL);
hasso508e53e2004-05-18 18:57:06 +0000713 vty_out (vty, " State %s for a duration of %s%s",
714 ospf6_neighbor_state_str[on->state], duration,
hasso049207c2004-08-04 20:02:13 +0000715 VNL);
hasso508e53e2004-05-18 18:57:06 +0000716 vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s",
717 drouter, bdrouter, on->priority,
hasso049207c2004-08-04 20:02:13 +0000718 VNL);
hasso508e53e2004-05-18 18:57:06 +0000719 vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s",
720 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""),
721 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),
722 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ?
723 "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum),
hasso049207c2004-08-04 20:02:13 +0000724 VNL);
paul718e3742002-12-13 20:15:29 +0000725
hasso508e53e2004-05-18 18:57:06 +0000726 vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count,
hasso049207c2004-08-04 20:02:13 +0000727 VNL);
hasso508e53e2004-05-18 18:57:06 +0000728 for (lsa = ospf6_lsdb_head (on->summary_list); lsa;
729 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000730 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000731
hasso508e53e2004-05-18 18:57:06 +0000732 vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count,
hasso049207c2004-08-04 20:02:13 +0000733 VNL);
hasso508e53e2004-05-18 18:57:06 +0000734 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
735 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000736 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000737
738 vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count,
hasso049207c2004-08-04 20:02:13 +0000739 VNL);
hasso508e53e2004-05-18 18:57:06 +0000740 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
741 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000742 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000743
744 timerclear (&res);
745 if (on->thread_send_dbdesc)
746 timersub (&on->thread_send_dbdesc->u.sands, &now, &res);
747 timerstring (&res, duration, sizeof (duration));
748 vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
749 on->dbdesc_list->count, duration,
750 (on->thread_send_dbdesc ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000751 VNL);
hasso508e53e2004-05-18 18:57:06 +0000752 for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa;
753 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000754 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000755
756 timerclear (&res);
757 if (on->thread_send_lsreq)
758 timersub (&on->thread_send_lsreq->u.sands, &now, &res);
759 timerstring (&res, duration, sizeof (duration));
760 vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000761 on->request_list->count, duration,
hasso508e53e2004-05-18 18:57:06 +0000762 (on->thread_send_lsreq ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000763 VNL);
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000764 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
hasso508e53e2004-05-18 18:57:06 +0000765 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000766 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000767
768 timerclear (&res);
769 if (on->thread_send_lsupdate)
770 timersub (&on->thread_send_lsupdate->u.sands, &now, &res);
771 timerstring (&res, duration, sizeof (duration));
772 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
773 on->lsupdate_list->count, duration,
774 (on->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000775 VNL);
hasso508e53e2004-05-18 18:57:06 +0000776 for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa;
777 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000778 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000779
780 timerclear (&res);
781 if (on->thread_send_lsack)
782 timersub (&on->thread_send_lsack->u.sands, &now, &res);
783 timerstring (&res, duration, sizeof (duration));
784 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
785 on->lsack_list->count, duration,
786 (on->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000787 VNL);
hasso508e53e2004-05-18 18:57:06 +0000788 for (lsa = ospf6_lsdb_head (on->lsack_list); lsa;
789 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000790 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000791
paul718e3742002-12-13 20:15:29 +0000792}
793
hasso508e53e2004-05-18 18:57:06 +0000794DEFUN (show_ipv6_ospf6_neighbor,
paul718e3742002-12-13 20:15:29 +0000795 show_ipv6_ospf6_neighbor_cmd,
796 "show ipv6 ospf6 neighbor",
797 SHOW_STR
798 IP6_STR
799 OSPF6_STR
800 "Neighbor list\n"
hasso508e53e2004-05-18 18:57:06 +0000801 )
paul718e3742002-12-13 20:15:29 +0000802{
hasso508e53e2004-05-18 18:57:06 +0000803 struct ospf6_neighbor *on;
804 struct ospf6_interface *oi;
805 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000806 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000807 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
paul718e3742002-12-13 20:15:29 +0000808
809 OSPF6_CMD_CHECK_RUNNING ();
hasso508e53e2004-05-18 18:57:06 +0000810 showfunc = ospf6_neighbor_show;
811
812 if (argc)
813 {
814 if (! strncmp (argv[0], "de", 2))
815 showfunc = ospf6_neighbor_show_detail;
816 else if (! strncmp (argv[0], "dr", 2))
817 showfunc = ospf6_neighbor_show_drchoice;
818 }
819
820 if (showfunc == ospf6_neighbor_show)
821 vty_out (vty, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s",
822 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
hasso049207c2004-08-04 20:02:13 +0000823 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000824 else if (showfunc == ospf6_neighbor_show_drchoice)
825 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
826 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000827 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000828
paul1eb8ef22005-04-07 07:30:20 +0000829 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
830 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
831 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
832 (*showfunc) (vty, on);
833
hasso508e53e2004-05-18 18:57:06 +0000834 return CMD_SUCCESS;
835}
paul718e3742002-12-13 20:15:29 +0000836
hasso508e53e2004-05-18 18:57:06 +0000837ALIAS (show_ipv6_ospf6_neighbor,
838 show_ipv6_ospf6_neighbor_detail_cmd,
839 "show ipv6 ospf6 neighbor (detail|drchoice)",
840 SHOW_STR
841 IP6_STR
842 OSPF6_STR
843 "Neighbor list\n"
844 "Display details\n"
845 "Display DR choices\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100846 )
hasso508e53e2004-05-18 18:57:06 +0000847
848DEFUN (show_ipv6_ospf6_neighbor_one,
849 show_ipv6_ospf6_neighbor_one_cmd,
850 "show ipv6 ospf6 neighbor A.B.C.D",
851 SHOW_STR
852 IP6_STR
853 OSPF6_STR
854 "Neighbor list\n"
855 "Specify Router-ID as IPv4 address notation\n"
856 )
857{
858 struct ospf6_neighbor *on;
859 struct ospf6_interface *oi;
860 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000861 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000862 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
863 u_int32_t router_id;
864
865 OSPF6_CMD_CHECK_RUNNING ();
866 showfunc = ospf6_neighbor_show_detail;
867
868 if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)
869 {
870 vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000871 VNL);
hasso508e53e2004-05-18 18:57:06 +0000872 return CMD_SUCCESS;
873 }
874
paul1eb8ef22005-04-07 07:30:20 +0000875 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
876 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
877 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
878 (*showfunc) (vty, on);
879
paul718e3742002-12-13 20:15:29 +0000880 return CMD_SUCCESS;
881}
882
883void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100884ospf6_neighbor_init (void)
paul718e3742002-12-13 20:15:29 +0000885{
886 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000887 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000888 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000889 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000890}
891
hasso508e53e2004-05-18 18:57:06 +0000892DEFUN (debug_ospf6_neighbor,
893 debug_ospf6_neighbor_cmd,
894 "debug ospf6 neighbor",
895 DEBUG_STR
896 OSPF6_STR
897 "Debug OSPFv3 Neighbor\n"
898 )
899{
900 unsigned char level = 0;
901 if (argc)
902 {
903 if (! strncmp (argv[0], "s", 1))
904 level = OSPF6_DEBUG_NEIGHBOR_STATE;
905 if (! strncmp (argv[0], "e", 1))
906 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
907 }
908 else
909 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
910
911 OSPF6_DEBUG_NEIGHBOR_ON (level);
912 return CMD_SUCCESS;
913}
914
915ALIAS (debug_ospf6_neighbor,
916 debug_ospf6_neighbor_detail_cmd,
917 "debug ospf6 neighbor (state|event)",
918 DEBUG_STR
919 OSPF6_STR
920 "Debug OSPFv3 Neighbor\n"
921 "Debug OSPFv3 Neighbor State Change\n"
922 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100923 )
hasso508e53e2004-05-18 18:57:06 +0000924
925DEFUN (no_debug_ospf6_neighbor,
926 no_debug_ospf6_neighbor_cmd,
927 "no debug ospf6 neighbor",
928 NO_STR
929 DEBUG_STR
930 OSPF6_STR
931 "Debug OSPFv3 Neighbor\n"
932 )
933{
934 unsigned char level = 0;
935 if (argc)
936 {
937 if (! strncmp (argv[0], "s", 1))
938 level = OSPF6_DEBUG_NEIGHBOR_STATE;
939 if (! strncmp (argv[0], "e", 1))
940 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
941 }
942 else
943 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
944
945 OSPF6_DEBUG_NEIGHBOR_OFF (level);
946 return CMD_SUCCESS;
947}
948
949ALIAS (no_debug_ospf6_neighbor,
950 no_debug_ospf6_neighbor_detail_cmd,
951 "no debug ospf6 neighbor (state|event)",
952 NO_STR
953 DEBUG_STR
954 OSPF6_STR
955 "Debug OSPFv3 Neighbor\n"
956 "Debug OSPFv3 Neighbor State Change\n"
957 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100958 )
hasso508e53e2004-05-18 18:57:06 +0000959
960int
961config_write_ospf6_debug_neighbor (struct vty *vty)
962{
963 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) &&
964 IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000965 vty_out (vty, "debug ospf6 neighbor%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000966 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
hasso049207c2004-08-04 20:02:13 +0000967 vty_out (vty, "debug ospf6 neighbor state%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000968 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000969 vty_out (vty, "debug ospf6 neighbor event%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000970 return 0;
971}
972
973void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100974install_element_ospf6_debug_neighbor (void)
hasso508e53e2004-05-18 18:57:06 +0000975{
976 install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);
977 install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);
978 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
979 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);
980 install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);
981 install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);
982 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
983 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);
984}
985
986
paul718e3742002-12-13 20:15:29 +0000987