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"
43 unsigned char conf_debug_ospf6_neighbor
= 0;
45 const char *ospf6_neighbor_state_str
[] =
46 { "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange",
47 "Loading", "Full", NULL
};
50 ospf6_neighbor_cmp (void *va
, void *vb
)
52 struct ospf6_neighbor
*ona
= (struct ospf6_neighbor
*) va
;
53 struct ospf6_neighbor
*onb
= (struct ospf6_neighbor
*) vb
;
54 return (ntohl (ona
->router_id
) < ntohl (onb
->router_id
) ? -1 : 1);
57 struct ospf6_neighbor
*
58 ospf6_neighbor_lookup (u_int32_t router_id
,
59 struct ospf6_interface
*oi
)
62 struct ospf6_neighbor
*on
;
64 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, n
, on
))
65 if (on
->router_id
== router_id
)
68 return (struct ospf6_neighbor
*) NULL
;
71 /* create ospf6_neighbor */
72 struct ospf6_neighbor
*
73 ospf6_neighbor_create (u_int32_t router_id
, struct ospf6_interface
*oi
)
75 struct ospf6_neighbor
*on
;
78 on
= (struct ospf6_neighbor
*)
79 XMALLOC (MTYPE_OSPF6_NEIGHBOR
, sizeof (struct ospf6_neighbor
));
82 zlog_warn ("neighbor: malloc failed");
86 memset (on
, 0, sizeof (struct ospf6_neighbor
));
87 inet_ntop (AF_INET
, &router_id
, buf
, sizeof (buf
));
88 snprintf (on
->name
, sizeof (on
->name
), "%s%%%s",
89 buf
, oi
->interface
->name
);
91 on
->state
= OSPF6_NEIGHBOR_DOWN
;
92 gettimeofday (&on
->last_changed
, (struct timezone
*) NULL
);
93 on
->router_id
= router_id
;
95 on
->summary_list
= ospf6_lsdb_create (on
);
96 on
->request_list
= ospf6_lsdb_create (on
);
97 on
->retrans_list
= ospf6_lsdb_create (on
);
99 on
->dbdesc_list
= ospf6_lsdb_create (on
);
100 on
->lsreq_list
= ospf6_lsdb_create (on
);
101 on
->lsupdate_list
= ospf6_lsdb_create (on
);
102 on
->lsack_list
= ospf6_lsdb_create (on
);
104 listnode_add_sort (oi
->neighbor_list
, on
);
109 ospf6_neighbor_delete (struct ospf6_neighbor
*on
)
111 struct ospf6_lsa
*lsa
;
113 ospf6_lsdb_remove_all (on
->summary_list
);
114 ospf6_lsdb_remove_all (on
->request_list
);
115 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
116 lsa
= ospf6_lsdb_next (lsa
))
118 ospf6_decrement_retrans_count (lsa
);
119 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
122 ospf6_lsdb_remove_all (on
->dbdesc_list
);
123 ospf6_lsdb_remove_all (on
->lsreq_list
);
124 ospf6_lsdb_remove_all (on
->lsupdate_list
);
125 ospf6_lsdb_remove_all (on
->lsack_list
);
127 ospf6_lsdb_delete (on
->summary_list
);
128 ospf6_lsdb_delete (on
->request_list
);
129 ospf6_lsdb_delete (on
->retrans_list
);
131 ospf6_lsdb_delete (on
->dbdesc_list
);
132 ospf6_lsdb_delete (on
->lsreq_list
);
133 ospf6_lsdb_delete (on
->lsupdate_list
);
134 ospf6_lsdb_delete (on
->lsack_list
);
136 THREAD_OFF (on
->inactivity_timer
);
138 THREAD_OFF (on
->thread_send_dbdesc
);
139 THREAD_OFF (on
->thread_send_lsreq
);
140 THREAD_OFF (on
->thread_send_lsupdate
);
141 THREAD_OFF (on
->thread_send_lsack
);
143 XFREE (MTYPE_OSPF6_NEIGHBOR
, on
);
147 ospf6_neighbor_state_change (u_char next_state
, struct ospf6_neighbor
*on
)
151 prev_state
= on
->state
;
152 on
->state
= next_state
;
154 if (prev_state
== next_state
)
157 gettimeofday (&on
->last_changed
, (struct timezone
*) NULL
);
160 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
))
162 zlog_debug ("Neighbor state change %s: [%s]->[%s]", on
->name
,
163 ospf6_neighbor_state_str
[prev_state
],
164 ospf6_neighbor_state_str
[next_state
]);
167 if (prev_state
== OSPF6_NEIGHBOR_FULL
|| next_state
== OSPF6_NEIGHBOR_FULL
)
169 OSPF6_ROUTER_LSA_SCHEDULE (on
->ospf6_if
->area
);
170 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
)
172 OSPF6_NETWORK_LSA_SCHEDULE (on
->ospf6_if
);
173 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on
->ospf6_if
);
175 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on
->ospf6_if
->area
);
178 if ((prev_state
== OSPF6_NEIGHBOR_EXCHANGE
||
179 prev_state
== OSPF6_NEIGHBOR_LOADING
) &&
180 (next_state
!= OSPF6_NEIGHBOR_EXCHANGE
&&
181 next_state
!= OSPF6_NEIGHBOR_LOADING
))
182 ospf6_maxage_remove (on
->ospf6_if
->area
->ospf6
);
185 /* RFC2328 section 10.4 */
187 need_adjacency (struct ospf6_neighbor
*on
)
189 if (on
->ospf6_if
->state
== OSPF6_INTERFACE_POINTTOPOINT
||
190 on
->ospf6_if
->state
== OSPF6_INTERFACE_DR
||
191 on
->ospf6_if
->state
== OSPF6_INTERFACE_BDR
)
194 if (on
->ospf6_if
->drouter
== on
->router_id
||
195 on
->ospf6_if
->bdrouter
== on
->router_id
)
202 hello_received (struct thread
*thread
)
204 struct ospf6_neighbor
*on
;
206 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
209 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
210 zlog_debug ("Neighbor Event %s: *HelloReceived*", on
->name
);
212 /* reset Inactivity Timer */
213 THREAD_OFF (on
->inactivity_timer
);
214 on
->inactivity_timer
= thread_add_timer (master
, inactivity_timer
, on
,
215 on
->ospf6_if
->dead_interval
);
217 if (on
->state
<= OSPF6_NEIGHBOR_DOWN
)
218 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT
, on
);
224 twoway_received (struct thread
*thread
)
226 struct ospf6_neighbor
*on
;
228 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
231 if (on
->state
> OSPF6_NEIGHBOR_INIT
)
234 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
235 zlog_debug ("Neighbor Event %s: *2Way-Received*", on
->name
);
237 thread_add_event (master
, neighbor_change
, on
->ospf6_if
, 0);
239 if (! need_adjacency (on
))
241 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY
, on
);
245 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
);
246 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
247 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
248 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
250 THREAD_OFF (on
->thread_send_dbdesc
);
251 on
->thread_send_dbdesc
=
252 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
258 negotiation_done (struct thread
*thread
)
260 struct ospf6_neighbor
*on
;
261 struct ospf6_lsa
*lsa
;
263 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
266 if (on
->state
!= OSPF6_NEIGHBOR_EXSTART
)
269 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
270 zlog_debug ("Neighbor Event %s: *NegotiationDone*", on
->name
);
273 ospf6_lsdb_remove_all (on
->summary_list
);
274 ospf6_lsdb_remove_all (on
->request_list
);
275 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
276 lsa
= ospf6_lsdb_next (lsa
))
278 ospf6_decrement_retrans_count (lsa
);
279 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
282 /* Interface scoped LSAs */
283 for (lsa
= ospf6_lsdb_head (on
->ospf6_if
->lsdb
); lsa
;
284 lsa
= ospf6_lsdb_next (lsa
))
286 if (OSPF6_LSA_IS_MAXAGE (lsa
))
288 ospf6_increment_retrans_count (lsa
);
289 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
292 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
295 /* Area scoped LSAs */
296 for (lsa
= ospf6_lsdb_head (on
->ospf6_if
->area
->lsdb
); lsa
;
297 lsa
= ospf6_lsdb_next (lsa
))
299 if (OSPF6_LSA_IS_MAXAGE (lsa
))
301 ospf6_increment_retrans_count (lsa
);
302 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
305 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
309 for (lsa
= ospf6_lsdb_head (on
->ospf6_if
->area
->ospf6
->lsdb
); lsa
;
310 lsa
= ospf6_lsdb_next (lsa
))
312 if (OSPF6_LSA_IS_MAXAGE (lsa
))
314 ospf6_increment_retrans_count (lsa
);
315 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->retrans_list
);
318 ospf6_lsdb_add (ospf6_lsa_copy (lsa
), on
->summary_list
);
321 UNSET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
322 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE
, on
);
328 exchange_done (struct thread
*thread
)
330 struct ospf6_neighbor
*on
;
332 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
335 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
)
338 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
339 zlog_debug ("Neighbor Event %s: *ExchangeDone*", on
->name
);
341 THREAD_OFF (on
->thread_send_dbdesc
);
342 ospf6_lsdb_remove_all (on
->dbdesc_list
);
345 thread_add_timer (master, ospf6_neighbor_last_dbdesc_release, on,
346 on->ospf6_if->dead_interval);
349 if (on
->request_list
->count
== 0)
350 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL
, on
);
352 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING
, on
);
358 loading_done (struct thread
*thread
)
360 struct ospf6_neighbor
*on
;
362 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
365 if (on
->state
!= OSPF6_NEIGHBOR_LOADING
)
368 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
369 zlog_debug ("Neighbor Event %s: *LoadingDone*", on
->name
);
371 assert (on
->request_list
->count
== 0);
373 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL
, on
);
379 adj_ok (struct thread
*thread
)
381 struct ospf6_neighbor
*on
;
382 struct ospf6_lsa
*lsa
;
384 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
387 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
388 zlog_debug ("Neighbor Event %s: *AdjOK?*", on
->name
);
390 if (on
->state
== OSPF6_NEIGHBOR_TWOWAY
&& need_adjacency (on
))
392 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
);
393 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
394 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
395 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
397 THREAD_OFF (on
->thread_send_dbdesc
);
398 on
->thread_send_dbdesc
=
399 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
402 else if (on
->state
>= OSPF6_NEIGHBOR_EXSTART
&&
403 ! need_adjacency (on
))
405 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY
, on
);
406 ospf6_lsdb_remove_all (on
->summary_list
);
407 ospf6_lsdb_remove_all (on
->request_list
);
408 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
409 lsa
= ospf6_lsdb_next (lsa
))
411 ospf6_decrement_retrans_count (lsa
);
412 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
420 seqnumber_mismatch (struct thread
*thread
)
422 struct ospf6_neighbor
*on
;
423 struct ospf6_lsa
*lsa
;
425 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
428 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
431 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
432 zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on
->name
);
434 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
);
435 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
436 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
437 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
439 ospf6_lsdb_remove_all (on
->summary_list
);
440 ospf6_lsdb_remove_all (on
->request_list
);
441 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
442 lsa
= ospf6_lsdb_next (lsa
))
444 ospf6_decrement_retrans_count (lsa
);
445 ospf6_lsdb_remove (lsa
, on
->retrans_list
);
448 THREAD_OFF (on
->thread_send_dbdesc
);
449 on
->thread_send_dbdesc
=
450 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
456 bad_lsreq (struct thread
*thread
)
458 struct ospf6_neighbor
*on
;
459 struct ospf6_lsa
*lsa
;
461 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
464 if (on
->state
< OSPF6_NEIGHBOR_EXCHANGE
)
467 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
468 zlog_debug ("Neighbor Event %s: *BadLSReq*", on
->name
);
470 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART
, on
);
471 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
);
472 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
);
473 SET_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
);
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
);
484 THREAD_OFF (on
->thread_send_dbdesc
);
485 on
->thread_send_dbdesc
=
486 thread_add_event (master
, ospf6_dbdesc_send
, on
, 0);
492 oneway_received (struct thread
*thread
)
494 struct ospf6_neighbor
*on
;
495 struct ospf6_lsa
*lsa
;
497 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
500 if (on
->state
< OSPF6_NEIGHBOR_TWOWAY
)
503 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
504 zlog_debug ("Neighbor Event %s: *1Way-Received*", on
->name
);
506 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT
, on
);
507 thread_add_event (master
, neighbor_change
, on
->ospf6_if
, 0);
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 THREAD_OFF (on
->thread_send_lsreq
);
520 THREAD_OFF (on
->thread_send_lsupdate
);
521 THREAD_OFF (on
->thread_send_lsack
);
527 inactivity_timer (struct thread
*thread
)
529 struct ospf6_neighbor
*on
;
531 on
= (struct ospf6_neighbor
*) THREAD_ARG (thread
);
534 if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
535 zlog_debug ("Neighbor Event %s: *InactivityTimer*", on
->name
);
537 on
->inactivity_timer
= NULL
;
538 on
->drouter
= on
->prev_drouter
= 0;
539 on
->bdrouter
= on
->prev_bdrouter
= 0;
541 ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN
, on
);
542 thread_add_event (master
, neighbor_change
, on
->ospf6_if
, 0);
544 listnode_delete (on
->ospf6_if
->neighbor_list
, on
);
545 ospf6_neighbor_delete (on
);
553 /* show neighbor structure */
555 ospf6_neighbor_show (struct vty
*vty
, struct ospf6_neighbor
*on
)
559 struct timeval now
, res
;
564 /* Router-ID (Name) */
565 inet_ntop (AF_INET
, &on
->router_id
, router_id
, sizeof (router_id
));
566 #ifdef HAVE_GETNAMEINFO
569 #endif /*HAVE_GETNAMEINFO*/
571 gettimeofday (&now
, NULL
);
575 if (on
->inactivity_timer
)
577 s
= on
->inactivity_timer
->u
.sands
.tv_sec
- recent_relative_time().tv_sec
;
583 snprintf (deadtime
, sizeof (deadtime
), "%02ld:%02ld:%02ld", h
, m
, s
);
586 if (if_is_pointopoint (on
->ospf6_if
->interface
))
587 snprintf (nstate
, sizeof (nstate
), "PointToPoint");
590 if (on
->router_id
== on
->drouter
)
591 snprintf (nstate
, sizeof (nstate
), "DR");
592 else if (on
->router_id
== on
->bdrouter
)
593 snprintf (nstate
, sizeof (nstate
), "BDR");
595 snprintf (nstate
, sizeof (nstate
), "DROther");
599 timersub (&now
, &on
->last_changed
, &res
);
600 timerstring (&res
, duration
, sizeof (duration
));
603 vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
604 "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
605 "I/F", "State", VNL);
608 vty_out (vty
, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",
609 router_id
, on
->priority
, deadtime
,
610 ospf6_neighbor_state_str
[on
->state
], nstate
, duration
,
611 on
->ospf6_if
->interface
->name
,
612 ospf6_interface_state_str
[on
->ospf6_if
->state
], VNL
);
616 ospf6_neighbor_show_drchoice (struct vty
*vty
, struct ospf6_neighbor
*on
)
619 char drouter
[16], bdrouter
[16];
621 struct timeval now
, res
;
624 vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
625 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
629 inet_ntop (AF_INET
, &on
->router_id
, router_id
, sizeof (router_id
));
630 inet_ntop (AF_INET
, &on
->drouter
, drouter
, sizeof (drouter
));
631 inet_ntop (AF_INET
, &on
->bdrouter
, bdrouter
, sizeof (bdrouter
));
633 gettimeofday (&now
, NULL
);
634 timersub (&now
, &on
->last_changed
, &res
);
635 timerstring (&res
, duration
, sizeof (duration
));
637 vty_out (vty
, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
638 router_id
, ospf6_neighbor_state_str
[on
->state
],
639 duration
, drouter
, bdrouter
, on
->ospf6_if
->interface
->name
,
640 ospf6_interface_state_str
[on
->ospf6_if
->state
],
645 ospf6_neighbor_show_detail (struct vty
*vty
, struct ospf6_neighbor
*on
)
647 char drouter
[16], bdrouter
[16];
648 char linklocal_addr
[64], duration
[32];
649 struct timeval now
, res
;
650 struct ospf6_lsa
*lsa
;
652 inet_ntop (AF_INET6
, &on
->linklocal_addr
, linklocal_addr
,
653 sizeof (linklocal_addr
));
654 inet_ntop (AF_INET
, &on
->drouter
, drouter
, sizeof (drouter
));
655 inet_ntop (AF_INET
, &on
->bdrouter
, bdrouter
, sizeof (bdrouter
));
657 gettimeofday (&now
, NULL
);
658 timersub (&now
, &on
->last_changed
, &res
);
659 timerstring (&res
, duration
, sizeof (duration
));
661 vty_out (vty
, " Neighbor %s%s", on
->name
,
663 vty_out (vty
, " Area %s via interface %s (ifindex %d)%s",
664 on
->ospf6_if
->area
->name
,
665 on
->ospf6_if
->interface
->name
,
666 on
->ospf6_if
->interface
->ifindex
,
668 vty_out (vty
, " His IfIndex: %d Link-local address: %s%s",
669 on
->ifindex
, linklocal_addr
,
671 vty_out (vty
, " State %s for a duration of %s%s",
672 ospf6_neighbor_state_str
[on
->state
], duration
,
674 vty_out (vty
, " His choice of DR/BDR %s/%s, Priority %d%s",
675 drouter
, bdrouter
, on
->priority
,
677 vty_out (vty
, " DbDesc status: %s%s%s SeqNum: %#lx%s",
678 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_IBIT
) ? "Initial " : ""),
679 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MBIT
) ? "More " : ""),
680 (CHECK_FLAG (on
->dbdesc_bits
, OSPF6_DBDESC_MSBIT
) ?
681 "Master" : "Slave"), (u_long
) ntohl (on
->dbdesc_seqnum
),
684 vty_out (vty
, " Summary-List: %d LSAs%s", on
->summary_list
->count
,
686 for (lsa
= ospf6_lsdb_head (on
->summary_list
); lsa
;
687 lsa
= ospf6_lsdb_next (lsa
))
688 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
690 vty_out (vty
, " Request-List: %d LSAs%s", on
->request_list
->count
,
692 for (lsa
= ospf6_lsdb_head (on
->request_list
); lsa
;
693 lsa
= ospf6_lsdb_next (lsa
))
694 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
696 vty_out (vty
, " Retrans-List: %d LSAs%s", on
->retrans_list
->count
,
698 for (lsa
= ospf6_lsdb_head (on
->retrans_list
); lsa
;
699 lsa
= ospf6_lsdb_next (lsa
))
700 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
703 if (on
->thread_send_dbdesc
)
704 timersub (&on
->thread_send_dbdesc
->u
.sands
, &now
, &res
);
705 timerstring (&res
, duration
, sizeof (duration
));
706 vty_out (vty
, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s",
707 on
->dbdesc_list
->count
, duration
,
708 (on
->thread_send_dbdesc
? "on" : "off"),
710 for (lsa
= ospf6_lsdb_head (on
->dbdesc_list
); lsa
;
711 lsa
= ospf6_lsdb_next (lsa
))
712 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
715 if (on
->thread_send_lsreq
)
716 timersub (&on
->thread_send_lsreq
->u
.sands
, &now
, &res
);
717 timerstring (&res
, duration
, sizeof (duration
));
718 vty_out (vty
, " %d Pending LSAs for LSReq in Time %s [thread %s]%s",
719 on
->lsreq_list
->count
, duration
,
720 (on
->thread_send_lsreq
? "on" : "off"),
722 for (lsa
= ospf6_lsdb_head (on
->lsreq_list
); lsa
;
723 lsa
= ospf6_lsdb_next (lsa
))
724 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
727 if (on
->thread_send_lsupdate
)
728 timersub (&on
->thread_send_lsupdate
->u
.sands
, &now
, &res
);
729 timerstring (&res
, duration
, sizeof (duration
));
730 vty_out (vty
, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
731 on
->lsupdate_list
->count
, duration
,
732 (on
->thread_send_lsupdate
? "on" : "off"),
734 for (lsa
= ospf6_lsdb_head (on
->lsupdate_list
); lsa
;
735 lsa
= ospf6_lsdb_next (lsa
))
736 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
739 if (on
->thread_send_lsack
)
740 timersub (&on
->thread_send_lsack
->u
.sands
, &now
, &res
);
741 timerstring (&res
, duration
, sizeof (duration
));
742 vty_out (vty
, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
743 on
->lsack_list
->count
, duration
,
744 (on
->thread_send_lsack
? "on" : "off"),
746 for (lsa
= ospf6_lsdb_head (on
->lsack_list
); lsa
;
747 lsa
= ospf6_lsdb_next (lsa
))
748 vty_out (vty
, " %s%s", lsa
->name
, VNL
);
752 DEFUN (show_ipv6_ospf6_neighbor
,
753 show_ipv6_ospf6_neighbor_cmd
,
754 "show ipv6 ospf6 neighbor",
761 struct ospf6_neighbor
*on
;
762 struct ospf6_interface
*oi
;
763 struct ospf6_area
*oa
;
764 struct listnode
*i
, *j
, *k
;
765 void (*showfunc
) (struct vty
*, struct ospf6_neighbor
*);
767 OSPF6_CMD_CHECK_RUNNING ();
768 showfunc
= ospf6_neighbor_show
;
772 if (! strncmp (argv
[0], "de", 2))
773 showfunc
= ospf6_neighbor_show_detail
;
774 else if (! strncmp (argv
[0], "dr", 2))
775 showfunc
= ospf6_neighbor_show_drchoice
;
778 if (showfunc
== ospf6_neighbor_show
)
779 vty_out (vty
, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s",
780 "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",
781 "I/F", "State", VNL
);
782 else if (showfunc
== ospf6_neighbor_show_drchoice
)
783 vty_out (vty
, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",
784 "RouterID", "State", "Duration", "DR", "BDR", "I/F",
787 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, i
, oa
))
788 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
789 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, k
, on
))
790 (*showfunc
) (vty
, on
);
795 ALIAS (show_ipv6_ospf6_neighbor
,
796 show_ipv6_ospf6_neighbor_detail_cmd
,
797 "show ipv6 ospf6 neighbor (detail|drchoice)",
803 "Display DR choices\n"
806 DEFUN (show_ipv6_ospf6_neighbor_one
,
807 show_ipv6_ospf6_neighbor_one_cmd
,
808 "show ipv6 ospf6 neighbor A.B.C.D",
813 "Specify Router-ID as IPv4 address notation\n"
816 struct ospf6_neighbor
*on
;
817 struct ospf6_interface
*oi
;
818 struct ospf6_area
*oa
;
819 struct listnode
*i
, *j
, *k
;
820 void (*showfunc
) (struct vty
*, struct ospf6_neighbor
*);
823 OSPF6_CMD_CHECK_RUNNING ();
824 showfunc
= ospf6_neighbor_show_detail
;
826 if ((inet_pton (AF_INET
, argv
[0], &router_id
)) != 1)
828 vty_out (vty
, "Router-ID is not parsable: %s%s", argv
[0],
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 ospf6_neighbor_init ()
844 install_element (VIEW_NODE
, &show_ipv6_ospf6_neighbor_cmd
);
845 install_element (VIEW_NODE
, &show_ipv6_ospf6_neighbor_detail_cmd
);
846 install_element (ENABLE_NODE
, &show_ipv6_ospf6_neighbor_cmd
);
847 install_element (ENABLE_NODE
, &show_ipv6_ospf6_neighbor_detail_cmd
);
850 DEFUN (debug_ospf6_neighbor
,
851 debug_ospf6_neighbor_cmd
,
852 "debug ospf6 neighbor",
855 "Debug OSPFv3 Neighbor\n"
858 unsigned char level
= 0;
861 if (! strncmp (argv
[0], "s", 1))
862 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
863 if (! strncmp (argv
[0], "e", 1))
864 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
867 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
869 OSPF6_DEBUG_NEIGHBOR_ON (level
);
873 ALIAS (debug_ospf6_neighbor
,
874 debug_ospf6_neighbor_detail_cmd
,
875 "debug ospf6 neighbor (state|event)",
878 "Debug OSPFv3 Neighbor\n"
879 "Debug OSPFv3 Neighbor State Change\n"
880 "Debug OSPFv3 Neighbor Event\n"
883 DEFUN (no_debug_ospf6_neighbor
,
884 no_debug_ospf6_neighbor_cmd
,
885 "no debug ospf6 neighbor",
889 "Debug OSPFv3 Neighbor\n"
892 unsigned char level
= 0;
895 if (! strncmp (argv
[0], "s", 1))
896 level
= OSPF6_DEBUG_NEIGHBOR_STATE
;
897 if (! strncmp (argv
[0], "e", 1))
898 level
= OSPF6_DEBUG_NEIGHBOR_EVENT
;
901 level
= OSPF6_DEBUG_NEIGHBOR_STATE
| OSPF6_DEBUG_NEIGHBOR_EVENT
;
903 OSPF6_DEBUG_NEIGHBOR_OFF (level
);
907 ALIAS (no_debug_ospf6_neighbor
,
908 no_debug_ospf6_neighbor_detail_cmd
,
909 "no debug ospf6 neighbor (state|event)",
913 "Debug OSPFv3 Neighbor\n"
914 "Debug OSPFv3 Neighbor State Change\n"
915 "Debug OSPFv3 Neighbor Event\n"
919 config_write_ospf6_debug_neighbor (struct vty
*vty
)
921 if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
) &&
922 IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
923 vty_out (vty
, "debug ospf6 neighbor%s", VNL
);
924 else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE
))
925 vty_out (vty
, "debug ospf6 neighbor state%s", VNL
);
926 else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT
))
927 vty_out (vty
, "debug ospf6 neighbor event%s", VNL
);
932 install_element_ospf6_debug_neighbor ()
934 install_element (ENABLE_NODE
, &debug_ospf6_neighbor_cmd
);
935 install_element (ENABLE_NODE
, &debug_ospf6_neighbor_detail_cmd
);
936 install_element (ENABLE_NODE
, &no_debug_ospf6_neighbor_cmd
);
937 install_element (ENABLE_NODE
, &no_debug_ospf6_neighbor_detail_cmd
);
938 install_element (CONFIG_NODE
, &debug_ospf6_neighbor_cmd
);
939 install_element (CONFIG_NODE
, &debug_ospf6_neighbor_detail_cmd
);
940 install_element (CONFIG_NODE
, &no_debug_ospf6_neighbor_cmd
);
941 install_element (CONFIG_NODE
, &no_debug_ospf6_neighbor_detail_cmd
);