blob: 772caff7f98d5af1a875cf5d8849d3c9518537aa [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"
hasso049207c2004-08-04 20:02:13 +000043#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000044
hasso508e53e2004-05-18 18:57:06 +000045unsigned char conf_debug_ospf6_interface = 0;
46
paul0c083ee2004-10-10 12:54:58 +000047const char *ospf6_interface_state_str[] =
paul718e3742002-12-13 20:15:29 +000048{
hasso508e53e2004-05-18 18:57:06 +000049 "None",
50 "Down",
51 "Loopback",
52 "Waiting",
53 "PointToPoint",
54 "DROther",
55 "BDR",
56 "DR",
57 NULL
paul718e3742002-12-13 20:15:29 +000058};
59
hasso508e53e2004-05-18 18:57:06 +000060struct ospf6_interface *
61ospf6_interface_lookup_by_ifindex (int ifindex)
paul718e3742002-12-13 20:15:29 +000062{
hasso508e53e2004-05-18 18:57:06 +000063 struct ospf6_interface *oi;
64 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +000065
hasso508e53e2004-05-18 18:57:06 +000066 ifp = if_lookup_by_index (ifindex);
67 if (ifp == NULL)
68 return (struct ospf6_interface *) NULL;
69
70 oi = (struct ospf6_interface *) ifp->info;
71 return oi;
paul718e3742002-12-13 20:15:29 +000072}
73
hasso508e53e2004-05-18 18:57:06 +000074/* schedule routing table recalculation */
Paul Jakma6ac29a52008-08-15 13:45:30 +010075static void
Dinesh Dutta0edf672013-08-26 03:40:23 +000076ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa, unsigned int reason)
paul718e3742002-12-13 20:15:29 +000077{
Dinesh Dutt3810e062013-08-24 07:54:09 +000078 struct ospf6_interface *oi;
79
80 if (lsa == NULL)
81 return;
82
83 oi = lsa->lsdb->data;
hasso508e53e2004-05-18 18:57:06 +000084 switch (ntohs (lsa->header->type))
85 {
86 case OSPF6_LSTYPE_LINK:
Dinesh Dutt3810e062013-08-24 07:54:09 +000087 if (oi->state == OSPF6_INTERFACE_DR)
88 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
Dinesh Dutta0edf672013-08-26 03:40:23 +000089 ospf6_spf_schedule (oi->area->ospf6, reason);
hasso508e53e2004-05-18 18:57:06 +000090 break;
paul718e3742002-12-13 20:15:29 +000091
hasso508e53e2004-05-18 18:57:06 +000092 default:
hasso508e53e2004-05-18 18:57:06 +000093 break;
94 }
paul718e3742002-12-13 20:15:29 +000095}
96
Dinesh Dutta0edf672013-08-26 03:40:23 +000097static void
98ospf6_interface_lsdb_hook_add (struct ospf6_lsa *lsa)
99{
100 ospf6_interface_lsdb_hook(lsa, ospf6_lsadd_to_spf_reason(lsa));
101}
102
103static void
104ospf6_interface_lsdb_hook_remove (struct ospf6_lsa *lsa)
105{
106 ospf6_interface_lsdb_hook(lsa, ospf6_lsremove_to_spf_reason(lsa));
107}
108
Dinesh Duttc5926a92013-08-24 07:55:00 +0000109static u_char
110ospf6_default_iftype(struct interface *ifp)
111{
112 if (if_is_pointopoint (ifp))
113 return OSPF_IFTYPE_POINTOPOINT;
114 else if (if_is_loopback (ifp))
115 return OSPF_IFTYPE_LOOPBACK;
116 else
117 return OSPF_IFTYPE_BROADCAST;
118}
119
Vincent Bernatc19543b2012-10-24 14:45:53 +0000120static u_int32_t
121ospf6_interface_get_cost (struct ospf6_interface *oi)
122{
123 /* If all else fails, use default OSPF cost */
124 u_int32_t cost;
125 u_int32_t bw, refbw;
126
127 bw = oi->interface->bandwidth ? oi->interface->bandwidth : OSPF6_INTERFACE_BANDWIDTH;
Vincent Bernatfd500682012-10-24 14:45:54 +0000128 refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
Vincent Bernatc19543b2012-10-24 14:45:53 +0000129
130 /* A specifed ip ospf cost overrides a calculated one. */
131 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
132 cost = oi->cost;
133 else
134 {
135 cost = (u_int32_t) ((double)refbw / (double)bw + (double)0.5);
136 if (cost < 1) cost = 1;
137 else if (cost > UINT32_MAX) cost = UINT32_MAX;
138 }
139
140 return cost;
141}
142
143static void
144ospf6_interface_recalculate_cost (struct ospf6_interface *oi)
145{
146 u_int32_t newcost;
147
148 newcost = ospf6_interface_get_cost (oi);
149 if (newcost == oi->cost) return;
150 oi->cost = newcost;
151
152 /* update cost held in route_connected list in ospf6_interface */
153 ospf6_interface_connected_route_update (oi->interface);
154
155 /* execute LSA hooks */
156 if (oi->area)
157 {
158 OSPF6_LINK_LSA_SCHEDULE (oi);
159 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
160 OSPF6_NETWORK_LSA_SCHEDULE (oi);
161 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
162 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
163 }
164}
165
paul718e3742002-12-13 20:15:29 +0000166/* Create new ospf6 interface structure */
167struct ospf6_interface *
168ospf6_interface_create (struct interface *ifp)
169{
hasso508e53e2004-05-18 18:57:06 +0000170 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000171 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000172
hasso508e53e2004-05-18 18:57:06 +0000173 oi = (struct ospf6_interface *)
Stephen Hemminger393deb92008-08-18 14:13:29 -0700174 XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
paul718e3742002-12-13 20:15:29 +0000175
Stephen Hemminger393deb92008-08-18 14:13:29 -0700176 if (!oi)
paul718e3742002-12-13 20:15:29 +0000177 {
178 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
179 return (struct ospf6_interface *) NULL;
180 }
181
hasso508e53e2004-05-18 18:57:06 +0000182 oi->area = (struct ospf6_area *) NULL;
183 oi->neighbor_list = list_new ();
184 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
185 oi->linklocal_addr = (struct in6_addr *) NULL;
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +0400186 oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
187 oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
188 oi->priority = OSPF6_INTERFACE_PRIORITY;
paul718e3742002-12-13 20:15:29 +0000189
Dinesh Dutt8551e6d2013-10-22 17:42:18 -0700190 oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
191 oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
192 oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
Dinesh Duttc5926a92013-08-24 07:55:00 +0000193 oi->type = ospf6_default_iftype (ifp);
hasso508e53e2004-05-18 18:57:06 +0000194 oi->state = OSPF6_INTERFACE_DOWN;
195 oi->flag = 0;
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400196 oi->mtu_ignore = 0;
paul718e3742002-12-13 20:15:29 +0000197
hassob596c712004-07-09 18:33:43 +0000198 /* Try to adjust I/O buffer size with IfMtu */
hasso1203e1c2004-07-23 21:34:27 +0000199 oi->ifmtu = ifp->mtu6;
200 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000201 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000202 {
hasso1e058382004-09-01 21:36:14 +0000203 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000204 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
205 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000206 oi->ifmtu = iobuflen;
207 }
hasso3b4cd3a2004-05-18 19:28:32 +0000208
hasso6452df02004-08-15 05:52:07 +0000209 oi->lsupdate_list = ospf6_lsdb_create (oi);
210 oi->lsack_list = ospf6_lsdb_create (oi);
211 oi->lsdb = ospf6_lsdb_create (oi);
Dinesh Dutta0edf672013-08-26 03:40:23 +0000212 oi->lsdb->hook_add = ospf6_interface_lsdb_hook_add;
213 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook_remove;
hasso6452df02004-08-15 05:52:07 +0000214 oi->lsdb_self = ospf6_lsdb_create (oi);
paul718e3742002-12-13 20:15:29 +0000215
Paul Jakmacf1ce252006-05-15 10:46:07 +0000216 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
217 oi->route_connected->scope = oi;
paul718e3742002-12-13 20:15:29 +0000218
219 /* link both */
hasso508e53e2004-05-18 18:57:06 +0000220 oi->interface = ifp;
221 ifp->info = oi;
paul718e3742002-12-13 20:15:29 +0000222
Vincent Bernatc19543b2012-10-24 14:45:53 +0000223 /* Compute cost. */
224 oi->cost = ospf6_interface_get_cost(oi);
225
hasso508e53e2004-05-18 18:57:06 +0000226 return oi;
paul718e3742002-12-13 20:15:29 +0000227}
228
229void
hasso508e53e2004-05-18 18:57:06 +0000230ospf6_interface_delete (struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000231{
paul1eb8ef22005-04-07 07:30:20 +0000232 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000233 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000234
paul1eb8ef22005-04-07 07:30:20 +0000235 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000236 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000237
hasso508e53e2004-05-18 18:57:06 +0000238 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000239
hasso508e53e2004-05-18 18:57:06 +0000240 THREAD_OFF (oi->thread_send_hello);
241 THREAD_OFF (oi->thread_send_lsupdate);
242 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000243
hasso508e53e2004-05-18 18:57:06 +0000244 ospf6_lsdb_remove_all (oi->lsdb);
245 ospf6_lsdb_remove_all (oi->lsupdate_list);
246 ospf6_lsdb_remove_all (oi->lsack_list);
247
248 ospf6_lsdb_delete (oi->lsdb);
hasso6452df02004-08-15 05:52:07 +0000249 ospf6_lsdb_delete (oi->lsdb_self);
250
hasso508e53e2004-05-18 18:57:06 +0000251 ospf6_lsdb_delete (oi->lsupdate_list);
252 ospf6_lsdb_delete (oi->lsack_list);
253
254 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000255
256 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000257 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000258
259 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000260 if (oi->plist_name)
261 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000262
hasso508e53e2004-05-18 18:57:06 +0000263 XFREE (MTYPE_OSPF6_IF, oi);
264}
265
266void
267ospf6_interface_enable (struct ospf6_interface *oi)
268{
269 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
Christian Franked9628722013-03-08 21:47:35 +0100270 ospf6_interface_state_update (oi->interface);
hasso508e53e2004-05-18 18:57:06 +0000271}
272
273void
274ospf6_interface_disable (struct ospf6_interface *oi)
275{
hasso508e53e2004-05-18 18:57:06 +0000276 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
277
Christian Franked9628722013-03-08 21:47:35 +0100278 thread_execute (master, interface_down, oi, 0);
hasso508e53e2004-05-18 18:57:06 +0000279
280 ospf6_lsdb_remove_all (oi->lsdb);
Christian Franked9628722013-03-08 21:47:35 +0100281 ospf6_lsdb_remove_all (oi->lsdb_self);
hasso508e53e2004-05-18 18:57:06 +0000282 ospf6_lsdb_remove_all (oi->lsupdate_list);
283 ospf6_lsdb_remove_all (oi->lsack_list);
284
285 THREAD_OFF (oi->thread_send_hello);
286 THREAD_OFF (oi->thread_send_lsupdate);
287 THREAD_OFF (oi->thread_send_lsack);
Christian Franked9628722013-03-08 21:47:35 +0100288
289 THREAD_OFF (oi->thread_network_lsa);
290 THREAD_OFF (oi->thread_link_lsa);
291 THREAD_OFF (oi->thread_intra_prefix_lsa);
paul718e3742002-12-13 20:15:29 +0000292}
293
294static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000295ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000296{
hasso52dc7ee2004-09-23 19:18:23 +0000297 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000298 struct connected *c;
299 struct in6_addr *l = (struct in6_addr *) NULL;
300
301 /* for each connected address */
paul1eb8ef22005-04-07 07:30:20 +0000302 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
paul718e3742002-12-13 20:15:29 +0000303 {
paul718e3742002-12-13 20:15:29 +0000304 /* if family not AF_INET6, ignore */
305 if (c->address->family != AF_INET6)
306 continue;
307
308 /* linklocal scope check */
309 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
310 l = &c->address->u.prefix6;
311 }
312 return l;
313}
314
315void
316ospf6_interface_if_add (struct interface *ifp)
317{
hasso508e53e2004-05-18 18:57:06 +0000318 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000319 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000320
hasso508e53e2004-05-18 18:57:06 +0000321 oi = (struct ospf6_interface *) ifp->info;
322 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000323 return;
324
hassob596c712004-07-09 18:33:43 +0000325 /* Try to adjust I/O buffer size with IfMtu */
326 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000327 oi->ifmtu = ifp->mtu6;
328 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000329 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000330 {
hasso1e058382004-09-01 21:36:14 +0000331 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000332 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
333 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000334 oi->ifmtu = iobuflen;
335 }
paul718e3742002-12-13 20:15:29 +0000336
337 /* interface start */
Christian Frankeb13c1d92012-12-13 16:11:16 +0100338 ospf6_interface_state_update(oi->interface);
paul718e3742002-12-13 20:15:29 +0000339}
340
341void
342ospf6_interface_if_del (struct interface *ifp)
343{
hasso508e53e2004-05-18 18:57:06 +0000344 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000345
hasso508e53e2004-05-18 18:57:06 +0000346 oi = (struct ospf6_interface *) ifp->info;
347 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000348 return;
349
350 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000351 if (oi->area)
352 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000353
hasso508e53e2004-05-18 18:57:06 +0000354 listnode_delete (oi->area->if_list, oi);
355 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000356
357 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000358 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000359 ifp->info = NULL;
360
hasso508e53e2004-05-18 18:57:06 +0000361 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000362}
363
364void
365ospf6_interface_state_update (struct interface *ifp)
366{
hasso508e53e2004-05-18 18:57:06 +0000367 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000368
hasso508e53e2004-05-18 18:57:06 +0000369 oi = (struct ospf6_interface *) ifp->info;
370 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000371 return;
hasso508e53e2004-05-18 18:57:06 +0000372 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000373 return;
Christian Franked9628722013-03-08 21:47:35 +0100374 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
375 return;
paul718e3742002-12-13 20:15:29 +0000376
Christian Frankeb13c1d92012-12-13 16:11:16 +0100377 if (if_is_operative (ifp)
378 && (ospf6_interface_get_linklocal_address(oi->interface)
379 || if_is_loopback(oi->interface)))
hasso508e53e2004-05-18 18:57:06 +0000380 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000381 else
hasso508e53e2004-05-18 18:57:06 +0000382 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000383
384 return;
385}
386
387void
hasso508e53e2004-05-18 18:57:06 +0000388ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000389{
hasso508e53e2004-05-18 18:57:06 +0000390 struct ospf6_interface *oi;
391 struct ospf6_route *route;
392 struct connected *c;
paul1eb8ef22005-04-07 07:30:20 +0000393 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +0000394
hasso508e53e2004-05-18 18:57:06 +0000395 oi = (struct ospf6_interface *) ifp->info;
396 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000397 return;
398
399 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000400 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000401
hasso508e53e2004-05-18 18:57:06 +0000402 /* if area is null, do not make connected-route list */
403 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000404 return;
405
Christian Franked9628722013-03-08 21:47:35 +0100406 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
407 return;
408
hasso508e53e2004-05-18 18:57:06 +0000409 /* update "route to advertise" interface route table */
410 ospf6_route_remove_all (oi->route_connected);
hasso508e53e2004-05-18 18:57:06 +0000411
paul1eb8ef22005-04-07 07:30:20 +0000412 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
413 {
hasso508e53e2004-05-18 18:57:06 +0000414 if (c->address->family != AF_INET6)
415 continue;
416
hasso1e058382004-09-01 21:36:14 +0000417 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
418 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
419 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
420 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
421 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000422
423 /* apply filter */
424 if (oi->plist_name)
425 {
426 struct prefix_list *plist;
427 enum prefix_list_type ret;
428 char buf[128];
429
430 prefix2str (c->address, buf, sizeof (buf));
431 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
432 ret = prefix_list_apply (plist, (void *) c->address);
433 if (ret == PREFIX_DENY)
434 {
hasso1e058382004-09-01 21:36:14 +0000435 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000436 zlog_debug ("%s on %s filtered by prefix-list %s ",
437 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000438 continue;
439 }
440 }
441
442 route = ospf6_route_create ();
443 memcpy (&route->prefix, c->address, sizeof (struct prefix));
444 apply_mask (&route->prefix);
445 route->type = OSPF6_DEST_TYPE_NETWORK;
446 route->path.area_id = oi->area->area_id;
447 route->path.type = OSPF6_PATH_TYPE_INTRA;
448 route->path.cost = oi->cost;
449 route->nexthop[0].ifindex = oi->interface->ifindex;
450 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
451 ospf6_route_add (route, oi->route_connected);
452 }
453
paul718e3742002-12-13 20:15:29 +0000454 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000455 OSPF6_LINK_LSA_SCHEDULE (oi);
456 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
457 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000458}
459
hasso508e53e2004-05-18 18:57:06 +0000460static void
461ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000462{
hasso508e53e2004-05-18 18:57:06 +0000463 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000464
hasso508e53e2004-05-18 18:57:06 +0000465 prev_state = oi->state;
466 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000467
hasso508e53e2004-05-18 18:57:06 +0000468 if (prev_state == next_state)
469 return;
paul718e3742002-12-13 20:15:29 +0000470
hasso508e53e2004-05-18 18:57:06 +0000471 /* log */
472 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000473 {
hassoc6487d62004-12-24 06:00:11 +0000474 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
475 ospf6_interface_state_str[prev_state],
476 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000477 }
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200478 oi->state_change++;
paul718e3742002-12-13 20:15:29 +0000479
hasso508e53e2004-05-18 18:57:06 +0000480 if ((prev_state == OSPF6_INTERFACE_DR ||
481 prev_state == OSPF6_INTERFACE_BDR) &&
482 (next_state != OSPF6_INTERFACE_DR &&
483 next_state != OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400484 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
Dinesh Duttc5926a92013-08-24 07:55:00 +0000485
hasso508e53e2004-05-18 18:57:06 +0000486 if ((prev_state != OSPF6_INTERFACE_DR &&
487 prev_state != OSPF6_INTERFACE_BDR) &&
488 (next_state == OSPF6_INTERFACE_DR ||
489 next_state == OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400490 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
paul718e3742002-12-13 20:15:29 +0000491
hasso508e53e2004-05-18 18:57:06 +0000492 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000493 if (next_state == OSPF6_INTERFACE_DOWN)
494 {
495 OSPF6_NETWORK_LSA_EXECUTE (oi);
496 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
497 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
498 }
499 else if (prev_state == OSPF6_INTERFACE_DR ||
500 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000501 {
hasso508e53e2004-05-18 18:57:06 +0000502 OSPF6_NETWORK_LSA_SCHEDULE (oi);
503 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
504 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000505 }
Vincent Bernatbf836662012-06-04 14:36:12 +0200506
507#ifdef HAVE_SNMP
508 /* Terminal state or regression */
509 if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
510 (next_state == OSPF6_INTERFACE_DROTHER) ||
511 (next_state == OSPF6_INTERFACE_BDR) ||
512 (next_state == OSPF6_INTERFACE_DR) ||
513 (next_state < prev_state))
514 ospf6TrapIfStateChange (oi);
515#endif
516
hasso508e53e2004-05-18 18:57:06 +0000517}
518
David Lamparter6b0655a2014-06-04 06:53:35 +0200519
hasso508e53e2004-05-18 18:57:06 +0000520/* DR Election, RFC2328 section 9.4 */
521
522#define IS_ELIGIBLE(n) \
523 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
524
525static struct ospf6_neighbor *
526better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
527{
528 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
529 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
530 return NULL;
531 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
532 return b;
533 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
534 return a;
535
536 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
537 return a;
538 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
539 return b;
540
541 if (a->priority > b->priority)
542 return a;
543 if (a->priority < b->priority)
544 return b;
545
546 if (ntohl (a->router_id) > ntohl (b->router_id))
547 return a;
548 if (ntohl (a->router_id) < ntohl (b->router_id))
549 return b;
550
551 zlog_warn ("Router-ID duplicate ?");
552 return a;
553}
554
555static struct ospf6_neighbor *
556better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
557{
558 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
559 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
560 return NULL;
561 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
562 return b;
563 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
564 return a;
565
566 if (a->drouter == a->router_id && b->drouter != b->router_id)
567 return a;
568 if (a->drouter != a->router_id && b->drouter == b->router_id)
569 return b;
570
571 if (a->priority > b->priority)
572 return a;
573 if (a->priority < b->priority)
574 return b;
575
576 if (ntohl (a->router_id) > ntohl (b->router_id))
577 return a;
578 if (ntohl (a->router_id) < ntohl (b->router_id))
579 return b;
580
581 zlog_warn ("Router-ID duplicate ?");
582 return a;
583}
584
585static u_char
586dr_election (struct ospf6_interface *oi)
587{
paul1eb8ef22005-04-07 07:30:20 +0000588 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000589 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
590 struct ospf6_neighbor *best_drouter, *best_bdrouter;
591 u_char next_state = 0;
592
593 drouter = bdrouter = NULL;
594 best_drouter = best_bdrouter = NULL;
595
596 /* pseudo neighbor myself, including noting current DR/BDR (1) */
597 memset (&myself, 0, sizeof (myself));
598 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
599 sizeof (myself.name));
600 myself.state = OSPF6_NEIGHBOR_TWOWAY;
601 myself.drouter = oi->drouter;
602 myself.bdrouter = oi->bdrouter;
603 myself.priority = oi->priority;
604 myself.router_id = oi->area->ospf6->router_id;
605
606 /* Electing BDR (2) */
paul1eb8ef22005-04-07 07:30:20 +0000607 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
608 bdrouter = better_bdrouter (bdrouter, on);
609
hasso508e53e2004-05-18 18:57:06 +0000610 best_bdrouter = bdrouter;
611 bdrouter = better_bdrouter (best_bdrouter, &myself);
612
613 /* Electing DR (3) */
paul1eb8ef22005-04-07 07:30:20 +0000614 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
615 drouter = better_drouter (drouter, on);
616
hasso508e53e2004-05-18 18:57:06 +0000617 best_drouter = drouter;
618 drouter = better_drouter (best_drouter, &myself);
619 if (drouter == NULL)
620 drouter = bdrouter;
621
622 /* the router itself is newly/no longer DR/BDR (4) */
623 if ((drouter == &myself && myself.drouter != myself.router_id) ||
624 (drouter != &myself && myself.drouter == myself.router_id) ||
625 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
626 (bdrouter != &myself && myself.bdrouter == myself.router_id))
627 {
628 myself.drouter = (drouter ? drouter->router_id : htonl (0));
629 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
630
631 /* compatible to Electing BDR (2) */
632 bdrouter = better_bdrouter (best_bdrouter, &myself);
633
634 /* compatible to Electing DR (3) */
635 drouter = better_drouter (best_drouter, &myself);
636 if (drouter == NULL)
637 drouter = bdrouter;
638 }
639
640 /* Set interface state accordingly (5) */
641 if (drouter && drouter == &myself)
642 next_state = OSPF6_INTERFACE_DR;
643 else if (bdrouter && bdrouter == &myself)
644 next_state = OSPF6_INTERFACE_BDR;
645 else
646 next_state = OSPF6_INTERFACE_DROTHER;
647
648 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
649 /* XXX */
650
651 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
652 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
653 accordingly after AdjOK */
654 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
655 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
656 {
657 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000658 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
659 (drouter ? drouter->name : "0.0.0.0"),
660 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000661
paul1eb8ef22005-04-07 07:30:20 +0000662 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
hasso508e53e2004-05-18 18:57:06 +0000663 {
hasso508e53e2004-05-18 18:57:06 +0000664 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
665 continue;
666 /* Schedule AdjOK. */
667 thread_add_event (master, adj_ok, on, 0);
668 }
669 }
670
671 oi->drouter = (drouter ? drouter->router_id : htonl (0));
672 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
673 return next_state;
674}
675
David Lamparter6b0655a2014-06-04 06:53:35 +0200676
hasso508e53e2004-05-18 18:57:06 +0000677/* Interface State Machine */
678int
679interface_up (struct thread *thread)
680{
681 struct ospf6_interface *oi;
682
683 oi = (struct ospf6_interface *) THREAD_ARG (thread);
684 assert (oi && oi->interface);
685
686 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000687 zlog_debug ("Interface Event %s: [InterfaceUp]",
688 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000689
690 /* check physical interface is up */
Dinesh Dutte7ad6b22013-08-24 07:55:57 +0000691 if (! if_is_operative (oi->interface))
hasso508e53e2004-05-18 18:57:06 +0000692 {
693 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000694 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
695 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000696 return 0;
697 }
698
Christian Frankeb13c1d92012-12-13 16:11:16 +0100699 /* check interface has a link-local address */
700 if (! (ospf6_interface_get_linklocal_address(oi->interface)
701 || if_is_loopback(oi->interface)))
702 {
703 if (IS_OSPF6_DEBUG_INTERFACE)
704 zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
705 oi->interface->name);
706 return 0;
707 }
708
Vincent Bernatc19543b2012-10-24 14:45:53 +0000709 /* Recompute cost */
710 ospf6_interface_recalculate_cost (oi);
711
hasso508e53e2004-05-18 18:57:06 +0000712 /* if already enabled, do nothing */
713 if (oi->state > OSPF6_INTERFACE_DOWN)
714 {
715 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000716 zlog_debug ("Interface %s already enabled",
717 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000718 return 0;
719 }
720
Dinesh Duttba960d52013-08-26 03:40:37 +0000721 /* If no area assigned, return */
722 if (oi->area == NULL)
723 {
724 zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__,
725 oi->interface->name);
726 return 0;
727 }
728
hasso508e53e2004-05-18 18:57:06 +0000729 /* Join AllSPFRouters */
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400730 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000731
732 /* Update interface route */
733 ospf6_interface_connected_route_update (oi->interface);
734
735 /* Schedule Hello */
736 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
David Lamparter424cc3b2013-11-23 16:55:36 +0100737 oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
hasso508e53e2004-05-18 18:57:06 +0000738
739 /* decide next interface state */
Dinesh Duttc5926a92013-08-24 07:55:00 +0000740 if ((if_is_pointopoint (oi->interface)) ||
741 (oi->type == OSPF_IFTYPE_POINTOPOINT)) {
hasso508e53e2004-05-18 18:57:06 +0000742 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
Dinesh Duttc5926a92013-08-24 07:55:00 +0000743 }
hasso508e53e2004-05-18 18:57:06 +0000744 else if (oi->priority == 0)
745 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
746 else
747 {
748 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
749 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
750 }
751
752 return 0;
paul718e3742002-12-13 20:15:29 +0000753}
754
755int
hasso508e53e2004-05-18 18:57:06 +0000756wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000757{
hasso508e53e2004-05-18 18:57:06 +0000758 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000759
hasso508e53e2004-05-18 18:57:06 +0000760 oi = (struct ospf6_interface *) THREAD_ARG (thread);
761 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000762
hasso508e53e2004-05-18 18:57:06 +0000763 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000764 zlog_debug ("Interface Event %s: [WaitTimer]",
765 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000766
hasso508e53e2004-05-18 18:57:06 +0000767 if (oi->state == OSPF6_INTERFACE_WAITING)
768 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000769
hasso508e53e2004-05-18 18:57:06 +0000770 return 0;
paul718e3742002-12-13 20:15:29 +0000771}
772
hasso508e53e2004-05-18 18:57:06 +0000773int
774backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000775{
hasso508e53e2004-05-18 18:57:06 +0000776 struct ospf6_interface *oi;
777
778 oi = (struct ospf6_interface *) THREAD_ARG (thread);
779 assert (oi && oi->interface);
780
781 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000782 zlog_debug ("Interface Event %s: [BackupSeen]",
783 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000784
785 if (oi->state == OSPF6_INTERFACE_WAITING)
786 ospf6_interface_state_change (dr_election (oi), oi);
787
788 return 0;
paul718e3742002-12-13 20:15:29 +0000789}
790
hasso508e53e2004-05-18 18:57:06 +0000791int
792neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000793{
hasso508e53e2004-05-18 18:57:06 +0000794 struct ospf6_interface *oi;
795
796 oi = (struct ospf6_interface *) THREAD_ARG (thread);
797 assert (oi && oi->interface);
798
799 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000800 zlog_debug ("Interface Event %s: [NeighborChange]",
801 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000802
803 if (oi->state == OSPF6_INTERFACE_DROTHER ||
804 oi->state == OSPF6_INTERFACE_BDR ||
805 oi->state == OSPF6_INTERFACE_DR)
806 ospf6_interface_state_change (dr_election (oi), oi);
807
808 return 0;
paul718e3742002-12-13 20:15:29 +0000809}
810
hasso508e53e2004-05-18 18:57:06 +0000811int
812interface_down (struct thread *thread)
813{
814 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000815 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000816 struct ospf6_neighbor *on;
817
818 oi = (struct ospf6_interface *) THREAD_ARG (thread);
819 assert (oi && oi->interface);
820
821 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000822 zlog_debug ("Interface Event %s: [InterfaceDown]",
823 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000824
David Lamparter424cc3b2013-11-23 16:55:36 +0100825 /* Stop Hellos */
826 THREAD_OFF (oi->thread_send_hello);
827
hasso508e53e2004-05-18 18:57:06 +0000828 /* Leave AllSPFRouters */
829 if (oi->state > OSPF6_INTERFACE_DOWN)
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400830 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000831
832 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
833
paul1eb8ef22005-04-07 07:30:20 +0000834 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
835 ospf6_neighbor_delete (on);
836
hasso508e53e2004-05-18 18:57:06 +0000837 list_delete_all_node (oi->neighbor_list);
838
Christian Franke37531a72012-12-13 13:50:28 +0100839 /* When interface state is reset, also reset information about
840 * DR election, as it is no longer valid. */
841 oi->drouter = oi->prev_drouter = htonl(0);
842 oi->bdrouter = oi->prev_bdrouter = htonl(0);
hasso508e53e2004-05-18 18:57:06 +0000843 return 0;
844}
845
David Lamparter6b0655a2014-06-04 06:53:35 +0200846
paul718e3742002-12-13 20:15:29 +0000847/* show specified interface structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100848static int
hasso508e53e2004-05-18 18:57:06 +0000849ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000850{
hasso508e53e2004-05-18 18:57:06 +0000851 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000852 struct connected *c;
853 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000854 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000855 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000856 const char *updown[3] = {"down", "up", NULL};
857 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000858 struct timeval res, now;
859 char duration[32];
860 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000861
862 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000863 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000864 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000865 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000866 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000867 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000868 type = "POINTOPOINT";
869 else
870 type = "UNKNOWN";
871
872 vty_out (vty, "%s is %s, type %s%s",
Dinesh Dutte7ad6b22013-08-24 07:55:57 +0000873 ifp->name, updown[if_is_operative (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000874 VNL);
875 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000876
hasso508e53e2004-05-18 18:57:06 +0000877 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000878 {
hasso049207c2004-08-04 20:02:13 +0000879 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000880 return 0;
881 }
882 else
hasso508e53e2004-05-18 18:57:06 +0000883 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000884
hasso049207c2004-08-04 20:02:13 +0000885 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000886
887 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000888 {
paul718e3742002-12-13 20:15:29 +0000889 p = c->address;
890 prefix2str (p, strbuf, sizeof (strbuf));
891 switch (p->family)
892 {
893 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000894 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000895 VNL);
paul718e3742002-12-13 20:15:29 +0000896 break;
897 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000898 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000899 VNL);
paul718e3742002-12-13 20:15:29 +0000900 break;
901 default:
hasso508e53e2004-05-18 18:57:06 +0000902 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000903 VNL);
paul718e3742002-12-13 20:15:29 +0000904 break;
905 }
906 }
907
hasso508e53e2004-05-18 18:57:06 +0000908 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000909 {
hasso508e53e2004-05-18 18:57:06 +0000910 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000911 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400912 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
913 "disabled" : "enabled", VNL);
hasso508e53e2004-05-18 18:57:06 +0000914 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000915 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000916 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000917 VNL);
paul718e3742002-12-13 20:15:29 +0000918 }
919 else
hasso049207c2004-08-04 20:02:13 +0000920 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000921
922 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000923 ospf6_interface_state_str[oi->state],
924 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000925 VNL);
926 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000927 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000928 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000929 VNL);
paul718e3742002-12-13 20:15:29 +0000930
hasso508e53e2004-05-18 18:57:06 +0000931 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
932 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000933 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000934
935 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000936 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000937
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900938 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
paul718e3742002-12-13 20:15:29 +0000939
hasso508e53e2004-05-18 18:57:06 +0000940 timerclear (&res);
941 if (oi->thread_send_lsupdate)
942 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
943 timerstring (&res, duration, sizeof (duration));
944 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
945 oi->lsupdate_list->count, duration,
946 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000947 VNL);
hasso508e53e2004-05-18 18:57:06 +0000948 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
949 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000950 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000951
hasso508e53e2004-05-18 18:57:06 +0000952 timerclear (&res);
953 if (oi->thread_send_lsack)
954 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
955 timerstring (&res, duration, sizeof (duration));
956 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
957 oi->lsack_list->count, duration,
958 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000959 VNL);
hasso508e53e2004-05-18 18:57:06 +0000960 for (lsa = ospf6_lsdb_head (oi->lsack_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 return 0;
paul718e3742002-12-13 20:15:29 +0000965}
966
967/* show interface */
968DEFUN (show_ipv6_ospf6_interface,
969 show_ipv6_ospf6_interface_ifname_cmd,
970 "show ipv6 ospf6 interface IFNAME",
971 SHOW_STR
972 IP6_STR
973 OSPF6_STR
974 INTERFACE_STR
975 IFNAME_STR
976 )
977{
978 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000979 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000980
981 if (argc)
982 {
983 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000984 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000985 {
986 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000987 VNL);
paul718e3742002-12-13 20:15:29 +0000988 return CMD_WARNING;
989 }
990 ospf6_interface_show (vty, ifp);
991 }
992 else
993 {
paul1eb8ef22005-04-07 07:30:20 +0000994 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
995 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000996 }
hasso508e53e2004-05-18 18:57:06 +0000997
paul718e3742002-12-13 20:15:29 +0000998 return CMD_SUCCESS;
999}
1000
1001ALIAS (show_ipv6_ospf6_interface,
1002 show_ipv6_ospf6_interface_cmd,
1003 "show ipv6 ospf6 interface",
1004 SHOW_STR
1005 IP6_STR
1006 OSPF6_STR
1007 INTERFACE_STR
Paul Jakma6ac29a52008-08-15 13:45:30 +01001008 )
paul718e3742002-12-13 20:15:29 +00001009
hasso508e53e2004-05-18 18:57:06 +00001010DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
1011 show_ipv6_ospf6_interface_ifname_prefix_cmd,
1012 "show ipv6 ospf6 interface IFNAME prefix",
1013 SHOW_STR
paul718e3742002-12-13 20:15:29 +00001014 IP6_STR
1015 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001016 INTERFACE_STR
1017 IFNAME_STR
1018 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +00001019 )
1020{
paul718e3742002-12-13 20:15:29 +00001021 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +00001022 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001023
hasso508e53e2004-05-18 18:57:06 +00001024 ifp = if_lookup_by_name (argv[0]);
1025 if (ifp == NULL)
1026 {
hasso049207c2004-08-04 20:02:13 +00001027 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +00001028 return CMD_WARNING;
1029 }
paul718e3742002-12-13 20:15:29 +00001030
hasso508e53e2004-05-18 18:57:06 +00001031 oi = ifp->info;
1032 if (oi == NULL)
1033 {
hasso049207c2004-08-04 20:02:13 +00001034 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +00001035 return CMD_WARNING;
1036 }
paul718e3742002-12-13 20:15:29 +00001037
hasso508e53e2004-05-18 18:57:06 +00001038 argc--;
1039 argv++;
1040 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +00001041
1042 return CMD_SUCCESS;
1043}
1044
hasso508e53e2004-05-18 18:57:06 +00001045ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1046 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
1047 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
1048 SHOW_STR
paul718e3742002-12-13 20:15:29 +00001049 IP6_STR
1050 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001051 INTERFACE_STR
1052 IFNAME_STR
1053 "Display connected prefixes to advertise\n"
1054 OSPF6_ROUTE_ADDRESS_STR
1055 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001056 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001057 )
hasso508e53e2004-05-18 18:57:06 +00001058
1059ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
1060 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
1061 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
1062 SHOW_STR
1063 IP6_STR
1064 OSPF6_STR
1065 INTERFACE_STR
1066 IFNAME_STR
1067 "Display connected prefixes to advertise\n"
1068 OSPF6_ROUTE_PREFIX_STR
1069 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001070 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001071 )
hasso508e53e2004-05-18 18:57:06 +00001072
1073DEFUN (show_ipv6_ospf6_interface_prefix,
1074 show_ipv6_ospf6_interface_prefix_cmd,
1075 "show ipv6 ospf6 interface prefix",
1076 SHOW_STR
1077 IP6_STR
1078 OSPF6_STR
1079 INTERFACE_STR
1080 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +00001081 )
1082{
hasso52dc7ee2004-09-23 19:18:23 +00001083 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001084 struct ospf6_interface *oi;
1085 struct interface *ifp;
1086
paul1eb8ef22005-04-07 07:30:20 +00001087 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +00001088 {
hasso508e53e2004-05-18 18:57:06 +00001089 oi = (struct ospf6_interface *) ifp->info;
1090 if (oi == NULL)
1091 continue;
1092
1093 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1094 }
1095
1096 return CMD_SUCCESS;
1097}
1098
1099ALIAS (show_ipv6_ospf6_interface_prefix,
1100 show_ipv6_ospf6_interface_prefix_detail_cmd,
1101 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1102 SHOW_STR
1103 IP6_STR
1104 OSPF6_STR
1105 INTERFACE_STR
1106 "Display connected prefixes to advertise\n"
1107 OSPF6_ROUTE_ADDRESS_STR
1108 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001109 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001110 )
hasso508e53e2004-05-18 18:57:06 +00001111
1112ALIAS (show_ipv6_ospf6_interface_prefix,
1113 show_ipv6_ospf6_interface_prefix_match_cmd,
1114 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1115 SHOW_STR
1116 IP6_STR
1117 OSPF6_STR
1118 INTERFACE_STR
1119 "Display connected prefixes to advertise\n"
1120 OSPF6_ROUTE_PREFIX_STR
1121 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001122 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001123 )
hasso508e53e2004-05-18 18:57:06 +00001124
1125
1126/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001127DEFUN (ipv6_ospf6_ifmtu,
1128 ipv6_ospf6_ifmtu_cmd,
1129 "ipv6 ospf6 ifmtu <1-65535>",
1130 IP6_STR
1131 OSPF6_STR
1132 "Interface MTU\n"
1133 "OSPFv3 Interface MTU\n"
1134 )
1135{
1136 struct ospf6_interface *oi;
1137 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001138 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001139 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001140 struct ospf6_neighbor *on;
1141
1142 ifp = (struct interface *) vty->index;
1143 assert (ifp);
1144
1145 oi = (struct ospf6_interface *) ifp->info;
1146 if (oi == NULL)
1147 oi = ospf6_interface_create (ifp);
1148 assert (oi);
1149
1150 ifmtu = strtol (argv[0], NULL, 10);
1151
1152 if (oi->ifmtu == ifmtu)
1153 return CMD_SUCCESS;
1154
hasso1203e1c2004-07-23 21:34:27 +00001155 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001156 {
1157 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001158 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001159 return CMD_WARNING;
1160 }
1161
1162 if (oi->ifmtu < ifmtu)
1163 {
1164 iobuflen = ospf6_iobuf_size (ifmtu);
1165 if (iobuflen < ifmtu)
1166 {
1167 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001168 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001169 oi->ifmtu = iobuflen;
1170 }
1171 else
1172 oi->ifmtu = ifmtu;
1173 }
1174 else
1175 oi->ifmtu = ifmtu;
1176
1177 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001178 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001179 {
hassob596c712004-07-09 18:33:43 +00001180 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001181 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001182 }
1183
1184 return CMD_SUCCESS;
1185}
1186
hasso049207c2004-08-04 20:02:13 +00001187DEFUN (no_ipv6_ospf6_ifmtu,
1188 no_ipv6_ospf6_ifmtu_cmd,
1189 "no ipv6 ospf6 ifmtu",
1190 NO_STR
1191 IP6_STR
1192 OSPF6_STR
1193 "Interface MTU\n"
1194 )
1195{
1196 struct ospf6_interface *oi;
1197 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001198 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001199 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001200 struct ospf6_neighbor *on;
1201
1202 ifp = (struct interface *) vty->index;
1203 assert (ifp);
1204
1205 oi = (struct ospf6_interface *) ifp->info;
1206 if (oi == NULL)
1207 oi = ospf6_interface_create (ifp);
1208 assert (oi);
1209
1210 if (oi->ifmtu < ifp->mtu)
1211 {
1212 iobuflen = ospf6_iobuf_size (ifp->mtu);
1213 if (iobuflen < ifp->mtu)
1214 {
1215 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1216 ifp->name, iobuflen, VNL);
1217 oi->ifmtu = iobuflen;
1218 }
1219 else
1220 oi->ifmtu = ifp->mtu;
1221 }
1222 else
1223 oi->ifmtu = ifp->mtu;
1224
1225 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001226 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001227 {
hasso049207c2004-08-04 20:02:13 +00001228 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001229 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001230 }
1231
1232 return CMD_SUCCESS;
1233}
1234
hasso508e53e2004-05-18 18:57:06 +00001235DEFUN (ipv6_ospf6_cost,
1236 ipv6_ospf6_cost_cmd,
1237 "ipv6 ospf6 cost <1-65535>",
1238 IP6_STR
1239 OSPF6_STR
1240 "Interface cost\n"
1241 "Outgoing metric of this interface\n"
1242 )
1243{
1244 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001245 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001246 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001247
1248 ifp = (struct interface *) vty->index;
1249 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001250
hasso508e53e2004-05-18 18:57:06 +00001251 oi = (struct ospf6_interface *) ifp->info;
1252 if (oi == NULL)
1253 oi = ospf6_interface_create (ifp);
1254 assert (oi);
1255
paul0c083ee2004-10-10 12:54:58 +00001256 lcost = strtol (argv[0], NULL, 10);
1257
1258 if (lcost > UINT32_MAX)
1259 {
1260 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1261 return CMD_WARNING;
1262 }
1263
1264 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001265 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001266
1267 oi->cost = lcost;
Vincent Bernatc19543b2012-10-24 14:45:53 +00001268 SET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
hasso508e53e2004-05-18 18:57:06 +00001269
Vincent Bernatc19543b2012-10-24 14:45:53 +00001270 ospf6_interface_recalculate_cost(oi);
1271
1272 return CMD_SUCCESS;
1273}
1274
1275DEFUN (no_ipv6_ospf6_cost,
1276 no_ipv6_ospf6_cost_cmd,
1277 "no ipv6 ospf6 cost",
1278 NO_STR
1279 IP6_STR
1280 OSPF6_STR
1281 "Calculate interface cost from bandwidth\n"
1282 )
1283{
1284 struct ospf6_interface *oi;
1285 struct interface *ifp;
Vincent Bernatc19543b2012-10-24 14:45:53 +00001286
1287 ifp = (struct interface *) vty->index;
1288 assert (ifp);
1289
1290 oi = (struct ospf6_interface *) ifp->info;
1291 if (oi == NULL)
1292 oi = ospf6_interface_create (ifp);
1293 assert (oi);
1294
1295 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1296
1297 ospf6_interface_recalculate_cost(oi);
hasso508e53e2004-05-18 18:57:06 +00001298
1299 return CMD_SUCCESS;
1300}
1301
Vincent Bernatfd500682012-10-24 14:45:54 +00001302DEFUN (auto_cost_reference_bandwidth,
1303 auto_cost_reference_bandwidth_cmd,
1304 "auto-cost reference-bandwidth <1-4294967>",
1305 "Calculate OSPF interface cost according to bandwidth\n"
1306 "Use reference bandwidth method to assign OSPF cost\n"
1307 "The reference bandwidth in terms of Mbits per second\n")
1308{
1309 struct ospf6 *o = vty->index;
1310 struct ospf6_area *oa;
1311 struct ospf6_interface *oi;
1312 struct listnode *i, *j;
1313 u_int32_t refbw;
1314
1315 refbw = strtol (argv[0], NULL, 10);
1316 if (refbw < 1 || refbw > 4294967)
1317 {
1318 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
1319 return CMD_WARNING;
1320 }
1321
1322 /* If reference bandwidth is changed. */
1323 if ((refbw * 1000) == o->ref_bandwidth)
1324 return CMD_SUCCESS;
1325
1326 o->ref_bandwidth = refbw * 1000;
1327 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1328 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1329 ospf6_interface_recalculate_cost (oi);
1330
1331 return CMD_SUCCESS;
1332}
1333
1334DEFUN (no_auto_cost_reference_bandwidth,
1335 no_auto_cost_reference_bandwidth_cmd,
1336 "no auto-cost reference-bandwidth",
1337 NO_STR
1338 "Calculate OSPF interface cost according to bandwidth\n"
1339 "Use reference bandwidth method to assign OSPF cost\n")
1340{
1341 struct ospf6 *o = vty->index;
1342 struct ospf6_area *oa;
1343 struct ospf6_interface *oi;
1344 struct listnode *i, *j;
1345
1346 if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
1347 return CMD_SUCCESS;
1348
1349 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
1350 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1351 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1352 ospf6_interface_recalculate_cost (oi);
1353
1354 return CMD_SUCCESS;
1355}
1356
hasso508e53e2004-05-18 18:57:06 +00001357DEFUN (ipv6_ospf6_hellointerval,
1358 ipv6_ospf6_hellointerval_cmd,
1359 "ipv6 ospf6 hello-interval <1-65535>",
1360 IP6_STR
1361 OSPF6_STR
1362 "Interval time of Hello packets\n"
1363 SECONDS_STR
1364 )
1365{
1366 struct ospf6_interface *oi;
1367 struct interface *ifp;
1368
1369 ifp = (struct interface *) vty->index;
1370 assert (ifp);
1371
1372 oi = (struct ospf6_interface *) ifp->info;
1373 if (oi == NULL)
1374 oi = ospf6_interface_create (ifp);
1375 assert (oi);
1376
1377 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001378 return CMD_SUCCESS;
1379}
1380
1381/* interface variable set command */
1382DEFUN (ipv6_ospf6_deadinterval,
1383 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001384 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001385 IP6_STR
1386 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001387 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001388 SECONDS_STR
1389 )
1390{
hasso508e53e2004-05-18 18:57:06 +00001391 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001392 struct interface *ifp;
1393
1394 ifp = (struct interface *) vty->index;
1395 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001396
hasso508e53e2004-05-18 18:57:06 +00001397 oi = (struct ospf6_interface *) ifp->info;
1398 if (oi == NULL)
1399 oi = ospf6_interface_create (ifp);
1400 assert (oi);
1401
1402 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001403 return CMD_SUCCESS;
1404}
1405
1406/* interface variable set command */
1407DEFUN (ipv6_ospf6_transmitdelay,
1408 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001409 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001410 IP6_STR
1411 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001412 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001413 SECONDS_STR
1414 )
1415{
hasso508e53e2004-05-18 18:57:06 +00001416 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001417 struct interface *ifp;
1418
1419 ifp = (struct interface *) vty->index;
1420 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001421
hasso508e53e2004-05-18 18:57:06 +00001422 oi = (struct ospf6_interface *) ifp->info;
1423 if (oi == NULL)
1424 oi = ospf6_interface_create (ifp);
1425 assert (oi);
1426
1427 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001428 return CMD_SUCCESS;
1429}
1430
1431/* interface variable set command */
1432DEFUN (ipv6_ospf6_retransmitinterval,
1433 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001434 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001435 IP6_STR
1436 OSPF6_STR
1437 "Time between retransmitting lost link state advertisements\n"
1438 SECONDS_STR
1439 )
1440{
hasso508e53e2004-05-18 18:57:06 +00001441 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001442 struct interface *ifp;
1443
1444 ifp = (struct interface *) vty->index;
1445 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001446
hasso508e53e2004-05-18 18:57:06 +00001447 oi = (struct ospf6_interface *) ifp->info;
1448 if (oi == NULL)
1449 oi = ospf6_interface_create (ifp);
1450 assert (oi);
1451
1452 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001453 return CMD_SUCCESS;
1454}
1455
1456/* interface variable set command */
1457DEFUN (ipv6_ospf6_priority,
1458 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001459 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001460 IP6_STR
1461 OSPF6_STR
1462 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001463 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001464 )
1465{
hasso508e53e2004-05-18 18:57:06 +00001466 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001467 struct interface *ifp;
1468
1469 ifp = (struct interface *) vty->index;
1470 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001471
hasso508e53e2004-05-18 18:57:06 +00001472 oi = (struct ospf6_interface *) ifp->info;
1473 if (oi == NULL)
1474 oi = ospf6_interface_create (ifp);
1475 assert (oi);
paul718e3742002-12-13 20:15:29 +00001476
hasso508e53e2004-05-18 18:57:06 +00001477 oi->priority = strtol (argv[0], NULL, 10);
1478
Christian Franke7d4aa1d2012-12-13 16:10:05 +01001479 if (oi->area &&
1480 (oi->state == OSPF6_INTERFACE_DROTHER ||
1481 oi->state == OSPF6_INTERFACE_BDR ||
1482 oi->state == OSPF6_INTERFACE_DR))
hasso508e53e2004-05-18 18:57:06 +00001483 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001484
1485 return CMD_SUCCESS;
1486}
1487
1488DEFUN (ipv6_ospf6_instance,
1489 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001490 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001491 IP6_STR
1492 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001493 "Instance ID for this interface\n"
1494 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001495 )
1496{
hasso508e53e2004-05-18 18:57:06 +00001497 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001498 struct interface *ifp;
1499
1500 ifp = (struct interface *)vty->index;
1501 assert (ifp);
1502
hasso508e53e2004-05-18 18:57:06 +00001503 oi = (struct ospf6_interface *)ifp->info;
1504 if (oi == NULL)
1505 oi = ospf6_interface_create (ifp);
1506 assert (oi);
paul718e3742002-12-13 20:15:29 +00001507
hasso508e53e2004-05-18 18:57:06 +00001508 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001509 return CMD_SUCCESS;
1510}
1511
1512DEFUN (ipv6_ospf6_passive,
1513 ipv6_ospf6_passive_cmd,
1514 "ipv6 ospf6 passive",
1515 IP6_STR
1516 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001517 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001518 )
1519{
hasso508e53e2004-05-18 18:57:06 +00001520 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001521 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001522 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001523 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001524
1525 ifp = (struct interface *) vty->index;
1526 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001527
hasso508e53e2004-05-18 18:57:06 +00001528 oi = (struct ospf6_interface *) ifp->info;
1529 if (oi == NULL)
1530 oi = ospf6_interface_create (ifp);
1531 assert (oi);
paul718e3742002-12-13 20:15:29 +00001532
hasso508e53e2004-05-18 18:57:06 +00001533 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1534 THREAD_OFF (oi->thread_send_hello);
1535
paul1eb8ef22005-04-07 07:30:20 +00001536 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001537 {
hasso508e53e2004-05-18 18:57:06 +00001538 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001539 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001540 }
1541
1542 return CMD_SUCCESS;
1543}
1544
1545DEFUN (no_ipv6_ospf6_passive,
1546 no_ipv6_ospf6_passive_cmd,
1547 "no ipv6 ospf6 passive",
1548 NO_STR
1549 IP6_STR
1550 OSPF6_STR
1551 "passive interface: No Adjacency will be formed on this I/F\n"
1552 )
1553{
hasso508e53e2004-05-18 18:57:06 +00001554 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001555 struct interface *ifp;
1556
1557 ifp = (struct interface *) vty->index;
1558 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001559
hasso508e53e2004-05-18 18:57:06 +00001560 oi = (struct ospf6_interface *) ifp->info;
1561 if (oi == NULL)
1562 oi = ospf6_interface_create (ifp);
1563 assert (oi);
paul718e3742002-12-13 20:15:29 +00001564
hasso508e53e2004-05-18 18:57:06 +00001565 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1566 THREAD_OFF (oi->thread_send_hello);
1567 oi->thread_send_hello =
1568 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001569
1570 return CMD_SUCCESS;
1571}
1572
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001573DEFUN (ipv6_ospf6_mtu_ignore,
1574 ipv6_ospf6_mtu_ignore_cmd,
1575 "ipv6 ospf6 mtu-ignore",
1576 IP6_STR
1577 OSPF6_STR
1578 "Ignore MTU mismatch on this interface\n"
1579 )
1580{
1581 struct ospf6_interface *oi;
1582 struct interface *ifp;
1583
1584 ifp = (struct interface *) vty->index;
1585 assert (ifp);
1586
1587 oi = (struct ospf6_interface *) ifp->info;
1588 if (oi == NULL)
1589 oi = ospf6_interface_create (ifp);
1590 assert (oi);
1591
1592 oi->mtu_ignore = 1;
1593
1594 return CMD_SUCCESS;
1595}
1596
1597DEFUN (no_ipv6_ospf6_mtu_ignore,
1598 no_ipv6_ospf6_mtu_ignore_cmd,
1599 "no ipv6 ospf6 mtu-ignore",
1600 NO_STR
1601 IP6_STR
1602 OSPF6_STR
1603 "Ignore MTU mismatch on this interface\n"
1604 )
1605{
1606 struct ospf6_interface *oi;
1607 struct interface *ifp;
1608
1609 ifp = (struct interface *) vty->index;
1610 assert (ifp);
1611
1612 oi = (struct ospf6_interface *) ifp->info;
1613 if (oi == NULL)
1614 oi = ospf6_interface_create (ifp);
1615 assert (oi);
1616
1617 oi->mtu_ignore = 0;
1618
1619 return CMD_SUCCESS;
1620}
1621
paul718e3742002-12-13 20:15:29 +00001622DEFUN (ipv6_ospf6_advertise_prefix_list,
1623 ipv6_ospf6_advertise_prefix_list_cmd,
1624 "ipv6 ospf6 advertise prefix-list WORD",
1625 IP6_STR
1626 OSPF6_STR
1627 "Advertising options\n"
1628 "Filter prefix using prefix-list\n"
1629 "Prefix list name\n"
1630 )
1631{
hasso508e53e2004-05-18 18:57:06 +00001632 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001633 struct interface *ifp;
1634
1635 ifp = (struct interface *) vty->index;
1636 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001637
hasso508e53e2004-05-18 18:57:06 +00001638 oi = (struct ospf6_interface *) ifp->info;
1639 if (oi == NULL)
1640 oi = ospf6_interface_create (ifp);
1641 assert (oi);
paul718e3742002-12-13 20:15:29 +00001642
hasso508e53e2004-05-18 18:57:06 +00001643 if (oi->plist_name)
1644 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1645 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001646
hasso508e53e2004-05-18 18:57:06 +00001647 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001648
1649 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001650 {
David Ward2470e992010-01-05 02:45:39 +00001651 OSPF6_LINK_LSA_SCHEDULE (oi);
1652 if (oi->state == OSPF6_INTERFACE_DR)
1653 {
1654 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1655 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1656 }
1657 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001658 }
paul718e3742002-12-13 20:15:29 +00001659
1660 return CMD_SUCCESS;
1661}
1662
1663DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1664 no_ipv6_ospf6_advertise_prefix_list_cmd,
1665 "no ipv6 ospf6 advertise prefix-list",
1666 NO_STR
1667 IP6_STR
1668 OSPF6_STR
1669 "Advertising options\n"
1670 "Filter prefix using prefix-list\n"
1671 )
1672{
hasso508e53e2004-05-18 18:57:06 +00001673 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001674 struct interface *ifp;
1675
1676 ifp = (struct interface *) vty->index;
1677 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001678
hasso508e53e2004-05-18 18:57:06 +00001679 oi = (struct ospf6_interface *) ifp->info;
1680 if (oi == NULL)
1681 oi = ospf6_interface_create (ifp);
1682 assert (oi);
1683
1684 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001685 {
hasso508e53e2004-05-18 18:57:06 +00001686 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1687 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001688 }
1689
hasso508e53e2004-05-18 18:57:06 +00001690 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001691
1692 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001693 {
David Ward2470e992010-01-05 02:45:39 +00001694 OSPF6_LINK_LSA_SCHEDULE (oi);
1695 if (oi->state == OSPF6_INTERFACE_DR)
1696 {
1697 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1698 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1699 }
1700 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001701 }
paul718e3742002-12-13 20:15:29 +00001702
1703 return CMD_SUCCESS;
1704}
1705
Dinesh Duttc5926a92013-08-24 07:55:00 +00001706DEFUN (ipv6_ospf6_network,
1707 ipv6_ospf6_network_cmd,
1708 "ipv6 ospf6 network (broadcast|point-to-point)",
1709 IP6_STR
1710 OSPF6_STR
1711 "Network Type\n"
1712 "Specify OSPFv6 broadcast network\n"
1713 "Specify OSPF6 point-to-point network\n"
1714 )
1715{
1716 struct ospf6_interface *oi;
1717 struct interface *ifp;
1718
1719 ifp = (struct interface *) vty->index;
1720 assert (ifp);
1721
1722 oi = (struct ospf6_interface *) ifp->info;
1723 if (oi == NULL) {
1724 oi = ospf6_interface_create (ifp);
1725 }
1726 assert (oi);
1727
1728 if (strncmp (argv[0], "b", 1) == 0)
1729 {
1730 if (oi->type == OSPF_IFTYPE_BROADCAST)
1731 return CMD_SUCCESS;
1732
1733 oi->type = OSPF_IFTYPE_BROADCAST;
1734 }
1735 else if (strncmp (argv[0], "point-to-p", 10) == 0)
1736 {
1737 if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
1738 return CMD_SUCCESS;
1739 }
1740 oi->type = OSPF_IFTYPE_POINTOPOINT;
1741 }
1742
1743 /* Reset the interface */
1744 thread_add_event (master, interface_down, oi, 0);
1745 thread_add_event (master, interface_up, oi, 0);
1746
1747 return CMD_SUCCESS;
1748}
1749
1750DEFUN (no_ipv6_ospf6_network,
1751 no_ipv6_ospf6_network_cmd,
1752 "no ipv6 ospf6 network",
1753 NO_STR
1754 IP6_STR
1755 OSPF6_STR
1756 "Network Type\n"
1757 "Default to whatever interface type system specifies"
1758 )
1759{
1760 struct ospf6_interface *oi;
1761 struct interface *ifp;
1762 int type;
1763
1764 ifp = (struct interface *) vty->index;
1765 assert (ifp);
1766
1767 oi = (struct ospf6_interface *) ifp->info;
1768 if (oi == NULL) {
1769 return CMD_SUCCESS;
1770 }
1771
1772 type = ospf6_default_iftype (ifp);
1773 if (oi->type == type)
1774 {
1775 return CMD_SUCCESS;
1776 }
1777 oi->type = type;
1778
1779 /* Reset the interface */
1780 thread_add_event (master, interface_down, oi, 0);
1781 thread_add_event (master, interface_up, oi, 0);
1782
1783 return CMD_SUCCESS;
1784}
1785
Paul Jakma6ac29a52008-08-15 13:45:30 +01001786static int
hasso508e53e2004-05-18 18:57:06 +00001787config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001788{
hasso52dc7ee2004-09-23 19:18:23 +00001789 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001790 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001791 struct interface *ifp;
1792
paul1eb8ef22005-04-07 07:30:20 +00001793 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001794 {
hasso508e53e2004-05-18 18:57:06 +00001795 oi = (struct ospf6_interface *) ifp->info;
1796 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001797 continue;
1798
1799 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001800 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001801
1802 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001803 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso1203e1c2004-07-23 21:34:27 +00001804 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001805 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001806
Vincent Bernatc19543b2012-10-24 14:45:53 +00001807 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001808 vty_out (vty, " ipv6 ospf6 cost %d%s",
1809 oi->cost, VNL);
1810
1811 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1812 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1813 oi->hello_interval, VNL);
1814
1815 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1816 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1817 oi->dead_interval, VNL);
1818
1819 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1820 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1821 oi->rxmt_interval, VNL);
1822
1823 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1824 vty_out (vty, " ipv6 ospf6 priority %d%s",
1825 oi->priority, VNL);
1826
1827 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1828 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1829 oi->transdelay, VNL);
1830
1831 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1832 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1833 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001834
hasso508e53e2004-05-18 18:57:06 +00001835 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001836 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001837 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001838
hasso508e53e2004-05-18 18:57:06 +00001839 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001840 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001841
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001842 if (oi->mtu_ignore)
1843 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1844
Dinesh Duttc5926a92013-08-24 07:55:00 +00001845 if (oi->type == OSPF_IFTYPE_POINTOPOINT)
1846 vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
1847 else if (oi->type == OSPF_IFTYPE_BROADCAST)
1848 vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
1849
hasso049207c2004-08-04 20:02:13 +00001850 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001851 }
1852 return 0;
1853}
1854
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001855static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001856{
1857 INTERFACE_NODE,
1858 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001859 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001860};
1861
1862void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001863ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001864{
1865 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001866 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001867
1868 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001869 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1870 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1871 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001872 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001873 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1874 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1875 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001876 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001877 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1878 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1879 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001880 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001881 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1882 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1883 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001884
hasso508e53e2004-05-18 18:57:06 +00001885 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001886 install_default (INTERFACE_NODE);
1887 install_element (INTERFACE_NODE, &interface_desc_cmd);
1888 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1889 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
Vincent Bernatc19543b2012-10-24 14:45:53 +00001890 install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001891 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001892 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001893 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1894 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1895 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1896 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1897 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1898 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001899
paul718e3742002-12-13 20:15:29 +00001900 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1901 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001902
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001903 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1904 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1905
hasso508e53e2004-05-18 18:57:06 +00001906 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1907 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
Dinesh Duttc5926a92013-08-24 07:55:00 +00001908
1909 install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
1910 install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
Vincent Bernatfd500682012-10-24 14:45:54 +00001911
1912 /* reference bandwidth commands */
1913 install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
1914 install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
hasso508e53e2004-05-18 18:57:06 +00001915}
1916
1917DEFUN (debug_ospf6_interface,
1918 debug_ospf6_interface_cmd,
1919 "debug ospf6 interface",
1920 DEBUG_STR
1921 OSPF6_STR
1922 "Debug OSPFv3 Interface\n"
1923 )
1924{
1925 OSPF6_DEBUG_INTERFACE_ON ();
1926 return CMD_SUCCESS;
1927}
1928
1929DEFUN (no_debug_ospf6_interface,
1930 no_debug_ospf6_interface_cmd,
1931 "no debug ospf6 interface",
1932 NO_STR
1933 DEBUG_STR
1934 OSPF6_STR
1935 "Debug OSPFv3 Interface\n"
1936 )
1937{
hasso3b687352004-08-19 06:56:53 +00001938 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001939 return CMD_SUCCESS;
1940}
1941
1942int
1943config_write_ospf6_debug_interface (struct vty *vty)
1944{
1945 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001946 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001947 return 0;
1948}
1949
1950void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001951install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001952{
1953 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1954 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1955 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1956 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001957}
1958
1959