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"
41 #include "ospf6_snmp.h"
43 #include "ospf6_bfd.h"
44 #include "ospf6_abr.h"
45 #include "ospf6_asbr.h"
46 #include "ospf6_lsa.h"
47 #include "ospf6_spf.h"
48 #include "ospf6_zebra.h"
50 unsigned char conf_debug_ospf6_neighbor
= 0;
52 const char *ospf6_neighbor_state_str
[] =
53 { "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange",
54 "Loading", "Full", NULL
};
57 ospf6_neighbor_cmp (void *va
, void *vb
)
59 struct ospf6_neighbor
*ona
= (struct ospf6_neighbor
*) va
;
60 struct ospf6_neighbor
*onb
= (struct ospf6_neighbor
*) vb
;
61 return (ntohl (ona
->router_id
) < ntohl (onb
->router_id
) ? -1 : 1);
64 struct ospf6_neighbor
*
65 ospf6_neighbor_lookup (u_int32_t router_id
,
66 struct ospf6_interface
*oi
)
69 struct ospf6_neighbor
*on
;
71 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, n
, on
))
72 if (on
->router_id
== router_id
)
75 return (struct ospf6_neighbor
*) NULL
;
78 /* create ospf6_neighbor */
79 struct ospf6_neighbor
*
80 ospf6_neighbor_create (u_int32_t router_id
, struct ospf6_interface
*oi
)
82 struct ospf6_neighbor
*on
;
85 on
= (struct ospf6_neighbor
*)
86 XMALLOC (MTYPE_OSPF6_NEIGHBOR
, sizeof (struct ospf6_neighbor
));
89 zlog_warn ("neighbor: malloc failed");
93 memset (on
, 0, sizeof (struct ospf6_neighbor
));
94 inet_ntop (AF_INET
, &router_id
, buf
, sizeof (buf
));
95 snprintf (on
->name
, sizeof (on
->name
), "%s%%%s",
96 buf
, oi
->interface
->name
);
98 on
->state
= OSPF6_NEIGHBOR_DOWN
;
100 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &on
->last_changed
);
101 on
->router_id
= router_id
;
103 on
->summary_list
= ospf6_lsdb_create (on
);
104 on
->request_list
= ospf6_lsdb_create (on
);
105 on
->retrans_list
= ospf6_lsdb_create (on
);
107 on
->dbdesc_list
= ospf6_lsdb_create (on
);
108 on
->lsupdate_list
= ospf6_lsdb_create (on
);
109 on
->lsack_list
= ospf6_lsdb_create (on
);
111 listnode_add_sort (oi
->neighbor_list
, on
);
113 ospf6_bfd_info_nbr_create(oi
, on
);
118 ospf6_neighbor_delete (struct ospf6_neighbor
*on
)
120 struct ospf6_lsa
*lsa
;
122 ospf6_lsdb_remove_all (on
->summary_list
);
123 ospf6_lsdb_remove_all (on
->request_list
);
124 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
125 lsa
= ospf6_lsdb_next (lsa
))
127 ospf6_decrement_retrans_count (lsa
);
128 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
131 ospf6_lsdb_remove_all (on
->dbdesc_list
);
132 ospf6_lsdb_remove_all (on
->lsupdate_list
);
133 ospf6_lsdb_remove_all (on
->lsack_list
);
135 ospf6_lsdb_delete (on
->summary_list
);
136 ospf6_lsdb_delete (on
->request_list
);
137 ospf6_lsdb_delete (on
->retrans_list
);
139 ospf6_lsdb_delete (on
->dbdesc_list
);
140 ospf6_lsdb_delete (on
->lsupdate_list
);
141 ospf6_lsdb_delete (on
->lsack_list
);
143 THREAD_OFF (on
->inactivity_timer
);
145 THREAD_OFF (on
->thread_send_dbdesc
);
146 THREAD_OFF (on
->thread_send_lsreq
);
147 THREAD_OFF (on
->thread_send_lsupdate
);
148 THREAD_OFF (on
->thread_send_lsack
);
150 ospf6_bfd_reg_dereg_nbr(on
, ZEBRA_BFD_DEST_DEREGISTER
);
151 XFREE (MTYPE_OSPF6_NEIGHBOR
, on
);
155 ospf6_neighbor_state_change (u_char next_state
, struct ospf6_neighbor
*on
, int event
)
159 prev_state
= on
->state
;
160 on
->state
= next_state
;
162 if (prev_state
== next_state
)
166 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &on
->last_changed
);
169 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
))
171 zlog_debug ("Neighbor state change %s: [%s]->[%s] (%s)", on
->name
,
172 ospf6_neighbor_state_str
[prev_state
],
173 ospf6_neighbor_state_str
[next_state
],
174 ospf6_neighbor_event_string(event
));
177 /* Optionally notify about adjacency changes */
178 if (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
179 OSPF6_LOG_ADJACENCY_CHANGES
) &&
180 (CHECK_FLAG(on
->ospf6_if
->area
->ospf6
->config_flags
,
181 OSPF6_LOG_ADJACENCY_DETAIL
) ||
182 (next_state
== OSPF6_NEIGHBOR_FULL
) || (next_state
< prev_state
)))
183 zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on
->name
,
184 ospf6_neighbor_state_str
[prev_state
],
185 ospf6_neighbor_state_str
[next_state
],
186 ospf6_neighbor_event_string(event
));
188 if (prev_state
== OSPF6_NEIGHBOR_FULL
|| next_state
== OSPF6_NEIGHBOR_FULL
)
190 OSPF6_ROUTER_LSA_SCHEDULE (on
->ospf6_if
->area
);
191 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
)
193 OSPF6_NETWORK_LSA_SCHEDULE (on
->ospf6_if
);
194 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on
->ospf6_if
);
196 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on
->ospf6_if
->area
);
199 if ((prev_state
== OSPF6_NEIGHBOR_EXCHANGE
||
200 prev_state
== OSPF6_NEIGHBOR_LOADING
) &&
201 (next_state
!= OSPF6_NEIGHBOR_EXCHANGE
&&
202 next_state
!= OSPF6_NEIGHBOR_LOADING
))
203 ospf6_maxage_remove (on
->ospf6_if
->area
->ospf6
);
206 /* Terminal state or regression */
207 if ((next_state
== OSPF6_NEIGHBOR_FULL
) ||
208 (next_state
== OSPF6_NEIGHBOR_TWOWAY
) ||
209 (next_state
< prev_state
))
210 ospf6TrapNbrStateChange (on
);
212 ospf6_bfd_trigger_event(on
, prev_state
, next_state
);
215 /* RFC2328 section 10.4 */
217 need_adjacency (struct ospf6_neighbor
*on
)
219 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_POINTTOPOINT
||
220 on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
||
221 on
->ospf6_if
->state
== OSPF6_INTERFACE_BDR
)
224 if (on
->ospf6_if
->drouter
== on
->router_id
||
225 on
->ospf6_if
->bdrouter
== on
->router_id
)
232 hello_received (struct thread
*thread
)
234 struct ospf6_neighbor
*on
;
236 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
239 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
240 zlog_debug ("Neighbor Event %s: *HelloReceived*", on
->name
);
242 /* reset Inactivity Timer */
243 THREAD_OFF (on
->inactivity_timer
);
244 on
->inactivity_timer
= thread_add_timer (master
, inactivity_timer
, on
,
245 on
->ospf6_if
->dead_interval
);
247 if (on
->state
<= OSPF6_NEIGHBOR_DOWN
)
248 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT
, on
,
249 OSPF6_NEIGHBOR_EVENT_HELLO_RCVD
);
255 twoway_received (struct thread
*thread
)
257 struct ospf6_neighbor
*on
;
259 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
262 if (on
->state
> OSPF6_NEIGHBOR_INIT
)
265 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
266 zlog_debug ("Neighbor Event %s: *2Way-Received*", on
->name
);
268 thread_add_event (master
, neighbor_change
, on
->ospf6_if
, 0);
270 if (! need_adjacency (on
))
272 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY
, on
,
273 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
277 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
278 OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD
);
279 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
280 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
281 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
283 THREAD_OFF (on
->thread_send_dbdesc
);
284 on
->thread_send_dbdesc
=
285 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
291 negotiation_done (struct thread
*thread
)
293 struct ospf6_neighbor
*on
;
294 struct ospf6_lsa
*lsa
;
296 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
299 if (on
->state
!= OSPF6_NEIGHBOR_EXSTART
)
302 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
303 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on
->name
);
306 ospf6_lsdb_remove_all (on
->summary_list
);
307 ospf6_lsdb_remove_all (on
->request_list
);
308 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
309 lsa
= ospf6_lsdb_next (lsa
))
311 ospf6_decrement_retrans_count (lsa
);
312 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
315 /* Interface scoped LSAs */
316 for (lsa
= ospf6_lsdb_head (on
->ospf6_if
->lsdb
); lsa
;
317 lsa
= ospf6_lsdb_next (lsa
))
319 if (OSPF6_LSA_IS_MAXAGE (lsa
))
321 ospf6_increment_retrans_count (lsa
);
322 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
325 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
328 /* Area scoped LSAs */
329 for (lsa
= ospf6_lsdb_head (on
->ospf6_if
->area
->lsdb
); lsa
;
330 lsa
= ospf6_lsdb_next (lsa
))
332 if (OSPF6_LSA_IS_MAXAGE (lsa
))
334 ospf6_increment_retrans_count (lsa
);
335 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
338 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
342 for (lsa
= ospf6_lsdb_head (on
->ospf6_if
->area
->ospf6
->lsdb
); lsa
;
343 lsa
= ospf6_lsdb_next (lsa
))
345 if (OSPF6_LSA_IS_MAXAGE (lsa
))
347 ospf6_increment_retrans_count (lsa
);
348 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
351 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
354 UNSET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
355 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE
, on
,
356 OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE
);
362 exchange_done (struct thread
*thread
)
364 struct ospf6_neighbor
*on
;
366 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
369 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
)
372 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
373 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on
->name
);
375 THREAD_OFF (on
->thread_send_dbdesc
);
376 ospf6_lsdb_remove_all (on
->dbdesc_list
);
379 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
380 on->ospf6_if->dead_interval);
383 if (on
->request_list
->count
== 0)
384 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL
, on
,
385 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
388 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING
, on
,
389 OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE
);
391 if (on
->thread_send_lsreq
== NULL
)
392 on
->thread_send_lsreq
=
393 thread_add_event (master
, ospf6_lsreq_send
, on
, 0);
399 /* Check loading state. */
401 ospf6_check_nbr_loading (struct ospf6_neighbor
*on
)
404 /* RFC2328 Section 10.9: When the neighbor responds to these requests
405 with the proper Link State Update packet(s), the Link state request
406 list is truncated and a new Link State Request packet is sent.
408 if ((on
->state
== OSPF6_NEIGHBOR_LOADING
) ||
409 (on
->state
== OSPF6_NEIGHBOR_EXCHANGE
))
411 if (on
->request_list
->count
== 0)
412 thread_add_event (master
, loading_done
, on
, 0);
413 else if (on
->last_ls_req
== NULL
)
415 if (on
->thread_send_lsreq
!= NULL
)
416 THREAD_OFF (on
->thread_send_lsreq
);
417 on
->thread_send_lsreq
=
418 thread_add_event (master
, ospf6_lsreq_send
, on
, 0);
424 loading_done (struct thread
*thread
)
426 struct ospf6_neighbor
*on
;
428 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
431 if (on
->state
!= OSPF6_NEIGHBOR_LOADING
)
434 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
435 zlog_debug ("Neighbor Event %s: *LoadingDone*", on
->name
);
437 assert (on
->request_list
->count
== 0);
439 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL
, on
,
440 OSPF6_NEIGHBOR_EVENT_LOADING_DONE
);
446 adj_ok (struct thread
*thread
)
448 struct ospf6_neighbor
*on
;
449 struct ospf6_lsa
*lsa
;
451 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
454 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
455 zlog_debug ("Neighbor Event %s: *AdjOK?*", on
->name
);
457 if (on
->state
== OSPF6_NEIGHBOR_TWOWAY
&& need_adjacency (on
))
459 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
460 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
461 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
462 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
463 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
465 THREAD_OFF (on
->thread_send_dbdesc
);
466 on
->thread_send_dbdesc
=
467 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
470 else if (on
->state
>= OSPF6_NEIGHBOR_EXSTART
&&
471 ! need_adjacency (on
))
473 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY
, on
,
474 OSPF6_NEIGHBOR_EVENT_ADJ_OK
);
475 ospf6_lsdb_remove_all (on
->summary_list
);
476 ospf6_lsdb_remove_all (on
->request_list
);
477 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
478 lsa
= ospf6_lsdb_next (lsa
))
480 ospf6_decrement_retrans_count (lsa
);
481 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
489 seqnumber_mismatch (struct thread
*thread
)
491 struct ospf6_neighbor
*on
;
492 struct ospf6_lsa
*lsa
;
494 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
497 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
500 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
501 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on
->name
);
503 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
504 OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH
);
505 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
506 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
507 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
509 ospf6_lsdb_remove_all (on
->summary_list
);
510 ospf6_lsdb_remove_all (on
->request_list
);
511 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
512 lsa
= ospf6_lsdb_next (lsa
))
514 ospf6_decrement_retrans_count (lsa
);
515 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
518 THREAD_OFF (on
->thread_send_dbdesc
);
519 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
521 on
->thread_send_dbdesc
=
522 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
528 bad_lsreq (struct thread
*thread
)
530 struct ospf6_neighbor
*on
;
531 struct ospf6_lsa
*lsa
;
533 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
536 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
539 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
540 zlog_debug ("Neighbor Event %s: *BadLSReq*", on
->name
);
542 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
,
543 OSPF6_NEIGHBOR_EVENT_BAD_LSREQ
);
544 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
545 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
546 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
548 ospf6_lsdb_remove_all (on
->summary_list
);
549 ospf6_lsdb_remove_all (on
->request_list
);
550 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
551 lsa
= ospf6_lsdb_next (lsa
))
553 ospf6_decrement_retrans_count (lsa
);
554 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
557 THREAD_OFF (on
->thread_send_dbdesc
);
558 on
->dbdesc_seqnum
++; /* Incr seqnum as per RFC2328, sec 10.3 */
560 on
->thread_send_dbdesc
=
561 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
567 oneway_received (struct thread
*thread
)
569 struct ospf6_neighbor
*on
;
570 struct ospf6_lsa
*lsa
;
572 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
575 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
578 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
579 zlog_debug ("Neighbor Event %s: *1Way-Received*", on
->name
);
581 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT
, on
,
582 OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD
);
583 thread_add_event (master
, neighbor_change
, on
->ospf6_if
, 0);
585 ospf6_lsdb_remove_all (on
->summary_list
);
586 ospf6_lsdb_remove_all (on
->request_list
);
587 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
588 lsa
= ospf6_lsdb_next (lsa
))
590 ospf6_decrement_retrans_count (lsa
);
591 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
594 THREAD_OFF (on
->thread_send_dbdesc
);
595 THREAD_OFF (on
->thread_send_lsreq
);
596 THREAD_OFF (on
->thread_send_lsupdate
);
597 THREAD_OFF (on
->thread_send_lsack
);
603 inactivity_timer (struct thread
*thread
)
605 struct ospf6_neighbor
*on
;
607 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
610 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
611 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on
->name
);
613 on
->inactivity_timer
= NULL
;
614 on
->drouter
= on
->prev_drouter
= 0;
615 on
->bdrouter
= on
->prev_bdrouter
= 0;
617 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN
, on
,
618 OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER
);
619 thread_add_event (master
, neighbor_change
, on
->ospf6_if
, 0);
621 listnode_delete (on
->ospf6_if
->neighbor_list
, on
);
622 ospf6_neighbor_delete (on
);
630 /* show neighbor structure */
632 ospf6_neighbor_show (struct vty
*vty
, struct ospf6_neighbor
*on
)
636 struct timeval now
, res
;
641 /* Router-ID (Name) */
642 inet_ntop (AF_INET
, &on
->router_id
, router_id
, sizeof (router_id
));
643 #ifdef HAVE_GETNAMEINFO
646 #endif /*HAVE_GETNAMEINFO*/
648 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &now
);
652 if (on
->inactivity_timer
)
654 s
= on
->inactivity_timer
->u
.sands
.tv_sec
- recent_relative_time().tv_sec
;
660 snprintf (deadtime
, sizeof (deadtime
), "%02ld:%02ld:%02ld", h
, m
, s
);
663 if (if_is_pointopoint (on
->ospf6_if
->interface
))
664 snprintf (nstate
, sizeof (nstate
), "PointToPoint");
667 if (on
->router_id
== on
->drouter
)
668 snprintf (nstate
, sizeof (nstate
), "DR");
669 else if (on
->router_id
== on
->bdrouter
)
670 snprintf (nstate
, sizeof (nstate
), "BDR");
672 snprintf (nstate
, sizeof (nstate
), "DROther");
676 timersub (&now
, &on
->last_changed
, &res
);
677 timerstring (&res
, duration
, sizeof (duration
));
680 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
681 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
682 "I/F", "State", VNL);
685 vty_out (vty
, "%-15s %3d %11s %8s/%-12s %11s %s[%s]%s",
686 router_id
, on
->priority
, deadtime
,
687 ospf6_neighbor_state_str
[on
->state
], nstate
, duration
,
688 on
->ospf6_if
->interface
->name
,
689 ospf6_interface_state_str
[on
->ospf6_if
->state
], VNL
);
693 ospf6_neighbor_show_drchoice (struct vty
*vty
, struct ospf6_neighbor
*on
)
696 char drouter
[16], bdrouter
[16];
698 struct timeval now
, res
;
701 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
702 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
706 inet_ntop (AF_INET
, &on
->router_id
, router_id
, sizeof (router_id
));
707 inet_ntop (AF_INET
, &on
->drouter
, drouter
, sizeof (drouter
));
708 inet_ntop (AF_INET
, &on
->bdrouter
, bdrouter
, sizeof (bdrouter
));
710 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &now
);
711 timersub (&now
, &on
->last_changed
, &res
);
712 timerstring (&res
, duration
, sizeof (duration
));
714 vty_out (vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]%s",
715 router_id
, ospf6_neighbor_state_str
[on
->state
],
716 duration
, drouter
, bdrouter
, on
->ospf6_if
->interface
->name
,
717 ospf6_interface_state_str
[on
->ospf6_if
->state
],
722 ospf6_neighbor_show_detail (struct vty
*vty
, struct ospf6_neighbor
*on
)
724 char drouter
[16], bdrouter
[16];
725 char linklocal_addr
[64], duration
[32];
726 struct timeval now
, res
;
727 struct ospf6_lsa
*lsa
;
729 inet_ntop (AF_INET6
, &on
->linklocal_addr
, linklocal_addr
,
730 sizeof (linklocal_addr
));
731 inet_ntop (AF_INET
, &on
->drouter
, drouter
, sizeof (drouter
));
732 inet_ntop (AF_INET
, &on
->bdrouter
, bdrouter
, sizeof (bdrouter
));
734 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &now
);
735 timersub (&now
, &on
->last_changed
, &res
);
736 timerstring (&res
, duration
, sizeof (duration
));
738 vty_out (vty
, " Neighbor %s%s", on
->name
,
740 vty_out (vty
, " Area %s via interface %s (ifindex %d)%s",
741 on
->ospf6_if
->area
->name
,
742 on
->ospf6_if
->interface
->name
,
743 on
->ospf6_if
->interface
->ifindex
,
745 vty_out (vty
, " His IfIndex: %d Link-local address: %s%s",
746 on
->ifindex
, linklocal_addr
,
748 vty_out (vty
, " State %s for a duration of %s%s",
749 ospf6_neighbor_state_str
[on
->state
], duration
,
751 vty_out (vty
, " His choice of DR/BDR %s/%s, Priority %d%s",
752 drouter
, bdrouter
, on
->priority
,
754 vty_out (vty
, " DbDesc status: %s%s%s SeqNum: %#lx%s",
755 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
) ? "Initial " : ""),
756 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
) ? "More " : ""),
757 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
) ?
758 "Master" : "Slave"), (u_long
) ntohl (on
->dbdesc_seqnum
),
761 vty_out (vty
, " Summary-List: %d LSAs%s", on
->summary_list
->count
,
763 for (lsa
= ospf6_lsdb_head (on
->summary_list
); lsa
;
764 lsa
= ospf6_lsdb_next (lsa
))
765 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
767 vty_out (vty
, " Request-List: %d LSAs%s", on
->request_list
->count
,
769 for (lsa
= ospf6_lsdb_head (on
->request_list
); lsa
;
770 lsa
= ospf6_lsdb_next (lsa
))
771 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
773 vty_out (vty
, " Retrans-List: %d LSAs%s", on
->retrans_list
->count
,
775 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
776 lsa
= ospf6_lsdb_next (lsa
))
777 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
780 if (on
->thread_send_dbdesc
)
781 timersub (&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
782 timerstring (&res
, duration
, sizeof (duration
));
783 vty_out (vty
, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
784 on
->dbdesc_list
->count
, duration
,
785 (on
->thread_send_dbdesc
? "on" : "off"),
787 for (lsa
= ospf6_lsdb_head (on
->dbdesc_list
); lsa
;
788 lsa
= ospf6_lsdb_next (lsa
))
789 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
792 if (on
->thread_send_lsreq
)
793 timersub (&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
794 timerstring (&res
, duration
, sizeof (duration
));
795 vty_out (vty
, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
796 on
->request_list
->count
, duration
,
797 (on
->thread_send_lsreq
? "on" : "off"),
799 for (lsa
= ospf6_lsdb_head (on
->request_list
); lsa
;
800 lsa
= ospf6_lsdb_next (lsa
))
801 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
804 if (on
->thread_send_lsupdate
)
805 timersub (&on
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
806 timerstring (&res
, duration
, sizeof (duration
));
807 vty_out (vty
, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
808 on
->lsupdate_list
->count
, duration
,
809 (on
->thread_send_lsupdate
? "on" : "off"),
811 for (lsa
= ospf6_lsdb_head (on
->lsupdate_list
); lsa
;
812 lsa
= ospf6_lsdb_next (lsa
))
813 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
816 if (on
->thread_send_lsack
)
817 timersub (&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
818 timerstring (&res
, duration
, sizeof (duration
));
819 vty_out (vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
820 on
->lsack_list
->count
, duration
,
821 (on
->thread_send_lsack
? "on" : "off"),
823 for (lsa
= ospf6_lsdb_head (on
->lsack_list
); lsa
;
824 lsa
= ospf6_lsdb_next (lsa
))
825 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
827 ospf6_bfd_show_info(vty
, on
->bfd_info
, 0);
830 DEFUN (show_ipv6_ospf6_neighbor
,
831 show_ipv6_ospf6_neighbor_cmd
,
832 "show ipv6 ospf6 neighbor [<detail|drchoice>]",
838 "Display DR choices\n")
841 struct ospf6_neighbor
*on
;
842 struct ospf6_interface
*oi
;
843 struct ospf6_area
*oa
;
844 struct listnode
*i
, *j
, *k
;
845 void (*showfunc
) (struct vty
*, struct ospf6_neighbor
*);
847 OSPF6_CMD_CHECK_RUNNING ();
848 showfunc
= ospf6_neighbor_show
;
852 if (! strncmp (argv
[idx_type
]->arg
, "de", 2))
853 showfunc
= ospf6_neighbor_show_detail
;
854 else if (! strncmp (argv
[idx_type
]->arg
, "dr", 2))
855 showfunc
= ospf6_neighbor_show_drchoice
;
858 if (showfunc
== ospf6_neighbor_show
)
859 vty_out (vty
, "%-15s %3s %11s %8s/%-12s %11s %s[%s]%s",
860 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
861 "I/F", "State", VNL
);
862 else if (showfunc
== ospf6_neighbor_show_drchoice
)
863 vty_out (vty
, "%-15s %8s/%-11s %-15s %-15s %s[%s]%s",
864 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
867 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, i
, oa
))
868 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
869 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, k
, on
))
870 (*showfunc
) (vty
, on
);
876 DEFUN (show_ipv6_ospf6_neighbor_one
,
877 show_ipv6_ospf6_neighbor_one_cmd
,
878 "show ipv6 ospf6 neighbor A.B.C.D",
883 "Specify Router-ID as IPv4 address notation\n"
887 struct ospf6_neighbor
*on
;
888 struct ospf6_interface
*oi
;
889 struct ospf6_area
*oa
;
890 struct listnode
*i
, *j
, *k
;
891 void (*showfunc
) (struct vty
*, struct ospf6_neighbor
*);
894 OSPF6_CMD_CHECK_RUNNING ();
895 showfunc
= ospf6_neighbor_show_detail
;
897 if ((inet_pton (AF_INET
, argv
[idx_ipv4
]->arg
, &router_id
)) != 1)
899 vty_out (vty
, "Router-ID is not parsable: %s%s", argv
[idx_ipv4
]->arg
,
904 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, i
, oa
))
905 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
906 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, k
, on
))
907 (*showfunc
) (vty
, on
);
913 ospf6_neighbor_init (void)
915 install_element (VIEW_NODE
, &show_ipv6_ospf6_neighbor_cmd
);
916 install_element (VIEW_NODE
, &show_ipv6_ospf6_neighbor_one_cmd
);
919 DEFUN (debug_ospf6_neighbor
,
920 debug_ospf6_neighbor_cmd
,
921 "debug ospf6 neighbor [<state|event>]",
924 "Debug OSPFv3 Neighbor\n"
925 "Debug OSPFv3 Neighbor State Change\n"
926 "Debug OSPFv3 Neighbor Event\n")
929 unsigned char level
= 0;
933 if (! strncmp (argv
[idx_type
]->arg
, "s", 1))
934 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
935 else if (! strncmp (argv
[idx_type
]->arg
, "e", 1))
936 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
939 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
941 OSPF6_DEBUG_NEIGHBOR_ON (level
);
946 DEFUN (no_debug_ospf6_neighbor
,
947 no_debug_ospf6_neighbor_cmd
,
948 "no debug ospf6 neighbor [<state|event>]",
952 "Debug OSPFv3 Neighbor\n"
953 "Debug OSPFv3 Neighbor State Change\n"
954 "Debug OSPFv3 Neighbor Event\n")
957 unsigned char level
= 0;
961 if (! strncmp (argv
[idx_type
]->arg
, "s", 1))
962 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
963 if (! strncmp (argv
[idx_type
]->arg
, "e", 1))
964 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
967 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
969 OSPF6_DEBUG_NEIGHBOR_OFF (level
);
974 DEFUN (no_debug_ospf6
,
982 struct ospf6_lsa_handler
*handler
= NULL
;
984 OSPF6_DEBUG_ABR_OFF ();
985 OSPF6_DEBUG_ASBR_OFF ();
986 OSPF6_DEBUG_BROUTER_OFF ();
987 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF ();
988 OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF ();
989 OSPF6_DEBUG_FLOODING_OFF ();
990 OSPF6_DEBUG_INTERFACE_OFF ();
992 for (i
= 0; i
< vector_active (ospf6_lsa_handler_vector
); i
++)
994 handler
= vector_slot (ospf6_lsa_handler_vector
, i
);
998 UNSET_FLAG (handler
->debug
, OSPF6_LSA_DEBUG
);
1002 for (i
= 0; i
< 6; i
++)
1003 OSPF6_DEBUG_MESSAGE_OFF (i
, OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
);
1005 OSPF6_DEBUG_NEIGHBOR_OFF (OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
);
1006 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_TABLE
);
1007 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_INTRA
);
1008 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_INTER
);
1009 OSPF6_DEBUG_ROUTE_OFF (OSPF6_DEBUG_ROUTE_MEMORY
);
1010 OSPF6_DEBUG_SPF_OFF (OSPF6_DEBUG_SPF_PROCESS
);
1011 OSPF6_DEBUG_SPF_OFF (OSPF6_DEBUG_SPF_TIME
);
1012 OSPF6_DEBUG_SPF_OFF (OSPF6_DEBUG_SPF_DATABASE
);
1013 OSPF6_DEBUG_ZEBRA_OFF (OSPF6_DEBUG_ZEBRA_SEND
| OSPF6_DEBUG_ZEBRA_RECV
);
1019 config_write_ospf6_debug_neighbor (struct vty
*vty
)
1021 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
) &&
1022 IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
1023 vty_out (vty
, "debug ospf6 neighbor%s", VNL
);
1024 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
))
1025 vty_out (vty
, "debug ospf6 neighbor state%s", VNL
);
1026 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
1027 vty_out (vty
, "debug ospf6 neighbor event%s", VNL
);
1032 install_element_ospf6_debug_neighbor (void)
1034 install_element (ENABLE_NODE
, &debug_ospf6_neighbor_cmd
);
1035 install_element (ENABLE_NODE
, &no_debug_ospf6_neighbor_cmd
);
1036 install_element (ENABLE_NODE
, &no_debug_ospf6_cmd
);
1037 install_element (CONFIG_NODE
, &debug_ospf6_neighbor_cmd
);
1038 install_element (CONFIG_NODE
, &no_debug_ospf6_neighbor_cmd
);
1039 install_element (CONFIG_NODE
, &no_debug_ospf6_cmd
);