blob: 26f68ac546162186953152a6740d7147a7bc17d3 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
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
hasso508e53e2004-05-18 18:57:06 +000022#include <zebra.h>
paul718e3742002-12-13 20:15:29 +000023
hasso508e53e2004-05-18 18:57:06 +000024#include "memory.h"
paul718e3742002-12-13 20:15:29 +000025#include "if.h"
26#include "log.h"
27#include "command.h"
hasso508e53e2004-05-18 18:57:06 +000028#include "thread.h"
29#include "prefix.h"
30#include "plist.h"
paul718e3742002-12-13 20:15:29 +000031
hasso508e53e2004-05-18 18:57:06 +000032#include "ospf6_lsa.h"
paul718e3742002-12-13 20:15:29 +000033#include "ospf6_lsdb.h"
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_network.h"
35#include "ospf6_message.h"
36#include "ospf6_route.h"
paul718e3742002-12-13 20:15:29 +000037#include "ospf6_top.h"
38#include "ospf6_area.h"
39#include "ospf6_interface.h"
hasso508e53e2004-05-18 18:57:06 +000040#include "ospf6_neighbor.h"
41#include "ospf6_intra.h"
42#include "ospf6_spf.h"
David Lamparter388f8852015-03-03 08:55:54 +010043#include "ospf6_snmp.h"
hasso049207c2004-08-04 20:02:13 +000044#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000045
hasso508e53e2004-05-18 18:57:06 +000046unsigned char conf_debug_ospf6_interface = 0;
47
paul0c083ee2004-10-10 12:54:58 +000048const char *ospf6_interface_state_str[] =
paul718e3742002-12-13 20:15:29 +000049{
hasso508e53e2004-05-18 18:57:06 +000050 "None",
51 "Down",
52 "Loopback",
53 "Waiting",
54 "PointToPoint",
55 "DROther",
56 "BDR",
57 "DR",
58 NULL
paul718e3742002-12-13 20:15:29 +000059};
60
hasso508e53e2004-05-18 18:57:06 +000061struct ospf6_interface *
Paul Jakma9099f9b2016-01-18 10:12:10 +000062ospf6_interface_lookup_by_ifindex (ifindex_t ifindex)
paul718e3742002-12-13 20:15:29 +000063{
hasso508e53e2004-05-18 18:57:06 +000064 struct ospf6_interface *oi;
65 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +000066
hasso508e53e2004-05-18 18:57:06 +000067 ifp = if_lookup_by_index (ifindex);
68 if (ifp == NULL)
69 return (struct ospf6_interface *) NULL;
70
71 oi = (struct ospf6_interface *) ifp->info;
72 return oi;
paul718e3742002-12-13 20:15:29 +000073}
74
hasso508e53e2004-05-18 18:57:06 +000075/* schedule routing table recalculation */
Paul Jakma6ac29a52008-08-15 13:45:30 +010076static void
Dinesh Dutta0edf672013-08-26 03:40:23 +000077ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa, unsigned int reason)
paul718e3742002-12-13 20:15:29 +000078{
Dinesh Dutt3810e062013-08-24 07:54:09 +000079 struct ospf6_interface *oi;
80
81 if (lsa == NULL)
82 return;
83
84 oi = lsa->lsdb->data;
hasso508e53e2004-05-18 18:57:06 +000085 switch (ntohs (lsa->header->type))
86 {
87 case OSPF6_LSTYPE_LINK:
Dinesh Dutt3810e062013-08-24 07:54:09 +000088 if (oi->state == OSPF6_INTERFACE_DR)
89 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
Dinesh Dutta0edf672013-08-26 03:40:23 +000090 ospf6_spf_schedule (oi->area->ospf6, reason);
hasso508e53e2004-05-18 18:57:06 +000091 break;
paul718e3742002-12-13 20:15:29 +000092
hasso508e53e2004-05-18 18:57:06 +000093 default:
hasso508e53e2004-05-18 18:57:06 +000094 break;
95 }
paul718e3742002-12-13 20:15:29 +000096}
97
Dinesh Dutta0edf672013-08-26 03:40:23 +000098static void
99ospf6_interface_lsdb_hook_add (struct ospf6_lsa *lsa)
100{
101 ospf6_interface_lsdb_hook(lsa, ospf6_lsadd_to_spf_reason(lsa));
102}
103
104static void
105ospf6_interface_lsdb_hook_remove (struct ospf6_lsa *lsa)
106{
107 ospf6_interface_lsdb_hook(lsa, ospf6_lsremove_to_spf_reason(lsa));
108}
109
Dinesh Duttc5926a92013-08-24 07:55:00 +0000110static u_char
111ospf6_default_iftype(struct interface *ifp)
112{
113 if (if_is_pointopoint (ifp))
114 return OSPF_IFTYPE_POINTOPOINT;
115 else if (if_is_loopback (ifp))
116 return OSPF_IFTYPE_LOOPBACK;
117 else
118 return OSPF_IFTYPE_BROADCAST;
119}
120
Vincent Bernatc19543b2012-10-24 14:45:53 +0000121static u_int32_t
122ospf6_interface_get_cost (struct ospf6_interface *oi)
123{
124 /* If all else fails, use default OSPF cost */
125 u_int32_t cost;
126 u_int32_t bw, refbw;
127
128 bw = oi->interface->bandwidth ? oi->interface->bandwidth : OSPF6_INTERFACE_BANDWIDTH;
Vincent Bernatfd500682012-10-24 14:45:54 +0000129 refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
Vincent Bernatc19543b2012-10-24 14:45:53 +0000130
131 /* A specifed ip ospf cost overrides a calculated one. */
132 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
133 cost = oi->cost;
134 else
135 {
136 cost = (u_int32_t) ((double)refbw / (double)bw + (double)0.5);
137 if (cost < 1) cost = 1;
138 else if (cost > UINT32_MAX) cost = UINT32_MAX;
139 }
140
141 return cost;
142}
143
144static void
145ospf6_interface_recalculate_cost (struct ospf6_interface *oi)
146{
147 u_int32_t newcost;
148
149 newcost = ospf6_interface_get_cost (oi);
150 if (newcost == oi->cost) return;
151 oi->cost = newcost;
152
153 /* update cost held in route_connected list in ospf6_interface */
154 ospf6_interface_connected_route_update (oi->interface);
155
156 /* execute LSA hooks */
157 if (oi->area)
158 {
159 OSPF6_LINK_LSA_SCHEDULE (oi);
160 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
161 OSPF6_NETWORK_LSA_SCHEDULE (oi);
162 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
163 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
164 }
165}
166
paul718e3742002-12-13 20:15:29 +0000167/* Create new ospf6 interface structure */
168struct ospf6_interface *
169ospf6_interface_create (struct interface *ifp)
170{
hasso508e53e2004-05-18 18:57:06 +0000171 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000172 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000173
hasso508e53e2004-05-18 18:57:06 +0000174 oi = (struct ospf6_interface *)
Stephen Hemminger393deb92008-08-18 14:13:29 -0700175 XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
paul718e3742002-12-13 20:15:29 +0000176
Stephen Hemminger393deb92008-08-18 14:13:29 -0700177 if (!oi)
paul718e3742002-12-13 20:15:29 +0000178 {
179 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
180 return (struct ospf6_interface *) NULL;
181 }
182
hasso508e53e2004-05-18 18:57:06 +0000183 oi->area = (struct ospf6_area *) NULL;
184 oi->neighbor_list = list_new ();
185 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
186 oi->linklocal_addr = (struct in6_addr *) NULL;
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +0400187 oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
188 oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
189 oi->priority = OSPF6_INTERFACE_PRIORITY;
paul718e3742002-12-13 20:15:29 +0000190
Dinesh Dutt8551e6d2013-10-22 17:42:18 -0700191 oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
192 oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
193 oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
Dinesh Duttc5926a92013-08-24 07:55:00 +0000194 oi->type = ospf6_default_iftype (ifp);
hasso508e53e2004-05-18 18:57:06 +0000195 oi->state = OSPF6_INTERFACE_DOWN;
196 oi->flag = 0;
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400197 oi->mtu_ignore = 0;
paul718e3742002-12-13 20:15:29 +0000198
hassob596c712004-07-09 18:33:43 +0000199 /* Try to adjust I/O buffer size with IfMtu */
hasso1203e1c2004-07-23 21:34:27 +0000200 oi->ifmtu = ifp->mtu6;
201 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000202 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000203 {
hasso1e058382004-09-01 21:36:14 +0000204 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000205 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
206 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000207 oi->ifmtu = iobuflen;
208 }
hasso3b4cd3a2004-05-18 19:28:32 +0000209
hasso6452df02004-08-15 05:52:07 +0000210 oi->lsupdate_list = ospf6_lsdb_create (oi);
211 oi->lsack_list = ospf6_lsdb_create (oi);
212 oi->lsdb = ospf6_lsdb_create (oi);
Dinesh Dutta0edf672013-08-26 03:40:23 +0000213 oi->lsdb->hook_add = ospf6_interface_lsdb_hook_add;
214 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook_remove;
hasso6452df02004-08-15 05:52:07 +0000215 oi->lsdb_self = ospf6_lsdb_create (oi);
paul718e3742002-12-13 20:15:29 +0000216
Paul Jakmacf1ce252006-05-15 10:46:07 +0000217 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
218 oi->route_connected->scope = oi;
paul718e3742002-12-13 20:15:29 +0000219
220 /* link both */
hasso508e53e2004-05-18 18:57:06 +0000221 oi->interface = ifp;
222 ifp->info = oi;
paul718e3742002-12-13 20:15:29 +0000223
Vincent Bernatc19543b2012-10-24 14:45:53 +0000224 /* Compute cost. */
225 oi->cost = ospf6_interface_get_cost(oi);
226
hasso508e53e2004-05-18 18:57:06 +0000227 return oi;
paul718e3742002-12-13 20:15:29 +0000228}
229
230void
hasso508e53e2004-05-18 18:57:06 +0000231ospf6_interface_delete (struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000232{
paul1eb8ef22005-04-07 07:30:20 +0000233 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000234 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000235
paul1eb8ef22005-04-07 07:30:20 +0000236 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000237 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000238
hasso508e53e2004-05-18 18:57:06 +0000239 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000240
hasso508e53e2004-05-18 18:57:06 +0000241 THREAD_OFF (oi->thread_send_hello);
242 THREAD_OFF (oi->thread_send_lsupdate);
243 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000244
hasso508e53e2004-05-18 18:57:06 +0000245 ospf6_lsdb_remove_all (oi->lsdb);
246 ospf6_lsdb_remove_all (oi->lsupdate_list);
247 ospf6_lsdb_remove_all (oi->lsack_list);
248
249 ospf6_lsdb_delete (oi->lsdb);
hasso6452df02004-08-15 05:52:07 +0000250 ospf6_lsdb_delete (oi->lsdb_self);
251
hasso508e53e2004-05-18 18:57:06 +0000252 ospf6_lsdb_delete (oi->lsupdate_list);
253 ospf6_lsdb_delete (oi->lsack_list);
254
255 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000256
257 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000258 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000259
260 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000261 if (oi->plist_name)
262 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000263
hasso508e53e2004-05-18 18:57:06 +0000264 XFREE (MTYPE_OSPF6_IF, oi);
265}
266
267void
268ospf6_interface_enable (struct ospf6_interface *oi)
269{
270 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
Christian Franked9628722013-03-08 21:47:35 +0100271 ospf6_interface_state_update (oi->interface);
hasso508e53e2004-05-18 18:57:06 +0000272}
273
274void
275ospf6_interface_disable (struct ospf6_interface *oi)
276{
hasso508e53e2004-05-18 18:57:06 +0000277 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
278
Christian Franked9628722013-03-08 21:47:35 +0100279 thread_execute (master, interface_down, oi, 0);
hasso508e53e2004-05-18 18:57:06 +0000280
281 ospf6_lsdb_remove_all (oi->lsdb);
Christian Franked9628722013-03-08 21:47:35 +0100282 ospf6_lsdb_remove_all (oi->lsdb_self);
hasso508e53e2004-05-18 18:57:06 +0000283 ospf6_lsdb_remove_all (oi->lsupdate_list);
284 ospf6_lsdb_remove_all (oi->lsack_list);
285
286 THREAD_OFF (oi->thread_send_hello);
287 THREAD_OFF (oi->thread_send_lsupdate);
288 THREAD_OFF (oi->thread_send_lsack);
Christian Franked9628722013-03-08 21:47:35 +0100289
290 THREAD_OFF (oi->thread_network_lsa);
291 THREAD_OFF (oi->thread_link_lsa);
292 THREAD_OFF (oi->thread_intra_prefix_lsa);
paul718e3742002-12-13 20:15:29 +0000293}
294
295static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000296ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000297{
hasso52dc7ee2004-09-23 19:18:23 +0000298 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000299 struct connected *c;
300 struct in6_addr *l = (struct in6_addr *) NULL;
301
302 /* for each connected address */
paul1eb8ef22005-04-07 07:30:20 +0000303 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
paul718e3742002-12-13 20:15:29 +0000304 {
paul718e3742002-12-13 20:15:29 +0000305 /* if family not AF_INET6, ignore */
306 if (c->address->family != AF_INET6)
307 continue;
308
309 /* linklocal scope check */
310 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
311 l = &c->address->u.prefix6;
312 }
313 return l;
314}
315
316void
317ospf6_interface_if_add (struct interface *ifp)
318{
hasso508e53e2004-05-18 18:57:06 +0000319 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000320 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000321
hasso508e53e2004-05-18 18:57:06 +0000322 oi = (struct ospf6_interface *) ifp->info;
323 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000324 return;
325
hassob596c712004-07-09 18:33:43 +0000326 /* Try to adjust I/O buffer size with IfMtu */
327 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000328 oi->ifmtu = ifp->mtu6;
329 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000330 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000331 {
hasso1e058382004-09-01 21:36:14 +0000332 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000333 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
334 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000335 oi->ifmtu = iobuflen;
336 }
paul718e3742002-12-13 20:15:29 +0000337
338 /* interface start */
Christian Frankeb13c1d92012-12-13 16:11:16 +0100339 ospf6_interface_state_update(oi->interface);
paul718e3742002-12-13 20:15:29 +0000340}
341
342void
343ospf6_interface_if_del (struct interface *ifp)
344{
hasso508e53e2004-05-18 18:57:06 +0000345 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000346
hasso508e53e2004-05-18 18:57:06 +0000347 oi = (struct ospf6_interface *) ifp->info;
348 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000349 return;
350
351 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000352 if (oi->area)
353 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000354
hasso508e53e2004-05-18 18:57:06 +0000355 listnode_delete (oi->area->if_list, oi);
356 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000357
358 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000359 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000360 ifp->info = NULL;
361
hasso508e53e2004-05-18 18:57:06 +0000362 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000363}
364
365void
366ospf6_interface_state_update (struct interface *ifp)
367{
hasso508e53e2004-05-18 18:57:06 +0000368 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000369
hasso508e53e2004-05-18 18:57:06 +0000370 oi = (struct ospf6_interface *) ifp->info;
371 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000372 return;
hasso508e53e2004-05-18 18:57:06 +0000373 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000374 return;
Christian Franked9628722013-03-08 21:47:35 +0100375 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
376 return;
paul718e3742002-12-13 20:15:29 +0000377
Christian Frankeb13c1d92012-12-13 16:11:16 +0100378 if (if_is_operative (ifp)
379 && (ospf6_interface_get_linklocal_address(oi->interface)
380 || if_is_loopback(oi->interface)))
hasso508e53e2004-05-18 18:57:06 +0000381 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000382 else
hasso508e53e2004-05-18 18:57:06 +0000383 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000384
385 return;
386}
387
388void
hasso508e53e2004-05-18 18:57:06 +0000389ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000390{
hasso508e53e2004-05-18 18:57:06 +0000391 struct ospf6_interface *oi;
392 struct ospf6_route *route;
393 struct connected *c;
paul1eb8ef22005-04-07 07:30:20 +0000394 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +0000395
hasso508e53e2004-05-18 18:57:06 +0000396 oi = (struct ospf6_interface *) ifp->info;
397 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000398 return;
399
400 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000401 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000402
hasso508e53e2004-05-18 18:57:06 +0000403 /* if area is null, do not make connected-route list */
404 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000405 return;
406
Christian Franked9628722013-03-08 21:47:35 +0100407 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
408 return;
409
hasso508e53e2004-05-18 18:57:06 +0000410 /* update "route to advertise" interface route table */
411 ospf6_route_remove_all (oi->route_connected);
hasso508e53e2004-05-18 18:57:06 +0000412
paul1eb8ef22005-04-07 07:30:20 +0000413 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
414 {
hasso508e53e2004-05-18 18:57:06 +0000415 if (c->address->family != AF_INET6)
416 continue;
417
hasso1e058382004-09-01 21:36:14 +0000418 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
419 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
420 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
421 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
422 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000423
424 /* apply filter */
425 if (oi->plist_name)
426 {
427 struct prefix_list *plist;
428 enum prefix_list_type ret;
429 char buf[128];
430
431 prefix2str (c->address, buf, sizeof (buf));
432 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
433 ret = prefix_list_apply (plist, (void *) c->address);
434 if (ret == PREFIX_DENY)
435 {
hasso1e058382004-09-01 21:36:14 +0000436 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000437 zlog_debug ("%s on %s filtered by prefix-list %s ",
438 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000439 continue;
440 }
441 }
442
443 route = ospf6_route_create ();
444 memcpy (&route->prefix, c->address, sizeof (struct prefix));
445 apply_mask (&route->prefix);
446 route->type = OSPF6_DEST_TYPE_NETWORK;
447 route->path.area_id = oi->area->area_id;
448 route->path.type = OSPF6_PATH_TYPE_INTRA;
449 route->path.cost = oi->cost;
450 route->nexthop[0].ifindex = oi->interface->ifindex;
451 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
452 ospf6_route_add (route, oi->route_connected);
453 }
454
paul718e3742002-12-13 20:15:29 +0000455 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000456 OSPF6_LINK_LSA_SCHEDULE (oi);
457 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
458 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000459}
460
hasso508e53e2004-05-18 18:57:06 +0000461static void
462ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000463{
hasso508e53e2004-05-18 18:57:06 +0000464 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000465
hasso508e53e2004-05-18 18:57:06 +0000466 prev_state = oi->state;
467 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000468
hasso508e53e2004-05-18 18:57:06 +0000469 if (prev_state == next_state)
470 return;
paul718e3742002-12-13 20:15:29 +0000471
hasso508e53e2004-05-18 18:57:06 +0000472 /* log */
473 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000474 {
hassoc6487d62004-12-24 06:00:11 +0000475 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
476 ospf6_interface_state_str[prev_state],
477 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000478 }
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200479 oi->state_change++;
paul718e3742002-12-13 20:15:29 +0000480
hasso508e53e2004-05-18 18:57:06 +0000481 if ((prev_state == OSPF6_INTERFACE_DR ||
482 prev_state == OSPF6_INTERFACE_BDR) &&
483 (next_state != OSPF6_INTERFACE_DR &&
484 next_state != OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400485 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
Dinesh Duttc5926a92013-08-24 07:55:00 +0000486
hasso508e53e2004-05-18 18:57:06 +0000487 if ((prev_state != OSPF6_INTERFACE_DR &&
488 prev_state != OSPF6_INTERFACE_BDR) &&
489 (next_state == OSPF6_INTERFACE_DR ||
490 next_state == OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400491 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
paul718e3742002-12-13 20:15:29 +0000492
hasso508e53e2004-05-18 18:57:06 +0000493 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000494 if (next_state == OSPF6_INTERFACE_DOWN)
495 {
496 OSPF6_NETWORK_LSA_EXECUTE (oi);
497 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
498 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
499 }
500 else if (prev_state == OSPF6_INTERFACE_DR ||
501 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000502 {
hasso508e53e2004-05-18 18:57:06 +0000503 OSPF6_NETWORK_LSA_SCHEDULE (oi);
504 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
505 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000506 }
Vincent Bernatbf836662012-06-04 14:36:12 +0200507
508#ifdef HAVE_SNMP
509 /* Terminal state or regression */
510 if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
511 (next_state == OSPF6_INTERFACE_DROTHER) ||
512 (next_state == OSPF6_INTERFACE_BDR) ||
513 (next_state == OSPF6_INTERFACE_DR) ||
514 (next_state < prev_state))
515 ospf6TrapIfStateChange (oi);
516#endif
517
hasso508e53e2004-05-18 18:57:06 +0000518}
519
David Lamparter6b0655a2014-06-04 06:53:35 +0200520
hasso508e53e2004-05-18 18:57:06 +0000521/* DR Election, RFC2328 section 9.4 */
522
523#define IS_ELIGIBLE(n) \
524 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
525
526static struct ospf6_neighbor *
527better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
528{
529 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
530 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
531 return NULL;
532 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
533 return b;
534 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
535 return a;
536
537 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
538 return a;
539 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
540 return b;
541
542 if (a->priority > b->priority)
543 return a;
544 if (a->priority < b->priority)
545 return b;
546
547 if (ntohl (a->router_id) > ntohl (b->router_id))
548 return a;
549 if (ntohl (a->router_id) < ntohl (b->router_id))
550 return b;
551
552 zlog_warn ("Router-ID duplicate ?");
553 return a;
554}
555
556static struct ospf6_neighbor *
557better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
558{
559 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
560 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
561 return NULL;
562 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
563 return b;
564 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
565 return a;
566
567 if (a->drouter == a->router_id && b->drouter != b->router_id)
568 return a;
569 if (a->drouter != a->router_id && b->drouter == b->router_id)
570 return b;
571
572 if (a->priority > b->priority)
573 return a;
574 if (a->priority < b->priority)
575 return b;
576
577 if (ntohl (a->router_id) > ntohl (b->router_id))
578 return a;
579 if (ntohl (a->router_id) < ntohl (b->router_id))
580 return b;
581
582 zlog_warn ("Router-ID duplicate ?");
583 return a;
584}
585
586static u_char
587dr_election (struct ospf6_interface *oi)
588{
paul1eb8ef22005-04-07 07:30:20 +0000589 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000590 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
591 struct ospf6_neighbor *best_drouter, *best_bdrouter;
592 u_char next_state = 0;
593
594 drouter = bdrouter = NULL;
595 best_drouter = best_bdrouter = NULL;
596
597 /* pseudo neighbor myself, including noting current DR/BDR (1) */
598 memset (&myself, 0, sizeof (myself));
599 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
600 sizeof (myself.name));
601 myself.state = OSPF6_NEIGHBOR_TWOWAY;
602 myself.drouter = oi->drouter;
603 myself.bdrouter = oi->bdrouter;
604 myself.priority = oi->priority;
605 myself.router_id = oi->area->ospf6->router_id;
606
607 /* Electing BDR (2) */
paul1eb8ef22005-04-07 07:30:20 +0000608 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
609 bdrouter = better_bdrouter (bdrouter, on);
610
hasso508e53e2004-05-18 18:57:06 +0000611 best_bdrouter = bdrouter;
612 bdrouter = better_bdrouter (best_bdrouter, &myself);
613
614 /* Electing DR (3) */
paul1eb8ef22005-04-07 07:30:20 +0000615 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
616 drouter = better_drouter (drouter, on);
617
hasso508e53e2004-05-18 18:57:06 +0000618 best_drouter = drouter;
619 drouter = better_drouter (best_drouter, &myself);
620 if (drouter == NULL)
621 drouter = bdrouter;
622
623 /* the router itself is newly/no longer DR/BDR (4) */
624 if ((drouter == &myself && myself.drouter != myself.router_id) ||
625 (drouter != &myself && myself.drouter == myself.router_id) ||
626 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
627 (bdrouter != &myself && myself.bdrouter == myself.router_id))
628 {
629 myself.drouter = (drouter ? drouter->router_id : htonl (0));
630 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
631
632 /* compatible to Electing BDR (2) */
633 bdrouter = better_bdrouter (best_bdrouter, &myself);
634
635 /* compatible to Electing DR (3) */
636 drouter = better_drouter (best_drouter, &myself);
637 if (drouter == NULL)
638 drouter = bdrouter;
639 }
640
641 /* Set interface state accordingly (5) */
642 if (drouter && drouter == &myself)
643 next_state = OSPF6_INTERFACE_DR;
644 else if (bdrouter && bdrouter == &myself)
645 next_state = OSPF6_INTERFACE_BDR;
646 else
647 next_state = OSPF6_INTERFACE_DROTHER;
648
649 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
650 /* XXX */
651
652 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
653 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
654 accordingly after AdjOK */
655 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
656 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
657 {
658 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000659 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
660 (drouter ? drouter->name : "0.0.0.0"),
661 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000662
paul1eb8ef22005-04-07 07:30:20 +0000663 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
hasso508e53e2004-05-18 18:57:06 +0000664 {
hasso508e53e2004-05-18 18:57:06 +0000665 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
666 continue;
667 /* Schedule AdjOK. */
668 thread_add_event (master, adj_ok, on, 0);
669 }
670 }
671
672 oi->drouter = (drouter ? drouter->router_id : htonl (0));
673 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
674 return next_state;
675}
676
David Lamparter6b0655a2014-06-04 06:53:35 +0200677
hasso508e53e2004-05-18 18:57:06 +0000678/* Interface State Machine */
679int
680interface_up (struct thread *thread)
681{
682 struct ospf6_interface *oi;
683
684 oi = (struct ospf6_interface *) THREAD_ARG (thread);
685 assert (oi && oi->interface);
686
687 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000688 zlog_debug ("Interface Event %s: [InterfaceUp]",
689 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000690
691 /* check physical interface is up */
Dinesh Dutte7ad6b22013-08-24 07:55:57 +0000692 if (! if_is_operative (oi->interface))
hasso508e53e2004-05-18 18:57:06 +0000693 {
694 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000695 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
696 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000697 return 0;
698 }
699
Christian Frankeb13c1d92012-12-13 16:11:16 +0100700 /* check interface has a link-local address */
701 if (! (ospf6_interface_get_linklocal_address(oi->interface)
702 || if_is_loopback(oi->interface)))
703 {
704 if (IS_OSPF6_DEBUG_INTERFACE)
705 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
706 oi->interface->name);
707 return 0;
708 }
709
Vincent Bernatc19543b2012-10-24 14:45:53 +0000710 /* Recompute cost */
711 ospf6_interface_recalculate_cost (oi);
712
hasso508e53e2004-05-18 18:57:06 +0000713 /* if already enabled, do nothing */
714 if (oi->state > OSPF6_INTERFACE_DOWN)
715 {
716 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000717 zlog_debug ("Interface %s already enabled",
718 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000719 return 0;
720 }
721
Dinesh Duttba960d52013-08-26 03:40:37 +0000722 /* If no area assigned, return */
723 if (oi->area == NULL)
724 {
725 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__,
726 oi->interface->name);
727 return 0;
728 }
729
hasso508e53e2004-05-18 18:57:06 +0000730 /* Join AllSPFRouters */
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400731 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000732
733 /* Update interface route */
734 ospf6_interface_connected_route_update (oi->interface);
735
736 /* Schedule Hello */
737 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
David Lamparter424cc3b2013-11-23 16:55:36 +0100738 oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
hasso508e53e2004-05-18 18:57:06 +0000739
740 /* decide next interface state */
Dinesh Duttc5926a92013-08-24 07:55:00 +0000741 if ((if_is_pointopoint (oi->interface)) ||
742 (oi->type == OSPF_IFTYPE_POINTOPOINT)) {
hasso508e53e2004-05-18 18:57:06 +0000743 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
Dinesh Duttc5926a92013-08-24 07:55:00 +0000744 }
hasso508e53e2004-05-18 18:57:06 +0000745 else if (oi->priority == 0)
746 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
747 else
748 {
749 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
750 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
751 }
752
753 return 0;
paul718e3742002-12-13 20:15:29 +0000754}
755
756int
hasso508e53e2004-05-18 18:57:06 +0000757wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000758{
hasso508e53e2004-05-18 18:57:06 +0000759 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000760
hasso508e53e2004-05-18 18:57:06 +0000761 oi = (struct ospf6_interface *) THREAD_ARG (thread);
762 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000763
hasso508e53e2004-05-18 18:57:06 +0000764 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000765 zlog_debug ("Interface Event %s: [WaitTimer]",
766 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000767
hasso508e53e2004-05-18 18:57:06 +0000768 if (oi->state == OSPF6_INTERFACE_WAITING)
769 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000770
hasso508e53e2004-05-18 18:57:06 +0000771 return 0;
paul718e3742002-12-13 20:15:29 +0000772}
773
hasso508e53e2004-05-18 18:57:06 +0000774int
775backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000776{
hasso508e53e2004-05-18 18:57:06 +0000777 struct ospf6_interface *oi;
778
779 oi = (struct ospf6_interface *) THREAD_ARG (thread);
780 assert (oi && oi->interface);
781
782 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000783 zlog_debug ("Interface Event %s: [BackupSeen]",
784 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000785
786 if (oi->state == OSPF6_INTERFACE_WAITING)
787 ospf6_interface_state_change (dr_election (oi), oi);
788
789 return 0;
paul718e3742002-12-13 20:15:29 +0000790}
791
hasso508e53e2004-05-18 18:57:06 +0000792int
793neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000794{
hasso508e53e2004-05-18 18:57:06 +0000795 struct ospf6_interface *oi;
796
797 oi = (struct ospf6_interface *) THREAD_ARG (thread);
798 assert (oi && oi->interface);
799
800 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000801 zlog_debug ("Interface Event %s: [NeighborChange]",
802 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000803
804 if (oi->state == OSPF6_INTERFACE_DROTHER ||
805 oi->state == OSPF6_INTERFACE_BDR ||
806 oi->state == OSPF6_INTERFACE_DR)
807 ospf6_interface_state_change (dr_election (oi), oi);
808
809 return 0;
paul718e3742002-12-13 20:15:29 +0000810}
811
hasso508e53e2004-05-18 18:57:06 +0000812int
813interface_down (struct thread *thread)
814{
815 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000816 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000817 struct ospf6_neighbor *on;
818
819 oi = (struct ospf6_interface *) THREAD_ARG (thread);
820 assert (oi && oi->interface);
821
822 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000823 zlog_debug ("Interface Event %s: [InterfaceDown]",
824 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000825
David Lamparter424cc3b2013-11-23 16:55:36 +0100826 /* Stop Hellos */
827 THREAD_OFF (oi->thread_send_hello);
828
hasso508e53e2004-05-18 18:57:06 +0000829 /* Leave AllSPFRouters */
830 if (oi->state > OSPF6_INTERFACE_DOWN)
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400831 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000832
833 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
834
paul1eb8ef22005-04-07 07:30:20 +0000835 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
836 ospf6_neighbor_delete (on);
837
hasso508e53e2004-05-18 18:57:06 +0000838 list_delete_all_node (oi->neighbor_list);
839
Christian Franke37531a72012-12-13 13:50:28 +0100840 /* When interface state is reset, also reset information about
841 * DR election, as it is no longer valid. */
842 oi->drouter = oi->prev_drouter = htonl(0);
843 oi->bdrouter = oi->prev_bdrouter = htonl(0);
hasso508e53e2004-05-18 18:57:06 +0000844 return 0;
845}
846
David Lamparter6b0655a2014-06-04 06:53:35 +0200847
paul718e3742002-12-13 20:15:29 +0000848/* show specified interface structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100849static int
hasso508e53e2004-05-18 18:57:06 +0000850ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000851{
hasso508e53e2004-05-18 18:57:06 +0000852 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000853 struct connected *c;
854 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000855 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000856 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000857 const char *updown[3] = {"down", "up", NULL};
858 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000859 struct timeval res, now;
860 char duration[32];
861 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000862
863 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000864 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000865 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000866 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000867 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000868 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000869 type = "POINTOPOINT";
870 else
871 type = "UNKNOWN";
872
873 vty_out (vty, "%s is %s, type %s%s",
Dinesh Dutte7ad6b22013-08-24 07:55:57 +0000874 ifp->name, updown[if_is_operative (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000875 VNL);
876 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000877
hasso508e53e2004-05-18 18:57:06 +0000878 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000879 {
hasso049207c2004-08-04 20:02:13 +0000880 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000881 return 0;
882 }
883 else
hasso508e53e2004-05-18 18:57:06 +0000884 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000885
hasso049207c2004-08-04 20:02:13 +0000886 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000887
888 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000889 {
paul718e3742002-12-13 20:15:29 +0000890 p = c->address;
891 prefix2str (p, strbuf, sizeof (strbuf));
892 switch (p->family)
893 {
894 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000895 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000896 VNL);
paul718e3742002-12-13 20:15:29 +0000897 break;
898 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000899 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000900 VNL);
paul718e3742002-12-13 20:15:29 +0000901 break;
902 default:
hasso508e53e2004-05-18 18:57:06 +0000903 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000904 VNL);
paul718e3742002-12-13 20:15:29 +0000905 break;
906 }
907 }
908
hasso508e53e2004-05-18 18:57:06 +0000909 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000910 {
hasso508e53e2004-05-18 18:57:06 +0000911 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000912 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400913 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
914 "disabled" : "enabled", VNL);
hasso508e53e2004-05-18 18:57:06 +0000915 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000916 strbuf, sizeof (strbuf));
David Lamparter72c69d42015-03-03 09:08:20 +0100917 vty_out (vty, " Area ID %s, Cost %u%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000918 VNL);
paul718e3742002-12-13 20:15:29 +0000919 }
920 else
hasso049207c2004-08-04 20:02:13 +0000921 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000922
923 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000924 ospf6_interface_state_str[oi->state],
925 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000926 VNL);
927 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000928 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000929 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000930 VNL);
paul718e3742002-12-13 20:15:29 +0000931
hasso508e53e2004-05-18 18:57:06 +0000932 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
933 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000934 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000935
936 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000937 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000938
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900939 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
paul718e3742002-12-13 20:15:29 +0000940
hasso508e53e2004-05-18 18:57:06 +0000941 timerclear (&res);
942 if (oi->thread_send_lsupdate)
943 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
944 timerstring (&res, duration, sizeof (duration));
945 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
946 oi->lsupdate_list->count, duration,
947 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000948 VNL);
hasso508e53e2004-05-18 18:57:06 +0000949 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
950 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000951 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000952
hasso508e53e2004-05-18 18:57:06 +0000953 timerclear (&res);
954 if (oi->thread_send_lsack)
955 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
956 timerstring (&res, duration, sizeof (duration));
957 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
958 oi->lsack_list->count, duration,
959 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000960 VNL);
hasso508e53e2004-05-18 18:57:06 +0000961 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
962 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000963 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000964
hasso508e53e2004-05-18 18:57:06 +0000965 return 0;
paul718e3742002-12-13 20:15:29 +0000966}
967
968/* show interface */
969DEFUN (show_ipv6_ospf6_interface,
970 show_ipv6_ospf6_interface_ifname_cmd,
971 "show ipv6 ospf6 interface IFNAME",
972 SHOW_STR
973 IP6_STR
974 OSPF6_STR
975 INTERFACE_STR
976 IFNAME_STR
977 )
978{
979 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000980 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000981
982 if (argc)
983 {
984 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000985 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000986 {
987 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000988 VNL);
paul718e3742002-12-13 20:15:29 +0000989 return CMD_WARNING;
990 }
991 ospf6_interface_show (vty, ifp);
992 }
993 else
994 {
paul1eb8ef22005-04-07 07:30:20 +0000995 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
996 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000997 }
hasso508e53e2004-05-18 18:57:06 +0000998
paul718e3742002-12-13 20:15:29 +0000999 return CMD_SUCCESS;
1000}
1001
1002ALIAS (show_ipv6_ospf6_interface,
1003 show_ipv6_ospf6_interface_cmd,
1004 "show ipv6 ospf6 interface",
1005 SHOW_STR
1006 IP6_STR
1007 OSPF6_STR
1008 INTERFACE_STR
Paul Jakma6ac29a52008-08-15 13:45:30 +01001009 )
paul718e3742002-12-13 20:15:29 +00001010
hasso508e53e2004-05-18 18:57:06 +00001011DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
1012 show_ipv6_ospf6_interface_ifname_prefix_cmd,
1013 "show ipv6 ospf6 interface IFNAME prefix",
1014 SHOW_STR
paul718e3742002-12-13 20:15:29 +00001015 IP6_STR
1016 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001017 INTERFACE_STR
1018 IFNAME_STR
1019 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +00001020 )
1021{
paul718e3742002-12-13 20:15:29 +00001022 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +00001023 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001024
hasso508e53e2004-05-18 18:57:06 +00001025 ifp = if_lookup_by_name (argv[0]);
1026 if (ifp == NULL)
1027 {
hasso049207c2004-08-04 20:02:13 +00001028 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +00001029 return CMD_WARNING;
1030 }
paul718e3742002-12-13 20:15:29 +00001031
hasso508e53e2004-05-18 18:57:06 +00001032 oi = ifp->info;
1033 if (oi == NULL)
1034 {
hasso049207c2004-08-04 20:02:13 +00001035 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +00001036 return CMD_WARNING;
1037 }
paul718e3742002-12-13 20:15:29 +00001038
hasso508e53e2004-05-18 18:57:06 +00001039 argc--;
1040 argv++;
1041 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +00001042
1043 return CMD_SUCCESS;
1044}
1045
hasso508e53e2004-05-18 18:57:06 +00001046ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1047 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
1048 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1049 SHOW_STR
paul718e3742002-12-13 20:15:29 +00001050 IP6_STR
1051 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001052 INTERFACE_STR
1053 IFNAME_STR
1054 "Display connected prefixes to advertise\n"
1055 OSPF6_ROUTE_ADDRESS_STR
1056 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001057 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001058 )
hasso508e53e2004-05-18 18:57:06 +00001059
1060ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1061 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
1062 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1063 SHOW_STR
1064 IP6_STR
1065 OSPF6_STR
1066 INTERFACE_STR
1067 IFNAME_STR
1068 "Display connected prefixes to advertise\n"
1069 OSPF6_ROUTE_PREFIX_STR
1070 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001071 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001072 )
hasso508e53e2004-05-18 18:57:06 +00001073
1074DEFUN (show_ipv6_ospf6_interface_prefix,
1075 show_ipv6_ospf6_interface_prefix_cmd,
1076 "show ipv6 ospf6 interface prefix",
1077 SHOW_STR
1078 IP6_STR
1079 OSPF6_STR
1080 INTERFACE_STR
1081 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +00001082 )
1083{
hasso52dc7ee2004-09-23 19:18:23 +00001084 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001085 struct ospf6_interface *oi;
1086 struct interface *ifp;
1087
paul1eb8ef22005-04-07 07:30:20 +00001088 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +00001089 {
hasso508e53e2004-05-18 18:57:06 +00001090 oi = (struct ospf6_interface *) ifp->info;
1091 if (oi == NULL)
1092 continue;
1093
1094 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1095 }
1096
1097 return CMD_SUCCESS;
1098}
1099
1100ALIAS (show_ipv6_ospf6_interface_prefix,
1101 show_ipv6_ospf6_interface_prefix_detail_cmd,
1102 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1103 SHOW_STR
1104 IP6_STR
1105 OSPF6_STR
1106 INTERFACE_STR
1107 "Display connected prefixes to advertise\n"
1108 OSPF6_ROUTE_ADDRESS_STR
1109 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001110 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001111 )
hasso508e53e2004-05-18 18:57:06 +00001112
1113ALIAS (show_ipv6_ospf6_interface_prefix,
1114 show_ipv6_ospf6_interface_prefix_match_cmd,
1115 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1116 SHOW_STR
1117 IP6_STR
1118 OSPF6_STR
1119 INTERFACE_STR
1120 "Display connected prefixes to advertise\n"
1121 OSPF6_ROUTE_PREFIX_STR
1122 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001123 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001124 )
hasso508e53e2004-05-18 18:57:06 +00001125
1126
1127/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001128DEFUN (ipv6_ospf6_ifmtu,
1129 ipv6_ospf6_ifmtu_cmd,
1130 "ipv6 ospf6 ifmtu <1-65535>",
1131 IP6_STR
1132 OSPF6_STR
1133 "Interface MTU\n"
1134 "OSPFv3 Interface MTU\n"
1135 )
1136{
1137 struct ospf6_interface *oi;
1138 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001139 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001140 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001141 struct ospf6_neighbor *on;
1142
1143 ifp = (struct interface *) vty->index;
1144 assert (ifp);
1145
1146 oi = (struct ospf6_interface *) ifp->info;
1147 if (oi == NULL)
1148 oi = ospf6_interface_create (ifp);
1149 assert (oi);
1150
1151 ifmtu = strtol (argv[0], NULL, 10);
1152
1153 if (oi->ifmtu == ifmtu)
1154 return CMD_SUCCESS;
1155
hasso1203e1c2004-07-23 21:34:27 +00001156 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001157 {
1158 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001159 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001160 return CMD_WARNING;
1161 }
1162
1163 if (oi->ifmtu < ifmtu)
1164 {
1165 iobuflen = ospf6_iobuf_size (ifmtu);
1166 if (iobuflen < ifmtu)
1167 {
1168 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001169 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001170 oi->ifmtu = iobuflen;
1171 }
1172 else
1173 oi->ifmtu = ifmtu;
1174 }
1175 else
1176 oi->ifmtu = ifmtu;
1177
1178 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001179 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001180 {
hassob596c712004-07-09 18:33:43 +00001181 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001182 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001183 }
1184
1185 return CMD_SUCCESS;
1186}
1187
hasso049207c2004-08-04 20:02:13 +00001188DEFUN (no_ipv6_ospf6_ifmtu,
1189 no_ipv6_ospf6_ifmtu_cmd,
1190 "no ipv6 ospf6 ifmtu",
1191 NO_STR
1192 IP6_STR
1193 OSPF6_STR
1194 "Interface MTU\n"
1195 )
1196{
1197 struct ospf6_interface *oi;
1198 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001199 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001200 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001201 struct ospf6_neighbor *on;
1202
1203 ifp = (struct interface *) vty->index;
1204 assert (ifp);
1205
1206 oi = (struct ospf6_interface *) ifp->info;
1207 if (oi == NULL)
1208 oi = ospf6_interface_create (ifp);
1209 assert (oi);
1210
1211 if (oi->ifmtu < ifp->mtu)
1212 {
1213 iobuflen = ospf6_iobuf_size (ifp->mtu);
1214 if (iobuflen < ifp->mtu)
1215 {
1216 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1217 ifp->name, iobuflen, VNL);
1218 oi->ifmtu = iobuflen;
1219 }
1220 else
1221 oi->ifmtu = ifp->mtu;
1222 }
1223 else
1224 oi->ifmtu = ifp->mtu;
1225
1226 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001227 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001228 {
hasso049207c2004-08-04 20:02:13 +00001229 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001230 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001231 }
1232
1233 return CMD_SUCCESS;
1234}
1235
hasso508e53e2004-05-18 18:57:06 +00001236DEFUN (ipv6_ospf6_cost,
1237 ipv6_ospf6_cost_cmd,
1238 "ipv6 ospf6 cost <1-65535>",
1239 IP6_STR
1240 OSPF6_STR
1241 "Interface cost\n"
1242 "Outgoing metric of this interface\n"
1243 )
1244{
1245 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001246 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001247 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001248
1249 ifp = (struct interface *) vty->index;
1250 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001251
hasso508e53e2004-05-18 18:57:06 +00001252 oi = (struct ospf6_interface *) ifp->info;
1253 if (oi == NULL)
1254 oi = ospf6_interface_create (ifp);
1255 assert (oi);
1256
paul0c083ee2004-10-10 12:54:58 +00001257 lcost = strtol (argv[0], NULL, 10);
1258
1259 if (lcost > UINT32_MAX)
1260 {
1261 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1262 return CMD_WARNING;
1263 }
1264
1265 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001266 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001267
1268 oi->cost = lcost;
Vincent Bernatc19543b2012-10-24 14:45:53 +00001269 SET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
hasso508e53e2004-05-18 18:57:06 +00001270
Vincent Bernatc19543b2012-10-24 14:45:53 +00001271 ospf6_interface_recalculate_cost(oi);
1272
1273 return CMD_SUCCESS;
1274}
1275
1276DEFUN (no_ipv6_ospf6_cost,
1277 no_ipv6_ospf6_cost_cmd,
1278 "no ipv6 ospf6 cost",
1279 NO_STR
1280 IP6_STR
1281 OSPF6_STR
1282 "Calculate interface cost from bandwidth\n"
1283 )
1284{
1285 struct ospf6_interface *oi;
1286 struct interface *ifp;
Vincent Bernatc19543b2012-10-24 14:45:53 +00001287
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);
hasso508e53e2004-05-18 18:57:06 +00001299
1300 return CMD_SUCCESS;
1301}
1302
Vincent Bernatfd500682012-10-24 14:45:54 +00001303DEFUN (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
hasso508e53e2004-05-18 18:57:06 +00001358DEFUN (ipv6_ospf6_hellointerval,
1359 ipv6_ospf6_hellointerval_cmd,
1360 "ipv6 ospf6 hello-interval <1-65535>",
1361 IP6_STR
1362 OSPF6_STR
1363 "Interval time of Hello packets\n"
1364 SECONDS_STR
1365 )
1366{
1367 struct ospf6_interface *oi;
1368 struct interface *ifp;
1369
1370 ifp = (struct interface *) vty->index;
1371 assert (ifp);
1372
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);
paul718e3742002-12-13 20:15:29 +00001379 return CMD_SUCCESS;
1380}
1381
1382/* interface variable set command */
1383DEFUN (ipv6_ospf6_deadinterval,
1384 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001385 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001386 IP6_STR
1387 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001388 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001389 SECONDS_STR
1390 )
1391{
hasso508e53e2004-05-18 18:57:06 +00001392 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001393 struct interface *ifp;
1394
1395 ifp = (struct interface *) vty->index;
1396 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001397
hasso508e53e2004-05-18 18:57:06 +00001398 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);
paul718e3742002-12-13 20:15:29 +00001404 return CMD_SUCCESS;
1405}
1406
1407/* interface variable set command */
1408DEFUN (ipv6_ospf6_transmitdelay,
1409 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001410 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001411 IP6_STR
1412 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001413 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001414 SECONDS_STR
1415 )
1416{
hasso508e53e2004-05-18 18:57:06 +00001417 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001418 struct interface *ifp;
1419
1420 ifp = (struct interface *) vty->index;
1421 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001422
hasso508e53e2004-05-18 18:57:06 +00001423 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);
paul718e3742002-12-13 20:15:29 +00001429 return CMD_SUCCESS;
1430}
1431
1432/* interface variable set command */
1433DEFUN (ipv6_ospf6_retransmitinterval,
1434 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001435 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001436 IP6_STR
1437 OSPF6_STR
1438 "Time between retransmitting lost link state advertisements\n"
1439 SECONDS_STR
1440 )
1441{
hasso508e53e2004-05-18 18:57:06 +00001442 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001443 struct interface *ifp;
1444
1445 ifp = (struct interface *) vty->index;
1446 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001447
hasso508e53e2004-05-18 18:57:06 +00001448 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);
paul718e3742002-12-13 20:15:29 +00001454 return CMD_SUCCESS;
1455}
1456
1457/* interface variable set command */
1458DEFUN (ipv6_ospf6_priority,
1459 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001460 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001461 IP6_STR
1462 OSPF6_STR
1463 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001464 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001465 )
1466{
hasso508e53e2004-05-18 18:57:06 +00001467 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001468 struct interface *ifp;
1469
1470 ifp = (struct interface *) vty->index;
1471 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001472
hasso508e53e2004-05-18 18:57:06 +00001473 oi = (struct ospf6_interface *) ifp->info;
1474 if (oi == NULL)
1475 oi = ospf6_interface_create (ifp);
1476 assert (oi);
paul718e3742002-12-13 20:15:29 +00001477
hasso508e53e2004-05-18 18:57:06 +00001478 oi->priority = strtol (argv[0], NULL, 10);
1479
Christian Franke7d4aa1d2012-12-13 16:10:05 +01001480 if (oi->area &&
1481 (oi->state == OSPF6_INTERFACE_DROTHER ||
1482 oi->state == OSPF6_INTERFACE_BDR ||
1483 oi->state == OSPF6_INTERFACE_DR))
hasso508e53e2004-05-18 18:57:06 +00001484 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001485
1486 return CMD_SUCCESS;
1487}
1488
1489DEFUN (ipv6_ospf6_instance,
1490 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001491 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001492 IP6_STR
1493 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001494 "Instance ID for this interface\n"
1495 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001496 )
1497{
hasso508e53e2004-05-18 18:57:06 +00001498 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001499 struct interface *ifp;
1500
1501 ifp = (struct interface *)vty->index;
1502 assert (ifp);
1503
hasso508e53e2004-05-18 18:57:06 +00001504 oi = (struct ospf6_interface *)ifp->info;
1505 if (oi == NULL)
1506 oi = ospf6_interface_create (ifp);
1507 assert (oi);
paul718e3742002-12-13 20:15:29 +00001508
hasso508e53e2004-05-18 18:57:06 +00001509 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001510 return CMD_SUCCESS;
1511}
1512
1513DEFUN (ipv6_ospf6_passive,
1514 ipv6_ospf6_passive_cmd,
1515 "ipv6 ospf6 passive",
1516 IP6_STR
1517 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001518 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001519 )
1520{
hasso508e53e2004-05-18 18:57:06 +00001521 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001522 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001523 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001524 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001525
1526 ifp = (struct interface *) vty->index;
1527 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001528
hasso508e53e2004-05-18 18:57:06 +00001529 oi = (struct ospf6_interface *) ifp->info;
1530 if (oi == NULL)
1531 oi = ospf6_interface_create (ifp);
1532 assert (oi);
paul718e3742002-12-13 20:15:29 +00001533
hasso508e53e2004-05-18 18:57:06 +00001534 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1535 THREAD_OFF (oi->thread_send_hello);
1536
paul1eb8ef22005-04-07 07:30:20 +00001537 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001538 {
hasso508e53e2004-05-18 18:57:06 +00001539 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001540 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001541 }
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{
hasso508e53e2004-05-18 18:57:06 +00001555 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001556 struct interface *ifp;
1557
1558 ifp = (struct interface *) vty->index;
1559 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001560
hasso508e53e2004-05-18 18:57:06 +00001561 oi = (struct ospf6_interface *) ifp->info;
1562 if (oi == NULL)
1563 oi = ospf6_interface_create (ifp);
1564 assert (oi);
paul718e3742002-12-13 20:15:29 +00001565
hasso508e53e2004-05-18 18:57:06 +00001566 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);
paul718e3742002-12-13 20:15:29 +00001570
1571 return CMD_SUCCESS;
1572}
1573
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001574DEFUN (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
paul718e3742002-12-13 20:15:29 +00001623DEFUN (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{
hasso508e53e2004-05-18 18:57:06 +00001633 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001634 struct interface *ifp;
1635
1636 ifp = (struct interface *) vty->index;
1637 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001638
hasso508e53e2004-05-18 18:57:06 +00001639 oi = (struct ospf6_interface *) ifp->info;
1640 if (oi == NULL)
1641 oi = ospf6_interface_create (ifp);
1642 assert (oi);
paul718e3742002-12-13 20:15:29 +00001643
hasso508e53e2004-05-18 18:57:06 +00001644 if (oi->plist_name)
1645 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1646 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001647
hasso508e53e2004-05-18 18:57:06 +00001648 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001649
1650 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001651 {
David Ward2470e992010-01-05 02:45:39 +00001652 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);
hasso508e53e2004-05-18 18:57:06 +00001659 }
paul718e3742002-12-13 20:15:29 +00001660
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{
hasso508e53e2004-05-18 18:57:06 +00001674 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001675 struct interface *ifp;
1676
1677 ifp = (struct interface *) vty->index;
1678 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001679
hasso508e53e2004-05-18 18:57:06 +00001680 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)
paul718e3742002-12-13 20:15:29 +00001686 {
hasso508e53e2004-05-18 18:57:06 +00001687 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1688 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001689 }
1690
hasso508e53e2004-05-18 18:57:06 +00001691 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001692
1693 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001694 {
David Ward2470e992010-01-05 02:45:39 +00001695 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);
hasso508e53e2004-05-18 18:57:06 +00001702 }
paul718e3742002-12-13 20:15:29 +00001703
1704 return CMD_SUCCESS;
1705}
1706
Dinesh Duttc5926a92013-08-24 07:55:00 +00001707DEFUN (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
Paul Jakma6ac29a52008-08-15 13:45:30 +01001787static int
hasso508e53e2004-05-18 18:57:06 +00001788config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001789{
hasso52dc7ee2004-09-23 19:18:23 +00001790 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001791 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001792 struct interface *ifp;
1793
paul1eb8ef22005-04-07 07:30:20 +00001794 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001795 {
hasso508e53e2004-05-18 18:57:06 +00001796 oi = (struct ospf6_interface *) ifp->info;
1797 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001798 continue;
1799
1800 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001801 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001802
1803 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001804 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso1203e1c2004-07-23 21:34:27 +00001805 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001806 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001807
Vincent Bernatc19543b2012-10-24 14:45:53 +00001808 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001809 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);
paul718e3742002-12-13 20:15:29 +00001835
hasso508e53e2004-05-18 18:57:06 +00001836 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001837 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001838 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001839
hasso508e53e2004-05-18 18:57:06 +00001840 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001841 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001842
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001843 if (oi->mtu_ignore)
1844 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1845
Dinesh Duttc5926a92013-08-24 07:55:00 +00001846 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
hasso049207c2004-08-04 20:02:13 +00001851 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001852 }
1853 return 0;
1854}
1855
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001856static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001857{
1858 INTERFACE_NODE,
1859 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001860 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001861};
1862
1863void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001864ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001865{
1866 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001867 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001868
1869 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001870 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);
paul718e3742002-12-13 20:15:29 +00001873 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001874 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);
paul718e3742002-12-13 20:15:29 +00001877 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001878 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);
paul718e3742002-12-13 20:15:29 +00001881 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001882 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);
paul718e3742002-12-13 20:15:29 +00001885
hasso508e53e2004-05-18 18:57:06 +00001886 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001887 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);
Vincent Bernatc19543b2012-10-24 14:45:53 +00001891 install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001892 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001893 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001894 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);
hasso508e53e2004-05-18 18:57:06 +00001900
paul718e3742002-12-13 20:15:29 +00001901 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1902 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001903
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001904 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1905 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1906
hasso508e53e2004-05-18 18:57:06 +00001907 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1908 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
Dinesh Duttc5926a92013-08-24 07:55:00 +00001909
1910 install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
1911 install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
Vincent Bernatfd500682012-10-24 14:45:54 +00001912
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);
hasso508e53e2004-05-18 18:57:06 +00001916}
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{
hasso3b687352004-08-19 06:56:53 +00001939 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001940 return CMD_SUCCESS;
1941}
1942
1943int
1944config_write_ospf6_debug_interface (struct vty *vty)
1945{
1946 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001947 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001948 return 0;
1949}
1950
1951void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001952install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001953{
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);
paul718e3742002-12-13 20:15:29 +00001958}
1959
1960