blob: e698893076d8efd97b37f7bba19c790e08976e8b [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;
128 refbw = OSPF6_REFERENCE_BANDWIDTH;
129
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
1303DEFUN (ipv6_ospf6_hellointerval,
1304 ipv6_ospf6_hellointerval_cmd,
1305 "ipv6 ospf6 hello-interval <1-65535>",
1306 IP6_STR
1307 OSPF6_STR
1308 "Interval time of Hello packets\n"
1309 SECONDS_STR
1310 )
1311{
1312 struct ospf6_interface *oi;
1313 struct interface *ifp;
1314
1315 ifp = (struct interface *) vty->index;
1316 assert (ifp);
1317
1318 oi = (struct ospf6_interface *) ifp->info;
1319 if (oi == NULL)
1320 oi = ospf6_interface_create (ifp);
1321 assert (oi);
1322
1323 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001324 return CMD_SUCCESS;
1325}
1326
1327/* interface variable set command */
1328DEFUN (ipv6_ospf6_deadinterval,
1329 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001330 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001331 IP6_STR
1332 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001333 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001334 SECONDS_STR
1335 )
1336{
hasso508e53e2004-05-18 18:57:06 +00001337 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001338 struct interface *ifp;
1339
1340 ifp = (struct interface *) vty->index;
1341 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001342
hasso508e53e2004-05-18 18:57:06 +00001343 oi = (struct ospf6_interface *) ifp->info;
1344 if (oi == NULL)
1345 oi = ospf6_interface_create (ifp);
1346 assert (oi);
1347
1348 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001349 return CMD_SUCCESS;
1350}
1351
1352/* interface variable set command */
1353DEFUN (ipv6_ospf6_transmitdelay,
1354 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001355 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001356 IP6_STR
1357 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001358 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001359 SECONDS_STR
1360 )
1361{
hasso508e53e2004-05-18 18:57:06 +00001362 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001363 struct interface *ifp;
1364
1365 ifp = (struct interface *) vty->index;
1366 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001367
hasso508e53e2004-05-18 18:57:06 +00001368 oi = (struct ospf6_interface *) ifp->info;
1369 if (oi == NULL)
1370 oi = ospf6_interface_create (ifp);
1371 assert (oi);
1372
1373 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001374 return CMD_SUCCESS;
1375}
1376
1377/* interface variable set command */
1378DEFUN (ipv6_ospf6_retransmitinterval,
1379 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001380 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001381 IP6_STR
1382 OSPF6_STR
1383 "Time between retransmitting lost link state advertisements\n"
1384 SECONDS_STR
1385 )
1386{
hasso508e53e2004-05-18 18:57:06 +00001387 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001388 struct interface *ifp;
1389
1390 ifp = (struct interface *) vty->index;
1391 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001392
hasso508e53e2004-05-18 18:57:06 +00001393 oi = (struct ospf6_interface *) ifp->info;
1394 if (oi == NULL)
1395 oi = ospf6_interface_create (ifp);
1396 assert (oi);
1397
1398 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001399 return CMD_SUCCESS;
1400}
1401
1402/* interface variable set command */
1403DEFUN (ipv6_ospf6_priority,
1404 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001405 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001406 IP6_STR
1407 OSPF6_STR
1408 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001409 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001410 )
1411{
hasso508e53e2004-05-18 18:57:06 +00001412 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001413 struct interface *ifp;
1414
1415 ifp = (struct interface *) vty->index;
1416 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001417
hasso508e53e2004-05-18 18:57:06 +00001418 oi = (struct ospf6_interface *) ifp->info;
1419 if (oi == NULL)
1420 oi = ospf6_interface_create (ifp);
1421 assert (oi);
paul718e3742002-12-13 20:15:29 +00001422
hasso508e53e2004-05-18 18:57:06 +00001423 oi->priority = strtol (argv[0], NULL, 10);
1424
Christian Franke7d4aa1d2012-12-13 16:10:05 +01001425 if (oi->area &&
1426 (oi->state == OSPF6_INTERFACE_DROTHER ||
1427 oi->state == OSPF6_INTERFACE_BDR ||
1428 oi->state == OSPF6_INTERFACE_DR))
hasso508e53e2004-05-18 18:57:06 +00001429 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001430
1431 return CMD_SUCCESS;
1432}
1433
1434DEFUN (ipv6_ospf6_instance,
1435 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001436 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001437 IP6_STR
1438 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001439 "Instance ID for this interface\n"
1440 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001441 )
1442{
hasso508e53e2004-05-18 18:57:06 +00001443 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001444 struct interface *ifp;
1445
1446 ifp = (struct interface *)vty->index;
1447 assert (ifp);
1448
hasso508e53e2004-05-18 18:57:06 +00001449 oi = (struct ospf6_interface *)ifp->info;
1450 if (oi == NULL)
1451 oi = ospf6_interface_create (ifp);
1452 assert (oi);
paul718e3742002-12-13 20:15:29 +00001453
hasso508e53e2004-05-18 18:57:06 +00001454 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001455 return CMD_SUCCESS;
1456}
1457
1458DEFUN (ipv6_ospf6_passive,
1459 ipv6_ospf6_passive_cmd,
1460 "ipv6 ospf6 passive",
1461 IP6_STR
1462 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001463 "passive interface, No adjacency will be formed on this interface\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;
paul1eb8ef22005-04-07 07:30:20 +00001468 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001469 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001470
1471 ifp = (struct interface *) vty->index;
1472 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001473
hasso508e53e2004-05-18 18:57:06 +00001474 oi = (struct ospf6_interface *) ifp->info;
1475 if (oi == NULL)
1476 oi = ospf6_interface_create (ifp);
1477 assert (oi);
paul718e3742002-12-13 20:15:29 +00001478
hasso508e53e2004-05-18 18:57:06 +00001479 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1480 THREAD_OFF (oi->thread_send_hello);
1481
paul1eb8ef22005-04-07 07:30:20 +00001482 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001483 {
hasso508e53e2004-05-18 18:57:06 +00001484 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001485 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001486 }
1487
1488 return CMD_SUCCESS;
1489}
1490
1491DEFUN (no_ipv6_ospf6_passive,
1492 no_ipv6_ospf6_passive_cmd,
1493 "no ipv6 ospf6 passive",
1494 NO_STR
1495 IP6_STR
1496 OSPF6_STR
1497 "passive interface: No Adjacency will be formed on this I/F\n"
1498 )
1499{
hasso508e53e2004-05-18 18:57:06 +00001500 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001501 struct interface *ifp;
1502
1503 ifp = (struct interface *) vty->index;
1504 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001505
hasso508e53e2004-05-18 18:57:06 +00001506 oi = (struct ospf6_interface *) ifp->info;
1507 if (oi == NULL)
1508 oi = ospf6_interface_create (ifp);
1509 assert (oi);
paul718e3742002-12-13 20:15:29 +00001510
hasso508e53e2004-05-18 18:57:06 +00001511 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1512 THREAD_OFF (oi->thread_send_hello);
1513 oi->thread_send_hello =
1514 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001515
1516 return CMD_SUCCESS;
1517}
1518
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001519DEFUN (ipv6_ospf6_mtu_ignore,
1520 ipv6_ospf6_mtu_ignore_cmd,
1521 "ipv6 ospf6 mtu-ignore",
1522 IP6_STR
1523 OSPF6_STR
1524 "Ignore MTU mismatch on this interface\n"
1525 )
1526{
1527 struct ospf6_interface *oi;
1528 struct interface *ifp;
1529
1530 ifp = (struct interface *) vty->index;
1531 assert (ifp);
1532
1533 oi = (struct ospf6_interface *) ifp->info;
1534 if (oi == NULL)
1535 oi = ospf6_interface_create (ifp);
1536 assert (oi);
1537
1538 oi->mtu_ignore = 1;
1539
1540 return CMD_SUCCESS;
1541}
1542
1543DEFUN (no_ipv6_ospf6_mtu_ignore,
1544 no_ipv6_ospf6_mtu_ignore_cmd,
1545 "no ipv6 ospf6 mtu-ignore",
1546 NO_STR
1547 IP6_STR
1548 OSPF6_STR
1549 "Ignore MTU mismatch on this interface\n"
1550 )
1551{
1552 struct ospf6_interface *oi;
1553 struct interface *ifp;
1554
1555 ifp = (struct interface *) vty->index;
1556 assert (ifp);
1557
1558 oi = (struct ospf6_interface *) ifp->info;
1559 if (oi == NULL)
1560 oi = ospf6_interface_create (ifp);
1561 assert (oi);
1562
1563 oi->mtu_ignore = 0;
1564
1565 return CMD_SUCCESS;
1566}
1567
paul718e3742002-12-13 20:15:29 +00001568DEFUN (ipv6_ospf6_advertise_prefix_list,
1569 ipv6_ospf6_advertise_prefix_list_cmd,
1570 "ipv6 ospf6 advertise prefix-list WORD",
1571 IP6_STR
1572 OSPF6_STR
1573 "Advertising options\n"
1574 "Filter prefix using prefix-list\n"
1575 "Prefix list name\n"
1576 )
1577{
hasso508e53e2004-05-18 18:57:06 +00001578 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001579 struct interface *ifp;
1580
1581 ifp = (struct interface *) vty->index;
1582 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001583
hasso508e53e2004-05-18 18:57:06 +00001584 oi = (struct ospf6_interface *) ifp->info;
1585 if (oi == NULL)
1586 oi = ospf6_interface_create (ifp);
1587 assert (oi);
paul718e3742002-12-13 20:15:29 +00001588
hasso508e53e2004-05-18 18:57:06 +00001589 if (oi->plist_name)
1590 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1591 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001592
hasso508e53e2004-05-18 18:57:06 +00001593 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001594
1595 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001596 {
David Ward2470e992010-01-05 02:45:39 +00001597 OSPF6_LINK_LSA_SCHEDULE (oi);
1598 if (oi->state == OSPF6_INTERFACE_DR)
1599 {
1600 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1601 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1602 }
1603 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001604 }
paul718e3742002-12-13 20:15:29 +00001605
1606 return CMD_SUCCESS;
1607}
1608
1609DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1610 no_ipv6_ospf6_advertise_prefix_list_cmd,
1611 "no ipv6 ospf6 advertise prefix-list",
1612 NO_STR
1613 IP6_STR
1614 OSPF6_STR
1615 "Advertising options\n"
1616 "Filter prefix using prefix-list\n"
1617 )
1618{
hasso508e53e2004-05-18 18:57:06 +00001619 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001620 struct interface *ifp;
1621
1622 ifp = (struct interface *) vty->index;
1623 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001624
hasso508e53e2004-05-18 18:57:06 +00001625 oi = (struct ospf6_interface *) ifp->info;
1626 if (oi == NULL)
1627 oi = ospf6_interface_create (ifp);
1628 assert (oi);
1629
1630 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001631 {
hasso508e53e2004-05-18 18:57:06 +00001632 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1633 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001634 }
1635
hasso508e53e2004-05-18 18:57:06 +00001636 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001637
1638 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001639 {
David Ward2470e992010-01-05 02:45:39 +00001640 OSPF6_LINK_LSA_SCHEDULE (oi);
1641 if (oi->state == OSPF6_INTERFACE_DR)
1642 {
1643 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1644 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1645 }
1646 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001647 }
paul718e3742002-12-13 20:15:29 +00001648
1649 return CMD_SUCCESS;
1650}
1651
Dinesh Duttc5926a92013-08-24 07:55:00 +00001652DEFUN (ipv6_ospf6_network,
1653 ipv6_ospf6_network_cmd,
1654 "ipv6 ospf6 network (broadcast|point-to-point)",
1655 IP6_STR
1656 OSPF6_STR
1657 "Network Type\n"
1658 "Specify OSPFv6 broadcast network\n"
1659 "Specify OSPF6 point-to-point network\n"
1660 )
1661{
1662 struct ospf6_interface *oi;
1663 struct interface *ifp;
1664
1665 ifp = (struct interface *) vty->index;
1666 assert (ifp);
1667
1668 oi = (struct ospf6_interface *) ifp->info;
1669 if (oi == NULL) {
1670 oi = ospf6_interface_create (ifp);
1671 }
1672 assert (oi);
1673
1674 if (strncmp (argv[0], "b", 1) == 0)
1675 {
1676 if (oi->type == OSPF_IFTYPE_BROADCAST)
1677 return CMD_SUCCESS;
1678
1679 oi->type = OSPF_IFTYPE_BROADCAST;
1680 }
1681 else if (strncmp (argv[0], "point-to-p", 10) == 0)
1682 {
1683 if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
1684 return CMD_SUCCESS;
1685 }
1686 oi->type = OSPF_IFTYPE_POINTOPOINT;
1687 }
1688
1689 /* Reset the interface */
1690 thread_add_event (master, interface_down, oi, 0);
1691 thread_add_event (master, interface_up, oi, 0);
1692
1693 return CMD_SUCCESS;
1694}
1695
1696DEFUN (no_ipv6_ospf6_network,
1697 no_ipv6_ospf6_network_cmd,
1698 "no ipv6 ospf6 network",
1699 NO_STR
1700 IP6_STR
1701 OSPF6_STR
1702 "Network Type\n"
1703 "Default to whatever interface type system specifies"
1704 )
1705{
1706 struct ospf6_interface *oi;
1707 struct interface *ifp;
1708 int type;
1709
1710 ifp = (struct interface *) vty->index;
1711 assert (ifp);
1712
1713 oi = (struct ospf6_interface *) ifp->info;
1714 if (oi == NULL) {
1715 return CMD_SUCCESS;
1716 }
1717
1718 type = ospf6_default_iftype (ifp);
1719 if (oi->type == type)
1720 {
1721 return CMD_SUCCESS;
1722 }
1723 oi->type = type;
1724
1725 /* Reset the interface */
1726 thread_add_event (master, interface_down, oi, 0);
1727 thread_add_event (master, interface_up, oi, 0);
1728
1729 return CMD_SUCCESS;
1730}
1731
Paul Jakma6ac29a52008-08-15 13:45:30 +01001732static int
hasso508e53e2004-05-18 18:57:06 +00001733config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001734{
hasso52dc7ee2004-09-23 19:18:23 +00001735 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001736 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001737 struct interface *ifp;
1738
paul1eb8ef22005-04-07 07:30:20 +00001739 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001740 {
hasso508e53e2004-05-18 18:57:06 +00001741 oi = (struct ospf6_interface *) ifp->info;
1742 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001743 continue;
1744
1745 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001746 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001747
1748 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001749 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso1203e1c2004-07-23 21:34:27 +00001750 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001751 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001752
Vincent Bernatc19543b2012-10-24 14:45:53 +00001753 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001754 vty_out (vty, " ipv6 ospf6 cost %d%s",
1755 oi->cost, VNL);
1756
1757 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1758 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1759 oi->hello_interval, VNL);
1760
1761 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1762 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1763 oi->dead_interval, VNL);
1764
1765 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1766 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1767 oi->rxmt_interval, VNL);
1768
1769 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1770 vty_out (vty, " ipv6 ospf6 priority %d%s",
1771 oi->priority, VNL);
1772
1773 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1774 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1775 oi->transdelay, VNL);
1776
1777 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1778 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1779 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001780
hasso508e53e2004-05-18 18:57:06 +00001781 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001782 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001783 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001784
hasso508e53e2004-05-18 18:57:06 +00001785 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001786 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001787
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001788 if (oi->mtu_ignore)
1789 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1790
Dinesh Duttc5926a92013-08-24 07:55:00 +00001791 if (oi->type == OSPF_IFTYPE_POINTOPOINT)
1792 vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
1793 else if (oi->type == OSPF_IFTYPE_BROADCAST)
1794 vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
1795
hasso049207c2004-08-04 20:02:13 +00001796 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001797 }
1798 return 0;
1799}
1800
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001801static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001802{
1803 INTERFACE_NODE,
1804 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001805 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001806};
1807
1808void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001809ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001810{
1811 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001812 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001813
1814 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001815 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1816 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1817 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001818 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001819 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1820 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1821 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001822 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001823 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1824 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1825 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001826 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001827 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1828 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1829 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001830
hasso508e53e2004-05-18 18:57:06 +00001831 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001832 install_default (INTERFACE_NODE);
1833 install_element (INTERFACE_NODE, &interface_desc_cmd);
1834 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1835 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
Vincent Bernatc19543b2012-10-24 14:45:53 +00001836 install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001837 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001838 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001839 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1840 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1841 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1842 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1843 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1844 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001845
paul718e3742002-12-13 20:15:29 +00001846 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1847 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001848
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001849 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1850 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1851
hasso508e53e2004-05-18 18:57:06 +00001852 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1853 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
Dinesh Duttc5926a92013-08-24 07:55:00 +00001854
1855 install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
1856 install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
hasso508e53e2004-05-18 18:57:06 +00001857}
1858
1859DEFUN (debug_ospf6_interface,
1860 debug_ospf6_interface_cmd,
1861 "debug ospf6 interface",
1862 DEBUG_STR
1863 OSPF6_STR
1864 "Debug OSPFv3 Interface\n"
1865 )
1866{
1867 OSPF6_DEBUG_INTERFACE_ON ();
1868 return CMD_SUCCESS;
1869}
1870
1871DEFUN (no_debug_ospf6_interface,
1872 no_debug_ospf6_interface_cmd,
1873 "no debug ospf6 interface",
1874 NO_STR
1875 DEBUG_STR
1876 OSPF6_STR
1877 "Debug OSPFv3 Interface\n"
1878 )
1879{
hasso3b687352004-08-19 06:56:53 +00001880 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001881 return CMD_SUCCESS;
1882}
1883
1884int
1885config_write_ospf6_debug_interface (struct vty *vty)
1886{
1887 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001888 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001889 return 0;
1890}
1891
1892void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001893install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001894{
1895 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1896 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1897 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1898 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001899}
1900
1901