2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
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
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.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include "ospf6_proto.h"
32 #include "ospf6_lsa.h"
33 #include "ospf6_lsdb.h"
34 #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"
40 #include "ospf6_flood.h"
42 #include "ospf6_bfd.h"
43 #include "ospf6_abr.h"
44 #include "ospf6_asbr.h"
45 #include "ospf6_lsa.h"
46 #include "ospf6_spf.h"
47 #include "ospf6_zebra.h"
51 DEFINE_MTYPE_STATIC(OSPF6D
, OSPF6_NEIGHBOR
, "OSPF6 neighbor");
53 DEFINE_HOOK(ospf6_neighbor_change
,
54 (struct ospf6_neighbor
* on
, int state
, int next_state
),
55 (on
, state
, next_state
));
57 unsigned char conf_debug_ospf6_neighbor
= 0;
59 const char *const ospf6_neighbor_state_str
[] = {
60 "None", "Down", "Attempt", "Init", "Twoway",
61 "ExStart", "ExChange", "Loading", "Full", NULL
};
63 const char *const ospf6_neighbor_event_str
[] = {
64 "NoEvent", "HelloReceived", "2-WayReceived", "NegotiationDone",
65 "ExchangeDone", "LoadingDone", "AdjOK?", "SeqNumberMismatch",
66 "BadLSReq", "1-WayReceived", "InactivityTimer",
69 int ospf6_neighbor_cmp(void *va
, void *vb
)
71 struct ospf6_neighbor
*ona
= (struct ospf6_neighbor
*)va
;
72 struct ospf6_neighbor
*onb
= (struct ospf6_neighbor
*)vb
;
74 if (ona
->router_id
== onb
->router_id
)
77 return (ntohl(ona
->router_id
) < ntohl(onb
->router_id
)) ? -1 : 1;
80 struct ospf6_neighbor
*ospf6_neighbor_lookup(uint32_t router_id
,
81 struct ospf6_interface
*oi
)
84 struct ospf6_neighbor
*on
;
86 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, n
, on
))
87 if (on
->router_id
== router_id
)
90 return (struct ospf6_neighbor
*)NULL
;
93 struct ospf6_neighbor
*ospf6_area_neighbor_lookup(struct ospf6_area
*area
,
96 struct ospf6_interface
*oi
;
97 struct ospf6_neighbor
*nbr
;
98 struct listnode
*node
;
100 for (ALL_LIST_ELEMENTS_RO(area
->if_list
, node
, oi
)) {
101 nbr
= ospf6_neighbor_lookup(router_id
, oi
);
109 /* create ospf6_neighbor */
110 struct ospf6_neighbor
*ospf6_neighbor_create(uint32_t router_id
,
111 struct ospf6_interface
*oi
)
113 struct ospf6_neighbor
*on
;
116 on
= XCALLOC(MTYPE_OSPF6_NEIGHBOR
, sizeof(struct ospf6_neighbor
));
117 inet_ntop(AF_INET
, &router_id
, buf
, sizeof(buf
));
118 snprintf(on
->name
, sizeof(on
->name
), "%s%%%s", buf
,
119 oi
->interface
->name
);
121 on
->state
= OSPF6_NEIGHBOR_DOWN
;
122 on
->state_change
= 0;
123 monotime(&on
->last_changed
);
124 on
->router_id
= router_id
;
126 on
->summary_list
= ospf6_lsdb_create(on
);
127 on
->request_list
= ospf6_lsdb_create(on
);
128 on
->retrans_list
= ospf6_lsdb_create(on
);
130 on
->dbdesc_list
= ospf6_lsdb_create(on
);
131 on
->lsupdate_list
= ospf6_lsdb_create(on
);
132 on
->lsack_list
= ospf6_lsdb_create(on
);
134 listnode_add_sort(oi
->neighbor_list
, on
);
136 ospf6_bfd_info_nbr_create(oi
, on
);
140 void ospf6_neighbor_delete(struct ospf6_neighbor
*on
)
142 struct ospf6_lsa
*lsa
, *lsanext
;
144 ospf6_lsdb_remove_all(on
->summary_list
);
145 ospf6_lsdb_remove_all(on
->request_list
);
146 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
147 ospf6_decrement_retrans_count(lsa
);
148 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
151 ospf6_lsdb_remove_all(on
->dbdesc_list
);
152 ospf6_lsdb_remove_all(on
->lsupdate_list
);
153 ospf6_lsdb_remove_all(on
->lsack_list
);
155 ospf6_lsdb_delete(on
->summary_list
);
156 ospf6_lsdb_delete(on
->request_list
);
157 ospf6_lsdb_delete(on
->retrans_list
);
159 ospf6_lsdb_delete(on
->dbdesc_list
);
160 ospf6_lsdb_delete(on
->lsupdate_list
);
161 ospf6_lsdb_delete(on
->lsack_list
);
163 THREAD_OFF(on
->inactivity_timer
);
165 THREAD_OFF(on
->last_dbdesc_release_timer
);
167 THREAD_OFF(on
->thread_send_dbdesc
);
168 THREAD_OFF(on
->thread_send_lsreq
);
169 THREAD_OFF(on
->thread_send_lsupdate
);
170 THREAD_OFF(on
->thread_send_lsack
);
171 THREAD_OFF(on
->thread_exchange_done
);
172 THREAD_OFF(on
->thread_adj_ok
);
174 THREAD_OFF(on
->gr_helper_info
.t_grace_timer
);
176 bfd_sess_free(&on
->bfd_session
);
177 XFREE(MTYPE_OSPF6_NEIGHBOR
, on
);
180 static void ospf6_neighbor_state_change(uint8_t next_state
,
181 struct ospf6_neighbor
*on
, int event
)
185 prev_state
= on
->state
;
186 on
->state
= next_state
;
188 if (prev_state
== next_state
)
192 monotime(&on
->last_changed
);
195 if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
)) {
196 zlog_debug("Neighbor state change %s: [%s]->[%s] (%s)",
197 on
->name
, ospf6_neighbor_state_str
[prev_state
],
198 ospf6_neighbor_state_str
[next_state
],
199 ospf6_neighbor_event_string(event
));
202 /* Optionally notify about adjacency changes */
203 if (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
204 OSPF6_LOG_ADJACENCY_CHANGES
)
205 && (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
206 OSPF6_LOG_ADJACENCY_DETAIL
)
207 || (next_state
== OSPF6_NEIGHBOR_FULL
)
208 || (next_state
< prev_state
)))
209 zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on
->name
,
210 ospf6_neighbor_state_str
[prev_state
],
211 ospf6_neighbor_state_str
[next_state
],
212 ospf6_neighbor_event_string(event
));
214 if (prev_state
== OSPF6_NEIGHBOR_FULL
215 || next_state
== OSPF6_NEIGHBOR_FULL
) {
216 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
)) {
217 OSPF6_ROUTER_LSA_SCHEDULE(on
->ospf6_if
->area
);
218 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
) {
219 OSPF6_NETWORK_LSA_SCHEDULE(on
->ospf6_if
);
220 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(
224 if (next_state
== OSPF6_NEIGHBOR_FULL
)
225 on
->ospf6_if
->area
->intra_prefix_originate
= 1;
227 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
))
228 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(
231 if ((prev_state
== OSPF6_NEIGHBOR_LOADING
232 || prev_state
== OSPF6_NEIGHBOR_EXCHANGE
)
233 && next_state
== OSPF6_NEIGHBOR_FULL
) {
234 OSPF6_AS_EXTERN_LSA_SCHEDULE(on
->ospf6_if
);
235 on
->ospf6_if
->area
->full_nbrs
++;
238 if (prev_state
== OSPF6_NEIGHBOR_FULL
)
239 on
->ospf6_if
->area
->full_nbrs
--;
242 if ((prev_state
== OSPF6_NEIGHBOR_EXCHANGE
243 || prev_state
== OSPF6_NEIGHBOR_LOADING
)
244 && (next_state
!= OSPF6_NEIGHBOR_EXCHANGE
245 && next_state
!= OSPF6_NEIGHBOR_LOADING
))
246 ospf6_maxage_remove(on
->ospf6_if
->area
->ospf6
);
248 hook_call(ospf6_neighbor_change
, on
, next_state
, prev_state
);
249 ospf6_bfd_trigger_event(on
, prev_state
, next_state
);
252 /* RFC2328 section 10.4 */
253 static int need_adjacency(struct ospf6_neighbor
*on
)
255 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_POINTTOPOINT
256 || on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
257 || on
->ospf6_if
->state
== OSPF6_INTERFACE_BDR
)
260 if (on
->ospf6_if
->drouter
== on
->router_id
261 || on
->ospf6_if
->bdrouter
== on
->router_id
)
267 int hello_received(struct thread
*thread
)
269 struct ospf6_neighbor
*on
;
271 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
274 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
275 zlog_debug("Neighbor Event %s: *HelloReceived*", on
->name
);
277 /* reset Inactivity Timer */
278 THREAD_OFF(on
->inactivity_timer
);
279 thread_add_timer(master
, inactivity_timer
, on
,
280 on
->ospf6_if
->dead_interval
, &on
->inactivity_timer
);
282 if (on
->state
<= OSPF6_NEIGHBOR_DOWN
)
283 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT
, on
,
284 OSPF6_NEIGHBOR_EVENT_HELLO_RCVD
);
289 int twoway_received(struct thread
*thread
)
291 struct ospf6_neighbor
*on
;
293 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
296 if (on
->state
> OSPF6_NEIGHBOR_INIT
)
299 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
300 zlog_debug("Neighbor Event %s: *2Way-Received*", on
->name
);
302 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
304 if (!need_adjacency(on
)) {
305 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY
, on
,
306 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
310 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
311 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
312 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
313 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
314 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
316 THREAD_OFF(on
->thread_send_dbdesc
);
317 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
318 &on
->thread_send_dbdesc
);
323 int negotiation_done(struct thread
*thread
)
325 struct ospf6_neighbor
*on
;
326 struct ospf6_lsa
*lsa
, *lsanext
;
328 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
331 if (on
->state
!= OSPF6_NEIGHBOR_EXSTART
)
334 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
335 zlog_debug("Neighbor Event %s: *NegotiationDone*", on
->name
);
338 ospf6_lsdb_remove_all(on
->summary_list
);
339 ospf6_lsdb_remove_all(on
->request_list
);
340 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
341 ospf6_decrement_retrans_count(lsa
);
342 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
345 /* Interface scoped LSAs */
346 for (ALL_LSDB(on
->ospf6_if
->lsdb
, lsa
, lsanext
)) {
347 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
348 ospf6_increment_retrans_count(lsa
);
349 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
351 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
354 /* Area scoped LSAs */
355 for (ALL_LSDB(on
->ospf6_if
->area
->lsdb
, lsa
, lsanext
)) {
356 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
357 ospf6_increment_retrans_count(lsa
);
358 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
360 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
364 for (ALL_LSDB(on
->ospf6_if
->area
->ospf6
->lsdb
, lsa
, lsanext
)) {
365 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
366 ospf6_increment_retrans_count(lsa
);
367 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
369 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
372 UNSET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
373 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXCHANGE
, on
,
374 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE
);
379 static int ospf6_neighbor_last_dbdesc_release(struct thread
*thread
)
381 struct ospf6_neighbor
*on
= THREAD_ARG(thread
);
384 memset(&on
->dbdesc_last
, 0, sizeof(struct ospf6_dbdesc
));
389 int exchange_done(struct thread
*thread
)
391 struct ospf6_neighbor
*on
;
393 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
396 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
)
399 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
400 zlog_debug("Neighbor Event %s: *ExchangeDone*", on
->name
);
402 THREAD_OFF(on
->thread_send_dbdesc
);
403 ospf6_lsdb_remove_all(on
->dbdesc_list
);
405 /* RFC 2328 (10.8): Release the last dbdesc after dead_interval */
406 if (!CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)) {
407 THREAD_OFF(on
->last_dbdesc_release_timer
);
408 thread_add_timer(master
, ospf6_neighbor_last_dbdesc_release
, on
,
409 on
->ospf6_if
->dead_interval
,
410 &on
->last_dbdesc_release_timer
);
413 if (on
->request_list
->count
== 0)
414 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL
, on
,
415 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
417 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING
, on
,
418 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
420 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
421 &on
->thread_send_lsreq
);
427 /* Check loading state. */
428 void ospf6_check_nbr_loading(struct ospf6_neighbor
*on
)
431 /* RFC2328 Section 10.9: When the neighbor responds to these requests
432 with the proper Link State Update packet(s), the Link state request
433 list is truncated and a new Link State Request packet is sent.
435 if ((on
->state
== OSPF6_NEIGHBOR_LOADING
)
436 || (on
->state
== OSPF6_NEIGHBOR_EXCHANGE
)) {
437 if (on
->request_list
->count
== 0)
438 thread_add_event(master
, loading_done
, on
, 0, NULL
);
439 else if (on
->last_ls_req
== NULL
) {
440 if (on
->thread_send_lsreq
!= NULL
)
441 THREAD_OFF(on
->thread_send_lsreq
);
442 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
443 &on
->thread_send_lsreq
);
448 int loading_done(struct thread
*thread
)
450 struct ospf6_neighbor
*on
;
452 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
455 if (on
->state
!= OSPF6_NEIGHBOR_LOADING
)
458 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
459 zlog_debug("Neighbor Event %s: *LoadingDone*", on
->name
);
461 assert(on
->request_list
->count
== 0);
463 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL
, on
,
464 OSPF6_NEIGHBOR_EVENT_LOADING_DONE
);
469 int adj_ok(struct thread
*thread
)
471 struct ospf6_neighbor
*on
;
472 struct ospf6_lsa
*lsa
, *lsanext
;
474 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
477 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
478 zlog_debug("Neighbor Event %s: *AdjOK?*", on
->name
);
480 if (on
->state
== OSPF6_NEIGHBOR_TWOWAY
&& need_adjacency(on
)) {
481 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
482 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
483 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
484 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
485 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
487 THREAD_OFF(on
->thread_send_dbdesc
);
488 on
->thread_send_dbdesc
= NULL
;
489 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
490 &on
->thread_send_dbdesc
);
492 } else if (on
->state
>= OSPF6_NEIGHBOR_EXSTART
&& !need_adjacency(on
)) {
493 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY
, on
,
494 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
495 ospf6_lsdb_remove_all(on
->summary_list
);
496 ospf6_lsdb_remove_all(on
->request_list
);
497 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
498 ospf6_decrement_retrans_count(lsa
);
499 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
506 int seqnumber_mismatch(struct thread
*thread
)
508 struct ospf6_neighbor
*on
;
509 struct ospf6_lsa
*lsa
, *lsanext
;
511 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
514 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
517 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
518 zlog_debug("Neighbor Event %s: *SeqNumberMismatch*", on
->name
);
520 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
521 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH
);
522 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
523 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
524 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
526 ospf6_lsdb_remove_all(on
->summary_list
);
527 ospf6_lsdb_remove_all(on
->request_list
);
528 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
529 ospf6_decrement_retrans_count(lsa
);
530 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
533 THREAD_OFF(on
->thread_send_dbdesc
);
534 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
536 on
->thread_send_dbdesc
= NULL
;
537 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
538 &on
->thread_send_dbdesc
);
543 int bad_lsreq(struct thread
*thread
)
545 struct ospf6_neighbor
*on
;
546 struct ospf6_lsa
*lsa
, *lsanext
;
548 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
551 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
554 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
555 zlog_debug("Neighbor Event %s: *BadLSReq*", on
->name
);
557 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
558 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ
);
559 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
560 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
561 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
563 ospf6_lsdb_remove_all(on
->summary_list
);
564 ospf6_lsdb_remove_all(on
->request_list
);
565 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
566 ospf6_decrement_retrans_count(lsa
);
567 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
570 THREAD_OFF(on
->thread_send_dbdesc
);
571 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
573 on
->thread_send_dbdesc
= NULL
;
574 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
575 &on
->thread_send_dbdesc
);
580 int oneway_received(struct thread
*thread
)
582 struct ospf6_neighbor
*on
;
583 struct ospf6_lsa
*lsa
, *lsanext
;
585 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
588 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
591 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
592 zlog_debug("Neighbor Event %s: *1Way-Received*", on
->name
);
594 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT
, on
,
595 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD
);
596 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
598 ospf6_lsdb_remove_all(on
->summary_list
);
599 ospf6_lsdb_remove_all(on
->request_list
);
600 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
601 ospf6_decrement_retrans_count(lsa
);
602 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
605 THREAD_OFF(on
->thread_send_dbdesc
);
606 THREAD_OFF(on
->thread_send_lsreq
);
607 THREAD_OFF(on
->thread_send_lsupdate
);
608 THREAD_OFF(on
->thread_send_lsack
);
609 THREAD_OFF(on
->thread_exchange_done
);
610 THREAD_OFF(on
->thread_adj_ok
);
615 int inactivity_timer(struct thread
*thread
)
617 struct ospf6_neighbor
*on
;
619 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
622 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
623 zlog_debug("Neighbor Event %s: *InactivityTimer*", on
->name
);
625 on
->drouter
= on
->prev_drouter
= 0;
626 on
->bdrouter
= on
->prev_bdrouter
= 0;
628 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
)) {
629 on
->drouter
= on
->prev_drouter
= 0;
630 on
->bdrouter
= on
->prev_bdrouter
= 0;
632 ospf6_neighbor_state_change(
633 OSPF6_NEIGHBOR_DOWN
, on
,
634 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER
);
635 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0,
638 listnode_delete(on
->ospf6_if
->neighbor_list
, on
);
639 ospf6_neighbor_delete(on
);
642 if (IS_DEBUG_OSPF6_GR
)
644 "%s, Acting as HELPER for this neighbour, So restart the dead timer.",
645 __PRETTY_FUNCTION__
);
647 thread_add_timer(master
, inactivity_timer
, on
,
648 on
->ospf6_if
->dead_interval
,
649 &on
->inactivity_timer
);
657 /* show neighbor structure */
658 static void ospf6_neighbor_show(struct vty
*vty
, struct ospf6_neighbor
*on
,
659 json_object
*json_array
, bool use_json
)
667 json_object
*json_route
;
669 /* Router-ID (Name) */
670 inet_ntop(AF_INET
, &on
->router_id
, router_id
, sizeof(router_id
));
671 #ifdef HAVE_GETNAMEINFO
674 #endif /*HAVE_GETNAMEINFO*/
678 if (on
->inactivity_timer
) {
679 s
= monotime_until(&on
->inactivity_timer
->u
.sands
, NULL
)
686 snprintf(deadtime
, sizeof(deadtime
), "%02ld:%02ld:%02ld", h
, m
, s
);
689 if (on
->ospf6_if
->type
== OSPF_IFTYPE_POINTOPOINT
)
690 snprintf(nstate
, sizeof(nstate
), "PointToPoint");
692 if (on
->router_id
== on
->drouter
)
693 snprintf(nstate
, sizeof(nstate
), "DR");
694 else if (on
->router_id
== on
->bdrouter
)
695 snprintf(nstate
, sizeof(nstate
), "BDR");
697 snprintf(nstate
, sizeof(nstate
), "DROther");
701 monotime_since(&on
->last_changed
, &res
);
702 timerstring(&res
, duration
, sizeof(duration
));
705 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n",
706 "Neighbor ID", "Pri", "DeadTime", "State", "IfState",
707 "Duration", "I/F", "State");
710 json_route
= json_object_new_object();
712 json_object_string_add(json_route
, "neighborId", router_id
);
713 json_object_int_add(json_route
, "priority", on
->priority
);
714 json_object_string_add(json_route
, "deadTime", deadtime
);
715 json_object_string_add(json_route
, "state",
716 ospf6_neighbor_state_str
[on
->state
]);
717 json_object_string_add(json_route
, "ifState", nstate
);
718 json_object_string_add(json_route
, "duration", duration
);
719 json_object_string_add(json_route
, "interfaceName",
720 on
->ospf6_if
->interface
->name
);
721 json_object_string_add(
722 json_route
, "interfaceState",
723 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
725 json_object_array_add(json_array
, json_route
);
727 vty_out(vty
, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n",
728 router_id
, on
->priority
, deadtime
,
729 ospf6_neighbor_state_str
[on
->state
], nstate
, duration
,
730 on
->ospf6_if
->interface
->name
,
731 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
734 static void ospf6_neighbor_show_drchoice(struct vty
*vty
,
735 struct ospf6_neighbor
*on
,
736 json_object
*json_array
, bool use_json
)
739 char drouter
[16], bdrouter
[16];
741 struct timeval now
, res
;
742 json_object
*json_route
;
745 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n",
746 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
750 inet_ntop(AF_INET
, &on
->router_id
, router_id
, sizeof(router_id
));
751 inet_ntop(AF_INET
, &on
->drouter
, drouter
, sizeof(drouter
));
752 inet_ntop(AF_INET
, &on
->bdrouter
, bdrouter
, sizeof(bdrouter
));
755 timersub(&now
, &on
->last_changed
, &res
);
756 timerstring(&res
, duration
, sizeof(duration
));
759 json_route
= json_object_new_object();
760 json_object_string_add(json_route
, "routerId", router_id
);
761 json_object_string_add(json_route
, "state",
762 ospf6_neighbor_state_str
[on
->state
]);
763 json_object_string_add(json_route
, "duration", duration
);
764 json_object_string_add(json_route
, "dRouter", drouter
);
765 json_object_string_add(json_route
, "bdRouter", bdrouter
);
766 json_object_string_add(json_route
, "interfaceName",
767 on
->ospf6_if
->interface
->name
);
768 json_object_string_add(
769 json_route
, "interfaceState",
770 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
772 json_object_array_add(json_array
, json_route
);
774 vty_out(vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id
,
775 ospf6_neighbor_state_str
[on
->state
], duration
, drouter
,
776 bdrouter
, on
->ospf6_if
->interface
->name
,
777 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
780 static void ospf6_neighbor_show_detail(struct vty
*vty
,
781 struct ospf6_neighbor
*on
,
782 json_object
*json
, bool use_json
)
784 char drouter
[16], bdrouter
[16];
785 char linklocal_addr
[64], duration
[32];
786 struct timeval now
, res
;
787 struct ospf6_lsa
*lsa
, *lsanext
;
788 json_object
*json_neighbor
;
789 json_object
*json_array
;
790 char db_desc_str
[20];
792 inet_ntop(AF_INET6
, &on
->linklocal_addr
, linklocal_addr
,
793 sizeof(linklocal_addr
));
794 inet_ntop(AF_INET
, &on
->drouter
, drouter
, sizeof(drouter
));
795 inet_ntop(AF_INET
, &on
->bdrouter
, bdrouter
, sizeof(bdrouter
));
798 timersub(&now
, &on
->last_changed
, &res
);
799 timerstring(&res
, duration
, sizeof(duration
));
802 json_neighbor
= json_object_new_object();
803 json_object_string_add(json_neighbor
, "area",
804 on
->ospf6_if
->area
->name
);
805 json_object_string_add(json_neighbor
, "interface",
806 on
->ospf6_if
->interface
->name
);
807 json_object_int_add(json_neighbor
, "interfaceIndex",
808 on
->ospf6_if
->interface
->ifindex
);
809 json_object_int_add(json_neighbor
, "neighborInterfaceIndex",
811 json_object_string_add(json_neighbor
, "linkLocalAddress",
813 json_object_string_add(json_neighbor
, "neighborState",
814 ospf6_neighbor_state_str
[on
->state
]);
815 json_object_string_add(json_neighbor
, "neighborStateDuration",
817 json_object_string_add(json_neighbor
, "neighborDRouter",
819 json_object_string_add(json_neighbor
, "neighborBdRouter",
821 snprintf(db_desc_str
, sizeof(db_desc_str
), "%s%s%s",
822 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
)
825 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
)
828 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)
831 json_object_string_add(json_neighbor
, "dbDescStatus",
834 json_object_int_add(json_neighbor
, "dbDescSeqNumber",
835 (unsigned long)ntohl(on
->dbdesc_seqnum
));
837 json_array
= json_object_new_array();
838 json_object_int_add(json_neighbor
, "summaryListCount",
839 on
->summary_list
->count
);
840 for (ALL_LSDB(on
->summary_list
, lsa
, lsanext
))
841 json_object_array_add(
842 json_array
, json_object_new_string(lsa
->name
));
843 json_object_object_add(json_neighbor
, "summaryListLsa",
846 json_array
= json_object_new_array();
847 json_object_int_add(json_neighbor
, "requestListCount",
848 on
->request_list
->count
);
849 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
850 json_object_array_add(
851 json_array
, json_object_new_string(lsa
->name
));
852 json_object_object_add(json_neighbor
, "requestListLsa",
855 json_array
= json_object_new_array();
856 json_object_int_add(json_neighbor
, "reTransListCount",
857 on
->retrans_list
->count
);
858 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
))
859 json_object_array_add(
860 json_array
, json_object_new_string(lsa
->name
));
861 json_object_object_add(json_neighbor
, "reTransListLsa",
866 if (on
->thread_send_dbdesc
)
867 timersub(&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
868 timerstring(&res
, duration
, sizeof(duration
));
869 json_object_int_add(json_neighbor
, "pendingLsaDbDescCount",
870 on
->dbdesc_list
->count
);
871 json_object_string_add(json_neighbor
, "pendingLsaDbDescTime",
873 json_object_string_add(json_neighbor
, "dbDescSendThread",
874 (on
->thread_send_dbdesc
? "on" : "off"));
875 json_array
= json_object_new_array();
876 for (ALL_LSDB(on
->dbdesc_list
, lsa
, lsanext
))
877 json_object_array_add(
878 json_array
, json_object_new_string(lsa
->name
));
879 json_object_object_add(json_neighbor
, "pendingLsaDbDesc",
883 if (on
->thread_send_lsreq
)
884 timersub(&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
885 timerstring(&res
, duration
, sizeof(duration
));
886 json_object_int_add(json_neighbor
, "pendingLsaLsReqCount",
887 on
->request_list
->count
);
888 json_object_string_add(json_neighbor
, "pendingLsaLsReqTime",
890 json_object_string_add(json_neighbor
, "lsReqSendThread",
891 (on
->thread_send_lsreq
? "on" : "off"));
892 json_array
= json_object_new_array();
893 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
894 json_object_array_add(
895 json_array
, json_object_new_string(lsa
->name
));
896 json_object_object_add(json_neighbor
, "pendingLsaLsReq",
901 if (on
->thread_send_lsupdate
)
902 timersub(&on
->thread_send_lsupdate
->u
.sands
, &now
,
904 timerstring(&res
, duration
, sizeof(duration
));
905 json_object_int_add(json_neighbor
, "pendingLsaLsUpdateCount",
906 on
->lsupdate_list
->count
);
907 json_object_string_add(json_neighbor
, "pendingLsaLsUpdateTime",
909 json_object_string_add(
910 json_neighbor
, "lsUpdateSendThread",
911 (on
->thread_send_lsupdate
? "on" : "off"));
912 json_array
= json_object_new_array();
913 for (ALL_LSDB(on
->lsupdate_list
, lsa
, lsanext
))
914 json_object_array_add(
915 json_array
, json_object_new_string(lsa
->name
));
916 json_object_object_add(json_neighbor
, "pendingLsaLsUpdate",
920 if (on
->thread_send_lsack
)
921 timersub(&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
922 timerstring(&res
, duration
, sizeof(duration
));
923 json_object_int_add(json_neighbor
, "pendingLsaLsAckCount",
924 on
->lsack_list
->count
);
925 json_object_string_add(json_neighbor
, "pendingLsaLsAckTime",
927 json_object_string_add(json_neighbor
, "lsAckSendThread",
928 (on
->thread_send_lsack
? "on" : "off"));
929 json_array
= json_object_new_array();
930 for (ALL_LSDB(on
->lsack_list
, lsa
, lsanext
))
931 json_object_array_add(
932 json_array
, json_object_new_string(lsa
->name
));
933 json_object_object_add(json_neighbor
, "pendingLsaLsAck",
936 bfd_sess_show(vty
, json_neighbor
, on
->bfd_session
);
938 json_object_object_add(json
, on
->name
, json_neighbor
);
942 vty_out(vty
, " Neighbor %s\n", on
->name
);
943 vty_out(vty
, " Area %s via interface %s (ifindex %d)\n",
944 on
->ospf6_if
->area
->name
, on
->ospf6_if
->interface
->name
,
945 on
->ospf6_if
->interface
->ifindex
);
946 vty_out(vty
, " His IfIndex: %d Link-local address: %s\n",
947 on
->ifindex
, linklocal_addr
);
948 vty_out(vty
, " State %s for a duration of %s\n",
949 ospf6_neighbor_state_str
[on
->state
], duration
);
950 vty_out(vty
, " His choice of DR/BDR %s/%s, Priority %d\n",
951 drouter
, bdrouter
, on
->priority
);
952 vty_out(vty
, " DbDesc status: %s%s%s SeqNum: %#lx\n",
953 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
)
956 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
)
959 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)
962 (unsigned long)ntohl(on
->dbdesc_seqnum
));
964 vty_out(vty
, " Summary-List: %d LSAs\n",
965 on
->summary_list
->count
);
966 for (ALL_LSDB(on
->summary_list
, lsa
, lsanext
))
967 vty_out(vty
, " %s\n", lsa
->name
);
969 vty_out(vty
, " Request-List: %d LSAs\n",
970 on
->request_list
->count
);
971 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
972 vty_out(vty
, " %s\n", lsa
->name
);
974 vty_out(vty
, " Retrans-List: %d LSAs\n",
975 on
->retrans_list
->count
);
976 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
))
977 vty_out(vty
, " %s\n", lsa
->name
);
980 if (on
->thread_send_dbdesc
)
981 timersub(&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
982 timerstring(&res
, duration
, sizeof(duration
));
984 " %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
985 on
->dbdesc_list
->count
, duration
,
986 (on
->thread_send_dbdesc
? "on" : "off"));
987 for (ALL_LSDB(on
->dbdesc_list
, lsa
, lsanext
))
988 vty_out(vty
, " %s\n", lsa
->name
);
991 if (on
->thread_send_lsreq
)
992 timersub(&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
993 timerstring(&res
, duration
, sizeof(duration
));
995 " %d Pending LSAs for LSReq in Time %s [thread %s]\n",
996 on
->request_list
->count
, duration
,
997 (on
->thread_send_lsreq
? "on" : "off"));
998 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
999 vty_out(vty
, " %s\n", lsa
->name
);
1002 if (on
->thread_send_lsupdate
)
1003 timersub(&on
->thread_send_lsupdate
->u
.sands
, &now
,
1005 timerstring(&res
, duration
, sizeof(duration
));
1007 " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
1008 on
->lsupdate_list
->count
, duration
,
1009 (on
->thread_send_lsupdate
? "on" : "off"));
1010 for (ALL_LSDB(on
->lsupdate_list
, lsa
, lsanext
))
1011 vty_out(vty
, " %s\n", lsa
->name
);
1014 if (on
->thread_send_lsack
)
1015 timersub(&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
1016 timerstring(&res
, duration
, sizeof(duration
));
1018 " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
1019 on
->lsack_list
->count
, duration
,
1020 (on
->thread_send_lsack
? "on" : "off"));
1021 for (ALL_LSDB(on
->lsack_list
, lsa
, lsanext
))
1022 vty_out(vty
, " %s\n", lsa
->name
);
1024 bfd_sess_show(vty
, NULL
, on
->bfd_session
);
1028 static void ospf6_neighbor_show_detail_common(struct vty
*vty
,
1029 struct ospf6
*ospf6
, bool uj
,
1030 bool detail
, bool drchoice
)
1032 struct ospf6_neighbor
*on
;
1033 struct ospf6_interface
*oi
;
1034 struct ospf6_area
*oa
;
1035 struct listnode
*i
, *j
, *k
;
1036 json_object
*json
= NULL
;
1037 json_object
*json_array
= NULL
;
1038 void (*showfunc
)(struct vty
*, struct ospf6_neighbor
*,
1039 json_object
*json
, bool use_json
);
1042 showfunc
= ospf6_neighbor_show_detail
;
1044 showfunc
= ospf6_neighbor_show_drchoice
;
1046 showfunc
= ospf6_neighbor_show
;
1049 json
= json_object_new_object();
1050 json_array
= json_object_new_array();
1052 if (showfunc
== ospf6_neighbor_show
)
1053 vty_out(vty
, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n",
1054 "Neighbor ID", "Pri", "DeadTime", "State",
1055 "IfState", "Duration", "I/F", "State");
1056 else if (showfunc
== ospf6_neighbor_show_drchoice
)
1057 vty_out(vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n",
1058 "RouterID", "State", "Duration", "DR", "BDR",
1062 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
))
1063 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1064 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
1065 if (showfunc
== ospf6_neighbor_show_detail
)
1066 (*showfunc
)(vty
, on
, json
, uj
);
1068 (*showfunc
)(vty
, on
, json_array
, uj
);
1072 if (showfunc
!= ospf6_neighbor_show_detail
)
1073 json_object_object_add(json
, "neighbors", json_array
);
1075 json_object_free(json_array
);
1076 vty_json(vty
, json
);
1080 DEFUN(show_ipv6_ospf6_neighbor
, show_ipv6_ospf6_neighbor_cmd
,
1081 "show ipv6 ospf6 [vrf <NAME|all>] neighbor [<detail|drchoice>] [json]",
1082 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1086 "Display DR choices\n" JSON_STR
)
1088 struct ospf6
*ospf6
;
1089 struct listnode
*node
;
1090 const char *vrf_name
= NULL
;
1091 bool all_vrf
= false;
1094 bool uj
= use_json(argc
, argv
);
1095 bool detail
= false;
1096 bool drchoice
= false;
1098 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1100 if (argv_find(argv
, argc
, "detail", &idx_type
))
1102 else if (argv_find(argv
, argc
, "drchoice", &idx_type
))
1105 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1106 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1107 ospf6_neighbor_show_detail_common(vty
, ospf6
, uj
,
1114 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1119 static int ospf6_neighbor_show_common(struct vty
*vty
, int argc
,
1120 struct cmd_token
**argv
,
1121 struct ospf6
*ospf6
, int idx_ipv4
,
1124 struct ospf6_neighbor
*on
;
1125 struct ospf6_interface
*oi
;
1126 struct ospf6_area
*oa
;
1127 struct listnode
*i
, *j
, *k
;
1128 void (*showfunc
)(struct vty
*, struct ospf6_neighbor
*,
1129 json_object
*json
, bool use_json
);
1131 json_object
*json
= NULL
;
1133 showfunc
= ospf6_neighbor_show_detail
;
1135 json
= json_object_new_object();
1137 if ((inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &router_id
)) != 1) {
1138 vty_out(vty
, "Router-ID is not parsable: %s\n",
1139 argv
[idx_ipv4
]->arg
);
1143 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
))
1144 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1145 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
1146 if (router_id
== on
->router_id
)
1147 (*showfunc
)(vty
, on
, json
, uj
);
1151 vty_json(vty
, json
);
1156 DEFUN(show_ipv6_ospf6_neighbor_one
, show_ipv6_ospf6_neighbor_one_cmd
,
1157 "show ipv6 ospf6 [vrf <NAME|all>] neighbor A.B.C.D [json]",
1158 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1161 "Specify Router-ID as IPv4 address notation\n" JSON_STR
)
1164 struct ospf6
*ospf6
;
1165 struct listnode
*node
;
1166 const char *vrf_name
= NULL
;
1167 bool all_vrf
= false;
1169 bool uj
= use_json(argc
, argv
);
1171 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1175 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1176 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1177 ospf6_neighbor_show_common(vty
, argc
, argv
, ospf6
,
1185 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1190 void ospf6_neighbor_init(void)
1192 install_element(VIEW_NODE
, &show_ipv6_ospf6_neighbor_cmd
);
1193 install_element(VIEW_NODE
, &show_ipv6_ospf6_neighbor_one_cmd
);
1196 DEFUN (debug_ospf6_neighbor
,
1197 debug_ospf6_neighbor_cmd
,
1198 "debug ospf6 neighbor [<state|event>]",
1201 "Debug OSPFv3 Neighbor\n"
1202 "Debug OSPFv3 Neighbor State Change\n"
1203 "Debug OSPFv3 Neighbor Event\n")
1206 unsigned char level
= 0;
1209 if (!strncmp(argv
[idx_type
]->arg
, "s", 1))
1210 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
1211 else if (!strncmp(argv
[idx_type
]->arg
, "e", 1))
1212 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
1214 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
1216 OSPF6_DEBUG_NEIGHBOR_ON(level
);
1221 DEFUN (no_debug_ospf6_neighbor
,
1222 no_debug_ospf6_neighbor_cmd
,
1223 "no debug ospf6 neighbor [<state|event>]",
1227 "Debug OSPFv3 Neighbor\n"
1228 "Debug OSPFv3 Neighbor State Change\n"
1229 "Debug OSPFv3 Neighbor Event\n")
1232 unsigned char level
= 0;
1235 if (!strncmp(argv
[idx_type
]->arg
, "s", 1))
1236 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
1237 if (!strncmp(argv
[idx_type
]->arg
, "e", 1))
1238 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
1240 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
1242 OSPF6_DEBUG_NEIGHBOR_OFF(level
);
1247 DEFUN (no_debug_ospf6
,
1256 OSPF6_DEBUG_ABR_OFF();
1257 OSPF6_DEBUG_ASBR_OFF();
1258 OSPF6_DEBUG_BROUTER_OFF();
1259 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF();
1260 OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF();
1261 OSPF6_DEBUG_FLOODING_OFF();
1262 OSPF6_DEBUG_INTERFACE_OFF();
1264 ospf6_lsa_debug_set_all(false);
1266 for (i
= 0; i
< 6; i
++)
1267 OSPF6_DEBUG_MESSAGE_OFF(i
,
1268 OSPF6_DEBUG_NEIGHBOR_STATE
1269 | OSPF6_DEBUG_NEIGHBOR_EVENT
);
1271 OSPF6_DEBUG_NEIGHBOR_OFF(OSPF6_DEBUG_NEIGHBOR_STATE
1272 | OSPF6_DEBUG_NEIGHBOR_EVENT
);
1273 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_TABLE
);
1274 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTRA
);
1275 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTER
);
1276 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_MEMORY
);
1277 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_PROCESS
);
1278 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_TIME
);
1279 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_DATABASE
);
1280 OSPF6_DEBUG_ZEBRA_OFF(OSPF6_DEBUG_ZEBRA_SEND
| OSPF6_DEBUG_ZEBRA_RECV
);
1285 int config_write_ospf6_debug_neighbor(struct vty
*vty
)
1287 if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
) && IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
1288 vty_out(vty
, "debug ospf6 neighbor\n");
1289 else if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
))
1290 vty_out(vty
, "debug ospf6 neighbor state\n");
1291 else if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
1292 vty_out(vty
, "debug ospf6 neighbor event\n");
1296 void install_element_ospf6_debug_neighbor(void)
1298 install_element(ENABLE_NODE
, &debug_ospf6_neighbor_cmd
);
1299 install_element(ENABLE_NODE
, &no_debug_ospf6_neighbor_cmd
);
1300 install_element(ENABLE_NODE
, &no_debug_ospf6_cmd
);
1301 install_element(CONFIG_NODE
, &debug_ospf6_neighbor_cmd
);
1302 install_element(CONFIG_NODE
, &no_debug_ospf6_neighbor_cmd
);
1303 install_element(CONFIG_NODE
, &no_debug_ospf6_cmd
);