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.
32 #include "ospf6_lsa.h"
33 #include "ospf6_lsdb.h"
34 #include "ospf6_network.h"
35 #include "ospf6_message.h"
36 #include "ospf6_route.h"
37 #include "ospf6_top.h"
38 #include "ospf6_area.h"
39 #include "ospf6_interface.h"
40 #include "ospf6_neighbor.h"
41 #include "ospf6_intra.h"
42 #include "ospf6_spf.h"
43 #include "ospf6_snmp.h"
46 unsigned char conf_debug_ospf6_interface = 0;
48 const char *ospf6_interface_state_str[] =
61 struct ospf6_interface *
62 ospf6_interface_lookup_by_ifindex (ifindex_t ifindex)
64 struct ospf6_interface *oi;
65 struct interface *ifp;
67 ifp = if_lookup_by_index (ifindex);
69 return (struct ospf6_interface *) NULL;
71 oi = (struct ospf6_interface *) ifp->info;
75 /* schedule routing table recalculation */
77 ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa, unsigned int reason)
79 struct ospf6_interface *oi;
85 switch (ntohs (lsa->header->type))
87 case OSPF6_LSTYPE_LINK:
88 if (oi->state == OSPF6_INTERFACE_DR)
89 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
90 ospf6_spf_schedule (oi->area->ospf6, reason);
99 ospf6_interface_lsdb_hook_add (struct ospf6_lsa *lsa)
101 ospf6_interface_lsdb_hook(lsa, ospf6_lsadd_to_spf_reason(lsa));
105 ospf6_interface_lsdb_hook_remove (struct ospf6_lsa *lsa)
107 ospf6_interface_lsdb_hook(lsa, ospf6_lsremove_to_spf_reason(lsa));
111 ospf6_default_iftype(struct interface *ifp)
113 if (if_is_pointopoint (ifp))
114 return OSPF_IFTYPE_POINTOPOINT;
115 else if (if_is_loopback (ifp))
116 return OSPF_IFTYPE_LOOPBACK;
118 return OSPF_IFTYPE_BROADCAST;
122 ospf6_interface_get_cost (struct ospf6_interface *oi)
124 /* If all else fails, use default OSPF cost */
128 bw = oi->interface->bandwidth ? oi->interface->bandwidth : OSPF6_INTERFACE_BANDWIDTH;
129 refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
131 /* A specifed ip ospf cost overrides a calculated one. */
132 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
136 cost = (u_int32_t) ((double)refbw / (double)bw + (double)0.5);
137 if (cost < 1) cost = 1;
138 else if (cost > UINT32_MAX) cost = UINT32_MAX;
145 ospf6_interface_recalculate_cost (struct ospf6_interface *oi)
149 newcost = ospf6_interface_get_cost (oi);
150 if (newcost == oi->cost) return;
153 /* update cost held in route_connected list in ospf6_interface */
154 ospf6_interface_connected_route_update (oi->interface);
156 /* execute LSA hooks */
159 OSPF6_LINK_LSA_SCHEDULE (oi);
160 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
161 OSPF6_NETWORK_LSA_SCHEDULE (oi);
162 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
163 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
167 /* Create new ospf6 interface structure */
168 struct ospf6_interface *
169 ospf6_interface_create (struct interface *ifp)
171 struct ospf6_interface *oi;
172 unsigned int iobuflen;
174 oi = (struct ospf6_interface *)
175 XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
179 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
180 return (struct ospf6_interface *) NULL;
183 oi->area = (struct ospf6_area *) NULL;
184 oi->neighbor_list = list_new ();
185 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
186 oi->linklocal_addr = (struct in6_addr *) NULL;
187 oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
188 oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
189 oi->priority = OSPF6_INTERFACE_PRIORITY;
191 oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
192 oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
193 oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
194 oi->type = ospf6_default_iftype (ifp);
195 oi->state = OSPF6_INTERFACE_DOWN;
199 /* Try to adjust I/O buffer size with IfMtu */
200 oi->ifmtu = ifp->mtu6;
201 iobuflen = ospf6_iobuf_size (ifp->mtu6);
202 if (oi->ifmtu > iobuflen)
204 if (IS_OSPF6_DEBUG_INTERFACE)
205 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
206 ifp->name, iobuflen);
207 oi->ifmtu = iobuflen;
210 oi->lsupdate_list = ospf6_lsdb_create (oi);
211 oi->lsack_list = ospf6_lsdb_create (oi);
212 oi->lsdb = ospf6_lsdb_create (oi);
213 oi->lsdb->hook_add = ospf6_interface_lsdb_hook_add;
214 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook_remove;
215 oi->lsdb_self = ospf6_lsdb_create (oi);
217 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
218 oi->route_connected->scope = oi;
225 oi->cost = ospf6_interface_get_cost(oi);
231 ospf6_interface_delete (struct ospf6_interface *oi)
233 struct listnode *node, *nnode;
234 struct ospf6_neighbor *on;
236 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
237 ospf6_neighbor_delete (on);
239 list_delete (oi->neighbor_list);
241 THREAD_OFF (oi->thread_send_hello);
242 THREAD_OFF (oi->thread_send_lsupdate);
243 THREAD_OFF (oi->thread_send_lsack);
245 ospf6_lsdb_remove_all (oi->lsdb);
246 ospf6_lsdb_remove_all (oi->lsupdate_list);
247 ospf6_lsdb_remove_all (oi->lsack_list);
249 ospf6_lsdb_delete (oi->lsdb);
250 ospf6_lsdb_delete (oi->lsdb_self);
252 ospf6_lsdb_delete (oi->lsupdate_list);
253 ospf6_lsdb_delete (oi->lsack_list);
255 ospf6_route_table_delete (oi->route_connected);
258 oi->interface->info = NULL;
262 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
264 XFREE (MTYPE_OSPF6_IF, oi);
268 ospf6_interface_enable (struct ospf6_interface *oi)
270 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
271 ospf6_interface_state_update (oi->interface);
275 ospf6_interface_disable (struct ospf6_interface *oi)
277 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
279 thread_execute (master, interface_down, oi, 0);
281 ospf6_lsdb_remove_all (oi->lsdb);
282 ospf6_lsdb_remove_all (oi->lsdb_self);
283 ospf6_lsdb_remove_all (oi->lsupdate_list);
284 ospf6_lsdb_remove_all (oi->lsack_list);
286 THREAD_OFF (oi->thread_send_hello);
287 THREAD_OFF (oi->thread_send_lsupdate);
288 THREAD_OFF (oi->thread_send_lsack);
290 THREAD_OFF (oi->thread_network_lsa);
291 THREAD_OFF (oi->thread_link_lsa);
292 THREAD_OFF (oi->thread_intra_prefix_lsa);
295 static struct in6_addr *
296 ospf6_interface_get_linklocal_address (struct interface *ifp)
300 struct in6_addr *l = (struct in6_addr *) NULL;
302 /* for each connected address */
303 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
305 /* if family not AF_INET6, ignore */
306 if (c->address->family != AF_INET6)
309 /* linklocal scope check */
310 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
311 l = &c->address->u.prefix6;
317 ospf6_interface_if_add (struct interface *ifp)
319 struct ospf6_interface *oi;
320 unsigned int iobuflen;
322 oi = (struct ospf6_interface *) ifp->info;
326 /* Try to adjust I/O buffer size with IfMtu */
328 oi->ifmtu = ifp->mtu6;
329 iobuflen = ospf6_iobuf_size (ifp->mtu6);
330 if (oi->ifmtu > iobuflen)
332 if (IS_OSPF6_DEBUG_INTERFACE)
333 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
334 ifp->name, iobuflen);
335 oi->ifmtu = iobuflen;
338 /* interface start */
339 ospf6_interface_state_update(oi->interface);
343 ospf6_interface_state_update (struct interface *ifp)
345 struct ospf6_interface *oi;
347 oi = (struct ospf6_interface *) ifp->info;
350 if (oi->area == NULL)
352 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
355 if (if_is_operative (ifp)
356 && (ospf6_interface_get_linklocal_address(oi->interface)
357 || if_is_loopback(oi->interface)))
358 thread_add_event (master, interface_up, oi, 0);
360 thread_add_event (master, interface_down, oi, 0);
366 ospf6_interface_connected_route_update (struct interface *ifp)
368 struct ospf6_interface *oi;
369 struct ospf6_route *route;
371 struct listnode *node, *nnode;
373 oi = (struct ospf6_interface *) ifp->info;
377 /* reset linklocal pointer */
378 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
380 /* if area is null, do not make connected-route list */
381 if (oi->area == NULL)
384 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
387 /* update "route to advertise" interface route table */
388 ospf6_route_remove_all (oi->route_connected);
390 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
392 if (c->address->family != AF_INET6)
395 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
396 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
397 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
398 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
399 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
404 struct prefix_list *plist;
405 enum prefix_list_type ret;
408 prefix2str (c->address, buf, sizeof (buf));
409 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
410 ret = prefix_list_apply (plist, (void *) c->address);
411 if (ret == PREFIX_DENY)
413 if (IS_OSPF6_DEBUG_INTERFACE)
414 zlog_debug ("%s on %s filtered by prefix-list %s ",
415 buf, oi->interface->name, oi->plist_name);
420 route = ospf6_route_create ();
421 memcpy (&route->prefix, c->address, sizeof (struct prefix));
422 apply_mask (&route->prefix);
423 route->type = OSPF6_DEST_TYPE_NETWORK;
424 route->path.area_id = oi->area->area_id;
425 route->path.type = OSPF6_PATH_TYPE_INTRA;
426 route->path.cost = oi->cost;
427 route->nexthop[0].ifindex = oi->interface->ifindex;
428 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
429 ospf6_route_add (route, oi->route_connected);
432 /* create new Link-LSA */
433 OSPF6_LINK_LSA_SCHEDULE (oi);
434 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
435 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
439 ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
443 prev_state = oi->state;
444 oi->state = next_state;
446 if (prev_state == next_state)
450 if (IS_OSPF6_DEBUG_INTERFACE)
452 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
453 ospf6_interface_state_str[prev_state],
454 ospf6_interface_state_str[next_state]);
458 if ((prev_state == OSPF6_INTERFACE_DR ||
459 prev_state == OSPF6_INTERFACE_BDR) &&
460 (next_state != OSPF6_INTERFACE_DR &&
461 next_state != OSPF6_INTERFACE_BDR))
462 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
464 if ((prev_state != OSPF6_INTERFACE_DR &&
465 prev_state != OSPF6_INTERFACE_BDR) &&
466 (next_state == OSPF6_INTERFACE_DR ||
467 next_state == OSPF6_INTERFACE_BDR))
468 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
470 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
471 if (next_state == OSPF6_INTERFACE_DOWN)
473 OSPF6_NETWORK_LSA_EXECUTE (oi);
474 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
475 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
477 else if (prev_state == OSPF6_INTERFACE_DR ||
478 next_state == OSPF6_INTERFACE_DR)
480 OSPF6_NETWORK_LSA_SCHEDULE (oi);
481 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
482 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
486 /* Terminal state or regression */
487 if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
488 (next_state == OSPF6_INTERFACE_DROTHER) ||
489 (next_state == OSPF6_INTERFACE_BDR) ||
490 (next_state == OSPF6_INTERFACE_DR) ||
491 (next_state < prev_state))
492 ospf6TrapIfStateChange (oi);
498 /* DR Election, RFC2328 section 9.4 */
500 #define IS_ELIGIBLE(n) \
501 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
503 static struct ospf6_neighbor *
504 better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
506 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
507 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
509 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
511 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
514 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
516 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
519 if (a->priority > b->priority)
521 if (a->priority < b->priority)
524 if (ntohl (a->router_id) > ntohl (b->router_id))
526 if (ntohl (a->router_id) < ntohl (b->router_id))
529 zlog_warn ("Router-ID duplicate ?");
533 static struct ospf6_neighbor *
534 better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
536 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
537 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
539 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
541 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
544 if (a->drouter == a->router_id && b->drouter != b->router_id)
546 if (a->drouter != a->router_id && b->drouter == b->router_id)
549 if (a->priority > b->priority)
551 if (a->priority < b->priority)
554 if (ntohl (a->router_id) > ntohl (b->router_id))
556 if (ntohl (a->router_id) < ntohl (b->router_id))
559 zlog_warn ("Router-ID duplicate ?");
564 dr_election (struct ospf6_interface *oi)
566 struct listnode *node, *nnode;
567 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
568 struct ospf6_neighbor *best_drouter, *best_bdrouter;
569 u_char next_state = 0;
571 drouter = bdrouter = NULL;
572 best_drouter = best_bdrouter = NULL;
574 /* pseudo neighbor myself, including noting current DR/BDR (1) */
575 memset (&myself, 0, sizeof (myself));
576 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
577 sizeof (myself.name));
578 myself.state = OSPF6_NEIGHBOR_TWOWAY;
579 myself.drouter = oi->drouter;
580 myself.bdrouter = oi->bdrouter;
581 myself.priority = oi->priority;
582 myself.router_id = oi->area->ospf6->router_id;
584 /* Electing BDR (2) */
585 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
586 bdrouter = better_bdrouter (bdrouter, on);
588 best_bdrouter = bdrouter;
589 bdrouter = better_bdrouter (best_bdrouter, &myself);
591 /* Electing DR (3) */
592 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
593 drouter = better_drouter (drouter, on);
595 best_drouter = drouter;
596 drouter = better_drouter (best_drouter, &myself);
600 /* the router itself is newly/no longer DR/BDR (4) */
601 if ((drouter == &myself && myself.drouter != myself.router_id) ||
602 (drouter != &myself && myself.drouter == myself.router_id) ||
603 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
604 (bdrouter != &myself && myself.bdrouter == myself.router_id))
606 myself.drouter = (drouter ? drouter->router_id : htonl (0));
607 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
609 /* compatible to Electing BDR (2) */
610 bdrouter = better_bdrouter (best_bdrouter, &myself);
612 /* compatible to Electing DR (3) */
613 drouter = better_drouter (best_drouter, &myself);
618 /* Set interface state accordingly (5) */
619 if (drouter && drouter == &myself)
620 next_state = OSPF6_INTERFACE_DR;
621 else if (bdrouter && bdrouter == &myself)
622 next_state = OSPF6_INTERFACE_BDR;
624 next_state = OSPF6_INTERFACE_DROTHER;
626 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
629 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
630 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
631 accordingly after AdjOK */
632 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
633 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
635 if (IS_OSPF6_DEBUG_INTERFACE)
636 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
637 (drouter ? drouter->name : "0.0.0.0"),
638 (bdrouter ? bdrouter->name : "0.0.0.0"));
640 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
642 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
644 /* Schedule AdjOK. */
645 thread_add_event (master, adj_ok, on, 0);
649 oi->drouter = (drouter ? drouter->router_id : htonl (0));
650 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
655 /* Interface State Machine */
657 interface_up (struct thread *thread)
659 struct ospf6_interface *oi;
661 oi = (struct ospf6_interface *) THREAD_ARG (thread);
662 assert (oi && oi->interface);
664 if (IS_OSPF6_DEBUG_INTERFACE)
665 zlog_debug ("Interface Event %s: [InterfaceUp]",
666 oi->interface->name);
668 /* check physical interface is up */
669 if (! if_is_operative (oi->interface))
671 if (IS_OSPF6_DEBUG_INTERFACE)
672 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
673 oi->interface->name);
677 /* check interface has a link-local address */
678 if (! (ospf6_interface_get_linklocal_address(oi->interface)
679 || if_is_loopback(oi->interface)))
681 if (IS_OSPF6_DEBUG_INTERFACE)
682 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
683 oi->interface->name);
688 ospf6_interface_recalculate_cost (oi);
690 /* if already enabled, do nothing */
691 if (oi->state > OSPF6_INTERFACE_DOWN)
693 if (IS_OSPF6_DEBUG_INTERFACE)
694 zlog_debug ("Interface %s already enabled",
695 oi->interface->name);
699 /* If no area assigned, return */
700 if (oi->area == NULL)
702 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__,
703 oi->interface->name);
707 /* Join AllSPFRouters */
708 if (ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP) < 0)
710 if (oi->sso_try_cnt++ < OSPF6_INTERFACE_SSO_RETRY_MAX)
712 zlog_info("Scheduling %s for sso retry, trial count: %d",
713 oi->interface->name, oi->sso_try_cnt);
714 thread_add_timer (master, interface_up, oi,
715 OSPF6_INTERFACE_SSO_RETRY_INT);
719 oi->sso_try_cnt = 0; /* Reset on success */
721 /* Update interface route */
722 ospf6_interface_connected_route_update (oi->interface);
725 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
726 oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
728 /* decide next interface state */
729 if ((if_is_pointopoint (oi->interface)) ||
730 (oi->type == OSPF_IFTYPE_POINTOPOINT)) {
731 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
733 else if (oi->priority == 0)
734 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
737 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
738 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
745 wait_timer (struct thread *thread)
747 struct ospf6_interface *oi;
749 oi = (struct ospf6_interface *) THREAD_ARG (thread);
750 assert (oi && oi->interface);
752 if (IS_OSPF6_DEBUG_INTERFACE)
753 zlog_debug ("Interface Event %s: [WaitTimer]",
754 oi->interface->name);
756 if (oi->state == OSPF6_INTERFACE_WAITING)
757 ospf6_interface_state_change (dr_election (oi), oi);
763 backup_seen (struct thread *thread)
765 struct ospf6_interface *oi;
767 oi = (struct ospf6_interface *) THREAD_ARG (thread);
768 assert (oi && oi->interface);
770 if (IS_OSPF6_DEBUG_INTERFACE)
771 zlog_debug ("Interface Event %s: [BackupSeen]",
772 oi->interface->name);
774 if (oi->state == OSPF6_INTERFACE_WAITING)
775 ospf6_interface_state_change (dr_election (oi), oi);
781 neighbor_change (struct thread *thread)
783 struct ospf6_interface *oi;
785 oi = (struct ospf6_interface *) THREAD_ARG (thread);
786 assert (oi && oi->interface);
788 if (IS_OSPF6_DEBUG_INTERFACE)
789 zlog_debug ("Interface Event %s: [NeighborChange]",
790 oi->interface->name);
792 if (oi->state == OSPF6_INTERFACE_DROTHER ||
793 oi->state == OSPF6_INTERFACE_BDR ||
794 oi->state == OSPF6_INTERFACE_DR)
795 ospf6_interface_state_change (dr_election (oi), oi);
801 interface_down (struct thread *thread)
803 struct ospf6_interface *oi;
804 struct listnode *node, *nnode;
805 struct ospf6_neighbor *on;
807 oi = (struct ospf6_interface *) THREAD_ARG (thread);
808 assert (oi && oi->interface);
810 if (IS_OSPF6_DEBUG_INTERFACE)
811 zlog_debug ("Interface Event %s: [InterfaceDown]",
812 oi->interface->name);
815 THREAD_OFF (oi->thread_send_hello);
817 /* Leave AllSPFRouters */
818 if (oi->state > OSPF6_INTERFACE_DOWN)
819 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
821 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
823 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
824 ospf6_neighbor_delete (on);
826 list_delete_all_node (oi->neighbor_list);
828 /* When interface state is reset, also reset information about
829 * DR election, as it is no longer valid. */
830 oi->drouter = oi->prev_drouter = htonl(0);
831 oi->bdrouter = oi->prev_bdrouter = htonl(0);
836 /* show specified interface structure */
838 ospf6_interface_show (struct vty *vty, struct interface *ifp)
840 struct ospf6_interface *oi;
844 char strbuf[64], drouter[32], bdrouter[32];
845 const char *updown[3] = {"down", "up", NULL};
847 struct timeval res, now;
849 struct ospf6_lsa *lsa;
851 /* check physical interface type */
852 if (if_is_loopback (ifp))
854 else if (if_is_broadcast (ifp))
856 else if (if_is_pointopoint (ifp))
857 type = "POINTOPOINT";
861 vty_out (vty, "%s is %s, type %s%s",
862 ifp->name, updown[if_is_operative (ifp)], type,
864 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
866 if (ifp->info == NULL)
868 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
872 oi = (struct ospf6_interface *) ifp->info;
874 vty_out (vty, " Internet Address:%s", VNL);
876 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
879 prefix2str (p, strbuf, sizeof (strbuf));
883 vty_out (vty, " inet : %s%s", strbuf,
887 vty_out (vty, " inet6: %s%s", strbuf,
891 vty_out (vty, " ??? : %s%s", strbuf,
899 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
900 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
901 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
902 "disabled" : "enabled", VNL);
903 inet_ntop (AF_INET, &oi->area->area_id,
904 strbuf, sizeof (strbuf));
905 vty_out (vty, " Area ID %s, Cost %u%s", strbuf, oi->cost,
909 vty_out (vty, " Not Attached to Area%s", VNL);
911 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
912 ospf6_interface_state_str[oi->state],
913 oi->transdelay, oi->priority,
915 vty_out (vty, " Timer intervals configured:%s", VNL);
916 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
917 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
920 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
921 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
922 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
924 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
925 oi->lsdb->count, VNL);
927 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
930 if (oi->thread_send_lsupdate)
931 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
932 timerstring (&res, duration, sizeof (duration));
933 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
934 oi->lsupdate_list->count, duration,
935 (oi->thread_send_lsupdate ? "on" : "off"),
937 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
938 lsa = ospf6_lsdb_next (lsa))
939 vty_out (vty, " %s%s", lsa->name, VNL);
942 if (oi->thread_send_lsack)
943 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
944 timerstring (&res, duration, sizeof (duration));
945 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
946 oi->lsack_list->count, duration,
947 (oi->thread_send_lsack ? "on" : "off"),
949 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
950 lsa = ospf6_lsdb_next (lsa))
951 vty_out (vty, " %s%s", lsa->name, VNL);
957 DEFUN (show_ipv6_ospf6_interface,
958 show_ipv6_ospf6_interface_ifname_cmd,
959 "show ipv6 ospf6 interface IFNAME",
967 struct interface *ifp;
972 ifp = if_lookup_by_name (argv[0]);
975 vty_out (vty, "No such Interface: %s%s", argv[0],
979 ospf6_interface_show (vty, ifp);
983 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
984 ospf6_interface_show (vty, ifp);
990 ALIAS (show_ipv6_ospf6_interface,
991 show_ipv6_ospf6_interface_cmd,
992 "show ipv6 ospf6 interface",
999 DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
1000 show_ipv6_ospf6_interface_ifname_prefix_cmd,
1001 "show ipv6 ospf6 interface IFNAME prefix",
1007 "Display connected prefixes to advertise\n"
1010 struct interface *ifp;
1011 struct ospf6_interface *oi;
1013 ifp = if_lookup_by_name (argv[0]);
1016 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
1023 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
1029 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1034 ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1035 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
1036 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1042 "Display connected prefixes to advertise\n"
1043 OSPF6_ROUTE_ADDRESS_STR
1044 OSPF6_ROUTE_PREFIX_STR
1045 "Display details of the prefixes\n"
1048 ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1049 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
1050 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1056 "Display connected prefixes to advertise\n"
1057 OSPF6_ROUTE_PREFIX_STR
1058 OSPF6_ROUTE_MATCH_STR
1059 "Display details of the prefixes\n"
1062 DEFUN (show_ipv6_ospf6_interface_prefix,
1063 show_ipv6_ospf6_interface_prefix_cmd,
1064 "show ipv6 ospf6 interface prefix",
1069 "Display connected prefixes to advertise\n"
1073 struct ospf6_interface *oi;
1074 struct interface *ifp;
1076 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
1078 oi = (struct ospf6_interface *) ifp->info;
1082 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1088 ALIAS (show_ipv6_ospf6_interface_prefix,
1089 show_ipv6_ospf6_interface_prefix_detail_cmd,
1090 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1095 "Display connected prefixes to advertise\n"
1096 OSPF6_ROUTE_ADDRESS_STR
1097 OSPF6_ROUTE_PREFIX_STR
1098 "Display details of the prefixes\n"
1101 ALIAS (show_ipv6_ospf6_interface_prefix,
1102 show_ipv6_ospf6_interface_prefix_match_cmd,
1103 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1108 "Display connected prefixes to advertise\n"
1109 OSPF6_ROUTE_PREFIX_STR
1110 OSPF6_ROUTE_MATCH_STR
1111 "Display details of the prefixes\n"
1115 /* interface variable set command */
1116 DEFUN (ipv6_ospf6_ifmtu,
1117 ipv6_ospf6_ifmtu_cmd,
1118 "ipv6 ospf6 ifmtu <1-65535>",
1122 "OSPFv3 Interface MTU\n"
1125 struct ospf6_interface *oi;
1126 struct interface *ifp;
1127 unsigned int ifmtu, iobuflen;
1128 struct listnode *node, *nnode;
1129 struct ospf6_neighbor *on;
1131 ifp = (struct interface *) vty->index;
1134 oi = (struct ospf6_interface *) ifp->info;
1136 oi = ospf6_interface_create (ifp);
1139 ifmtu = strtol (argv[0], NULL, 10);
1141 if (oi->ifmtu == ifmtu)
1144 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
1146 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
1147 ifp->name, ifp->mtu6, VNL);
1151 if (oi->ifmtu < ifmtu)
1153 iobuflen = ospf6_iobuf_size (ifmtu);
1154 if (iobuflen < ifmtu)
1156 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1157 ifp->name, iobuflen, VNL);
1158 oi->ifmtu = iobuflen;
1166 /* re-establish adjacencies */
1167 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1169 THREAD_OFF (on->inactivity_timer);
1170 thread_add_event (master, inactivity_timer, on, 0);
1176 DEFUN (no_ipv6_ospf6_ifmtu,
1177 no_ipv6_ospf6_ifmtu_cmd,
1178 "no ipv6 ospf6 ifmtu",
1185 struct ospf6_interface *oi;
1186 struct interface *ifp;
1187 unsigned int iobuflen;
1188 struct listnode *node, *nnode;
1189 struct ospf6_neighbor *on;
1191 ifp = (struct interface *) vty->index;
1194 oi = (struct ospf6_interface *) ifp->info;
1196 oi = ospf6_interface_create (ifp);
1199 if (oi->ifmtu < ifp->mtu)
1201 iobuflen = ospf6_iobuf_size (ifp->mtu);
1202 if (iobuflen < ifp->mtu)
1204 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1205 ifp->name, iobuflen, VNL);
1206 oi->ifmtu = iobuflen;
1209 oi->ifmtu = ifp->mtu;
1212 oi->ifmtu = ifp->mtu;
1214 /* re-establish adjacencies */
1215 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1217 THREAD_OFF (on->inactivity_timer);
1218 thread_add_event (master, inactivity_timer, on, 0);
1224 DEFUN (ipv6_ospf6_cost,
1225 ipv6_ospf6_cost_cmd,
1226 "ipv6 ospf6 cost <1-65535>",
1230 "Outgoing metric of this interface\n"
1233 struct ospf6_interface *oi;
1234 struct interface *ifp;
1235 unsigned long int lcost;
1237 ifp = (struct interface *) vty->index;
1240 oi = (struct ospf6_interface *) ifp->info;
1242 oi = ospf6_interface_create (ifp);
1245 lcost = strtol (argv[0], NULL, 10);
1247 if (lcost > UINT32_MAX)
1249 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1253 if (oi->cost == lcost)
1257 SET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1259 ospf6_interface_recalculate_cost(oi);
1264 DEFUN (no_ipv6_ospf6_cost,
1265 no_ipv6_ospf6_cost_cmd,
1266 "no ipv6 ospf6 cost",
1270 "Calculate interface cost from bandwidth\n"
1273 struct ospf6_interface *oi;
1274 struct interface *ifp;
1276 ifp = (struct interface *) vty->index;
1279 oi = (struct ospf6_interface *) ifp->info;
1281 oi = ospf6_interface_create (ifp);
1284 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1286 ospf6_interface_recalculate_cost(oi);
1291 DEFUN (auto_cost_reference_bandwidth,
1292 auto_cost_reference_bandwidth_cmd,
1293 "auto-cost reference-bandwidth <1-4294967>",
1294 "Calculate OSPF interface cost according to bandwidth\n"
1295 "Use reference bandwidth method to assign OSPF cost\n"
1296 "The reference bandwidth in terms of Mbits per second\n")
1298 struct ospf6 *o = vty->index;
1299 struct ospf6_area *oa;
1300 struct ospf6_interface *oi;
1301 struct listnode *i, *j;
1304 refbw = strtol (argv[0], NULL, 10);
1305 if (refbw < 1 || refbw > 4294967)
1307 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
1311 /* If reference bandwidth is changed. */
1312 if ((refbw * 1000) == o->ref_bandwidth)
1315 o->ref_bandwidth = refbw * 1000;
1316 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1317 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1318 ospf6_interface_recalculate_cost (oi);
1323 DEFUN (no_auto_cost_reference_bandwidth,
1324 no_auto_cost_reference_bandwidth_cmd,
1325 "no auto-cost reference-bandwidth",
1327 "Calculate OSPF interface cost according to bandwidth\n"
1328 "Use reference bandwidth method to assign OSPF cost\n")
1330 struct ospf6 *o = vty->index;
1331 struct ospf6_area *oa;
1332 struct ospf6_interface *oi;
1333 struct listnode *i, *j;
1335 if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
1338 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
1339 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1340 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1341 ospf6_interface_recalculate_cost (oi);
1346 DEFUN (ipv6_ospf6_hellointerval,
1347 ipv6_ospf6_hellointerval_cmd,
1348 "ipv6 ospf6 hello-interval <1-65535>",
1351 "Interval time of Hello packets\n"
1355 struct ospf6_interface *oi;
1356 struct interface *ifp;
1358 ifp = (struct interface *) vty->index;
1361 oi = (struct ospf6_interface *) ifp->info;
1363 oi = ospf6_interface_create (ifp);
1366 oi->hello_interval = strtol (argv[0], NULL, 10);
1370 /* interface variable set command */
1371 DEFUN (ipv6_ospf6_deadinterval,
1372 ipv6_ospf6_deadinterval_cmd,
1373 "ipv6 ospf6 dead-interval <1-65535>",
1376 "Interval time after which a neighbor is declared down\n"
1380 struct ospf6_interface *oi;
1381 struct interface *ifp;
1383 ifp = (struct interface *) vty->index;
1386 oi = (struct ospf6_interface *) ifp->info;
1388 oi = ospf6_interface_create (ifp);
1391 oi->dead_interval = strtol (argv[0], NULL, 10);
1395 /* interface variable set command */
1396 DEFUN (ipv6_ospf6_transmitdelay,
1397 ipv6_ospf6_transmitdelay_cmd,
1398 "ipv6 ospf6 transmit-delay <1-3600>",
1401 "Transmit delay of this interface\n"
1405 struct ospf6_interface *oi;
1406 struct interface *ifp;
1408 ifp = (struct interface *) vty->index;
1411 oi = (struct ospf6_interface *) ifp->info;
1413 oi = ospf6_interface_create (ifp);
1416 oi->transdelay = strtol (argv[0], NULL, 10);
1420 /* interface variable set command */
1421 DEFUN (ipv6_ospf6_retransmitinterval,
1422 ipv6_ospf6_retransmitinterval_cmd,
1423 "ipv6 ospf6 retransmit-interval <1-65535>",
1426 "Time between retransmitting lost link state advertisements\n"
1430 struct ospf6_interface *oi;
1431 struct interface *ifp;
1433 ifp = (struct interface *) vty->index;
1436 oi = (struct ospf6_interface *) ifp->info;
1438 oi = ospf6_interface_create (ifp);
1441 oi->rxmt_interval = strtol (argv[0], NULL, 10);
1445 /* interface variable set command */
1446 DEFUN (ipv6_ospf6_priority,
1447 ipv6_ospf6_priority_cmd,
1448 "ipv6 ospf6 priority <0-255>",
1455 struct ospf6_interface *oi;
1456 struct interface *ifp;
1458 ifp = (struct interface *) vty->index;
1461 oi = (struct ospf6_interface *) ifp->info;
1463 oi = ospf6_interface_create (ifp);
1466 oi->priority = strtol (argv[0], NULL, 10);
1469 (oi->state == OSPF6_INTERFACE_DROTHER ||
1470 oi->state == OSPF6_INTERFACE_BDR ||
1471 oi->state == OSPF6_INTERFACE_DR))
1472 ospf6_interface_state_change (dr_election (oi), oi);
1477 DEFUN (ipv6_ospf6_instance,
1478 ipv6_ospf6_instance_cmd,
1479 "ipv6 ospf6 instance-id <0-255>",
1482 "Instance ID for this interface\n"
1483 "Instance ID value\n"
1486 struct ospf6_interface *oi;
1487 struct interface *ifp;
1489 ifp = (struct interface *)vty->index;
1492 oi = (struct ospf6_interface *)ifp->info;
1494 oi = ospf6_interface_create (ifp);
1497 oi->instance_id = strtol (argv[0], NULL, 10);
1501 DEFUN (ipv6_ospf6_passive,
1502 ipv6_ospf6_passive_cmd,
1503 "ipv6 ospf6 passive",
1506 "passive interface, No adjacency will be formed on this interface\n"
1509 struct ospf6_interface *oi;
1510 struct interface *ifp;
1511 struct listnode *node, *nnode;
1512 struct ospf6_neighbor *on;
1514 ifp = (struct interface *) vty->index;
1517 oi = (struct ospf6_interface *) ifp->info;
1519 oi = ospf6_interface_create (ifp);
1522 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1523 THREAD_OFF (oi->thread_send_hello);
1525 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1527 THREAD_OFF (on->inactivity_timer);
1528 thread_add_event (master, inactivity_timer, on, 0);
1534 DEFUN (no_ipv6_ospf6_passive,
1535 no_ipv6_ospf6_passive_cmd,
1536 "no ipv6 ospf6 passive",
1540 "passive interface: No Adjacency will be formed on this I/F\n"
1543 struct ospf6_interface *oi;
1544 struct interface *ifp;
1546 ifp = (struct interface *) vty->index;
1549 oi = (struct ospf6_interface *) ifp->info;
1551 oi = ospf6_interface_create (ifp);
1554 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1555 THREAD_OFF (oi->thread_send_hello);
1556 oi->thread_send_hello =
1557 thread_add_event (master, ospf6_hello_send, oi, 0);
1562 DEFUN (ipv6_ospf6_mtu_ignore,
1563 ipv6_ospf6_mtu_ignore_cmd,
1564 "ipv6 ospf6 mtu-ignore",
1567 "Ignore MTU mismatch on this interface\n"
1570 struct ospf6_interface *oi;
1571 struct interface *ifp;
1573 ifp = (struct interface *) vty->index;
1576 oi = (struct ospf6_interface *) ifp->info;
1578 oi = ospf6_interface_create (ifp);
1586 DEFUN (no_ipv6_ospf6_mtu_ignore,
1587 no_ipv6_ospf6_mtu_ignore_cmd,
1588 "no ipv6 ospf6 mtu-ignore",
1592 "Ignore MTU mismatch on this interface\n"
1595 struct ospf6_interface *oi;
1596 struct interface *ifp;
1598 ifp = (struct interface *) vty->index;
1601 oi = (struct ospf6_interface *) ifp->info;
1603 oi = ospf6_interface_create (ifp);
1611 DEFUN (ipv6_ospf6_advertise_prefix_list,
1612 ipv6_ospf6_advertise_prefix_list_cmd,
1613 "ipv6 ospf6 advertise prefix-list WORD",
1616 "Advertising options\n"
1617 "Filter prefix using prefix-list\n"
1618 "Prefix list name\n"
1621 struct ospf6_interface *oi;
1622 struct interface *ifp;
1624 ifp = (struct interface *) vty->index;
1627 oi = (struct ospf6_interface *) ifp->info;
1629 oi = ospf6_interface_create (ifp);
1633 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1634 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
1636 ospf6_interface_connected_route_update (oi->interface);
1640 OSPF6_LINK_LSA_SCHEDULE (oi);
1641 if (oi->state == OSPF6_INTERFACE_DR)
1643 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1644 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1646 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1652 DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1653 no_ipv6_ospf6_advertise_prefix_list_cmd,
1654 "no ipv6 ospf6 advertise prefix-list",
1658 "Advertising options\n"
1659 "Filter prefix using prefix-list\n"
1662 struct ospf6_interface *oi;
1663 struct interface *ifp;
1665 ifp = (struct interface *) vty->index;
1668 oi = (struct ospf6_interface *) ifp->info;
1670 oi = ospf6_interface_create (ifp);
1675 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1676 oi->plist_name = NULL;
1679 ospf6_interface_connected_route_update (oi->interface);
1683 OSPF6_LINK_LSA_SCHEDULE (oi);
1684 if (oi->state == OSPF6_INTERFACE_DR)
1686 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1687 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1689 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1695 DEFUN (ipv6_ospf6_network,
1696 ipv6_ospf6_network_cmd,
1697 "ipv6 ospf6 network (broadcast|point-to-point)",
1701 "Specify OSPFv6 broadcast network\n"
1702 "Specify OSPF6 point-to-point network\n"
1705 struct ospf6_interface *oi;
1706 struct interface *ifp;
1708 ifp = (struct interface *) vty->index;
1711 oi = (struct ospf6_interface *) ifp->info;
1713 oi = ospf6_interface_create (ifp);
1717 if (strncmp (argv[0], "b", 1) == 0)
1719 if (oi->type == OSPF_IFTYPE_BROADCAST)
1722 oi->type = OSPF_IFTYPE_BROADCAST;
1724 else if (strncmp (argv[0], "point-to-p", 10) == 0)
1726 if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
1729 oi->type = OSPF_IFTYPE_POINTOPOINT;
1732 /* Reset the interface */
1733 thread_add_event (master, interface_down, oi, 0);
1734 thread_add_event (master, interface_up, oi, 0);
1739 DEFUN (no_ipv6_ospf6_network,
1740 no_ipv6_ospf6_network_cmd,
1741 "no ipv6 ospf6 network",
1746 "Default to whatever interface type system specifies"
1749 struct ospf6_interface *oi;
1750 struct interface *ifp;
1753 ifp = (struct interface *) vty->index;
1756 oi = (struct ospf6_interface *) ifp->info;
1761 type = ospf6_default_iftype (ifp);
1762 if (oi->type == type)
1768 /* Reset the interface */
1769 thread_add_event (master, interface_down, oi, 0);
1770 thread_add_event (master, interface_up, oi, 0);
1776 config_write_ospf6_interface (struct vty *vty)
1779 struct ospf6_interface *oi;
1780 struct interface *ifp;
1782 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
1784 oi = (struct ospf6_interface *) ifp->info;
1788 vty_out (vty, "interface %s%s",
1789 oi->interface->name, VNL);
1792 vty_out (vty, " description %s%s", ifp->desc, VNL);
1793 if (ifp->mtu6 != oi->ifmtu)
1794 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
1796 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
1797 vty_out (vty, " ipv6 ospf6 cost %d%s",
1800 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1801 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1802 oi->hello_interval, VNL);
1804 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1805 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1806 oi->dead_interval, VNL);
1808 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1809 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1810 oi->rxmt_interval, VNL);
1812 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1813 vty_out (vty, " ipv6 ospf6 priority %d%s",
1816 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1817 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1818 oi->transdelay, VNL);
1820 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1821 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1822 oi->instance_id, VNL);
1825 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
1826 oi->plist_name, VNL);
1828 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
1829 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
1832 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1834 if (oi->type == OSPF_IFTYPE_POINTOPOINT)
1835 vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
1836 else if (oi->type == OSPF_IFTYPE_BROADCAST)
1837 vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
1839 vty_out (vty, "!%s", VNL);
1844 static struct cmd_node interface_node =
1852 ospf6_interface_init (void)
1854 /* Install interface node. */
1855 install_node (&interface_node, config_write_ospf6_interface);
1857 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
1858 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1859 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1860 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
1861 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
1862 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1863 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1864 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
1866 install_element (CONFIG_NODE, &interface_cmd);
1867 install_default (INTERFACE_NODE);
1868 install_element (INTERFACE_NODE, &interface_desc_cmd);
1869 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1870 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
1871 install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
1872 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
1873 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
1874 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1875 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1876 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1877 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1878 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1879 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
1881 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1882 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
1884 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1885 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1887 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1888 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1890 install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
1891 install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
1893 /* reference bandwidth commands */
1894 install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
1895 install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
1898 /* Clear the specified interface structure */
1900 ospf6_interface_clear (struct vty *vty, struct interface *ifp)
1902 struct ospf6_interface *oi;
1904 if (!if_is_operative (ifp))
1907 if (ifp->info == NULL)
1910 oi = (struct ospf6_interface *) ifp->info;
1912 if (IS_OSPF6_DEBUG_INTERFACE)
1913 zlog_debug ("Interface %s: clear by reset", ifp->name);
1915 /* Reset the interface */
1916 thread_add_event (master, interface_down, oi, 0);
1917 thread_add_event (master, interface_up, oi, 0);
1920 /* Clear interface */
1921 DEFUN (clear_ipv6_ospf6_interface,
1922 clear_ipv6_ospf6_interface_cmd,
1923 "clear ipv6 ospf6 interface [IFNAME]",
1931 struct interface *ifp;
1932 struct listnode *node;
1934 if (argc == 0) /* Clear all the ospfv3 interfaces. */
1936 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
1937 ospf6_interface_clear (vty, ifp);
1939 else /* Interface name is specified. */
1941 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
1943 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
1946 ospf6_interface_clear (vty, ifp);
1953 install_element_ospf6_clear_interface (void)
1955 install_element (ENABLE_NODE, &clear_ipv6_ospf6_interface_cmd);
1958 DEFUN (debug_ospf6_interface,
1959 debug_ospf6_interface_cmd,
1960 "debug ospf6 interface",
1963 "Debug OSPFv3 Interface\n"
1966 OSPF6_DEBUG_INTERFACE_ON ();
1970 DEFUN (no_debug_ospf6_interface,
1971 no_debug_ospf6_interface_cmd,
1972 "no debug ospf6 interface",
1976 "Debug OSPFv3 Interface\n"
1979 OSPF6_DEBUG_INTERFACE_OFF ();
1984 config_write_ospf6_debug_interface (struct vty *vty)
1986 if (IS_OSPF6_DEBUG_INTERFACE)
1987 vty_out (vty, "debug ospf6 interface%s", VNL);
1992 install_element_ospf6_debug_interface (void)
1994 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1995 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1996 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1997 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);