blob: 5e71c7b4969733bb588f876c4b1a4fccf093ab01 [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
hasso508e53e2004-05-18 18:57:06 +000064 for (n = listhead (oi->neighbor_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +000065 {
hasso508e53e2004-05-18 18:57:06 +000066 on = (struct ospf6_neighbor *) getdata (n);
67 if (on->router_id == router_id)
68 return on;
paul718e3742002-12-13 20:15:29 +000069 }
hasso508e53e2004-05-18 18:57:06 +000070 return (struct ospf6_neighbor *) NULL;
paul718e3742002-12-13 20:15:29 +000071}
72
73/* create ospf6_neighbor */
74struct ospf6_neighbor *
hasso508e53e2004-05-18 18:57:06 +000075ospf6_neighbor_create (u_int32_t router_id, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +000076{
hasso508e53e2004-05-18 18:57:06 +000077 struct ospf6_neighbor *on;
78 char buf[16];
paul718e3742002-12-13 20:15:29 +000079
hasso508e53e2004-05-18 18:57:06 +000080 on = (struct ospf6_neighbor *)
paul718e3742002-12-13 20:15:29 +000081 XMALLOC (MTYPE_OSPF6_NEIGHBOR, sizeof (struct ospf6_neighbor));
hasso508e53e2004-05-18 18:57:06 +000082 if (on == NULL)
paul718e3742002-12-13 20:15:29 +000083 {
84 zlog_warn ("neighbor: malloc failed");
85 return NULL;
86 }
87
hasso508e53e2004-05-18 18:57:06 +000088 memset (on, 0, sizeof (struct ospf6_neighbor));
paul718e3742002-12-13 20:15:29 +000089 inet_ntop (AF_INET, &router_id, buf, sizeof (buf));
hasso508e53e2004-05-18 18:57:06 +000090 snprintf (on->name, sizeof (on->name), "%s%%%s",
91 buf, oi->interface->name);
92 on->ospf6_if = oi;
93 on->state = OSPF6_NEIGHBOR_DOWN;
94 gettimeofday (&on->last_changed, (struct timezone *) NULL);
95 on->router_id = router_id;
paul718e3742002-12-13 20:15:29 +000096
hasso6452df02004-08-15 05:52:07 +000097 on->summary_list = ospf6_lsdb_create (on);
98 on->request_list = ospf6_lsdb_create (on);
99 on->retrans_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +0000100
hasso6452df02004-08-15 05:52:07 +0000101 on->dbdesc_list = ospf6_lsdb_create (on);
102 on->lsreq_list = ospf6_lsdb_create (on);
103 on->lsupdate_list = ospf6_lsdb_create (on);
104 on->lsack_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +0000105
hasso508e53e2004-05-18 18:57:06 +0000106 listnode_add_sort (oi->neighbor_list, on);
107 return on;
paul718e3742002-12-13 20:15:29 +0000108}
109
110void
hasso508e53e2004-05-18 18:57:06 +0000111ospf6_neighbor_delete (struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000112{
hasso3b4cd3a2004-05-18 19:28:32 +0000113 struct ospf6_lsa *lsa;
114
hasso508e53e2004-05-18 18:57:06 +0000115 ospf6_lsdb_remove_all (on->summary_list);
116 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000117 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
118 lsa = ospf6_lsdb_next (lsa))
119 {
hasso6452df02004-08-15 05:52:07 +0000120 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000121 ospf6_lsdb_remove (lsa, on->retrans_list);
122 }
paul718e3742002-12-13 20:15:29 +0000123
hasso508e53e2004-05-18 18:57:06 +0000124 ospf6_lsdb_remove_all (on->dbdesc_list);
125 ospf6_lsdb_remove_all (on->lsreq_list);
126 ospf6_lsdb_remove_all (on->lsupdate_list);
127 ospf6_lsdb_remove_all (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000128
hasso508e53e2004-05-18 18:57:06 +0000129 ospf6_lsdb_delete (on->summary_list);
130 ospf6_lsdb_delete (on->request_list);
131 ospf6_lsdb_delete (on->retrans_list);
paul718e3742002-12-13 20:15:29 +0000132
hasso508e53e2004-05-18 18:57:06 +0000133 ospf6_lsdb_delete (on->dbdesc_list);
134 ospf6_lsdb_delete (on->lsreq_list);
135 ospf6_lsdb_delete (on->lsupdate_list);
136 ospf6_lsdb_delete (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000137
hasso508e53e2004-05-18 18:57:06 +0000138 THREAD_OFF (on->inactivity_timer);
139
140 THREAD_OFF (on->thread_send_dbdesc);
141 THREAD_OFF (on->thread_send_lsreq);
142 THREAD_OFF (on->thread_send_lsupdate);
143 THREAD_OFF (on->thread_send_lsack);
144
145 XFREE (MTYPE_OSPF6_NEIGHBOR, on);
paul718e3742002-12-13 20:15:29 +0000146}
147
hasso508e53e2004-05-18 18:57:06 +0000148static void
149ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000150{
hasso508e53e2004-05-18 18:57:06 +0000151 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000152
hasso508e53e2004-05-18 18:57:06 +0000153 prev_state = on->state;
154 on->state = next_state;
155
156 if (prev_state == next_state)
157 return;
158
159 gettimeofday (&on->last_changed, (struct timezone *) NULL);
160
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
180#ifdef XXX
181 if (prev_state == NBS_FULL || next_state == NBS_FULL)
182 nbs_full_change (on->ospf6_interface);
183
184 /* check for LSAs that already reached MaxAge */
185 if ((prev_state == OSPF6_NEIGHBOR_EXCHANGE ||
186 prev_state == OSPF6_NEIGHBOR_LOADING) &&
187 (next_state != OSPF6_NEIGHBOR_EXCHANGE &&
188 next_state != OSPF6_NEIGHBOR_LOADING))
189 {
190 ospf6_maxage_remover ();
191 }
192#endif /*XXX*/
193
paul718e3742002-12-13 20:15:29 +0000194}
195
hasso508e53e2004-05-18 18:57:06 +0000196/* RFC2328 section 10.4 */
197int
198need_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 */
565void
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
582 gettimeofday (&now, NULL);
583
584 /* Dead time */
585 h = m = s = 0;
586 if (on->inactivity_timer)
587 {
588 s = on->inactivity_timer->u.sands.tv_sec - now.tv_sec;
589 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
626void
627ospf6_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
644 gettimeofday (&now, NULL);
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
655void
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
668 gettimeofday (&now, NULL);
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
798 for (i = listhead (ospf6->area_list); i; nextnode (i))
799 {
hasso508e53e2004-05-18 18:57:06 +0000800 oa = (struct ospf6_area *) getdata (i);
801 for (j = listhead (oa->if_list); j; nextnode (j))
paul718e3742002-12-13 20:15:29 +0000802 {
hasso508e53e2004-05-18 18:57:06 +0000803 oi = (struct ospf6_interface *) getdata (j);
804 for (k = listhead (oi->neighbor_list); k; nextnode (k))
paul718e3742002-12-13 20:15:29 +0000805 {
hasso508e53e2004-05-18 18:57:06 +0000806 on = (struct ospf6_neighbor *) getdata (k);
807 (*showfunc) (vty, on);
paul718e3742002-12-13 20:15:29 +0000808 }
809 }
810 }
hasso508e53e2004-05-18 18:57:06 +0000811 return CMD_SUCCESS;
812}
paul718e3742002-12-13 20:15:29 +0000813
hasso508e53e2004-05-18 18:57:06 +0000814ALIAS (show_ipv6_ospf6_neighbor,
815 show_ipv6_ospf6_neighbor_detail_cmd,
816 "show ipv6 ospf6 neighbor (detail|drchoice)",
817 SHOW_STR
818 IP6_STR
819 OSPF6_STR
820 "Neighbor list\n"
821 "Display details\n"
822 "Display DR choices\n"
823 );
824
825DEFUN (show_ipv6_ospf6_neighbor_one,
826 show_ipv6_ospf6_neighbor_one_cmd,
827 "show ipv6 ospf6 neighbor A.B.C.D",
828 SHOW_STR
829 IP6_STR
830 OSPF6_STR
831 "Neighbor list\n"
832 "Specify Router-ID as IPv4 address notation\n"
833 )
834{
835 struct ospf6_neighbor *on;
836 struct ospf6_interface *oi;
837 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000838 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000839 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
840 u_int32_t router_id;
841
842 OSPF6_CMD_CHECK_RUNNING ();
843 showfunc = ospf6_neighbor_show_detail;
844
845 if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)
846 {
847 vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000848 VNL);
hasso508e53e2004-05-18 18:57:06 +0000849 return CMD_SUCCESS;
850 }
851
852 for (i = listhead (ospf6->area_list); i; nextnode (i))
853 {
854 oa = (struct ospf6_area *) getdata (i);
855 for (j = listhead (oa->if_list); j; nextnode (j))
856 {
857 oi = (struct ospf6_interface *) getdata (j);
858 for (k = listhead (oi->neighbor_list); k; nextnode (k))
859 {
860 on = (struct ospf6_neighbor *) getdata (k);
861 if (on->router_id == router_id)
862 (*showfunc) (vty, on);
863 }
864 }
865 }
paul718e3742002-12-13 20:15:29 +0000866 return CMD_SUCCESS;
867}
868
869void
870ospf6_neighbor_init ()
871{
872 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000873 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000874 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000875 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000876}
877
hasso508e53e2004-05-18 18:57:06 +0000878DEFUN (debug_ospf6_neighbor,
879 debug_ospf6_neighbor_cmd,
880 "debug ospf6 neighbor",
881 DEBUG_STR
882 OSPF6_STR
883 "Debug OSPFv3 Neighbor\n"
884 )
885{
886 unsigned char level = 0;
887 if (argc)
888 {
889 if (! strncmp (argv[0], "s", 1))
890 level = OSPF6_DEBUG_NEIGHBOR_STATE;
891 if (! strncmp (argv[0], "e", 1))
892 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
893 }
894 else
895 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
896
897 OSPF6_DEBUG_NEIGHBOR_ON (level);
898 return CMD_SUCCESS;
899}
900
901ALIAS (debug_ospf6_neighbor,
902 debug_ospf6_neighbor_detail_cmd,
903 "debug ospf6 neighbor (state|event)",
904 DEBUG_STR
905 OSPF6_STR
906 "Debug OSPFv3 Neighbor\n"
907 "Debug OSPFv3 Neighbor State Change\n"
908 "Debug OSPFv3 Neighbor Event\n"
909 );
910
911DEFUN (no_debug_ospf6_neighbor,
912 no_debug_ospf6_neighbor_cmd,
913 "no debug ospf6 neighbor",
914 NO_STR
915 DEBUG_STR
916 OSPF6_STR
917 "Debug OSPFv3 Neighbor\n"
918 )
919{
920 unsigned char level = 0;
921 if (argc)
922 {
923 if (! strncmp (argv[0], "s", 1))
924 level = OSPF6_DEBUG_NEIGHBOR_STATE;
925 if (! strncmp (argv[0], "e", 1))
926 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
927 }
928 else
929 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
930
931 OSPF6_DEBUG_NEIGHBOR_OFF (level);
932 return CMD_SUCCESS;
933}
934
935ALIAS (no_debug_ospf6_neighbor,
936 no_debug_ospf6_neighbor_detail_cmd,
937 "no debug ospf6 neighbor (state|event)",
938 NO_STR
939 DEBUG_STR
940 OSPF6_STR
941 "Debug OSPFv3 Neighbor\n"
942 "Debug OSPFv3 Neighbor State Change\n"
943 "Debug OSPFv3 Neighbor Event\n"
944 );
945
946int
947config_write_ospf6_debug_neighbor (struct vty *vty)
948{
949 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) &&
950 IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000951 vty_out (vty, "debug ospf6 neighbor%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000952 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
hasso049207c2004-08-04 20:02:13 +0000953 vty_out (vty, "debug ospf6 neighbor state%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000954 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000955 vty_out (vty, "debug ospf6 neighbor event%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000956 return 0;
957}
958
959void
960install_element_ospf6_debug_neighbor ()
961{
962 install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);
963 install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);
964 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
965 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);
966 install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);
967 install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);
968 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
969 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);
970}
971
972
paul718e3742002-12-13 20:15:29 +0000973