]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_interface.c
build: Quagga 0.99.23-rc1
[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 "ospf6_lsa.h"
718e3744 33#include "ospf6_lsdb.h"
508e53e2 34#include "ospf6_network.h"
35#include "ospf6_message.h"
36#include "ospf6_route.h"
718e3744 37#include "ospf6_top.h"
38#include "ospf6_area.h"
39#include "ospf6_interface.h"
508e53e2 40#include "ospf6_neighbor.h"
41#include "ospf6_intra.h"
42#include "ospf6_spf.h"
049207c3 43#include "ospf6d.h"
718e3744 44
508e53e2 45unsigned char conf_debug_ospf6_interface = 0;
46
0c083ee9 47const char *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 74/* schedule routing table recalculation */
6ac29a51 75static void
a0edf674 76ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa, unsigned int reason)
718e3744 77{
3810e06e
DD
78 struct ospf6_interface *oi;
79
80 if (lsa == NULL)
81 return;
82
83 oi = lsa->lsdb->data;
508e53e2 84 switch (ntohs (lsa->header->type))
85 {
86 case OSPF6_LSTYPE_LINK:
3810e06e
DD
87 if (oi->state == OSPF6_INTERFACE_DR)
88 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
a0edf674 89 ospf6_spf_schedule (oi->area->ospf6, reason);
508e53e2 90 break;
91
92 default:
508e53e2 93 break;
94 }
718e3744 95}
96
a0edf674
DD
97static void
98ospf6_interface_lsdb_hook_add (struct ospf6_lsa *lsa)
99{
100 ospf6_interface_lsdb_hook(lsa, ospf6_lsadd_to_spf_reason(lsa));
101}
102
103static void
104ospf6_interface_lsdb_hook_remove (struct ospf6_lsa *lsa)
105{
106 ospf6_interface_lsdb_hook(lsa, ospf6_lsremove_to_spf_reason(lsa));
107}
108
c5926a92
DD
109static u_char
110ospf6_default_iftype(struct interface *ifp)
111{
112 if (if_is_pointopoint (ifp))
113 return OSPF_IFTYPE_POINTOPOINT;
114 else if (if_is_loopback (ifp))
115 return OSPF_IFTYPE_LOOPBACK;
116 else
117 return OSPF_IFTYPE_BROADCAST;
118}
119
c19543b2
VB
120static u_int32_t
121ospf6_interface_get_cost (struct ospf6_interface *oi)
122{
123 /* If all else fails, use default OSPF cost */
124 u_int32_t cost;
125 u_int32_t bw, refbw;
126
127 bw = oi->interface->bandwidth ? oi->interface->bandwidth : OSPF6_INTERFACE_BANDWIDTH;
fd500689 128 refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
c19543b2
VB
129
130 /* A specifed ip ospf cost overrides a calculated one. */
131 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
132 cost = oi->cost;
133 else
134 {
135 cost = (u_int32_t) ((double)refbw / (double)bw + (double)0.5);
136 if (cost < 1) cost = 1;
137 else if (cost > UINT32_MAX) cost = UINT32_MAX;
138 }
139
140 return cost;
141}
142
143static void
144ospf6_interface_recalculate_cost (struct ospf6_interface *oi)
145{
146 u_int32_t newcost;
147
148 newcost = ospf6_interface_get_cost (oi);
149 if (newcost == oi->cost) return;
150 oi->cost = newcost;
151
152 /* update cost held in route_connected list in ospf6_interface */
153 ospf6_interface_connected_route_update (oi->interface);
154
155 /* execute LSA hooks */
156 if (oi->area)
157 {
158 OSPF6_LINK_LSA_SCHEDULE (oi);
159 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
160 OSPF6_NETWORK_LSA_SCHEDULE (oi);
161 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
162 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
163 }
164}
165
718e3744 166/* Create new ospf6 interface structure */
167struct ospf6_interface *
168ospf6_interface_create (struct interface *ifp)
169{
508e53e2 170 struct ospf6_interface *oi;
0c083ee9 171 unsigned int iobuflen;
718e3744 172
508e53e2 173 oi = (struct ospf6_interface *)
393deb9b 174 XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
718e3744 175
393deb9b 176 if (!oi)
718e3744 177 {
178 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
179 return (struct ospf6_interface *) NULL;
180 }
181
508e53e2 182 oi->area = (struct ospf6_area *) NULL;
183 oi->neighbor_list = list_new ();
184 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
185 oi->linklocal_addr = (struct in6_addr *) NULL;
b51a3a31
VT
186 oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
187 oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
188 oi->priority = OSPF6_INTERFACE_PRIORITY;
189
8551e6da
DD
190 oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
191 oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
192 oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
c5926a92 193 oi->type = ospf6_default_iftype (ifp);
508e53e2 194 oi->state = OSPF6_INTERFACE_DOWN;
195 oi->flag = 0;
d42306d9 196 oi->mtu_ignore = 0;
508e53e2 197
b596c71e 198 /* Try to adjust I/O buffer size with IfMtu */
1203e1c0 199 oi->ifmtu = ifp->mtu6;
200 iobuflen = ospf6_iobuf_size (ifp->mtu6);
b596c71e 201 if (oi->ifmtu > iobuflen)
3b4cd3a9 202 {
1e05838a 203 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 204 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
205 ifp->name, iobuflen);
3b4cd3a9 206 oi->ifmtu = iobuflen;
207 }
3b4cd3a9 208
6452df09 209 oi->lsupdate_list = ospf6_lsdb_create (oi);
210 oi->lsack_list = ospf6_lsdb_create (oi);
211 oi->lsdb = ospf6_lsdb_create (oi);
a0edf674
DD
212 oi->lsdb->hook_add = ospf6_interface_lsdb_hook_add;
213 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook_remove;
6452df09 214 oi->lsdb_self = ospf6_lsdb_create (oi);
508e53e2 215
cf1ce250
PJ
216 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
217 oi->route_connected->scope = oi;
718e3744 218
219 /* link both */
508e53e2 220 oi->interface = ifp;
221 ifp->info = oi;
718e3744 222
c19543b2
VB
223 /* Compute cost. */
224 oi->cost = ospf6_interface_get_cost(oi);
225
508e53e2 226 return oi;
718e3744 227}
228
229void
508e53e2 230ospf6_interface_delete (struct ospf6_interface *oi)
718e3744 231{
1eb8ef25 232 struct listnode *node, *nnode;
508e53e2 233 struct ospf6_neighbor *on;
718e3744 234
1eb8ef25 235 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
508e53e2 236 ospf6_neighbor_delete (on);
1eb8ef25 237
508e53e2 238 list_delete (oi->neighbor_list);
718e3744 239
508e53e2 240 THREAD_OFF (oi->thread_send_hello);
241 THREAD_OFF (oi->thread_send_lsupdate);
242 THREAD_OFF (oi->thread_send_lsack);
243
244 ospf6_lsdb_remove_all (oi->lsdb);
245 ospf6_lsdb_remove_all (oi->lsupdate_list);
246 ospf6_lsdb_remove_all (oi->lsack_list);
247
248 ospf6_lsdb_delete (oi->lsdb);
6452df09 249 ospf6_lsdb_delete (oi->lsdb_self);
250
508e53e2 251 ospf6_lsdb_delete (oi->lsupdate_list);
252 ospf6_lsdb_delete (oi->lsack_list);
718e3744 253
508e53e2 254 ospf6_route_table_delete (oi->route_connected);
718e3744 255
256 /* cut link */
508e53e2 257 oi->interface->info = NULL;
718e3744 258
259 /* plist_name */
508e53e2 260 if (oi->plist_name)
261 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
262
263 XFREE (MTYPE_OSPF6_IF, oi);
264}
265
266void
267ospf6_interface_enable (struct ospf6_interface *oi)
268{
269 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
d9628728 270 ospf6_interface_state_update (oi->interface);
508e53e2 271}
272
273void
274ospf6_interface_disable (struct ospf6_interface *oi)
275{
508e53e2 276 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
277
d9628728 278 thread_execute (master, interface_down, oi, 0);
508e53e2 279
280 ospf6_lsdb_remove_all (oi->lsdb);
d9628728 281 ospf6_lsdb_remove_all (oi->lsdb_self);
508e53e2 282 ospf6_lsdb_remove_all (oi->lsupdate_list);
283 ospf6_lsdb_remove_all (oi->lsack_list);
284
285 THREAD_OFF (oi->thread_send_hello);
286 THREAD_OFF (oi->thread_send_lsupdate);
287 THREAD_OFF (oi->thread_send_lsack);
d9628728
CF
288
289 THREAD_OFF (oi->thread_network_lsa);
290 THREAD_OFF (oi->thread_link_lsa);
291 THREAD_OFF (oi->thread_intra_prefix_lsa);
718e3744 292}
293
294static struct in6_addr *
508e53e2 295ospf6_interface_get_linklocal_address (struct interface *ifp)
718e3744 296{
52dc7ee6 297 struct listnode *n;
718e3744 298 struct connected *c;
299 struct in6_addr *l = (struct in6_addr *) NULL;
300
301 /* for each connected address */
1eb8ef25 302 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
718e3744 303 {
718e3744 304 /* if family not AF_INET6, ignore */
305 if (c->address->family != AF_INET6)
306 continue;
307
308 /* linklocal scope check */
309 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
310 l = &c->address->u.prefix6;
311 }
312 return l;
313}
314
315void
316ospf6_interface_if_add (struct interface *ifp)
317{
508e53e2 318 struct ospf6_interface *oi;
0c083ee9 319 unsigned int iobuflen;
718e3744 320
508e53e2 321 oi = (struct ospf6_interface *) ifp->info;
322 if (oi == NULL)
718e3744 323 return;
324
b596c71e 325 /* Try to adjust I/O buffer size with IfMtu */
326 if (oi->ifmtu == 0)
1203e1c0 327 oi->ifmtu = ifp->mtu6;
328 iobuflen = ospf6_iobuf_size (ifp->mtu6);
b596c71e 329 if (oi->ifmtu > iobuflen)
3b4cd3a9 330 {
1e05838a 331 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 332 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
333 ifp->name, iobuflen);
3b4cd3a9 334 oi->ifmtu = iobuflen;
335 }
718e3744 336
337 /* interface start */
b13c1d92 338 ospf6_interface_state_update(oi->interface);
718e3744 339}
340
341void
342ospf6_interface_if_del (struct interface *ifp)
343{
508e53e2 344 struct ospf6_interface *oi;
718e3744 345
508e53e2 346 oi = (struct ospf6_interface *) ifp->info;
347 if (oi == NULL)
718e3744 348 return;
349
350 /* interface stop */
508e53e2 351 if (oi->area)
352 thread_execute (master, interface_down, oi, 0);
718e3744 353
508e53e2 354 listnode_delete (oi->area->if_list, oi);
355 oi->area = (struct ospf6_area *) NULL;
718e3744 356
357 /* cut link */
508e53e2 358 oi->interface = NULL;
718e3744 359 ifp->info = NULL;
360
508e53e2 361 ospf6_interface_delete (oi);
718e3744 362}
363
364void
365ospf6_interface_state_update (struct interface *ifp)
366{
508e53e2 367 struct ospf6_interface *oi;
718e3744 368
508e53e2 369 oi = (struct ospf6_interface *) ifp->info;
370 if (oi == NULL)
718e3744 371 return;
508e53e2 372 if (oi->area == NULL)
718e3744 373 return;
d9628728
CF
374 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
375 return;
718e3744 376
b13c1d92
CF
377 if (if_is_operative (ifp)
378 && (ospf6_interface_get_linklocal_address(oi->interface)
379 || if_is_loopback(oi->interface)))
508e53e2 380 thread_add_event (master, interface_up, oi, 0);
718e3744 381 else
508e53e2 382 thread_add_event (master, interface_down, oi, 0);
718e3744 383
384 return;
385}
386
387void
508e53e2 388ospf6_interface_connected_route_update (struct interface *ifp)
718e3744 389{
508e53e2 390 struct ospf6_interface *oi;
391 struct ospf6_route *route;
392 struct connected *c;
1eb8ef25 393 struct listnode *node, *nnode;
718e3744 394
508e53e2 395 oi = (struct ospf6_interface *) ifp->info;
396 if (oi == NULL)
718e3744 397 return;
398
399 /* reset linklocal pointer */
508e53e2 400 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
718e3744 401
508e53e2 402 /* if area is null, do not make connected-route list */
403 if (oi->area == NULL)
718e3744 404 return;
405
d9628728
CF
406 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
407 return;
408
508e53e2 409 /* update "route to advertise" interface route table */
410 ospf6_route_remove_all (oi->route_connected);
508e53e2 411
1eb8ef25 412 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
413 {
508e53e2 414 if (c->address->family != AF_INET6)
415 continue;
416
1e05838a 417 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
418 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
419 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
420 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
421 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
718e3744 422
508e53e2 423 /* apply filter */
424 if (oi->plist_name)
425 {
426 struct prefix_list *plist;
427 enum prefix_list_type ret;
428 char buf[128];
429
430 prefix2str (c->address, buf, sizeof (buf));
431 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
432 ret = prefix_list_apply (plist, (void *) c->address);
433 if (ret == PREFIX_DENY)
434 {
1e05838a 435 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 436 zlog_debug ("%s on %s filtered by prefix-list %s ",
437 buf, oi->interface->name, oi->plist_name);
508e53e2 438 continue;
439 }
440 }
441
442 route = ospf6_route_create ();
443 memcpy (&route->prefix, c->address, sizeof (struct prefix));
444 apply_mask (&route->prefix);
445 route->type = OSPF6_DEST_TYPE_NETWORK;
446 route->path.area_id = oi->area->area_id;
447 route->path.type = OSPF6_PATH_TYPE_INTRA;
448 route->path.cost = oi->cost;
449 route->nexthop[0].ifindex = oi->interface->ifindex;
450 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
451 ospf6_route_add (route, oi->route_connected);
452 }
453
454 /* create new Link-LSA */
455 OSPF6_LINK_LSA_SCHEDULE (oi);
456 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
457 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
718e3744 458}
459
508e53e2 460static void
461ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
718e3744 462{
508e53e2 463 u_char prev_state;
718e3744 464
508e53e2 465 prev_state = oi->state;
466 oi->state = next_state;
718e3744 467
508e53e2 468 if (prev_state == next_state)
469 return;
470
471 /* log */
472 if (IS_OSPF6_DEBUG_INTERFACE)
473 {
c6487d61 474 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
475 ospf6_interface_state_str[prev_state],
476 ospf6_interface_state_str[next_state]);
508e53e2 477 }
3bc4f84e 478 oi->state_change++;
718e3744 479
508e53e2 480 if ((prev_state == OSPF6_INTERFACE_DR ||
481 prev_state == OSPF6_INTERFACE_BDR) &&
482 (next_state != OSPF6_INTERFACE_DR &&
483 next_state != OSPF6_INTERFACE_BDR))
9a9446ea 484 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
c5926a92 485
508e53e2 486 if ((prev_state != OSPF6_INTERFACE_DR &&
487 prev_state != OSPF6_INTERFACE_BDR) &&
488 (next_state == OSPF6_INTERFACE_DR ||
489 next_state == OSPF6_INTERFACE_BDR))
9a9446ea 490 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
508e53e2 491
492 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
6452df09 493 if (next_state == OSPF6_INTERFACE_DOWN)
494 {
495 OSPF6_NETWORK_LSA_EXECUTE (oi);
496 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
497 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
498 }
499 else if (prev_state == OSPF6_INTERFACE_DR ||
500 next_state == OSPF6_INTERFACE_DR)
508e53e2 501 {
502 OSPF6_NETWORK_LSA_SCHEDULE (oi);
503 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
504 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
505 }
bf836661
VB
506
507#ifdef HAVE_SNMP
508 /* Terminal state or regression */
509 if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
510 (next_state == OSPF6_INTERFACE_DROTHER) ||
511 (next_state == OSPF6_INTERFACE_BDR) ||
512 (next_state == OSPF6_INTERFACE_DR) ||
513 (next_state < prev_state))
514 ospf6TrapIfStateChange (oi);
515#endif
516
718e3744 517}
518
508e53e2 519\f
520/* DR Election, RFC2328 section 9.4 */
718e3744 521
508e53e2 522#define IS_ELIGIBLE(n) \
523 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
718e3744 524
508e53e2 525static struct ospf6_neighbor *
526better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
527{
528 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
529 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
530 return NULL;
531 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
532 return b;
533 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
534 return a;
535
536 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
537 return a;
538 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
539 return b;
540
541 if (a->priority > b->priority)
542 return a;
543 if (a->priority < b->priority)
544 return b;
545
546 if (ntohl (a->router_id) > ntohl (b->router_id))
547 return a;
548 if (ntohl (a->router_id) < ntohl (b->router_id))
549 return b;
550
551 zlog_warn ("Router-ID duplicate ?");
552 return a;
553}
718e3744 554
508e53e2 555static struct ospf6_neighbor *
556better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
557{
558 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
559 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
560 return NULL;
561 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
562 return b;
563 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
564 return a;
565
566 if (a->drouter == a->router_id && b->drouter != b->router_id)
567 return a;
568 if (a->drouter != a->router_id && b->drouter == b->router_id)
569 return b;
570
571 if (a->priority > b->priority)
572 return a;
573 if (a->priority < b->priority)
574 return b;
575
576 if (ntohl (a->router_id) > ntohl (b->router_id))
577 return a;
578 if (ntohl (a->router_id) < ntohl (b->router_id))
579 return b;
580
581 zlog_warn ("Router-ID duplicate ?");
582 return a;
718e3744 583}
584
508e53e2 585static u_char
586dr_election (struct ospf6_interface *oi)
718e3744 587{
1eb8ef25 588 struct listnode *node, *nnode;
508e53e2 589 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
590 struct ospf6_neighbor *best_drouter, *best_bdrouter;
591 u_char next_state = 0;
592
593 drouter = bdrouter = NULL;
594 best_drouter = best_bdrouter = NULL;
595
596 /* pseudo neighbor myself, including noting current DR/BDR (1) */
597 memset (&myself, 0, sizeof (myself));
598 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
599 sizeof (myself.name));
600 myself.state = OSPF6_NEIGHBOR_TWOWAY;
601 myself.drouter = oi->drouter;
602 myself.bdrouter = oi->bdrouter;
603 myself.priority = oi->priority;
604 myself.router_id = oi->area->ospf6->router_id;
605
606 /* Electing BDR (2) */
1eb8ef25 607 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
608 bdrouter = better_bdrouter (bdrouter, on);
609
508e53e2 610 best_bdrouter = bdrouter;
611 bdrouter = better_bdrouter (best_bdrouter, &myself);
612
613 /* Electing DR (3) */
1eb8ef25 614 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
615 drouter = better_drouter (drouter, on);
616
508e53e2 617 best_drouter = drouter;
618 drouter = better_drouter (best_drouter, &myself);
619 if (drouter == NULL)
620 drouter = bdrouter;
621
622 /* the router itself is newly/no longer DR/BDR (4) */
623 if ((drouter == &myself && myself.drouter != myself.router_id) ||
624 (drouter != &myself && myself.drouter == myself.router_id) ||
625 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
626 (bdrouter != &myself && myself.bdrouter == myself.router_id))
627 {
628 myself.drouter = (drouter ? drouter->router_id : htonl (0));
629 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
630
631 /* compatible to Electing BDR (2) */
632 bdrouter = better_bdrouter (best_bdrouter, &myself);
633
634 /* compatible to Electing DR (3) */
635 drouter = better_drouter (best_drouter, &myself);
636 if (drouter == NULL)
637 drouter = bdrouter;
638 }
639
640 /* Set interface state accordingly (5) */
641 if (drouter && drouter == &myself)
642 next_state = OSPF6_INTERFACE_DR;
643 else if (bdrouter && bdrouter == &myself)
644 next_state = OSPF6_INTERFACE_BDR;
645 else
646 next_state = OSPF6_INTERFACE_DROTHER;
718e3744 647
508e53e2 648 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
649 /* XXX */
650
651 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
652 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
653 accordingly after AdjOK */
654 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
655 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
718e3744 656 {
508e53e2 657 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 658 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
659 (drouter ? drouter->name : "0.0.0.0"),
660 (bdrouter ? bdrouter->name : "0.0.0.0"));
508e53e2 661
1eb8ef25 662 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
508e53e2 663 {
508e53e2 664 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
665 continue;
666 /* Schedule AdjOK. */
667 thread_add_event (master, adj_ok, on, 0);
668 }
718e3744 669 }
508e53e2 670
671 oi->drouter = (drouter ? drouter->router_id : htonl (0));
672 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
673 return next_state;
718e3744 674}
675
508e53e2 676\f
677/* Interface State Machine */
718e3744 678int
508e53e2 679interface_up (struct thread *thread)
718e3744 680{
508e53e2 681 struct ospf6_interface *oi;
682
683 oi = (struct ospf6_interface *) THREAD_ARG (thread);
684 assert (oi && oi->interface);
685
686 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 687 zlog_debug ("Interface Event %s: [InterfaceUp]",
688 oi->interface->name);
508e53e2 689
690 /* check physical interface is up */
e7ad6b20 691 if (! if_is_operative (oi->interface))
508e53e2 692 {
693 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 694 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
695 oi->interface->name);
508e53e2 696 return 0;
697 }
698
b13c1d92
CF
699 /* check interface has a link-local address */
700 if (! (ospf6_interface_get_linklocal_address(oi->interface)
701 || if_is_loopback(oi->interface)))
702 {
703 if (IS_OSPF6_DEBUG_INTERFACE)
704 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
705 oi->interface->name);
706 return 0;
707 }
708
c19543b2
VB
709 /* Recompute cost */
710 ospf6_interface_recalculate_cost (oi);
711
508e53e2 712 /* if already enabled, do nothing */
713 if (oi->state > OSPF6_INTERFACE_DOWN)
714 {
715 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 716 zlog_debug ("Interface %s already enabled",
717 oi->interface->name);
508e53e2 718 return 0;
719 }
720
ba960d5a
DD
721 /* If no area assigned, return */
722 if (oi->area == NULL)
723 {
724 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__,
725 oi->interface->name);
726 return 0;
727 }
728
508e53e2 729 /* Join AllSPFRouters */
9a9446ea 730 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
508e53e2 731
732 /* Update interface route */
733 ospf6_interface_connected_route_update (oi->interface);
718e3744 734
508e53e2 735 /* Schedule Hello */
736 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
424cc3bd 737 oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
508e53e2 738
739 /* decide next interface state */
c5926a92
DD
740 if ((if_is_pointopoint (oi->interface)) ||
741 (oi->type == OSPF_IFTYPE_POINTOPOINT)) {
508e53e2 742 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
c5926a92 743 }
508e53e2 744 else if (oi->priority == 0)
745 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
746 else
718e3744 747 {
508e53e2 748 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
749 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
718e3744 750 }
508e53e2 751
752 return 0;
718e3744 753}
754
755int
508e53e2 756wait_timer (struct thread *thread)
718e3744 757{
508e53e2 758 struct ospf6_interface *oi;
718e3744 759
508e53e2 760 oi = (struct ospf6_interface *) THREAD_ARG (thread);
761 assert (oi && oi->interface);
718e3744 762
508e53e2 763 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 764 zlog_debug ("Interface Event %s: [WaitTimer]",
765 oi->interface->name);
718e3744 766
508e53e2 767 if (oi->state == OSPF6_INTERFACE_WAITING)
768 ospf6_interface_state_change (dr_election (oi), oi);
718e3744 769
508e53e2 770 return 0;
718e3744 771}
772
508e53e2 773int
774backup_seen (struct thread *thread)
775{
776 struct ospf6_interface *oi;
777
778 oi = (struct ospf6_interface *) THREAD_ARG (thread);
779 assert (oi && oi->interface);
780
781 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 782 zlog_debug ("Interface Event %s: [BackupSeen]",
783 oi->interface->name);
508e53e2 784
785 if (oi->state == OSPF6_INTERFACE_WAITING)
786 ospf6_interface_state_change (dr_election (oi), oi);
787
788 return 0;
789}
790
791int
792neighbor_change (struct thread *thread)
718e3744 793{
508e53e2 794 struct ospf6_interface *oi;
795
796 oi = (struct ospf6_interface *) THREAD_ARG (thread);
797 assert (oi && oi->interface);
798
799 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 800 zlog_debug ("Interface Event %s: [NeighborChange]",
801 oi->interface->name);
508e53e2 802
803 if (oi->state == OSPF6_INTERFACE_DROTHER ||
804 oi->state == OSPF6_INTERFACE_BDR ||
805 oi->state == OSPF6_INTERFACE_DR)
806 ospf6_interface_state_change (dr_election (oi), oi);
807
808 return 0;
718e3744 809}
810
508e53e2 811int
812interface_down (struct thread *thread)
718e3744 813{
508e53e2 814 struct ospf6_interface *oi;
1eb8ef25 815 struct listnode *node, *nnode;
508e53e2 816 struct ospf6_neighbor *on;
817
818 oi = (struct ospf6_interface *) THREAD_ARG (thread);
819 assert (oi && oi->interface);
820
821 if (IS_OSPF6_DEBUG_INTERFACE)
c6487d61 822 zlog_debug ("Interface Event %s: [InterfaceDown]",
823 oi->interface->name);
508e53e2 824
424cc3bd
DL
825 /* Stop Hellos */
826 THREAD_OFF (oi->thread_send_hello);
827
508e53e2 828 /* Leave AllSPFRouters */
829 if (oi->state > OSPF6_INTERFACE_DOWN)
9a9446ea 830 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
508e53e2 831
832 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
833
1eb8ef25 834 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
835 ospf6_neighbor_delete (on);
836
508e53e2 837 list_delete_all_node (oi->neighbor_list);
838
37531a7e
CF
839 /* When interface state is reset, also reset information about
840 * DR election, as it is no longer valid. */
841 oi->drouter = oi->prev_drouter = htonl(0);
842 oi->bdrouter = oi->prev_bdrouter = htonl(0);
508e53e2 843 return 0;
718e3744 844}
845
508e53e2 846\f
718e3744 847/* show specified interface structure */
6ac29a51 848static int
508e53e2 849ospf6_interface_show (struct vty *vty, struct interface *ifp)
718e3744 850{
508e53e2 851 struct ospf6_interface *oi;
718e3744 852 struct connected *c;
853 struct prefix *p;
52dc7ee6 854 struct listnode *i;
508e53e2 855 char strbuf[64], drouter[32], bdrouter[32];
0c083ee9 856 const char *updown[3] = {"down", "up", NULL};
857 const char *type;
508e53e2 858 struct timeval res, now;
859 char duration[32];
860 struct ospf6_lsa *lsa;
718e3744 861
862 /* check physical interface type */
508e53e2 863 if (if_is_loopback (ifp))
718e3744 864 type = "LOOPBACK";
508e53e2 865 else if (if_is_broadcast (ifp))
718e3744 866 type = "BROADCAST";
508e53e2 867 else if (if_is_pointopoint (ifp))
718e3744 868 type = "POINTOPOINT";
869 else
870 type = "UNKNOWN";
871
872 vty_out (vty, "%s is %s, type %s%s",
e7ad6b20 873 ifp->name, updown[if_is_operative (ifp)], type,
049207c3 874 VNL);
875 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
718e3744 876
508e53e2 877 if (ifp->info == NULL)
718e3744 878 {
049207c3 879 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
718e3744 880 return 0;
881 }
882 else
508e53e2 883 oi = (struct ospf6_interface *) ifp->info;
718e3744 884
049207c3 885 vty_out (vty, " Internet Address:%s", VNL);
1eb8ef25 886
887 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
718e3744 888 {
718e3744 889 p = c->address;
890 prefix2str (p, strbuf, sizeof (strbuf));
891 switch (p->family)
892 {
893 case AF_INET:
508e53e2 894 vty_out (vty, " inet : %s%s", strbuf,
049207c3 895 VNL);
718e3744 896 break;
897 case AF_INET6:
508e53e2 898 vty_out (vty, " inet6: %s%s", strbuf,
049207c3 899 VNL);
718e3744 900 break;
901 default:
508e53e2 902 vty_out (vty, " ??? : %s%s", strbuf,
049207c3 903 VNL);
718e3744 904 break;
905 }
906 }
907
508e53e2 908 if (oi->area)
718e3744 909 {
508e53e2 910 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
049207c3 911 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
d42306d9
DT
912 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
913 "disabled" : "enabled", VNL);
508e53e2 914 inet_ntop (AF_INET, &oi->area->area_id,
718e3744 915 strbuf, sizeof (strbuf));
508e53e2 916 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
049207c3 917 VNL);
718e3744 918 }
919 else
049207c3 920 vty_out (vty, " Not Attached to Area%s", VNL);
718e3744 921
922 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
508e53e2 923 ospf6_interface_state_str[oi->state],
924 oi->transdelay, oi->priority,
049207c3 925 VNL);
926 vty_out (vty, " Timer intervals configured:%s", VNL);
718e3744 927 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
508e53e2 928 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
049207c3 929 VNL);
718e3744 930
508e53e2 931 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
932 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
049207c3 933 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
718e3744 934
935 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
049207c3 936 oi->lsdb->count, VNL);
718e3744 937
86f72dcb 938 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
718e3744 939
508e53e2 940 timerclear (&res);
941 if (oi->thread_send_lsupdate)
942 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
943 timerstring (&res, duration, sizeof (duration));
944 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
945 oi->lsupdate_list->count, duration,
946 (oi->thread_send_lsupdate ? "on" : "off"),
049207c3 947 VNL);
508e53e2 948 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
949 lsa = ospf6_lsdb_next (lsa))
049207c3 950 vty_out (vty, " %s%s", lsa->name, VNL);
508e53e2 951
952 timerclear (&res);
953 if (oi->thread_send_lsack)
954 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
955 timerstring (&res, duration, sizeof (duration));
956 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
957 oi->lsack_list->count, duration,
958 (oi->thread_send_lsack ? "on" : "off"),
049207c3 959 VNL);
508e53e2 960 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
961 lsa = ospf6_lsdb_next (lsa))
049207c3 962 vty_out (vty, " %s%s", lsa->name, VNL);
718e3744 963
508e53e2 964 return 0;
718e3744 965}
966
967/* show interface */
968DEFUN (show_ipv6_ospf6_interface,
969 show_ipv6_ospf6_interface_ifname_cmd,
970 "show ipv6 ospf6 interface IFNAME",
971 SHOW_STR
972 IP6_STR
973 OSPF6_STR
974 INTERFACE_STR
975 IFNAME_STR
976 )
977{
978 struct interface *ifp;
52dc7ee6 979 struct listnode *i;
718e3744 980
981 if (argc)
982 {
983 ifp = if_lookup_by_name (argv[0]);
508e53e2 984 if (ifp == NULL)
718e3744 985 {
986 vty_out (vty, "No such Interface: %s%s", argv[0],
049207c3 987 VNL);
718e3744 988 return CMD_WARNING;
989 }
990 ospf6_interface_show (vty, ifp);
991 }
992 else
993 {
1eb8ef25 994 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
995 ospf6_interface_show (vty, ifp);
718e3744 996 }
508e53e2 997
718e3744 998 return CMD_SUCCESS;
999}
1000
1001ALIAS (show_ipv6_ospf6_interface,
1002 show_ipv6_ospf6_interface_cmd,
1003 "show ipv6 ospf6 interface",
1004 SHOW_STR
1005 IP6_STR
1006 OSPF6_STR
1007 INTERFACE_STR
6ac29a51 1008 )
508e53e2 1009
1010DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
1011 show_ipv6_ospf6_interface_ifname_prefix_cmd,
1012 "show ipv6 ospf6 interface IFNAME prefix",
1013 SHOW_STR
1014 IP6_STR
1015 OSPF6_STR
1016 INTERFACE_STR
1017 IFNAME_STR
1018 "Display connected prefixes to advertise\n"
718e3744 1019 )
508e53e2 1020{
1021 struct interface *ifp;
1022 struct ospf6_interface *oi;
1023
1024 ifp = if_lookup_by_name (argv[0]);
1025 if (ifp == NULL)
1026 {
049207c3 1027 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
508e53e2 1028 return CMD_WARNING;
1029 }
1030
1031 oi = ifp->info;
1032 if (oi == NULL)
1033 {
049207c3 1034 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
508e53e2 1035 return CMD_WARNING;
1036 }
1037
1038 argc--;
1039 argv++;
1040 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1041
1042 return CMD_SUCCESS;
1043}
1044
1045ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1046 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
1047 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1048 SHOW_STR
1049 IP6_STR
1050 OSPF6_STR
1051 INTERFACE_STR
1052 IFNAME_STR
1053 "Display connected prefixes to advertise\n"
1054 OSPF6_ROUTE_ADDRESS_STR
1055 OSPF6_ROUTE_PREFIX_STR
ea402198 1056 "Display details of the prefixes\n"
6ac29a51 1057 )
508e53e2 1058
1059ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1060 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
1061 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1062 SHOW_STR
1063 IP6_STR
1064 OSPF6_STR
1065 INTERFACE_STR
1066 IFNAME_STR
1067 "Display connected prefixes to advertise\n"
1068 OSPF6_ROUTE_PREFIX_STR
1069 OSPF6_ROUTE_MATCH_STR
ea402198 1070 "Display details of the prefixes\n"
6ac29a51 1071 )
508e53e2 1072
1073DEFUN (show_ipv6_ospf6_interface_prefix,
1074 show_ipv6_ospf6_interface_prefix_cmd,
1075 "show ipv6 ospf6 interface prefix",
1076 SHOW_STR
1077 IP6_STR
1078 OSPF6_STR
1079 INTERFACE_STR
1080 "Display connected prefixes to advertise\n"
1081 )
1082{
52dc7ee6 1083 struct listnode *i;
508e53e2 1084 struct ospf6_interface *oi;
1085 struct interface *ifp;
1086
1eb8ef25 1087 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
508e53e2 1088 {
508e53e2 1089 oi = (struct ospf6_interface *) ifp->info;
1090 if (oi == NULL)
1091 continue;
1092
1093 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1094 }
1095
1096 return CMD_SUCCESS;
1097}
1098
1099ALIAS (show_ipv6_ospf6_interface_prefix,
1100 show_ipv6_ospf6_interface_prefix_detail_cmd,
1101 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1102 SHOW_STR
1103 IP6_STR
1104 OSPF6_STR
1105 INTERFACE_STR
1106 "Display connected prefixes to advertise\n"
1107 OSPF6_ROUTE_ADDRESS_STR
1108 OSPF6_ROUTE_PREFIX_STR
ea402198 1109 "Display details of the prefixes\n"
6ac29a51 1110 )
508e53e2 1111
1112ALIAS (show_ipv6_ospf6_interface_prefix,
1113 show_ipv6_ospf6_interface_prefix_match_cmd,
1114 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1115 SHOW_STR
1116 IP6_STR
1117 OSPF6_STR
1118 INTERFACE_STR
1119 "Display connected prefixes to advertise\n"
1120 OSPF6_ROUTE_PREFIX_STR
1121 OSPF6_ROUTE_MATCH_STR
ea402198 1122 "Display details of the prefixes\n"
6ac29a51 1123 )
508e53e2 1124
718e3744 1125
1126/* interface variable set command */
b596c71e 1127DEFUN (ipv6_ospf6_ifmtu,
1128 ipv6_ospf6_ifmtu_cmd,
1129 "ipv6 ospf6 ifmtu <1-65535>",
1130 IP6_STR
1131 OSPF6_STR
1132 "Interface MTU\n"
1133 "OSPFv3 Interface MTU\n"
1134 )
1135{
1136 struct ospf6_interface *oi;
1137 struct interface *ifp;
0c083ee9 1138 unsigned int ifmtu, iobuflen;
1eb8ef25 1139 struct listnode *node, *nnode;
b596c71e 1140 struct ospf6_neighbor *on;
1141
1142 ifp = (struct interface *) vty->index;
1143 assert (ifp);
1144
1145 oi = (struct ospf6_interface *) ifp->info;
1146 if (oi == NULL)
1147 oi = ospf6_interface_create (ifp);
1148 assert (oi);
1149
1150 ifmtu = strtol (argv[0], NULL, 10);
1151
1152 if (oi->ifmtu == ifmtu)
1153 return CMD_SUCCESS;
1154
1203e1c0 1155 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
b596c71e 1156 {
1157 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
049207c3 1158 ifp->name, ifp->mtu6, VNL);
b596c71e 1159 return CMD_WARNING;
1160 }
1161
1162 if (oi->ifmtu < ifmtu)
1163 {
1164 iobuflen = ospf6_iobuf_size (ifmtu);
1165 if (iobuflen < ifmtu)
1166 {
1167 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
049207c3 1168 ifp->name, iobuflen, VNL);
b596c71e 1169 oi->ifmtu = iobuflen;
1170 }
1171 else
1172 oi->ifmtu = ifmtu;
1173 }
1174 else
1175 oi->ifmtu = ifmtu;
1176
1177 /* re-establish adjacencies */
1eb8ef25 1178 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
b596c71e 1179 {
b596c71e 1180 THREAD_OFF (on->inactivity_timer);
3e834b12 1181 thread_add_event (master, inactivity_timer, on, 0);
b596c71e 1182 }
1183
1184 return CMD_SUCCESS;
1185}
1186
049207c3 1187DEFUN (no_ipv6_ospf6_ifmtu,
1188 no_ipv6_ospf6_ifmtu_cmd,
1189 "no ipv6 ospf6 ifmtu",
1190 NO_STR
1191 IP6_STR
1192 OSPF6_STR
1193 "Interface MTU\n"
1194 )
1195{
1196 struct ospf6_interface *oi;
1197 struct interface *ifp;
0c083ee9 1198 unsigned int iobuflen;
1eb8ef25 1199 struct listnode *node, *nnode;
049207c3 1200 struct ospf6_neighbor *on;
1201
1202 ifp = (struct interface *) vty->index;
1203 assert (ifp);
1204
1205 oi = (struct ospf6_interface *) ifp->info;
1206 if (oi == NULL)
1207 oi = ospf6_interface_create (ifp);
1208 assert (oi);
1209
1210 if (oi->ifmtu < ifp->mtu)
1211 {
1212 iobuflen = ospf6_iobuf_size (ifp->mtu);
1213 if (iobuflen < ifp->mtu)
1214 {
1215 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1216 ifp->name, iobuflen, VNL);
1217 oi->ifmtu = iobuflen;
1218 }
1219 else
1220 oi->ifmtu = ifp->mtu;
1221 }
1222 else
1223 oi->ifmtu = ifp->mtu;
1224
1225 /* re-establish adjacencies */
1eb8ef25 1226 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
049207c3 1227 {
049207c3 1228 THREAD_OFF (on->inactivity_timer);
3e834b12 1229 thread_add_event (master, inactivity_timer, on, 0);
049207c3 1230 }
1231
1232 return CMD_SUCCESS;
1233}
1234
718e3744 1235DEFUN (ipv6_ospf6_cost,
1236 ipv6_ospf6_cost_cmd,
508e53e2 1237 "ipv6 ospf6 cost <1-65535>",
718e3744 1238 IP6_STR
1239 OSPF6_STR
1240 "Interface cost\n"
508e53e2 1241 "Outgoing metric of this interface\n"
718e3744 1242 )
1243{
508e53e2 1244 struct ospf6_interface *oi;
718e3744 1245 struct interface *ifp;
0c083ee9 1246 unsigned long int lcost;
718e3744 1247
508e53e2 1248 ifp = (struct interface *) vty->index;
718e3744 1249 assert (ifp);
1250
508e53e2 1251 oi = (struct ospf6_interface *) ifp->info;
1252 if (oi == NULL)
1253 oi = ospf6_interface_create (ifp);
1254 assert (oi);
718e3744 1255
0c083ee9 1256 lcost = strtol (argv[0], NULL, 10);
718e3744 1257
0c083ee9 1258 if (lcost > UINT32_MAX)
1259 {
1260 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1261 return CMD_WARNING;
1262 }
1263
1264 if (oi->cost == lcost)
1265 return CMD_SUCCESS;
1266
1267 oi->cost = lcost;
c19543b2 1268 SET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
718e3744 1269
c19543b2
VB
1270 ospf6_interface_recalculate_cost(oi);
1271
1272 return CMD_SUCCESS;
1273}
1274
1275DEFUN (no_ipv6_ospf6_cost,
1276 no_ipv6_ospf6_cost_cmd,
1277 "no ipv6 ospf6 cost",
1278 NO_STR
1279 IP6_STR
1280 OSPF6_STR
1281 "Calculate interface cost from bandwidth\n"
1282 )
1283{
1284 struct ospf6_interface *oi;
1285 struct interface *ifp;
1286 unsigned long int lcost;
1287
1288 ifp = (struct interface *) vty->index;
1289 assert (ifp);
1290
1291 oi = (struct ospf6_interface *) ifp->info;
1292 if (oi == NULL)
1293 oi = ospf6_interface_create (ifp);
1294 assert (oi);
1295
1296 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1297
1298 ospf6_interface_recalculate_cost(oi);
718e3744 1299
1300 return CMD_SUCCESS;
1301}
1302
fd500689
VB
1303DEFUN (auto_cost_reference_bandwidth,
1304 auto_cost_reference_bandwidth_cmd,
1305 "auto-cost reference-bandwidth <1-4294967>",
1306 "Calculate OSPF interface cost according to bandwidth\n"
1307 "Use reference bandwidth method to assign OSPF cost\n"
1308 "The reference bandwidth in terms of Mbits per second\n")
1309{
1310 struct ospf6 *o = vty->index;
1311 struct ospf6_area *oa;
1312 struct ospf6_interface *oi;
1313 struct listnode *i, *j;
1314 u_int32_t refbw;
1315
1316 refbw = strtol (argv[0], NULL, 10);
1317 if (refbw < 1 || refbw > 4294967)
1318 {
1319 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
1320 return CMD_WARNING;
1321 }
1322
1323 /* If reference bandwidth is changed. */
1324 if ((refbw * 1000) == o->ref_bandwidth)
1325 return CMD_SUCCESS;
1326
1327 o->ref_bandwidth = refbw * 1000;
1328 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1329 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1330 ospf6_interface_recalculate_cost (oi);
1331
1332 return CMD_SUCCESS;
1333}
1334
1335DEFUN (no_auto_cost_reference_bandwidth,
1336 no_auto_cost_reference_bandwidth_cmd,
1337 "no auto-cost reference-bandwidth",
1338 NO_STR
1339 "Calculate OSPF interface cost according to bandwidth\n"
1340 "Use reference bandwidth method to assign OSPF cost\n")
1341{
1342 struct ospf6 *o = vty->index;
1343 struct ospf6_area *oa;
1344 struct ospf6_interface *oi;
1345 struct listnode *i, *j;
1346
1347 if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
1348 return CMD_SUCCESS;
1349
1350 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
1351 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1352 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1353 ospf6_interface_recalculate_cost (oi);
1354
1355 return CMD_SUCCESS;
1356}
1357
718e3744 1358DEFUN (ipv6_ospf6_hellointerval,
1359 ipv6_ospf6_hellointerval_cmd,
508e53e2 1360 "ipv6 ospf6 hello-interval <1-65535>",
718e3744 1361 IP6_STR
1362 OSPF6_STR
508e53e2 1363 "Interval time of Hello packets\n"
718e3744 1364 SECONDS_STR
1365 )
1366{
508e53e2 1367 struct ospf6_interface *oi;
718e3744 1368 struct interface *ifp;
1369
1370 ifp = (struct interface *) vty->index;
1371 assert (ifp);
718e3744 1372
508e53e2 1373 oi = (struct ospf6_interface *) ifp->info;
1374 if (oi == NULL)
1375 oi = ospf6_interface_create (ifp);
1376 assert (oi);
1377
1378 oi->hello_interval = strtol (argv[0], NULL, 10);
718e3744 1379 return CMD_SUCCESS;
1380}
1381
1382/* interface variable set command */
1383DEFUN (ipv6_ospf6_deadinterval,
1384 ipv6_ospf6_deadinterval_cmd,
508e53e2 1385 "ipv6 ospf6 dead-interval <1-65535>",
718e3744 1386 IP6_STR
1387 OSPF6_STR
508e53e2 1388 "Interval time after which a neighbor is declared down\n"
718e3744 1389 SECONDS_STR
1390 )
1391{
508e53e2 1392 struct ospf6_interface *oi;
718e3744 1393 struct interface *ifp;
1394
1395 ifp = (struct interface *) vty->index;
1396 assert (ifp);
718e3744 1397
508e53e2 1398 oi = (struct ospf6_interface *) ifp->info;
1399 if (oi == NULL)
1400 oi = ospf6_interface_create (ifp);
1401 assert (oi);
1402
1403 oi->dead_interval = strtol (argv[0], NULL, 10);
718e3744 1404 return CMD_SUCCESS;
1405}
1406
1407/* interface variable set command */
1408DEFUN (ipv6_ospf6_transmitdelay,
1409 ipv6_ospf6_transmitdelay_cmd,
508e53e2 1410 "ipv6 ospf6 transmit-delay <1-3600>",
718e3744 1411 IP6_STR
1412 OSPF6_STR
508e53e2 1413 "Transmit delay of this interface\n"
718e3744 1414 SECONDS_STR
1415 )
1416{
508e53e2 1417 struct ospf6_interface *oi;
718e3744 1418 struct interface *ifp;
1419
1420 ifp = (struct interface *) vty->index;
1421 assert (ifp);
718e3744 1422
508e53e2 1423 oi = (struct ospf6_interface *) ifp->info;
1424 if (oi == NULL)
1425 oi = ospf6_interface_create (ifp);
1426 assert (oi);
1427
1428 oi->transdelay = strtol (argv[0], NULL, 10);
718e3744 1429 return CMD_SUCCESS;
1430}
1431
1432/* interface variable set command */
1433DEFUN (ipv6_ospf6_retransmitinterval,
1434 ipv6_ospf6_retransmitinterval_cmd,
508e53e2 1435 "ipv6 ospf6 retransmit-interval <1-65535>",
718e3744 1436 IP6_STR
1437 OSPF6_STR
1438 "Time between retransmitting lost link state advertisements\n"
1439 SECONDS_STR
1440 )
1441{
508e53e2 1442 struct ospf6_interface *oi;
718e3744 1443 struct interface *ifp;
1444
1445 ifp = (struct interface *) vty->index;
1446 assert (ifp);
718e3744 1447
508e53e2 1448 oi = (struct ospf6_interface *) ifp->info;
1449 if (oi == NULL)
1450 oi = ospf6_interface_create (ifp);
1451 assert (oi);
1452
1453 oi->rxmt_interval = strtol (argv[0], NULL, 10);
718e3744 1454 return CMD_SUCCESS;
1455}
1456
1457/* interface variable set command */
1458DEFUN (ipv6_ospf6_priority,
1459 ipv6_ospf6_priority_cmd,
508e53e2 1460 "ipv6 ospf6 priority <0-255>",
718e3744 1461 IP6_STR
1462 OSPF6_STR
1463 "Router priority\n"
508e53e2 1464 "Priority value\n"
718e3744 1465 )
1466{
508e53e2 1467 struct ospf6_interface *oi;
718e3744 1468 struct interface *ifp;
1469
1470 ifp = (struct interface *) vty->index;
1471 assert (ifp);
718e3744 1472
508e53e2 1473 oi = (struct ospf6_interface *) ifp->info;
1474 if (oi == NULL)
1475 oi = ospf6_interface_create (ifp);
1476 assert (oi);
1477
1478 oi->priority = strtol (argv[0], NULL, 10);
718e3744 1479
7d4aa1d5
CF
1480 if (oi->area &&
1481 (oi->state == OSPF6_INTERFACE_DROTHER ||
1482 oi->state == OSPF6_INTERFACE_BDR ||
1483 oi->state == OSPF6_INTERFACE_DR))
508e53e2 1484 ospf6_interface_state_change (dr_election (oi), oi);
718e3744 1485
1486 return CMD_SUCCESS;
1487}
1488
1489DEFUN (ipv6_ospf6_instance,
1490 ipv6_ospf6_instance_cmd,
508e53e2 1491 "ipv6 ospf6 instance-id <0-255>",
718e3744 1492 IP6_STR
1493 OSPF6_STR
508e53e2 1494 "Instance ID for this interface\n"
1495 "Instance ID value\n"
718e3744 1496 )
1497{
508e53e2 1498 struct ospf6_interface *oi;
718e3744 1499 struct interface *ifp;
1500
1501 ifp = (struct interface *)vty->index;
1502 assert (ifp);
1503
508e53e2 1504 oi = (struct ospf6_interface *)ifp->info;
1505 if (oi == NULL)
1506 oi = ospf6_interface_create (ifp);
1507 assert (oi);
718e3744 1508
508e53e2 1509 oi->instance_id = strtol (argv[0], NULL, 10);
718e3744 1510 return CMD_SUCCESS;
1511}
1512
1513DEFUN (ipv6_ospf6_passive,
1514 ipv6_ospf6_passive_cmd,
1515 "ipv6 ospf6 passive",
1516 IP6_STR
1517 OSPF6_STR
508e53e2 1518 "passive interface, No adjacency will be formed on this interface\n"
718e3744 1519 )
1520{
508e53e2 1521 struct ospf6_interface *oi;
718e3744 1522 struct interface *ifp;
1eb8ef25 1523 struct listnode *node, *nnode;
508e53e2 1524 struct ospf6_neighbor *on;
718e3744 1525
1526 ifp = (struct interface *) vty->index;
1527 assert (ifp);
718e3744 1528
508e53e2 1529 oi = (struct ospf6_interface *) ifp->info;
1530 if (oi == NULL)
1531 oi = ospf6_interface_create (ifp);
1532 assert (oi);
718e3744 1533
508e53e2 1534 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1535 THREAD_OFF (oi->thread_send_hello);
1536
1eb8ef25 1537 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
718e3744 1538 {
508e53e2 1539 THREAD_OFF (on->inactivity_timer);
3e834b12 1540 thread_add_event (master, inactivity_timer, on, 0);
718e3744 1541 }
1542
1543 return CMD_SUCCESS;
1544}
1545
1546DEFUN (no_ipv6_ospf6_passive,
1547 no_ipv6_ospf6_passive_cmd,
1548 "no ipv6 ospf6 passive",
1549 NO_STR
1550 IP6_STR
1551 OSPF6_STR
1552 "passive interface: No Adjacency will be formed on this I/F\n"
1553 )
1554{
508e53e2 1555 struct ospf6_interface *oi;
718e3744 1556 struct interface *ifp;
1557
1558 ifp = (struct interface *) vty->index;
1559 assert (ifp);
718e3744 1560
508e53e2 1561 oi = (struct ospf6_interface *) ifp->info;
1562 if (oi == NULL)
1563 oi = ospf6_interface_create (ifp);
1564 assert (oi);
718e3744 1565
508e53e2 1566 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1567 THREAD_OFF (oi->thread_send_hello);
1568 oi->thread_send_hello =
1569 thread_add_event (master, ospf6_hello_send, oi, 0);
718e3744 1570
1571 return CMD_SUCCESS;
1572}
1573
d42306d9
DT
1574DEFUN (ipv6_ospf6_mtu_ignore,
1575 ipv6_ospf6_mtu_ignore_cmd,
1576 "ipv6 ospf6 mtu-ignore",
1577 IP6_STR
1578 OSPF6_STR
1579 "Ignore MTU mismatch on this interface\n"
1580 )
1581{
1582 struct ospf6_interface *oi;
1583 struct interface *ifp;
1584
1585 ifp = (struct interface *) vty->index;
1586 assert (ifp);
1587
1588 oi = (struct ospf6_interface *) ifp->info;
1589 if (oi == NULL)
1590 oi = ospf6_interface_create (ifp);
1591 assert (oi);
1592
1593 oi->mtu_ignore = 1;
1594
1595 return CMD_SUCCESS;
1596}
1597
1598DEFUN (no_ipv6_ospf6_mtu_ignore,
1599 no_ipv6_ospf6_mtu_ignore_cmd,
1600 "no ipv6 ospf6 mtu-ignore",
1601 NO_STR
1602 IP6_STR
1603 OSPF6_STR
1604 "Ignore MTU mismatch on this interface\n"
1605 )
1606{
1607 struct ospf6_interface *oi;
1608 struct interface *ifp;
1609
1610 ifp = (struct interface *) vty->index;
1611 assert (ifp);
1612
1613 oi = (struct ospf6_interface *) ifp->info;
1614 if (oi == NULL)
1615 oi = ospf6_interface_create (ifp);
1616 assert (oi);
1617
1618 oi->mtu_ignore = 0;
1619
1620 return CMD_SUCCESS;
1621}
1622
718e3744 1623DEFUN (ipv6_ospf6_advertise_prefix_list,
1624 ipv6_ospf6_advertise_prefix_list_cmd,
1625 "ipv6 ospf6 advertise prefix-list WORD",
1626 IP6_STR
1627 OSPF6_STR
1628 "Advertising options\n"
1629 "Filter prefix using prefix-list\n"
1630 "Prefix list name\n"
1631 )
1632{
508e53e2 1633 struct ospf6_interface *oi;
718e3744 1634 struct interface *ifp;
1635
1636 ifp = (struct interface *) vty->index;
1637 assert (ifp);
718e3744 1638
508e53e2 1639 oi = (struct ospf6_interface *) ifp->info;
1640 if (oi == NULL)
1641 oi = ospf6_interface_create (ifp);
1642 assert (oi);
718e3744 1643
508e53e2 1644 if (oi->plist_name)
1645 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1646 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
718e3744 1647
508e53e2 1648 ospf6_interface_connected_route_update (oi->interface);
2470e99e
DW
1649
1650 if (oi->area)
508e53e2 1651 {
2470e99e
DW
1652 OSPF6_LINK_LSA_SCHEDULE (oi);
1653 if (oi->state == OSPF6_INTERFACE_DR)
1654 {
1655 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1656 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1657 }
1658 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
508e53e2 1659 }
718e3744 1660
1661 return CMD_SUCCESS;
1662}
1663
1664DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1665 no_ipv6_ospf6_advertise_prefix_list_cmd,
1666 "no ipv6 ospf6 advertise prefix-list",
1667 NO_STR
1668 IP6_STR
1669 OSPF6_STR
1670 "Advertising options\n"
1671 "Filter prefix using prefix-list\n"
1672 )
1673{
508e53e2 1674 struct ospf6_interface *oi;
718e3744 1675 struct interface *ifp;
1676
1677 ifp = (struct interface *) vty->index;
1678 assert (ifp);
718e3744 1679
508e53e2 1680 oi = (struct ospf6_interface *) ifp->info;
1681 if (oi == NULL)
1682 oi = ospf6_interface_create (ifp);
1683 assert (oi);
1684
1685 if (oi->plist_name)
718e3744 1686 {
508e53e2 1687 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1688 oi->plist_name = NULL;
718e3744 1689 }
1690
508e53e2 1691 ospf6_interface_connected_route_update (oi->interface);
2470e99e
DW
1692
1693 if (oi->area)
508e53e2 1694 {
2470e99e
DW
1695 OSPF6_LINK_LSA_SCHEDULE (oi);
1696 if (oi->state == OSPF6_INTERFACE_DR)
1697 {
1698 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1699 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1700 }
1701 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
508e53e2 1702 }
718e3744 1703
1704 return CMD_SUCCESS;
1705}
1706
c5926a92
DD
1707DEFUN (ipv6_ospf6_network,
1708 ipv6_ospf6_network_cmd,
1709 "ipv6 ospf6 network (broadcast|point-to-point)",
1710 IP6_STR
1711 OSPF6_STR
1712 "Network Type\n"
1713 "Specify OSPFv6 broadcast network\n"
1714 "Specify OSPF6 point-to-point network\n"
1715 )
1716{
1717 struct ospf6_interface *oi;
1718 struct interface *ifp;
1719
1720 ifp = (struct interface *) vty->index;
1721 assert (ifp);
1722
1723 oi = (struct ospf6_interface *) ifp->info;
1724 if (oi == NULL) {
1725 oi = ospf6_interface_create (ifp);
1726 }
1727 assert (oi);
1728
1729 if (strncmp (argv[0], "b", 1) == 0)
1730 {
1731 if (oi->type == OSPF_IFTYPE_BROADCAST)
1732 return CMD_SUCCESS;
1733
1734 oi->type = OSPF_IFTYPE_BROADCAST;
1735 }
1736 else if (strncmp (argv[0], "point-to-p", 10) == 0)
1737 {
1738 if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
1739 return CMD_SUCCESS;
1740 }
1741 oi->type = OSPF_IFTYPE_POINTOPOINT;
1742 }
1743
1744 /* Reset the interface */
1745 thread_add_event (master, interface_down, oi, 0);
1746 thread_add_event (master, interface_up, oi, 0);
1747
1748 return CMD_SUCCESS;
1749}
1750
1751DEFUN (no_ipv6_ospf6_network,
1752 no_ipv6_ospf6_network_cmd,
1753 "no ipv6 ospf6 network",
1754 NO_STR
1755 IP6_STR
1756 OSPF6_STR
1757 "Network Type\n"
1758 "Default to whatever interface type system specifies"
1759 )
1760{
1761 struct ospf6_interface *oi;
1762 struct interface *ifp;
1763 int type;
1764
1765 ifp = (struct interface *) vty->index;
1766 assert (ifp);
1767
1768 oi = (struct ospf6_interface *) ifp->info;
1769 if (oi == NULL) {
1770 return CMD_SUCCESS;
1771 }
1772
1773 type = ospf6_default_iftype (ifp);
1774 if (oi->type == type)
1775 {
1776 return CMD_SUCCESS;
1777 }
1778 oi->type = type;
1779
1780 /* Reset the interface */
1781 thread_add_event (master, interface_down, oi, 0);
1782 thread_add_event (master, interface_up, oi, 0);
1783
1784 return CMD_SUCCESS;
1785}
1786
6ac29a51 1787static int
508e53e2 1788config_write_ospf6_interface (struct vty *vty)
718e3744 1789{
52dc7ee6 1790 struct listnode *i;
508e53e2 1791 struct ospf6_interface *oi;
718e3744 1792 struct interface *ifp;
1793
1eb8ef25 1794 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
718e3744 1795 {
508e53e2 1796 oi = (struct ospf6_interface *) ifp->info;
1797 if (oi == NULL)
718e3744 1798 continue;
1799
1800 vty_out (vty, "interface %s%s",
049207c3 1801 oi->interface->name, VNL);
508e53e2 1802
1803 if (ifp->desc)
049207c3 1804 vty_out (vty, " description %s%s", ifp->desc, VNL);
1203e1c0 1805 if (ifp->mtu6 != oi->ifmtu)
049207c3 1806 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
b51a3a31 1807
c19543b2 1808 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
b51a3a31
VT
1809 vty_out (vty, " ipv6 ospf6 cost %d%s",
1810 oi->cost, VNL);
1811
1812 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1813 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1814 oi->hello_interval, VNL);
1815
1816 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1817 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1818 oi->dead_interval, VNL);
1819
1820 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1821 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1822 oi->rxmt_interval, VNL);
1823
1824 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1825 vty_out (vty, " ipv6 ospf6 priority %d%s",
1826 oi->priority, VNL);
1827
1828 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1829 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1830 oi->transdelay, VNL);
1831
1832 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1833 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1834 oi->instance_id, VNL);
718e3744 1835
508e53e2 1836 if (oi->plist_name)
718e3744 1837 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
049207c3 1838 oi->plist_name, VNL);
718e3744 1839
508e53e2 1840 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
049207c3 1841 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
718e3744 1842
d42306d9
DT
1843 if (oi->mtu_ignore)
1844 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1845
c5926a92
DD
1846 if (oi->type == OSPF_IFTYPE_POINTOPOINT)
1847 vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
1848 else if (oi->type == OSPF_IFTYPE_BROADCAST)
1849 vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
1850
049207c3 1851 vty_out (vty, "!%s", VNL);
718e3744 1852 }
1853 return 0;
1854}
1855
7fc626de 1856static struct cmd_node interface_node =
718e3744 1857{
1858 INTERFACE_NODE,
1859 "%s(config-if)# ",
69b4a810 1860 1 /* VTYSH */
718e3744 1861};
1862
1863void
6ac29a51 1864ospf6_interface_init (void)
718e3744 1865{
1866 /* Install interface node. */
508e53e2 1867 install_node (&interface_node, config_write_ospf6_interface);
718e3744 1868
1869 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
508e53e2 1870 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1871 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1872 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
718e3744 1873 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
508e53e2 1874 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1875 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1876 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
718e3744 1877 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
508e53e2 1878 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1879 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1880 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
718e3744 1881 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
508e53e2 1882 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1883 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1884 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
718e3744 1885
508e53e2 1886 install_element (CONFIG_NODE, &interface_cmd);
718e3744 1887 install_default (INTERFACE_NODE);
1888 install_element (INTERFACE_NODE, &interface_desc_cmd);
1889 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1890 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
c19543b2 1891 install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
b596c71e 1892 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
049207c3 1893 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
718e3744 1894 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1895 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1896 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1897 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1898 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1899 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
508e53e2 1900
718e3744 1901 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1902 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
508e53e2 1903
d42306d9
DT
1904 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1905 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1906
508e53e2 1907 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1908 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
c5926a92
DD
1909
1910 install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
1911 install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
fd500689
VB
1912
1913 /* reference bandwidth commands */
1914 install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
1915 install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
508e53e2 1916}
1917
1918DEFUN (debug_ospf6_interface,
1919 debug_ospf6_interface_cmd,
1920 "debug ospf6 interface",
1921 DEBUG_STR
1922 OSPF6_STR
1923 "Debug OSPFv3 Interface\n"
1924 )
1925{
1926 OSPF6_DEBUG_INTERFACE_ON ();
1927 return CMD_SUCCESS;
1928}
1929
1930DEFUN (no_debug_ospf6_interface,
1931 no_debug_ospf6_interface_cmd,
1932 "no debug ospf6 interface",
1933 NO_STR
1934 DEBUG_STR
1935 OSPF6_STR
1936 "Debug OSPFv3 Interface\n"
1937 )
1938{
3b68735f 1939 OSPF6_DEBUG_INTERFACE_OFF ();
508e53e2 1940 return CMD_SUCCESS;
1941}
1942
1943int
1944config_write_ospf6_debug_interface (struct vty *vty)
1945{
1946 if (IS_OSPF6_DEBUG_INTERFACE)
049207c3 1947 vty_out (vty, "debug ospf6 interface%s", VNL);
508e53e2 1948 return 0;
1949}
1950
1951void
6ac29a51 1952install_element_ospf6_debug_interface (void)
508e53e2 1953{
1954 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1955 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1956 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1957 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
718e3744 1958}
1959
1960