blob: 806767dd56e97e9d2efbe20777722b806c9dcec1 [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);
Vincent Bernatbf836662012-06-04 14:36:12 +0200185
186#ifdef HAVE_SNMP
187 /* Terminal state or regression */
188 if ((next_state == OSPF6_NEIGHBOR_FULL) ||
189 (next_state == OSPF6_NEIGHBOR_TWOWAY) ||
190 (next_state < prev_state))
191 ospf6TrapNbrStateChange (on);
192#endif
193
paul718e3742002-12-13 20:15:29 +0000194}
195
hasso508e53e2004-05-18 18:57:06 +0000196/* RFC2328 section 10.4 */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100197static int
hasso508e53e2004-05-18 18:57:06 +0000198need_adjacency (struct ospf6_neighbor *on)
199{
200 if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT ||
201 on->ospf6_if->state == OSPF6_INTERFACE_DR ||
202 on->ospf6_if->state == OSPF6_INTERFACE_BDR)
203 return 1;
204
205 if (on->ospf6_if->drouter == on->router_id ||
206 on->ospf6_if->bdrouter == on->router_id)
207 return 1;
208
209 return 0;
210}
211
212int
213hello_received (struct thread *thread)
214{
215 struct ospf6_neighbor *on;
216
217 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
218 assert (on);
219
220 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000221 zlog_debug ("Neighbor Event %s: *HelloReceived*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000222
223 /* reset Inactivity Timer */
224 THREAD_OFF (on->inactivity_timer);
225 on->inactivity_timer = thread_add_timer (master, inactivity_timer, on,
226 on->ospf6_if->dead_interval);
227
228 if (on->state <= OSPF6_NEIGHBOR_DOWN)
229 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
230
231 return 0;
232}
233
234int
235twoway_received (struct thread *thread)
236{
237 struct ospf6_neighbor *on;
238
239 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
240 assert (on);
241
242 if (on->state > OSPF6_NEIGHBOR_INIT)
243 return 0;
244
245 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000246 zlog_debug ("Neighbor Event %s: *2Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000247
248 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
249
250 if (! need_adjacency (on))
251 {
252 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
253 return 0;
254 }
255
256 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
257 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
258 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
259 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
260
261 THREAD_OFF (on->thread_send_dbdesc);
262 on->thread_send_dbdesc =
263 thread_add_event (master, ospf6_dbdesc_send, on, 0);
264
265 return 0;
266}
267
268int
269negotiation_done (struct thread *thread)
270{
271 struct ospf6_neighbor *on;
272 struct ospf6_lsa *lsa;
273
274 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
275 assert (on);
276
277 if (on->state != OSPF6_NEIGHBOR_EXSTART)
278 return 0;
279
280 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000281 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000282
283 /* clear ls-list */
284 ospf6_lsdb_remove_all (on->summary_list);
285 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000286 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
287 lsa = ospf6_lsdb_next (lsa))
288 {
hasso6452df02004-08-15 05:52:07 +0000289 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000290 ospf6_lsdb_remove (lsa, on->retrans_list);
291 }
hasso508e53e2004-05-18 18:57:06 +0000292
293 /* Interface scoped LSAs */
294 for (lsa = ospf6_lsdb_head (on->ospf6_if->lsdb); lsa;
295 lsa = ospf6_lsdb_next (lsa))
296 {
hasso508e53e2004-05-18 18:57:06 +0000297 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000298 {
hasso6452df02004-08-15 05:52:07 +0000299 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000300 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
301 }
hasso508e53e2004-05-18 18:57:06 +0000302 else
303 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
304 }
305
306 /* Area scoped LSAs */
307 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->lsdb); lsa;
308 lsa = ospf6_lsdb_next (lsa))
309 {
hasso508e53e2004-05-18 18:57:06 +0000310 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000311 {
hasso6452df02004-08-15 05:52:07 +0000312 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000313 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
314 }
hasso508e53e2004-05-18 18:57:06 +0000315 else
316 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
317 }
318
319 /* AS scoped LSAs */
320 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->ospf6->lsdb); lsa;
321 lsa = ospf6_lsdb_next (lsa))
322 {
hasso508e53e2004-05-18 18:57:06 +0000323 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000324 {
hasso6452df02004-08-15 05:52:07 +0000325 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000326 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
327 }
hasso508e53e2004-05-18 18:57:06 +0000328 else
329 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
330 }
331
332 UNSET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
333 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE, on);
334
335 return 0;
336}
337
338int
339exchange_done (struct thread *thread)
340{
341 struct ospf6_neighbor *on;
342
343 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
344 assert (on);
345
346 if (on->state != OSPF6_NEIGHBOR_EXCHANGE)
347 return 0;
348
349 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000350 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000351
352 THREAD_OFF (on->thread_send_dbdesc);
353 ospf6_lsdb_remove_all (on->dbdesc_list);
354
355/* XXX
356 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
357 on->ospf6_if->dead_interval);
358*/
359
360 if (on->request_list->count == 0)
361 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
362 else
363 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on);
364
365 return 0;
366}
367
368int
369loading_done (struct thread *thread)
370{
371 struct ospf6_neighbor *on;
372
373 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
374 assert (on);
375
376 if (on->state != OSPF6_NEIGHBOR_LOADING)
377 return 0;
378
379 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000380 zlog_debug ("Neighbor Event %s: *LoadingDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000381
382 assert (on->request_list->count == 0);
383
384 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
385
386 return 0;
387}
388
389int
390adj_ok (struct thread *thread)
391{
392 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000393 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000394
395 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
396 assert (on);
397
398 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000399 zlog_debug ("Neighbor Event %s: *AdjOK?*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000400
401 if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency (on))
402 {
403 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
404 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
405 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
406 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
407
408 THREAD_OFF (on->thread_send_dbdesc);
409 on->thread_send_dbdesc =
410 thread_add_event (master, ospf6_dbdesc_send, on, 0);
411
412 }
413 else if (on->state >= OSPF6_NEIGHBOR_EXSTART &&
414 ! need_adjacency (on))
415 {
416 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
417 ospf6_lsdb_remove_all (on->summary_list);
418 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000419 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
420 lsa = ospf6_lsdb_next (lsa))
421 {
hasso6452df02004-08-15 05:52:07 +0000422 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000423 ospf6_lsdb_remove (lsa, on->retrans_list);
424 }
hasso508e53e2004-05-18 18:57:06 +0000425 }
426
427 return 0;
428}
429
430int
431seqnumber_mismatch (struct thread *thread)
432{
433 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000434 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000435
436 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
437 assert (on);
438
439 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
440 return 0;
441
442 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000443 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000444
445 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
446 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
447 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
448 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
449
450 ospf6_lsdb_remove_all (on->summary_list);
451 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000452 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
453 lsa = ospf6_lsdb_next (lsa))
454 {
hasso6452df02004-08-15 05:52:07 +0000455 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000456 ospf6_lsdb_remove (lsa, on->retrans_list);
457 }
hasso508e53e2004-05-18 18:57:06 +0000458
459 THREAD_OFF (on->thread_send_dbdesc);
460 on->thread_send_dbdesc =
461 thread_add_event (master, ospf6_dbdesc_send, on, 0);
462
463 return 0;
464}
465
466int
467bad_lsreq (struct thread *thread)
468{
469 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000470 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000471
472 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
473 assert (on);
474
475 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
476 return 0;
477
478 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000479 zlog_debug ("Neighbor Event %s: *BadLSReq*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000480
481 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
482 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
483 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
484 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
485
486 ospf6_lsdb_remove_all (on->summary_list);
487 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000488 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
489 lsa = ospf6_lsdb_next (lsa))
490 {
hasso6452df02004-08-15 05:52:07 +0000491 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000492 ospf6_lsdb_remove (lsa, on->retrans_list);
493 }
hasso508e53e2004-05-18 18:57:06 +0000494
495 THREAD_OFF (on->thread_send_dbdesc);
496 on->thread_send_dbdesc =
497 thread_add_event (master, ospf6_dbdesc_send, on, 0);
498
499 return 0;
500}
501
502int
503oneway_received (struct thread *thread)
504{
505 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000506 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000507
508 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
509 assert (on);
510
511 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
512 return 0;
513
514 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000515 zlog_debug ("Neighbor Event %s: *1Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000516
517 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
518 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
519
520 ospf6_lsdb_remove_all (on->summary_list);
521 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000522 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
523 lsa = ospf6_lsdb_next (lsa))
524 {
hasso6452df02004-08-15 05:52:07 +0000525 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000526 ospf6_lsdb_remove (lsa, on->retrans_list);
527 }
hasso508e53e2004-05-18 18:57:06 +0000528
529 THREAD_OFF (on->thread_send_dbdesc);
530 THREAD_OFF (on->thread_send_lsreq);
531 THREAD_OFF (on->thread_send_lsupdate);
532 THREAD_OFF (on->thread_send_lsack);
533
534 return 0;
535}
536
537int
538inactivity_timer (struct thread *thread)
539{
540 struct ospf6_neighbor *on;
541
542 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
543 assert (on);
544
545 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000546 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000547
548 on->inactivity_timer = NULL;
549 on->drouter = on->prev_drouter = 0;
550 on->bdrouter = on->prev_bdrouter = 0;
551
552 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on);
553 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
554
555 listnode_delete (on->ospf6_if->neighbor_list, on);
556 ospf6_neighbor_delete (on);
557
558 return 0;
559}
560
561
paul718e3742002-12-13 20:15:29 +0000562
563/* vty functions */
564/* show neighbor structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100565static void
hasso508e53e2004-05-18 18:57:06 +0000566ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000567{
568 char router_id[16];
hasso508e53e2004-05-18 18:57:06 +0000569 char duration[16];
570 struct timeval now, res;
571 char nstate[16];
572 char deadtime[16];
573 long h, m, s;
574
575 /* Router-ID (Name) */
576 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
577#ifdef HAVE_GETNAMEINFO
578 {
579 }
580#endif /*HAVE_GETNAMEINFO*/
581
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900582 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000583
584 /* Dead time */
585 h = m = s = 0;
586 if (on->inactivity_timer)
587 {
Paul Jakmac136d242007-03-08 17:50:01 +0000588 s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec;
hasso508e53e2004-05-18 18:57:06 +0000589 h = s / 3600;
590 s -= h * 3600;
591 m = s / 60;
592 s -= m * 60;
593 }
594 snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s);
595
596 /* Neighbor State */
597 if (if_is_pointopoint (on->ospf6_if->interface))
598 snprintf (nstate, sizeof (nstate), "PointToPoint");
599 else
600 {
601 if (on->router_id == on->drouter)
602 snprintf (nstate, sizeof (nstate), "DR");
603 else if (on->router_id == on->bdrouter)
604 snprintf (nstate, sizeof (nstate), "BDR");
605 else
606 snprintf (nstate, sizeof (nstate), "DROther");
607 }
608
609 /* Duration */
610 timersub (&now, &on->last_changed, &res);
611 timerstring (&res, duration, sizeof (duration));
612
613 /*
614 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
615 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
hasso049207c2004-08-04 20:02:13 +0000616 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000617 */
618
619 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
620 router_id, on->priority, deadtime,
621 ospf6_neighbor_state_str[on->state], nstate, duration,
622 on->ospf6_if->interface->name,
hasso049207c2004-08-04 20:02:13 +0000623 ospf6_interface_state_str[on->ospf6_if->state], VNL);
hasso508e53e2004-05-18 18:57:06 +0000624}
625
Paul Jakma6ac29a52008-08-15 13:45:30 +0100626static void
hasso508e53e2004-05-18 18:57:06 +0000627ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on)
628{
629 char router_id[16];
630 char drouter[16], bdrouter[16];
paul718e3742002-12-13 20:15:29 +0000631 char duration[16];
632 struct timeval now, res;
633
634/*
635 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
636 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000637 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000638*/
639
hasso508e53e2004-05-18 18:57:06 +0000640 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
641 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
642 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000643
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900644 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000645 timersub (&now, &on->last_changed, &res);
646 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000647
648 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
hasso508e53e2004-05-18 18:57:06 +0000649 router_id, ospf6_neighbor_state_str[on->state],
650 duration, drouter, bdrouter, on->ospf6_if->interface->name,
651 ospf6_interface_state_str[on->ospf6_if->state],
hasso049207c2004-08-04 20:02:13 +0000652 VNL);
paul718e3742002-12-13 20:15:29 +0000653}
654
Paul Jakma6ac29a52008-08-15 13:45:30 +0100655static void
hasso508e53e2004-05-18 18:57:06 +0000656ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000657{
hasso508e53e2004-05-18 18:57:06 +0000658 char drouter[16], bdrouter[16];
659 char linklocal_addr[64], duration[32];
paul718e3742002-12-13 20:15:29 +0000660 struct timeval now, res;
hasso508e53e2004-05-18 18:57:06 +0000661 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000662
hasso508e53e2004-05-18 18:57:06 +0000663 inet_ntop (AF_INET6, &on->linklocal_addr, linklocal_addr,
664 sizeof (linklocal_addr));
665 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
666 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000667
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900668 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000669 timersub (&now, &on->last_changed, &res);
670 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000671
hasso508e53e2004-05-18 18:57:06 +0000672 vty_out (vty, " Neighbor %s%s", on->name,
hasso049207c2004-08-04 20:02:13 +0000673 VNL);
hasso508e53e2004-05-18 18:57:06 +0000674 vty_out (vty, " Area %s via interface %s (ifindex %d)%s",
675 on->ospf6_if->area->name,
676 on->ospf6_if->interface->name,
677 on->ospf6_if->interface->ifindex,
hasso049207c2004-08-04 20:02:13 +0000678 VNL);
hasso508e53e2004-05-18 18:57:06 +0000679 vty_out (vty, " His IfIndex: %d Link-local address: %s%s",
680 on->ifindex, linklocal_addr,
hasso049207c2004-08-04 20:02:13 +0000681 VNL);
hasso508e53e2004-05-18 18:57:06 +0000682 vty_out (vty, " State %s for a duration of %s%s",
683 ospf6_neighbor_state_str[on->state], duration,
hasso049207c2004-08-04 20:02:13 +0000684 VNL);
hasso508e53e2004-05-18 18:57:06 +0000685 vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s",
686 drouter, bdrouter, on->priority,
hasso049207c2004-08-04 20:02:13 +0000687 VNL);
hasso508e53e2004-05-18 18:57:06 +0000688 vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s",
689 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""),
690 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),
691 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ?
692 "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum),
hasso049207c2004-08-04 20:02:13 +0000693 VNL);
paul718e3742002-12-13 20:15:29 +0000694
hasso508e53e2004-05-18 18:57:06 +0000695 vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count,
hasso049207c2004-08-04 20:02:13 +0000696 VNL);
hasso508e53e2004-05-18 18:57:06 +0000697 for (lsa = ospf6_lsdb_head (on->summary_list); lsa;
698 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000699 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000700
hasso508e53e2004-05-18 18:57:06 +0000701 vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count,
hasso049207c2004-08-04 20:02:13 +0000702 VNL);
hasso508e53e2004-05-18 18:57:06 +0000703 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
704 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000705 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000706
707 vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count,
hasso049207c2004-08-04 20:02:13 +0000708 VNL);
hasso508e53e2004-05-18 18:57:06 +0000709 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
710 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000711 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000712
713 timerclear (&res);
714 if (on->thread_send_dbdesc)
715 timersub (&on->thread_send_dbdesc->u.sands, &now, &res);
716 timerstring (&res, duration, sizeof (duration));
717 vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
718 on->dbdesc_list->count, duration,
719 (on->thread_send_dbdesc ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000720 VNL);
hasso508e53e2004-05-18 18:57:06 +0000721 for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa;
722 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000723 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000724
725 timerclear (&res);
726 if (on->thread_send_lsreq)
727 timersub (&on->thread_send_lsreq->u.sands, &now, &res);
728 timerstring (&res, duration, sizeof (duration));
729 vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
730 on->lsreq_list->count, duration,
731 (on->thread_send_lsreq ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000732 VNL);
hasso508e53e2004-05-18 18:57:06 +0000733 for (lsa = ospf6_lsdb_head (on->lsreq_list); lsa;
734 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000735 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000736
737 timerclear (&res);
738 if (on->thread_send_lsupdate)
739 timersub (&on->thread_send_lsupdate->u.sands, &now, &res);
740 timerstring (&res, duration, sizeof (duration));
741 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
742 on->lsupdate_list->count, duration,
743 (on->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000744 VNL);
hasso508e53e2004-05-18 18:57:06 +0000745 for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa;
746 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000747 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000748
749 timerclear (&res);
750 if (on->thread_send_lsack)
751 timersub (&on->thread_send_lsack->u.sands, &now, &res);
752 timerstring (&res, duration, sizeof (duration));
753 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
754 on->lsack_list->count, duration,
755 (on->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000756 VNL);
hasso508e53e2004-05-18 18:57:06 +0000757 for (lsa = ospf6_lsdb_head (on->lsack_list); lsa;
758 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000759 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000760
paul718e3742002-12-13 20:15:29 +0000761}
762
hasso508e53e2004-05-18 18:57:06 +0000763DEFUN (show_ipv6_ospf6_neighbor,
paul718e3742002-12-13 20:15:29 +0000764 show_ipv6_ospf6_neighbor_cmd,
765 "show ipv6 ospf6 neighbor",
766 SHOW_STR
767 IP6_STR
768 OSPF6_STR
769 "Neighbor list\n"
hasso508e53e2004-05-18 18:57:06 +0000770 )
paul718e3742002-12-13 20:15:29 +0000771{
hasso508e53e2004-05-18 18:57:06 +0000772 struct ospf6_neighbor *on;
773 struct ospf6_interface *oi;
774 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000775 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000776 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
paul718e3742002-12-13 20:15:29 +0000777
778 OSPF6_CMD_CHECK_RUNNING ();
hasso508e53e2004-05-18 18:57:06 +0000779 showfunc = ospf6_neighbor_show;
780
781 if (argc)
782 {
783 if (! strncmp (argv[0], "de", 2))
784 showfunc = ospf6_neighbor_show_detail;
785 else if (! strncmp (argv[0], "dr", 2))
786 showfunc = ospf6_neighbor_show_drchoice;
787 }
788
789 if (showfunc == ospf6_neighbor_show)
790 vty_out (vty, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s",
791 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
hasso049207c2004-08-04 20:02:13 +0000792 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000793 else if (showfunc == ospf6_neighbor_show_drchoice)
794 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
795 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000796 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000797
paul1eb8ef22005-04-07 07:30:20 +0000798 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
799 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
800 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
801 (*showfunc) (vty, on);
802
hasso508e53e2004-05-18 18:57:06 +0000803 return CMD_SUCCESS;
804}
paul718e3742002-12-13 20:15:29 +0000805
hasso508e53e2004-05-18 18:57:06 +0000806ALIAS (show_ipv6_ospf6_neighbor,
807 show_ipv6_ospf6_neighbor_detail_cmd,
808 "show ipv6 ospf6 neighbor (detail|drchoice)",
809 SHOW_STR
810 IP6_STR
811 OSPF6_STR
812 "Neighbor list\n"
813 "Display details\n"
814 "Display DR choices\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100815 )
hasso508e53e2004-05-18 18:57:06 +0000816
817DEFUN (show_ipv6_ospf6_neighbor_one,
818 show_ipv6_ospf6_neighbor_one_cmd,
819 "show ipv6 ospf6 neighbor A.B.C.D",
820 SHOW_STR
821 IP6_STR
822 OSPF6_STR
823 "Neighbor list\n"
824 "Specify Router-ID as IPv4 address notation\n"
825 )
826{
827 struct ospf6_neighbor *on;
828 struct ospf6_interface *oi;
829 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000830 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000831 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
832 u_int32_t router_id;
833
834 OSPF6_CMD_CHECK_RUNNING ();
835 showfunc = ospf6_neighbor_show_detail;
836
837 if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)
838 {
839 vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000840 VNL);
hasso508e53e2004-05-18 18:57:06 +0000841 return CMD_SUCCESS;
842 }
843
paul1eb8ef22005-04-07 07:30:20 +0000844 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
845 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
846 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
847 (*showfunc) (vty, on);
848
paul718e3742002-12-13 20:15:29 +0000849 return CMD_SUCCESS;
850}
851
852void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100853ospf6_neighbor_init (void)
paul718e3742002-12-13 20:15:29 +0000854{
855 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000856 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000857 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000858 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000859}
860
hasso508e53e2004-05-18 18:57:06 +0000861DEFUN (debug_ospf6_neighbor,
862 debug_ospf6_neighbor_cmd,
863 "debug ospf6 neighbor",
864 DEBUG_STR
865 OSPF6_STR
866 "Debug OSPFv3 Neighbor\n"
867 )
868{
869 unsigned char level = 0;
870 if (argc)
871 {
872 if (! strncmp (argv[0], "s", 1))
873 level = OSPF6_DEBUG_NEIGHBOR_STATE;
874 if (! strncmp (argv[0], "e", 1))
875 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
876 }
877 else
878 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
879
880 OSPF6_DEBUG_NEIGHBOR_ON (level);
881 return CMD_SUCCESS;
882}
883
884ALIAS (debug_ospf6_neighbor,
885 debug_ospf6_neighbor_detail_cmd,
886 "debug ospf6 neighbor (state|event)",
887 DEBUG_STR
888 OSPF6_STR
889 "Debug OSPFv3 Neighbor\n"
890 "Debug OSPFv3 Neighbor State Change\n"
891 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100892 )
hasso508e53e2004-05-18 18:57:06 +0000893
894DEFUN (no_debug_ospf6_neighbor,
895 no_debug_ospf6_neighbor_cmd,
896 "no debug ospf6 neighbor",
897 NO_STR
898 DEBUG_STR
899 OSPF6_STR
900 "Debug OSPFv3 Neighbor\n"
901 )
902{
903 unsigned char level = 0;
904 if (argc)
905 {
906 if (! strncmp (argv[0], "s", 1))
907 level = OSPF6_DEBUG_NEIGHBOR_STATE;
908 if (! strncmp (argv[0], "e", 1))
909 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
910 }
911 else
912 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
913
914 OSPF6_DEBUG_NEIGHBOR_OFF (level);
915 return CMD_SUCCESS;
916}
917
918ALIAS (no_debug_ospf6_neighbor,
919 no_debug_ospf6_neighbor_detail_cmd,
920 "no debug ospf6 neighbor (state|event)",
921 NO_STR
922 DEBUG_STR
923 OSPF6_STR
924 "Debug OSPFv3 Neighbor\n"
925 "Debug OSPFv3 Neighbor State Change\n"
926 "Debug OSPFv3 Neighbor Event\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100927 )
hasso508e53e2004-05-18 18:57:06 +0000928
929int
930config_write_ospf6_debug_neighbor (struct vty *vty)
931{
932 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) &&
933 IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000934 vty_out (vty, "debug ospf6 neighbor%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000935 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
hasso049207c2004-08-04 20:02:13 +0000936 vty_out (vty, "debug ospf6 neighbor state%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000937 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000938 vty_out (vty, "debug ospf6 neighbor event%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000939 return 0;
940}
941
942void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100943install_element_ospf6_debug_neighbor (void)
hasso508e53e2004-05-18 18:57:06 +0000944{
945 install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);
946 install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);
947 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
948 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);
949 install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);
950 install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);
951 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
952 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);
953}
954
955
paul718e3742002-12-13 20:15:29 +0000956