blob: ab157ca8678a33230c9a0cd0a978f48057f223e5 [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);
101 on->lsreq_list = ospf6_lsdb_create (on);
102 on->lsupdate_list = ospf6_lsdb_create (on);
103 on->lsack_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +0000104
hasso508e53e2004-05-18 18:57:06 +0000105 listnode_add_sort (oi->neighbor_list, on);
106 return on;
paul718e3742002-12-13 20:15:29 +0000107}
108
109void
hasso508e53e2004-05-18 18:57:06 +0000110ospf6_neighbor_delete (struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000111{
hasso3b4cd3a2004-05-18 19:28:32 +0000112 struct ospf6_lsa *lsa;
113
hasso508e53e2004-05-18 18:57:06 +0000114 ospf6_lsdb_remove_all (on->summary_list);
115 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000116 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
117 lsa = ospf6_lsdb_next (lsa))
118 {
hasso6452df02004-08-15 05:52:07 +0000119 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000120 ospf6_lsdb_remove (lsa, on->retrans_list);
121 }
paul718e3742002-12-13 20:15:29 +0000122
hasso508e53e2004-05-18 18:57:06 +0000123 ospf6_lsdb_remove_all (on->dbdesc_list);
124 ospf6_lsdb_remove_all (on->lsreq_list);
125 ospf6_lsdb_remove_all (on->lsupdate_list);
126 ospf6_lsdb_remove_all (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000127
hasso508e53e2004-05-18 18:57:06 +0000128 ospf6_lsdb_delete (on->summary_list);
129 ospf6_lsdb_delete (on->request_list);
130 ospf6_lsdb_delete (on->retrans_list);
paul718e3742002-12-13 20:15:29 +0000131
hasso508e53e2004-05-18 18:57:06 +0000132 ospf6_lsdb_delete (on->dbdesc_list);
133 ospf6_lsdb_delete (on->lsreq_list);
134 ospf6_lsdb_delete (on->lsupdate_list);
135 ospf6_lsdb_delete (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000136
hasso508e53e2004-05-18 18:57:06 +0000137 THREAD_OFF (on->inactivity_timer);
138
139 THREAD_OFF (on->thread_send_dbdesc);
140 THREAD_OFF (on->thread_send_lsreq);
141 THREAD_OFF (on->thread_send_lsupdate);
142 THREAD_OFF (on->thread_send_lsack);
143
144 XFREE (MTYPE_OSPF6_NEIGHBOR, on);
paul718e3742002-12-13 20:15:29 +0000145}
146
hasso508e53e2004-05-18 18:57:06 +0000147static void
148ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000149{
hasso508e53e2004-05-18 18:57:06 +0000150 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000151
hasso508e53e2004-05-18 18:57:06 +0000152 prev_state = on->state;
153 on->state = next_state;
154
155 if (prev_state == next_state)
156 return;
157
Vincent Bernat061bc732012-05-31 20:21:15 +0200158 on->state_change++;
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900159 quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed);
hasso508e53e2004-05-18 18:57:06 +0000160
161 /* log */
162 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
paul718e3742002-12-13 20:15:29 +0000163 {
hassoc6487d62004-12-24 06:00:11 +0000164 zlog_debug ("Neighbor state change %s: [%s]->[%s]", on->name,
165 ospf6_neighbor_state_str[prev_state],
166 ospf6_neighbor_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000167 }
hasso508e53e2004-05-18 18:57:06 +0000168
169 if (prev_state == OSPF6_NEIGHBOR_FULL || next_state == OSPF6_NEIGHBOR_FULL)
170 {
171 OSPF6_ROUTER_LSA_SCHEDULE (on->ospf6_if->area);
172 if (on->ospf6_if->state == OSPF6_INTERFACE_DR)
173 {
174 OSPF6_NETWORK_LSA_SCHEDULE (on->ospf6_if);
175 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on->ospf6_if);
hasso508e53e2004-05-18 18:57:06 +0000176 }
hasso4846ef62004-09-03 06:04:00 +0000177 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on->ospf6_if->area);
hasso508e53e2004-05-18 18:57:06 +0000178 }
179
hasso508e53e2004-05-18 18:57:06 +0000180 if ((prev_state == OSPF6_NEIGHBOR_EXCHANGE ||
181 prev_state == OSPF6_NEIGHBOR_LOADING) &&
182 (next_state != OSPF6_NEIGHBOR_EXCHANGE &&
183 next_state != OSPF6_NEIGHBOR_LOADING))
Paul Jakma932bf192006-05-15 10:42:24 +0000184 ospf6_maxage_remove (on->ospf6_if->area->ospf6);
paul718e3742002-12-13 20:15:29 +0000185}
186
hasso508e53e2004-05-18 18:57:06 +0000187/* RFC2328 section 10.4 */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100188static int
hasso508e53e2004-05-18 18:57:06 +0000189need_adjacency (struct ospf6_neighbor *on)
190{
191 if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT ||
192 on->ospf6_if->state == OSPF6_INTERFACE_DR ||
193 on->ospf6_if->state == OSPF6_INTERFACE_BDR)
194 return 1;
195
196 if (on->ospf6_if->drouter == on->router_id ||
197 on->ospf6_if->bdrouter == on->router_id)
198 return 1;
199
200 return 0;
201}
202
203int
204hello_received (struct thread *thread)
205{
206 struct ospf6_neighbor *on;
207
208 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
209 assert (on);
210
211 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000212 zlog_debug ("Neighbor Event %s: *HelloReceived*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000213
214 /* reset Inactivity Timer */
215 THREAD_OFF (on->inactivity_timer);
216 on->inactivity_timer = thread_add_timer (master, inactivity_timer, on,
217 on->ospf6_if->dead_interval);
218
219 if (on->state <= OSPF6_NEIGHBOR_DOWN)
220 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
221
222 return 0;
223}
224
225int
226twoway_received (struct thread *thread)
227{
228 struct ospf6_neighbor *on;
229
230 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
231 assert (on);
232
233 if (on->state > OSPF6_NEIGHBOR_INIT)
234 return 0;
235
236 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000237 zlog_debug ("Neighbor Event %s: *2Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000238
239 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
240
241 if (! need_adjacency (on))
242 {
243 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
244 return 0;
245 }
246
247 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
248 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
249 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
250 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
251
252 THREAD_OFF (on->thread_send_dbdesc);
253 on->thread_send_dbdesc =
254 thread_add_event (master, ospf6_dbdesc_send, on, 0);
255
256 return 0;
257}
258
259int
260negotiation_done (struct thread *thread)
261{
262 struct ospf6_neighbor *on;
263 struct ospf6_lsa *lsa;
264
265 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
266 assert (on);
267
268 if (on->state != OSPF6_NEIGHBOR_EXSTART)
269 return 0;
270
271 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000272 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000273
274 /* clear ls-list */
275 ospf6_lsdb_remove_all (on->summary_list);
276 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000277 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
278 lsa = ospf6_lsdb_next (lsa))
279 {
hasso6452df02004-08-15 05:52:07 +0000280 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000281 ospf6_lsdb_remove (lsa, on->retrans_list);
282 }
hasso508e53e2004-05-18 18:57:06 +0000283
284 /* Interface scoped LSAs */
285 for (lsa = ospf6_lsdb_head (on->ospf6_if->lsdb); lsa;
286 lsa = ospf6_lsdb_next (lsa))
287 {
hasso508e53e2004-05-18 18:57:06 +0000288 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000289 {
hasso6452df02004-08-15 05:52:07 +0000290 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000291 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
292 }
hasso508e53e2004-05-18 18:57:06 +0000293 else
294 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
295 }
296
297 /* Area scoped LSAs */
298 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->lsdb); lsa;
299 lsa = ospf6_lsdb_next (lsa))
300 {
hasso508e53e2004-05-18 18:57:06 +0000301 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000302 {
hasso6452df02004-08-15 05:52:07 +0000303 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000304 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
305 }
hasso508e53e2004-05-18 18:57:06 +0000306 else
307 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
308 }
309
310 /* AS scoped LSAs */
311 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->ospf6->lsdb); lsa;
312 lsa = ospf6_lsdb_next (lsa))
313 {
hasso508e53e2004-05-18 18:57:06 +0000314 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000315 {
hasso6452df02004-08-15 05:52:07 +0000316 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000317 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
318 }
hasso508e53e2004-05-18 18:57:06 +0000319 else
320 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
321 }
322
323 UNSET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
324 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE, on);
325
326 return 0;
327}
328
329int
330exchange_done (struct thread *thread)
331{
332 struct ospf6_neighbor *on;
333
334 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
335 assert (on);
336
337 if (on->state != OSPF6_NEIGHBOR_EXCHANGE)
338 return 0;
339
340 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000341 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000342
343 THREAD_OFF (on->thread_send_dbdesc);
344 ospf6_lsdb_remove_all (on->dbdesc_list);
345
346/* XXX
347 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
348 on->ospf6_if->dead_interval);
349*/
350
351 if (on->request_list->count == 0)
352 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
353 else
354 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on);
355
356 return 0;
357}
358
359int
360loading_done (struct thread *thread)
361{
362 struct ospf6_neighbor *on;
363
364 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
365 assert (on);
366
367 if (on->state != OSPF6_NEIGHBOR_LOADING)
368 return 0;
369
370 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000371 zlog_debug ("Neighbor Event %s: *LoadingDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000372
373 assert (on->request_list->count == 0);
374
375 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
376
377 return 0;
378}
379
380int
381adj_ok (struct thread *thread)
382{
383 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000384 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000385
386 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
387 assert (on);
388
389 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000390 zlog_debug ("Neighbor Event %s: *AdjOK?*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000391
392 if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency (on))
393 {
394 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
395 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
396 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
397 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
398
399 THREAD_OFF (on->thread_send_dbdesc);
400 on->thread_send_dbdesc =
401 thread_add_event (master, ospf6_dbdesc_send, on, 0);
402
403 }
404 else if (on->state >= OSPF6_NEIGHBOR_EXSTART &&
405 ! need_adjacency (on))
406 {
407 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
408 ospf6_lsdb_remove_all (on->summary_list);
409 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000410 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
411 lsa = ospf6_lsdb_next (lsa))
412 {
hasso6452df02004-08-15 05:52:07 +0000413 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000414 ospf6_lsdb_remove (lsa, on->retrans_list);
415 }
hasso508e53e2004-05-18 18:57:06 +0000416 }
417
418 return 0;
419}
420
421int
422seqnumber_mismatch (struct thread *thread)
423{
424 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000425 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000426
427 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
428 assert (on);
429
430 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
431 return 0;
432
433 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000434 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000435
436 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
437 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
438 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
439 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
440
441 ospf6_lsdb_remove_all (on->summary_list);
442 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000443 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
444 lsa = ospf6_lsdb_next (lsa))
445 {
hasso6452df02004-08-15 05:52:07 +0000446 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000447 ospf6_lsdb_remove (lsa, on->retrans_list);
448 }
hasso508e53e2004-05-18 18:57:06 +0000449
450 THREAD_OFF (on->thread_send_dbdesc);
451 on->thread_send_dbdesc =
452 thread_add_event (master, ospf6_dbdesc_send, on, 0);
453
454 return 0;
455}
456
457int
458bad_lsreq (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: *BadLSReq*", 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
494oneway_received (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_TWOWAY)
503 return 0;
504
505 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000506 zlog_debug ("Neighbor Event %s: *1Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000507
508 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
509 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
510
511 ospf6_lsdb_remove_all (on->summary_list);
512 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000513 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
514 lsa = ospf6_lsdb_next (lsa))
515 {
hasso6452df02004-08-15 05:52:07 +0000516 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000517 ospf6_lsdb_remove (lsa, on->retrans_list);
518 }
hasso508e53e2004-05-18 18:57:06 +0000519
520 THREAD_OFF (on->thread_send_dbdesc);
521 THREAD_OFF (on->thread_send_lsreq);
522 THREAD_OFF (on->thread_send_lsupdate);
523 THREAD_OFF (on->thread_send_lsack);
524
525 return 0;
526}
527
528int
529inactivity_timer (struct thread *thread)
530{
531 struct ospf6_neighbor *on;
532
533 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
534 assert (on);
535
536 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000537 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000538
539 on->inactivity_timer = NULL;
540 on->drouter = on->prev_drouter = 0;
541 on->bdrouter = on->prev_bdrouter = 0;
542
543 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on);
544 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
545
546 listnode_delete (on->ospf6_if->neighbor_list, on);
547 ospf6_neighbor_delete (on);
548
549 return 0;
550}
551
552
paul718e3742002-12-13 20:15:29 +0000553
554/* vty functions */
555/* show neighbor structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100556static void
hasso508e53e2004-05-18 18:57:06 +0000557ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000558{
559 char router_id[16];
hasso508e53e2004-05-18 18:57:06 +0000560 char duration[16];
561 struct timeval now, res;
562 char nstate[16];
563 char deadtime[16];
564 long h, m, s;
565
566 /* Router-ID (Name) */
567 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
568#ifdef HAVE_GETNAMEINFO
569 {
570 }
571#endif /*HAVE_GETNAMEINFO*/
572
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900573 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000574
575 /* Dead time */
576 h = m = s = 0;
577 if (on->inactivity_timer)
578 {
Paul Jakmac136d242007-03-08 17:50:01 +0000579 s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec;
hasso508e53e2004-05-18 18:57:06 +0000580 h = s / 3600;
581 s -= h * 3600;
582 m = s / 60;
583 s -= m * 60;
584 }
585 snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s);
586
587 /* Neighbor State */
588 if (if_is_pointopoint (on->ospf6_if->interface))
589 snprintf (nstate, sizeof (nstate), "PointToPoint");
590 else
591 {
592 if (on->router_id == on->drouter)
593 snprintf (nstate, sizeof (nstate), "DR");
594 else if (on->router_id == on->bdrouter)
595 snprintf (nstate, sizeof (nstate), "BDR");
596 else
597 snprintf (nstate, sizeof (nstate), "DROther");
598 }
599
600 /* Duration */
601 timersub (&now, &on->last_changed, &res);
602 timerstring (&res, duration, sizeof (duration));
603
604 /*
605 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
606 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
hasso049207c2004-08-04 20:02:13 +0000607 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000608 */
609
610 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
611 router_id, on->priority, deadtime,
612 ospf6_neighbor_state_str[on->state], nstate, duration,
613 on->ospf6_if->interface->name,
hasso049207c2004-08-04 20:02:13 +0000614 ospf6_interface_state_str[on->ospf6_if->state], VNL);
hasso508e53e2004-05-18 18:57:06 +0000615}
616
Paul Jakma6ac29a52008-08-15 13:45:30 +0100617static void
hasso508e53e2004-05-18 18:57:06 +0000618ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on)
619{
620 char router_id[16];
621 char drouter[16], bdrouter[16];
paul718e3742002-12-13 20:15:29 +0000622 char duration[16];
623 struct timeval now, res;
624
625/*
626 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
627 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000628 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000629*/
630
hasso508e53e2004-05-18 18:57:06 +0000631 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
632 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
633 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000634
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900635 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000636 timersub (&now, &on->last_changed, &res);
637 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000638
639 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
hasso508e53e2004-05-18 18:57:06 +0000640 router_id, ospf6_neighbor_state_str[on->state],
641 duration, drouter, bdrouter, on->ospf6_if->interface->name,
642 ospf6_interface_state_str[on->ospf6_if->state],
hasso049207c2004-08-04 20:02:13 +0000643 VNL);
paul718e3742002-12-13 20:15:29 +0000644}
645
Paul Jakma6ac29a52008-08-15 13:45:30 +0100646static void
hasso508e53e2004-05-18 18:57:06 +0000647ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000648{
hasso508e53e2004-05-18 18:57:06 +0000649 char drouter[16], bdrouter[16];
650 char linklocal_addr[64], duration[32];
paul718e3742002-12-13 20:15:29 +0000651 struct timeval now, res;
hasso508e53e2004-05-18 18:57:06 +0000652 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000653
hasso508e53e2004-05-18 18:57:06 +0000654 inet_ntop (AF_INET6, &on->linklocal_addr, linklocal_addr,
655 sizeof (linklocal_addr));
656 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
657 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000658
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900659 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000660 timersub (&now, &on->last_changed, &res);
661 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000662
hasso508e53e2004-05-18 18:57:06 +0000663 vty_out (vty, " Neighbor %s%s", on->name,
hasso049207c2004-08-04 20:02:13 +0000664 VNL);
hasso508e53e2004-05-18 18:57:06 +0000665 vty_out (vty, " Area %s via interface %s (ifindex %d)%s",
666 on->ospf6_if->area->name,
667 on->ospf6_if->interface->name,
668 on->ospf6_if->interface->ifindex,
hasso049207c2004-08-04 20:02:13 +0000669 VNL);
hasso508e53e2004-05-18 18:57:06 +0000670 vty_out (vty, " His IfIndex: %d Link-local address: %s%s",
671 on->ifindex, linklocal_addr,
hasso049207c2004-08-04 20:02:13 +0000672 VNL);
hasso508e53e2004-05-18 18:57:06 +0000673 vty_out (vty, " State %s for a duration of %s%s",
674 ospf6_neighbor_state_str[on->state], duration,
hasso049207c2004-08-04 20:02:13 +0000675 VNL);
hasso508e53e2004-05-18 18:57:06 +0000676 vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s",
677 drouter, bdrouter, on->priority,
hasso049207c2004-08-04 20:02:13 +0000678 VNL);
hasso508e53e2004-05-18 18:57:06 +0000679 vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s",
680 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""),
681 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),
682 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ?
683 "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum),
hasso049207c2004-08-04 20:02:13 +0000684 VNL);
paul718e3742002-12-13 20:15:29 +0000685
hasso508e53e2004-05-18 18:57:06 +0000686 vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count,
hasso049207c2004-08-04 20:02:13 +0000687 VNL);
hasso508e53e2004-05-18 18:57:06 +0000688 for (lsa = ospf6_lsdb_head (on->summary_list); lsa;
689 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000690 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000691
hasso508e53e2004-05-18 18:57:06 +0000692 vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count,
hasso049207c2004-08-04 20:02:13 +0000693 VNL);
hasso508e53e2004-05-18 18:57:06 +0000694 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
695 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000696 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000697
698 vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count,
hasso049207c2004-08-04 20:02:13 +0000699 VNL);
hasso508e53e2004-05-18 18:57:06 +0000700 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
701 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000702 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000703
704 timerclear (&res);
705 if (on->thread_send_dbdesc)
706 timersub (&on->thread_send_dbdesc->u.sands, &now, &res);
707 timerstring (&res, duration, sizeof (duration));
708 vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
709 on->dbdesc_list->count, duration,
710 (on->thread_send_dbdesc ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000711 VNL);
hasso508e53e2004-05-18 18:57:06 +0000712 for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa;
713 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000714 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000715
716 timerclear (&res);
717 if (on->thread_send_lsreq)
718 timersub (&on->thread_send_lsreq->u.sands, &now, &res);
719 timerstring (&res, duration, sizeof (duration));
720 vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
721 on->lsreq_list->count, duration,
722 (on->thread_send_lsreq ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000723 VNL);
hasso508e53e2004-05-18 18:57:06 +0000724 for (lsa = ospf6_lsdb_head (on->lsreq_list); lsa;
725 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000726 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000727
728 timerclear (&res);
729 if (on->thread_send_lsupdate)
730 timersub (&on->thread_send_lsupdate->u.sands, &now, &res);
731 timerstring (&res, duration, sizeof (duration));
732 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
733 on->lsupdate_list->count, duration,
734 (on->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000735 VNL);
hasso508e53e2004-05-18 18:57:06 +0000736 for (lsa = ospf6_lsdb_head (on->lsupdate_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_lsack)
742 timersub (&on->thread_send_lsack->u.sands, &now, &res);
743 timerstring (&res, duration, sizeof (duration));
744 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
745 on->lsack_list->count, duration,
746 (on->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000747 VNL);
hasso508e53e2004-05-18 18:57:06 +0000748 for (lsa = ospf6_lsdb_head (on->lsack_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
paul718e3742002-12-13 20:15:29 +0000752}
753
hasso508e53e2004-05-18 18:57:06 +0000754DEFUN (show_ipv6_ospf6_neighbor,
paul718e3742002-12-13 20:15:29 +0000755 show_ipv6_ospf6_neighbor_cmd,
756 "show ipv6 ospf6 neighbor",
757 SHOW_STR
758 IP6_STR
759 OSPF6_STR
760 "Neighbor list\n"
hasso508e53e2004-05-18 18:57:06 +0000761 )
paul718e3742002-12-13 20:15:29 +0000762{
hasso508e53e2004-05-18 18:57:06 +0000763 struct ospf6_neighbor *on;
764 struct ospf6_interface *oi;
765 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000766 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000767 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
paul718e3742002-12-13 20:15:29 +0000768
769 OSPF6_CMD_CHECK_RUNNING ();
hasso508e53e2004-05-18 18:57:06 +0000770 showfunc = ospf6_neighbor_show;
771
772 if (argc)
773 {
774 if (! strncmp (argv[0], "de", 2))
775 showfunc = ospf6_neighbor_show_detail;
776 else if (! strncmp (argv[0], "dr", 2))
777 showfunc = ospf6_neighbor_show_drchoice;
778 }
779
780 if (showfunc == ospf6_neighbor_show)
781 vty_out (vty, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s",
782 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
hasso049207c2004-08-04 20:02:13 +0000783 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000784 else if (showfunc == ospf6_neighbor_show_drchoice)
785 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
786 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000787 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000788
paul1eb8ef22005-04-07 07:30:20 +0000789 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
790 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
791 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
792 (*showfunc) (vty, on);
793
hasso508e53e2004-05-18 18:57:06 +0000794 return CMD_SUCCESS;
795}
paul718e3742002-12-13 20:15:29 +0000796
hasso508e53e2004-05-18 18:57:06 +0000797ALIAS (show_ipv6_ospf6_neighbor,
798 show_ipv6_ospf6_neighbor_detail_cmd,
799 "show ipv6 ospf6 neighbor (detail|drchoice)",
800 SHOW_STR
801 IP6_STR
802 OSPF6_STR
803 "Neighbor list\n"
804 "Display details\n"
805 "Display DR choices\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100806 )
hasso508e53e2004-05-18 18:57:06 +0000807
808DEFUN (show_ipv6_ospf6_neighbor_one,
809 show_ipv6_ospf6_neighbor_one_cmd,
810 "show ipv6 ospf6 neighbor A.B.C.D",
811 SHOW_STR
812 IP6_STR
813 OSPF6_STR
814 "Neighbor list\n"
815 "Specify Router-ID as IPv4 address notation\n"
816 )
817{
818 struct ospf6_neighbor *on;
819 struct ospf6_interface *oi;
820 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000821 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000822 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
823 u_int32_t router_id;
824
825 OSPF6_CMD_CHECK_RUNNING ();
826 showfunc = ospf6_neighbor_show_detail;
827
828 if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)
829 {
830 vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000831 VNL);
hasso508e53e2004-05-18 18:57:06 +0000832 return CMD_SUCCESS;
833 }
834
paul1eb8ef22005-04-07 07:30:20 +0000835 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
836 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
837 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
838 (*showfunc) (vty, on);
839
paul718e3742002-12-13 20:15:29 +0000840 return CMD_SUCCESS;
841}
842
843void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100844ospf6_neighbor_init (void)
paul718e3742002-12-13 20:15:29 +0000845{
846 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000847 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000848 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000849 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000850}
851
hasso508e53e2004-05-18 18:57:06 +0000852DEFUN (debug_ospf6_neighbor,
853 debug_ospf6_neighbor_cmd,
854 "debug ospf6 neighbor",
855 DEBUG_STR
856 OSPF6_STR
857 "Debug OSPFv3 Neighbor\n"
858 )
859{
860 unsigned char level = 0;
861 if (argc)
862 {
863 if (! strncmp (argv[0], "s", 1))
864 level = OSPF6_DEBUG_NEIGHBOR_STATE;
865 if (! strncmp (argv[0], "e", 1))
866 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
867 }
868 else
869 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
870
871 OSPF6_DEBUG_NEIGHBOR_ON (level);
872 return CMD_SUCCESS;
873}
874
875ALIAS (debug_ospf6_neighbor,
876 debug_ospf6_neighbor_detail_cmd,
877 "debug ospf6 neighbor (state|event)",
878 DEBUG_STR
879 OSPF6_STR
880 "Debug OSPFv3 Neighbor\n"
881 "Debug OSPFv3 Neighbor State Change\n"
882 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100883 )
hasso508e53e2004-05-18 18:57:06 +0000884
885DEFUN (no_debug_ospf6_neighbor,
886 no_debug_ospf6_neighbor_cmd,
887 "no debug ospf6 neighbor",
888 NO_STR
889 DEBUG_STR
890 OSPF6_STR
891 "Debug OSPFv3 Neighbor\n"
892 )
893{
894 unsigned char level = 0;
895 if (argc)
896 {
897 if (! strncmp (argv[0], "s", 1))
898 level = OSPF6_DEBUG_NEIGHBOR_STATE;
899 if (! strncmp (argv[0], "e", 1))
900 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
901 }
902 else
903 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
904
905 OSPF6_DEBUG_NEIGHBOR_OFF (level);
906 return CMD_SUCCESS;
907}
908
909ALIAS (no_debug_ospf6_neighbor,
910 no_debug_ospf6_neighbor_detail_cmd,
911 "no debug ospf6 neighbor (state|event)",
912 NO_STR
913 DEBUG_STR
914 OSPF6_STR
915 "Debug OSPFv3 Neighbor\n"
916 "Debug OSPFv3 Neighbor State Change\n"
917 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100918 )
hasso508e53e2004-05-18 18:57:06 +0000919
920int
921config_write_ospf6_debug_neighbor (struct vty *vty)
922{
923 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) &&
924 IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000925 vty_out (vty, "debug ospf6 neighbor%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000926 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
hasso049207c2004-08-04 20:02:13 +0000927 vty_out (vty, "debug ospf6 neighbor state%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000928 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000929 vty_out (vty, "debug ospf6 neighbor event%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000930 return 0;
931}
932
933void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100934install_element_ospf6_debug_neighbor (void)
hasso508e53e2004-05-18 18:57:06 +0000935{
936 install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);
937 install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);
938 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
939 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);
940 install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);
941 install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);
942 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
943 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);
944}
945
946
paul718e3742002-12-13 20:15:29 +0000947