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 static void ospf6_neighbor_clear_ls_lists(struct ospf6_neighbor
*on
)
111 struct ospf6_lsa
*lsa
;
112 struct ospf6_lsa
*lsanext
;
114 ospf6_lsdb_remove_all(on
->summary_list
);
115 if (on
->last_ls_req
) {
116 ospf6_lsa_unlock(on
->last_ls_req
);
117 on
->last_ls_req
= NULL
;
119 ospf6_lsdb_remove_all(on
->request_list
);
120 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
)) {
121 ospf6_decrement_retrans_count(lsa
);
122 ospf6_lsdb_remove(lsa
, on
->retrans_list
);
126 /* create ospf6_neighbor */
127 struct ospf6_neighbor
*ospf6_neighbor_create(uint32_t router_id
,
128 struct ospf6_interface
*oi
)
130 struct ospf6_neighbor
*on
;
134 on
= XCALLOC(MTYPE_OSPF6_NEIGHBOR
, sizeof(struct ospf6_neighbor
));
135 inet_ntop(AF_INET
, &router_id
, buf
, sizeof(buf
));
136 snprintf(on
->name
, sizeof(on
->name
), "%s%%%s", buf
,
137 oi
->interface
->name
);
139 on
->state
= OSPF6_NEIGHBOR_DOWN
;
140 on
->state_change
= 0;
141 monotime(&on
->last_changed
);
142 on
->router_id
= router_id
;
144 on
->summary_list
= ospf6_lsdb_create(on
);
145 on
->request_list
= ospf6_lsdb_create(on
);
146 on
->retrans_list
= ospf6_lsdb_create(on
);
148 on
->dbdesc_list
= ospf6_lsdb_create(on
);
149 on
->lsupdate_list
= ospf6_lsdb_create(on
);
150 on
->lsack_list
= ospf6_lsdb_create(on
);
152 for (type
= 0; type
< OSPF6_MESSAGE_TYPE_MAX
; type
++) {
153 on
->seqnum_l
[type
] = 0;
154 on
->seqnum_h
[type
] = 0;
157 on
->auth_present
= false;
159 listnode_add_sort(oi
->neighbor_list
, on
);
161 ospf6_bfd_info_nbr_create(oi
, on
);
165 void ospf6_neighbor_delete(struct ospf6_neighbor
*on
)
167 ospf6_neighbor_clear_ls_lists(on
);
169 ospf6_lsdb_remove_all(on
->dbdesc_list
);
170 ospf6_lsdb_remove_all(on
->lsupdate_list
);
171 ospf6_lsdb_remove_all(on
->lsack_list
);
173 ospf6_lsdb_delete(on
->summary_list
);
174 ospf6_lsdb_delete(on
->request_list
);
175 ospf6_lsdb_delete(on
->retrans_list
);
177 ospf6_lsdb_delete(on
->dbdesc_list
);
178 ospf6_lsdb_delete(on
->lsupdate_list
);
179 ospf6_lsdb_delete(on
->lsack_list
);
181 THREAD_OFF(on
->inactivity_timer
);
183 THREAD_OFF(on
->last_dbdesc_release_timer
);
185 THREAD_OFF(on
->thread_send_dbdesc
);
186 THREAD_OFF(on
->thread_send_lsreq
);
187 THREAD_OFF(on
->thread_send_lsupdate
);
188 THREAD_OFF(on
->thread_send_lsack
);
189 THREAD_OFF(on
->thread_exchange_done
);
190 THREAD_OFF(on
->thread_adj_ok
);
192 THREAD_OFF(on
->gr_helper_info
.t_grace_timer
);
194 bfd_sess_free(&on
->bfd_session
);
195 XFREE(MTYPE_OSPF6_NEIGHBOR
, on
);
198 static void ospf6_neighbor_state_change(uint8_t next_state
,
199 struct ospf6_neighbor
*on
, int event
)
203 prev_state
= on
->state
;
204 on
->state
= next_state
;
206 if (prev_state
== next_state
)
210 monotime(&on
->last_changed
);
213 if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
)) {
214 zlog_debug("Neighbor state change %s: [%s]->[%s] (%s)",
215 on
->name
, ospf6_neighbor_state_str
[prev_state
],
216 ospf6_neighbor_state_str
[next_state
],
217 ospf6_neighbor_event_string(event
));
220 /* Optionally notify about adjacency changes */
221 if (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
222 OSPF6_LOG_ADJACENCY_CHANGES
)
223 && (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
224 OSPF6_LOG_ADJACENCY_DETAIL
)
225 || (next_state
== OSPF6_NEIGHBOR_FULL
)
226 || (next_state
< prev_state
)))
227 zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on
->name
,
228 ospf6_neighbor_state_str
[prev_state
],
229 ospf6_neighbor_state_str
[next_state
],
230 ospf6_neighbor_event_string(event
));
232 if (prev_state
== OSPF6_NEIGHBOR_FULL
233 || next_state
== OSPF6_NEIGHBOR_FULL
) {
234 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
)) {
235 OSPF6_ROUTER_LSA_SCHEDULE(on
->ospf6_if
->area
);
236 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
) {
237 OSPF6_NETWORK_LSA_SCHEDULE(on
->ospf6_if
);
238 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(
242 if (next_state
== OSPF6_NEIGHBOR_FULL
)
243 on
->ospf6_if
->area
->intra_prefix_originate
= 1;
245 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
))
246 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(
249 if ((prev_state
== OSPF6_NEIGHBOR_LOADING
250 || prev_state
== OSPF6_NEIGHBOR_EXCHANGE
)
251 && next_state
== OSPF6_NEIGHBOR_FULL
) {
252 OSPF6_AS_EXTERN_LSA_SCHEDULE(on
->ospf6_if
);
253 on
->ospf6_if
->area
->full_nbrs
++;
256 if (prev_state
== OSPF6_NEIGHBOR_FULL
)
257 on
->ospf6_if
->area
->full_nbrs
--;
260 if ((prev_state
== OSPF6_NEIGHBOR_EXCHANGE
261 || prev_state
== OSPF6_NEIGHBOR_LOADING
)
262 && (next_state
!= OSPF6_NEIGHBOR_EXCHANGE
263 && next_state
!= OSPF6_NEIGHBOR_LOADING
))
264 ospf6_maxage_remove(on
->ospf6_if
->area
->ospf6
);
266 hook_call(ospf6_neighbor_change
, on
, next_state
, prev_state
);
267 ospf6_bfd_trigger_event(on
, prev_state
, next_state
);
270 /* RFC2328 section 10.4 */
271 static int need_adjacency(struct ospf6_neighbor
*on
)
273 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_POINTTOPOINT
274 || on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
275 || on
->ospf6_if
->state
== OSPF6_INTERFACE_BDR
)
278 if (on
->ospf6_if
->drouter
== on
->router_id
279 || on
->ospf6_if
->bdrouter
== on
->router_id
)
285 void hello_received(struct thread
*thread
)
287 struct ospf6_neighbor
*on
;
289 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
292 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
293 zlog_debug("Neighbor Event %s: *HelloReceived*", on
->name
);
295 /* reset Inactivity Timer */
296 THREAD_OFF(on
->inactivity_timer
);
297 thread_add_timer(master
, inactivity_timer
, on
,
298 on
->ospf6_if
->dead_interval
, &on
->inactivity_timer
);
300 if (on
->state
<= OSPF6_NEIGHBOR_DOWN
)
301 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT
, on
,
302 OSPF6_NEIGHBOR_EVENT_HELLO_RCVD
);
305 void twoway_received(struct thread
*thread
)
307 struct ospf6_neighbor
*on
;
309 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
312 if (on
->state
> OSPF6_NEIGHBOR_INIT
)
315 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
316 zlog_debug("Neighbor Event %s: *2Way-Received*", on
->name
);
318 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
320 if (!need_adjacency(on
)) {
321 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY
, on
,
322 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
326 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
327 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
328 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
329 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
330 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
332 THREAD_OFF(on
->thread_send_dbdesc
);
333 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
334 &on
->thread_send_dbdesc
);
337 void negotiation_done(struct thread
*thread
)
339 struct ospf6_neighbor
*on
;
340 struct ospf6_lsa
*lsa
, *lsanext
;
342 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
345 if (on
->state
!= OSPF6_NEIGHBOR_EXSTART
)
348 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
349 zlog_debug("Neighbor Event %s: *NegotiationDone*", on
->name
);
352 ospf6_neighbor_clear_ls_lists(on
);
354 /* Interface scoped LSAs */
355 for (ALL_LSDB(on
->ospf6_if
->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
);
363 /* Area scoped LSAs */
364 for (ALL_LSDB(on
->ospf6_if
->area
->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
);
373 for (ALL_LSDB(on
->ospf6_if
->area
->ospf6
->lsdb
, lsa
, lsanext
)) {
374 if (OSPF6_LSA_IS_MAXAGE(lsa
)) {
375 ospf6_increment_retrans_count(lsa
);
376 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->retrans_list
);
378 ospf6_lsdb_add(ospf6_lsa_copy(lsa
), on
->summary_list
);
381 UNSET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
382 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXCHANGE
, on
,
383 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE
);
386 static void ospf6_neighbor_last_dbdesc_release(struct thread
*thread
)
388 struct ospf6_neighbor
*on
= THREAD_ARG(thread
);
391 memset(&on
->dbdesc_last
, 0, sizeof(struct ospf6_dbdesc
));
394 void exchange_done(struct thread
*thread
)
396 struct ospf6_neighbor
*on
;
398 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
401 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
)
404 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
405 zlog_debug("Neighbor Event %s: *ExchangeDone*", on
->name
);
407 THREAD_OFF(on
->thread_send_dbdesc
);
408 ospf6_lsdb_remove_all(on
->dbdesc_list
);
410 /* RFC 2328 (10.8): Release the last dbdesc after dead_interval */
411 if (!CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)) {
412 THREAD_OFF(on
->last_dbdesc_release_timer
);
413 thread_add_timer(master
, ospf6_neighbor_last_dbdesc_release
, on
,
414 on
->ospf6_if
->dead_interval
,
415 &on
->last_dbdesc_release_timer
);
418 if (on
->request_list
->count
== 0)
419 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL
, on
,
420 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
422 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING
, on
,
423 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
425 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
426 &on
->thread_send_lsreq
);
430 /* Check loading state. */
431 void ospf6_check_nbr_loading(struct ospf6_neighbor
*on
)
434 /* RFC2328 Section 10.9: When the neighbor responds to these requests
435 with the proper Link State Update packet(s), the Link state request
436 list is truncated and a new Link State Request packet is sent.
438 if ((on
->state
== OSPF6_NEIGHBOR_LOADING
)
439 || (on
->state
== OSPF6_NEIGHBOR_EXCHANGE
)) {
440 if (on
->request_list
->count
== 0)
441 thread_add_event(master
, loading_done
, on
, 0, NULL
);
442 else if (on
->last_ls_req
== NULL
) {
443 THREAD_OFF(on
->thread_send_lsreq
);
444 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
445 &on
->thread_send_lsreq
);
450 void loading_done(struct thread
*thread
)
452 struct ospf6_neighbor
*on
;
454 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
457 if (on
->state
!= OSPF6_NEIGHBOR_LOADING
)
460 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
461 zlog_debug("Neighbor Event %s: *LoadingDone*", on
->name
);
463 assert(on
->request_list
->count
== 0);
465 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL
, on
,
466 OSPF6_NEIGHBOR_EVENT_LOADING_DONE
);
469 void adj_ok(struct thread
*thread
)
471 struct ospf6_neighbor
*on
;
473 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
476 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
477 zlog_debug("Neighbor Event %s: *AdjOK?*", on
->name
);
479 if (on
->state
== OSPF6_NEIGHBOR_TWOWAY
&& need_adjacency(on
)) {
480 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
481 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
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
);
486 THREAD_OFF(on
->thread_send_dbdesc
);
487 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
488 &on
->thread_send_dbdesc
);
490 } else if (on
->state
>= OSPF6_NEIGHBOR_EXSTART
&& !need_adjacency(on
)) {
491 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY
, on
,
492 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
493 ospf6_neighbor_clear_ls_lists(on
);
497 void seqnumber_mismatch(struct thread
*thread
)
499 struct ospf6_neighbor
*on
;
501 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
504 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
507 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
508 zlog_debug("Neighbor Event %s: *SeqNumberMismatch*", on
->name
);
510 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
511 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH
);
512 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
513 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
514 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
516 ospf6_neighbor_clear_ls_lists(on
);
518 THREAD_OFF(on
->thread_send_dbdesc
);
519 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
521 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
522 &on
->thread_send_dbdesc
);
525 void bad_lsreq(struct thread
*thread
)
527 struct ospf6_neighbor
*on
;
529 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
532 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
535 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
536 zlog_debug("Neighbor Event %s: *BadLSReq*", on
->name
);
538 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART
, on
,
539 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ
);
540 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
541 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
542 SET_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
544 ospf6_neighbor_clear_ls_lists(on
);
546 THREAD_OFF(on
->thread_send_dbdesc
);
547 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
549 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
550 &on
->thread_send_dbdesc
);
554 void oneway_received(struct thread
*thread
)
556 struct ospf6_neighbor
*on
;
558 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
561 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
564 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
565 zlog_debug("Neighbor Event %s: *1Way-Received*", on
->name
);
567 ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT
, on
,
568 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD
);
569 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
571 ospf6_neighbor_clear_ls_lists(on
);
573 THREAD_OFF(on
->thread_send_dbdesc
);
574 THREAD_OFF(on
->thread_send_lsreq
);
575 THREAD_OFF(on
->thread_send_lsupdate
);
576 THREAD_OFF(on
->thread_send_lsack
);
577 THREAD_OFF(on
->thread_exchange_done
);
578 THREAD_OFF(on
->thread_adj_ok
);
581 void inactivity_timer(struct thread
*thread
)
583 struct ospf6_neighbor
*on
;
585 on
= (struct ospf6_neighbor
*)THREAD_ARG(thread
);
588 if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
589 zlog_debug("Neighbor Event %s: *InactivityTimer*", on
->name
);
591 on
->drouter
= on
->prev_drouter
= 0;
592 on
->bdrouter
= on
->prev_bdrouter
= 0;
594 if (!OSPF6_GR_IS_ACTIVE_HELPER(on
)) {
595 on
->drouter
= on
->prev_drouter
= 0;
596 on
->bdrouter
= on
->prev_bdrouter
= 0;
598 ospf6_neighbor_state_change(
599 OSPF6_NEIGHBOR_DOWN
, on
,
600 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER
);
601 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0,
604 listnode_delete(on
->ospf6_if
->neighbor_list
, on
);
605 ospf6_neighbor_delete(on
);
608 if (IS_DEBUG_OSPF6_GR
)
610 "%s, Acting as HELPER for this neighbour, So restart the dead timer.",
611 __PRETTY_FUNCTION__
);
613 thread_add_timer(master
, inactivity_timer
, on
,
614 on
->ospf6_if
->dead_interval
,
615 &on
->inactivity_timer
);
621 /* show neighbor structure */
622 static void ospf6_neighbor_show(struct vty
*vty
, struct ospf6_neighbor
*on
,
623 json_object
*json_array
, bool use_json
)
631 json_object
*json_route
;
633 /* Router-ID (Name) */
634 inet_ntop(AF_INET
, &on
->router_id
, router_id
, sizeof(router_id
));
635 #ifdef HAVE_GETNAMEINFO
638 #endif /*HAVE_GETNAMEINFO*/
642 if (on
->inactivity_timer
) {
643 s
= monotime_until(&on
->inactivity_timer
->u
.sands
, NULL
)
650 snprintf(deadtime
, sizeof(deadtime
), "%02ld:%02ld:%02ld", h
, m
, s
);
653 if (on
->ospf6_if
->type
== OSPF_IFTYPE_POINTOPOINT
)
654 snprintf(nstate
, sizeof(nstate
), "PointToPoint");
656 if (on
->router_id
== on
->drouter
)
657 snprintf(nstate
, sizeof(nstate
), "DR");
658 else if (on
->router_id
== on
->bdrouter
)
659 snprintf(nstate
, sizeof(nstate
), "BDR");
661 snprintf(nstate
, sizeof(nstate
), "DROther");
665 monotime_since(&on
->last_changed
, &res
);
666 timerstring(&res
, duration
, sizeof(duration
));
669 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n",
670 "Neighbor ID", "Pri", "DeadTime", "State", "IfState",
671 "Duration", "I/F", "State");
674 json_route
= json_object_new_object();
676 json_object_string_add(json_route
, "neighborId", router_id
);
677 json_object_int_add(json_route
, "priority", on
->priority
);
678 json_object_string_add(json_route
, "deadTime", deadtime
);
679 json_object_string_add(json_route
, "state",
680 ospf6_neighbor_state_str
[on
->state
]);
681 json_object_string_add(json_route
, "ifState", nstate
);
682 json_object_string_add(json_route
, "duration", duration
);
683 json_object_string_add(json_route
, "interfaceName",
684 on
->ospf6_if
->interface
->name
);
685 json_object_string_add(
686 json_route
, "interfaceState",
687 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
689 json_object_array_add(json_array
, json_route
);
691 vty_out(vty
, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n",
692 router_id
, on
->priority
, deadtime
,
693 ospf6_neighbor_state_str
[on
->state
], nstate
, duration
,
694 on
->ospf6_if
->interface
->name
,
695 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
698 static void ospf6_neighbor_show_drchoice(struct vty
*vty
,
699 struct ospf6_neighbor
*on
,
700 json_object
*json_array
, bool use_json
)
703 char drouter
[16], bdrouter
[16];
705 struct timeval now
, res
;
706 json_object
*json_route
;
709 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n",
710 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
714 inet_ntop(AF_INET
, &on
->router_id
, router_id
, sizeof(router_id
));
715 inet_ntop(AF_INET
, &on
->drouter
, drouter
, sizeof(drouter
));
716 inet_ntop(AF_INET
, &on
->bdrouter
, bdrouter
, sizeof(bdrouter
));
719 timersub(&now
, &on
->last_changed
, &res
);
720 timerstring(&res
, duration
, sizeof(duration
));
723 json_route
= json_object_new_object();
724 json_object_string_add(json_route
, "routerId", router_id
);
725 json_object_string_add(json_route
, "state",
726 ospf6_neighbor_state_str
[on
->state
]);
727 json_object_string_add(json_route
, "duration", duration
);
728 json_object_string_add(json_route
, "dRouter", drouter
);
729 json_object_string_add(json_route
, "bdRouter", bdrouter
);
730 json_object_string_add(json_route
, "interfaceName",
731 on
->ospf6_if
->interface
->name
);
732 json_object_string_add(
733 json_route
, "interfaceState",
734 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
736 json_object_array_add(json_array
, json_route
);
738 vty_out(vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id
,
739 ospf6_neighbor_state_str
[on
->state
], duration
, drouter
,
740 bdrouter
, on
->ospf6_if
->interface
->name
,
741 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
744 static void ospf6_neighbor_show_detail(struct vty
*vty
,
745 struct ospf6_neighbor
*on
,
746 json_object
*json
, bool use_json
)
748 char drouter
[16], bdrouter
[16];
749 char linklocal_addr
[64], duration
[32];
750 struct timeval now
, res
;
751 struct ospf6_lsa
*lsa
, *lsanext
;
752 json_object
*json_neighbor
;
753 json_object
*json_array
;
754 char db_desc_str
[20];
756 inet_ntop(AF_INET6
, &on
->linklocal_addr
, linklocal_addr
,
757 sizeof(linklocal_addr
));
758 inet_ntop(AF_INET
, &on
->drouter
, drouter
, sizeof(drouter
));
759 inet_ntop(AF_INET
, &on
->bdrouter
, bdrouter
, sizeof(bdrouter
));
762 timersub(&now
, &on
->last_changed
, &res
);
763 timerstring(&res
, duration
, sizeof(duration
));
766 json_neighbor
= json_object_new_object();
767 json_object_string_add(json_neighbor
, "area",
768 on
->ospf6_if
->area
->name
);
769 json_object_string_add(json_neighbor
, "interface",
770 on
->ospf6_if
->interface
->name
);
771 json_object_int_add(json_neighbor
, "interfaceIndex",
772 on
->ospf6_if
->interface
->ifindex
);
773 json_object_int_add(json_neighbor
, "neighborInterfaceIndex",
775 json_object_string_add(json_neighbor
, "linkLocalAddress",
777 json_object_string_add(json_neighbor
, "neighborState",
778 ospf6_neighbor_state_str
[on
->state
]);
779 json_object_string_add(json_neighbor
, "neighborStateDuration",
781 json_object_string_add(json_neighbor
, "neighborDRouter",
783 json_object_string_add(json_neighbor
, "neighborBdRouter",
785 snprintf(db_desc_str
, sizeof(db_desc_str
), "%s%s%s",
786 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
)
789 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
)
792 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)
795 json_object_string_add(json_neighbor
, "dbDescStatus",
798 json_object_int_add(json_neighbor
, "dbDescSeqNumber",
799 (unsigned long)ntohl(on
->dbdesc_seqnum
));
801 json_array
= json_object_new_array();
802 json_object_int_add(json_neighbor
, "summaryListCount",
803 on
->summary_list
->count
);
804 for (ALL_LSDB(on
->summary_list
, lsa
, lsanext
))
805 json_object_array_add(
806 json_array
, json_object_new_string(lsa
->name
));
807 json_object_object_add(json_neighbor
, "summaryListLsa",
810 json_array
= json_object_new_array();
811 json_object_int_add(json_neighbor
, "requestListCount",
812 on
->request_list
->count
);
813 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
814 json_object_array_add(
815 json_array
, json_object_new_string(lsa
->name
));
816 json_object_object_add(json_neighbor
, "requestListLsa",
819 json_array
= json_object_new_array();
820 json_object_int_add(json_neighbor
, "reTransListCount",
821 on
->retrans_list
->count
);
822 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
))
823 json_object_array_add(
824 json_array
, json_object_new_string(lsa
->name
));
825 json_object_object_add(json_neighbor
, "reTransListLsa",
830 if (thread_is_scheduled(on
->thread_send_dbdesc
))
831 timersub(&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
832 timerstring(&res
, duration
, sizeof(duration
));
833 json_object_int_add(json_neighbor
, "pendingLsaDbDescCount",
834 on
->dbdesc_list
->count
);
835 json_object_string_add(json_neighbor
, "pendingLsaDbDescTime",
837 json_object_string_add(
838 json_neighbor
, "dbDescSendThread",
839 (thread_is_scheduled(on
->thread_send_dbdesc
) ? "on"
841 json_array
= json_object_new_array();
842 for (ALL_LSDB(on
->dbdesc_list
, lsa
, lsanext
))
843 json_object_array_add(
844 json_array
, json_object_new_string(lsa
->name
));
845 json_object_object_add(json_neighbor
, "pendingLsaDbDesc",
849 if (thread_is_scheduled(on
->thread_send_lsreq
))
850 timersub(&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
851 timerstring(&res
, duration
, sizeof(duration
));
852 json_object_int_add(json_neighbor
, "pendingLsaLsReqCount",
853 on
->request_list
->count
);
854 json_object_string_add(json_neighbor
, "pendingLsaLsReqTime",
856 json_object_string_add(
857 json_neighbor
, "lsReqSendThread",
858 (thread_is_scheduled(on
->thread_send_lsreq
) ? "on"
860 json_array
= json_object_new_array();
861 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
862 json_object_array_add(
863 json_array
, json_object_new_string(lsa
->name
));
864 json_object_object_add(json_neighbor
, "pendingLsaLsReq",
869 if (thread_is_scheduled(on
->thread_send_lsupdate
))
870 timersub(&on
->thread_send_lsupdate
->u
.sands
, &now
,
872 timerstring(&res
, duration
, sizeof(duration
));
873 json_object_int_add(json_neighbor
, "pendingLsaLsUpdateCount",
874 on
->lsupdate_list
->count
);
875 json_object_string_add(json_neighbor
, "pendingLsaLsUpdateTime",
877 json_object_string_add(
878 json_neighbor
, "lsUpdateSendThread",
879 (thread_is_scheduled(on
->thread_send_lsupdate
)
882 json_array
= json_object_new_array();
883 for (ALL_LSDB(on
->lsupdate_list
, lsa
, lsanext
))
884 json_object_array_add(
885 json_array
, json_object_new_string(lsa
->name
));
886 json_object_object_add(json_neighbor
, "pendingLsaLsUpdate",
890 if (thread_is_scheduled(on
->thread_send_lsack
))
891 timersub(&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
892 timerstring(&res
, duration
, sizeof(duration
));
893 json_object_int_add(json_neighbor
, "pendingLsaLsAckCount",
894 on
->lsack_list
->count
);
895 json_object_string_add(json_neighbor
, "pendingLsaLsAckTime",
897 json_object_string_add(
898 json_neighbor
, "lsAckSendThread",
899 (thread_is_scheduled(on
->thread_send_lsack
) ? "on"
901 json_array
= json_object_new_array();
902 for (ALL_LSDB(on
->lsack_list
, lsa
, lsanext
))
903 json_object_array_add(
904 json_array
, json_object_new_string(lsa
->name
));
905 json_object_object_add(json_neighbor
, "pendingLsaLsAck",
908 bfd_sess_show(vty
, json_neighbor
, on
->bfd_session
);
910 if (on
->auth_present
== true) {
911 json_object_string_add(json_neighbor
, "authStatus",
914 json_neighbor
, "recvdHelloHigherSeqNo",
915 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_HELLO
]);
917 json_neighbor
, "recvdHelloLowerSeqNo",
918 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_HELLO
]);
920 json_neighbor
, "recvdDBDescHigherSeqNo",
921 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_DBDESC
]);
923 json_neighbor
, "recvdDBDescLowerSeqNo",
924 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_DBDESC
]);
926 json_neighbor
, "recvdLSReqHigherSeqNo",
927 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSREQ
]);
929 json_neighbor
, "recvdLSReqLowerSeqNo",
930 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSREQ
]);
932 json_neighbor
, "recvdLSUpdHigherSeqNo",
933 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSUPDATE
]);
935 json_neighbor
, "recvdLSUpdLowerSeqNo",
936 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSUPDATE
]);
938 json_neighbor
, "recvdLSAckHigherSeqNo",
939 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSACK
]);
941 json_neighbor
, "recvdLSAckLowerSeqNo",
942 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSACK
]);
944 json_object_string_add(json_neighbor
, "authStatus",
947 json_object_object_add(json
, on
->name
, json_neighbor
);
950 vty_out(vty
, " Neighbor %s\n", on
->name
);
951 vty_out(vty
, " Area %s via interface %s (ifindex %d)\n",
952 on
->ospf6_if
->area
->name
, on
->ospf6_if
->interface
->name
,
953 on
->ospf6_if
->interface
->ifindex
);
954 vty_out(vty
, " His IfIndex: %d Link-local address: %s\n",
955 on
->ifindex
, linklocal_addr
);
956 vty_out(vty
, " State %s for a duration of %s\n",
957 ospf6_neighbor_state_str
[on
->state
], duration
);
958 vty_out(vty
, " His choice of DR/BDR %s/%s, Priority %d\n",
959 drouter
, bdrouter
, on
->priority
);
960 vty_out(vty
, " DbDesc status: %s%s%s SeqNum: %#lx\n",
961 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
)
964 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
)
967 (CHECK_FLAG(on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
)
970 (unsigned long)ntohl(on
->dbdesc_seqnum
));
972 vty_out(vty
, " Summary-List: %d LSAs\n",
973 on
->summary_list
->count
);
974 for (ALL_LSDB(on
->summary_list
, lsa
, lsanext
))
975 vty_out(vty
, " %s\n", lsa
->name
);
977 vty_out(vty
, " Request-List: %d LSAs\n",
978 on
->request_list
->count
);
979 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
980 vty_out(vty
, " %s\n", lsa
->name
);
982 vty_out(vty
, " Retrans-List: %d LSAs\n",
983 on
->retrans_list
->count
);
984 for (ALL_LSDB(on
->retrans_list
, lsa
, lsanext
))
985 vty_out(vty
, " %s\n", lsa
->name
);
988 if (thread_is_scheduled(on
->thread_send_dbdesc
))
989 timersub(&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
990 timerstring(&res
, duration
, sizeof(duration
));
992 " %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
993 on
->dbdesc_list
->count
, duration
,
994 (thread_is_scheduled(on
->thread_send_dbdesc
) ? "on"
996 for (ALL_LSDB(on
->dbdesc_list
, lsa
, lsanext
))
997 vty_out(vty
, " %s\n", lsa
->name
);
1000 if (thread_is_scheduled(on
->thread_send_lsreq
))
1001 timersub(&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
1002 timerstring(&res
, duration
, sizeof(duration
));
1004 " %d Pending LSAs for LSReq in Time %s [thread %s]\n",
1005 on
->request_list
->count
, duration
,
1006 (thread_is_scheduled(on
->thread_send_lsreq
) ? "on"
1008 for (ALL_LSDB(on
->request_list
, lsa
, lsanext
))
1009 vty_out(vty
, " %s\n", lsa
->name
);
1012 if (thread_is_scheduled(on
->thread_send_lsupdate
))
1013 timersub(&on
->thread_send_lsupdate
->u
.sands
, &now
,
1015 timerstring(&res
, duration
, sizeof(duration
));
1017 " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
1018 on
->lsupdate_list
->count
, duration
,
1019 (thread_is_scheduled(on
->thread_send_lsupdate
)
1022 for (ALL_LSDB(on
->lsupdate_list
, lsa
, lsanext
))
1023 vty_out(vty
, " %s\n", lsa
->name
);
1026 if (thread_is_scheduled(on
->thread_send_lsack
))
1027 timersub(&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
1028 timerstring(&res
, duration
, sizeof(duration
));
1030 " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
1031 on
->lsack_list
->count
, duration
,
1032 (thread_is_scheduled(on
->thread_send_lsack
) ? "on"
1034 for (ALL_LSDB(on
->lsack_list
, lsa
, lsanext
))
1035 vty_out(vty
, " %s\n", lsa
->name
);
1037 bfd_sess_show(vty
, NULL
, on
->bfd_session
);
1039 if (on
->auth_present
== true) {
1040 vty_out(vty
, " Authentication header present\n");
1042 "\t\t\t hello DBDesc LSReq LSUpd LSAck\n");
1044 " Higher sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n",
1045 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_HELLO
],
1046 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_DBDESC
],
1047 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSREQ
],
1048 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSUPDATE
],
1049 on
->seqnum_h
[OSPF6_MESSAGE_TYPE_LSACK
]);
1051 " Lower sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n",
1052 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_HELLO
],
1053 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_DBDESC
],
1054 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSREQ
],
1055 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSUPDATE
],
1056 on
->seqnum_l
[OSPF6_MESSAGE_TYPE_LSACK
]);
1058 vty_out(vty
, " Authentication header not present\n");
1062 static void ospf6_neighbor_show_detail_common(struct vty
*vty
,
1063 struct ospf6
*ospf6
, bool uj
,
1064 bool detail
, bool drchoice
)
1066 struct ospf6_neighbor
*on
;
1067 struct ospf6_interface
*oi
;
1068 struct ospf6_area
*oa
;
1069 struct listnode
*i
, *j
, *k
;
1070 json_object
*json
= NULL
;
1071 json_object
*json_array
= NULL
;
1072 void (*showfunc
)(struct vty
*, struct ospf6_neighbor
*,
1073 json_object
*json
, bool use_json
);
1076 showfunc
= ospf6_neighbor_show_detail
;
1078 showfunc
= ospf6_neighbor_show_drchoice
;
1080 showfunc
= ospf6_neighbor_show
;
1083 json
= json_object_new_object();
1084 json_array
= json_object_new_array();
1086 if (showfunc
== ospf6_neighbor_show
)
1087 vty_out(vty
, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n",
1088 "Neighbor ID", "Pri", "DeadTime", "State",
1089 "IfState", "Duration", "I/F", "State");
1090 else if (showfunc
== ospf6_neighbor_show_drchoice
)
1091 vty_out(vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n",
1092 "RouterID", "State", "Duration", "DR", "BDR",
1096 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
))
1097 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1098 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
1099 if (showfunc
== ospf6_neighbor_show_detail
)
1100 (*showfunc
)(vty
, on
, json
, uj
);
1102 (*showfunc
)(vty
, on
, json_array
, uj
);
1106 if (showfunc
!= ospf6_neighbor_show_detail
)
1107 json_object_object_add(json
, "neighbors", json_array
);
1109 json_object_free(json_array
);
1110 vty_json(vty
, json
);
1114 DEFUN(show_ipv6_ospf6_neighbor
, show_ipv6_ospf6_neighbor_cmd
,
1115 "show ipv6 ospf6 [vrf <NAME|all>] neighbor [<detail|drchoice>] [json]",
1116 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1120 "Display DR choices\n" JSON_STR
)
1122 struct ospf6
*ospf6
;
1123 struct listnode
*node
;
1124 const char *vrf_name
= NULL
;
1125 bool all_vrf
= false;
1128 bool uj
= use_json(argc
, argv
);
1129 bool detail
= false;
1130 bool drchoice
= false;
1132 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1134 if (argv_find(argv
, argc
, "detail", &idx_type
))
1136 else if (argv_find(argv
, argc
, "drchoice", &idx_type
))
1139 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1140 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1141 ospf6_neighbor_show_detail_common(vty
, ospf6
, uj
,
1148 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1153 static int ospf6_neighbor_show_common(struct vty
*vty
, int argc
,
1154 struct cmd_token
**argv
,
1155 struct ospf6
*ospf6
, int idx_ipv4
,
1158 struct ospf6_neighbor
*on
;
1159 struct ospf6_interface
*oi
;
1160 struct ospf6_area
*oa
;
1161 struct listnode
*i
, *j
, *k
;
1162 void (*showfunc
)(struct vty
*, struct ospf6_neighbor
*,
1163 json_object
*json
, bool use_json
);
1165 json_object
*json
= NULL
;
1167 showfunc
= ospf6_neighbor_show_detail
;
1169 json
= json_object_new_object();
1171 if ((inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &router_id
)) != 1) {
1172 vty_out(vty
, "Router-ID is not parsable: %s\n",
1173 argv
[idx_ipv4
]->arg
);
1177 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
))
1178 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
))
1179 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
1180 if (router_id
== on
->router_id
)
1181 (*showfunc
)(vty
, on
, json
, uj
);
1185 vty_json(vty
, json
);
1190 DEFUN(show_ipv6_ospf6_neighbor_one
, show_ipv6_ospf6_neighbor_one_cmd
,
1191 "show ipv6 ospf6 [vrf <NAME|all>] neighbor A.B.C.D [json]",
1192 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1195 "Specify Router-ID as IPv4 address notation\n" JSON_STR
)
1198 struct ospf6
*ospf6
;
1199 struct listnode
*node
;
1200 const char *vrf_name
= NULL
;
1201 bool all_vrf
= false;
1203 bool uj
= use_json(argc
, argv
);
1205 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1209 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1210 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1211 ospf6_neighbor_show_common(vty
, argc
, argv
, ospf6
,
1219 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1224 void ospf6_neighbor_init(void)
1226 install_element(VIEW_NODE
, &show_ipv6_ospf6_neighbor_cmd
);
1227 install_element(VIEW_NODE
, &show_ipv6_ospf6_neighbor_one_cmd
);
1230 DEFUN (debug_ospf6_neighbor
,
1231 debug_ospf6_neighbor_cmd
,
1232 "debug ospf6 neighbor [<state|event>]",
1235 "Debug OSPFv3 Neighbor\n"
1236 "Debug OSPFv3 Neighbor State Change\n"
1237 "Debug OSPFv3 Neighbor Event\n")
1240 unsigned char level
= 0;
1243 if (!strncmp(argv
[idx_type
]->arg
, "s", 1))
1244 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
1245 else if (!strncmp(argv
[idx_type
]->arg
, "e", 1))
1246 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
1248 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
1250 OSPF6_DEBUG_NEIGHBOR_ON(level
);
1255 DEFUN (no_debug_ospf6_neighbor
,
1256 no_debug_ospf6_neighbor_cmd
,
1257 "no debug ospf6 neighbor [<state|event>]",
1261 "Debug OSPFv3 Neighbor\n"
1262 "Debug OSPFv3 Neighbor State Change\n"
1263 "Debug OSPFv3 Neighbor Event\n")
1266 unsigned char level
= 0;
1269 if (!strncmp(argv
[idx_type
]->arg
, "s", 1))
1270 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
1271 if (!strncmp(argv
[idx_type
]->arg
, "e", 1))
1272 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
1274 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
1276 OSPF6_DEBUG_NEIGHBOR_OFF(level
);
1281 DEFUN (no_debug_ospf6
,
1290 OSPF6_DEBUG_ABR_OFF();
1291 OSPF6_DEBUG_ASBR_OFF();
1292 OSPF6_DEBUG_BROUTER_OFF();
1293 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF();
1294 OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF();
1295 OSPF6_DEBUG_FLOODING_OFF();
1296 OSPF6_DEBUG_INTERFACE_OFF();
1298 ospf6_lsa_debug_set_all(false);
1300 for (i
= 0; i
< 6; i
++)
1301 OSPF6_DEBUG_MESSAGE_OFF(i
,
1302 OSPF6_DEBUG_NEIGHBOR_STATE
1303 | OSPF6_DEBUG_NEIGHBOR_EVENT
);
1305 OSPF6_DEBUG_NEIGHBOR_OFF(OSPF6_DEBUG_NEIGHBOR_STATE
1306 | OSPF6_DEBUG_NEIGHBOR_EVENT
);
1307 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_TABLE
);
1308 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTRA
);
1309 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTER
);
1310 OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_MEMORY
);
1311 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_PROCESS
);
1312 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_TIME
);
1313 OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_DATABASE
);
1314 OSPF6_DEBUG_ZEBRA_OFF(OSPF6_DEBUG_ZEBRA_SEND
| OSPF6_DEBUG_ZEBRA_RECV
);
1319 int config_write_ospf6_debug_neighbor(struct vty
*vty
)
1321 if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
) && IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
1322 vty_out(vty
, "debug ospf6 neighbor\n");
1323 else if (IS_OSPF6_DEBUG_NEIGHBOR(STATE
))
1324 vty_out(vty
, "debug ospf6 neighbor state\n");
1325 else if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT
))
1326 vty_out(vty
, "debug ospf6 neighbor event\n");
1330 void install_element_ospf6_debug_neighbor(void)
1332 install_element(ENABLE_NODE
, &debug_ospf6_neighbor_cmd
);
1333 install_element(ENABLE_NODE
, &no_debug_ospf6_neighbor_cmd
);
1334 install_element(ENABLE_NODE
, &no_debug_ospf6_cmd
);
1335 install_element(CONFIG_NODE
, &debug_ospf6_neighbor_cmd
);
1336 install_element(CONFIG_NODE
, &no_debug_ospf6_neighbor_cmd
);
1337 install_element(CONFIG_NODE
, &no_debug_ospf6_cmd
);