blob: fa6509f40ea0edc38a5de6e4e920895839823d02 [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
paul718e3742002-12-13 20:15:29 +0000343ospf6_interface_state_update (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;
hasso508e53e2004-05-18 18:57:06 +0000350 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000351 return;
Christian Franked9628722013-03-08 21:47:35 +0100352 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
353 return;
paul718e3742002-12-13 20:15:29 +0000354
Christian Frankeb13c1d92012-12-13 16:11:16 +0100355 if (if_is_operative (ifp)
356 && (ospf6_interface_get_linklocal_address(oi->interface)
357 || if_is_loopback(oi->interface)))
hasso508e53e2004-05-18 18:57:06 +0000358 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000359 else
hasso508e53e2004-05-18 18:57:06 +0000360 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000361
362 return;
363}
364
365void
hasso508e53e2004-05-18 18:57:06 +0000366ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000367{
hasso508e53e2004-05-18 18:57:06 +0000368 struct ospf6_interface *oi;
369 struct ospf6_route *route;
370 struct connected *c;
paul1eb8ef22005-04-07 07:30:20 +0000371 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +0000372
hasso508e53e2004-05-18 18:57:06 +0000373 oi = (struct ospf6_interface *) ifp->info;
374 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000375 return;
376
377 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000378 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000379
hasso508e53e2004-05-18 18:57:06 +0000380 /* if area is null, do not make connected-route list */
381 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000382 return;
383
Christian Franked9628722013-03-08 21:47:35 +0100384 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
385 return;
386
hasso508e53e2004-05-18 18:57:06 +0000387 /* update "route to advertise" interface route table */
388 ospf6_route_remove_all (oi->route_connected);
hasso508e53e2004-05-18 18:57:06 +0000389
paul1eb8ef22005-04-07 07:30:20 +0000390 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
391 {
hasso508e53e2004-05-18 18:57:06 +0000392 if (c->address->family != AF_INET6)
393 continue;
394
hasso1e058382004-09-01 21:36:14 +0000395 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
396 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
397 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
398 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
399 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000400
401 /* apply filter */
402 if (oi->plist_name)
403 {
404 struct prefix_list *plist;
405 enum prefix_list_type ret;
406 char buf[128];
407
408 prefix2str (c->address, buf, sizeof (buf));
409 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
410 ret = prefix_list_apply (plist, (void *) c->address);
411 if (ret == PREFIX_DENY)
412 {
hasso1e058382004-09-01 21:36:14 +0000413 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000414 zlog_debug ("%s on %s filtered by prefix-list %s ",
415 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000416 continue;
417 }
418 }
419
420 route = ospf6_route_create ();
421 memcpy (&route->prefix, c->address, sizeof (struct prefix));
422 apply_mask (&route->prefix);
423 route->type = OSPF6_DEST_TYPE_NETWORK;
424 route->path.area_id = oi->area->area_id;
425 route->path.type = OSPF6_PATH_TYPE_INTRA;
426 route->path.cost = oi->cost;
427 route->nexthop[0].ifindex = oi->interface->ifindex;
428 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
429 ospf6_route_add (route, oi->route_connected);
430 }
431
paul718e3742002-12-13 20:15:29 +0000432 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000433 OSPF6_LINK_LSA_SCHEDULE (oi);
434 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
435 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000436}
437
hasso508e53e2004-05-18 18:57:06 +0000438static void
439ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000440{
hasso508e53e2004-05-18 18:57:06 +0000441 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000442
hasso508e53e2004-05-18 18:57:06 +0000443 prev_state = oi->state;
444 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000445
hasso508e53e2004-05-18 18:57:06 +0000446 if (prev_state == next_state)
447 return;
paul718e3742002-12-13 20:15:29 +0000448
hasso508e53e2004-05-18 18:57:06 +0000449 /* log */
450 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000451 {
hassoc6487d62004-12-24 06:00:11 +0000452 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
453 ospf6_interface_state_str[prev_state],
454 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000455 }
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200456 oi->state_change++;
paul718e3742002-12-13 20:15:29 +0000457
hasso508e53e2004-05-18 18:57:06 +0000458 if ((prev_state == OSPF6_INTERFACE_DR ||
459 prev_state == OSPF6_INTERFACE_BDR) &&
460 (next_state != OSPF6_INTERFACE_DR &&
461 next_state != OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400462 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
Dinesh Duttc5926a92013-08-24 07:55:00 +0000463
hasso508e53e2004-05-18 18:57:06 +0000464 if ((prev_state != OSPF6_INTERFACE_DR &&
465 prev_state != OSPF6_INTERFACE_BDR) &&
466 (next_state == OSPF6_INTERFACE_DR ||
467 next_state == OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400468 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
paul718e3742002-12-13 20:15:29 +0000469
hasso508e53e2004-05-18 18:57:06 +0000470 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000471 if (next_state == OSPF6_INTERFACE_DOWN)
472 {
473 OSPF6_NETWORK_LSA_EXECUTE (oi);
474 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
475 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
476 }
477 else if (prev_state == OSPF6_INTERFACE_DR ||
478 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000479 {
hasso508e53e2004-05-18 18:57:06 +0000480 OSPF6_NETWORK_LSA_SCHEDULE (oi);
481 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
482 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000483 }
Vincent Bernatbf836662012-06-04 14:36:12 +0200484
485#ifdef HAVE_SNMP
486 /* Terminal state or regression */
487 if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
488 (next_state == OSPF6_INTERFACE_DROTHER) ||
489 (next_state == OSPF6_INTERFACE_BDR) ||
490 (next_state == OSPF6_INTERFACE_DR) ||
491 (next_state < prev_state))
492 ospf6TrapIfStateChange (oi);
493#endif
494
hasso508e53e2004-05-18 18:57:06 +0000495}
496
David Lamparter6b0655a2014-06-04 06:53:35 +0200497
hasso508e53e2004-05-18 18:57:06 +0000498/* DR Election, RFC2328 section 9.4 */
499
500#define IS_ELIGIBLE(n) \
501 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
502
503static struct ospf6_neighbor *
504better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
505{
506 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
507 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
508 return NULL;
509 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
510 return b;
511 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
512 return a;
513
514 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
515 return a;
516 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
517 return b;
518
519 if (a->priority > b->priority)
520 return a;
521 if (a->priority < b->priority)
522 return b;
523
524 if (ntohl (a->router_id) > ntohl (b->router_id))
525 return a;
526 if (ntohl (a->router_id) < ntohl (b->router_id))
527 return b;
528
529 zlog_warn ("Router-ID duplicate ?");
530 return a;
531}
532
533static struct ospf6_neighbor *
534better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
535{
536 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
537 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
538 return NULL;
539 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
540 return b;
541 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
542 return a;
543
544 if (a->drouter == a->router_id && b->drouter != b->router_id)
545 return a;
546 if (a->drouter != a->router_id && b->drouter == b->router_id)
547 return b;
548
549 if (a->priority > b->priority)
550 return a;
551 if (a->priority < b->priority)
552 return b;
553
554 if (ntohl (a->router_id) > ntohl (b->router_id))
555 return a;
556 if (ntohl (a->router_id) < ntohl (b->router_id))
557 return b;
558
559 zlog_warn ("Router-ID duplicate ?");
560 return a;
561}
562
563static u_char
564dr_election (struct ospf6_interface *oi)
565{
paul1eb8ef22005-04-07 07:30:20 +0000566 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000567 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
568 struct ospf6_neighbor *best_drouter, *best_bdrouter;
569 u_char next_state = 0;
570
571 drouter = bdrouter = NULL;
572 best_drouter = best_bdrouter = NULL;
573
574 /* pseudo neighbor myself, including noting current DR/BDR (1) */
575 memset (&myself, 0, sizeof (myself));
576 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
577 sizeof (myself.name));
578 myself.state = OSPF6_NEIGHBOR_TWOWAY;
579 myself.drouter = oi->drouter;
580 myself.bdrouter = oi->bdrouter;
581 myself.priority = oi->priority;
582 myself.router_id = oi->area->ospf6->router_id;
583
584 /* Electing BDR (2) */
paul1eb8ef22005-04-07 07:30:20 +0000585 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
586 bdrouter = better_bdrouter (bdrouter, on);
587
hasso508e53e2004-05-18 18:57:06 +0000588 best_bdrouter = bdrouter;
589 bdrouter = better_bdrouter (best_bdrouter, &myself);
590
591 /* Electing DR (3) */
paul1eb8ef22005-04-07 07:30:20 +0000592 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
593 drouter = better_drouter (drouter, on);
594
hasso508e53e2004-05-18 18:57:06 +0000595 best_drouter = drouter;
596 drouter = better_drouter (best_drouter, &myself);
597 if (drouter == NULL)
598 drouter = bdrouter;
599
600 /* the router itself is newly/no longer DR/BDR (4) */
601 if ((drouter == &myself && myself.drouter != myself.router_id) ||
602 (drouter != &myself && myself.drouter == myself.router_id) ||
603 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
604 (bdrouter != &myself && myself.bdrouter == myself.router_id))
605 {
606 myself.drouter = (drouter ? drouter->router_id : htonl (0));
607 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
608
609 /* compatible to Electing BDR (2) */
610 bdrouter = better_bdrouter (best_bdrouter, &myself);
611
612 /* compatible to Electing DR (3) */
613 drouter = better_drouter (best_drouter, &myself);
614 if (drouter == NULL)
615 drouter = bdrouter;
616 }
617
618 /* Set interface state accordingly (5) */
619 if (drouter && drouter == &myself)
620 next_state = OSPF6_INTERFACE_DR;
621 else if (bdrouter && bdrouter == &myself)
622 next_state = OSPF6_INTERFACE_BDR;
623 else
624 next_state = OSPF6_INTERFACE_DROTHER;
625
626 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
627 /* XXX */
628
629 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
630 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
631 accordingly after AdjOK */
632 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
633 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
634 {
635 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000636 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
637 (drouter ? drouter->name : "0.0.0.0"),
638 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000639
paul1eb8ef22005-04-07 07:30:20 +0000640 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
hasso508e53e2004-05-18 18:57:06 +0000641 {
hasso508e53e2004-05-18 18:57:06 +0000642 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
643 continue;
644 /* Schedule AdjOK. */
645 thread_add_event (master, adj_ok, on, 0);
646 }
647 }
648
649 oi->drouter = (drouter ? drouter->router_id : htonl (0));
650 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
651 return next_state;
652}
653
David Lamparter6b0655a2014-06-04 06:53:35 +0200654
hasso508e53e2004-05-18 18:57:06 +0000655/* Interface State Machine */
656int
657interface_up (struct thread *thread)
658{
659 struct ospf6_interface *oi;
660
661 oi = (struct ospf6_interface *) THREAD_ARG (thread);
662 assert (oi && oi->interface);
663
664 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000665 zlog_debug ("Interface Event %s: [InterfaceUp]",
666 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000667
668 /* check physical interface is up */
Dinesh Dutte7ad6b22013-08-24 07:55:57 +0000669 if (! if_is_operative (oi->interface))
hasso508e53e2004-05-18 18:57:06 +0000670 {
671 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000672 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
673 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000674 return 0;
675 }
676
Christian Frankeb13c1d92012-12-13 16:11:16 +0100677 /* check interface has a link-local address */
678 if (! (ospf6_interface_get_linklocal_address(oi->interface)
679 || if_is_loopback(oi->interface)))
680 {
681 if (IS_OSPF6_DEBUG_INTERFACE)
682 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
683 oi->interface->name);
Paul Jakma5bc62ca2016-07-11 16:21:23 +0100684 return 0;
Christian Frankeb13c1d92012-12-13 16:11:16 +0100685 }
686
Vincent Bernatc19543b2012-10-24 14:45:53 +0000687 /* Recompute cost */
688 ospf6_interface_recalculate_cost (oi);
689
hasso508e53e2004-05-18 18:57:06 +0000690 /* if already enabled, do nothing */
691 if (oi->state > OSPF6_INTERFACE_DOWN)
692 {
693 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000694 zlog_debug ("Interface %s already enabled",
695 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000696 return 0;
697 }
698
Dinesh Duttba960d52013-08-26 03:40:37 +0000699 /* If no area assigned, return */
700 if (oi->area == NULL)
701 {
702 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__,
703 oi->interface->name);
704 return 0;
705 }
706
hasso508e53e2004-05-18 18:57:06 +0000707 /* Join AllSPFRouters */
Vipin Kumarcb37de42015-05-19 18:03:40 -0700708 if (ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP) < 0)
709 {
710 if (oi->sso_try_cnt++ < OSPF6_INTERFACE_SSO_RETRY_MAX)
711 {
712 zlog_info("Scheduling %s for sso retry, trial count: %d",
713 oi->interface->name, oi->sso_try_cnt);
714 thread_add_timer (master, interface_up, oi,
715 OSPF6_INTERFACE_SSO_RETRY_INT);
716 }
717 return 0;
718 }
719 oi->sso_try_cnt = 0; /* Reset on success */
hasso508e53e2004-05-18 18:57:06 +0000720
721 /* Update interface route */
722 ospf6_interface_connected_route_update (oi->interface);
723
724 /* Schedule Hello */
725 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
David Lamparter424cc3b2013-11-23 16:55:36 +0100726 oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
hasso508e53e2004-05-18 18:57:06 +0000727
728 /* decide next interface state */
Dinesh Duttc5926a92013-08-24 07:55:00 +0000729 if ((if_is_pointopoint (oi->interface)) ||
730 (oi->type == OSPF_IFTYPE_POINTOPOINT)) {
hasso508e53e2004-05-18 18:57:06 +0000731 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
Dinesh Duttc5926a92013-08-24 07:55:00 +0000732 }
hasso508e53e2004-05-18 18:57:06 +0000733 else if (oi->priority == 0)
734 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
735 else
736 {
737 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
738 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
739 }
740
741 return 0;
paul718e3742002-12-13 20:15:29 +0000742}
743
744int
hasso508e53e2004-05-18 18:57:06 +0000745wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000746{
hasso508e53e2004-05-18 18:57:06 +0000747 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000748
hasso508e53e2004-05-18 18:57:06 +0000749 oi = (struct ospf6_interface *) THREAD_ARG (thread);
750 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000751
hasso508e53e2004-05-18 18:57:06 +0000752 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000753 zlog_debug ("Interface Event %s: [WaitTimer]",
754 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000755
hasso508e53e2004-05-18 18:57:06 +0000756 if (oi->state == OSPF6_INTERFACE_WAITING)
757 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000758
hasso508e53e2004-05-18 18:57:06 +0000759 return 0;
paul718e3742002-12-13 20:15:29 +0000760}
761
hasso508e53e2004-05-18 18:57:06 +0000762int
763backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000764{
hasso508e53e2004-05-18 18:57:06 +0000765 struct ospf6_interface *oi;
766
767 oi = (struct ospf6_interface *) THREAD_ARG (thread);
768 assert (oi && oi->interface);
769
770 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000771 zlog_debug ("Interface Event %s: [BackupSeen]",
772 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000773
774 if (oi->state == OSPF6_INTERFACE_WAITING)
775 ospf6_interface_state_change (dr_election (oi), oi);
776
777 return 0;
paul718e3742002-12-13 20:15:29 +0000778}
779
hasso508e53e2004-05-18 18:57:06 +0000780int
781neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000782{
hasso508e53e2004-05-18 18:57:06 +0000783 struct ospf6_interface *oi;
784
785 oi = (struct ospf6_interface *) THREAD_ARG (thread);
786 assert (oi && oi->interface);
787
788 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000789 zlog_debug ("Interface Event %s: [NeighborChange]",
790 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000791
792 if (oi->state == OSPF6_INTERFACE_DROTHER ||
793 oi->state == OSPF6_INTERFACE_BDR ||
794 oi->state == OSPF6_INTERFACE_DR)
795 ospf6_interface_state_change (dr_election (oi), oi);
796
797 return 0;
paul718e3742002-12-13 20:15:29 +0000798}
799
hasso508e53e2004-05-18 18:57:06 +0000800int
801interface_down (struct thread *thread)
802{
803 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000804 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000805 struct ospf6_neighbor *on;
806
807 oi = (struct ospf6_interface *) THREAD_ARG (thread);
808 assert (oi && oi->interface);
809
810 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000811 zlog_debug ("Interface Event %s: [InterfaceDown]",
812 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000813
David Lamparter424cc3b2013-11-23 16:55:36 +0100814 /* Stop Hellos */
815 THREAD_OFF (oi->thread_send_hello);
816
hasso508e53e2004-05-18 18:57:06 +0000817 /* Leave AllSPFRouters */
818 if (oi->state > OSPF6_INTERFACE_DOWN)
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400819 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000820
821 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
822
paul1eb8ef22005-04-07 07:30:20 +0000823 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
824 ospf6_neighbor_delete (on);
825
hasso508e53e2004-05-18 18:57:06 +0000826 list_delete_all_node (oi->neighbor_list);
827
Christian Franke37531a72012-12-13 13:50:28 +0100828 /* When interface state is reset, also reset information about
829 * DR election, as it is no longer valid. */
830 oi->drouter = oi->prev_drouter = htonl(0);
831 oi->bdrouter = oi->prev_bdrouter = htonl(0);
hasso508e53e2004-05-18 18:57:06 +0000832 return 0;
833}
834
David Lamparter6b0655a2014-06-04 06:53:35 +0200835
paul718e3742002-12-13 20:15:29 +0000836/* show specified interface structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100837static int
hasso508e53e2004-05-18 18:57:06 +0000838ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000839{
hasso508e53e2004-05-18 18:57:06 +0000840 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000841 struct connected *c;
842 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000843 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000844 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000845 const char *updown[3] = {"down", "up", NULL};
846 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000847 struct timeval res, now;
848 char duration[32];
849 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000850
851 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000852 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000853 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000854 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000855 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000856 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000857 type = "POINTOPOINT";
858 else
859 type = "UNKNOWN";
860
861 vty_out (vty, "%s is %s, type %s%s",
Dinesh Dutte7ad6b22013-08-24 07:55:57 +0000862 ifp->name, updown[if_is_operative (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000863 VNL);
864 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000865
hasso508e53e2004-05-18 18:57:06 +0000866 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000867 {
hasso049207c2004-08-04 20:02:13 +0000868 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000869 return 0;
870 }
871 else
hasso508e53e2004-05-18 18:57:06 +0000872 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000873
hasso049207c2004-08-04 20:02:13 +0000874 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000875
876 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000877 {
paul718e3742002-12-13 20:15:29 +0000878 p = c->address;
879 prefix2str (p, strbuf, sizeof (strbuf));
880 switch (p->family)
881 {
882 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000883 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000884 VNL);
paul718e3742002-12-13 20:15:29 +0000885 break;
886 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000887 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000888 VNL);
paul718e3742002-12-13 20:15:29 +0000889 break;
890 default:
hasso508e53e2004-05-18 18:57:06 +0000891 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000892 VNL);
paul718e3742002-12-13 20:15:29 +0000893 break;
894 }
895 }
896
hasso508e53e2004-05-18 18:57:06 +0000897 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000898 {
hasso508e53e2004-05-18 18:57:06 +0000899 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000900 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400901 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
902 "disabled" : "enabled", VNL);
hasso508e53e2004-05-18 18:57:06 +0000903 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000904 strbuf, sizeof (strbuf));
David Lamparter72c69d42015-03-03 09:08:20 +0100905 vty_out (vty, " Area ID %s, Cost %u%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000906 VNL);
paul718e3742002-12-13 20:15:29 +0000907 }
908 else
hasso049207c2004-08-04 20:02:13 +0000909 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000910
911 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000912 ospf6_interface_state_str[oi->state],
913 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000914 VNL);
915 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000916 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000917 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000918 VNL);
paul718e3742002-12-13 20:15:29 +0000919
hasso508e53e2004-05-18 18:57:06 +0000920 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
921 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000922 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000923
924 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000925 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000926
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900927 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
paul718e3742002-12-13 20:15:29 +0000928
hasso508e53e2004-05-18 18:57:06 +0000929 timerclear (&res);
930 if (oi->thread_send_lsupdate)
931 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
932 timerstring (&res, duration, sizeof (duration));
933 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
934 oi->lsupdate_list->count, duration,
935 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000936 VNL);
hasso508e53e2004-05-18 18:57:06 +0000937 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
938 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000939 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000940
hasso508e53e2004-05-18 18:57:06 +0000941 timerclear (&res);
942 if (oi->thread_send_lsack)
943 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
944 timerstring (&res, duration, sizeof (duration));
945 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
946 oi->lsack_list->count, duration,
947 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000948 VNL);
hasso508e53e2004-05-18 18:57:06 +0000949 for (lsa = ospf6_lsdb_head (oi->lsack_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 return 0;
paul718e3742002-12-13 20:15:29 +0000954}
955
956/* show interface */
957DEFUN (show_ipv6_ospf6_interface,
958 show_ipv6_ospf6_interface_ifname_cmd,
959 "show ipv6 ospf6 interface IFNAME",
960 SHOW_STR
961 IP6_STR
962 OSPF6_STR
963 INTERFACE_STR
964 IFNAME_STR
965 )
966{
967 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000968 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000969
970 if (argc)
971 {
972 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000973 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000974 {
975 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000976 VNL);
paul718e3742002-12-13 20:15:29 +0000977 return CMD_WARNING;
978 }
979 ospf6_interface_show (vty, ifp);
980 }
981 else
982 {
paul1eb8ef22005-04-07 07:30:20 +0000983 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
984 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000985 }
hasso508e53e2004-05-18 18:57:06 +0000986
paul718e3742002-12-13 20:15:29 +0000987 return CMD_SUCCESS;
988}
989
990ALIAS (show_ipv6_ospf6_interface,
991 show_ipv6_ospf6_interface_cmd,
992 "show ipv6 ospf6 interface",
993 SHOW_STR
994 IP6_STR
995 OSPF6_STR
996 INTERFACE_STR
Paul Jakma6ac29a52008-08-15 13:45:30 +0100997 )
paul718e3742002-12-13 20:15:29 +0000998
hasso508e53e2004-05-18 18:57:06 +0000999DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
1000 show_ipv6_ospf6_interface_ifname_prefix_cmd,
1001 "show ipv6 ospf6 interface IFNAME prefix",
1002 SHOW_STR
paul718e3742002-12-13 20:15:29 +00001003 IP6_STR
1004 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001005 INTERFACE_STR
1006 IFNAME_STR
1007 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +00001008 )
1009{
paul718e3742002-12-13 20:15:29 +00001010 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +00001011 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001012
hasso508e53e2004-05-18 18:57:06 +00001013 ifp = if_lookup_by_name (argv[0]);
1014 if (ifp == NULL)
1015 {
hasso049207c2004-08-04 20:02:13 +00001016 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +00001017 return CMD_WARNING;
1018 }
paul718e3742002-12-13 20:15:29 +00001019
hasso508e53e2004-05-18 18:57:06 +00001020 oi = ifp->info;
1021 if (oi == NULL)
1022 {
hasso049207c2004-08-04 20:02:13 +00001023 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +00001024 return CMD_WARNING;
1025 }
paul718e3742002-12-13 20:15:29 +00001026
hasso508e53e2004-05-18 18:57:06 +00001027 argc--;
1028 argv++;
1029 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +00001030
1031 return CMD_SUCCESS;
1032}
1033
hasso508e53e2004-05-18 18:57:06 +00001034ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1035 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
1036 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1037 SHOW_STR
paul718e3742002-12-13 20:15:29 +00001038 IP6_STR
1039 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001040 INTERFACE_STR
1041 IFNAME_STR
1042 "Display connected prefixes to advertise\n"
1043 OSPF6_ROUTE_ADDRESS_STR
1044 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001045 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001046 )
hasso508e53e2004-05-18 18:57:06 +00001047
1048ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1049 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
1050 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1051 SHOW_STR
1052 IP6_STR
1053 OSPF6_STR
1054 INTERFACE_STR
1055 IFNAME_STR
1056 "Display connected prefixes to advertise\n"
1057 OSPF6_ROUTE_PREFIX_STR
1058 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001059 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001060 )
hasso508e53e2004-05-18 18:57:06 +00001061
1062DEFUN (show_ipv6_ospf6_interface_prefix,
1063 show_ipv6_ospf6_interface_prefix_cmd,
1064 "show ipv6 ospf6 interface prefix",
1065 SHOW_STR
1066 IP6_STR
1067 OSPF6_STR
1068 INTERFACE_STR
1069 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +00001070 )
1071{
hasso52dc7ee2004-09-23 19:18:23 +00001072 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001073 struct ospf6_interface *oi;
1074 struct interface *ifp;
1075
paul1eb8ef22005-04-07 07:30:20 +00001076 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +00001077 {
hasso508e53e2004-05-18 18:57:06 +00001078 oi = (struct ospf6_interface *) ifp->info;
1079 if (oi == NULL)
1080 continue;
1081
1082 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1083 }
1084
1085 return CMD_SUCCESS;
1086}
1087
1088ALIAS (show_ipv6_ospf6_interface_prefix,
1089 show_ipv6_ospf6_interface_prefix_detail_cmd,
1090 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1091 SHOW_STR
1092 IP6_STR
1093 OSPF6_STR
1094 INTERFACE_STR
1095 "Display connected prefixes to advertise\n"
1096 OSPF6_ROUTE_ADDRESS_STR
1097 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001098 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001099 )
hasso508e53e2004-05-18 18:57:06 +00001100
1101ALIAS (show_ipv6_ospf6_interface_prefix,
1102 show_ipv6_ospf6_interface_prefix_match_cmd,
1103 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1104 SHOW_STR
1105 IP6_STR
1106 OSPF6_STR
1107 INTERFACE_STR
1108 "Display connected prefixes to advertise\n"
1109 OSPF6_ROUTE_PREFIX_STR
1110 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001111 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001112 )
hasso508e53e2004-05-18 18:57:06 +00001113
1114
1115/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001116DEFUN (ipv6_ospf6_ifmtu,
1117 ipv6_ospf6_ifmtu_cmd,
1118 "ipv6 ospf6 ifmtu <1-65535>",
1119 IP6_STR
1120 OSPF6_STR
1121 "Interface MTU\n"
1122 "OSPFv3 Interface MTU\n"
1123 )
1124{
1125 struct ospf6_interface *oi;
1126 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001127 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001128 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001129 struct ospf6_neighbor *on;
1130
1131 ifp = (struct interface *) vty->index;
1132 assert (ifp);
1133
1134 oi = (struct ospf6_interface *) ifp->info;
1135 if (oi == NULL)
1136 oi = ospf6_interface_create (ifp);
1137 assert (oi);
1138
1139 ifmtu = strtol (argv[0], NULL, 10);
1140
1141 if (oi->ifmtu == ifmtu)
1142 return CMD_SUCCESS;
1143
hasso1203e1c2004-07-23 21:34:27 +00001144 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001145 {
1146 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001147 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001148 return CMD_WARNING;
1149 }
1150
1151 if (oi->ifmtu < ifmtu)
1152 {
1153 iobuflen = ospf6_iobuf_size (ifmtu);
1154 if (iobuflen < ifmtu)
1155 {
1156 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001157 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001158 oi->ifmtu = iobuflen;
1159 }
1160 else
1161 oi->ifmtu = ifmtu;
1162 }
1163 else
1164 oi->ifmtu = ifmtu;
1165
1166 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001167 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001168 {
hassob596c712004-07-09 18:33:43 +00001169 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001170 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001171 }
1172
1173 return CMD_SUCCESS;
1174}
1175
hasso049207c2004-08-04 20:02:13 +00001176DEFUN (no_ipv6_ospf6_ifmtu,
1177 no_ipv6_ospf6_ifmtu_cmd,
1178 "no ipv6 ospf6 ifmtu",
1179 NO_STR
1180 IP6_STR
1181 OSPF6_STR
1182 "Interface MTU\n"
1183 )
1184{
1185 struct ospf6_interface *oi;
1186 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001187 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001188 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001189 struct ospf6_neighbor *on;
1190
1191 ifp = (struct interface *) vty->index;
1192 assert (ifp);
1193
1194 oi = (struct ospf6_interface *) ifp->info;
1195 if (oi == NULL)
1196 oi = ospf6_interface_create (ifp);
1197 assert (oi);
1198
1199 if (oi->ifmtu < ifp->mtu)
1200 {
1201 iobuflen = ospf6_iobuf_size (ifp->mtu);
1202 if (iobuflen < ifp->mtu)
1203 {
1204 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1205 ifp->name, iobuflen, VNL);
1206 oi->ifmtu = iobuflen;
1207 }
1208 else
1209 oi->ifmtu = ifp->mtu;
1210 }
1211 else
1212 oi->ifmtu = ifp->mtu;
1213
1214 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001215 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001216 {
hasso049207c2004-08-04 20:02:13 +00001217 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001218 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001219 }
1220
1221 return CMD_SUCCESS;
1222}
1223
hasso508e53e2004-05-18 18:57:06 +00001224DEFUN (ipv6_ospf6_cost,
1225 ipv6_ospf6_cost_cmd,
1226 "ipv6 ospf6 cost <1-65535>",
1227 IP6_STR
1228 OSPF6_STR
1229 "Interface cost\n"
1230 "Outgoing metric of this interface\n"
1231 )
1232{
1233 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001234 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001235 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001236
1237 ifp = (struct interface *) vty->index;
1238 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001239
hasso508e53e2004-05-18 18:57:06 +00001240 oi = (struct ospf6_interface *) ifp->info;
1241 if (oi == NULL)
1242 oi = ospf6_interface_create (ifp);
1243 assert (oi);
1244
paul0c083ee2004-10-10 12:54:58 +00001245 lcost = strtol (argv[0], NULL, 10);
1246
1247 if (lcost > UINT32_MAX)
1248 {
1249 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1250 return CMD_WARNING;
1251 }
1252
1253 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001254 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001255
1256 oi->cost = lcost;
Vincent Bernatc19543b2012-10-24 14:45:53 +00001257 SET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
hasso508e53e2004-05-18 18:57:06 +00001258
Vincent Bernatc19543b2012-10-24 14:45:53 +00001259 ospf6_interface_recalculate_cost(oi);
1260
1261 return CMD_SUCCESS;
1262}
1263
1264DEFUN (no_ipv6_ospf6_cost,
1265 no_ipv6_ospf6_cost_cmd,
1266 "no ipv6 ospf6 cost",
1267 NO_STR
1268 IP6_STR
1269 OSPF6_STR
1270 "Calculate interface cost from bandwidth\n"
1271 )
1272{
1273 struct ospf6_interface *oi;
1274 struct interface *ifp;
Vincent Bernatc19543b2012-10-24 14:45:53 +00001275
1276 ifp = (struct interface *) vty->index;
1277 assert (ifp);
1278
1279 oi = (struct ospf6_interface *) ifp->info;
1280 if (oi == NULL)
1281 oi = ospf6_interface_create (ifp);
1282 assert (oi);
1283
1284 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1285
1286 ospf6_interface_recalculate_cost(oi);
hasso508e53e2004-05-18 18:57:06 +00001287
1288 return CMD_SUCCESS;
1289}
1290
Vincent Bernatfd500682012-10-24 14:45:54 +00001291DEFUN (auto_cost_reference_bandwidth,
1292 auto_cost_reference_bandwidth_cmd,
1293 "auto-cost reference-bandwidth <1-4294967>",
1294 "Calculate OSPF interface cost according to bandwidth\n"
1295 "Use reference bandwidth method to assign OSPF cost\n"
1296 "The reference bandwidth in terms of Mbits per second\n")
1297{
1298 struct ospf6 *o = vty->index;
1299 struct ospf6_area *oa;
1300 struct ospf6_interface *oi;
1301 struct listnode *i, *j;
1302 u_int32_t refbw;
1303
1304 refbw = strtol (argv[0], NULL, 10);
1305 if (refbw < 1 || refbw > 4294967)
1306 {
1307 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
1308 return CMD_WARNING;
1309 }
1310
1311 /* If reference bandwidth is changed. */
1312 if ((refbw * 1000) == o->ref_bandwidth)
1313 return CMD_SUCCESS;
1314
1315 o->ref_bandwidth = refbw * 1000;
1316 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1317 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1318 ospf6_interface_recalculate_cost (oi);
1319
1320 return CMD_SUCCESS;
1321}
1322
1323DEFUN (no_auto_cost_reference_bandwidth,
1324 no_auto_cost_reference_bandwidth_cmd,
1325 "no auto-cost reference-bandwidth",
1326 NO_STR
1327 "Calculate OSPF interface cost according to bandwidth\n"
1328 "Use reference bandwidth method to assign OSPF cost\n")
1329{
1330 struct ospf6 *o = vty->index;
1331 struct ospf6_area *oa;
1332 struct ospf6_interface *oi;
1333 struct listnode *i, *j;
1334
1335 if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
1336 return CMD_SUCCESS;
1337
1338 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
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
hasso508e53e2004-05-18 18:57:06 +00001346DEFUN (ipv6_ospf6_hellointerval,
1347 ipv6_ospf6_hellointerval_cmd,
1348 "ipv6 ospf6 hello-interval <1-65535>",
1349 IP6_STR
1350 OSPF6_STR
1351 "Interval time of Hello packets\n"
1352 SECONDS_STR
1353 )
1354{
1355 struct ospf6_interface *oi;
1356 struct interface *ifp;
1357
1358 ifp = (struct interface *) vty->index;
1359 assert (ifp);
1360
1361 oi = (struct ospf6_interface *) ifp->info;
1362 if (oi == NULL)
1363 oi = ospf6_interface_create (ifp);
1364 assert (oi);
1365
1366 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001367 return CMD_SUCCESS;
1368}
1369
1370/* interface variable set command */
1371DEFUN (ipv6_ospf6_deadinterval,
1372 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001373 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001374 IP6_STR
1375 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001376 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001377 SECONDS_STR
1378 )
1379{
hasso508e53e2004-05-18 18:57:06 +00001380 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001381 struct interface *ifp;
1382
1383 ifp = (struct interface *) vty->index;
1384 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001385
hasso508e53e2004-05-18 18:57:06 +00001386 oi = (struct ospf6_interface *) ifp->info;
1387 if (oi == NULL)
1388 oi = ospf6_interface_create (ifp);
1389 assert (oi);
1390
1391 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001392 return CMD_SUCCESS;
1393}
1394
1395/* interface variable set command */
1396DEFUN (ipv6_ospf6_transmitdelay,
1397 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001398 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001399 IP6_STR
1400 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001401 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001402 SECONDS_STR
1403 )
1404{
hasso508e53e2004-05-18 18:57:06 +00001405 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001406 struct interface *ifp;
1407
1408 ifp = (struct interface *) vty->index;
1409 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001410
hasso508e53e2004-05-18 18:57:06 +00001411 oi = (struct ospf6_interface *) ifp->info;
1412 if (oi == NULL)
1413 oi = ospf6_interface_create (ifp);
1414 assert (oi);
1415
1416 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001417 return CMD_SUCCESS;
1418}
1419
1420/* interface variable set command */
1421DEFUN (ipv6_ospf6_retransmitinterval,
1422 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001423 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001424 IP6_STR
1425 OSPF6_STR
1426 "Time between retransmitting lost link state advertisements\n"
1427 SECONDS_STR
1428 )
1429{
hasso508e53e2004-05-18 18:57:06 +00001430 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001431 struct interface *ifp;
1432
1433 ifp = (struct interface *) vty->index;
1434 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001435
hasso508e53e2004-05-18 18:57:06 +00001436 oi = (struct ospf6_interface *) ifp->info;
1437 if (oi == NULL)
1438 oi = ospf6_interface_create (ifp);
1439 assert (oi);
1440
1441 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001442 return CMD_SUCCESS;
1443}
1444
1445/* interface variable set command */
1446DEFUN (ipv6_ospf6_priority,
1447 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001448 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001449 IP6_STR
1450 OSPF6_STR
1451 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001452 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001453 )
1454{
hasso508e53e2004-05-18 18:57:06 +00001455 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001456 struct interface *ifp;
1457
1458 ifp = (struct interface *) vty->index;
1459 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001460
hasso508e53e2004-05-18 18:57:06 +00001461 oi = (struct ospf6_interface *) ifp->info;
1462 if (oi == NULL)
1463 oi = ospf6_interface_create (ifp);
1464 assert (oi);
paul718e3742002-12-13 20:15:29 +00001465
hasso508e53e2004-05-18 18:57:06 +00001466 oi->priority = strtol (argv[0], NULL, 10);
1467
Christian Franke7d4aa1d2012-12-13 16:10:05 +01001468 if (oi->area &&
1469 (oi->state == OSPF6_INTERFACE_DROTHER ||
1470 oi->state == OSPF6_INTERFACE_BDR ||
1471 oi->state == OSPF6_INTERFACE_DR))
hasso508e53e2004-05-18 18:57:06 +00001472 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001473
1474 return CMD_SUCCESS;
1475}
1476
1477DEFUN (ipv6_ospf6_instance,
1478 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001479 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001480 IP6_STR
1481 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001482 "Instance ID for this interface\n"
1483 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001484 )
1485{
hasso508e53e2004-05-18 18:57:06 +00001486 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001487 struct interface *ifp;
1488
1489 ifp = (struct interface *)vty->index;
1490 assert (ifp);
1491
hasso508e53e2004-05-18 18:57:06 +00001492 oi = (struct ospf6_interface *)ifp->info;
1493 if (oi == NULL)
1494 oi = ospf6_interface_create (ifp);
1495 assert (oi);
paul718e3742002-12-13 20:15:29 +00001496
hasso508e53e2004-05-18 18:57:06 +00001497 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001498 return CMD_SUCCESS;
1499}
1500
1501DEFUN (ipv6_ospf6_passive,
1502 ipv6_ospf6_passive_cmd,
1503 "ipv6 ospf6 passive",
1504 IP6_STR
1505 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001506 "passive interface, No adjacency will be formed on this interface\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;
paul1eb8ef22005-04-07 07:30:20 +00001511 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001512 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001513
1514 ifp = (struct interface *) vty->index;
1515 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001516
hasso508e53e2004-05-18 18:57:06 +00001517 oi = (struct ospf6_interface *) ifp->info;
1518 if (oi == NULL)
1519 oi = ospf6_interface_create (ifp);
1520 assert (oi);
paul718e3742002-12-13 20:15:29 +00001521
hasso508e53e2004-05-18 18:57:06 +00001522 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1523 THREAD_OFF (oi->thread_send_hello);
1524
paul1eb8ef22005-04-07 07:30:20 +00001525 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001526 {
hasso508e53e2004-05-18 18:57:06 +00001527 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001528 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001529 }
1530
1531 return CMD_SUCCESS;
1532}
1533
1534DEFUN (no_ipv6_ospf6_passive,
1535 no_ipv6_ospf6_passive_cmd,
1536 "no ipv6 ospf6 passive",
1537 NO_STR
1538 IP6_STR
1539 OSPF6_STR
1540 "passive interface: No Adjacency will be formed on this I/F\n"
1541 )
1542{
hasso508e53e2004-05-18 18:57:06 +00001543 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001544 struct interface *ifp;
1545
1546 ifp = (struct interface *) vty->index;
1547 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001548
hasso508e53e2004-05-18 18:57:06 +00001549 oi = (struct ospf6_interface *) ifp->info;
1550 if (oi == NULL)
1551 oi = ospf6_interface_create (ifp);
1552 assert (oi);
paul718e3742002-12-13 20:15:29 +00001553
hasso508e53e2004-05-18 18:57:06 +00001554 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1555 THREAD_OFF (oi->thread_send_hello);
1556 oi->thread_send_hello =
1557 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001558
1559 return CMD_SUCCESS;
1560}
1561
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001562DEFUN (ipv6_ospf6_mtu_ignore,
1563 ipv6_ospf6_mtu_ignore_cmd,
1564 "ipv6 ospf6 mtu-ignore",
1565 IP6_STR
1566 OSPF6_STR
1567 "Ignore MTU mismatch on this interface\n"
1568 )
1569{
1570 struct ospf6_interface *oi;
1571 struct interface *ifp;
1572
1573 ifp = (struct interface *) vty->index;
1574 assert (ifp);
1575
1576 oi = (struct ospf6_interface *) ifp->info;
1577 if (oi == NULL)
1578 oi = ospf6_interface_create (ifp);
1579 assert (oi);
1580
1581 oi->mtu_ignore = 1;
1582
1583 return CMD_SUCCESS;
1584}
1585
1586DEFUN (no_ipv6_ospf6_mtu_ignore,
1587 no_ipv6_ospf6_mtu_ignore_cmd,
1588 "no ipv6 ospf6 mtu-ignore",
1589 NO_STR
1590 IP6_STR
1591 OSPF6_STR
1592 "Ignore MTU mismatch on this interface\n"
1593 )
1594{
1595 struct ospf6_interface *oi;
1596 struct interface *ifp;
1597
1598 ifp = (struct interface *) vty->index;
1599 assert (ifp);
1600
1601 oi = (struct ospf6_interface *) ifp->info;
1602 if (oi == NULL)
1603 oi = ospf6_interface_create (ifp);
1604 assert (oi);
1605
1606 oi->mtu_ignore = 0;
1607
1608 return CMD_SUCCESS;
1609}
1610
paul718e3742002-12-13 20:15:29 +00001611DEFUN (ipv6_ospf6_advertise_prefix_list,
1612 ipv6_ospf6_advertise_prefix_list_cmd,
1613 "ipv6 ospf6 advertise prefix-list WORD",
1614 IP6_STR
1615 OSPF6_STR
1616 "Advertising options\n"
1617 "Filter prefix using prefix-list\n"
1618 "Prefix list name\n"
1619 )
1620{
hasso508e53e2004-05-18 18:57:06 +00001621 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001622 struct interface *ifp;
1623
1624 ifp = (struct interface *) vty->index;
1625 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001626
hasso508e53e2004-05-18 18:57:06 +00001627 oi = (struct ospf6_interface *) ifp->info;
1628 if (oi == NULL)
1629 oi = ospf6_interface_create (ifp);
1630 assert (oi);
paul718e3742002-12-13 20:15:29 +00001631
hasso508e53e2004-05-18 18:57:06 +00001632 if (oi->plist_name)
1633 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1634 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001635
hasso508e53e2004-05-18 18:57:06 +00001636 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001637
1638 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001639 {
David Ward2470e992010-01-05 02:45:39 +00001640 OSPF6_LINK_LSA_SCHEDULE (oi);
1641 if (oi->state == OSPF6_INTERFACE_DR)
1642 {
1643 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1644 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1645 }
1646 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001647 }
paul718e3742002-12-13 20:15:29 +00001648
1649 return CMD_SUCCESS;
1650}
1651
1652DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1653 no_ipv6_ospf6_advertise_prefix_list_cmd,
1654 "no ipv6 ospf6 advertise prefix-list",
1655 NO_STR
1656 IP6_STR
1657 OSPF6_STR
1658 "Advertising options\n"
1659 "Filter prefix using prefix-list\n"
1660 )
1661{
hasso508e53e2004-05-18 18:57:06 +00001662 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001663 struct interface *ifp;
1664
1665 ifp = (struct interface *) vty->index;
1666 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001667
hasso508e53e2004-05-18 18:57:06 +00001668 oi = (struct ospf6_interface *) ifp->info;
1669 if (oi == NULL)
1670 oi = ospf6_interface_create (ifp);
1671 assert (oi);
1672
1673 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001674 {
hasso508e53e2004-05-18 18:57:06 +00001675 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1676 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001677 }
1678
hasso508e53e2004-05-18 18:57:06 +00001679 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001680
1681 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001682 {
David Ward2470e992010-01-05 02:45:39 +00001683 OSPF6_LINK_LSA_SCHEDULE (oi);
1684 if (oi->state == OSPF6_INTERFACE_DR)
1685 {
1686 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1687 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1688 }
1689 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001690 }
paul718e3742002-12-13 20:15:29 +00001691
1692 return CMD_SUCCESS;
1693}
1694
Dinesh Duttc5926a92013-08-24 07:55:00 +00001695DEFUN (ipv6_ospf6_network,
1696 ipv6_ospf6_network_cmd,
1697 "ipv6 ospf6 network (broadcast|point-to-point)",
1698 IP6_STR
1699 OSPF6_STR
1700 "Network Type\n"
1701 "Specify OSPFv6 broadcast network\n"
1702 "Specify OSPF6 point-to-point network\n"
1703 )
1704{
1705 struct ospf6_interface *oi;
1706 struct interface *ifp;
1707
1708 ifp = (struct interface *) vty->index;
1709 assert (ifp);
1710
1711 oi = (struct ospf6_interface *) ifp->info;
1712 if (oi == NULL) {
1713 oi = ospf6_interface_create (ifp);
1714 }
1715 assert (oi);
1716
1717 if (strncmp (argv[0], "b", 1) == 0)
1718 {
1719 if (oi->type == OSPF_IFTYPE_BROADCAST)
1720 return CMD_SUCCESS;
1721
1722 oi->type = OSPF_IFTYPE_BROADCAST;
1723 }
1724 else if (strncmp (argv[0], "point-to-p", 10) == 0)
1725 {
1726 if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
1727 return CMD_SUCCESS;
1728 }
1729 oi->type = OSPF_IFTYPE_POINTOPOINT;
1730 }
1731
1732 /* Reset the interface */
1733 thread_add_event (master, interface_down, oi, 0);
1734 thread_add_event (master, interface_up, oi, 0);
1735
1736 return CMD_SUCCESS;
1737}
1738
1739DEFUN (no_ipv6_ospf6_network,
1740 no_ipv6_ospf6_network_cmd,
1741 "no ipv6 ospf6 network",
1742 NO_STR
1743 IP6_STR
1744 OSPF6_STR
1745 "Network Type\n"
1746 "Default to whatever interface type system specifies"
1747 )
1748{
1749 struct ospf6_interface *oi;
1750 struct interface *ifp;
1751 int type;
1752
1753 ifp = (struct interface *) vty->index;
1754 assert (ifp);
1755
1756 oi = (struct ospf6_interface *) ifp->info;
1757 if (oi == NULL) {
1758 return CMD_SUCCESS;
1759 }
1760
1761 type = ospf6_default_iftype (ifp);
1762 if (oi->type == type)
1763 {
1764 return CMD_SUCCESS;
1765 }
1766 oi->type = type;
1767
1768 /* Reset the interface */
1769 thread_add_event (master, interface_down, oi, 0);
1770 thread_add_event (master, interface_up, oi, 0);
1771
1772 return CMD_SUCCESS;
1773}
1774
Paul Jakma6ac29a52008-08-15 13:45:30 +01001775static int
hasso508e53e2004-05-18 18:57:06 +00001776config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001777{
hasso52dc7ee2004-09-23 19:18:23 +00001778 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001779 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001780 struct interface *ifp;
1781
paul1eb8ef22005-04-07 07:30:20 +00001782 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001783 {
hasso508e53e2004-05-18 18:57:06 +00001784 oi = (struct ospf6_interface *) ifp->info;
1785 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001786 continue;
1787
1788 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001789 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001790
1791 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001792 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso1203e1c2004-07-23 21:34:27 +00001793 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001794 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001795
Vincent Bernatc19543b2012-10-24 14:45:53 +00001796 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001797 vty_out (vty, " ipv6 ospf6 cost %d%s",
1798 oi->cost, VNL);
1799
1800 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1801 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1802 oi->hello_interval, VNL);
1803
1804 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1805 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1806 oi->dead_interval, VNL);
1807
1808 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1809 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1810 oi->rxmt_interval, VNL);
1811
1812 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1813 vty_out (vty, " ipv6 ospf6 priority %d%s",
1814 oi->priority, VNL);
1815
1816 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1817 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1818 oi->transdelay, VNL);
1819
1820 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1821 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1822 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001823
hasso508e53e2004-05-18 18:57:06 +00001824 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001825 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001826 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001827
hasso508e53e2004-05-18 18:57:06 +00001828 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001829 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001830
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001831 if (oi->mtu_ignore)
1832 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1833
Dinesh Duttc5926a92013-08-24 07:55:00 +00001834 if (oi->type == OSPF_IFTYPE_POINTOPOINT)
1835 vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
1836 else if (oi->type == OSPF_IFTYPE_BROADCAST)
1837 vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
1838
hasso049207c2004-08-04 20:02:13 +00001839 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001840 }
1841 return 0;
1842}
1843
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001844static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001845{
1846 INTERFACE_NODE,
1847 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001848 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001849};
1850
1851void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001852ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001853{
1854 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001855 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001856
1857 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001858 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1859 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1860 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001861 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001862 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1863 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1864 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001865
hasso508e53e2004-05-18 18:57:06 +00001866 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001867 install_default (INTERFACE_NODE);
1868 install_element (INTERFACE_NODE, &interface_desc_cmd);
1869 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1870 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
Vincent Bernatc19543b2012-10-24 14:45:53 +00001871 install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001872 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001873 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001874 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1875 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1876 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1877 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1878 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1879 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001880
paul718e3742002-12-13 20:15:29 +00001881 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1882 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001883
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001884 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1885 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1886
hasso508e53e2004-05-18 18:57:06 +00001887 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1888 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
Dinesh Duttc5926a92013-08-24 07:55:00 +00001889
1890 install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
1891 install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
Vincent Bernatfd500682012-10-24 14:45:54 +00001892
1893 /* reference bandwidth commands */
1894 install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
1895 install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
hasso508e53e2004-05-18 18:57:06 +00001896}
1897
Vipin Kumare87f8082015-05-19 18:03:40 -07001898/* Clear the specified interface structure */
1899static void
1900ospf6_interface_clear (struct vty *vty, struct interface *ifp)
1901{
1902 struct ospf6_interface *oi;
1903
1904 if (!if_is_operative (ifp))
1905 return;
1906
1907 if (ifp->info == NULL)
1908 return;
1909
1910 oi = (struct ospf6_interface *) ifp->info;
1911
1912 if (IS_OSPF6_DEBUG_INTERFACE)
1913 zlog_debug ("Interface %s: clear by reset", ifp->name);
1914
1915 /* Reset the interface */
1916 thread_add_event (master, interface_down, oi, 0);
1917 thread_add_event (master, interface_up, oi, 0);
1918}
1919
1920/* Clear interface */
1921DEFUN (clear_ipv6_ospf6_interface,
1922 clear_ipv6_ospf6_interface_cmd,
1923 "clear ipv6 ospf6 interface [IFNAME]",
1924 CLEAR_STR
1925 IP6_STR
1926 OSPF6_STR
1927 INTERFACE_STR
1928 IFNAME_STR
1929 )
1930{
1931 struct interface *ifp;
1932 struct listnode *node;
1933
1934 if (argc == 0) /* Clear all the ospfv3 interfaces. */
1935 {
1936 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
1937 ospf6_interface_clear (vty, ifp);
1938 }
1939 else /* Interface name is specified. */
1940 {
1941 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
1942 {
1943 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
1944 return CMD_WARNING;
1945 }
1946 ospf6_interface_clear (vty, ifp);
1947 }
1948
1949 return CMD_SUCCESS;
1950}
1951
1952void
1953install_element_ospf6_clear_interface (void)
1954{
1955 install_element (ENABLE_NODE, &clear_ipv6_ospf6_interface_cmd);
1956}
1957
hasso508e53e2004-05-18 18:57:06 +00001958DEFUN (debug_ospf6_interface,
1959 debug_ospf6_interface_cmd,
1960 "debug ospf6 interface",
1961 DEBUG_STR
1962 OSPF6_STR
1963 "Debug OSPFv3 Interface\n"
1964 )
1965{
1966 OSPF6_DEBUG_INTERFACE_ON ();
1967 return CMD_SUCCESS;
1968}
1969
1970DEFUN (no_debug_ospf6_interface,
1971 no_debug_ospf6_interface_cmd,
1972 "no debug ospf6 interface",
1973 NO_STR
1974 DEBUG_STR
1975 OSPF6_STR
1976 "Debug OSPFv3 Interface\n"
1977 )
1978{
hasso3b687352004-08-19 06:56:53 +00001979 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001980 return CMD_SUCCESS;
1981}
1982
1983int
1984config_write_ospf6_debug_interface (struct vty *vty)
1985{
1986 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001987 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001988 return 0;
1989}
1990
1991void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001992install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001993{
1994 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1995 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1996 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1997 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001998}
1999
2000