]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_interface.c
Ospf6d merge from Zebra repository with added privs stuff and merged
[mirror_frr.git] / ospf6d / ospf6_interface.c
CommitLineData
718e3744 1/*
508e53e2 2 * Copyright (C) 2003 Yasuhiro Ohara
718e3744 3 *
4 * This file is part of GNU Zebra.
5 *
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.
10 *
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.
15 *
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.
20 */
21
508e53e2 22#include <zebra.h>
718e3744 23
508e53e2 24#include "memory.h"
718e3744 25#include "if.h"
26#include "log.h"
27#include "command.h"
508e53e2 28#include "thread.h"
29#include "prefix.h"
30#include "plist.h"
718e3744 31
508e53e2 32#include "ospf6d.h"
33#include "ospf6_lsa.h"
718e3744 34#include "ospf6_lsdb.h"
508e53e2 35#include "ospf6_network.h"
36#include "ospf6_message.h"
37#include "ospf6_route.h"
718e3744 38#include "ospf6_top.h"
39#include "ospf6_area.h"
40#include "ospf6_interface.h"
508e53e2 41#include "ospf6_neighbor.h"
42#include "ospf6_intra.h"
43#include "ospf6_spf.h"
718e3744 44
508e53e2 45unsigned char conf_debug_ospf6_interface = 0;
46
47char *ospf6_interface_state_str[] =
718e3744 48{
508e53e2 49 "None",
50 "Down",
51 "Loopback",
52 "Waiting",
53 "PointToPoint",
54 "DROther",
55 "BDR",
56 "DR",
57 NULL
718e3744 58};
59
508e53e2 60struct ospf6_interface *
61ospf6_interface_lookup_by_ifindex (int ifindex)
718e3744 62{
508e53e2 63 struct ospf6_interface *oi;
64 struct interface *ifp;
718e3744 65
508e53e2 66 ifp = if_lookup_by_index (ifindex);
67 if (ifp == NULL)
68 return (struct ospf6_interface *) NULL;
69
70 oi = (struct ospf6_interface *) ifp->info;
71 return oi;
718e3744 72}
73
508e53e2 74struct ospf6_interface *
75ospf6_interface_lookup_by_name (char *ifname)
718e3744 76{
508e53e2 77 struct ospf6_interface *oi;
78 struct interface *ifp;
718e3744 79
508e53e2 80 ifp = if_lookup_by_name (ifname);
81 if (ifp == NULL)
82 return (struct ospf6_interface *) NULL;
718e3744 83
508e53e2 84 oi = (struct ospf6_interface *) ifp->info;
85 return oi;
718e3744 86}
87
508e53e2 88/* schedule routing table recalculation */
718e3744 89void
508e53e2 90ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa)
718e3744 91{
508e53e2 92 struct ospf6_interface *oi;
718e3744 93
508e53e2 94 oi = (struct ospf6_interface *) lsa->scope;
95 switch (ntohs (lsa->header->type))
96 {
97 case OSPF6_LSTYPE_LINK:
98 if (oi->state == OSPF6_INTERFACE_DR)
99 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
100 ospf6_spf_schedule (oi->area);
101 break;
102
103 default:
104 if (IS_OSPF6_DEBUG_LSA (RECV))
105 zlog_info ("Unknown LSA in Interface %s's lsdb",
106 oi->interface->name);
107 break;
108 }
718e3744 109}
110
111/* Create new ospf6 interface structure */
112struct ospf6_interface *
113ospf6_interface_create (struct interface *ifp)
114{
508e53e2 115 struct ospf6_interface *oi;
718e3744 116
508e53e2 117 oi = (struct ospf6_interface *)
718e3744 118 XMALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
119
508e53e2 120 if (oi)
121 memset (oi, 0, sizeof (struct ospf6_interface));
718e3744 122 else
123 {
124 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
125 return (struct ospf6_interface *) NULL;
126 }
127
508e53e2 128 oi->area = (struct ospf6_area *) NULL;
129 oi->neighbor_list = list_new ();
130 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
131 oi->linklocal_addr = (struct in6_addr *) NULL;
132 oi->instance_id = 0;
133 oi->transdelay = 1;
134 oi->priority = 1;
135
136 oi->hello_interval = 10;
137 oi->dead_interval = 40;
138 oi->rxmt_interval = 5;
139 oi->cost = 1;
140 oi->ifmtu = ifp->mtu;
141 oi->state = OSPF6_INTERFACE_DOWN;
142 oi->flag = 0;
143
144 oi->lsupdate_list = ospf6_lsdb_create ();
145 oi->lsack_list = ospf6_lsdb_create ();
146 oi->lsdb = ospf6_lsdb_create ();
147 oi->lsdb->hook_add = ospf6_interface_lsdb_hook;
148 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook;
149
150 oi->route_connected = ospf6_route_table_create ();
718e3744 151
152 /* link both */
508e53e2 153 oi->interface = ifp;
154 ifp->info = oi;
718e3744 155
508e53e2 156 return oi;
718e3744 157}
158
159void
508e53e2 160ospf6_interface_delete (struct ospf6_interface *oi)
718e3744 161{
162 listnode n;
508e53e2 163 struct ospf6_neighbor *on;
718e3744 164
508e53e2 165 for (n = listhead (oi->neighbor_list); n; nextnode (n))
718e3744 166 {
508e53e2 167 on = (struct ospf6_neighbor *) getdata (n);
168 ospf6_neighbor_delete (on);
718e3744 169 }
508e53e2 170 list_delete (oi->neighbor_list);
718e3744 171
508e53e2 172 THREAD_OFF (oi->thread_send_hello);
173 THREAD_OFF (oi->thread_send_lsupdate);
174 THREAD_OFF (oi->thread_send_lsack);
175
176 ospf6_lsdb_remove_all (oi->lsdb);
177 ospf6_lsdb_remove_all (oi->lsupdate_list);
178 ospf6_lsdb_remove_all (oi->lsack_list);
179
180 ospf6_lsdb_delete (oi->lsdb);
181 ospf6_lsdb_delete (oi->lsupdate_list);
182 ospf6_lsdb_delete (oi->lsack_list);
718e3744 183
508e53e2 184 ospf6_route_table_delete (oi->route_connected);
718e3744 185
186 /* cut link */
508e53e2 187 oi->interface->info = NULL;
718e3744 188
189 /* plist_name */
508e53e2 190 if (oi->plist_name)
191 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
192
193 XFREE (MTYPE_OSPF6_IF, oi);
194}
195
196void
197ospf6_interface_enable (struct ospf6_interface *oi)
198{
199 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
718e3744 200
508e53e2 201 oi->thread_send_hello =
202 thread_add_event (master, ospf6_hello_send, oi, 0);
203}
204
205void
206ospf6_interface_disable (struct ospf6_interface *oi)
207{
208 listnode i;
209 struct ospf6_neighbor *on;
210
211 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
212
213 for (i = listhead (oi->neighbor_list); i; nextnode (i))
214 {
215 on = (struct ospf6_neighbor *) getdata (i);
216 ospf6_neighbor_delete (on);
217 }
218 list_delete_all_node (oi->neighbor_list);
219
220 ospf6_lsdb_remove_all (oi->lsdb);
221 ospf6_lsdb_remove_all (oi->lsupdate_list);
222 ospf6_lsdb_remove_all (oi->lsack_list);
223
224 THREAD_OFF (oi->thread_send_hello);
225 THREAD_OFF (oi->thread_send_lsupdate);
226 THREAD_OFF (oi->thread_send_lsack);
718e3744 227}
228
229static struct in6_addr *
508e53e2 230ospf6_interface_get_linklocal_address (struct interface *ifp)
718e3744 231{
232 listnode n;
233 struct connected *c;
234 struct in6_addr *l = (struct in6_addr *) NULL;
235
236 /* for each connected address */
237 for (n = listhead (ifp->connected); n; nextnode (n))
238 {
239 c = (struct connected *) getdata (n);
240
241 /* if family not AF_INET6, ignore */
242 if (c->address->family != AF_INET6)
243 continue;
244
245 /* linklocal scope check */
246 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
247 l = &c->address->u.prefix6;
248 }
249 return l;
250}
251
252void
253ospf6_interface_if_add (struct interface *ifp)
254{
508e53e2 255 struct ospf6_interface *oi;
718e3744 256
508e53e2 257 oi = (struct ospf6_interface *) ifp->info;
258 if (oi == NULL)
718e3744 259 return;
260
508e53e2 261 oi->ifmtu = ifp->mtu;
718e3744 262
263 /* interface start */
508e53e2 264 if (oi->area)
265 thread_add_event (master, interface_up, oi, 0);
718e3744 266}
267
268void
269ospf6_interface_if_del (struct interface *ifp)
270{
508e53e2 271 struct ospf6_interface *oi;
718e3744 272
508e53e2 273 oi = (struct ospf6_interface *) ifp->info;
274 if (oi == NULL)
718e3744 275 return;
276
277 /* interface stop */
508e53e2 278 if (oi->area)
279 thread_execute (master, interface_down, oi, 0);
718e3744 280
508e53e2 281 listnode_delete (oi->area->if_list, oi);
282 oi->area = (struct ospf6_area *) NULL;
718e3744 283
284 /* cut link */
508e53e2 285 oi->interface = NULL;
718e3744 286 ifp->info = NULL;
287
508e53e2 288 ospf6_interface_delete (oi);
718e3744 289}
290
291void
292ospf6_interface_state_update (struct interface *ifp)
293{
508e53e2 294 struct ospf6_interface *oi;
718e3744 295
508e53e2 296 oi = (struct ospf6_interface *) ifp->info;
297 if (oi == NULL)
718e3744 298 return;
508e53e2 299 if (oi->area == NULL)
718e3744 300 return;
301
302 if (if_is_up (ifp))
508e53e2 303 thread_add_event (master, interface_up, oi, 0);
718e3744 304 else
508e53e2 305 thread_add_event (master, interface_down, oi, 0);
718e3744 306
307 return;
308}
309
310void
508e53e2 311ospf6_interface_connected_route_update (struct interface *ifp)
718e3744 312{
508e53e2 313 struct ospf6_interface *oi;
314 struct ospf6_route *route;
315 struct connected *c;
316 listnode i;
718e3744 317
508e53e2 318 oi = (struct ospf6_interface *) ifp->info;
319 if (oi == NULL)
718e3744 320 return;
321
322 /* reset linklocal pointer */
508e53e2 323 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
718e3744 324
508e53e2 325 /* if area is null, do not make connected-route list */
326 if (oi->area == NULL)
718e3744 327 return;
328
508e53e2 329 /* update "route to advertise" interface route table */
330 ospf6_route_remove_all (oi->route_connected);
331 for (i = listhead (oi->interface->connected); i; nextnode (i))
332 {
333 c = (struct connected *) getdata (i);
334
335 if (c->address->family != AF_INET6)
336 continue;
337
338 CONTINUE_IF_ADDRESS_LINKLOCAL (c->address);
339 CONTINUE_IF_ADDRESS_UNSPECIFIED (c->address);
340 CONTINUE_IF_ADDRESS_LOOPBACK (c->address);
341 CONTINUE_IF_ADDRESS_V4COMPAT (c->address);
342 CONTINUE_IF_ADDRESS_V4MAPPED (c->address);
718e3744 343
508e53e2 344 /* apply filter */
345 if (oi->plist_name)
346 {
347 struct prefix_list *plist;
348 enum prefix_list_type ret;
349 char buf[128];
350
351 prefix2str (c->address, buf, sizeof (buf));
352 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
353 ret = prefix_list_apply (plist, (void *) c->address);
354 if (ret == PREFIX_DENY)
355 {
356 zlog_info ("%s on %s filtered by prefix-list %s ",
357 buf, oi->interface->name, oi->plist_name);
358 continue;
359 }
360 }
361
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);
372 }
373
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);
718e3744 378}
379
508e53e2 380static void
381ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
718e3744 382{
508e53e2 383 u_char prev_state;
718e3744 384
508e53e2 385 prev_state = oi->state;
386 oi->state = next_state;
718e3744 387
508e53e2 388 if (prev_state == next_state)
389 return;
390
391 /* log */
392 if (IS_OSPF6_DEBUG_INTERFACE)
393 {
394 zlog_info ("Interface state change %s: %s -> %s", oi->interface->name,
395 ospf6_interface_state_str[prev_state],
396 ospf6_interface_state_str[next_state]);
397 }
718e3744 398
508e53e2 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);
409
410 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
411 if (prev_state == OSPF6_INTERFACE_DR || next_state == OSPF6_INTERFACE_DR)
412 {
413 OSPF6_NETWORK_LSA_SCHEDULE (oi);
414 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
415 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
416 }
718e3744 417}
418
508e53e2 419\f
420/* DR Election, RFC2328 section 9.4 */
718e3744 421
508e53e2 422#define IS_ELIGIBLE(n) \
423 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
718e3744 424
508e53e2 425static struct ospf6_neighbor *
426better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
427{
428 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
429 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
430 return NULL;
431 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
432 return b;
433 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
434 return a;
435
436 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
437 return a;
438 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
439 return b;
440
441 if (a->priority > b->priority)
442 return a;
443 if (a->priority < b->priority)
444 return b;
445
446 if (ntohl (a->router_id) > ntohl (b->router_id))
447 return a;
448 if (ntohl (a->router_id) < ntohl (b->router_id))
449 return b;
450
451 zlog_warn ("Router-ID duplicate ?");
452 return a;
453}
718e3744 454
508e53e2 455static struct ospf6_neighbor *
456better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
457{
458 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
459 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
460 return NULL;
461 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
462 return b;
463 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
464 return a;
465
466 if (a->drouter == a->router_id && b->drouter != b->router_id)
467 return a;
468 if (a->drouter != a->router_id && b->drouter == b->router_id)
469 return b;
470
471 if (a->priority > b->priority)
472 return a;
473 if (a->priority < b->priority)
474 return b;
475
476 if (ntohl (a->router_id) > ntohl (b->router_id))
477 return a;
478 if (ntohl (a->router_id) < ntohl (b->router_id))
479 return b;
480
481 zlog_warn ("Router-ID duplicate ?");
482 return a;
718e3744 483}
484
508e53e2 485static u_char
486dr_election (struct ospf6_interface *oi)
718e3744 487{
508e53e2 488 listnode i;
489 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
490 struct ospf6_neighbor *best_drouter, *best_bdrouter;
491 u_char next_state = 0;
492
493 drouter = bdrouter = NULL;
494 best_drouter = best_bdrouter = NULL;
495
496 /* pseudo neighbor myself, including noting current DR/BDR (1) */
497 memset (&myself, 0, sizeof (myself));
498 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
499 sizeof (myself.name));
500 myself.state = OSPF6_NEIGHBOR_TWOWAY;
501 myself.drouter = oi->drouter;
502 myself.bdrouter = oi->bdrouter;
503 myself.priority = oi->priority;
504 myself.router_id = oi->area->ospf6->router_id;
505
506 /* Electing BDR (2) */
507 for (i = listhead (oi->neighbor_list); i; nextnode (i))
508 {
509 on = (struct ospf6_neighbor *) getdata (i);
510 bdrouter = better_bdrouter (bdrouter, on);
511 }
512 best_bdrouter = bdrouter;
513 bdrouter = better_bdrouter (best_bdrouter, &myself);
514
515 /* Electing DR (3) */
516 for (i = listhead (oi->neighbor_list); i; nextnode (i))
517 {
518 on = (struct ospf6_neighbor *) getdata (i);
519 drouter = better_drouter (drouter, on);
520 }
521 best_drouter = drouter;
522 drouter = better_drouter (best_drouter, &myself);
523 if (drouter == NULL)
524 drouter = bdrouter;
525
526 /* the router itself is newly/no longer DR/BDR (4) */
527 if ((drouter == &myself && myself.drouter != myself.router_id) ||
528 (drouter != &myself && myself.drouter == myself.router_id) ||
529 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
530 (bdrouter != &myself && myself.bdrouter == myself.router_id))
531 {
532 myself.drouter = (drouter ? drouter->router_id : htonl (0));
533 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
534
535 /* compatible to Electing BDR (2) */
536 bdrouter = better_bdrouter (best_bdrouter, &myself);
537
538 /* compatible to Electing DR (3) */
539 drouter = better_drouter (best_drouter, &myself);
540 if (drouter == NULL)
541 drouter = bdrouter;
542 }
543
544 /* Set interface state accordingly (5) */
545 if (drouter && drouter == &myself)
546 next_state = OSPF6_INTERFACE_DR;
547 else if (bdrouter && bdrouter == &myself)
548 next_state = OSPF6_INTERFACE_BDR;
549 else
550 next_state = OSPF6_INTERFACE_DROTHER;
718e3744 551
508e53e2 552 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
553 /* XXX */
554
555 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
556 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
557 accordingly after AdjOK */
558 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
559 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
718e3744 560 {
508e53e2 561 if (IS_OSPF6_DEBUG_INTERFACE)
562 zlog_info ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
563 (drouter ? drouter->name : "0.0.0.0"),
564 (bdrouter ? bdrouter->name : "0.0.0.0"));
565
566 for (i = listhead (oi->neighbor_list); i; nextnode (i))
567 {
568 on = (struct ospf6_neighbor *) getdata (i);
569 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
570 continue;
571 /* Schedule AdjOK. */
572 thread_add_event (master, adj_ok, on, 0);
573 }
718e3744 574 }
508e53e2 575
576 oi->drouter = (drouter ? drouter->router_id : htonl (0));
577 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
578 return next_state;
718e3744 579}
580
508e53e2 581\f
582/* Interface State Machine */
718e3744 583int
508e53e2 584interface_up (struct thread *thread)
718e3744 585{
508e53e2 586 struct ospf6_interface *oi;
587
588 oi = (struct ospf6_interface *) THREAD_ARG (thread);
589 assert (oi && oi->interface);
590
591 if (IS_OSPF6_DEBUG_INTERFACE)
592 zlog_info ("Interface Event %s: [InterfaceUp]",
593 oi->interface->name);
594
595 /* check physical interface is up */
596 if (! if_is_up (oi->interface))
597 {
598 if (IS_OSPF6_DEBUG_INTERFACE)
599 zlog_info ("Interface %s is down, can't execute [InterfaceUp]",
600 oi->interface->name);
601 return 0;
602 }
603
604 /* if already enabled, do nothing */
605 if (oi->state > OSPF6_INTERFACE_DOWN)
606 {
607 if (IS_OSPF6_DEBUG_INTERFACE)
608 zlog_info ("Interface %s already enabled",
609 oi->interface->name);
610 return 0;
611 }
612
613 /* Join AllSPFRouters */
614 ospf6_join_allspfrouters (oi->interface->ifindex);
615
616 /* Update interface route */
617 ospf6_interface_connected_route_update (oi->interface);
718e3744 618
508e53e2 619 /* Schedule Hello */
620 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
621 thread_add_event (master, ospf6_hello_send, oi, 0);
622
623 /* decide next interface state */
624 if (if_is_pointopoint (oi->interface))
625 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
626 else if (oi->priority == 0)
627 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
628 else
718e3744 629 {
508e53e2 630 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
631 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
718e3744 632 }
508e53e2 633
634 return 0;
718e3744 635}
636
637int
508e53e2 638wait_timer (struct thread *thread)
718e3744 639{
508e53e2 640 struct ospf6_interface *oi;
718e3744 641
508e53e2 642 oi = (struct ospf6_interface *) THREAD_ARG (thread);
643 assert (oi && oi->interface);
718e3744 644
508e53e2 645 if (IS_OSPF6_DEBUG_INTERFACE)
646 zlog_info ("Interface Event %s: [WaitTimer]",
647 oi->interface->name);
718e3744 648
508e53e2 649 if (oi->state == OSPF6_INTERFACE_WAITING)
650 ospf6_interface_state_change (dr_election (oi), oi);
718e3744 651
508e53e2 652 return 0;
718e3744 653}
654
508e53e2 655int
656backup_seen (struct thread *thread)
657{
658 struct ospf6_interface *oi;
659
660 oi = (struct ospf6_interface *) THREAD_ARG (thread);
661 assert (oi && oi->interface);
662
663 if (IS_OSPF6_DEBUG_INTERFACE)
664 zlog_info ("Interface Event %s: [BackupSeen]",
665 oi->interface->name);
666
667 if (oi->state == OSPF6_INTERFACE_WAITING)
668 ospf6_interface_state_change (dr_election (oi), oi);
669
670 return 0;
671}
672
673int
674neighbor_change (struct thread *thread)
718e3744 675{
508e53e2 676 struct ospf6_interface *oi;
677
678 oi = (struct ospf6_interface *) THREAD_ARG (thread);
679 assert (oi && oi->interface);
680
681 if (IS_OSPF6_DEBUG_INTERFACE)
682 zlog_info ("Interface Event %s: [NeighborChange]",
683 oi->interface->name);
684
685 if (oi->state == OSPF6_INTERFACE_DROTHER ||
686 oi->state == OSPF6_INTERFACE_BDR ||
687 oi->state == OSPF6_INTERFACE_DR)
688 ospf6_interface_state_change (dr_election (oi), oi);
689
690 return 0;
718e3744 691}
692
508e53e2 693int
694loopind (struct thread *thread)
695{
696 struct ospf6_interface *oi;
697
698 oi = (struct ospf6_interface *) THREAD_ARG (thread);
699 assert (oi && oi->interface);
700
701 if (IS_OSPF6_DEBUG_INTERFACE)
702 zlog_info ("Interface Event %s: [LoopInd]",
703 oi->interface->name);
704
705 /* XXX not yet */
706
707 return 0;
708}
709
710int
711interface_down (struct thread *thread)
718e3744 712{
508e53e2 713 struct ospf6_interface *oi;
714 listnode n;
715 struct ospf6_neighbor *on;
716
717 oi = (struct ospf6_interface *) THREAD_ARG (thread);
718 assert (oi && oi->interface);
719
720 if (IS_OSPF6_DEBUG_INTERFACE)
721 zlog_info ("Interface Event %s: [InterfaceDown]",
722 oi->interface->name);
723
724 /* Leave AllSPFRouters */
725 if (oi->state > OSPF6_INTERFACE_DOWN)
726 ospf6_leave_allspfrouters (oi->interface->ifindex);
727
728 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
729
730 for (n = listhead (oi->neighbor_list); n; nextnode (n))
731 {
732 on = (struct ospf6_neighbor *) getdata (n);
733 ospf6_neighbor_delete (on);
734 }
735 list_delete_all_node (oi->neighbor_list);
736
737 return 0;
718e3744 738}
739
508e53e2 740\f
718e3744 741/* show specified interface structure */
742int
508e53e2 743ospf6_interface_show (struct vty *vty, struct interface *ifp)
718e3744 744{
508e53e2 745 struct ospf6_interface *oi;
718e3744 746 struct connected *c;
747 struct prefix *p;
748 listnode i;
508e53e2 749 char strbuf[64], drouter[32], bdrouter[32];
718e3744 750 char *updown[3] = {"down", "up", NULL};
751 char *type;
508e53e2 752 struct timeval res, now;
753 char duration[32];
754 struct ospf6_lsa *lsa;
718e3744 755
756 /* check physical interface type */
508e53e2 757 if (if_is_loopback (ifp))
718e3744 758 type = "LOOPBACK";
508e53e2 759 else if (if_is_broadcast (ifp))
718e3744 760 type = "BROADCAST";
508e53e2 761 else if (if_is_pointopoint (ifp))
718e3744 762 type = "POINTOPOINT";
763 else
764 type = "UNKNOWN";
765
766 vty_out (vty, "%s is %s, type %s%s",
508e53e2 767 ifp->name, updown[if_is_up (ifp)], type,
718e3744 768 VTY_NEWLINE);
508e53e2 769 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VTY_NEWLINE);
718e3744 770
508e53e2 771 if (ifp->info == NULL)
718e3744 772 {
773 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
774 return 0;
775 }
776 else
508e53e2 777 oi = (struct ospf6_interface *) ifp->info;
718e3744 778
779 vty_out (vty, " Internet Address:%s", VTY_NEWLINE);
508e53e2 780 for (i = listhead (ifp->connected); i; nextnode (i))
718e3744 781 {
782 c = (struct connected *)getdata (i);
783 p = c->address;
784 prefix2str (p, strbuf, sizeof (strbuf));
785 switch (p->family)
786 {
787 case AF_INET:
508e53e2 788 vty_out (vty, " inet : %s%s", strbuf,
718e3744 789 VTY_NEWLINE);
790 break;
791 case AF_INET6:
508e53e2 792 vty_out (vty, " inet6: %s%s", strbuf,
718e3744 793 VTY_NEWLINE);
794 break;
795 default:
508e53e2 796 vty_out (vty, " ??? : %s%s", strbuf,
718e3744 797 VTY_NEWLINE);
798 break;
799 }
800 }
801
508e53e2 802 if (oi->area)
718e3744 803 {
508e53e2 804 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
805 oi->instance_id, oi->ifmtu, ifp->mtu, VTY_NEWLINE);
806 inet_ntop (AF_INET, &oi->area->area_id,
718e3744 807 strbuf, sizeof (strbuf));
508e53e2 808 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
718e3744 809 VTY_NEWLINE);
718e3744 810 }
811 else
812 vty_out (vty, " Not Attached to Area%s", VTY_NEWLINE);
813
814 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
508e53e2 815 ospf6_interface_state_str[oi->state],
816 oi->transdelay, oi->priority,
718e3744 817 VTY_NEWLINE);
818 vty_out (vty, " Timer intervals configured:%s", VTY_NEWLINE);
819 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
508e53e2 820 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
718e3744 821 VTY_NEWLINE);
822
508e53e2 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, VTY_NEWLINE);
718e3744 826
827 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
508e53e2 828 oi->lsdb->count, VTY_NEWLINE);
718e3744 829
830 gettimeofday (&now, (struct timezone *) NULL);
718e3744 831
508e53e2 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 VTY_NEWLINE);
840 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
841 lsa = ospf6_lsdb_next (lsa))
842 vty_out (vty, " %s%s", lsa->name, VTY_NEWLINE);
843
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 VTY_NEWLINE);
852 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
853 lsa = ospf6_lsdb_next (lsa))
854 vty_out (vty, " %s%s", lsa->name, VTY_NEWLINE);
718e3744 855
508e53e2 856 return 0;
718e3744 857}
858
859/* show interface */
860DEFUN (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
868 )
869{
870 struct interface *ifp;
871 listnode i;
872
873 if (argc)
874 {
875 ifp = if_lookup_by_name (argv[0]);
508e53e2 876 if (ifp == NULL)
718e3744 877 {
878 vty_out (vty, "No such Interface: %s%s", argv[0],
508e53e2 879 VTY_NEWLINE);
718e3744 880 return CMD_WARNING;
881 }
882 ospf6_interface_show (vty, ifp);
883 }
884 else
885 {
886 for (i = listhead (iflist); i; nextnode (i))
887 {
508e53e2 888 ifp = (struct interface *) getdata (i);
718e3744 889 ospf6_interface_show (vty, ifp);
890 }
891 }
508e53e2 892
718e3744 893 return CMD_SUCCESS;
894}
895
896ALIAS (show_ipv6_ospf6_interface,
897 show_ipv6_ospf6_interface_cmd,
898 "show ipv6 ospf6 interface",
899 SHOW_STR
900 IP6_STR
901 OSPF6_STR
902 INTERFACE_STR
508e53e2 903 );
904
905DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
906 show_ipv6_ospf6_interface_ifname_prefix_cmd,
907 "show ipv6 ospf6 interface IFNAME prefix",
908 SHOW_STR
909 IP6_STR
910 OSPF6_STR
911 INTERFACE_STR
912 IFNAME_STR
913 "Display connected prefixes to advertise\n"
718e3744 914 )
508e53e2 915{
916 struct interface *ifp;
917 struct ospf6_interface *oi;
918
919 ifp = if_lookup_by_name (argv[0]);
920 if (ifp == NULL)
921 {
922 vty_out (vty, "No such Interface: %s%s", argv[0], VTY_NEWLINE);
923 return CMD_WARNING;
924 }
925
926 oi = ifp->info;
927 if (oi == NULL)
928 {
929 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VTY_NEWLINE);
930 return CMD_WARNING;
931 }
932
933 argc--;
934 argv++;
935 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
936
937 return CMD_SUCCESS;
938}
939
940ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
941 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
942 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
943 SHOW_STR
944 IP6_STR
945 OSPF6_STR
946 INTERFACE_STR
947 IFNAME_STR
948 "Display connected prefixes to advertise\n"
949 OSPF6_ROUTE_ADDRESS_STR
950 OSPF6_ROUTE_PREFIX_STR
951 "Dispaly details of the prefixes\n"
952 );
953
954ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
955 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
956 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
957 SHOW_STR
958 IP6_STR
959 OSPF6_STR
960 INTERFACE_STR
961 IFNAME_STR
962 "Display connected prefixes to advertise\n"
963 OSPF6_ROUTE_PREFIX_STR
964 OSPF6_ROUTE_MATCH_STR
965 "Dispaly details of the prefixes\n"
966 );
967
968DEFUN (show_ipv6_ospf6_interface_prefix,
969 show_ipv6_ospf6_interface_prefix_cmd,
970 "show ipv6 ospf6 interface prefix",
971 SHOW_STR
972 IP6_STR
973 OSPF6_STR
974 INTERFACE_STR
975 "Display connected prefixes to advertise\n"
976 )
977{
978 listnode i;
979 struct ospf6_interface *oi;
980 struct interface *ifp;
981
982 for (i = listhead (iflist); i; nextnode (i))
983 {
984 ifp = (struct interface *) getdata (i);
985 oi = (struct ospf6_interface *) ifp->info;
986 if (oi == NULL)
987 continue;
988
989 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
990 }
991
992 return CMD_SUCCESS;
993}
994
995ALIAS (show_ipv6_ospf6_interface_prefix,
996 show_ipv6_ospf6_interface_prefix_detail_cmd,
997 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
998 SHOW_STR
999 IP6_STR
1000 OSPF6_STR
1001 INTERFACE_STR
1002 "Display connected prefixes to advertise\n"
1003 OSPF6_ROUTE_ADDRESS_STR
1004 OSPF6_ROUTE_PREFIX_STR
1005 "Dispaly details of the prefixes\n"
1006 );
1007
1008ALIAS (show_ipv6_ospf6_interface_prefix,
1009 show_ipv6_ospf6_interface_prefix_match_cmd,
1010 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1011 SHOW_STR
1012 IP6_STR
1013 OSPF6_STR
1014 INTERFACE_STR
1015 "Display connected prefixes to advertise\n"
1016 OSPF6_ROUTE_PREFIX_STR
1017 OSPF6_ROUTE_MATCH_STR
1018 "Dispaly details of the prefixes\n"
1019 );
1020
718e3744 1021
1022/* interface variable set command */
1023DEFUN (ipv6_ospf6_cost,
1024 ipv6_ospf6_cost_cmd,
508e53e2 1025 "ipv6 ospf6 cost <1-65535>",
718e3744 1026 IP6_STR
1027 OSPF6_STR
1028 "Interface cost\n"
508e53e2 1029 "Outgoing metric of this interface\n"
718e3744 1030 )
1031{
508e53e2 1032 struct ospf6_interface *oi;
718e3744 1033 struct interface *ifp;
1034
508e53e2 1035 ifp = (struct interface *) vty->index;
718e3744 1036 assert (ifp);
1037
508e53e2 1038 oi = (struct ospf6_interface *) ifp->info;
1039 if (oi == NULL)
1040 oi = ospf6_interface_create (ifp);
1041 assert (oi);
718e3744 1042
508e53e2 1043 if (oi->cost == strtol (argv[0], NULL, 10))
718e3744 1044 return CMD_SUCCESS;
1045
508e53e2 1046 oi->cost = strtol (argv[0], NULL, 10);
718e3744 1047
508e53e2 1048 /* update cost held in route_connected list in ospf6_interface */
1049 ospf6_interface_connected_route_update (oi->interface);
718e3744 1050
508e53e2 1051 /* execute LSA hooks */
1052 if (oi->area)
1053 {
1054 OSPF6_LINK_LSA_SCHEDULE (oi);
1055 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1056 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1057 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1058 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1059 }
718e3744 1060
1061 return CMD_SUCCESS;
1062}
1063
718e3744 1064DEFUN (ipv6_ospf6_hellointerval,
1065 ipv6_ospf6_hellointerval_cmd,
508e53e2 1066 "ipv6 ospf6 hello-interval <1-65535>",
718e3744 1067 IP6_STR
1068 OSPF6_STR
508e53e2 1069 "Interval time of Hello packets\n"
718e3744 1070 SECONDS_STR
1071 )
1072{
508e53e2 1073 struct ospf6_interface *oi;
718e3744 1074 struct interface *ifp;
1075
1076 ifp = (struct interface *) vty->index;
1077 assert (ifp);
718e3744 1078
508e53e2 1079 oi = (struct ospf6_interface *) ifp->info;
1080 if (oi == NULL)
1081 oi = ospf6_interface_create (ifp);
1082 assert (oi);
1083
1084 oi->hello_interval = strtol (argv[0], NULL, 10);
718e3744 1085 return CMD_SUCCESS;
1086}
1087
1088/* interface variable set command */
1089DEFUN (ipv6_ospf6_deadinterval,
1090 ipv6_ospf6_deadinterval_cmd,
508e53e2 1091 "ipv6 ospf6 dead-interval <1-65535>",
718e3744 1092 IP6_STR
1093 OSPF6_STR
508e53e2 1094 "Interval time after which a neighbor is declared down\n"
718e3744 1095 SECONDS_STR
1096 )
1097{
508e53e2 1098 struct ospf6_interface *oi;
718e3744 1099 struct interface *ifp;
1100
1101 ifp = (struct interface *) vty->index;
1102 assert (ifp);
718e3744 1103
508e53e2 1104 oi = (struct ospf6_interface *) ifp->info;
1105 if (oi == NULL)
1106 oi = ospf6_interface_create (ifp);
1107 assert (oi);
1108
1109 oi->dead_interval = strtol (argv[0], NULL, 10);
718e3744 1110 return CMD_SUCCESS;
1111}
1112
1113/* interface variable set command */
1114DEFUN (ipv6_ospf6_transmitdelay,
1115 ipv6_ospf6_transmitdelay_cmd,
508e53e2 1116 "ipv6 ospf6 transmit-delay <1-3600>",
718e3744 1117 IP6_STR
1118 OSPF6_STR
508e53e2 1119 "Transmit delay of this interface\n"
718e3744 1120 SECONDS_STR
1121 )
1122{
508e53e2 1123 struct ospf6_interface *oi;
718e3744 1124 struct interface *ifp;
1125
1126 ifp = (struct interface *) vty->index;
1127 assert (ifp);
718e3744 1128
508e53e2 1129 oi = (struct ospf6_interface *) ifp->info;
1130 if (oi == NULL)
1131 oi = ospf6_interface_create (ifp);
1132 assert (oi);
1133
1134 oi->transdelay = strtol (argv[0], NULL, 10);
718e3744 1135 return CMD_SUCCESS;
1136}
1137
1138/* interface variable set command */
1139DEFUN (ipv6_ospf6_retransmitinterval,
1140 ipv6_ospf6_retransmitinterval_cmd,
508e53e2 1141 "ipv6 ospf6 retransmit-interval <1-65535>",
718e3744 1142 IP6_STR
1143 OSPF6_STR
1144 "Time between retransmitting lost link state advertisements\n"
1145 SECONDS_STR
1146 )
1147{
508e53e2 1148 struct ospf6_interface *oi;
718e3744 1149 struct interface *ifp;
1150
1151 ifp = (struct interface *) vty->index;
1152 assert (ifp);
718e3744 1153
508e53e2 1154 oi = (struct ospf6_interface *) ifp->info;
1155 if (oi == NULL)
1156 oi = ospf6_interface_create (ifp);
1157 assert (oi);
1158
1159 oi->rxmt_interval = strtol (argv[0], NULL, 10);
718e3744 1160 return CMD_SUCCESS;
1161}
1162
1163/* interface variable set command */
1164DEFUN (ipv6_ospf6_priority,
1165 ipv6_ospf6_priority_cmd,
508e53e2 1166 "ipv6 ospf6 priority <0-255>",
718e3744 1167 IP6_STR
1168 OSPF6_STR
1169 "Router priority\n"
508e53e2 1170 "Priority value\n"
718e3744 1171 )
1172{
508e53e2 1173 struct ospf6_interface *oi;
718e3744 1174 struct interface *ifp;
1175
1176 ifp = (struct interface *) vty->index;
1177 assert (ifp);
718e3744 1178
508e53e2 1179 oi = (struct ospf6_interface *) ifp->info;
1180 if (oi == NULL)
1181 oi = ospf6_interface_create (ifp);
1182 assert (oi);
1183
1184 oi->priority = strtol (argv[0], NULL, 10);
718e3744 1185
508e53e2 1186 if (oi->area)
1187 ospf6_interface_state_change (dr_election (oi), oi);
718e3744 1188
1189 return CMD_SUCCESS;
1190}
1191
1192DEFUN (ipv6_ospf6_instance,
1193 ipv6_ospf6_instance_cmd,
508e53e2 1194 "ipv6 ospf6 instance-id <0-255>",
718e3744 1195 IP6_STR
1196 OSPF6_STR
508e53e2 1197 "Instance ID for this interface\n"
1198 "Instance ID value\n"
718e3744 1199 )
1200{
508e53e2 1201 struct ospf6_interface *oi;
718e3744 1202 struct interface *ifp;
1203
1204 ifp = (struct interface *)vty->index;
1205 assert (ifp);
1206
508e53e2 1207 oi = (struct ospf6_interface *)ifp->info;
1208 if (oi == NULL)
1209 oi = ospf6_interface_create (ifp);
1210 assert (oi);
718e3744 1211
508e53e2 1212 oi->instance_id = strtol (argv[0], NULL, 10);
718e3744 1213 return CMD_SUCCESS;
1214}
1215
1216DEFUN (ipv6_ospf6_passive,
1217 ipv6_ospf6_passive_cmd,
1218 "ipv6 ospf6 passive",
1219 IP6_STR
1220 OSPF6_STR
508e53e2 1221 "passive interface, No adjacency will be formed on this interface\n"
718e3744 1222 )
1223{
508e53e2 1224 struct ospf6_interface *oi;
718e3744 1225 struct interface *ifp;
1226 listnode node;
508e53e2 1227 struct ospf6_neighbor *on;
718e3744 1228
1229 ifp = (struct interface *) vty->index;
1230 assert (ifp);
718e3744 1231
508e53e2 1232 oi = (struct ospf6_interface *) ifp->info;
1233 if (oi == NULL)
1234 oi = ospf6_interface_create (ifp);
1235 assert (oi);
718e3744 1236
508e53e2 1237 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1238 THREAD_OFF (oi->thread_send_hello);
1239
1240 for (node = listhead (oi->neighbor_list); node; nextnode (node))
718e3744 1241 {
508e53e2 1242 on = (struct ospf6_neighbor *) getdata (node);
1243 THREAD_OFF (on->inactivity_timer);
1244 thread_execute (master, inactivity_timer, on, 0);
718e3744 1245 }
1246
1247 return CMD_SUCCESS;
1248}
1249
1250DEFUN (no_ipv6_ospf6_passive,
1251 no_ipv6_ospf6_passive_cmd,
1252 "no ipv6 ospf6 passive",
1253 NO_STR
1254 IP6_STR
1255 OSPF6_STR
1256 "passive interface: No Adjacency will be formed on this I/F\n"
1257 )
1258{
508e53e2 1259 struct ospf6_interface *oi;
718e3744 1260 struct interface *ifp;
1261
1262 ifp = (struct interface *) vty->index;
1263 assert (ifp);
718e3744 1264
508e53e2 1265 oi = (struct ospf6_interface *) ifp->info;
1266 if (oi == NULL)
1267 oi = ospf6_interface_create (ifp);
1268 assert (oi);
718e3744 1269
508e53e2 1270 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1271 THREAD_OFF (oi->thread_send_hello);
1272 oi->thread_send_hello =
1273 thread_add_event (master, ospf6_hello_send, oi, 0);
718e3744 1274
1275 return CMD_SUCCESS;
1276}
1277
1278DEFUN (ipv6_ospf6_advertise_prefix_list,
1279 ipv6_ospf6_advertise_prefix_list_cmd,
1280 "ipv6 ospf6 advertise prefix-list WORD",
1281 IP6_STR
1282 OSPF6_STR
1283 "Advertising options\n"
1284 "Filter prefix using prefix-list\n"
1285 "Prefix list name\n"
1286 )
1287{
508e53e2 1288 struct ospf6_interface *oi;
718e3744 1289 struct interface *ifp;
1290
1291 ifp = (struct interface *) vty->index;
1292 assert (ifp);
718e3744 1293
508e53e2 1294 oi = (struct ospf6_interface *) ifp->info;
1295 if (oi == NULL)
1296 oi = ospf6_interface_create (ifp);
1297 assert (oi);
718e3744 1298
508e53e2 1299 if (oi->plist_name)
1300 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1301 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
718e3744 1302
508e53e2 1303 ospf6_interface_connected_route_update (oi->interface);
1304 OSPF6_LINK_LSA_SCHEDULE (oi);
1305 if (oi->state == OSPF6_INTERFACE_DR)
1306 {
1307 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1308 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1309 }
1310 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
718e3744 1311
1312 return CMD_SUCCESS;
1313}
1314
1315DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1316 no_ipv6_ospf6_advertise_prefix_list_cmd,
1317 "no ipv6 ospf6 advertise prefix-list",
1318 NO_STR
1319 IP6_STR
1320 OSPF6_STR
1321 "Advertising options\n"
1322 "Filter prefix using prefix-list\n"
1323 )
1324{
508e53e2 1325 struct ospf6_interface *oi;
718e3744 1326 struct interface *ifp;
1327
1328 ifp = (struct interface *) vty->index;
1329 assert (ifp);
718e3744 1330
508e53e2 1331 oi = (struct ospf6_interface *) ifp->info;
1332 if (oi == NULL)
1333 oi = ospf6_interface_create (ifp);
1334 assert (oi);
1335
1336 if (oi->plist_name)
718e3744 1337 {
508e53e2 1338 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1339 oi->plist_name = NULL;
718e3744 1340 }
1341
508e53e2 1342 ospf6_interface_connected_route_update (oi->interface);
1343 OSPF6_LINK_LSA_SCHEDULE (oi);
1344 if (oi->state == OSPF6_INTERFACE_DR)
1345 {
1346 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1347 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1348 }
1349 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
718e3744 1350
1351 return CMD_SUCCESS;
1352}
1353
1354int
508e53e2 1355config_write_ospf6_interface (struct vty *vty)
718e3744 1356{
1357 listnode i;
508e53e2 1358 struct ospf6_interface *oi;
718e3744 1359 struct interface *ifp;
1360
1361 for (i = listhead (iflist); i; nextnode (i))
1362 {
1363 ifp = (struct interface *) getdata (i);
508e53e2 1364 oi = (struct ospf6_interface *) ifp->info;
1365 if (oi == NULL)
718e3744 1366 continue;
1367
1368 vty_out (vty, "interface %s%s",
508e53e2 1369 oi->interface->name, VTY_NEWLINE);
1370
1371 if (ifp->desc)
1372 vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
1373
718e3744 1374 vty_out (vty, " ipv6 ospf6 cost %d%s",
508e53e2 1375 oi->cost, VTY_NEWLINE);
718e3744 1376 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
508e53e2 1377 oi->hello_interval, VTY_NEWLINE);
718e3744 1378 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
508e53e2 1379 oi->dead_interval, VTY_NEWLINE);
718e3744 1380 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
508e53e2 1381 oi->rxmt_interval, VTY_NEWLINE);
718e3744 1382 vty_out (vty, " ipv6 ospf6 priority %d%s",
508e53e2 1383 oi->priority, VTY_NEWLINE);
718e3744 1384 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
508e53e2 1385 oi->transdelay, VTY_NEWLINE);
718e3744 1386 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
508e53e2 1387 oi->instance_id, VTY_NEWLINE);
718e3744 1388
508e53e2 1389 if (oi->plist_name)
718e3744 1390 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
508e53e2 1391 oi->plist_name, VTY_NEWLINE);
718e3744 1392
508e53e2 1393 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
718e3744 1394 vty_out (vty, " ipv6 ospf6 passive%s", VTY_NEWLINE);
1395
1396 vty_out (vty, "!%s", VTY_NEWLINE);
1397 }
1398 return 0;
1399}
1400
1401struct cmd_node interface_node =
1402{
1403 INTERFACE_NODE,
1404 "%s(config-if)# ",
1405};
1406
1407void
1408ospf6_interface_init ()
1409{
1410 /* Install interface node. */
508e53e2 1411 install_node (&interface_node, config_write_ospf6_interface);
718e3744 1412
1413 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
508e53e2 1414 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1415 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1416 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
718e3744 1417 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
508e53e2 1418 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1419 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1420 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
718e3744 1421 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
508e53e2 1422 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1423 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1424 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
718e3744 1425 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
508e53e2 1426 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1427 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1428 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
718e3744 1429
508e53e2 1430 install_element (CONFIG_NODE, &interface_cmd);
718e3744 1431 install_default (INTERFACE_NODE);
1432 install_element (INTERFACE_NODE, &interface_desc_cmd);
1433 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1434 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
1435 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1436 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1437 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1438 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1439 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1440 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
508e53e2 1441
718e3744 1442 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1443 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
508e53e2 1444
1445 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1446 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1447}
1448
1449DEFUN (debug_ospf6_interface,
1450 debug_ospf6_interface_cmd,
1451 "debug ospf6 interface",
1452 DEBUG_STR
1453 OSPF6_STR
1454 "Debug OSPFv3 Interface\n"
1455 )
1456{
1457 OSPF6_DEBUG_INTERFACE_ON ();
1458 return CMD_SUCCESS;
1459}
1460
1461DEFUN (no_debug_ospf6_interface,
1462 no_debug_ospf6_interface_cmd,
1463 "no debug ospf6 interface",
1464 NO_STR
1465 DEBUG_STR
1466 OSPF6_STR
1467 "Debug OSPFv3 Interface\n"
1468 )
1469{
1470 OSPF6_DEBUG_INTERFACE_ON ();
1471 return CMD_SUCCESS;
1472}
1473
1474int
1475config_write_ospf6_debug_interface (struct vty *vty)
1476{
1477 if (IS_OSPF6_DEBUG_INTERFACE)
1478 vty_out (vty, "debug ospf6 interface%s", VTY_NEWLINE);
1479 return 0;
1480}
1481
1482void
1483install_element_ospf6_debug_interface ()
1484{
1485 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1486 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1487 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1488 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
718e3744 1489}
1490
1491