blob: 4bc61551853ec787fa37db6d8021a257f41a451e [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
519
520/* 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
676
677/* 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
846
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;
1286 unsigned long int lcost;
1287
1288 ifp = (struct interface *) vty->index;
1289 assert (ifp);
1290
1291 oi = (struct ospf6_interface *) ifp->info;
1292 if (oi == NULL)
1293 oi = ospf6_interface_create (ifp);
1294 assert (oi);
1295
1296 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
1297
1298 ospf6_interface_recalculate_cost(oi);
hasso508e53e2004-05-18 18:57:06 +00001299
1300 return CMD_SUCCESS;
1301}
1302
Vincent Bernatfd500682012-10-24 14:45:54 +00001303DEFUN (auto_cost_reference_bandwidth,
1304 auto_cost_reference_bandwidth_cmd,
1305 "auto-cost reference-bandwidth <1-4294967>",
1306 "Calculate OSPF interface cost according to bandwidth\n"
1307 "Use reference bandwidth method to assign OSPF cost\n"
1308 "The reference bandwidth in terms of Mbits per second\n")
1309{
1310 struct ospf6 *o = vty->index;
1311 struct ospf6_area *oa;
1312 struct ospf6_interface *oi;
1313 struct listnode *i, *j;
1314 u_int32_t refbw;
1315
1316 refbw = strtol (argv[0], NULL, 10);
1317 if (refbw < 1 || refbw > 4294967)
1318 {
1319 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
1320 return CMD_WARNING;
1321 }
1322
1323 /* If reference bandwidth is changed. */
1324 if ((refbw * 1000) == o->ref_bandwidth)
1325 return CMD_SUCCESS;
1326
1327 o->ref_bandwidth = refbw * 1000;
1328 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1329 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1330 ospf6_interface_recalculate_cost (oi);
1331
1332 return CMD_SUCCESS;
1333}
1334
1335DEFUN (no_auto_cost_reference_bandwidth,
1336 no_auto_cost_reference_bandwidth_cmd,
1337 "no auto-cost reference-bandwidth",
1338 NO_STR
1339 "Calculate OSPF interface cost according to bandwidth\n"
1340 "Use reference bandwidth method to assign OSPF cost\n")
1341{
1342 struct ospf6 *o = vty->index;
1343 struct ospf6_area *oa;
1344 struct ospf6_interface *oi;
1345 struct listnode *i, *j;
1346
1347 if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
1348 return CMD_SUCCESS;
1349
1350 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
1351 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
1352 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
1353 ospf6_interface_recalculate_cost (oi);
1354
1355 return CMD_SUCCESS;
1356}
1357
hasso508e53e2004-05-18 18:57:06 +00001358DEFUN (ipv6_ospf6_hellointerval,
1359 ipv6_ospf6_hellointerval_cmd,
1360 "ipv6 ospf6 hello-interval <1-65535>",
1361 IP6_STR
1362 OSPF6_STR
1363 "Interval time of Hello packets\n"
1364 SECONDS_STR
1365 )
1366{
1367 struct ospf6_interface *oi;
1368 struct interface *ifp;
1369
1370 ifp = (struct interface *) vty->index;
1371 assert (ifp);
1372
1373 oi = (struct ospf6_interface *) ifp->info;
1374 if (oi == NULL)
1375 oi = ospf6_interface_create (ifp);
1376 assert (oi);
1377
1378 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001379 return CMD_SUCCESS;
1380}
1381
1382/* interface variable set command */
1383DEFUN (ipv6_ospf6_deadinterval,
1384 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001385 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001386 IP6_STR
1387 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001388 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001389 SECONDS_STR
1390 )
1391{
hasso508e53e2004-05-18 18:57:06 +00001392 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001393 struct interface *ifp;
1394
1395 ifp = (struct interface *) vty->index;
1396 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001397
hasso508e53e2004-05-18 18:57:06 +00001398 oi = (struct ospf6_interface *) ifp->info;
1399 if (oi == NULL)
1400 oi = ospf6_interface_create (ifp);
1401 assert (oi);
1402
1403 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001404 return CMD_SUCCESS;
1405}
1406
1407/* interface variable set command */
1408DEFUN (ipv6_ospf6_transmitdelay,
1409 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001410 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001411 IP6_STR
1412 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001413 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001414 SECONDS_STR
1415 )
1416{
hasso508e53e2004-05-18 18:57:06 +00001417 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001418 struct interface *ifp;
1419
1420 ifp = (struct interface *) vty->index;
1421 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001422
hasso508e53e2004-05-18 18:57:06 +00001423 oi = (struct ospf6_interface *) ifp->info;
1424 if (oi == NULL)
1425 oi = ospf6_interface_create (ifp);
1426 assert (oi);
1427
1428 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001429 return CMD_SUCCESS;
1430}
1431
1432/* interface variable set command */
1433DEFUN (ipv6_ospf6_retransmitinterval,
1434 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001435 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001436 IP6_STR
1437 OSPF6_STR
1438 "Time between retransmitting lost link state advertisements\n"
1439 SECONDS_STR
1440 )
1441{
hasso508e53e2004-05-18 18:57:06 +00001442 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001443 struct interface *ifp;
1444
1445 ifp = (struct interface *) vty->index;
1446 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001447
hasso508e53e2004-05-18 18:57:06 +00001448 oi = (struct ospf6_interface *) ifp->info;
1449 if (oi == NULL)
1450 oi = ospf6_interface_create (ifp);
1451 assert (oi);
1452
1453 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001454 return CMD_SUCCESS;
1455}
1456
1457/* interface variable set command */
1458DEFUN (ipv6_ospf6_priority,
1459 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001460 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001461 IP6_STR
1462 OSPF6_STR
1463 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001464 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001465 )
1466{
hasso508e53e2004-05-18 18:57:06 +00001467 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001468 struct interface *ifp;
1469
1470 ifp = (struct interface *) vty->index;
1471 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001472
hasso508e53e2004-05-18 18:57:06 +00001473 oi = (struct ospf6_interface *) ifp->info;
1474 if (oi == NULL)
1475 oi = ospf6_interface_create (ifp);
1476 assert (oi);
paul718e3742002-12-13 20:15:29 +00001477
hasso508e53e2004-05-18 18:57:06 +00001478 oi->priority = strtol (argv[0], NULL, 10);
1479
Christian Franke7d4aa1d2012-12-13 16:10:05 +01001480 if (oi->area &&
1481 (oi->state == OSPF6_INTERFACE_DROTHER ||
1482 oi->state == OSPF6_INTERFACE_BDR ||
1483 oi->state == OSPF6_INTERFACE_DR))
hasso508e53e2004-05-18 18:57:06 +00001484 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001485
1486 return CMD_SUCCESS;
1487}
1488
1489DEFUN (ipv6_ospf6_instance,
1490 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001491 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001492 IP6_STR
1493 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001494 "Instance ID for this interface\n"
1495 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001496 )
1497{
hasso508e53e2004-05-18 18:57:06 +00001498 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001499 struct interface *ifp;
1500
1501 ifp = (struct interface *)vty->index;
1502 assert (ifp);
1503
hasso508e53e2004-05-18 18:57:06 +00001504 oi = (struct ospf6_interface *)ifp->info;
1505 if (oi == NULL)
1506 oi = ospf6_interface_create (ifp);
1507 assert (oi);
paul718e3742002-12-13 20:15:29 +00001508
hasso508e53e2004-05-18 18:57:06 +00001509 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001510 return CMD_SUCCESS;
1511}
1512
1513DEFUN (ipv6_ospf6_passive,
1514 ipv6_ospf6_passive_cmd,
1515 "ipv6 ospf6 passive",
1516 IP6_STR
1517 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001518 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001519 )
1520{
hasso508e53e2004-05-18 18:57:06 +00001521 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001522 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001523 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001524 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001525
1526 ifp = (struct interface *) vty->index;
1527 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001528
hasso508e53e2004-05-18 18:57:06 +00001529 oi = (struct ospf6_interface *) ifp->info;
1530 if (oi == NULL)
1531 oi = ospf6_interface_create (ifp);
1532 assert (oi);
paul718e3742002-12-13 20:15:29 +00001533
hasso508e53e2004-05-18 18:57:06 +00001534 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1535 THREAD_OFF (oi->thread_send_hello);
1536
paul1eb8ef22005-04-07 07:30:20 +00001537 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001538 {
hasso508e53e2004-05-18 18:57:06 +00001539 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001540 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001541 }
1542
1543 return CMD_SUCCESS;
1544}
1545
1546DEFUN (no_ipv6_ospf6_passive,
1547 no_ipv6_ospf6_passive_cmd,
1548 "no ipv6 ospf6 passive",
1549 NO_STR
1550 IP6_STR
1551 OSPF6_STR
1552 "passive interface: No Adjacency will be formed on this I/F\n"
1553 )
1554{
hasso508e53e2004-05-18 18:57:06 +00001555 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001556 struct interface *ifp;
1557
1558 ifp = (struct interface *) vty->index;
1559 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001560
hasso508e53e2004-05-18 18:57:06 +00001561 oi = (struct ospf6_interface *) ifp->info;
1562 if (oi == NULL)
1563 oi = ospf6_interface_create (ifp);
1564 assert (oi);
paul718e3742002-12-13 20:15:29 +00001565
hasso508e53e2004-05-18 18:57:06 +00001566 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1567 THREAD_OFF (oi->thread_send_hello);
1568 oi->thread_send_hello =
1569 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001570
1571 return CMD_SUCCESS;
1572}
1573
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001574DEFUN (ipv6_ospf6_mtu_ignore,
1575 ipv6_ospf6_mtu_ignore_cmd,
1576 "ipv6 ospf6 mtu-ignore",
1577 IP6_STR
1578 OSPF6_STR
1579 "Ignore MTU mismatch on this interface\n"
1580 )
1581{
1582 struct ospf6_interface *oi;
1583 struct interface *ifp;
1584
1585 ifp = (struct interface *) vty->index;
1586 assert (ifp);
1587
1588 oi = (struct ospf6_interface *) ifp->info;
1589 if (oi == NULL)
1590 oi = ospf6_interface_create (ifp);
1591 assert (oi);
1592
1593 oi->mtu_ignore = 1;
1594
1595 return CMD_SUCCESS;
1596}
1597
1598DEFUN (no_ipv6_ospf6_mtu_ignore,
1599 no_ipv6_ospf6_mtu_ignore_cmd,
1600 "no ipv6 ospf6 mtu-ignore",
1601 NO_STR
1602 IP6_STR
1603 OSPF6_STR
1604 "Ignore MTU mismatch on this interface\n"
1605 )
1606{
1607 struct ospf6_interface *oi;
1608 struct interface *ifp;
1609
1610 ifp = (struct interface *) vty->index;
1611 assert (ifp);
1612
1613 oi = (struct ospf6_interface *) ifp->info;
1614 if (oi == NULL)
1615 oi = ospf6_interface_create (ifp);
1616 assert (oi);
1617
1618 oi->mtu_ignore = 0;
1619
1620 return CMD_SUCCESS;
1621}
1622
paul718e3742002-12-13 20:15:29 +00001623DEFUN (ipv6_ospf6_advertise_prefix_list,
1624 ipv6_ospf6_advertise_prefix_list_cmd,
1625 "ipv6 ospf6 advertise prefix-list WORD",
1626 IP6_STR
1627 OSPF6_STR
1628 "Advertising options\n"
1629 "Filter prefix using prefix-list\n"
1630 "Prefix list name\n"
1631 )
1632{
hasso508e53e2004-05-18 18:57:06 +00001633 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001634 struct interface *ifp;
1635
1636 ifp = (struct interface *) vty->index;
1637 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001638
hasso508e53e2004-05-18 18:57:06 +00001639 oi = (struct ospf6_interface *) ifp->info;
1640 if (oi == NULL)
1641 oi = ospf6_interface_create (ifp);
1642 assert (oi);
paul718e3742002-12-13 20:15:29 +00001643
hasso508e53e2004-05-18 18:57:06 +00001644 if (oi->plist_name)
1645 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1646 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001647
hasso508e53e2004-05-18 18:57:06 +00001648 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001649
1650 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001651 {
David Ward2470e992010-01-05 02:45:39 +00001652 OSPF6_LINK_LSA_SCHEDULE (oi);
1653 if (oi->state == OSPF6_INTERFACE_DR)
1654 {
1655 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1656 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1657 }
1658 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001659 }
paul718e3742002-12-13 20:15:29 +00001660
1661 return CMD_SUCCESS;
1662}
1663
1664DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1665 no_ipv6_ospf6_advertise_prefix_list_cmd,
1666 "no ipv6 ospf6 advertise prefix-list",
1667 NO_STR
1668 IP6_STR
1669 OSPF6_STR
1670 "Advertising options\n"
1671 "Filter prefix using prefix-list\n"
1672 )
1673{
hasso508e53e2004-05-18 18:57:06 +00001674 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001675 struct interface *ifp;
1676
1677 ifp = (struct interface *) vty->index;
1678 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001679
hasso508e53e2004-05-18 18:57:06 +00001680 oi = (struct ospf6_interface *) ifp->info;
1681 if (oi == NULL)
1682 oi = ospf6_interface_create (ifp);
1683 assert (oi);
1684
1685 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001686 {
hasso508e53e2004-05-18 18:57:06 +00001687 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1688 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001689 }
1690
hasso508e53e2004-05-18 18:57:06 +00001691 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001692
1693 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001694 {
David Ward2470e992010-01-05 02:45:39 +00001695 OSPF6_LINK_LSA_SCHEDULE (oi);
1696 if (oi->state == OSPF6_INTERFACE_DR)
1697 {
1698 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1699 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1700 }
1701 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001702 }
paul718e3742002-12-13 20:15:29 +00001703
1704 return CMD_SUCCESS;
1705}
1706
Dinesh Duttc5926a92013-08-24 07:55:00 +00001707DEFUN (ipv6_ospf6_network,
1708 ipv6_ospf6_network_cmd,
1709 "ipv6 ospf6 network (broadcast|point-to-point)",
1710 IP6_STR
1711 OSPF6_STR
1712 "Network Type\n"
1713 "Specify OSPFv6 broadcast network\n"
1714 "Specify OSPF6 point-to-point network\n"
1715 )
1716{
1717 struct ospf6_interface *oi;
1718 struct interface *ifp;
1719
1720 ifp = (struct interface *) vty->index;
1721 assert (ifp);
1722
1723 oi = (struct ospf6_interface *) ifp->info;
1724 if (oi == NULL) {
1725 oi = ospf6_interface_create (ifp);
1726 }
1727 assert (oi);
1728
1729 if (strncmp (argv[0], "b", 1) == 0)
1730 {
1731 if (oi->type == OSPF_IFTYPE_BROADCAST)
1732 return CMD_SUCCESS;
1733
1734 oi->type = OSPF_IFTYPE_BROADCAST;
1735 }
1736 else if (strncmp (argv[0], "point-to-p", 10) == 0)
1737 {
1738 if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
1739 return CMD_SUCCESS;
1740 }
1741 oi->type = OSPF_IFTYPE_POINTOPOINT;
1742 }
1743
1744 /* Reset the interface */
1745 thread_add_event (master, interface_down, oi, 0);
1746 thread_add_event (master, interface_up, oi, 0);
1747
1748 return CMD_SUCCESS;
1749}
1750
1751DEFUN (no_ipv6_ospf6_network,
1752 no_ipv6_ospf6_network_cmd,
1753 "no ipv6 ospf6 network",
1754 NO_STR
1755 IP6_STR
1756 OSPF6_STR
1757 "Network Type\n"
1758 "Default to whatever interface type system specifies"
1759 )
1760{
1761 struct ospf6_interface *oi;
1762 struct interface *ifp;
1763 int type;
1764
1765 ifp = (struct interface *) vty->index;
1766 assert (ifp);
1767
1768 oi = (struct ospf6_interface *) ifp->info;
1769 if (oi == NULL) {
1770 return CMD_SUCCESS;
1771 }
1772
1773 type = ospf6_default_iftype (ifp);
1774 if (oi->type == type)
1775 {
1776 return CMD_SUCCESS;
1777 }
1778 oi->type = type;
1779
1780 /* Reset the interface */
1781 thread_add_event (master, interface_down, oi, 0);
1782 thread_add_event (master, interface_up, oi, 0);
1783
1784 return CMD_SUCCESS;
1785}
1786
Paul Jakma6ac29a52008-08-15 13:45:30 +01001787static int
hasso508e53e2004-05-18 18:57:06 +00001788config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001789{
hasso52dc7ee2004-09-23 19:18:23 +00001790 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001791 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001792 struct interface *ifp;
1793
paul1eb8ef22005-04-07 07:30:20 +00001794 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001795 {
hasso508e53e2004-05-18 18:57:06 +00001796 oi = (struct ospf6_interface *) ifp->info;
1797 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001798 continue;
1799
1800 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001801 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001802
1803 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001804 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso1203e1c2004-07-23 21:34:27 +00001805 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001806 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001807
Vincent Bernatc19543b2012-10-24 14:45:53 +00001808 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001809 vty_out (vty, " ipv6 ospf6 cost %d%s",
1810 oi->cost, VNL);
1811
1812 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1813 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1814 oi->hello_interval, VNL);
1815
1816 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1817 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1818 oi->dead_interval, VNL);
1819
1820 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1821 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1822 oi->rxmt_interval, VNL);
1823
1824 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1825 vty_out (vty, " ipv6 ospf6 priority %d%s",
1826 oi->priority, VNL);
1827
1828 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1829 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1830 oi->transdelay, VNL);
1831
1832 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1833 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1834 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001835
hasso508e53e2004-05-18 18:57:06 +00001836 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001837 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001838 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001839
hasso508e53e2004-05-18 18:57:06 +00001840 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001841 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001842
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001843 if (oi->mtu_ignore)
1844 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1845
Dinesh Duttc5926a92013-08-24 07:55:00 +00001846 if (oi->type == OSPF_IFTYPE_POINTOPOINT)
1847 vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
1848 else if (oi->type == OSPF_IFTYPE_BROADCAST)
1849 vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
1850
hasso049207c2004-08-04 20:02:13 +00001851 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001852 }
1853 return 0;
1854}
1855
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001856static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001857{
1858 INTERFACE_NODE,
1859 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001860 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001861};
1862
1863void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001864ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001865{
1866 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001867 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001868
1869 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001870 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1871 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1872 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001873 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001874 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1875 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1876 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001877 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001878 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1879 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1880 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001881 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001882 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1883 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1884 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001885
hasso508e53e2004-05-18 18:57:06 +00001886 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001887 install_default (INTERFACE_NODE);
1888 install_element (INTERFACE_NODE, &interface_desc_cmd);
1889 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1890 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
Vincent Bernatc19543b2012-10-24 14:45:53 +00001891 install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001892 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001893 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001894 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1895 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1896 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1897 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1898 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1899 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001900
paul718e3742002-12-13 20:15:29 +00001901 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1902 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001903
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001904 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1905 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1906
hasso508e53e2004-05-18 18:57:06 +00001907 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1908 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
Dinesh Duttc5926a92013-08-24 07:55:00 +00001909
1910 install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
1911 install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
Vincent Bernatfd500682012-10-24 14:45:54 +00001912
1913 /* reference bandwidth commands */
1914 install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
1915 install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
hasso508e53e2004-05-18 18:57:06 +00001916}
1917
1918DEFUN (debug_ospf6_interface,
1919 debug_ospf6_interface_cmd,
1920 "debug ospf6 interface",
1921 DEBUG_STR
1922 OSPF6_STR
1923 "Debug OSPFv3 Interface\n"
1924 )
1925{
1926 OSPF6_DEBUG_INTERFACE_ON ();
1927 return CMD_SUCCESS;
1928}
1929
1930DEFUN (no_debug_ospf6_interface,
1931 no_debug_ospf6_interface_cmd,
1932 "no debug ospf6 interface",
1933 NO_STR
1934 DEBUG_STR
1935 OSPF6_STR
1936 "Debug OSPFv3 Interface\n"
1937 )
1938{
hasso3b687352004-08-19 06:56:53 +00001939 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001940 return CMD_SUCCESS;
1941}
1942
1943int
1944config_write_ospf6_debug_interface (struct vty *vty)
1945{
1946 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001947 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001948 return 0;
1949}
1950
1951void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001952install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001953{
1954 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1955 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1956 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1957 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001958}
1959
1960