[release] Bump version to 0.99.11
[jleu-quagga.git] / ospf6d / ospf6_interface.c
blob8d9a7f01691cc9ef41f7642f37b23c7db6d419e6
1 /*
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
9 * later version.
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.
22 #include <zebra.h>
24 #include "memory.h"
25 #include "if.h"
26 #include "log.h"
27 #include "command.h"
28 #include "thread.h"
29 #include "prefix.h"
30 #include "plist.h"
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 "ospf6d.h"
45 unsigned char conf_debug_ospf6_interface = 0;
47 const char *ospf6_interface_state_str[] =
49 "None",
50 "Down",
51 "Loopback",
52 "Waiting",
53 "PointToPoint",
54 "DROther",
55 "BDR",
56 "DR",
57 NULL
60 struct ospf6_interface *
61 ospf6_interface_lookup_by_ifindex (int ifindex)
63 struct ospf6_interface *oi;
64 struct interface *ifp;
66 ifp = if_lookup_by_index (ifindex);
67 if (ifp == NULL)
68 return (struct ospf6_interface *) NULL;
70 oi = (struct ospf6_interface *) ifp->info;
71 return oi;
74 /* schedule routing table recalculation */
75 static void
76 ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa)
78 switch (ntohs (lsa->header->type))
80 case OSPF6_LSTYPE_LINK:
81 if (OSPF6_INTERFACE (lsa->lsdb->data)->state == OSPF6_INTERFACE_DR)
82 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (OSPF6_INTERFACE (lsa->lsdb->data));
83 ospf6_spf_schedule (OSPF6_INTERFACE (lsa->lsdb->data)->area);
84 break;
86 default:
87 break;
91 /* Create new ospf6 interface structure */
92 struct ospf6_interface *
93 ospf6_interface_create (struct interface *ifp)
95 struct ospf6_interface *oi;
96 unsigned int iobuflen;
98 oi = (struct ospf6_interface *)
99 XMALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
101 if (oi)
102 memset (oi, 0, sizeof (struct ospf6_interface));
103 else
105 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
106 return (struct ospf6_interface *) NULL;
109 oi->area = (struct ospf6_area *) NULL;
110 oi->neighbor_list = list_new ();
111 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
112 oi->linklocal_addr = (struct in6_addr *) NULL;
113 oi->instance_id = 0;
114 oi->transdelay = 1;
115 oi->priority = 1;
117 oi->hello_interval = 10;
118 oi->dead_interval = 40;
119 oi->rxmt_interval = 5;
120 oi->cost = 1;
121 oi->state = OSPF6_INTERFACE_DOWN;
122 oi->flag = 0;
124 /* Try to adjust I/O buffer size with IfMtu */
125 oi->ifmtu = ifp->mtu6;
126 iobuflen = ospf6_iobuf_size (ifp->mtu6);
127 if (oi->ifmtu > iobuflen)
129 if (IS_OSPF6_DEBUG_INTERFACE)
130 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
131 ifp->name, iobuflen);
132 oi->ifmtu = iobuflen;
135 oi->lsupdate_list = ospf6_lsdb_create (oi);
136 oi->lsack_list = ospf6_lsdb_create (oi);
137 oi->lsdb = ospf6_lsdb_create (oi);
138 oi->lsdb->hook_add = ospf6_interface_lsdb_hook;
139 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook;
140 oi->lsdb_self = ospf6_lsdb_create (oi);
142 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
143 oi->route_connected->scope = oi;
145 /* link both */
146 oi->interface = ifp;
147 ifp->info = oi;
149 return oi;
152 void
153 ospf6_interface_delete (struct ospf6_interface *oi)
155 struct listnode *node, *nnode;
156 struct ospf6_neighbor *on;
158 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
159 ospf6_neighbor_delete (on);
161 list_delete (oi->neighbor_list);
163 THREAD_OFF (oi->thread_send_hello);
164 THREAD_OFF (oi->thread_send_lsupdate);
165 THREAD_OFF (oi->thread_send_lsack);
167 ospf6_lsdb_remove_all (oi->lsdb);
168 ospf6_lsdb_remove_all (oi->lsupdate_list);
169 ospf6_lsdb_remove_all (oi->lsack_list);
171 ospf6_lsdb_delete (oi->lsdb);
172 ospf6_lsdb_delete (oi->lsdb_self);
174 ospf6_lsdb_delete (oi->lsupdate_list);
175 ospf6_lsdb_delete (oi->lsack_list);
177 ospf6_route_table_delete (oi->route_connected);
179 /* cut link */
180 oi->interface->info = NULL;
182 /* plist_name */
183 if (oi->plist_name)
184 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
186 XFREE (MTYPE_OSPF6_IF, oi);
189 void
190 ospf6_interface_enable (struct ospf6_interface *oi)
192 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
194 oi->thread_send_hello =
195 thread_add_event (master, ospf6_hello_send, oi, 0);
198 void
199 ospf6_interface_disable (struct ospf6_interface *oi)
201 struct listnode *node, *nnode;
202 struct ospf6_neighbor *on;
204 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
206 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
207 ospf6_neighbor_delete (on);
209 list_delete_all_node (oi->neighbor_list);
211 ospf6_lsdb_remove_all (oi->lsdb);
212 ospf6_lsdb_remove_all (oi->lsupdate_list);
213 ospf6_lsdb_remove_all (oi->lsack_list);
215 THREAD_OFF (oi->thread_send_hello);
216 THREAD_OFF (oi->thread_send_lsupdate);
217 THREAD_OFF (oi->thread_send_lsack);
220 static struct in6_addr *
221 ospf6_interface_get_linklocal_address (struct interface *ifp)
223 struct listnode *n;
224 struct connected *c;
225 struct in6_addr *l = (struct in6_addr *) NULL;
227 /* for each connected address */
228 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
230 /* if family not AF_INET6, ignore */
231 if (c->address->family != AF_INET6)
232 continue;
234 /* linklocal scope check */
235 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
236 l = &c->address->u.prefix6;
238 return l;
241 void
242 ospf6_interface_if_add (struct interface *ifp)
244 struct ospf6_interface *oi;
245 unsigned int iobuflen;
247 oi = (struct ospf6_interface *) ifp->info;
248 if (oi == NULL)
249 return;
251 /* Try to adjust I/O buffer size with IfMtu */
252 if (oi->ifmtu == 0)
253 oi->ifmtu = ifp->mtu6;
254 iobuflen = ospf6_iobuf_size (ifp->mtu6);
255 if (oi->ifmtu > iobuflen)
257 if (IS_OSPF6_DEBUG_INTERFACE)
258 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
259 ifp->name, iobuflen);
260 oi->ifmtu = iobuflen;
263 /* interface start */
264 if (oi->area)
265 thread_add_event (master, interface_up, oi, 0);
268 void
269 ospf6_interface_if_del (struct interface *ifp)
271 struct ospf6_interface *oi;
273 oi = (struct ospf6_interface *) ifp->info;
274 if (oi == NULL)
275 return;
277 /* interface stop */
278 if (oi->area)
279 thread_execute (master, interface_down, oi, 0);
281 listnode_delete (oi->area->if_list, oi);
282 oi->area = (struct ospf6_area *) NULL;
284 /* cut link */
285 oi->interface = NULL;
286 ifp->info = NULL;
288 ospf6_interface_delete (oi);
291 void
292 ospf6_interface_state_update (struct interface *ifp)
294 struct ospf6_interface *oi;
296 oi = (struct ospf6_interface *) ifp->info;
297 if (oi == NULL)
298 return;
299 if (oi->area == NULL)
300 return;
302 if (if_is_up (ifp))
303 thread_add_event (master, interface_up, oi, 0);
304 else
305 thread_add_event (master, interface_down, oi, 0);
307 return;
310 void
311 ospf6_interface_connected_route_update (struct interface *ifp)
313 struct ospf6_interface *oi;
314 struct ospf6_route *route;
315 struct connected *c;
316 struct listnode *node, *nnode;
318 oi = (struct ospf6_interface *) ifp->info;
319 if (oi == NULL)
320 return;
322 /* reset linklocal pointer */
323 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
325 /* if area is null, do not make connected-route list */
326 if (oi->area == NULL)
327 return;
329 /* update "route to advertise" interface route table */
330 ospf6_route_remove_all (oi->route_connected);
332 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
334 if (c->address->family != AF_INET6)
335 continue;
337 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
338 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
339 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
340 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
341 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
343 /* apply filter */
344 if (oi->plist_name)
346 struct prefix_list *plist;
347 enum prefix_list_type ret;
348 char buf[128];
350 prefix2str (c->address, buf, sizeof (buf));
351 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
352 ret = prefix_list_apply (plist, (void *) c->address);
353 if (ret == PREFIX_DENY)
355 if (IS_OSPF6_DEBUG_INTERFACE)
356 zlog_debug ("%s on %s filtered by prefix-list %s ",
357 buf, oi->interface->name, oi->plist_name);
358 continue;
362 route = ospf6_route_create ();
363 memcpy (&route->prefix, c->address, sizeof (struct prefix));
364 apply_mask (&route->prefix);
365 route->type = OSPF6_DEST_TYPE_NETWORK;
366 route->path.area_id = oi->area->area_id;
367 route->path.type = OSPF6_PATH_TYPE_INTRA;
368 route->path.cost = oi->cost;
369 route->nexthop[0].ifindex = oi->interface->ifindex;
370 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
371 ospf6_route_add (route, oi->route_connected);
374 /* create new Link-LSA */
375 OSPF6_LINK_LSA_SCHEDULE (oi);
376 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
377 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
380 static void
381 ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
383 u_char prev_state;
385 prev_state = oi->state;
386 oi->state = next_state;
388 if (prev_state == next_state)
389 return;
391 /* log */
392 if (IS_OSPF6_DEBUG_INTERFACE)
394 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
395 ospf6_interface_state_str[prev_state],
396 ospf6_interface_state_str[next_state]);
399 if ((prev_state == OSPF6_INTERFACE_DR ||
400 prev_state == OSPF6_INTERFACE_BDR) &&
401 (next_state != OSPF6_INTERFACE_DR &&
402 next_state != OSPF6_INTERFACE_BDR))
403 ospf6_leave_alldrouters (oi->interface->ifindex);
404 if ((prev_state != OSPF6_INTERFACE_DR &&
405 prev_state != OSPF6_INTERFACE_BDR) &&
406 (next_state == OSPF6_INTERFACE_DR ||
407 next_state == OSPF6_INTERFACE_BDR))
408 ospf6_join_alldrouters (oi->interface->ifindex);
410 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
411 if (next_state == OSPF6_INTERFACE_DOWN)
413 OSPF6_NETWORK_LSA_EXECUTE (oi);
414 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
415 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
417 else if (prev_state == OSPF6_INTERFACE_DR ||
418 next_state == OSPF6_INTERFACE_DR)
420 OSPF6_NETWORK_LSA_SCHEDULE (oi);
421 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
422 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
427 /* DR Election, RFC2328 section 9.4 */
429 #define IS_ELIGIBLE(n) \
430 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
432 static struct ospf6_neighbor *
433 better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
435 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
436 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
437 return NULL;
438 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
439 return b;
440 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
441 return a;
443 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
444 return a;
445 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
446 return b;
448 if (a->priority > b->priority)
449 return a;
450 if (a->priority < b->priority)
451 return b;
453 if (ntohl (a->router_id) > ntohl (b->router_id))
454 return a;
455 if (ntohl (a->router_id) < ntohl (b->router_id))
456 return b;
458 zlog_warn ("Router-ID duplicate ?");
459 return a;
462 static struct ospf6_neighbor *
463 better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
465 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
466 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
467 return NULL;
468 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
469 return b;
470 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
471 return a;
473 if (a->drouter == a->router_id && b->drouter != b->router_id)
474 return a;
475 if (a->drouter != a->router_id && b->drouter == b->router_id)
476 return b;
478 if (a->priority > b->priority)
479 return a;
480 if (a->priority < b->priority)
481 return b;
483 if (ntohl (a->router_id) > ntohl (b->router_id))
484 return a;
485 if (ntohl (a->router_id) < ntohl (b->router_id))
486 return b;
488 zlog_warn ("Router-ID duplicate ?");
489 return a;
492 static u_char
493 dr_election (struct ospf6_interface *oi)
495 struct listnode *node, *nnode;
496 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
497 struct ospf6_neighbor *best_drouter, *best_bdrouter;
498 u_char next_state = 0;
500 drouter = bdrouter = NULL;
501 best_drouter = best_bdrouter = NULL;
503 /* pseudo neighbor myself, including noting current DR/BDR (1) */
504 memset (&myself, 0, sizeof (myself));
505 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
506 sizeof (myself.name));
507 myself.state = OSPF6_NEIGHBOR_TWOWAY;
508 myself.drouter = oi->drouter;
509 myself.bdrouter = oi->bdrouter;
510 myself.priority = oi->priority;
511 myself.router_id = oi->area->ospf6->router_id;
513 /* Electing BDR (2) */
514 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
515 bdrouter = better_bdrouter (bdrouter, on);
517 best_bdrouter = bdrouter;
518 bdrouter = better_bdrouter (best_bdrouter, &myself);
520 /* Electing DR (3) */
521 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
522 drouter = better_drouter (drouter, on);
524 best_drouter = drouter;
525 drouter = better_drouter (best_drouter, &myself);
526 if (drouter == NULL)
527 drouter = bdrouter;
529 /* the router itself is newly/no longer DR/BDR (4) */
530 if ((drouter == &myself && myself.drouter != myself.router_id) ||
531 (drouter != &myself && myself.drouter == myself.router_id) ||
532 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
533 (bdrouter != &myself && myself.bdrouter == myself.router_id))
535 myself.drouter = (drouter ? drouter->router_id : htonl (0));
536 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
538 /* compatible to Electing BDR (2) */
539 bdrouter = better_bdrouter (best_bdrouter, &myself);
541 /* compatible to Electing DR (3) */
542 drouter = better_drouter (best_drouter, &myself);
543 if (drouter == NULL)
544 drouter = bdrouter;
547 /* Set interface state accordingly (5) */
548 if (drouter && drouter == &myself)
549 next_state = OSPF6_INTERFACE_DR;
550 else if (bdrouter && bdrouter == &myself)
551 next_state = OSPF6_INTERFACE_BDR;
552 else
553 next_state = OSPF6_INTERFACE_DROTHER;
555 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
556 /* XXX */
558 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
559 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
560 accordingly after AdjOK */
561 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
562 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
564 if (IS_OSPF6_DEBUG_INTERFACE)
565 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
566 (drouter ? drouter->name : "0.0.0.0"),
567 (bdrouter ? bdrouter->name : "0.0.0.0"));
569 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
571 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
572 continue;
573 /* Schedule AdjOK. */
574 thread_add_event (master, adj_ok, on, 0);
578 oi->drouter = (drouter ? drouter->router_id : htonl (0));
579 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
580 return next_state;
584 /* Interface State Machine */
586 interface_up (struct thread *thread)
588 struct ospf6_interface *oi;
590 oi = (struct ospf6_interface *) THREAD_ARG (thread);
591 assert (oi && oi->interface);
593 if (IS_OSPF6_DEBUG_INTERFACE)
594 zlog_debug ("Interface Event %s: [InterfaceUp]",
595 oi->interface->name);
597 /* check physical interface is up */
598 if (! if_is_up (oi->interface))
600 if (IS_OSPF6_DEBUG_INTERFACE)
601 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
602 oi->interface->name);
603 return 0;
606 /* if already enabled, do nothing */
607 if (oi->state > OSPF6_INTERFACE_DOWN)
609 if (IS_OSPF6_DEBUG_INTERFACE)
610 zlog_debug ("Interface %s already enabled",
611 oi->interface->name);
612 return 0;
615 /* Join AllSPFRouters */
616 ospf6_join_allspfrouters (oi->interface->ifindex);
618 /* Update interface route */
619 ospf6_interface_connected_route_update (oi->interface);
621 /* Schedule Hello */
622 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
623 thread_add_event (master, ospf6_hello_send, oi, 0);
625 /* decide next interface state */
626 if (if_is_pointopoint (oi->interface))
627 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
628 else if (oi->priority == 0)
629 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
630 else
632 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
633 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
636 return 0;
640 wait_timer (struct thread *thread)
642 struct ospf6_interface *oi;
644 oi = (struct ospf6_interface *) THREAD_ARG (thread);
645 assert (oi && oi->interface);
647 if (IS_OSPF6_DEBUG_INTERFACE)
648 zlog_debug ("Interface Event %s: [WaitTimer]",
649 oi->interface->name);
651 if (oi->state == OSPF6_INTERFACE_WAITING)
652 ospf6_interface_state_change (dr_election (oi), oi);
654 return 0;
658 backup_seen (struct thread *thread)
660 struct ospf6_interface *oi;
662 oi = (struct ospf6_interface *) THREAD_ARG (thread);
663 assert (oi && oi->interface);
665 if (IS_OSPF6_DEBUG_INTERFACE)
666 zlog_debug ("Interface Event %s: [BackupSeen]",
667 oi->interface->name);
669 if (oi->state == OSPF6_INTERFACE_WAITING)
670 ospf6_interface_state_change (dr_election (oi), oi);
672 return 0;
676 neighbor_change (struct thread *thread)
678 struct ospf6_interface *oi;
680 oi = (struct ospf6_interface *) THREAD_ARG (thread);
681 assert (oi && oi->interface);
683 if (IS_OSPF6_DEBUG_INTERFACE)
684 zlog_debug ("Interface Event %s: [NeighborChange]",
685 oi->interface->name);
687 if (oi->state == OSPF6_INTERFACE_DROTHER ||
688 oi->state == OSPF6_INTERFACE_BDR ||
689 oi->state == OSPF6_INTERFACE_DR)
690 ospf6_interface_state_change (dr_election (oi), oi);
692 return 0;
695 static int
696 loopind (struct thread *thread)
698 struct ospf6_interface *oi;
700 oi = (struct ospf6_interface *) THREAD_ARG (thread);
701 assert (oi && oi->interface);
703 if (IS_OSPF6_DEBUG_INTERFACE)
704 zlog_debug ("Interface Event %s: [LoopInd]",
705 oi->interface->name);
707 /* XXX not yet */
709 return 0;
713 interface_down (struct thread *thread)
715 struct ospf6_interface *oi;
716 struct listnode *node, *nnode;
717 struct ospf6_neighbor *on;
719 oi = (struct ospf6_interface *) THREAD_ARG (thread);
720 assert (oi && oi->interface);
722 if (IS_OSPF6_DEBUG_INTERFACE)
723 zlog_debug ("Interface Event %s: [InterfaceDown]",
724 oi->interface->name);
726 /* Leave AllSPFRouters */
727 if (oi->state > OSPF6_INTERFACE_DOWN)
728 ospf6_leave_allspfrouters (oi->interface->ifindex);
730 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
732 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
733 ospf6_neighbor_delete (on);
735 list_delete_all_node (oi->neighbor_list);
737 return 0;
741 /* show specified interface structure */
742 static int
743 ospf6_interface_show (struct vty *vty, struct interface *ifp)
745 struct ospf6_interface *oi;
746 struct connected *c;
747 struct prefix *p;
748 struct listnode *i;
749 char strbuf[64], drouter[32], bdrouter[32];
750 const char *updown[3] = {"down", "up", NULL};
751 const char *type;
752 struct timeval res, now;
753 char duration[32];
754 struct ospf6_lsa *lsa;
756 /* check physical interface type */
757 if (if_is_loopback (ifp))
758 type = "LOOPBACK";
759 else if (if_is_broadcast (ifp))
760 type = "BROADCAST";
761 else if (if_is_pointopoint (ifp))
762 type = "POINTOPOINT";
763 else
764 type = "UNKNOWN";
766 vty_out (vty, "%s is %s, type %s%s",
767 ifp->name, updown[if_is_up (ifp)], type,
768 VNL);
769 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
771 if (ifp->info == NULL)
773 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
774 return 0;
776 else
777 oi = (struct ospf6_interface *) ifp->info;
779 vty_out (vty, " Internet Address:%s", VNL);
781 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
783 p = c->address;
784 prefix2str (p, strbuf, sizeof (strbuf));
785 switch (p->family)
787 case AF_INET:
788 vty_out (vty, " inet : %s%s", strbuf,
789 VNL);
790 break;
791 case AF_INET6:
792 vty_out (vty, " inet6: %s%s", strbuf,
793 VNL);
794 break;
795 default:
796 vty_out (vty, " ??? : %s%s", strbuf,
797 VNL);
798 break;
802 if (oi->area)
804 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
805 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
806 inet_ntop (AF_INET, &oi->area->area_id,
807 strbuf, sizeof (strbuf));
808 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
809 VNL);
811 else
812 vty_out (vty, " Not Attached to Area%s", VNL);
814 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
815 ospf6_interface_state_str[oi->state],
816 oi->transdelay, oi->priority,
817 VNL);
818 vty_out (vty, " Timer intervals configured:%s", VNL);
819 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
820 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
821 VNL);
823 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
824 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
825 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
827 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
828 oi->lsdb->count, VNL);
830 gettimeofday (&now, (struct timezone *) NULL);
832 timerclear (&res);
833 if (oi->thread_send_lsupdate)
834 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
835 timerstring (&res, duration, sizeof (duration));
836 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
837 oi->lsupdate_list->count, duration,
838 (oi->thread_send_lsupdate ? "on" : "off"),
839 VNL);
840 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
841 lsa = ospf6_lsdb_next (lsa))
842 vty_out (vty, " %s%s", lsa->name, VNL);
844 timerclear (&res);
845 if (oi->thread_send_lsack)
846 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
847 timerstring (&res, duration, sizeof (duration));
848 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
849 oi->lsack_list->count, duration,
850 (oi->thread_send_lsack ? "on" : "off"),
851 VNL);
852 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
853 lsa = ospf6_lsdb_next (lsa))
854 vty_out (vty, " %s%s", lsa->name, VNL);
856 return 0;
859 /* show interface */
860 DEFUN (show_ipv6_ospf6_interface,
861 show_ipv6_ospf6_interface_ifname_cmd,
862 "show ipv6 ospf6 interface IFNAME",
863 SHOW_STR
864 IP6_STR
865 OSPF6_STR
866 INTERFACE_STR
867 IFNAME_STR
870 struct interface *ifp;
871 struct listnode *i;
873 if (argc)
875 ifp = if_lookup_by_name (argv[0]);
876 if (ifp == NULL)
878 vty_out (vty, "No such Interface: %s%s", argv[0],
879 VNL);
880 return CMD_WARNING;
882 ospf6_interface_show (vty, ifp);
884 else
886 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
887 ospf6_interface_show (vty, ifp);
890 return CMD_SUCCESS;
893 ALIAS (show_ipv6_ospf6_interface,
894 show_ipv6_ospf6_interface_cmd,
895 "show ipv6 ospf6 interface",
896 SHOW_STR
897 IP6_STR
898 OSPF6_STR
899 INTERFACE_STR
902 DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
903 show_ipv6_ospf6_interface_ifname_prefix_cmd,
904 "show ipv6 ospf6 interface IFNAME prefix",
905 SHOW_STR
906 IP6_STR
907 OSPF6_STR
908 INTERFACE_STR
909 IFNAME_STR
910 "Display connected prefixes to advertise\n"
913 struct interface *ifp;
914 struct ospf6_interface *oi;
916 ifp = if_lookup_by_name (argv[0]);
917 if (ifp == NULL)
919 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
920 return CMD_WARNING;
923 oi = ifp->info;
924 if (oi == NULL)
926 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
927 return CMD_WARNING;
930 argc--;
931 argv++;
932 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
934 return CMD_SUCCESS;
937 ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
938 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
939 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
940 SHOW_STR
941 IP6_STR
942 OSPF6_STR
943 INTERFACE_STR
944 IFNAME_STR
945 "Display connected prefixes to advertise\n"
946 OSPF6_ROUTE_ADDRESS_STR
947 OSPF6_ROUTE_PREFIX_STR
948 "Dispaly details of the prefixes\n"
951 ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
952 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
953 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
954 SHOW_STR
955 IP6_STR
956 OSPF6_STR
957 INTERFACE_STR
958 IFNAME_STR
959 "Display connected prefixes to advertise\n"
960 OSPF6_ROUTE_PREFIX_STR
961 OSPF6_ROUTE_MATCH_STR
962 "Dispaly details of the prefixes\n"
965 DEFUN (show_ipv6_ospf6_interface_prefix,
966 show_ipv6_ospf6_interface_prefix_cmd,
967 "show ipv6 ospf6 interface prefix",
968 SHOW_STR
969 IP6_STR
970 OSPF6_STR
971 INTERFACE_STR
972 "Display connected prefixes to advertise\n"
975 struct listnode *i;
976 struct ospf6_interface *oi;
977 struct interface *ifp;
979 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
981 oi = (struct ospf6_interface *) ifp->info;
982 if (oi == NULL)
983 continue;
985 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
988 return CMD_SUCCESS;
991 ALIAS (show_ipv6_ospf6_interface_prefix,
992 show_ipv6_ospf6_interface_prefix_detail_cmd,
993 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
994 SHOW_STR
995 IP6_STR
996 OSPF6_STR
997 INTERFACE_STR
998 "Display connected prefixes to advertise\n"
999 OSPF6_ROUTE_ADDRESS_STR
1000 OSPF6_ROUTE_PREFIX_STR
1001 "Dispaly details of the prefixes\n"
1004 ALIAS (show_ipv6_ospf6_interface_prefix,
1005 show_ipv6_ospf6_interface_prefix_match_cmd,
1006 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1007 SHOW_STR
1008 IP6_STR
1009 OSPF6_STR
1010 INTERFACE_STR
1011 "Display connected prefixes to advertise\n"
1012 OSPF6_ROUTE_PREFIX_STR
1013 OSPF6_ROUTE_MATCH_STR
1014 "Dispaly details of the prefixes\n"
1018 /* interface variable set command */
1019 DEFUN (ipv6_ospf6_ifmtu,
1020 ipv6_ospf6_ifmtu_cmd,
1021 "ipv6 ospf6 ifmtu <1-65535>",
1022 IP6_STR
1023 OSPF6_STR
1024 "Interface MTU\n"
1025 "OSPFv3 Interface MTU\n"
1028 struct ospf6_interface *oi;
1029 struct interface *ifp;
1030 unsigned int ifmtu, iobuflen;
1031 struct listnode *node, *nnode;
1032 struct ospf6_neighbor *on;
1034 ifp = (struct interface *) vty->index;
1035 assert (ifp);
1037 oi = (struct ospf6_interface *) ifp->info;
1038 if (oi == NULL)
1039 oi = ospf6_interface_create (ifp);
1040 assert (oi);
1042 ifmtu = strtol (argv[0], NULL, 10);
1044 if (oi->ifmtu == ifmtu)
1045 return CMD_SUCCESS;
1047 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
1049 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
1050 ifp->name, ifp->mtu6, VNL);
1051 return CMD_WARNING;
1054 if (oi->ifmtu < ifmtu)
1056 iobuflen = ospf6_iobuf_size (ifmtu);
1057 if (iobuflen < ifmtu)
1059 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1060 ifp->name, iobuflen, VNL);
1061 oi->ifmtu = iobuflen;
1063 else
1064 oi->ifmtu = ifmtu;
1066 else
1067 oi->ifmtu = ifmtu;
1069 /* re-establish adjacencies */
1070 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1072 THREAD_OFF (on->inactivity_timer);
1073 thread_add_event (master, inactivity_timer, on, 0);
1076 return CMD_SUCCESS;
1079 DEFUN (no_ipv6_ospf6_ifmtu,
1080 no_ipv6_ospf6_ifmtu_cmd,
1081 "no ipv6 ospf6 ifmtu",
1082 NO_STR
1083 IP6_STR
1084 OSPF6_STR
1085 "Interface MTU\n"
1088 struct ospf6_interface *oi;
1089 struct interface *ifp;
1090 unsigned int iobuflen;
1091 struct listnode *node, *nnode;
1092 struct ospf6_neighbor *on;
1094 ifp = (struct interface *) vty->index;
1095 assert (ifp);
1097 oi = (struct ospf6_interface *) ifp->info;
1098 if (oi == NULL)
1099 oi = ospf6_interface_create (ifp);
1100 assert (oi);
1102 if (oi->ifmtu < ifp->mtu)
1104 iobuflen = ospf6_iobuf_size (ifp->mtu);
1105 if (iobuflen < ifp->mtu)
1107 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1108 ifp->name, iobuflen, VNL);
1109 oi->ifmtu = iobuflen;
1111 else
1112 oi->ifmtu = ifp->mtu;
1114 else
1115 oi->ifmtu = ifp->mtu;
1117 /* re-establish adjacencies */
1118 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1120 THREAD_OFF (on->inactivity_timer);
1121 thread_add_event (master, inactivity_timer, on, 0);
1124 return CMD_SUCCESS;
1127 DEFUN (ipv6_ospf6_cost,
1128 ipv6_ospf6_cost_cmd,
1129 "ipv6 ospf6 cost <1-65535>",
1130 IP6_STR
1131 OSPF6_STR
1132 "Interface cost\n"
1133 "Outgoing metric of this interface\n"
1136 struct ospf6_interface *oi;
1137 struct interface *ifp;
1138 unsigned long int lcost;
1140 ifp = (struct interface *) vty->index;
1141 assert (ifp);
1143 oi = (struct ospf6_interface *) ifp->info;
1144 if (oi == NULL)
1145 oi = ospf6_interface_create (ifp);
1146 assert (oi);
1148 lcost = strtol (argv[0], NULL, 10);
1150 if (lcost > UINT32_MAX)
1152 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1153 return CMD_WARNING;
1156 if (oi->cost == lcost)
1157 return CMD_SUCCESS;
1159 oi->cost = lcost;
1161 /* update cost held in route_connected list in ospf6_interface */
1162 ospf6_interface_connected_route_update (oi->interface);
1164 /* execute LSA hooks */
1165 if (oi->area)
1167 OSPF6_LINK_LSA_SCHEDULE (oi);
1168 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1169 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1170 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1171 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1174 return CMD_SUCCESS;
1177 DEFUN (ipv6_ospf6_hellointerval,
1178 ipv6_ospf6_hellointerval_cmd,
1179 "ipv6 ospf6 hello-interval <1-65535>",
1180 IP6_STR
1181 OSPF6_STR
1182 "Interval time of Hello packets\n"
1183 SECONDS_STR
1186 struct ospf6_interface *oi;
1187 struct interface *ifp;
1189 ifp = (struct interface *) vty->index;
1190 assert (ifp);
1192 oi = (struct ospf6_interface *) ifp->info;
1193 if (oi == NULL)
1194 oi = ospf6_interface_create (ifp);
1195 assert (oi);
1197 oi->hello_interval = strtol (argv[0], NULL, 10);
1198 return CMD_SUCCESS;
1201 /* interface variable set command */
1202 DEFUN (ipv6_ospf6_deadinterval,
1203 ipv6_ospf6_deadinterval_cmd,
1204 "ipv6 ospf6 dead-interval <1-65535>",
1205 IP6_STR
1206 OSPF6_STR
1207 "Interval time after which a neighbor is declared down\n"
1208 SECONDS_STR
1211 struct ospf6_interface *oi;
1212 struct interface *ifp;
1214 ifp = (struct interface *) vty->index;
1215 assert (ifp);
1217 oi = (struct ospf6_interface *) ifp->info;
1218 if (oi == NULL)
1219 oi = ospf6_interface_create (ifp);
1220 assert (oi);
1222 oi->dead_interval = strtol (argv[0], NULL, 10);
1223 return CMD_SUCCESS;
1226 /* interface variable set command */
1227 DEFUN (ipv6_ospf6_transmitdelay,
1228 ipv6_ospf6_transmitdelay_cmd,
1229 "ipv6 ospf6 transmit-delay <1-3600>",
1230 IP6_STR
1231 OSPF6_STR
1232 "Transmit delay of this interface\n"
1233 SECONDS_STR
1236 struct ospf6_interface *oi;
1237 struct interface *ifp;
1239 ifp = (struct interface *) vty->index;
1240 assert (ifp);
1242 oi = (struct ospf6_interface *) ifp->info;
1243 if (oi == NULL)
1244 oi = ospf6_interface_create (ifp);
1245 assert (oi);
1247 oi->transdelay = strtol (argv[0], NULL, 10);
1248 return CMD_SUCCESS;
1251 /* interface variable set command */
1252 DEFUN (ipv6_ospf6_retransmitinterval,
1253 ipv6_ospf6_retransmitinterval_cmd,
1254 "ipv6 ospf6 retransmit-interval <1-65535>",
1255 IP6_STR
1256 OSPF6_STR
1257 "Time between retransmitting lost link state advertisements\n"
1258 SECONDS_STR
1261 struct ospf6_interface *oi;
1262 struct interface *ifp;
1264 ifp = (struct interface *) vty->index;
1265 assert (ifp);
1267 oi = (struct ospf6_interface *) ifp->info;
1268 if (oi == NULL)
1269 oi = ospf6_interface_create (ifp);
1270 assert (oi);
1272 oi->rxmt_interval = strtol (argv[0], NULL, 10);
1273 return CMD_SUCCESS;
1276 /* interface variable set command */
1277 DEFUN (ipv6_ospf6_priority,
1278 ipv6_ospf6_priority_cmd,
1279 "ipv6 ospf6 priority <0-255>",
1280 IP6_STR
1281 OSPF6_STR
1282 "Router priority\n"
1283 "Priority value\n"
1286 struct ospf6_interface *oi;
1287 struct interface *ifp;
1289 ifp = (struct interface *) vty->index;
1290 assert (ifp);
1292 oi = (struct ospf6_interface *) ifp->info;
1293 if (oi == NULL)
1294 oi = ospf6_interface_create (ifp);
1295 assert (oi);
1297 oi->priority = strtol (argv[0], NULL, 10);
1299 if (oi->area)
1300 ospf6_interface_state_change (dr_election (oi), oi);
1302 return CMD_SUCCESS;
1305 DEFUN (ipv6_ospf6_instance,
1306 ipv6_ospf6_instance_cmd,
1307 "ipv6 ospf6 instance-id <0-255>",
1308 IP6_STR
1309 OSPF6_STR
1310 "Instance ID for this interface\n"
1311 "Instance ID value\n"
1314 struct ospf6_interface *oi;
1315 struct interface *ifp;
1317 ifp = (struct interface *)vty->index;
1318 assert (ifp);
1320 oi = (struct ospf6_interface *)ifp->info;
1321 if (oi == NULL)
1322 oi = ospf6_interface_create (ifp);
1323 assert (oi);
1325 oi->instance_id = strtol (argv[0], NULL, 10);
1326 return CMD_SUCCESS;
1329 DEFUN (ipv6_ospf6_passive,
1330 ipv6_ospf6_passive_cmd,
1331 "ipv6 ospf6 passive",
1332 IP6_STR
1333 OSPF6_STR
1334 "passive interface, No adjacency will be formed on this interface\n"
1337 struct ospf6_interface *oi;
1338 struct interface *ifp;
1339 struct listnode *node, *nnode;
1340 struct ospf6_neighbor *on;
1342 ifp = (struct interface *) vty->index;
1343 assert (ifp);
1345 oi = (struct ospf6_interface *) ifp->info;
1346 if (oi == NULL)
1347 oi = ospf6_interface_create (ifp);
1348 assert (oi);
1350 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1351 THREAD_OFF (oi->thread_send_hello);
1353 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
1355 THREAD_OFF (on->inactivity_timer);
1356 thread_add_event (master, inactivity_timer, on, 0);
1359 return CMD_SUCCESS;
1362 DEFUN (no_ipv6_ospf6_passive,
1363 no_ipv6_ospf6_passive_cmd,
1364 "no ipv6 ospf6 passive",
1365 NO_STR
1366 IP6_STR
1367 OSPF6_STR
1368 "passive interface: No Adjacency will be formed on this I/F\n"
1371 struct ospf6_interface *oi;
1372 struct interface *ifp;
1374 ifp = (struct interface *) vty->index;
1375 assert (ifp);
1377 oi = (struct ospf6_interface *) ifp->info;
1378 if (oi == NULL)
1379 oi = ospf6_interface_create (ifp);
1380 assert (oi);
1382 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1383 THREAD_OFF (oi->thread_send_hello);
1384 oi->thread_send_hello =
1385 thread_add_event (master, ospf6_hello_send, oi, 0);
1387 return CMD_SUCCESS;
1390 DEFUN (ipv6_ospf6_advertise_prefix_list,
1391 ipv6_ospf6_advertise_prefix_list_cmd,
1392 "ipv6 ospf6 advertise prefix-list WORD",
1393 IP6_STR
1394 OSPF6_STR
1395 "Advertising options\n"
1396 "Filter prefix using prefix-list\n"
1397 "Prefix list name\n"
1400 struct ospf6_interface *oi;
1401 struct interface *ifp;
1403 ifp = (struct interface *) vty->index;
1404 assert (ifp);
1406 oi = (struct ospf6_interface *) ifp->info;
1407 if (oi == NULL)
1408 oi = ospf6_interface_create (ifp);
1409 assert (oi);
1411 if (oi->plist_name)
1412 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1413 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
1415 ospf6_interface_connected_route_update (oi->interface);
1416 OSPF6_LINK_LSA_SCHEDULE (oi);
1417 if (oi->state == OSPF6_INTERFACE_DR)
1419 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1420 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1422 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1424 return CMD_SUCCESS;
1427 DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1428 no_ipv6_ospf6_advertise_prefix_list_cmd,
1429 "no ipv6 ospf6 advertise prefix-list",
1430 NO_STR
1431 IP6_STR
1432 OSPF6_STR
1433 "Advertising options\n"
1434 "Filter prefix using prefix-list\n"
1437 struct ospf6_interface *oi;
1438 struct interface *ifp;
1440 ifp = (struct interface *) vty->index;
1441 assert (ifp);
1443 oi = (struct ospf6_interface *) ifp->info;
1444 if (oi == NULL)
1445 oi = ospf6_interface_create (ifp);
1446 assert (oi);
1448 if (oi->plist_name)
1450 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1451 oi->plist_name = NULL;
1454 ospf6_interface_connected_route_update (oi->interface);
1455 OSPF6_LINK_LSA_SCHEDULE (oi);
1456 if (oi->state == OSPF6_INTERFACE_DR)
1458 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1459 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1461 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1463 return CMD_SUCCESS;
1466 static int
1467 config_write_ospf6_interface (struct vty *vty)
1469 struct listnode *i;
1470 struct ospf6_interface *oi;
1471 struct interface *ifp;
1473 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
1475 oi = (struct ospf6_interface *) ifp->info;
1476 if (oi == NULL)
1477 continue;
1479 vty_out (vty, "interface %s%s",
1480 oi->interface->name, VNL);
1482 if (ifp->desc)
1483 vty_out (vty, " description %s%s", ifp->desc, VNL);
1485 if (ifp->mtu6 != oi->ifmtu)
1486 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
1487 vty_out (vty, " ipv6 ospf6 cost %d%s",
1488 oi->cost, VNL);
1489 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1490 oi->hello_interval, VNL);
1491 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1492 oi->dead_interval, VNL);
1493 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1494 oi->rxmt_interval, VNL);
1495 vty_out (vty, " ipv6 ospf6 priority %d%s",
1496 oi->priority, VNL);
1497 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1498 oi->transdelay, VNL);
1499 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1500 oi->instance_id, VNL);
1502 if (oi->plist_name)
1503 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
1504 oi->plist_name, VNL);
1506 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
1507 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
1509 vty_out (vty, "!%s", VNL);
1511 return 0;
1514 struct cmd_node interface_node =
1516 INTERFACE_NODE,
1517 "%s(config-if)# ",
1518 1 /* VTYSH */
1521 void
1522 ospf6_interface_init (void)
1524 /* Install interface node. */
1525 install_node (&interface_node, config_write_ospf6_interface);
1527 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
1528 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1529 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1530 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
1531 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
1532 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1533 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1534 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
1535 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
1536 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1537 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1538 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
1539 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
1540 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1541 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1542 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
1544 install_element (CONFIG_NODE, &interface_cmd);
1545 install_default (INTERFACE_NODE);
1546 install_element (INTERFACE_NODE, &interface_desc_cmd);
1547 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1548 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
1549 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
1550 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
1551 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1552 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1553 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1554 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1555 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1556 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
1558 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1559 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
1561 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1562 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1565 DEFUN (debug_ospf6_interface,
1566 debug_ospf6_interface_cmd,
1567 "debug ospf6 interface",
1568 DEBUG_STR
1569 OSPF6_STR
1570 "Debug OSPFv3 Interface\n"
1573 OSPF6_DEBUG_INTERFACE_ON ();
1574 return CMD_SUCCESS;
1577 DEFUN (no_debug_ospf6_interface,
1578 no_debug_ospf6_interface_cmd,
1579 "no debug ospf6 interface",
1580 NO_STR
1581 DEBUG_STR
1582 OSPF6_STR
1583 "Debug OSPFv3 Interface\n"
1586 OSPF6_DEBUG_INTERFACE_OFF ();
1587 return CMD_SUCCESS;
1591 config_write_ospf6_debug_interface (struct vty *vty)
1593 if (IS_OSPF6_DEBUG_INTERFACE)
1594 vty_out (vty, "debug ospf6 interface%s", VNL);
1595 return 0;
1598 void
1599 install_element_ospf6_debug_interface (void)
1601 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1602 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1603 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1604 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);