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
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
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"
49 DEFINE_HOOK(ospf6_neighbor_change
,
50 (struct ospf6_neighbor
*on
, int state
, int next_state
),
51 (on
, state
, next_state
))
53 unsigned char conf_debug_ospf6_neighbor
= 0;
55 const char *ospf6_neighbor_state_str
[] =
56 { "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange",
57 "Loading", "Full", NULL
};
60 ospf6_neighbor_cmp (void *va
, void *vb
)
62 struct ospf6_neighbor
*ona
= (struct ospf6_neighbor
*) va
;
63 struct ospf6_neighbor
*onb
= (struct ospf6_neighbor
*) vb
;
64 return (ntohl (ona
->router_id
) < ntohl (onb
->router_id
) ? -1 : 1);
67 struct ospf6_neighbor
*
68 ospf6_neighbor_lookup (u_int32_t router_id
,
69 struct ospf6_interface
*oi
)
72 struct ospf6_neighbor
*on
;
74 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, n
, on
))
75 if (on
->router_id
== router_id
)
78 return (struct ospf6_neighbor
*) NULL
;
81 /* create ospf6_neighbor */
82 struct ospf6_neighbor
*
83 ospf6_neighbor_create (u_int32_t router_id
, struct ospf6_interface
*oi
)
85 struct ospf6_neighbor
*on
;
88 on
= (struct ospf6_neighbor
*)
89 XMALLOC (MTYPE_OSPF6_NEIGHBOR
, sizeof (struct ospf6_neighbor
));
92 zlog_warn ("neighbor: malloc failed");
96 memset (on
, 0, sizeof (struct ospf6_neighbor
));
97 inet_ntop (AF_INET
, &router_id
, buf
, sizeof (buf
));
98 snprintf (on
->name
, sizeof (on
->name
), "%s%%%s",
99 buf
, oi
->interface
->name
);
101 on
->state
= OSPF6_NEIGHBOR_DOWN
;
102 on
->state_change
= 0;
103 monotime(&on
->last_changed
);
104 on
->router_id
= router_id
;
106 on
->summary_list
= ospf6_lsdb_create (on
);
107 on
->request_list
= ospf6_lsdb_create (on
);
108 on
->retrans_list
= ospf6_lsdb_create (on
);
110 on
->dbdesc_list
= ospf6_lsdb_create (on
);
111 on
->lsupdate_list
= ospf6_lsdb_create (on
);
112 on
->lsack_list
= ospf6_lsdb_create (on
);
114 listnode_add_sort (oi
->neighbor_list
, on
);
116 ospf6_bfd_info_nbr_create(oi
, on
);
121 ospf6_neighbor_delete (struct ospf6_neighbor
*on
)
123 struct ospf6_lsa
*lsa
;
125 ospf6_lsdb_remove_all (on
->summary_list
);
126 ospf6_lsdb_remove_all (on
->request_list
);
127 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
128 lsa
= ospf6_lsdb_next (lsa
))
130 ospf6_decrement_retrans_count (lsa
);
131 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
134 ospf6_lsdb_remove_all (on
->dbdesc_list
);
135 ospf6_lsdb_remove_all (on
->lsupdate_list
);
136 ospf6_lsdb_remove_all (on
->lsack_list
);
138 ospf6_lsdb_delete (on
->summary_list
);
139 ospf6_lsdb_delete (on
->request_list
);
140 ospf6_lsdb_delete (on
->retrans_list
);
142 ospf6_lsdb_delete (on
->dbdesc_list
);
143 ospf6_lsdb_delete (on
->lsupdate_list
);
144 ospf6_lsdb_delete (on
->lsack_list
);
146 THREAD_OFF (on
->inactivity_timer
);
148 THREAD_OFF (on
->thread_send_dbdesc
);
149 THREAD_OFF (on
->thread_send_lsreq
);
150 THREAD_OFF (on
->thread_send_lsupdate
);
151 THREAD_OFF (on
->thread_send_lsack
);
153 ospf6_bfd_reg_dereg_nbr(on
, ZEBRA_BFD_DEST_DEREGISTER
);
154 XFREE (MTYPE_OSPF6_NEIGHBOR
, on
);
158 ospf6_neighbor_state_change (u_char next_state
, struct ospf6_neighbor
*on
, int event
)
162 prev_state
= on
->state
;
163 on
->state
= next_state
;
165 if (prev_state
== next_state
)
169 monotime(&on
->last_changed
);
172 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
))
174 zlog_debug ("Neighbor state change %s: [%s]->[%s] (%s)", on
->name
,
175 ospf6_neighbor_state_str
[prev_state
],
176 ospf6_neighbor_state_str
[next_state
],
177 ospf6_neighbor_event_string(event
));
180 /* Optionally notify about adjacency changes */
181 if (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
182 OSPF6_LOG_ADJACENCY_CHANGES
) &&
183 (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
184 OSPF6_LOG_ADJACENCY_DETAIL
) ||
185 (next_state
== OSPF6_NEIGHBOR_FULL
) || (next_state
< prev_state
)))
186 zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on
->name
,
187 ospf6_neighbor_state_str
[prev_state
],
188 ospf6_neighbor_state_str
[next_state
],
189 ospf6_neighbor_event_string(event
));
191 if (prev_state
== OSPF6_NEIGHBOR_FULL
|| next_state
== OSPF6_NEIGHBOR_FULL
)
193 OSPF6_ROUTER_LSA_SCHEDULE (on
->ospf6_if
->area
);
194 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
)
196 OSPF6_NETWORK_LSA_SCHEDULE (on
->ospf6_if
);
197 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on
->ospf6_if
);
199 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on
->ospf6_if
->area
);
202 if ((prev_state
== OSPF6_NEIGHBOR_EXCHANGE
||
203 prev_state
== OSPF6_NEIGHBOR_LOADING
) &&
204 (next_state
!= OSPF6_NEIGHBOR_EXCHANGE
&&
205 next_state
!= OSPF6_NEIGHBOR_LOADING
))
206 ospf6_maxage_remove (on
->ospf6_if
->area
->ospf6
);
208 hook_call(ospf6_neighbor_change
, on
, next_state
, prev_state
);
209 ospf6_bfd_trigger_event(on
, prev_state
, next_state
);
212 /* RFC2328 section 10.4 */
214 need_adjacency (struct ospf6_neighbor
*on
)
216 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_POINTTOPOINT
||
217 on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
||
218 on
->ospf6_if
->state
== OSPF6_INTERFACE_BDR
)
221 if (on
->ospf6_if
->drouter
== on
->router_id
||
222 on
->ospf6_if
->bdrouter
== on
->router_id
)
229 hello_received (struct thread
*thread
)
231 struct ospf6_neighbor
*on
;
233 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
236 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
237 zlog_debug ("Neighbor Event %s: *HelloReceived*", on
->name
);
239 /* reset Inactivity Timer */
240 THREAD_OFF (on
->inactivity_timer
);
241 on
->inactivity_timer
= thread_add_timer (master
, inactivity_timer
, on
,
242 on
->ospf6_if
->dead_interval
);
244 if (on
->state
<= OSPF6_NEIGHBOR_DOWN
)
245 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT
, on
,
246 OSPF6_NEIGHBOR_EVENT_HELLO_RCVD
);
252 twoway_received (struct thread
*thread
)
254 struct ospf6_neighbor
*on
;
256 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
259 if (on
->state
> OSPF6_NEIGHBOR_INIT
)
262 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
263 zlog_debug ("Neighbor Event %s: *2Way-Received*", on
->name
);
265 thread_add_event (master
, neighbor_change
, on
->ospf6_if
, 0);
267 if (! need_adjacency (on
))
269 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY
, on
,
270 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
274 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
275 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
276 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
277 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
278 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
280 THREAD_OFF (on
->thread_send_dbdesc
);
281 on
->thread_send_dbdesc
=
282 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
288 negotiation_done (struct thread
*thread
)
290 struct ospf6_neighbor
*on
;
291 struct ospf6_lsa
*lsa
;
293 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
296 if (on
->state
!= OSPF6_NEIGHBOR_EXSTART
)
299 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
300 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on
->name
);
303 ospf6_lsdb_remove_all (on
->summary_list
);
304 ospf6_lsdb_remove_all (on
->request_list
);
305 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
306 lsa
= ospf6_lsdb_next (lsa
))
308 ospf6_decrement_retrans_count (lsa
);
309 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
312 /* Interface scoped LSAs */
313 for (lsa
= ospf6_lsdb_head (on
->ospf6_if
->lsdb
); lsa
;
314 lsa
= ospf6_lsdb_next (lsa
))
316 if (OSPF6_LSA_IS_MAXAGE (lsa
))
318 ospf6_increment_retrans_count (lsa
);
319 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
322 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
325 /* Area scoped LSAs */
326 for (lsa
= ospf6_lsdb_head (on
->ospf6_if
->area
->lsdb
); lsa
;
327 lsa
= ospf6_lsdb_next (lsa
))
329 if (OSPF6_LSA_IS_MAXAGE (lsa
))
331 ospf6_increment_retrans_count (lsa
);
332 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
335 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
339 for (lsa
= ospf6_lsdb_head (on
->ospf6_if
->area
->ospf6
->lsdb
); lsa
;
340 lsa
= ospf6_lsdb_next (lsa
))
342 if (OSPF6_LSA_IS_MAXAGE (lsa
))
344 ospf6_increment_retrans_count (lsa
);
345 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
348 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
351 UNSET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
352 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE
, on
,
353 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE
);
359 exchange_done (struct thread
*thread
)
361 struct ospf6_neighbor
*on
;
363 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
366 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
)
369 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
370 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on
->name
);
372 THREAD_OFF (on
->thread_send_dbdesc
);
373 ospf6_lsdb_remove_all (on
->dbdesc_list
);
376 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
377 on->ospf6_if->dead_interval);
380 if (on
->request_list
->count
== 0)
381 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL
, on
,
382 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
385 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING
, on
,
386 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
388 if (on
->thread_send_lsreq
== NULL
)
389 on
->thread_send_lsreq
=
390 thread_add_event (master
, ospf6_lsreq_send
, on
, 0);
396 /* Check loading state. */
398 ospf6_check_nbr_loading (struct ospf6_neighbor
*on
)
401 /* RFC2328 Section 10.9: When the neighbor responds to these requests
402 with the proper Link State Update packet(s), the Link state request
403 list is truncated and a new Link State Request packet is sent.
405 if ((on
->state
== OSPF6_NEIGHBOR_LOADING
) ||
406 (on
->state
== OSPF6_NEIGHBOR_EXCHANGE
))
408 if (on
->request_list
->count
== 0)
409 thread_add_event (master
, loading_done
, on
, 0);
410 else if (on
->last_ls_req
== NULL
)
412 if (on
->thread_send_lsreq
!= NULL
)
413 THREAD_OFF (on
->thread_send_lsreq
);
414 on
->thread_send_lsreq
=
415 thread_add_event (master
, ospf6_lsreq_send
, on
, 0);
421 loading_done (struct thread
*thread
)
423 struct ospf6_neighbor
*on
;
425 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
428 if (on
->state
!= OSPF6_NEIGHBOR_LOADING
)
431 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
432 zlog_debug ("Neighbor Event %s: *LoadingDone*", on
->name
);
434 assert (on
->request_list
->count
== 0);
436 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL
, on
,
437 OSPF6_NEIGHBOR_EVENT_LOADING_DONE
);
443 adj_ok (struct thread
*thread
)
445 struct ospf6_neighbor
*on
;
446 struct ospf6_lsa
*lsa
;
448 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
451 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
452 zlog_debug ("Neighbor Event %s: *AdjOK?*", on
->name
);
454 if (on
->state
== OSPF6_NEIGHBOR_TWOWAY
&& need_adjacency (on
))
456 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
457 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
458 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
459 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
460 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
462 THREAD_OFF (on
->thread_send_dbdesc
);
463 on
->thread_send_dbdesc
=
464 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
467 else if (on
->state
>= OSPF6_NEIGHBOR_EXSTART
&&
468 ! need_adjacency (on
))
470 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY
, on
,
471 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
472 ospf6_lsdb_remove_all (on
->summary_list
);
473 ospf6_lsdb_remove_all (on
->request_list
);
474 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
475 lsa
= ospf6_lsdb_next (lsa
))
477 ospf6_decrement_retrans_count (lsa
);
478 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
486 seqnumber_mismatch (struct thread
*thread
)
488 struct ospf6_neighbor
*on
;
489 struct ospf6_lsa
*lsa
;
491 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
494 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
497 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
498 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on
->name
);
500 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
501 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH
);
502 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
503 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
504 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
506 ospf6_lsdb_remove_all (on
->summary_list
);
507 ospf6_lsdb_remove_all (on
->request_list
);
508 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
509 lsa
= ospf6_lsdb_next (lsa
))
511 ospf6_decrement_retrans_count (lsa
);
512 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
515 THREAD_OFF (on
->thread_send_dbdesc
);
516 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
518 on
->thread_send_dbdesc
=
519 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
525 bad_lsreq (struct thread
*thread
)
527 struct ospf6_neighbor
*on
;
528 struct ospf6_lsa
*lsa
;
530 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
533 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
536 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
537 zlog_debug ("Neighbor Event %s: *BadLSReq*", on
->name
);
539 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
540 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ
);
541 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
542 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
543 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
545 ospf6_lsdb_remove_all (on
->summary_list
);
546 ospf6_lsdb_remove_all (on
->request_list
);
547 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
548 lsa
= ospf6_lsdb_next (lsa
))
550 ospf6_decrement_retrans_count (lsa
);
551 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
554 THREAD_OFF (on
->thread_send_dbdesc
);
555 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
557 on
->thread_send_dbdesc
=
558 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
564 oneway_received (struct thread
*thread
)
566 struct ospf6_neighbor
*on
;
567 struct ospf6_lsa
*lsa
;
569 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
572 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
575 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
576 zlog_debug ("Neighbor Event %s: *1Way-Received*", on
->name
);
578 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT
, on
,
579 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD
);
580 thread_add_event (master
, neighbor_change
, on
->ospf6_if
, 0);
582 ospf6_lsdb_remove_all (on
->summary_list
);
583 ospf6_lsdb_remove_all (on
->request_list
);
584 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
585 lsa
= ospf6_lsdb_next (lsa
))
587 ospf6_decrement_retrans_count (lsa
);
588 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
591 THREAD_OFF (on
->thread_send_dbdesc
);
592 THREAD_OFF (on
->thread_send_lsreq
);
593 THREAD_OFF (on
->thread_send_lsupdate
);
594 THREAD_OFF (on
->thread_send_lsack
);
600 inactivity_timer (struct thread
*thread
)
602 struct ospf6_neighbor
*on
;
604 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
607 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
608 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on
->name
);
610 on
->inactivity_timer
= NULL
;
611 on
->drouter
= on
->prev_drouter
= 0;
612 on
->bdrouter
= on
->prev_bdrouter
= 0;
614 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN
, on
,
615 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER
);
616 thread_add_event (master
, neighbor_change
, on
->ospf6_if
, 0);
618 listnode_delete (on
->ospf6_if
->neighbor_list
, on
);
619 ospf6_neighbor_delete (on
);
627 /* show neighbor structure */
629 ospf6_neighbor_show (struct vty
*vty
, struct ospf6_neighbor
*on
)
638 /* Router-ID (Name) */
639 inet_ntop (AF_INET
, &on
->router_id
, router_id
, sizeof (router_id
));
640 #ifdef HAVE_GETNAMEINFO
643 #endif /*HAVE_GETNAMEINFO*/
647 if (on
->inactivity_timer
)
649 s
= monotime_until(&on
->inactivity_timer
->u
.sands
, NULL
) / 1000000LL;
655 snprintf (deadtime
, sizeof (deadtime
), "%02ld:%02ld:%02ld", h
, m
, s
);
658 if (if_is_pointopoint (on
->ospf6_if
->interface
))
659 snprintf (nstate
, sizeof (nstate
), "PointToPoint");
662 if (on
->router_id
== on
->drouter
)
663 snprintf (nstate
, sizeof (nstate
), "DR");
664 else if (on
->router_id
== on
->bdrouter
)
665 snprintf (nstate
, sizeof (nstate
), "BDR");
667 snprintf (nstate
, sizeof (nstate
), "DROther");
671 monotime_since(&on
->last_changed
, &res
);
672 timerstring (&res
, duration
, sizeof (duration
));
675 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
676 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
677 "I/F", "State", VNL);
680 vty_out (vty
, "%-15s %3d %11s %8s/%-12s %11s %s[%s]%s",
681 router_id
, on
->priority
, deadtime
,
682 ospf6_neighbor_state_str
[on
->state
], nstate
, duration
,
683 on
->ospf6_if
->interface
->name
,
684 ospf6_interface_state_str
[on
->ospf6_if
->state
], VNL
);
688 ospf6_neighbor_show_drchoice (struct vty
*vty
, struct ospf6_neighbor
*on
)
691 char drouter
[16], bdrouter
[16];
693 struct timeval now
, res
;
696 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
697 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
701 inet_ntop (AF_INET
, &on
->router_id
, router_id
, sizeof (router_id
));
702 inet_ntop (AF_INET
, &on
->drouter
, drouter
, sizeof (drouter
));
703 inet_ntop (AF_INET
, &on
->bdrouter
, bdrouter
, sizeof (bdrouter
));
706 timersub (&now
, &on
->last_changed
, &res
);
707 timerstring (&res
, duration
, sizeof (duration
));
709 vty_out (vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]%s",
710 router_id
, ospf6_neighbor_state_str
[on
->state
],
711 duration
, drouter
, bdrouter
, on
->ospf6_if
->interface
->name
,
712 ospf6_interface_state_str
[on
->ospf6_if
->state
],
717 ospf6_neighbor_show_detail (struct vty
*vty
, struct ospf6_neighbor
*on
)
719 char drouter
[16], bdrouter
[16];
720 char linklocal_addr
[64], duration
[32];
721 struct timeval now
, res
;
722 struct ospf6_lsa
*lsa
;
724 inet_ntop (AF_INET6
, &on
->linklocal_addr
, linklocal_addr
,
725 sizeof (linklocal_addr
));
726 inet_ntop (AF_INET
, &on
->drouter
, drouter
, sizeof (drouter
));
727 inet_ntop (AF_INET
, &on
->bdrouter
, bdrouter
, sizeof (bdrouter
));
730 timersub (&now
, &on
->last_changed
, &res
);
731 timerstring (&res
, duration
, sizeof (duration
));
733 vty_out (vty
, " Neighbor %s%s", on
->name
,
735 vty_out (vty
, " Area %s via interface %s (ifindex %d)%s",
736 on
->ospf6_if
->area
->name
,
737 on
->ospf6_if
->interface
->name
,
738 on
->ospf6_if
->interface
->ifindex
,
740 vty_out (vty
, " His IfIndex: %d Link-local address: %s%s",
741 on
->ifindex
, linklocal_addr
,
743 vty_out (vty
, " State %s for a duration of %s%s",
744 ospf6_neighbor_state_str
[on
->state
], duration
,
746 vty_out (vty
, " His choice of DR/BDR %s/%s, Priority %d%s",
747 drouter
, bdrouter
, on
->priority
,
749 vty_out (vty
, " DbDesc status: %s%s%s SeqNum: %#lx%s",
750 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
) ? "Initial " : ""),
751 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
) ? "More " : ""),
752 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
) ?
753 "Master" : "Slave"), (u_long
) ntohl (on
->dbdesc_seqnum
),
756 vty_out (vty
, " Summary-List: %d LSAs%s", on
->summary_list
->count
,
758 for (lsa
= ospf6_lsdb_head (on
->summary_list
); lsa
;
759 lsa
= ospf6_lsdb_next (lsa
))
760 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
762 vty_out (vty
, " Request-List: %d LSAs%s", on
->request_list
->count
,
764 for (lsa
= ospf6_lsdb_head (on
->request_list
); lsa
;
765 lsa
= ospf6_lsdb_next (lsa
))
766 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
768 vty_out (vty
, " Retrans-List: %d LSAs%s", on
->retrans_list
->count
,
770 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
771 lsa
= ospf6_lsdb_next (lsa
))
772 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
775 if (on
->thread_send_dbdesc
)
776 timersub (&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
777 timerstring (&res
, duration
, sizeof (duration
));
778 vty_out (vty
, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
779 on
->dbdesc_list
->count
, duration
,
780 (on
->thread_send_dbdesc
? "on" : "off"),
782 for (lsa
= ospf6_lsdb_head (on
->dbdesc_list
); lsa
;
783 lsa
= ospf6_lsdb_next (lsa
))
784 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
787 if (on
->thread_send_lsreq
)
788 timersub (&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
789 timerstring (&res
, duration
, sizeof (duration
));
790 vty_out (vty
, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
791 on
->request_list
->count
, duration
,
792 (on
->thread_send_lsreq
? "on" : "off"),
794 for (lsa
= ospf6_lsdb_head (on
->request_list
); lsa
;
795 lsa
= ospf6_lsdb_next (lsa
))
796 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
799 if (on
->thread_send_lsupdate
)
800 timersub (&on
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
801 timerstring (&res
, duration
, sizeof (duration
));
802 vty_out (vty
, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
803 on
->lsupdate_list
->count
, duration
,
804 (on
->thread_send_lsupdate
? "on" : "off"),
806 for (lsa
= ospf6_lsdb_head (on
->lsupdate_list
); lsa
;
807 lsa
= ospf6_lsdb_next (lsa
))
808 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
811 if (on
->thread_send_lsack
)
812 timersub (&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
813 timerstring (&res
, duration
, sizeof (duration
));
814 vty_out (vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
815 on
->lsack_list
->count
, duration
,
816 (on
->thread_send_lsack
? "on" : "off"),
818 for (lsa
= ospf6_lsdb_head (on
->lsack_list
); lsa
;
819 lsa
= ospf6_lsdb_next (lsa
))
820 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
822 ospf6_bfd_show_info(vty
, on
->bfd_info
, 0);
825 DEFUN (show_ipv6_ospf6_neighbor
,
826 show_ipv6_ospf6_neighbor_cmd
,
827 "show ipv6 ospf6 neighbor [<detail|drchoice>]",
833 "Display DR choices\n")
836 struct ospf6_neighbor
*on
;
837 struct ospf6_interface
*oi
;
838 struct ospf6_area
*oa
;
839 struct listnode
*i
, *j
, *k
;
840 void (*showfunc
) (struct vty
*, struct ospf6_neighbor
*);
842 OSPF6_CMD_CHECK_RUNNING ();
843 showfunc
= ospf6_neighbor_show
;
847 if (! strncmp (argv
[idx_type
]->arg
, "de", 2))
848 showfunc
= ospf6_neighbor_show_detail
;
849 else if (! strncmp (argv
[idx_type
]->arg
, "dr", 2))
850 showfunc
= ospf6_neighbor_show_drchoice
;
853 if (showfunc
== ospf6_neighbor_show
)
854 vty_out (vty
, "%-15s %3s %11s %8s/%-12s %11s %s[%s]%s",
855 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
856 "I/F", "State", VNL
);
857 else if (showfunc
== ospf6_neighbor_show_drchoice
)
858 vty_out (vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]%s",
859 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
862 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, i
, oa
))
863 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
864 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, k
, on
))
865 (*showfunc
) (vty
, on
);
871 DEFUN (show_ipv6_ospf6_neighbor_one
,
872 show_ipv6_ospf6_neighbor_one_cmd
,
873 "show ipv6 ospf6 neighbor A.B.C.D",
878 "Specify Router-ID as IPv4 address notation\n"
882 struct ospf6_neighbor
*on
;
883 struct ospf6_interface
*oi
;
884 struct ospf6_area
*oa
;
885 struct listnode
*i
, *j
, *k
;
886 void (*showfunc
) (struct vty
*, struct ospf6_neighbor
*);
889 OSPF6_CMD_CHECK_RUNNING ();
890 showfunc
= ospf6_neighbor_show_detail
;
892 if ((inet_pton (AF_INET
, argv
[idx_ipv4
]->arg
, &router_id
)) != 1)
894 vty_out (vty
, "Router-ID is not parsable: %s%s", argv
[idx_ipv4
]->arg
,
899 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, i
, oa
))
900 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
901 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, k
, on
))
902 (*showfunc
) (vty
, on
);
908 ospf6_neighbor_init (void)
910 install_element (VIEW_NODE
, &show_ipv6_ospf6_neighbor_cmd
);
911 install_element (VIEW_NODE
, &show_ipv6_ospf6_neighbor_one_cmd
);
914 DEFUN (debug_ospf6_neighbor
,
915 debug_ospf6_neighbor_cmd
,
916 "debug ospf6 neighbor [<state|event>]",
919 "Debug OSPFv3 Neighbor\n"
920 "Debug OSPFv3 Neighbor State Change\n"
921 "Debug OSPFv3 Neighbor Event\n")
924 unsigned char level
= 0;
928 if (! strncmp (argv
[idx_type
]->arg
, "s", 1))
929 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
930 else if (! strncmp (argv
[idx_type
]->arg
, "e", 1))
931 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
934 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
936 OSPF6_DEBUG_NEIGHBOR_ON (level
);
941 DEFUN (no_debug_ospf6_neighbor
,
942 no_debug_ospf6_neighbor_cmd
,
943 "no debug ospf6 neighbor [<state|event>]",
947 "Debug OSPFv3 Neighbor\n"
948 "Debug OSPFv3 Neighbor State Change\n"
949 "Debug OSPFv3 Neighbor Event\n")
952 unsigned char level
= 0;
956 if (! strncmp (argv
[idx_type
]->arg
, "s", 1))
957 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
958 if (! strncmp (argv
[idx_type
]->arg
, "e", 1))
959 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
962 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
964 OSPF6_DEBUG_NEIGHBOR_OFF (level
);
969 DEFUN (no_debug_ospf6
,
977 struct ospf6_lsa_handler
*handler
= NULL
;
979 OSPF6_DEBUG_ABR_OFF ();
980 OSPF6_DEBUG_ASBR_OFF ();
981 OSPF6_DEBUG_BROUTER_OFF ();
982 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF ();
983 OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF ();
984 OSPF6_DEBUG_FLOODING_OFF ();
985 OSPF6_DEBUG_INTERFACE_OFF ();
987 for (i
= 0; i
< vector_active (ospf6_lsa_handler_vector
); i
++)
989 handler
= vector_slot (ospf6_lsa_handler_vector
, i
);
993 UNSET_FLAG (handler
->debug
, OSPF6_LSA_DEBUG
);
997 for (i
= 0; i
< 6; i
++)
998 OSPF6_DEBUG_MESSAGE_OFF (i
, OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
);
1000 OSPF6_DEBUG_NEIGHBOR_OFF (OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
);
1001 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_TABLE
);
1002 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_INTRA
);
1003 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_INTER
);
1004 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_MEMORY
);
1005 OSPF6_DEBUG_SPF_OFF (OSPF6_DEBUG_SPF_PROCESS
);
1006 OSPF6_DEBUG_SPF_OFF (OSPF6_DEBUG_SPF_TIME
);
1007 OSPF6_DEBUG_SPF_OFF (OSPF6_DEBUG_SPF_DATABASE
);
1008 OSPF6_DEBUG_ZEBRA_OFF (OSPF6_DEBUG_ZEBRA_SEND
| OSPF6_DEBUG_ZEBRA_RECV
);
1014 config_write_ospf6_debug_neighbor (struct vty
*vty
)
1016 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
) &&
1017 IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
1018 vty_out (vty
, "debug ospf6 neighbor%s", VNL
);
1019 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
))
1020 vty_out (vty
, "debug ospf6 neighbor state%s", VNL
);
1021 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
1022 vty_out (vty
, "debug ospf6 neighbor event%s", VNL
);
1027 install_element_ospf6_debug_neighbor (void)
1029 install_element (ENABLE_NODE
, &debug_ospf6_neighbor_cmd
);
1030 install_element (ENABLE_NODE
, &no_debug_ospf6_neighbor_cmd
);
1031 install_element (ENABLE_NODE
, &no_debug_ospf6_cmd
);
1032 install_element (CONFIG_NODE
, &debug_ospf6_neighbor_cmd
);
1033 install_element (CONFIG_NODE
, &no_debug_ospf6_neighbor_cmd
);
1034 install_element (CONFIG_NODE
, &no_debug_ospf6_cmd
);