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
30 #include "ospf6_proto.h"
31 #include "ospf6_lsa.h"
32 #include "ospf6_lsdb.h"
33 #include "ospf6_message.h"
34 #include "ospf6_top.h"
35 #include "ospf6_area.h"
36 #include "ospf6_interface.h"
37 #include "ospf6_neighbor.h"
38 #include "ospf6_intra.h"
39 #include "ospf6_flood.h"
41 #include "ospf6_bfd.h"
42 #include "ospf6_abr.h"
43 #include "ospf6_asbr.h"
44 #include "ospf6_lsa.h"
45 #include "ospf6_spf.h"
46 #include "ospf6_zebra.h"
48 DEFINE_HOOK(ospf6_neighbor_change
,
49 (struct ospf6_neighbor
*on
, int state
, int next_state
),
50 (on
, state
, next_state
))
52 unsigned char conf_debug_ospf6_neighbor
= 0;
54 const char *ospf6_neighbor_state_str
[] =
55 { "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange",
56 "Loading", "Full", NULL
};
59 ospf6_neighbor_cmp (void *va
, void *vb
)
61 struct ospf6_neighbor
*ona
= (struct ospf6_neighbor
*) va
;
62 struct ospf6_neighbor
*onb
= (struct ospf6_neighbor
*) vb
;
63 return (ntohl (ona
->router_id
) < ntohl (onb
->router_id
) ? -1 : 1);
66 struct ospf6_neighbor
*
67 ospf6_neighbor_lookup (u_int32_t router_id
,
68 struct ospf6_interface
*oi
)
71 struct ospf6_neighbor
*on
;
73 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, n
, on
))
74 if (on
->router_id
== router_id
)
77 return (struct ospf6_neighbor
*) NULL
;
80 /* create ospf6_neighbor */
81 struct ospf6_neighbor
*
82 ospf6_neighbor_create (u_int32_t router_id
, struct ospf6_interface
*oi
)
84 struct ospf6_neighbor
*on
;
87 on
= (struct ospf6_neighbor
*)
88 XMALLOC (MTYPE_OSPF6_NEIGHBOR
, sizeof (struct ospf6_neighbor
));
91 zlog_warn ("neighbor: malloc failed");
95 memset (on
, 0, sizeof (struct ospf6_neighbor
));
96 inet_ntop (AF_INET
, &router_id
, buf
, sizeof (buf
));
97 snprintf (on
->name
, sizeof (on
->name
), "%s%%%s",
98 buf
, oi
->interface
->name
);
100 on
->state
= OSPF6_NEIGHBOR_DOWN
;
101 on
->state_change
= 0;
102 monotime(&on
->last_changed
);
103 on
->router_id
= router_id
;
105 on
->summary_list
= ospf6_lsdb_create (on
);
106 on
->request_list
= ospf6_lsdb_create (on
);
107 on
->retrans_list
= ospf6_lsdb_create (on
);
109 on
->dbdesc_list
= ospf6_lsdb_create (on
);
110 on
->lsupdate_list
= ospf6_lsdb_create (on
);
111 on
->lsack_list
= ospf6_lsdb_create (on
);
113 listnode_add_sort (oi
->neighbor_list
, on
);
115 ospf6_bfd_info_nbr_create(oi
, on
);
120 ospf6_neighbor_delete (struct ospf6_neighbor
*on
)
122 struct ospf6_lsa
*lsa
;
124 ospf6_lsdb_remove_all (on
->summary_list
);
125 ospf6_lsdb_remove_all (on
->request_list
);
126 for (ALL_LSDB(on
->retrans_list
, lsa
))
128 ospf6_decrement_retrans_count (lsa
);
129 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
132 ospf6_lsdb_remove_all (on
->dbdesc_list
);
133 ospf6_lsdb_remove_all (on
->lsupdate_list
);
134 ospf6_lsdb_remove_all (on
->lsack_list
);
136 ospf6_lsdb_delete (on
->summary_list
);
137 ospf6_lsdb_delete (on
->request_list
);
138 ospf6_lsdb_delete (on
->retrans_list
);
140 ospf6_lsdb_delete (on
->dbdesc_list
);
141 ospf6_lsdb_delete (on
->lsupdate_list
);
142 ospf6_lsdb_delete (on
->lsack_list
);
144 THREAD_OFF (on
->inactivity_timer
);
146 THREAD_OFF (on
->thread_send_dbdesc
);
147 THREAD_OFF (on
->thread_send_lsreq
);
148 THREAD_OFF (on
->thread_send_lsupdate
);
149 THREAD_OFF (on
->thread_send_lsack
);
151 ospf6_bfd_reg_dereg_nbr(on
, ZEBRA_BFD_DEST_DEREGISTER
);
152 XFREE (MTYPE_OSPF6_NEIGHBOR
, on
);
156 ospf6_neighbor_state_change (u_char next_state
, struct ospf6_neighbor
*on
, int event
)
160 prev_state
= on
->state
;
161 on
->state
= next_state
;
163 if (prev_state
== next_state
)
167 monotime(&on
->last_changed
);
170 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
))
172 zlog_debug ("Neighbor state change %s: [%s]->[%s] (%s)", on
->name
,
173 ospf6_neighbor_state_str
[prev_state
],
174 ospf6_neighbor_state_str
[next_state
],
175 ospf6_neighbor_event_string(event
));
178 /* Optionally notify about adjacency changes */
179 if (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
180 OSPF6_LOG_ADJACENCY_CHANGES
) &&
181 (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
182 OSPF6_LOG_ADJACENCY_DETAIL
) ||
183 (next_state
== OSPF6_NEIGHBOR_FULL
) || (next_state
< prev_state
)))
184 zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on
->name
,
185 ospf6_neighbor_state_str
[prev_state
],
186 ospf6_neighbor_state_str
[next_state
],
187 ospf6_neighbor_event_string(event
));
189 if (prev_state
== OSPF6_NEIGHBOR_FULL
|| next_state
== OSPF6_NEIGHBOR_FULL
)
191 OSPF6_ROUTER_LSA_SCHEDULE (on
->ospf6_if
->area
);
192 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
)
194 OSPF6_NETWORK_LSA_SCHEDULE (on
->ospf6_if
);
195 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on
->ospf6_if
);
197 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on
->ospf6_if
->area
);
200 if ((prev_state
== OSPF6_NEIGHBOR_EXCHANGE
||
201 prev_state
== OSPF6_NEIGHBOR_LOADING
) &&
202 (next_state
!= OSPF6_NEIGHBOR_EXCHANGE
&&
203 next_state
!= OSPF6_NEIGHBOR_LOADING
))
204 ospf6_maxage_remove (on
->ospf6_if
->area
->ospf6
);
206 hook_call(ospf6_neighbor_change
, on
, next_state
, prev_state
);
207 ospf6_bfd_trigger_event(on
, prev_state
, next_state
);
210 /* RFC2328 section 10.4 */
212 need_adjacency (struct ospf6_neighbor
*on
)
214 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_POINTTOPOINT
||
215 on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
||
216 on
->ospf6_if
->state
== OSPF6_INTERFACE_BDR
)
219 if (on
->ospf6_if
->drouter
== on
->router_id
||
220 on
->ospf6_if
->bdrouter
== on
->router_id
)
227 hello_received (struct thread
*thread
)
229 struct ospf6_neighbor
*on
;
231 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
234 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
235 zlog_debug ("Neighbor Event %s: *HelloReceived*", on
->name
);
237 /* reset Inactivity Timer */
238 THREAD_OFF (on
->inactivity_timer
);
239 on
->inactivity_timer
= NULL
;
240 thread_add_timer(master
, inactivity_timer
, on
, on
->ospf6_if
->dead_interval
,
241 &on
->inactivity_timer
);
243 if (on
->state
<= OSPF6_NEIGHBOR_DOWN
)
244 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT
, on
,
245 OSPF6_NEIGHBOR_EVENT_HELLO_RCVD
);
251 twoway_received (struct thread
*thread
)
253 struct ospf6_neighbor
*on
;
255 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
258 if (on
->state
> OSPF6_NEIGHBOR_INIT
)
261 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
262 zlog_debug ("Neighbor Event %s: *2Way-Received*", on
->name
);
264 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
266 if (! need_adjacency (on
))
268 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY
, on
,
269 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
273 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
274 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
275 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
276 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
277 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
279 THREAD_OFF (on
->thread_send_dbdesc
);
280 on
->thread_send_dbdesc
= NULL
;
281 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0, &on
->thread_send_dbdesc
);
287 negotiation_done (struct thread
*thread
)
289 struct ospf6_neighbor
*on
;
290 struct ospf6_lsa
*lsa
;
292 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
295 if (on
->state
!= OSPF6_NEIGHBOR_EXSTART
)
298 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
299 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on
->name
);
302 ospf6_lsdb_remove_all (on
->summary_list
);
303 ospf6_lsdb_remove_all (on
->request_list
);
304 for (ALL_LSDB(on
->retrans_list
, lsa
))
306 ospf6_decrement_retrans_count (lsa
);
307 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
310 /* Interface scoped LSAs */
311 for (ALL_LSDB(on
->ospf6_if
->lsdb
, lsa
))
313 if (OSPF6_LSA_IS_MAXAGE (lsa
))
315 ospf6_increment_retrans_count (lsa
);
316 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
319 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
322 /* Area scoped LSAs */
323 for (ALL_LSDB(on
->ospf6_if
->area
->lsdb
, lsa
))
325 if (OSPF6_LSA_IS_MAXAGE (lsa
))
327 ospf6_increment_retrans_count (lsa
);
328 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
331 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
335 for (ALL_LSDB(on
->ospf6_if
->area
->ospf6
->lsdb
, lsa
))
337 if (OSPF6_LSA_IS_MAXAGE (lsa
))
339 ospf6_increment_retrans_count (lsa
);
340 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
343 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
346 UNSET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
347 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE
, on
,
348 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE
);
354 exchange_done (struct thread
*thread
)
356 struct ospf6_neighbor
*on
;
358 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
361 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
)
364 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
365 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on
->name
);
367 THREAD_OFF (on
->thread_send_dbdesc
);
368 ospf6_lsdb_remove_all (on
->dbdesc_list
);
371 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
372 on->ospf6_if->dead_interval);
375 if (on
->request_list
->count
== 0)
376 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL
, on
,
377 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
380 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING
, on
,
381 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
383 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
384 &on
->thread_send_lsreq
);
390 /* Check loading state. */
392 ospf6_check_nbr_loading (struct ospf6_neighbor
*on
)
395 /* RFC2328 Section 10.9: When the neighbor responds to these requests
396 with the proper Link State Update packet(s), the Link state request
397 list is truncated and a new Link State Request packet is sent.
399 if ((on
->state
== OSPF6_NEIGHBOR_LOADING
) ||
400 (on
->state
== OSPF6_NEIGHBOR_EXCHANGE
))
402 if (on
->request_list
->count
== 0)
403 thread_add_event(master
, loading_done
, on
, 0, NULL
);
404 else if (on
->last_ls_req
== NULL
)
406 if (on
->thread_send_lsreq
!= NULL
)
407 THREAD_OFF (on
->thread_send_lsreq
);
408 on
->thread_send_lsreq
= NULL
;
409 thread_add_event(master
, ospf6_lsreq_send
, on
, 0,
410 &on
->thread_send_lsreq
);
416 loading_done (struct thread
*thread
)
418 struct ospf6_neighbor
*on
;
420 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
423 if (on
->state
!= OSPF6_NEIGHBOR_LOADING
)
426 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
427 zlog_debug ("Neighbor Event %s: *LoadingDone*", on
->name
);
429 assert (on
->request_list
->count
== 0);
431 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL
, on
,
432 OSPF6_NEIGHBOR_EVENT_LOADING_DONE
);
438 adj_ok (struct thread
*thread
)
440 struct ospf6_neighbor
*on
;
441 struct ospf6_lsa
*lsa
;
443 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
446 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
447 zlog_debug ("Neighbor Event %s: *AdjOK?*", on
->name
);
449 if (on
->state
== OSPF6_NEIGHBOR_TWOWAY
&& need_adjacency (on
))
451 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
452 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
453 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
454 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
455 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
457 THREAD_OFF (on
->thread_send_dbdesc
);
458 on
->thread_send_dbdesc
= NULL
;
459 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0,
460 &on
->thread_send_dbdesc
);
463 else if (on
->state
>= OSPF6_NEIGHBOR_EXSTART
&&
464 ! need_adjacency (on
))
466 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY
, on
,
467 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
468 ospf6_lsdb_remove_all (on
->summary_list
);
469 ospf6_lsdb_remove_all (on
->request_list
);
470 for (ALL_LSDB(on
->retrans_list
, lsa
))
472 ospf6_decrement_retrans_count (lsa
);
473 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
481 seqnumber_mismatch (struct thread
*thread
)
483 struct ospf6_neighbor
*on
;
484 struct ospf6_lsa
*lsa
;
486 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
489 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
492 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
493 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on
->name
);
495 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
496 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH
);
497 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
498 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
499 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
501 ospf6_lsdb_remove_all (on
->summary_list
);
502 ospf6_lsdb_remove_all (on
->request_list
);
503 for (ALL_LSDB(on
->retrans_list
, lsa
))
505 ospf6_decrement_retrans_count (lsa
);
506 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
509 THREAD_OFF (on
->thread_send_dbdesc
);
510 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
512 on
->thread_send_dbdesc
= NULL
;
513 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0, &on
->thread_send_dbdesc
);
519 bad_lsreq (struct thread
*thread
)
521 struct ospf6_neighbor
*on
;
522 struct ospf6_lsa
*lsa
;
524 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
527 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
530 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
531 zlog_debug ("Neighbor Event %s: *BadLSReq*", on
->name
);
533 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
534 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ
);
535 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
536 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
537 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
539 ospf6_lsdb_remove_all (on
->summary_list
);
540 ospf6_lsdb_remove_all (on
->request_list
);
541 for (ALL_LSDB(on
->retrans_list
, lsa
))
543 ospf6_decrement_retrans_count (lsa
);
544 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
547 THREAD_OFF (on
->thread_send_dbdesc
);
548 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
550 on
->thread_send_dbdesc
= NULL
;
551 thread_add_event(master
, ospf6_dbdesc_send
, on
, 0, &on
->thread_send_dbdesc
);
557 oneway_received (struct thread
*thread
)
559 struct ospf6_neighbor
*on
;
560 struct ospf6_lsa
*lsa
;
562 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
565 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
568 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
569 zlog_debug ("Neighbor Event %s: *1Way-Received*", on
->name
);
571 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT
, on
,
572 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD
);
573 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
575 ospf6_lsdb_remove_all (on
->summary_list
);
576 ospf6_lsdb_remove_all (on
->request_list
);
577 for (ALL_LSDB(on
->retrans_list
, lsa
))
579 ospf6_decrement_retrans_count (lsa
);
580 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
583 THREAD_OFF (on
->thread_send_dbdesc
);
584 THREAD_OFF (on
->thread_send_lsreq
);
585 THREAD_OFF (on
->thread_send_lsupdate
);
586 THREAD_OFF (on
->thread_send_lsack
);
592 inactivity_timer (struct thread
*thread
)
594 struct ospf6_neighbor
*on
;
596 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
599 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
600 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on
->name
);
602 on
->inactivity_timer
= NULL
;
603 on
->drouter
= on
->prev_drouter
= 0;
604 on
->bdrouter
= on
->prev_bdrouter
= 0;
606 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN
, on
,
607 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER
);
608 thread_add_event(master
, neighbor_change
, on
->ospf6_if
, 0, NULL
);
610 listnode_delete (on
->ospf6_if
->neighbor_list
, on
);
611 ospf6_neighbor_delete (on
);
619 /* show neighbor structure */
621 ospf6_neighbor_show (struct vty
*vty
, struct ospf6_neighbor
*on
)
630 /* Router-ID (Name) */
631 inet_ntop (AF_INET
, &on
->router_id
, router_id
, sizeof (router_id
));
632 #ifdef HAVE_GETNAMEINFO
635 #endif /*HAVE_GETNAMEINFO*/
639 if (on
->inactivity_timer
)
641 s
= monotime_until(&on
->inactivity_timer
->u
.sands
, NULL
) / 1000000LL;
647 snprintf (deadtime
, sizeof (deadtime
), "%02ld:%02ld:%02ld", h
, m
, s
);
650 if (if_is_pointopoint (on
->ospf6_if
->interface
))
651 snprintf (nstate
, sizeof (nstate
), "PointToPoint");
654 if (on
->router_id
== on
->drouter
)
655 snprintf (nstate
, sizeof (nstate
), "DR");
656 else if (on
->router_id
== on
->bdrouter
)
657 snprintf (nstate
, sizeof (nstate
), "BDR");
659 snprintf (nstate
, sizeof (nstate
), "DROther");
663 monotime_since(&on
->last_changed
, &res
);
664 timerstring (&res
, duration
, sizeof (duration
));
667 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n",
668 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
672 vty_out (vty
, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n",
673 router_id
, on
->priority
, deadtime
,
674 ospf6_neighbor_state_str
[on
->state
], nstate
, duration
,
675 on
->ospf6_if
->interface
->name
,
676 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
680 ospf6_neighbor_show_drchoice (struct vty
*vty
, struct ospf6_neighbor
*on
)
683 char drouter
[16], bdrouter
[16];
685 struct timeval now
, res
;
688 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n",
689 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
693 inet_ntop (AF_INET
, &on
->router_id
, router_id
, sizeof (router_id
));
694 inet_ntop (AF_INET
, &on
->drouter
, drouter
, sizeof (drouter
));
695 inet_ntop (AF_INET
, &on
->bdrouter
, bdrouter
, sizeof (bdrouter
));
698 timersub (&now
, &on
->last_changed
, &res
);
699 timerstring (&res
, duration
, sizeof (duration
));
701 vty_out (vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n",
702 router_id
, ospf6_neighbor_state_str
[on
->state
],
703 duration
, drouter
, bdrouter
, on
->ospf6_if
->interface
->name
,
704 ospf6_interface_state_str
[on
->ospf6_if
->state
]);
708 ospf6_neighbor_show_detail (struct vty
*vty
, struct ospf6_neighbor
*on
)
710 char drouter
[16], bdrouter
[16];
711 char linklocal_addr
[64], duration
[32];
712 struct timeval now
, res
;
713 struct ospf6_lsa
*lsa
;
715 inet_ntop (AF_INET6
, &on
->linklocal_addr
, linklocal_addr
,
716 sizeof (linklocal_addr
));
717 inet_ntop (AF_INET
, &on
->drouter
, drouter
, sizeof (drouter
));
718 inet_ntop (AF_INET
, &on
->bdrouter
, bdrouter
, sizeof (bdrouter
));
721 timersub (&now
, &on
->last_changed
, &res
);
722 timerstring (&res
, duration
, sizeof (duration
));
724 vty_out (vty
, " Neighbor %s\n", on
->name
);
725 vty_out (vty
, " Area %s via interface %s (ifindex %d)\n",
726 on
->ospf6_if
->area
->name
,
727 on
->ospf6_if
->interface
->name
,
728 on
->ospf6_if
->interface
->ifindex
);
729 vty_out (vty
, " His IfIndex: %d Link-local address: %s\n",
730 on
->ifindex
, linklocal_addr
);
731 vty_out (vty
, " State %s for a duration of %s\n",
732 ospf6_neighbor_state_str
[on
->state
], duration
);
733 vty_out (vty
, " His choice of DR/BDR %s/%s, Priority %d\n",
734 drouter
, bdrouter
, on
->priority
);
735 vty_out (vty
, " DbDesc status: %s%s%s SeqNum: %#lx\n",
736 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
) ? "Initial " : ""),
737 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
) ? "More " : ""),
738 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
) ?
739 "Master" : "Slave"), (u_long
) ntohl (on
->dbdesc_seqnum
));
741 vty_out (vty
, " Summary-List: %d LSAs\n", on
->summary_list
->count
);
742 for (ALL_LSDB(on
->summary_list
, lsa
))
743 vty_out (vty
, " %s\n", lsa
->name
);
745 vty_out (vty
, " Request-List: %d LSAs\n", on
->request_list
->count
);
746 for (ALL_LSDB(on
->request_list
, lsa
))
747 vty_out (vty
, " %s\n", lsa
->name
);
749 vty_out (vty
, " Retrans-List: %d LSAs\n", on
->retrans_list
->count
);
750 for (ALL_LSDB(on
->retrans_list
, lsa
))
751 vty_out (vty
, " %s\n", lsa
->name
);
754 if (on
->thread_send_dbdesc
)
755 timersub (&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
756 timerstring (&res
, duration
, sizeof (duration
));
757 vty_out (vty
, " %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
758 on
->dbdesc_list
->count
, duration
,
759 (on
->thread_send_dbdesc
? "on" : "off"));
760 for (ALL_LSDB(on
->dbdesc_list
, lsa
))
761 vty_out (vty
, " %s\n", lsa
->name
);
764 if (on
->thread_send_lsreq
)
765 timersub (&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
766 timerstring (&res
, duration
, sizeof (duration
));
767 vty_out (vty
, " %d Pending LSAs for LSReq in Time %s [thread %s]\n",
768 on
->request_list
->count
, duration
,
769 (on
->thread_send_lsreq
? "on" : "off"));
770 for (ALL_LSDB(on
->request_list
, lsa
))
771 vty_out (vty
, " %s\n", lsa
->name
);
774 if (on
->thread_send_lsupdate
)
775 timersub (&on
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
776 timerstring (&res
, duration
, sizeof (duration
));
777 vty_out (vty
, " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
778 on
->lsupdate_list
->count
, duration
,
779 (on
->thread_send_lsupdate
? "on" : "off"));
780 for (ALL_LSDB(on
->lsupdate_list
, lsa
))
781 vty_out (vty
, " %s\n", lsa
->name
);
784 if (on
->thread_send_lsack
)
785 timersub (&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
786 timerstring (&res
, duration
, sizeof (duration
));
787 vty_out (vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
788 on
->lsack_list
->count
, duration
,
789 (on
->thread_send_lsack
? "on" : "off"));
790 for (ALL_LSDB(on
->lsack_list
, lsa
))
791 vty_out (vty
, " %s\n", lsa
->name
);
793 ospf6_bfd_show_info(vty
, on
->bfd_info
, 0);
796 DEFUN (show_ipv6_ospf6_neighbor
,
797 show_ipv6_ospf6_neighbor_cmd
,
798 "show ipv6 ospf6 neighbor [<detail|drchoice>]",
804 "Display DR choices\n")
807 struct ospf6_neighbor
*on
;
808 struct ospf6_interface
*oi
;
809 struct ospf6_area
*oa
;
810 struct listnode
*i
, *j
, *k
;
811 void (*showfunc
) (struct vty
*, struct ospf6_neighbor
*);
813 OSPF6_CMD_CHECK_RUNNING ();
814 showfunc
= ospf6_neighbor_show
;
818 if (! strncmp (argv
[idx_type
]->arg
, "de", 2))
819 showfunc
= ospf6_neighbor_show_detail
;
820 else if (! strncmp (argv
[idx_type
]->arg
, "dr", 2))
821 showfunc
= ospf6_neighbor_show_drchoice
;
824 if (showfunc
== ospf6_neighbor_show
)
825 vty_out (vty
, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n",
826 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
828 else if (showfunc
== ospf6_neighbor_show_drchoice
)
829 vty_out (vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n",
830 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
833 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, i
, oa
))
834 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
835 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, k
, on
))
836 (*showfunc
) (vty
, on
);
842 DEFUN (show_ipv6_ospf6_neighbor_one
,
843 show_ipv6_ospf6_neighbor_one_cmd
,
844 "show ipv6 ospf6 neighbor A.B.C.D",
849 "Specify Router-ID as IPv4 address notation\n"
853 struct ospf6_neighbor
*on
;
854 struct ospf6_interface
*oi
;
855 struct ospf6_area
*oa
;
856 struct listnode
*i
, *j
, *k
;
857 void (*showfunc
) (struct vty
*, struct ospf6_neighbor
*);
860 OSPF6_CMD_CHECK_RUNNING ();
861 showfunc
= ospf6_neighbor_show_detail
;
863 if ((inet_pton (AF_INET
, argv
[idx_ipv4
]->arg
, &router_id
)) != 1)
865 vty_out (vty
, "Router-ID is not parsable: %s\n", argv
[idx_ipv4
]->arg
);
869 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, i
, oa
))
870 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
871 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, k
, on
))
872 (*showfunc
) (vty
, on
);
878 ospf6_neighbor_init (void)
880 install_element (VIEW_NODE
, &show_ipv6_ospf6_neighbor_cmd
);
881 install_element (VIEW_NODE
, &show_ipv6_ospf6_neighbor_one_cmd
);
884 DEFUN (debug_ospf6_neighbor
,
885 debug_ospf6_neighbor_cmd
,
886 "debug ospf6 neighbor [<state|event>]",
889 "Debug OSPFv3 Neighbor\n"
890 "Debug OSPFv3 Neighbor State Change\n"
891 "Debug OSPFv3 Neighbor Event\n")
894 unsigned char level
= 0;
898 if (! strncmp (argv
[idx_type
]->arg
, "s", 1))
899 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
900 else if (! strncmp (argv
[idx_type
]->arg
, "e", 1))
901 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
904 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
906 OSPF6_DEBUG_NEIGHBOR_ON (level
);
911 DEFUN (no_debug_ospf6_neighbor
,
912 no_debug_ospf6_neighbor_cmd
,
913 "no debug ospf6 neighbor [<state|event>]",
917 "Debug OSPFv3 Neighbor\n"
918 "Debug OSPFv3 Neighbor State Change\n"
919 "Debug OSPFv3 Neighbor Event\n")
922 unsigned char level
= 0;
926 if (! strncmp (argv
[idx_type
]->arg
, "s", 1))
927 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
928 if (! strncmp (argv
[idx_type
]->arg
, "e", 1))
929 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
932 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
934 OSPF6_DEBUG_NEIGHBOR_OFF (level
);
939 DEFUN (no_debug_ospf6
,
947 struct ospf6_lsa_handler
*handler
= NULL
;
949 OSPF6_DEBUG_ABR_OFF ();
950 OSPF6_DEBUG_ASBR_OFF ();
951 OSPF6_DEBUG_BROUTER_OFF ();
952 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF ();
953 OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF ();
954 OSPF6_DEBUG_FLOODING_OFF ();
955 OSPF6_DEBUG_INTERFACE_OFF ();
957 for (i
= 0; i
< vector_active (ospf6_lsa_handler_vector
); i
++)
959 handler
= vector_slot (ospf6_lsa_handler_vector
, i
);
963 UNSET_FLAG (handler
->debug
, OSPF6_LSA_DEBUG
);
967 for (i
= 0; i
< 6; i
++)
968 OSPF6_DEBUG_MESSAGE_OFF (i
, OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
);
970 OSPF6_DEBUG_NEIGHBOR_OFF (OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
);
971 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_TABLE
);
972 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_INTRA
);
973 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_INTER
);
974 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_MEMORY
);
975 OSPF6_DEBUG_SPF_OFF (OSPF6_DEBUG_SPF_PROCESS
);
976 OSPF6_DEBUG_SPF_OFF (OSPF6_DEBUG_SPF_TIME
);
977 OSPF6_DEBUG_SPF_OFF (OSPF6_DEBUG_SPF_DATABASE
);
978 OSPF6_DEBUG_ZEBRA_OFF (OSPF6_DEBUG_ZEBRA_SEND
| OSPF6_DEBUG_ZEBRA_RECV
);
984 config_write_ospf6_debug_neighbor (struct vty
*vty
)
986 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
) &&
987 IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
988 vty_out (vty
, "debug ospf6 neighbor\n");
989 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
))
990 vty_out (vty
, "debug ospf6 neighbor state\n");
991 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
992 vty_out (vty
, "debug ospf6 neighbor event\n");
997 install_element_ospf6_debug_neighbor (void)
999 install_element (ENABLE_NODE
, &debug_ospf6_neighbor_cmd
);
1000 install_element (ENABLE_NODE
, &no_debug_ospf6_neighbor_cmd
);
1001 install_element (ENABLE_NODE
, &no_debug_ospf6_cmd
);
1002 install_element (CONFIG_NODE
, &debug_ospf6_neighbor_cmd
);
1003 install_element (CONFIG_NODE
, &no_debug_ospf6_neighbor_cmd
);
1004 install_element (CONFIG_NODE
, &no_debug_ospf6_cmd
);