blob: 3d6ebcda7398394a61d5a077de2dc2ed5f945d72 [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 */
Vipin Kumarcb37de42015-05-19 18:03:40 -0700731 if (ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP) < 0)
732 {
733 if (oi->sso_try_cnt++ < OSPF6_INTERFACE_SSO_RETRY_MAX)
734 {
735 zlog_info("Scheduling %s for sso retry, trial count: %d",
736 oi->interface->name, oi->sso_try_cnt);
737 thread_add_timer (master, interface_up, oi,
738 OSPF6_INTERFACE_SSO_RETRY_INT);
739 }
740 return 0;
741 }
742 oi->sso_try_cnt = 0; /* Reset on success */
hasso508e53e2004-05-18 18:57:06 +0000743
744 /* Update interface route */
745 ospf6_interface_connected_route_update (oi->interface);
746
747 /* Schedule Hello */
748 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
David Lamparter424cc3b2013-11-23 16:55:36 +0100749 oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
hasso508e53e2004-05-18 18:57:06 +0000750
751 /* decide next interface state */
Dinesh Duttc5926a92013-08-24 07:55:00 +0000752 if ((if_is_pointopoint (oi->interface)) ||
753 (oi->type == OSPF_IFTYPE_POINTOPOINT)) {
hasso508e53e2004-05-18 18:57:06 +0000754 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
Dinesh Duttc5926a92013-08-24 07:55:00 +0000755 }
hasso508e53e2004-05-18 18:57:06 +0000756 else if (oi->priority == 0)
757 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
758 else
759 {
760 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
761 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
762 }
763
764 return 0;
paul718e3742002-12-13 20:15:29 +0000765}
766
767int
hasso508e53e2004-05-18 18:57:06 +0000768wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000769{
hasso508e53e2004-05-18 18:57:06 +0000770 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000771
hasso508e53e2004-05-18 18:57:06 +0000772 oi = (struct ospf6_interface *) THREAD_ARG (thread);
773 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000774
hasso508e53e2004-05-18 18:57:06 +0000775 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000776 zlog_debug ("Interface Event %s: [WaitTimer]",
777 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000778
hasso508e53e2004-05-18 18:57:06 +0000779 if (oi->state == OSPF6_INTERFACE_WAITING)
780 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000781
hasso508e53e2004-05-18 18:57:06 +0000782 return 0;
paul718e3742002-12-13 20:15:29 +0000783}
784
hasso508e53e2004-05-18 18:57:06 +0000785int
786backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000787{
hasso508e53e2004-05-18 18:57:06 +0000788 struct ospf6_interface *oi;
789
790 oi = (struct ospf6_interface *) THREAD_ARG (thread);
791 assert (oi && oi->interface);
792
793 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000794 zlog_debug ("Interface Event %s: [BackupSeen]",
795 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000796
797 if (oi->state == OSPF6_INTERFACE_WAITING)
798 ospf6_interface_state_change (dr_election (oi), oi);
799
800 return 0;
paul718e3742002-12-13 20:15:29 +0000801}
802
hasso508e53e2004-05-18 18:57:06 +0000803int
804neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000805{
hasso508e53e2004-05-18 18:57:06 +0000806 struct ospf6_interface *oi;
807
808 oi = (struct ospf6_interface *) THREAD_ARG (thread);
809 assert (oi && oi->interface);
810
811 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000812 zlog_debug ("Interface Event %s: [NeighborChange]",
813 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000814
815 if (oi->state == OSPF6_INTERFACE_DROTHER ||
816 oi->state == OSPF6_INTERFACE_BDR ||
817 oi->state == OSPF6_INTERFACE_DR)
818 ospf6_interface_state_change (dr_election (oi), oi);
819
820 return 0;
paul718e3742002-12-13 20:15:29 +0000821}
822
hasso508e53e2004-05-18 18:57:06 +0000823int
824interface_down (struct thread *thread)
825{
826 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000827 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000828 struct ospf6_neighbor *on;
829
830 oi = (struct ospf6_interface *) THREAD_ARG (thread);
831 assert (oi && oi->interface);
832
833 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000834 zlog_debug ("Interface Event %s: [InterfaceDown]",
835 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000836
David Lamparter424cc3b2013-11-23 16:55:36 +0100837 /* Stop Hellos */
838 THREAD_OFF (oi->thread_send_hello);
839
hasso508e53e2004-05-18 18:57:06 +0000840 /* Leave AllSPFRouters */
841 if (oi->state > OSPF6_INTERFACE_DOWN)
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400842 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000843
844 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
845
paul1eb8ef22005-04-07 07:30:20 +0000846 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
847 ospf6_neighbor_delete (on);
848
hasso508e53e2004-05-18 18:57:06 +0000849 list_delete_all_node (oi->neighbor_list);
850
Christian Franke37531a72012-12-13 13:50:28 +0100851 /* When interface state is reset, also reset information about
852 * DR election, as it is no longer valid. */
853 oi->drouter = oi->prev_drouter = htonl(0);
854 oi->bdrouter = oi->prev_bdrouter = htonl(0);
hasso508e53e2004-05-18 18:57:06 +0000855 return 0;
856}
857
David Lamparter6b0655a2014-06-04 06:53:35 +0200858
paul718e3742002-12-13 20:15:29 +0000859/* show specified interface structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100860static int
hasso508e53e2004-05-18 18:57:06 +0000861ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000862{
hasso508e53e2004-05-18 18:57:06 +0000863 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000864 struct connected *c;
865 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000866 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000867 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000868 const char *updown[3] = {"down", "up", NULL};
869 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000870 struct timeval res, now;
871 char duration[32];
872 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000873
874 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000875 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000876 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000877 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000878 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000879 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000880 type = "POINTOPOINT";
881 else
882 type = "UNKNOWN";
883
884 vty_out (vty, "%s is %s, type %s%s",
Dinesh Dutte7ad6b22013-08-24 07:55:57 +0000885 ifp->name, updown[if_is_operative (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000886 VNL);
887 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000888
hasso508e53e2004-05-18 18:57:06 +0000889 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000890 {
hasso049207c2004-08-04 20:02:13 +0000891 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000892 return 0;
893 }
894 else
hasso508e53e2004-05-18 18:57:06 +0000895 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000896
hasso049207c2004-08-04 20:02:13 +0000897 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000898
899 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000900 {
paul718e3742002-12-13 20:15:29 +0000901 p = c->address;
902 prefix2str (p, strbuf, sizeof (strbuf));
903 switch (p->family)
904 {
905 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000906 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000907 VNL);
paul718e3742002-12-13 20:15:29 +0000908 break;
909 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000910 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000911 VNL);
paul718e3742002-12-13 20:15:29 +0000912 break;
913 default:
hasso508e53e2004-05-18 18:57:06 +0000914 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000915 VNL);
paul718e3742002-12-13 20:15:29 +0000916 break;
917 }
918 }
919
hasso508e53e2004-05-18 18:57:06 +0000920 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000921 {
hasso508e53e2004-05-18 18:57:06 +0000922 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000923 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400924 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
925 "disabled" : "enabled", VNL);
hasso508e53e2004-05-18 18:57:06 +0000926 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000927 strbuf, sizeof (strbuf));
David Lamparter72c69d42015-03-03 09:08:20 +0100928 vty_out (vty, " Area ID %s, Cost %u%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000929 VNL);
paul718e3742002-12-13 20:15:29 +0000930 }
931 else
hasso049207c2004-08-04 20:02:13 +0000932 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000933
934 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000935 ospf6_interface_state_str[oi->state],
936 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000937 VNL);
938 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000939 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000940 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000941 VNL);
paul718e3742002-12-13 20:15:29 +0000942
hasso508e53e2004-05-18 18:57:06 +0000943 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
944 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000945 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000946
947 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000948 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000949
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900950 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
paul718e3742002-12-13 20:15:29 +0000951
hasso508e53e2004-05-18 18:57:06 +0000952 timerclear (&res);
953 if (oi->thread_send_lsupdate)
954 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
955 timerstring (&res, duration, sizeof (duration));
956 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
957 oi->lsupdate_list->count, duration,
958 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000959 VNL);
hasso508e53e2004-05-18 18:57:06 +0000960 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
961 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000962 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000963
hasso508e53e2004-05-18 18:57:06 +0000964 timerclear (&res);
965 if (oi->thread_send_lsack)
966 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
967 timerstring (&res, duration, sizeof (duration));
968 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
969 oi->lsack_list->count, duration,
970 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000971 VNL);
hasso508e53e2004-05-18 18:57:06 +0000972 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
973 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000974 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000975
hasso508e53e2004-05-18 18:57:06 +0000976 return 0;
paul718e3742002-12-13 20:15:29 +0000977}
978
979/* show interface */
980DEFUN (show_ipv6_ospf6_interface,
981 show_ipv6_ospf6_interface_ifname_cmd,
982 "show ipv6 ospf6 interface IFNAME",
983 SHOW_STR
984 IP6_STR
985 OSPF6_STR
986 INTERFACE_STR
987 IFNAME_STR
988 )
989{
990 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000991 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000992
993 if (argc)
994 {
995 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000996 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000997 {
998 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000999 VNL);
paul718e3742002-12-13 20:15:29 +00001000 return CMD_WARNING;
1001 }
1002 ospf6_interface_show (vty, ifp);
1003 }
1004 else
1005 {
paul1eb8ef22005-04-07 07:30:20 +00001006 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
1007 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +00001008 }
hasso508e53e2004-05-18 18:57:06 +00001009
paul718e3742002-12-13 20:15:29 +00001010 return CMD_SUCCESS;
1011}
1012
1013ALIAS (show_ipv6_ospf6_interface,
1014 show_ipv6_ospf6_interface_cmd,
1015 "show ipv6 ospf6 interface",
1016 SHOW_STR
1017 IP6_STR
1018 OSPF6_STR
1019 INTERFACE_STR
Paul Jakma6ac29a52008-08-15 13:45:30 +01001020 )
paul718e3742002-12-13 20:15:29 +00001021
hasso508e53e2004-05-18 18:57:06 +00001022DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
1023 show_ipv6_ospf6_interface_ifname_prefix_cmd,
1024 "show ipv6 ospf6 interface IFNAME prefix",
1025 SHOW_STR
paul718e3742002-12-13 20:15:29 +00001026 IP6_STR
1027 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001028 INTERFACE_STR
1029 IFNAME_STR
1030 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +00001031 )
1032{
paul718e3742002-12-13 20:15:29 +00001033 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +00001034 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001035
hasso508e53e2004-05-18 18:57:06 +00001036 ifp = if_lookup_by_name (argv[0]);
1037 if (ifp == NULL)
1038 {
hasso049207c2004-08-04 20:02:13 +00001039 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +00001040 return CMD_WARNING;
1041 }
paul718e3742002-12-13 20:15:29 +00001042
hasso508e53e2004-05-18 18:57:06 +00001043 oi = ifp->info;
1044 if (oi == NULL)
1045 {
hasso049207c2004-08-04 20:02:13 +00001046 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +00001047 return CMD_WARNING;
1048 }
paul718e3742002-12-13 20:15:29 +00001049
hasso508e53e2004-05-18 18:57:06 +00001050 argc--;
1051 argv++;
1052 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +00001053
1054 return CMD_SUCCESS;
1055}
1056
hasso508e53e2004-05-18 18:57:06 +00001057ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1058 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
1059 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1060 SHOW_STR
paul718e3742002-12-13 20:15:29 +00001061 IP6_STR
1062 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001063 INTERFACE_STR
1064 IFNAME_STR
1065 "Display connected prefixes to advertise\n"
1066 OSPF6_ROUTE_ADDRESS_STR
1067 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001068 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001069 )
hasso508e53e2004-05-18 18:57:06 +00001070
1071ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1072 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
1073 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1074 SHOW_STR
1075 IP6_STR
1076 OSPF6_STR
1077 INTERFACE_STR
1078 IFNAME_STR
1079 "Display connected prefixes to advertise\n"
1080 OSPF6_ROUTE_PREFIX_STR
1081 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001082 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001083 )
hasso508e53e2004-05-18 18:57:06 +00001084
1085DEFUN (show_ipv6_ospf6_interface_prefix,
1086 show_ipv6_ospf6_interface_prefix_cmd,
1087 "show ipv6 ospf6 interface prefix",
1088 SHOW_STR
1089 IP6_STR
1090 OSPF6_STR
1091 INTERFACE_STR
1092 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +00001093 )
1094{
hasso52dc7ee2004-09-23 19:18:23 +00001095 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001096 struct ospf6_interface *oi;
1097 struct interface *ifp;
1098
paul1eb8ef22005-04-07 07:30:20 +00001099 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +00001100 {
hasso508e53e2004-05-18 18:57:06 +00001101 oi = (struct ospf6_interface *) ifp->info;
1102 if (oi == NULL)
1103 continue;
1104
1105 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1106 }
1107
1108 return CMD_SUCCESS;
1109}
1110
1111ALIAS (show_ipv6_ospf6_interface_prefix,
1112 show_ipv6_ospf6_interface_prefix_detail_cmd,
1113 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1114 SHOW_STR
1115 IP6_STR
1116 OSPF6_STR
1117 INTERFACE_STR
1118 "Display connected prefixes to advertise\n"
1119 OSPF6_ROUTE_ADDRESS_STR
1120 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001121 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001122 )
hasso508e53e2004-05-18 18:57:06 +00001123
1124ALIAS (show_ipv6_ospf6_interface_prefix,
1125 show_ipv6_ospf6_interface_prefix_match_cmd,
1126 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1127 SHOW_STR
1128 IP6_STR
1129 OSPF6_STR
1130 INTERFACE_STR
1131 "Display connected prefixes to advertise\n"
1132 OSPF6_ROUTE_PREFIX_STR
1133 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001134 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001135 )
hasso508e53e2004-05-18 18:57:06 +00001136
1137
1138/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001139DEFUN (ipv6_ospf6_ifmtu,
1140 ipv6_ospf6_ifmtu_cmd,
1141 "ipv6 ospf6 ifmtu <1-65535>",
1142 IP6_STR
1143 OSPF6_STR
1144 "Interface MTU\n"
1145 "OSPFv3 Interface MTU\n"
1146 )
1147{
1148 struct ospf6_interface *oi;
1149 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001150 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001151 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001152 struct ospf6_neighbor *on;
1153
1154 ifp = (struct interface *) vty->index;
1155 assert (ifp);
1156
1157 oi = (struct ospf6_interface *) ifp->info;
1158 if (oi == NULL)
1159 oi = ospf6_interface_create (ifp);
1160 assert (oi);
1161
1162 ifmtu = strtol (argv[0], NULL, 10);
1163
1164 if (oi->ifmtu == ifmtu)
1165 return CMD_SUCCESS;
1166
hasso1203e1c2004-07-23 21:34:27 +00001167 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001168 {
1169 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001170 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001171 return CMD_WARNING;
1172 }
1173
1174 if (oi->ifmtu < ifmtu)
1175 {
1176 iobuflen = ospf6_iobuf_size (ifmtu);
1177 if (iobuflen < ifmtu)
1178 {
1179 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001180 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001181 oi->ifmtu = iobuflen;
1182 }
1183 else
1184 oi->ifmtu = ifmtu;
1185 }
1186 else
1187 oi->ifmtu = ifmtu;
1188
1189 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001190 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001191 {
hassob596c712004-07-09 18:33:43 +00001192 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001193 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001194 }
1195
1196 return CMD_SUCCESS;
1197}
1198
hasso049207c2004-08-04 20:02:13 +00001199DEFUN (no_ipv6_ospf6_ifmtu,
1200 no_ipv6_ospf6_ifmtu_cmd,
1201 "no ipv6 ospf6 ifmtu",
1202 NO_STR
1203 IP6_STR
1204 OSPF6_STR
1205 "Interface MTU\n"
1206 )
1207{
1208 struct ospf6_interface *oi;
1209 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001210 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001211 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001212 struct ospf6_neighbor *on;
1213
1214 ifp = (struct interface *) vty->index;
1215 assert (ifp);
1216
1217 oi = (struct ospf6_interface *) ifp->info;
1218 if (oi == NULL)
1219 oi = ospf6_interface_create (ifp);
1220 assert (oi);
1221
1222 if (oi->ifmtu < ifp->mtu)
1223 {
1224 iobuflen = ospf6_iobuf_size (ifp->mtu);
1225 if (iobuflen < ifp->mtu)
1226 {
1227 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1228 ifp->name, iobuflen, VNL);
1229 oi->ifmtu = iobuflen;
1230 }
1231 else
1232 oi->ifmtu = ifp->mtu;
1233 }
1234 else
1235 oi->ifmtu = ifp->mtu;
1236
1237 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001238 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001239 {
hasso049207c2004-08-04 20:02:13 +00001240 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001241 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001242 }
1243
1244 return CMD_SUCCESS;
1245}
1246
hasso508e53e2004-05-18 18:57:06 +00001247DEFUN (ipv6_ospf6_cost,
1248 ipv6_ospf6_cost_cmd,
1249 "ipv6 ospf6 cost <1-65535>",
1250 IP6_STR
1251 OSPF6_STR
1252 "Interface cost\n"
1253 "Outgoing metric of this interface\n"
1254 )
1255{
1256 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001257 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001258 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001259
1260 ifp = (struct interface *) vty->index;
1261 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001262
hasso508e53e2004-05-18 18:57:06 +00001263 oi = (struct ospf6_interface *) ifp->info;
1264 if (oi == NULL)
1265 oi = ospf6_interface_create (ifp);
1266 assert (oi);
1267
paul0c083ee2004-10-10 12:54:58 +00001268 lcost = strtol (argv[0], NULL, 10);
1269
1270 if (lcost > UINT32_MAX)
1271 {
1272 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1273 return CMD_WARNING;
1274 }
1275
1276 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001277 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001278
1279 oi->cost = lcost;
Vincent Bernatc19543b2012-10-24 14:45:53 +00001280 SET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
hasso508e53e2004-05-18 18:57:06 +00001281
Vincent Bernatc19543b2012-10-24 14:45:53 +00001282 ospf6_interface_recalculate_cost(oi);
1283
1284 return CMD_SUCCESS;
1285}
1286
1287DEFUN (no_ipv6_ospf6_cost,
1288 no_ipv6_ospf6_cost_cmd,
1289 "no ipv6 ospf6 cost",
1290 NO_STR
1291 IP6_STR
1292 OSPF6_STR
1293 "Calculate interface cost from bandwidth\n"
1294 )
1295{
1296 struct ospf6_interface *oi;
1297 struct interface *ifp;
Vincent Bernatc19543b2012-10-24 14:45:53 +00001298
1299 ifp = (struct interface *) vty->index;
1300 assert (ifp);
1301
1302 oi = (struct ospf6_interface *) ifp->info;
1303 if (oi == NULL)
1304 oi = ospf6_interface_create (ifp);
1305 assert (oi);
1306
1307 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1308
1309 ospf6_interface_recalculate_cost(oi);
hasso508e53e2004-05-18 18:57:06 +00001310
1311 return CMD_SUCCESS;
1312}
1313
Vincent Bernatfd500682012-10-24 14:45:54 +00001314DEFUN (auto_cost_reference_bandwidth,
1315 auto_cost_reference_bandwidth_cmd,
1316 "auto-cost reference-bandwidth <1-4294967>",
1317 "Calculate OSPF interface cost according to bandwidth\n"
1318 "Use reference bandwidth method to assign OSPF cost\n"
1319 "The reference bandwidth in terms of Mbits per second\n")
1320{
1321 struct ospf6 *o = vty->index;
1322 struct ospf6_area *oa;
1323 struct ospf6_interface *oi;
1324 struct listnode *i, *j;
1325 u_int32_t refbw;
1326
1327 refbw = strtol (argv[0], NULL, 10);
1328 if (refbw < 1 || refbw > 4294967)
1329 {
1330 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
1331 return CMD_WARNING;
1332 }
1333
1334 /* If reference bandwidth is changed. */
1335 if ((refbw * 1000) == o->ref_bandwidth)
1336 return CMD_SUCCESS;
1337
1338 o->ref_bandwidth = refbw * 1000;
1339 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1340 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1341 ospf6_interface_recalculate_cost (oi);
1342
1343 return CMD_SUCCESS;
1344}
1345
1346DEFUN (no_auto_cost_reference_bandwidth,
1347 no_auto_cost_reference_bandwidth_cmd,
1348 "no auto-cost reference-bandwidth",
1349 NO_STR
1350 "Calculate OSPF interface cost according to bandwidth\n"
1351 "Use reference bandwidth method to assign OSPF cost\n")
1352{
1353 struct ospf6 *o = vty->index;
1354 struct ospf6_area *oa;
1355 struct ospf6_interface *oi;
1356 struct listnode *i, *j;
1357
1358 if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
1359 return CMD_SUCCESS;
1360
1361 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
1362 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1363 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1364 ospf6_interface_recalculate_cost (oi);
1365
1366 return CMD_SUCCESS;
1367}
1368
hasso508e53e2004-05-18 18:57:06 +00001369DEFUN (ipv6_ospf6_hellointerval,
1370 ipv6_ospf6_hellointerval_cmd,
1371 "ipv6 ospf6 hello-interval <1-65535>",
1372 IP6_STR
1373 OSPF6_STR
1374 "Interval time of Hello packets\n"
1375 SECONDS_STR
1376 )
1377{
1378 struct ospf6_interface *oi;
1379 struct interface *ifp;
1380
1381 ifp = (struct interface *) vty->index;
1382 assert (ifp);
1383
1384 oi = (struct ospf6_interface *) ifp->info;
1385 if (oi == NULL)
1386 oi = ospf6_interface_create (ifp);
1387 assert (oi);
1388
1389 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001390 return CMD_SUCCESS;
1391}
1392
1393/* interface variable set command */
1394DEFUN (ipv6_ospf6_deadinterval,
1395 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001396 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001397 IP6_STR
1398 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001399 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001400 SECONDS_STR
1401 )
1402{
hasso508e53e2004-05-18 18:57:06 +00001403 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001404 struct interface *ifp;
1405
1406 ifp = (struct interface *) vty->index;
1407 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001408
hasso508e53e2004-05-18 18:57:06 +00001409 oi = (struct ospf6_interface *) ifp->info;
1410 if (oi == NULL)
1411 oi = ospf6_interface_create (ifp);
1412 assert (oi);
1413
1414 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001415 return CMD_SUCCESS;
1416}
1417
1418/* interface variable set command */
1419DEFUN (ipv6_ospf6_transmitdelay,
1420 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001421 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001422 IP6_STR
1423 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001424 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001425 SECONDS_STR
1426 )
1427{
hasso508e53e2004-05-18 18:57:06 +00001428 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001429 struct interface *ifp;
1430
1431 ifp = (struct interface *) vty->index;
1432 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001433
hasso508e53e2004-05-18 18:57:06 +00001434 oi = (struct ospf6_interface *) ifp->info;
1435 if (oi == NULL)
1436 oi = ospf6_interface_create (ifp);
1437 assert (oi);
1438
1439 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001440 return CMD_SUCCESS;
1441}
1442
1443/* interface variable set command */
1444DEFUN (ipv6_ospf6_retransmitinterval,
1445 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001446 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001447 IP6_STR
1448 OSPF6_STR
1449 "Time between retransmitting lost link state advertisements\n"
1450 SECONDS_STR
1451 )
1452{
hasso508e53e2004-05-18 18:57:06 +00001453 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001454 struct interface *ifp;
1455
1456 ifp = (struct interface *) vty->index;
1457 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001458
hasso508e53e2004-05-18 18:57:06 +00001459 oi = (struct ospf6_interface *) ifp->info;
1460 if (oi == NULL)
1461 oi = ospf6_interface_create (ifp);
1462 assert (oi);
1463
1464 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001465 return CMD_SUCCESS;
1466}
1467
1468/* interface variable set command */
1469DEFUN (ipv6_ospf6_priority,
1470 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001471 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001472 IP6_STR
1473 OSPF6_STR
1474 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001475 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001476 )
1477{
hasso508e53e2004-05-18 18:57:06 +00001478 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001479 struct interface *ifp;
1480
1481 ifp = (struct interface *) vty->index;
1482 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001483
hasso508e53e2004-05-18 18:57:06 +00001484 oi = (struct ospf6_interface *) ifp->info;
1485 if (oi == NULL)
1486 oi = ospf6_interface_create (ifp);
1487 assert (oi);
paul718e3742002-12-13 20:15:29 +00001488
hasso508e53e2004-05-18 18:57:06 +00001489 oi->priority = strtol (argv[0], NULL, 10);
1490
Christian Franke7d4aa1d2012-12-13 16:10:05 +01001491 if (oi->area &&
1492 (oi->state == OSPF6_INTERFACE_DROTHER ||
1493 oi->state == OSPF6_INTERFACE_BDR ||
1494 oi->state == OSPF6_INTERFACE_DR))
hasso508e53e2004-05-18 18:57:06 +00001495 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001496
1497 return CMD_SUCCESS;
1498}
1499
1500DEFUN (ipv6_ospf6_instance,
1501 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001502 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001503 IP6_STR
1504 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001505 "Instance ID for this interface\n"
1506 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001507 )
1508{
hasso508e53e2004-05-18 18:57:06 +00001509 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001510 struct interface *ifp;
1511
1512 ifp = (struct interface *)vty->index;
1513 assert (ifp);
1514
hasso508e53e2004-05-18 18:57:06 +00001515 oi = (struct ospf6_interface *)ifp->info;
1516 if (oi == NULL)
1517 oi = ospf6_interface_create (ifp);
1518 assert (oi);
paul718e3742002-12-13 20:15:29 +00001519
hasso508e53e2004-05-18 18:57:06 +00001520 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001521 return CMD_SUCCESS;
1522}
1523
1524DEFUN (ipv6_ospf6_passive,
1525 ipv6_ospf6_passive_cmd,
1526 "ipv6 ospf6 passive",
1527 IP6_STR
1528 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001529 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001530 )
1531{
hasso508e53e2004-05-18 18:57:06 +00001532 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001533 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001534 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001535 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001536
1537 ifp = (struct interface *) vty->index;
1538 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001539
hasso508e53e2004-05-18 18:57:06 +00001540 oi = (struct ospf6_interface *) ifp->info;
1541 if (oi == NULL)
1542 oi = ospf6_interface_create (ifp);
1543 assert (oi);
paul718e3742002-12-13 20:15:29 +00001544
hasso508e53e2004-05-18 18:57:06 +00001545 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1546 THREAD_OFF (oi->thread_send_hello);
1547
paul1eb8ef22005-04-07 07:30:20 +00001548 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001549 {
hasso508e53e2004-05-18 18:57:06 +00001550 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001551 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001552 }
1553
1554 return CMD_SUCCESS;
1555}
1556
1557DEFUN (no_ipv6_ospf6_passive,
1558 no_ipv6_ospf6_passive_cmd,
1559 "no ipv6 ospf6 passive",
1560 NO_STR
1561 IP6_STR
1562 OSPF6_STR
1563 "passive interface: No Adjacency will be formed on this I/F\n"
1564 )
1565{
hasso508e53e2004-05-18 18:57:06 +00001566 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001567 struct interface *ifp;
1568
1569 ifp = (struct interface *) vty->index;
1570 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001571
hasso508e53e2004-05-18 18:57:06 +00001572 oi = (struct ospf6_interface *) ifp->info;
1573 if (oi == NULL)
1574 oi = ospf6_interface_create (ifp);
1575 assert (oi);
paul718e3742002-12-13 20:15:29 +00001576
hasso508e53e2004-05-18 18:57:06 +00001577 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1578 THREAD_OFF (oi->thread_send_hello);
1579 oi->thread_send_hello =
1580 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001581
1582 return CMD_SUCCESS;
1583}
1584
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001585DEFUN (ipv6_ospf6_mtu_ignore,
1586 ipv6_ospf6_mtu_ignore_cmd,
1587 "ipv6 ospf6 mtu-ignore",
1588 IP6_STR
1589 OSPF6_STR
1590 "Ignore MTU mismatch on this interface\n"
1591 )
1592{
1593 struct ospf6_interface *oi;
1594 struct interface *ifp;
1595
1596 ifp = (struct interface *) vty->index;
1597 assert (ifp);
1598
1599 oi = (struct ospf6_interface *) ifp->info;
1600 if (oi == NULL)
1601 oi = ospf6_interface_create (ifp);
1602 assert (oi);
1603
1604 oi->mtu_ignore = 1;
1605
1606 return CMD_SUCCESS;
1607}
1608
1609DEFUN (no_ipv6_ospf6_mtu_ignore,
1610 no_ipv6_ospf6_mtu_ignore_cmd,
1611 "no ipv6 ospf6 mtu-ignore",
1612 NO_STR
1613 IP6_STR
1614 OSPF6_STR
1615 "Ignore MTU mismatch on this interface\n"
1616 )
1617{
1618 struct ospf6_interface *oi;
1619 struct interface *ifp;
1620
1621 ifp = (struct interface *) vty->index;
1622 assert (ifp);
1623
1624 oi = (struct ospf6_interface *) ifp->info;
1625 if (oi == NULL)
1626 oi = ospf6_interface_create (ifp);
1627 assert (oi);
1628
1629 oi->mtu_ignore = 0;
1630
1631 return CMD_SUCCESS;
1632}
1633
paul718e3742002-12-13 20:15:29 +00001634DEFUN (ipv6_ospf6_advertise_prefix_list,
1635 ipv6_ospf6_advertise_prefix_list_cmd,
1636 "ipv6 ospf6 advertise prefix-list WORD",
1637 IP6_STR
1638 OSPF6_STR
1639 "Advertising options\n"
1640 "Filter prefix using prefix-list\n"
1641 "Prefix list name\n"
1642 )
1643{
hasso508e53e2004-05-18 18:57:06 +00001644 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001645 struct interface *ifp;
1646
1647 ifp = (struct interface *) vty->index;
1648 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001649
hasso508e53e2004-05-18 18:57:06 +00001650 oi = (struct ospf6_interface *) ifp->info;
1651 if (oi == NULL)
1652 oi = ospf6_interface_create (ifp);
1653 assert (oi);
paul718e3742002-12-13 20:15:29 +00001654
hasso508e53e2004-05-18 18:57:06 +00001655 if (oi->plist_name)
1656 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1657 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001658
hasso508e53e2004-05-18 18:57:06 +00001659 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001660
1661 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001662 {
David Ward2470e992010-01-05 02:45:39 +00001663 OSPF6_LINK_LSA_SCHEDULE (oi);
1664 if (oi->state == OSPF6_INTERFACE_DR)
1665 {
1666 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1667 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1668 }
1669 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001670 }
paul718e3742002-12-13 20:15:29 +00001671
1672 return CMD_SUCCESS;
1673}
1674
1675DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1676 no_ipv6_ospf6_advertise_prefix_list_cmd,
1677 "no ipv6 ospf6 advertise prefix-list",
1678 NO_STR
1679 IP6_STR
1680 OSPF6_STR
1681 "Advertising options\n"
1682 "Filter prefix using prefix-list\n"
1683 )
1684{
hasso508e53e2004-05-18 18:57:06 +00001685 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001686 struct interface *ifp;
1687
1688 ifp = (struct interface *) vty->index;
1689 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001690
hasso508e53e2004-05-18 18:57:06 +00001691 oi = (struct ospf6_interface *) ifp->info;
1692 if (oi == NULL)
1693 oi = ospf6_interface_create (ifp);
1694 assert (oi);
1695
1696 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001697 {
hasso508e53e2004-05-18 18:57:06 +00001698 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1699 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001700 }
1701
hasso508e53e2004-05-18 18:57:06 +00001702 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001703
1704 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001705 {
David Ward2470e992010-01-05 02:45:39 +00001706 OSPF6_LINK_LSA_SCHEDULE (oi);
1707 if (oi->state == OSPF6_INTERFACE_DR)
1708 {
1709 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1710 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1711 }
1712 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001713 }
paul718e3742002-12-13 20:15:29 +00001714
1715 return CMD_SUCCESS;
1716}
1717
Dinesh Duttc5926a92013-08-24 07:55:00 +00001718DEFUN (ipv6_ospf6_network,
1719 ipv6_ospf6_network_cmd,
1720 "ipv6 ospf6 network (broadcast|point-to-point)",
1721 IP6_STR
1722 OSPF6_STR
1723 "Network Type\n"
1724 "Specify OSPFv6 broadcast network\n"
1725 "Specify OSPF6 point-to-point network\n"
1726 )
1727{
1728 struct ospf6_interface *oi;
1729 struct interface *ifp;
1730
1731 ifp = (struct interface *) vty->index;
1732 assert (ifp);
1733
1734 oi = (struct ospf6_interface *) ifp->info;
1735 if (oi == NULL) {
1736 oi = ospf6_interface_create (ifp);
1737 }
1738 assert (oi);
1739
1740 if (strncmp (argv[0], "b", 1) == 0)
1741 {
1742 if (oi->type == OSPF_IFTYPE_BROADCAST)
1743 return CMD_SUCCESS;
1744
1745 oi->type = OSPF_IFTYPE_BROADCAST;
1746 }
1747 else if (strncmp (argv[0], "point-to-p", 10) == 0)
1748 {
1749 if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
1750 return CMD_SUCCESS;
1751 }
1752 oi->type = OSPF_IFTYPE_POINTOPOINT;
1753 }
1754
1755 /* Reset the interface */
1756 thread_add_event (master, interface_down, oi, 0);
1757 thread_add_event (master, interface_up, oi, 0);
1758
1759 return CMD_SUCCESS;
1760}
1761
1762DEFUN (no_ipv6_ospf6_network,
1763 no_ipv6_ospf6_network_cmd,
1764 "no ipv6 ospf6 network",
1765 NO_STR
1766 IP6_STR
1767 OSPF6_STR
1768 "Network Type\n"
1769 "Default to whatever interface type system specifies"
1770 )
1771{
1772 struct ospf6_interface *oi;
1773 struct interface *ifp;
1774 int type;
1775
1776 ifp = (struct interface *) vty->index;
1777 assert (ifp);
1778
1779 oi = (struct ospf6_interface *) ifp->info;
1780 if (oi == NULL) {
1781 return CMD_SUCCESS;
1782 }
1783
1784 type = ospf6_default_iftype (ifp);
1785 if (oi->type == type)
1786 {
1787 return CMD_SUCCESS;
1788 }
1789 oi->type = type;
1790
1791 /* Reset the interface */
1792 thread_add_event (master, interface_down, oi, 0);
1793 thread_add_event (master, interface_up, oi, 0);
1794
1795 return CMD_SUCCESS;
1796}
1797
Paul Jakma6ac29a52008-08-15 13:45:30 +01001798static int
hasso508e53e2004-05-18 18:57:06 +00001799config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001800{
hasso52dc7ee2004-09-23 19:18:23 +00001801 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001802 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001803 struct interface *ifp;
1804
paul1eb8ef22005-04-07 07:30:20 +00001805 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001806 {
hasso508e53e2004-05-18 18:57:06 +00001807 oi = (struct ospf6_interface *) ifp->info;
1808 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001809 continue;
1810
1811 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001812 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001813
1814 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001815 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso1203e1c2004-07-23 21:34:27 +00001816 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001817 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001818
Vincent Bernatc19543b2012-10-24 14:45:53 +00001819 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001820 vty_out (vty, " ipv6 ospf6 cost %d%s",
1821 oi->cost, VNL);
1822
1823 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1824 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1825 oi->hello_interval, VNL);
1826
1827 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1828 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1829 oi->dead_interval, VNL);
1830
1831 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1832 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1833 oi->rxmt_interval, VNL);
1834
1835 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1836 vty_out (vty, " ipv6 ospf6 priority %d%s",
1837 oi->priority, VNL);
1838
1839 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1840 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1841 oi->transdelay, VNL);
1842
1843 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1844 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1845 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001846
hasso508e53e2004-05-18 18:57:06 +00001847 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001848 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001849 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001850
hasso508e53e2004-05-18 18:57:06 +00001851 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001852 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001853
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001854 if (oi->mtu_ignore)
1855 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1856
Dinesh Duttc5926a92013-08-24 07:55:00 +00001857 if (oi->type == OSPF_IFTYPE_POINTOPOINT)
1858 vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
1859 else if (oi->type == OSPF_IFTYPE_BROADCAST)
1860 vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
1861
hasso049207c2004-08-04 20:02:13 +00001862 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001863 }
1864 return 0;
1865}
1866
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001867static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001868{
1869 INTERFACE_NODE,
1870 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001871 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001872};
1873
1874void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001875ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001876{
1877 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001878 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001879
1880 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001881 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1882 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1883 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001884 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001885 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1886 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1887 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001888
hasso508e53e2004-05-18 18:57:06 +00001889 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001890 install_default (INTERFACE_NODE);
1891 install_element (INTERFACE_NODE, &interface_desc_cmd);
1892 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1893 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
Vincent Bernatc19543b2012-10-24 14:45:53 +00001894 install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001895 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001896 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001897 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1898 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1899 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1900 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1901 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1902 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001903
paul718e3742002-12-13 20:15:29 +00001904 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1905 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001906
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001907 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1908 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1909
hasso508e53e2004-05-18 18:57:06 +00001910 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1911 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
Dinesh Duttc5926a92013-08-24 07:55:00 +00001912
1913 install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
1914 install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
Vincent Bernatfd500682012-10-24 14:45:54 +00001915
1916 /* reference bandwidth commands */
1917 install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
1918 install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
hasso508e53e2004-05-18 18:57:06 +00001919}
1920
Vipin Kumare87f8082015-05-19 18:03:40 -07001921/* Clear the specified interface structure */
1922static void
1923ospf6_interface_clear (struct vty *vty, struct interface *ifp)
1924{
1925 struct ospf6_interface *oi;
1926
1927 if (!if_is_operative (ifp))
1928 return;
1929
1930 if (ifp->info == NULL)
1931 return;
1932
1933 oi = (struct ospf6_interface *) ifp->info;
1934
1935 if (IS_OSPF6_DEBUG_INTERFACE)
1936 zlog_debug ("Interface %s: clear by reset", ifp->name);
1937
1938 /* Reset the interface */
1939 thread_add_event (master, interface_down, oi, 0);
1940 thread_add_event (master, interface_up, oi, 0);
1941}
1942
1943/* Clear interface */
1944DEFUN (clear_ipv6_ospf6_interface,
1945 clear_ipv6_ospf6_interface_cmd,
1946 "clear ipv6 ospf6 interface [IFNAME]",
1947 CLEAR_STR
1948 IP6_STR
1949 OSPF6_STR
1950 INTERFACE_STR
1951 IFNAME_STR
1952 )
1953{
1954 struct interface *ifp;
1955 struct listnode *node;
1956
1957 if (argc == 0) /* Clear all the ospfv3 interfaces. */
1958 {
1959 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
1960 ospf6_interface_clear (vty, ifp);
1961 }
1962 else /* Interface name is specified. */
1963 {
1964 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
1965 {
1966 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
1967 return CMD_WARNING;
1968 }
1969 ospf6_interface_clear (vty, ifp);
1970 }
1971
1972 return CMD_SUCCESS;
1973}
1974
1975void
1976install_element_ospf6_clear_interface (void)
1977{
1978 install_element (ENABLE_NODE, &clear_ipv6_ospf6_interface_cmd);
1979}
1980
hasso508e53e2004-05-18 18:57:06 +00001981DEFUN (debug_ospf6_interface,
1982 debug_ospf6_interface_cmd,
1983 "debug ospf6 interface",
1984 DEBUG_STR
1985 OSPF6_STR
1986 "Debug OSPFv3 Interface\n"
1987 )
1988{
1989 OSPF6_DEBUG_INTERFACE_ON ();
1990 return CMD_SUCCESS;
1991}
1992
1993DEFUN (no_debug_ospf6_interface,
1994 no_debug_ospf6_interface_cmd,
1995 "no debug ospf6 interface",
1996 NO_STR
1997 DEBUG_STR
1998 OSPF6_STR
1999 "Debug OSPFv3 Interface\n"
2000 )
2001{
hasso3b687352004-08-19 06:56:53 +00002002 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00002003 return CMD_SUCCESS;
2004}
2005
2006int
2007config_write_ospf6_debug_interface (struct vty *vty)
2008{
2009 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00002010 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00002011 return 0;
2012}
2013
2014void
Paul Jakma6ac29a52008-08-15 13:45:30 +01002015install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00002016{
2017 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
2018 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
2019 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
2020 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00002021}
2022
2023