blob: dd46ebc7d4b5fc424480ea4bf3119bf60c06c35d [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;
92 gettimeofday (&on->last_changed, (struct timezone *) NULL);
93 on->router_id = router_id;
paul718e3742002-12-13 20:15:29 +000094
hasso6452df02004-08-15 05:52:07 +000095 on->summary_list = ospf6_lsdb_create (on);
96 on->request_list = ospf6_lsdb_create (on);
97 on->retrans_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +000098
hasso6452df02004-08-15 05:52:07 +000099 on->dbdesc_list = ospf6_lsdb_create (on);
100 on->lsreq_list = ospf6_lsdb_create (on);
101 on->lsupdate_list = ospf6_lsdb_create (on);
102 on->lsack_list = ospf6_lsdb_create (on);
paul718e3742002-12-13 20:15:29 +0000103
hasso508e53e2004-05-18 18:57:06 +0000104 listnode_add_sort (oi->neighbor_list, on);
105 return on;
paul718e3742002-12-13 20:15:29 +0000106}
107
108void
hasso508e53e2004-05-18 18:57:06 +0000109ospf6_neighbor_delete (struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000110{
hasso3b4cd3a2004-05-18 19:28:32 +0000111 struct ospf6_lsa *lsa;
112
hasso508e53e2004-05-18 18:57:06 +0000113 ospf6_lsdb_remove_all (on->summary_list);
114 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000115 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
116 lsa = ospf6_lsdb_next (lsa))
117 {
hasso6452df02004-08-15 05:52:07 +0000118 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000119 ospf6_lsdb_remove (lsa, on->retrans_list);
120 }
paul718e3742002-12-13 20:15:29 +0000121
hasso508e53e2004-05-18 18:57:06 +0000122 ospf6_lsdb_remove_all (on->dbdesc_list);
123 ospf6_lsdb_remove_all (on->lsreq_list);
124 ospf6_lsdb_remove_all (on->lsupdate_list);
125 ospf6_lsdb_remove_all (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000126
hasso508e53e2004-05-18 18:57:06 +0000127 ospf6_lsdb_delete (on->summary_list);
128 ospf6_lsdb_delete (on->request_list);
129 ospf6_lsdb_delete (on->retrans_list);
paul718e3742002-12-13 20:15:29 +0000130
hasso508e53e2004-05-18 18:57:06 +0000131 ospf6_lsdb_delete (on->dbdesc_list);
132 ospf6_lsdb_delete (on->lsreq_list);
133 ospf6_lsdb_delete (on->lsupdate_list);
134 ospf6_lsdb_delete (on->lsack_list);
paul718e3742002-12-13 20:15:29 +0000135
hasso508e53e2004-05-18 18:57:06 +0000136 THREAD_OFF (on->inactivity_timer);
137
138 THREAD_OFF (on->thread_send_dbdesc);
139 THREAD_OFF (on->thread_send_lsreq);
140 THREAD_OFF (on->thread_send_lsupdate);
141 THREAD_OFF (on->thread_send_lsack);
142
143 XFREE (MTYPE_OSPF6_NEIGHBOR, on);
paul718e3742002-12-13 20:15:29 +0000144}
145
hasso508e53e2004-05-18 18:57:06 +0000146static void
147ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000148{
hasso508e53e2004-05-18 18:57:06 +0000149 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000150
hasso508e53e2004-05-18 18:57:06 +0000151 prev_state = on->state;
152 on->state = next_state;
153
154 if (prev_state == next_state)
155 return;
156
157 gettimeofday (&on->last_changed, (struct timezone *) NULL);
158
159 /* log */
160 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
paul718e3742002-12-13 20:15:29 +0000161 {
hassoc6487d62004-12-24 06:00:11 +0000162 zlog_debug ("Neighbor state change %s: [%s]->[%s]", on->name,
163 ospf6_neighbor_state_str[prev_state],
164 ospf6_neighbor_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000165 }
hasso508e53e2004-05-18 18:57:06 +0000166
167 if (prev_state == OSPF6_NEIGHBOR_FULL || next_state == OSPF6_NEIGHBOR_FULL)
168 {
169 OSPF6_ROUTER_LSA_SCHEDULE (on->ospf6_if->area);
170 if (on->ospf6_if->state == OSPF6_INTERFACE_DR)
171 {
172 OSPF6_NETWORK_LSA_SCHEDULE (on->ospf6_if);
173 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on->ospf6_if);
hasso508e53e2004-05-18 18:57:06 +0000174 }
hasso4846ef62004-09-03 06:04:00 +0000175 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on->ospf6_if->area);
hasso508e53e2004-05-18 18:57:06 +0000176 }
177
178#ifdef XXX
179 if (prev_state == NBS_FULL || next_state == NBS_FULL)
180 nbs_full_change (on->ospf6_interface);
181
182 /* check for LSAs that already reached MaxAge */
183 if ((prev_state == OSPF6_NEIGHBOR_EXCHANGE ||
184 prev_state == OSPF6_NEIGHBOR_LOADING) &&
185 (next_state != OSPF6_NEIGHBOR_EXCHANGE &&
186 next_state != OSPF6_NEIGHBOR_LOADING))
187 {
188 ospf6_maxage_remover ();
189 }
190#endif /*XXX*/
191
paul718e3742002-12-13 20:15:29 +0000192}
193
hasso508e53e2004-05-18 18:57:06 +0000194/* RFC2328 section 10.4 */
195int
196need_adjacency (struct ospf6_neighbor *on)
197{
198 if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT ||
199 on->ospf6_if->state == OSPF6_INTERFACE_DR ||
200 on->ospf6_if->state == OSPF6_INTERFACE_BDR)
201 return 1;
202
203 if (on->ospf6_if->drouter == on->router_id ||
204 on->ospf6_if->bdrouter == on->router_id)
205 return 1;
206
207 return 0;
208}
209
210int
211hello_received (struct thread *thread)
212{
213 struct ospf6_neighbor *on;
214
215 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
216 assert (on);
217
218 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000219 zlog_debug ("Neighbor Event %s: *HelloReceived*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000220
221 /* reset Inactivity Timer */
222 THREAD_OFF (on->inactivity_timer);
223 on->inactivity_timer = thread_add_timer (master, inactivity_timer, on,
224 on->ospf6_if->dead_interval);
225
226 if (on->state <= OSPF6_NEIGHBOR_DOWN)
227 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
228
229 return 0;
230}
231
232int
233twoway_received (struct thread *thread)
234{
235 struct ospf6_neighbor *on;
236
237 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
238 assert (on);
239
240 if (on->state > OSPF6_NEIGHBOR_INIT)
241 return 0;
242
243 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000244 zlog_debug ("Neighbor Event %s: *2Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000245
246 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
247
248 if (! need_adjacency (on))
249 {
250 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
251 return 0;
252 }
253
254 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
255 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
256 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
257 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
258
259 THREAD_OFF (on->thread_send_dbdesc);
260 on->thread_send_dbdesc =
261 thread_add_event (master, ospf6_dbdesc_send, on, 0);
262
263 return 0;
264}
265
266int
267negotiation_done (struct thread *thread)
268{
269 struct ospf6_neighbor *on;
270 struct ospf6_lsa *lsa;
271
272 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
273 assert (on);
274
275 if (on->state != OSPF6_NEIGHBOR_EXSTART)
276 return 0;
277
278 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000279 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000280
281 /* clear ls-list */
282 ospf6_lsdb_remove_all (on->summary_list);
283 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000284 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
285 lsa = ospf6_lsdb_next (lsa))
286 {
hasso6452df02004-08-15 05:52:07 +0000287 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000288 ospf6_lsdb_remove (lsa, on->retrans_list);
289 }
hasso508e53e2004-05-18 18:57:06 +0000290
291 /* Interface scoped LSAs */
292 for (lsa = ospf6_lsdb_head (on->ospf6_if->lsdb); lsa;
293 lsa = ospf6_lsdb_next (lsa))
294 {
hasso508e53e2004-05-18 18:57:06 +0000295 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000296 {
hasso6452df02004-08-15 05:52:07 +0000297 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000298 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
299 }
hasso508e53e2004-05-18 18:57:06 +0000300 else
301 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
302 }
303
304 /* Area scoped LSAs */
305 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->lsdb); lsa;
306 lsa = ospf6_lsdb_next (lsa))
307 {
hasso508e53e2004-05-18 18:57:06 +0000308 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000309 {
hasso6452df02004-08-15 05:52:07 +0000310 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000311 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
312 }
hasso508e53e2004-05-18 18:57:06 +0000313 else
314 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
315 }
316
317 /* AS scoped LSAs */
318 for (lsa = ospf6_lsdb_head (on->ospf6_if->area->ospf6->lsdb); lsa;
319 lsa = ospf6_lsdb_next (lsa))
320 {
hasso508e53e2004-05-18 18:57:06 +0000321 if (OSPF6_LSA_IS_MAXAGE (lsa))
hasso3b4cd3a2004-05-18 19:28:32 +0000322 {
hasso6452df02004-08-15 05:52:07 +0000323 ospf6_increment_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000324 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
325 }
hasso508e53e2004-05-18 18:57:06 +0000326 else
327 ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->summary_list);
328 }
329
330 UNSET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
331 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE, on);
332
333 return 0;
334}
335
336int
337exchange_done (struct thread *thread)
338{
339 struct ospf6_neighbor *on;
340
341 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
342 assert (on);
343
344 if (on->state != OSPF6_NEIGHBOR_EXCHANGE)
345 return 0;
346
347 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000348 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000349
350 THREAD_OFF (on->thread_send_dbdesc);
351 ospf6_lsdb_remove_all (on->dbdesc_list);
352
353/* XXX
354 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
355 on->ospf6_if->dead_interval);
356*/
357
358 if (on->request_list->count == 0)
359 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
360 else
361 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on);
362
363 return 0;
364}
365
366int
367loading_done (struct thread *thread)
368{
369 struct ospf6_neighbor *on;
370
371 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
372 assert (on);
373
374 if (on->state != OSPF6_NEIGHBOR_LOADING)
375 return 0;
376
377 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000378 zlog_debug ("Neighbor Event %s: *LoadingDone*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000379
380 assert (on->request_list->count == 0);
381
382 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
383
384 return 0;
385}
386
387int
388adj_ok (struct thread *thread)
389{
390 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000391 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000392
393 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
394 assert (on);
395
396 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000397 zlog_debug ("Neighbor Event %s: *AdjOK?*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000398
399 if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency (on))
400 {
401 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
402 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
403 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
404 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
405
406 THREAD_OFF (on->thread_send_dbdesc);
407 on->thread_send_dbdesc =
408 thread_add_event (master, ospf6_dbdesc_send, on, 0);
409
410 }
411 else if (on->state >= OSPF6_NEIGHBOR_EXSTART &&
412 ! need_adjacency (on))
413 {
414 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
415 ospf6_lsdb_remove_all (on->summary_list);
416 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000417 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
418 lsa = ospf6_lsdb_next (lsa))
419 {
hasso6452df02004-08-15 05:52:07 +0000420 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000421 ospf6_lsdb_remove (lsa, on->retrans_list);
422 }
hasso508e53e2004-05-18 18:57:06 +0000423 }
424
425 return 0;
426}
427
428int
429seqnumber_mismatch (struct thread *thread)
430{
431 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000432 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000433
434 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
435 assert (on);
436
437 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
438 return 0;
439
440 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000441 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000442
443 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
444 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
445 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
446 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
447
448 ospf6_lsdb_remove_all (on->summary_list);
449 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000450 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
451 lsa = ospf6_lsdb_next (lsa))
452 {
hasso6452df02004-08-15 05:52:07 +0000453 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000454 ospf6_lsdb_remove (lsa, on->retrans_list);
455 }
hasso508e53e2004-05-18 18:57:06 +0000456
457 THREAD_OFF (on->thread_send_dbdesc);
458 on->thread_send_dbdesc =
459 thread_add_event (master, ospf6_dbdesc_send, on, 0);
460
461 return 0;
462}
463
464int
465bad_lsreq (struct thread *thread)
466{
467 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000468 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000469
470 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
471 assert (on);
472
473 if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
474 return 0;
475
476 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000477 zlog_debug ("Neighbor Event %s: *BadLSReq*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000478
479 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
480 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
481 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
482 SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
483
484 ospf6_lsdb_remove_all (on->summary_list);
485 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000486 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
487 lsa = ospf6_lsdb_next (lsa))
488 {
hasso6452df02004-08-15 05:52:07 +0000489 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000490 ospf6_lsdb_remove (lsa, on->retrans_list);
491 }
hasso508e53e2004-05-18 18:57:06 +0000492
493 THREAD_OFF (on->thread_send_dbdesc);
494 on->thread_send_dbdesc =
495 thread_add_event (master, ospf6_dbdesc_send, on, 0);
496
497 return 0;
498}
499
500int
501oneway_received (struct thread *thread)
502{
503 struct ospf6_neighbor *on;
hasso3b4cd3a2004-05-18 19:28:32 +0000504 struct ospf6_lsa *lsa;
hasso508e53e2004-05-18 18:57:06 +0000505
506 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
507 assert (on);
508
509 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
510 return 0;
511
512 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000513 zlog_debug ("Neighbor Event %s: *1Way-Received*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000514
515 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
516 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
517
518 ospf6_lsdb_remove_all (on->summary_list);
519 ospf6_lsdb_remove_all (on->request_list);
hasso3b4cd3a2004-05-18 19:28:32 +0000520 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
521 lsa = ospf6_lsdb_next (lsa))
522 {
hasso6452df02004-08-15 05:52:07 +0000523 ospf6_decrement_retrans_count (lsa);
hasso3b4cd3a2004-05-18 19:28:32 +0000524 ospf6_lsdb_remove (lsa, on->retrans_list);
525 }
hasso508e53e2004-05-18 18:57:06 +0000526
527 THREAD_OFF (on->thread_send_dbdesc);
528 THREAD_OFF (on->thread_send_lsreq);
529 THREAD_OFF (on->thread_send_lsupdate);
530 THREAD_OFF (on->thread_send_lsack);
531
532 return 0;
533}
534
535int
536inactivity_timer (struct thread *thread)
537{
538 struct ospf6_neighbor *on;
539
540 on = (struct ospf6_neighbor *) THREAD_ARG (thread);
541 assert (on);
542
543 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hassoc6487d62004-12-24 06:00:11 +0000544 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on->name);
hasso508e53e2004-05-18 18:57:06 +0000545
546 on->inactivity_timer = NULL;
547 on->drouter = on->prev_drouter = 0;
548 on->bdrouter = on->prev_bdrouter = 0;
549
550 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on);
551 thread_add_event (master, neighbor_change, on->ospf6_if, 0);
552
553 listnode_delete (on->ospf6_if->neighbor_list, on);
554 ospf6_neighbor_delete (on);
555
556 return 0;
557}
558
559
paul718e3742002-12-13 20:15:29 +0000560
561/* vty functions */
562/* show neighbor structure */
563void
hasso508e53e2004-05-18 18:57:06 +0000564ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000565{
566 char router_id[16];
hasso508e53e2004-05-18 18:57:06 +0000567 char duration[16];
568 struct timeval now, res;
569 char nstate[16];
570 char deadtime[16];
571 long h, m, s;
572
573 /* Router-ID (Name) */
574 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
575#ifdef HAVE_GETNAMEINFO
576 {
577 }
578#endif /*HAVE_GETNAMEINFO*/
579
580 gettimeofday (&now, NULL);
581
582 /* Dead time */
583 h = m = s = 0;
584 if (on->inactivity_timer)
585 {
586 s = on->inactivity_timer->u.sands.tv_sec - now.tv_sec;
587 h = s / 3600;
588 s -= h * 3600;
589 m = s / 60;
590 s -= m * 60;
591 }
592 snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s);
593
594 /* Neighbor State */
595 if (if_is_pointopoint (on->ospf6_if->interface))
596 snprintf (nstate, sizeof (nstate), "PointToPoint");
597 else
598 {
599 if (on->router_id == on->drouter)
600 snprintf (nstate, sizeof (nstate), "DR");
601 else if (on->router_id == on->bdrouter)
602 snprintf (nstate, sizeof (nstate), "BDR");
603 else
604 snprintf (nstate, sizeof (nstate), "DROther");
605 }
606
607 /* Duration */
608 timersub (&now, &on->last_changed, &res);
609 timerstring (&res, duration, sizeof (duration));
610
611 /*
612 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
613 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
hasso049207c2004-08-04 20:02:13 +0000614 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000615 */
616
617 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
618 router_id, on->priority, deadtime,
619 ospf6_neighbor_state_str[on->state], nstate, duration,
620 on->ospf6_if->interface->name,
hasso049207c2004-08-04 20:02:13 +0000621 ospf6_interface_state_str[on->ospf6_if->state], VNL);
hasso508e53e2004-05-18 18:57:06 +0000622}
623
624void
625ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on)
626{
627 char router_id[16];
628 char drouter[16], bdrouter[16];
paul718e3742002-12-13 20:15:29 +0000629 char duration[16];
630 struct timeval now, res;
631
632/*
633 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
634 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000635 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000636*/
637
hasso508e53e2004-05-18 18:57:06 +0000638 inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));
639 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
640 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000641
642 gettimeofday (&now, NULL);
hasso508e53e2004-05-18 18:57:06 +0000643 timersub (&now, &on->last_changed, &res);
644 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000645
646 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
hasso508e53e2004-05-18 18:57:06 +0000647 router_id, ospf6_neighbor_state_str[on->state],
648 duration, drouter, bdrouter, on->ospf6_if->interface->name,
649 ospf6_interface_state_str[on->ospf6_if->state],
hasso049207c2004-08-04 20:02:13 +0000650 VNL);
paul718e3742002-12-13 20:15:29 +0000651}
652
653void
hasso508e53e2004-05-18 18:57:06 +0000654ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
paul718e3742002-12-13 20:15:29 +0000655{
hasso508e53e2004-05-18 18:57:06 +0000656 char drouter[16], bdrouter[16];
657 char linklocal_addr[64], duration[32];
paul718e3742002-12-13 20:15:29 +0000658 struct timeval now, res;
hasso508e53e2004-05-18 18:57:06 +0000659 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000660
hasso508e53e2004-05-18 18:57:06 +0000661 inet_ntop (AF_INET6, &on->linklocal_addr, linklocal_addr,
662 sizeof (linklocal_addr));
663 inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
664 inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
paul718e3742002-12-13 20:15:29 +0000665
666 gettimeofday (&now, NULL);
hasso508e53e2004-05-18 18:57:06 +0000667 timersub (&now, &on->last_changed, &res);
668 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000669
hasso508e53e2004-05-18 18:57:06 +0000670 vty_out (vty, " Neighbor %s%s", on->name,
hasso049207c2004-08-04 20:02:13 +0000671 VNL);
hasso508e53e2004-05-18 18:57:06 +0000672 vty_out (vty, " Area %s via interface %s (ifindex %d)%s",
673 on->ospf6_if->area->name,
674 on->ospf6_if->interface->name,
675 on->ospf6_if->interface->ifindex,
hasso049207c2004-08-04 20:02:13 +0000676 VNL);
hasso508e53e2004-05-18 18:57:06 +0000677 vty_out (vty, " His IfIndex: %d Link-local address: %s%s",
678 on->ifindex, linklocal_addr,
hasso049207c2004-08-04 20:02:13 +0000679 VNL);
hasso508e53e2004-05-18 18:57:06 +0000680 vty_out (vty, " State %s for a duration of %s%s",
681 ospf6_neighbor_state_str[on->state], duration,
hasso049207c2004-08-04 20:02:13 +0000682 VNL);
hasso508e53e2004-05-18 18:57:06 +0000683 vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s",
684 drouter, bdrouter, on->priority,
hasso049207c2004-08-04 20:02:13 +0000685 VNL);
hasso508e53e2004-05-18 18:57:06 +0000686 vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s",
687 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""),
688 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),
689 (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ?
690 "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum),
hasso049207c2004-08-04 20:02:13 +0000691 VNL);
paul718e3742002-12-13 20:15:29 +0000692
hasso508e53e2004-05-18 18:57:06 +0000693 vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count,
hasso049207c2004-08-04 20:02:13 +0000694 VNL);
hasso508e53e2004-05-18 18:57:06 +0000695 for (lsa = ospf6_lsdb_head (on->summary_list); lsa;
696 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000697 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000698
hasso508e53e2004-05-18 18:57:06 +0000699 vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count,
hasso049207c2004-08-04 20:02:13 +0000700 VNL);
hasso508e53e2004-05-18 18:57:06 +0000701 for (lsa = ospf6_lsdb_head (on->request_list); lsa;
702 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000703 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000704
705 vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count,
hasso049207c2004-08-04 20:02:13 +0000706 VNL);
hasso508e53e2004-05-18 18:57:06 +0000707 for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
708 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000709 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000710
711 timerclear (&res);
712 if (on->thread_send_dbdesc)
713 timersub (&on->thread_send_dbdesc->u.sands, &now, &res);
714 timerstring (&res, duration, sizeof (duration));
715 vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
716 on->dbdesc_list->count, duration,
717 (on->thread_send_dbdesc ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000718 VNL);
hasso508e53e2004-05-18 18:57:06 +0000719 for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa;
720 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000721 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000722
723 timerclear (&res);
724 if (on->thread_send_lsreq)
725 timersub (&on->thread_send_lsreq->u.sands, &now, &res);
726 timerstring (&res, duration, sizeof (duration));
727 vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
728 on->lsreq_list->count, duration,
729 (on->thread_send_lsreq ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000730 VNL);
hasso508e53e2004-05-18 18:57:06 +0000731 for (lsa = ospf6_lsdb_head (on->lsreq_list); lsa;
732 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000733 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000734
735 timerclear (&res);
736 if (on->thread_send_lsupdate)
737 timersub (&on->thread_send_lsupdate->u.sands, &now, &res);
738 timerstring (&res, duration, sizeof (duration));
739 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
740 on->lsupdate_list->count, duration,
741 (on->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000742 VNL);
hasso508e53e2004-05-18 18:57:06 +0000743 for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa;
744 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000745 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000746
747 timerclear (&res);
748 if (on->thread_send_lsack)
749 timersub (&on->thread_send_lsack->u.sands, &now, &res);
750 timerstring (&res, duration, sizeof (duration));
751 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
752 on->lsack_list->count, duration,
753 (on->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000754 VNL);
hasso508e53e2004-05-18 18:57:06 +0000755 for (lsa = ospf6_lsdb_head (on->lsack_list); lsa;
756 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000757 vty_out (vty, " %s%s", lsa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000758
paul718e3742002-12-13 20:15:29 +0000759}
760
hasso508e53e2004-05-18 18:57:06 +0000761DEFUN (show_ipv6_ospf6_neighbor,
paul718e3742002-12-13 20:15:29 +0000762 show_ipv6_ospf6_neighbor_cmd,
763 "show ipv6 ospf6 neighbor",
764 SHOW_STR
765 IP6_STR
766 OSPF6_STR
767 "Neighbor list\n"
hasso508e53e2004-05-18 18:57:06 +0000768 )
paul718e3742002-12-13 20:15:29 +0000769{
hasso508e53e2004-05-18 18:57:06 +0000770 struct ospf6_neighbor *on;
771 struct ospf6_interface *oi;
772 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000773 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000774 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
paul718e3742002-12-13 20:15:29 +0000775
776 OSPF6_CMD_CHECK_RUNNING ();
hasso508e53e2004-05-18 18:57:06 +0000777 showfunc = ospf6_neighbor_show;
778
779 if (argc)
780 {
781 if (! strncmp (argv[0], "de", 2))
782 showfunc = ospf6_neighbor_show_detail;
783 else if (! strncmp (argv[0], "dr", 2))
784 showfunc = ospf6_neighbor_show_drchoice;
785 }
786
787 if (showfunc == ospf6_neighbor_show)
788 vty_out (vty, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s",
789 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
hasso049207c2004-08-04 20:02:13 +0000790 "I/F", "State", VNL);
hasso508e53e2004-05-18 18:57:06 +0000791 else if (showfunc == ospf6_neighbor_show_drchoice)
792 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
793 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
hasso049207c2004-08-04 20:02:13 +0000794 "State", VNL);
paul718e3742002-12-13 20:15:29 +0000795
paul1eb8ef22005-04-07 07:30:20 +0000796 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
797 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
798 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
799 (*showfunc) (vty, on);
800
hasso508e53e2004-05-18 18:57:06 +0000801 return CMD_SUCCESS;
802}
paul718e3742002-12-13 20:15:29 +0000803
hasso508e53e2004-05-18 18:57:06 +0000804ALIAS (show_ipv6_ospf6_neighbor,
805 show_ipv6_ospf6_neighbor_detail_cmd,
806 "show ipv6 ospf6 neighbor (detail|drchoice)",
807 SHOW_STR
808 IP6_STR
809 OSPF6_STR
810 "Neighbor list\n"
811 "Display details\n"
812 "Display DR choices\n"
813 );
814
815DEFUN (show_ipv6_ospf6_neighbor_one,
816 show_ipv6_ospf6_neighbor_one_cmd,
817 "show ipv6 ospf6 neighbor A.B.C.D",
818 SHOW_STR
819 IP6_STR
820 OSPF6_STR
821 "Neighbor list\n"
822 "Specify Router-ID as IPv4 address notation\n"
823 )
824{
825 struct ospf6_neighbor *on;
826 struct ospf6_interface *oi;
827 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000828 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000829 void (*showfunc) (struct vty *, struct ospf6_neighbor *);
830 u_int32_t router_id;
831
832 OSPF6_CMD_CHECK_RUNNING ();
833 showfunc = ospf6_neighbor_show_detail;
834
835 if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)
836 {
837 vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000838 VNL);
hasso508e53e2004-05-18 18:57:06 +0000839 return CMD_SUCCESS;
840 }
841
paul1eb8ef22005-04-07 07:30:20 +0000842 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
843 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
844 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
845 (*showfunc) (vty, on);
846
paul718e3742002-12-13 20:15:29 +0000847 return CMD_SUCCESS;
848}
849
850void
851ospf6_neighbor_init ()
852{
853 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000854 install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000855 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd);
hasso508e53e2004-05-18 18:57:06 +0000856 install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000857}
858
hasso508e53e2004-05-18 18:57:06 +0000859DEFUN (debug_ospf6_neighbor,
860 debug_ospf6_neighbor_cmd,
861 "debug ospf6 neighbor",
862 DEBUG_STR
863 OSPF6_STR
864 "Debug OSPFv3 Neighbor\n"
865 )
866{
867 unsigned char level = 0;
868 if (argc)
869 {
870 if (! strncmp (argv[0], "s", 1))
871 level = OSPF6_DEBUG_NEIGHBOR_STATE;
872 if (! strncmp (argv[0], "e", 1))
873 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
874 }
875 else
876 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
877
878 OSPF6_DEBUG_NEIGHBOR_ON (level);
879 return CMD_SUCCESS;
880}
881
882ALIAS (debug_ospf6_neighbor,
883 debug_ospf6_neighbor_detail_cmd,
884 "debug ospf6 neighbor (state|event)",
885 DEBUG_STR
886 OSPF6_STR
887 "Debug OSPFv3 Neighbor\n"
888 "Debug OSPFv3 Neighbor State Change\n"
889 "Debug OSPFv3 Neighbor Event\n"
890 );
891
892DEFUN (no_debug_ospf6_neighbor,
893 no_debug_ospf6_neighbor_cmd,
894 "no debug ospf6 neighbor",
895 NO_STR
896 DEBUG_STR
897 OSPF6_STR
898 "Debug OSPFv3 Neighbor\n"
899 )
900{
901 unsigned char level = 0;
902 if (argc)
903 {
904 if (! strncmp (argv[0], "s", 1))
905 level = OSPF6_DEBUG_NEIGHBOR_STATE;
906 if (! strncmp (argv[0], "e", 1))
907 level = OSPF6_DEBUG_NEIGHBOR_EVENT;
908 }
909 else
910 level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
911
912 OSPF6_DEBUG_NEIGHBOR_OFF (level);
913 return CMD_SUCCESS;
914}
915
916ALIAS (no_debug_ospf6_neighbor,
917 no_debug_ospf6_neighbor_detail_cmd,
918 "no debug ospf6 neighbor (state|event)",
919 NO_STR
920 DEBUG_STR
921 OSPF6_STR
922 "Debug OSPFv3 Neighbor\n"
923 "Debug OSPFv3 Neighbor State Change\n"
924 "Debug OSPFv3 Neighbor Event\n"
925 );
926
927int
928config_write_ospf6_debug_neighbor (struct vty *vty)
929{
930 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) &&
931 IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000932 vty_out (vty, "debug ospf6 neighbor%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000933 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
hasso049207c2004-08-04 20:02:13 +0000934 vty_out (vty, "debug ospf6 neighbor state%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000935 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
hasso049207c2004-08-04 20:02:13 +0000936 vty_out (vty, "debug ospf6 neighbor event%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000937 return 0;
938}
939
940void
941install_element_ospf6_debug_neighbor ()
942{
943 install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);
944 install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);
945 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
946 install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);
947 install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);
948 install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);
949 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
950 install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);
951}
952
953
paul718e3742002-12-13 20:15:29 +0000954