blob: 7c45fe46a8255f0c4a4356d78c388007ca3d9b48 [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
hasso508e53e2004-05-18 18:57:06 +000076ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa)
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);
89 ospf6_spf_schedule (oi->area->ospf6);
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
97/* Create new ospf6 interface structure */
98struct ospf6_interface *
99ospf6_interface_create (struct interface *ifp)
100{
hasso508e53e2004-05-18 18:57:06 +0000101 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000102 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000103
hasso508e53e2004-05-18 18:57:06 +0000104 oi = (struct ospf6_interface *)
Stephen Hemminger393deb92008-08-18 14:13:29 -0700105 XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
paul718e3742002-12-13 20:15:29 +0000106
Stephen Hemminger393deb92008-08-18 14:13:29 -0700107 if (!oi)
paul718e3742002-12-13 20:15:29 +0000108 {
109 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
110 return (struct ospf6_interface *) NULL;
111 }
112
hasso508e53e2004-05-18 18:57:06 +0000113 oi->area = (struct ospf6_area *) NULL;
114 oi->neighbor_list = list_new ();
115 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
116 oi->linklocal_addr = (struct in6_addr *) NULL;
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +0400117 oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
118 oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
119 oi->priority = OSPF6_INTERFACE_PRIORITY;
paul718e3742002-12-13 20:15:29 +0000120
Dinesh Dutt8551e6d2013-10-22 17:42:18 -0700121 oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
122 oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
123 oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +0400124 oi->cost = OSPF6_INTERFACE_COST;
hasso508e53e2004-05-18 18:57:06 +0000125 oi->state = OSPF6_INTERFACE_DOWN;
126 oi->flag = 0;
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400127 oi->mtu_ignore = 0;
paul718e3742002-12-13 20:15:29 +0000128
hassob596c712004-07-09 18:33:43 +0000129 /* Try to adjust I/O buffer size with IfMtu */
hasso1203e1c2004-07-23 21:34:27 +0000130 oi->ifmtu = ifp->mtu6;
131 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000132 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000133 {
hasso1e058382004-09-01 21:36:14 +0000134 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000135 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
136 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000137 oi->ifmtu = iobuflen;
138 }
hasso3b4cd3a2004-05-18 19:28:32 +0000139
hasso6452df02004-08-15 05:52:07 +0000140 oi->lsupdate_list = ospf6_lsdb_create (oi);
141 oi->lsack_list = ospf6_lsdb_create (oi);
142 oi->lsdb = ospf6_lsdb_create (oi);
hasso508e53e2004-05-18 18:57:06 +0000143 oi->lsdb->hook_add = ospf6_interface_lsdb_hook;
144 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook;
hasso6452df02004-08-15 05:52:07 +0000145 oi->lsdb_self = ospf6_lsdb_create (oi);
paul718e3742002-12-13 20:15:29 +0000146
Paul Jakmacf1ce252006-05-15 10:46:07 +0000147 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
148 oi->route_connected->scope = oi;
paul718e3742002-12-13 20:15:29 +0000149
150 /* link both */
hasso508e53e2004-05-18 18:57:06 +0000151 oi->interface = ifp;
152 ifp->info = oi;
paul718e3742002-12-13 20:15:29 +0000153
hasso508e53e2004-05-18 18:57:06 +0000154 return oi;
paul718e3742002-12-13 20:15:29 +0000155}
156
157void
hasso508e53e2004-05-18 18:57:06 +0000158ospf6_interface_delete (struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000159{
paul1eb8ef22005-04-07 07:30:20 +0000160 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000161 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000162
paul1eb8ef22005-04-07 07:30:20 +0000163 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000164 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000165
hasso508e53e2004-05-18 18:57:06 +0000166 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000167
hasso508e53e2004-05-18 18:57:06 +0000168 THREAD_OFF (oi->thread_send_hello);
169 THREAD_OFF (oi->thread_send_lsupdate);
170 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000171
hasso508e53e2004-05-18 18:57:06 +0000172 ospf6_lsdb_remove_all (oi->lsdb);
173 ospf6_lsdb_remove_all (oi->lsupdate_list);
174 ospf6_lsdb_remove_all (oi->lsack_list);
175
176 ospf6_lsdb_delete (oi->lsdb);
hasso6452df02004-08-15 05:52:07 +0000177 ospf6_lsdb_delete (oi->lsdb_self);
178
hasso508e53e2004-05-18 18:57:06 +0000179 ospf6_lsdb_delete (oi->lsupdate_list);
180 ospf6_lsdb_delete (oi->lsack_list);
181
182 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000183
184 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000185 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000186
187 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000188 if (oi->plist_name)
189 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000190
hasso508e53e2004-05-18 18:57:06 +0000191 XFREE (MTYPE_OSPF6_IF, oi);
192}
193
194void
195ospf6_interface_enable (struct ospf6_interface *oi)
196{
197 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
198
199 oi->thread_send_hello =
200 thread_add_event (master, ospf6_hello_send, oi, 0);
201}
202
203void
204ospf6_interface_disable (struct ospf6_interface *oi)
205{
paul1eb8ef22005-04-07 07:30:20 +0000206 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000207 struct ospf6_neighbor *on;
208
209 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
210
paul1eb8ef22005-04-07 07:30:20 +0000211 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000212 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000213
hasso508e53e2004-05-18 18:57:06 +0000214 list_delete_all_node (oi->neighbor_list);
215
216 ospf6_lsdb_remove_all (oi->lsdb);
217 ospf6_lsdb_remove_all (oi->lsupdate_list);
218 ospf6_lsdb_remove_all (oi->lsack_list);
219
220 THREAD_OFF (oi->thread_send_hello);
221 THREAD_OFF (oi->thread_send_lsupdate);
222 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000223}
224
225static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000226ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000227{
hasso52dc7ee2004-09-23 19:18:23 +0000228 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000229 struct connected *c;
230 struct in6_addr *l = (struct in6_addr *) NULL;
231
232 /* for each connected address */
paul1eb8ef22005-04-07 07:30:20 +0000233 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
paul718e3742002-12-13 20:15:29 +0000234 {
paul718e3742002-12-13 20:15:29 +0000235 /* if family not AF_INET6, ignore */
236 if (c->address->family != AF_INET6)
237 continue;
238
239 /* linklocal scope check */
240 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
241 l = &c->address->u.prefix6;
242 }
243 return l;
244}
245
246void
247ospf6_interface_if_add (struct interface *ifp)
248{
hasso508e53e2004-05-18 18:57:06 +0000249 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000250 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000251
hasso508e53e2004-05-18 18:57:06 +0000252 oi = (struct ospf6_interface *) ifp->info;
253 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000254 return;
255
hassob596c712004-07-09 18:33:43 +0000256 /* Try to adjust I/O buffer size with IfMtu */
257 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000258 oi->ifmtu = ifp->mtu6;
259 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000260 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000261 {
hasso1e058382004-09-01 21:36:14 +0000262 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000263 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
264 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000265 oi->ifmtu = iobuflen;
266 }
paul718e3742002-12-13 20:15:29 +0000267
268 /* interface start */
hasso508e53e2004-05-18 18:57:06 +0000269 if (oi->area)
270 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000271}
272
273void
274ospf6_interface_if_del (struct interface *ifp)
275{
hasso508e53e2004-05-18 18:57:06 +0000276 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000277
hasso508e53e2004-05-18 18:57:06 +0000278 oi = (struct ospf6_interface *) ifp->info;
279 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000280 return;
281
282 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000283 if (oi->area)
284 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000285
hasso508e53e2004-05-18 18:57:06 +0000286 listnode_delete (oi->area->if_list, oi);
287 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000288
289 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000290 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000291 ifp->info = NULL;
292
hasso508e53e2004-05-18 18:57:06 +0000293 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000294}
295
296void
297ospf6_interface_state_update (struct interface *ifp)
298{
hasso508e53e2004-05-18 18:57:06 +0000299 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000300
hasso508e53e2004-05-18 18:57:06 +0000301 oi = (struct ospf6_interface *) ifp->info;
302 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000303 return;
hasso508e53e2004-05-18 18:57:06 +0000304 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000305 return;
306
307 if (if_is_up (ifp))
hasso508e53e2004-05-18 18:57:06 +0000308 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000309 else
hasso508e53e2004-05-18 18:57:06 +0000310 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000311
312 return;
313}
314
315void
hasso508e53e2004-05-18 18:57:06 +0000316ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000317{
hasso508e53e2004-05-18 18:57:06 +0000318 struct ospf6_interface *oi;
319 struct ospf6_route *route;
320 struct connected *c;
paul1eb8ef22005-04-07 07:30:20 +0000321 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +0000322
hasso508e53e2004-05-18 18:57:06 +0000323 oi = (struct ospf6_interface *) ifp->info;
324 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000325 return;
326
327 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000328 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000329
hasso508e53e2004-05-18 18:57:06 +0000330 /* if area is null, do not make connected-route list */
331 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000332 return;
333
hasso508e53e2004-05-18 18:57:06 +0000334 /* update "route to advertise" interface route table */
335 ospf6_route_remove_all (oi->route_connected);
hasso508e53e2004-05-18 18:57:06 +0000336
paul1eb8ef22005-04-07 07:30:20 +0000337 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
338 {
hasso508e53e2004-05-18 18:57:06 +0000339 if (c->address->family != AF_INET6)
340 continue;
341
hasso1e058382004-09-01 21:36:14 +0000342 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
343 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
344 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
345 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
346 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000347
348 /* apply filter */
349 if (oi->plist_name)
350 {
351 struct prefix_list *plist;
352 enum prefix_list_type ret;
353 char buf[128];
354
355 prefix2str (c->address, buf, sizeof (buf));
356 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
357 ret = prefix_list_apply (plist, (void *) c->address);
358 if (ret == PREFIX_DENY)
359 {
hasso1e058382004-09-01 21:36:14 +0000360 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000361 zlog_debug ("%s on %s filtered by prefix-list %s ",
362 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000363 continue;
364 }
365 }
366
367 route = ospf6_route_create ();
368 memcpy (&route->prefix, c->address, sizeof (struct prefix));
369 apply_mask (&route->prefix);
370 route->type = OSPF6_DEST_TYPE_NETWORK;
371 route->path.area_id = oi->area->area_id;
372 route->path.type = OSPF6_PATH_TYPE_INTRA;
373 route->path.cost = oi->cost;
374 route->nexthop[0].ifindex = oi->interface->ifindex;
375 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
376 ospf6_route_add (route, oi->route_connected);
377 }
378
paul718e3742002-12-13 20:15:29 +0000379 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000380 OSPF6_LINK_LSA_SCHEDULE (oi);
381 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
382 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000383}
384
hasso508e53e2004-05-18 18:57:06 +0000385static void
386ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000387{
hasso508e53e2004-05-18 18:57:06 +0000388 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000389
hasso508e53e2004-05-18 18:57:06 +0000390 prev_state = oi->state;
391 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000392
hasso508e53e2004-05-18 18:57:06 +0000393 if (prev_state == next_state)
394 return;
paul718e3742002-12-13 20:15:29 +0000395
hasso508e53e2004-05-18 18:57:06 +0000396 /* log */
397 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000398 {
hassoc6487d62004-12-24 06:00:11 +0000399 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
400 ospf6_interface_state_str[prev_state],
401 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000402 }
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200403 oi->state_change++;
paul718e3742002-12-13 20:15:29 +0000404
hasso508e53e2004-05-18 18:57:06 +0000405 if ((prev_state == OSPF6_INTERFACE_DR ||
406 prev_state == OSPF6_INTERFACE_BDR) &&
407 (next_state != OSPF6_INTERFACE_DR &&
408 next_state != OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400409 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000410 if ((prev_state != OSPF6_INTERFACE_DR &&
411 prev_state != OSPF6_INTERFACE_BDR) &&
412 (next_state == OSPF6_INTERFACE_DR ||
413 next_state == OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400414 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
paul718e3742002-12-13 20:15:29 +0000415
hasso508e53e2004-05-18 18:57:06 +0000416 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000417 if (next_state == OSPF6_INTERFACE_DOWN)
418 {
419 OSPF6_NETWORK_LSA_EXECUTE (oi);
420 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
421 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
422 }
423 else if (prev_state == OSPF6_INTERFACE_DR ||
424 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000425 {
hasso508e53e2004-05-18 18:57:06 +0000426 OSPF6_NETWORK_LSA_SCHEDULE (oi);
427 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
428 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000429 }
Vincent Bernatbf836662012-06-04 14:36:12 +0200430
431#ifdef HAVE_SNMP
432 /* Terminal state or regression */
433 if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
434 (next_state == OSPF6_INTERFACE_DROTHER) ||
435 (next_state == OSPF6_INTERFACE_BDR) ||
436 (next_state == OSPF6_INTERFACE_DR) ||
437 (next_state < prev_state))
438 ospf6TrapIfStateChange (oi);
439#endif
440
hasso508e53e2004-05-18 18:57:06 +0000441}
442
443
444/* DR Election, RFC2328 section 9.4 */
445
446#define IS_ELIGIBLE(n) \
447 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
448
449static struct ospf6_neighbor *
450better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
451{
452 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
453 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
454 return NULL;
455 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
456 return b;
457 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
458 return a;
459
460 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
461 return a;
462 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
463 return b;
464
465 if (a->priority > b->priority)
466 return a;
467 if (a->priority < b->priority)
468 return b;
469
470 if (ntohl (a->router_id) > ntohl (b->router_id))
471 return a;
472 if (ntohl (a->router_id) < ntohl (b->router_id))
473 return b;
474
475 zlog_warn ("Router-ID duplicate ?");
476 return a;
477}
478
479static struct ospf6_neighbor *
480better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
481{
482 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
483 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
484 return NULL;
485 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
486 return b;
487 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
488 return a;
489
490 if (a->drouter == a->router_id && b->drouter != b->router_id)
491 return a;
492 if (a->drouter != a->router_id && b->drouter == b->router_id)
493 return b;
494
495 if (a->priority > b->priority)
496 return a;
497 if (a->priority < b->priority)
498 return b;
499
500 if (ntohl (a->router_id) > ntohl (b->router_id))
501 return a;
502 if (ntohl (a->router_id) < ntohl (b->router_id))
503 return b;
504
505 zlog_warn ("Router-ID duplicate ?");
506 return a;
507}
508
509static u_char
510dr_election (struct ospf6_interface *oi)
511{
paul1eb8ef22005-04-07 07:30:20 +0000512 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000513 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
514 struct ospf6_neighbor *best_drouter, *best_bdrouter;
515 u_char next_state = 0;
516
517 drouter = bdrouter = NULL;
518 best_drouter = best_bdrouter = NULL;
519
520 /* pseudo neighbor myself, including noting current DR/BDR (1) */
521 memset (&myself, 0, sizeof (myself));
522 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
523 sizeof (myself.name));
524 myself.state = OSPF6_NEIGHBOR_TWOWAY;
525 myself.drouter = oi->drouter;
526 myself.bdrouter = oi->bdrouter;
527 myself.priority = oi->priority;
528 myself.router_id = oi->area->ospf6->router_id;
529
530 /* Electing BDR (2) */
paul1eb8ef22005-04-07 07:30:20 +0000531 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
532 bdrouter = better_bdrouter (bdrouter, on);
533
hasso508e53e2004-05-18 18:57:06 +0000534 best_bdrouter = bdrouter;
535 bdrouter = better_bdrouter (best_bdrouter, &myself);
536
537 /* Electing DR (3) */
paul1eb8ef22005-04-07 07:30:20 +0000538 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
539 drouter = better_drouter (drouter, on);
540
hasso508e53e2004-05-18 18:57:06 +0000541 best_drouter = drouter;
542 drouter = better_drouter (best_drouter, &myself);
543 if (drouter == NULL)
544 drouter = bdrouter;
545
546 /* the router itself is newly/no longer DR/BDR (4) */
547 if ((drouter == &myself && myself.drouter != myself.router_id) ||
548 (drouter != &myself && myself.drouter == myself.router_id) ||
549 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
550 (bdrouter != &myself && myself.bdrouter == myself.router_id))
551 {
552 myself.drouter = (drouter ? drouter->router_id : htonl (0));
553 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
554
555 /* compatible to Electing BDR (2) */
556 bdrouter = better_bdrouter (best_bdrouter, &myself);
557
558 /* compatible to Electing DR (3) */
559 drouter = better_drouter (best_drouter, &myself);
560 if (drouter == NULL)
561 drouter = bdrouter;
562 }
563
564 /* Set interface state accordingly (5) */
565 if (drouter && drouter == &myself)
566 next_state = OSPF6_INTERFACE_DR;
567 else if (bdrouter && bdrouter == &myself)
568 next_state = OSPF6_INTERFACE_BDR;
569 else
570 next_state = OSPF6_INTERFACE_DROTHER;
571
572 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
573 /* XXX */
574
575 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
576 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
577 accordingly after AdjOK */
578 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
579 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
580 {
581 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000582 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
583 (drouter ? drouter->name : "0.0.0.0"),
584 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000585
paul1eb8ef22005-04-07 07:30:20 +0000586 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
hasso508e53e2004-05-18 18:57:06 +0000587 {
hasso508e53e2004-05-18 18:57:06 +0000588 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
589 continue;
590 /* Schedule AdjOK. */
591 thread_add_event (master, adj_ok, on, 0);
592 }
593 }
594
595 oi->drouter = (drouter ? drouter->router_id : htonl (0));
596 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
597 return next_state;
598}
599
600
601/* Interface State Machine */
602int
603interface_up (struct thread *thread)
604{
605 struct ospf6_interface *oi;
606
607 oi = (struct ospf6_interface *) THREAD_ARG (thread);
608 assert (oi && oi->interface);
609
610 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000611 zlog_debug ("Interface Event %s: [InterfaceUp]",
612 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000613
614 /* check physical interface is up */
615 if (! if_is_up (oi->interface))
616 {
617 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000618 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
619 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000620 return 0;
621 }
622
623 /* if already enabled, do nothing */
624 if (oi->state > OSPF6_INTERFACE_DOWN)
625 {
626 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000627 zlog_debug ("Interface %s already enabled",
628 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000629 return 0;
630 }
631
632 /* Join AllSPFRouters */
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400633 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000634
635 /* Update interface route */
636 ospf6_interface_connected_route_update (oi->interface);
637
638 /* Schedule Hello */
639 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
640 thread_add_event (master, ospf6_hello_send, oi, 0);
641
642 /* decide next interface state */
643 if (if_is_pointopoint (oi->interface))
644 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
645 else if (oi->priority == 0)
646 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
647 else
648 {
649 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
650 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
651 }
652
653 return 0;
paul718e3742002-12-13 20:15:29 +0000654}
655
656int
hasso508e53e2004-05-18 18:57:06 +0000657wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000658{
hasso508e53e2004-05-18 18:57:06 +0000659 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000660
hasso508e53e2004-05-18 18:57:06 +0000661 oi = (struct ospf6_interface *) THREAD_ARG (thread);
662 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000663
hasso508e53e2004-05-18 18:57:06 +0000664 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000665 zlog_debug ("Interface Event %s: [WaitTimer]",
666 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000667
hasso508e53e2004-05-18 18:57:06 +0000668 if (oi->state == OSPF6_INTERFACE_WAITING)
669 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000670
hasso508e53e2004-05-18 18:57:06 +0000671 return 0;
paul718e3742002-12-13 20:15:29 +0000672}
673
hasso508e53e2004-05-18 18:57:06 +0000674int
675backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000676{
hasso508e53e2004-05-18 18:57:06 +0000677 struct ospf6_interface *oi;
678
679 oi = (struct ospf6_interface *) THREAD_ARG (thread);
680 assert (oi && oi->interface);
681
682 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000683 zlog_debug ("Interface Event %s: [BackupSeen]",
684 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000685
686 if (oi->state == OSPF6_INTERFACE_WAITING)
687 ospf6_interface_state_change (dr_election (oi), oi);
688
689 return 0;
paul718e3742002-12-13 20:15:29 +0000690}
691
hasso508e53e2004-05-18 18:57:06 +0000692int
693neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000694{
hasso508e53e2004-05-18 18:57:06 +0000695 struct ospf6_interface *oi;
696
697 oi = (struct ospf6_interface *) THREAD_ARG (thread);
698 assert (oi && oi->interface);
699
700 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000701 zlog_debug ("Interface Event %s: [NeighborChange]",
702 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000703
704 if (oi->state == OSPF6_INTERFACE_DROTHER ||
705 oi->state == OSPF6_INTERFACE_BDR ||
706 oi->state == OSPF6_INTERFACE_DR)
707 ospf6_interface_state_change (dr_election (oi), oi);
708
709 return 0;
paul718e3742002-12-13 20:15:29 +0000710}
711
hasso508e53e2004-05-18 18:57:06 +0000712int
713interface_down (struct thread *thread)
714{
715 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000716 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000717 struct ospf6_neighbor *on;
718
719 oi = (struct ospf6_interface *) THREAD_ARG (thread);
720 assert (oi && oi->interface);
721
722 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000723 zlog_debug ("Interface Event %s: [InterfaceDown]",
724 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000725
726 /* Leave AllSPFRouters */
727 if (oi->state > OSPF6_INTERFACE_DOWN)
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400728 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000729
730 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
731
paul1eb8ef22005-04-07 07:30:20 +0000732 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
733 ospf6_neighbor_delete (on);
734
hasso508e53e2004-05-18 18:57:06 +0000735 list_delete_all_node (oi->neighbor_list);
736
737 return 0;
738}
739
740
paul718e3742002-12-13 20:15:29 +0000741/* show specified interface structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100742static int
hasso508e53e2004-05-18 18:57:06 +0000743ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000744{
hasso508e53e2004-05-18 18:57:06 +0000745 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000746 struct connected *c;
747 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000748 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000749 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000750 const char *updown[3] = {"down", "up", NULL};
751 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000752 struct timeval res, now;
753 char duration[32];
754 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000755
756 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000757 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000758 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000759 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000760 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000761 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000762 type = "POINTOPOINT";
763 else
764 type = "UNKNOWN";
765
766 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000767 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000768 VNL);
769 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000770
hasso508e53e2004-05-18 18:57:06 +0000771 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000772 {
hasso049207c2004-08-04 20:02:13 +0000773 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000774 return 0;
775 }
776 else
hasso508e53e2004-05-18 18:57:06 +0000777 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000778
hasso049207c2004-08-04 20:02:13 +0000779 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000780
781 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000782 {
paul718e3742002-12-13 20:15:29 +0000783 p = c->address;
784 prefix2str (p, strbuf, sizeof (strbuf));
785 switch (p->family)
786 {
787 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000788 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000789 VNL);
paul718e3742002-12-13 20:15:29 +0000790 break;
791 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000792 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000793 VNL);
paul718e3742002-12-13 20:15:29 +0000794 break;
795 default:
hasso508e53e2004-05-18 18:57:06 +0000796 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000797 VNL);
paul718e3742002-12-13 20:15:29 +0000798 break;
799 }
800 }
801
hasso508e53e2004-05-18 18:57:06 +0000802 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000803 {
hasso508e53e2004-05-18 18:57:06 +0000804 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000805 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400806 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
807 "disabled" : "enabled", VNL);
hasso508e53e2004-05-18 18:57:06 +0000808 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000809 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000810 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000811 VNL);
paul718e3742002-12-13 20:15:29 +0000812 }
813 else
hasso049207c2004-08-04 20:02:13 +0000814 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000815
816 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000817 ospf6_interface_state_str[oi->state],
818 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000819 VNL);
820 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000821 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000822 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000823 VNL);
paul718e3742002-12-13 20:15:29 +0000824
hasso508e53e2004-05-18 18:57:06 +0000825 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
826 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000827 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000828
829 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000830 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000831
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900832 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
paul718e3742002-12-13 20:15:29 +0000833
hasso508e53e2004-05-18 18:57:06 +0000834 timerclear (&res);
835 if (oi->thread_send_lsupdate)
836 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
837 timerstring (&res, duration, sizeof (duration));
838 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
839 oi->lsupdate_list->count, duration,
840 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000841 VNL);
hasso508e53e2004-05-18 18:57:06 +0000842 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
843 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000844 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000845
hasso508e53e2004-05-18 18:57:06 +0000846 timerclear (&res);
847 if (oi->thread_send_lsack)
848 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
849 timerstring (&res, duration, sizeof (duration));
850 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
851 oi->lsack_list->count, duration,
852 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000853 VNL);
hasso508e53e2004-05-18 18:57:06 +0000854 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
855 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000856 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000857
hasso508e53e2004-05-18 18:57:06 +0000858 return 0;
paul718e3742002-12-13 20:15:29 +0000859}
860
861/* show interface */
862DEFUN (show_ipv6_ospf6_interface,
863 show_ipv6_ospf6_interface_ifname_cmd,
864 "show ipv6 ospf6 interface IFNAME",
865 SHOW_STR
866 IP6_STR
867 OSPF6_STR
868 INTERFACE_STR
869 IFNAME_STR
870 )
871{
872 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000873 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000874
875 if (argc)
876 {
877 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000878 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000879 {
880 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000881 VNL);
paul718e3742002-12-13 20:15:29 +0000882 return CMD_WARNING;
883 }
884 ospf6_interface_show (vty, ifp);
885 }
886 else
887 {
paul1eb8ef22005-04-07 07:30:20 +0000888 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
889 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000890 }
hasso508e53e2004-05-18 18:57:06 +0000891
paul718e3742002-12-13 20:15:29 +0000892 return CMD_SUCCESS;
893}
894
895ALIAS (show_ipv6_ospf6_interface,
896 show_ipv6_ospf6_interface_cmd,
897 "show ipv6 ospf6 interface",
898 SHOW_STR
899 IP6_STR
900 OSPF6_STR
901 INTERFACE_STR
Paul Jakma6ac29a52008-08-15 13:45:30 +0100902 )
paul718e3742002-12-13 20:15:29 +0000903
hasso508e53e2004-05-18 18:57:06 +0000904DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
905 show_ipv6_ospf6_interface_ifname_prefix_cmd,
906 "show ipv6 ospf6 interface IFNAME prefix",
907 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000908 IP6_STR
909 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000910 INTERFACE_STR
911 IFNAME_STR
912 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000913 )
914{
paul718e3742002-12-13 20:15:29 +0000915 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000916 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000917
hasso508e53e2004-05-18 18:57:06 +0000918 ifp = if_lookup_by_name (argv[0]);
919 if (ifp == NULL)
920 {
hasso049207c2004-08-04 20:02:13 +0000921 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000922 return CMD_WARNING;
923 }
paul718e3742002-12-13 20:15:29 +0000924
hasso508e53e2004-05-18 18:57:06 +0000925 oi = ifp->info;
926 if (oi == NULL)
927 {
hasso049207c2004-08-04 20:02:13 +0000928 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000929 return CMD_WARNING;
930 }
paul718e3742002-12-13 20:15:29 +0000931
hasso508e53e2004-05-18 18:57:06 +0000932 argc--;
933 argv++;
934 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000935
936 return CMD_SUCCESS;
937}
938
hasso508e53e2004-05-18 18:57:06 +0000939ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
940 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
941 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
942 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000943 IP6_STR
944 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000945 INTERFACE_STR
946 IFNAME_STR
947 "Display connected prefixes to advertise\n"
948 OSPF6_ROUTE_ADDRESS_STR
949 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400950 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100951 )
hasso508e53e2004-05-18 18:57:06 +0000952
953ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
954 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
955 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
956 SHOW_STR
957 IP6_STR
958 OSPF6_STR
959 INTERFACE_STR
960 IFNAME_STR
961 "Display connected prefixes to advertise\n"
962 OSPF6_ROUTE_PREFIX_STR
963 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400964 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100965 )
hasso508e53e2004-05-18 18:57:06 +0000966
967DEFUN (show_ipv6_ospf6_interface_prefix,
968 show_ipv6_ospf6_interface_prefix_cmd,
969 "show ipv6 ospf6 interface prefix",
970 SHOW_STR
971 IP6_STR
972 OSPF6_STR
973 INTERFACE_STR
974 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000975 )
976{
hasso52dc7ee2004-09-23 19:18:23 +0000977 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000978 struct ospf6_interface *oi;
979 struct interface *ifp;
980
paul1eb8ef22005-04-07 07:30:20 +0000981 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +0000982 {
hasso508e53e2004-05-18 18:57:06 +0000983 oi = (struct ospf6_interface *) ifp->info;
984 if (oi == NULL)
985 continue;
986
987 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
988 }
989
990 return CMD_SUCCESS;
991}
992
993ALIAS (show_ipv6_ospf6_interface_prefix,
994 show_ipv6_ospf6_interface_prefix_detail_cmd,
995 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
996 SHOW_STR
997 IP6_STR
998 OSPF6_STR
999 INTERFACE_STR
1000 "Display connected prefixes to advertise\n"
1001 OSPF6_ROUTE_ADDRESS_STR
1002 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001003 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001004 )
hasso508e53e2004-05-18 18:57:06 +00001005
1006ALIAS (show_ipv6_ospf6_interface_prefix,
1007 show_ipv6_ospf6_interface_prefix_match_cmd,
1008 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1009 SHOW_STR
1010 IP6_STR
1011 OSPF6_STR
1012 INTERFACE_STR
1013 "Display connected prefixes to advertise\n"
1014 OSPF6_ROUTE_PREFIX_STR
1015 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001016 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001017 )
hasso508e53e2004-05-18 18:57:06 +00001018
1019
1020/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001021DEFUN (ipv6_ospf6_ifmtu,
1022 ipv6_ospf6_ifmtu_cmd,
1023 "ipv6 ospf6 ifmtu <1-65535>",
1024 IP6_STR
1025 OSPF6_STR
1026 "Interface MTU\n"
1027 "OSPFv3 Interface MTU\n"
1028 )
1029{
1030 struct ospf6_interface *oi;
1031 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001032 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001033 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001034 struct ospf6_neighbor *on;
1035
1036 ifp = (struct interface *) vty->index;
1037 assert (ifp);
1038
1039 oi = (struct ospf6_interface *) ifp->info;
1040 if (oi == NULL)
1041 oi = ospf6_interface_create (ifp);
1042 assert (oi);
1043
1044 ifmtu = strtol (argv[0], NULL, 10);
1045
1046 if (oi->ifmtu == ifmtu)
1047 return CMD_SUCCESS;
1048
hasso1203e1c2004-07-23 21:34:27 +00001049 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001050 {
1051 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001052 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001053 return CMD_WARNING;
1054 }
1055
1056 if (oi->ifmtu < ifmtu)
1057 {
1058 iobuflen = ospf6_iobuf_size (ifmtu);
1059 if (iobuflen < ifmtu)
1060 {
1061 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001062 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001063 oi->ifmtu = iobuflen;
1064 }
1065 else
1066 oi->ifmtu = ifmtu;
1067 }
1068 else
1069 oi->ifmtu = ifmtu;
1070
1071 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001072 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001073 {
hassob596c712004-07-09 18:33:43 +00001074 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001075 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001076 }
1077
1078 return CMD_SUCCESS;
1079}
1080
hasso049207c2004-08-04 20:02:13 +00001081DEFUN (no_ipv6_ospf6_ifmtu,
1082 no_ipv6_ospf6_ifmtu_cmd,
1083 "no ipv6 ospf6 ifmtu",
1084 NO_STR
1085 IP6_STR
1086 OSPF6_STR
1087 "Interface MTU\n"
1088 )
1089{
1090 struct ospf6_interface *oi;
1091 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001092 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001093 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001094 struct ospf6_neighbor *on;
1095
1096 ifp = (struct interface *) vty->index;
1097 assert (ifp);
1098
1099 oi = (struct ospf6_interface *) ifp->info;
1100 if (oi == NULL)
1101 oi = ospf6_interface_create (ifp);
1102 assert (oi);
1103
1104 if (oi->ifmtu < ifp->mtu)
1105 {
1106 iobuflen = ospf6_iobuf_size (ifp->mtu);
1107 if (iobuflen < ifp->mtu)
1108 {
1109 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1110 ifp->name, iobuflen, VNL);
1111 oi->ifmtu = iobuflen;
1112 }
1113 else
1114 oi->ifmtu = ifp->mtu;
1115 }
1116 else
1117 oi->ifmtu = ifp->mtu;
1118
1119 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001120 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001121 {
hasso049207c2004-08-04 20:02:13 +00001122 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001123 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001124 }
1125
1126 return CMD_SUCCESS;
1127}
1128
hasso508e53e2004-05-18 18:57:06 +00001129DEFUN (ipv6_ospf6_cost,
1130 ipv6_ospf6_cost_cmd,
1131 "ipv6 ospf6 cost <1-65535>",
1132 IP6_STR
1133 OSPF6_STR
1134 "Interface cost\n"
1135 "Outgoing metric of this interface\n"
1136 )
1137{
1138 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001139 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001140 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001141
1142 ifp = (struct interface *) vty->index;
1143 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001144
hasso508e53e2004-05-18 18:57:06 +00001145 oi = (struct ospf6_interface *) ifp->info;
1146 if (oi == NULL)
1147 oi = ospf6_interface_create (ifp);
1148 assert (oi);
1149
paul0c083ee2004-10-10 12:54:58 +00001150 lcost = strtol (argv[0], NULL, 10);
1151
1152 if (lcost > UINT32_MAX)
1153 {
1154 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1155 return CMD_WARNING;
1156 }
1157
1158 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001159 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001160
1161 oi->cost = lcost;
1162
hasso508e53e2004-05-18 18:57:06 +00001163 /* update cost held in route_connected list in ospf6_interface */
1164 ospf6_interface_connected_route_update (oi->interface);
1165
1166 /* execute LSA hooks */
1167 if (oi->area)
1168 {
1169 OSPF6_LINK_LSA_SCHEDULE (oi);
1170 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1171 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1172 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1173 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1174 }
1175
1176 return CMD_SUCCESS;
1177}
1178
1179DEFUN (ipv6_ospf6_hellointerval,
1180 ipv6_ospf6_hellointerval_cmd,
1181 "ipv6 ospf6 hello-interval <1-65535>",
1182 IP6_STR
1183 OSPF6_STR
1184 "Interval time of Hello packets\n"
1185 SECONDS_STR
1186 )
1187{
1188 struct ospf6_interface *oi;
1189 struct interface *ifp;
1190
1191 ifp = (struct interface *) vty->index;
1192 assert (ifp);
1193
1194 oi = (struct ospf6_interface *) ifp->info;
1195 if (oi == NULL)
1196 oi = ospf6_interface_create (ifp);
1197 assert (oi);
1198
1199 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001200 return CMD_SUCCESS;
1201}
1202
1203/* interface variable set command */
1204DEFUN (ipv6_ospf6_deadinterval,
1205 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001206 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001207 IP6_STR
1208 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001209 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001210 SECONDS_STR
1211 )
1212{
hasso508e53e2004-05-18 18:57:06 +00001213 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001214 struct interface *ifp;
1215
1216 ifp = (struct interface *) vty->index;
1217 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001218
hasso508e53e2004-05-18 18:57:06 +00001219 oi = (struct ospf6_interface *) ifp->info;
1220 if (oi == NULL)
1221 oi = ospf6_interface_create (ifp);
1222 assert (oi);
1223
1224 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001225 return CMD_SUCCESS;
1226}
1227
1228/* interface variable set command */
1229DEFUN (ipv6_ospf6_transmitdelay,
1230 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001231 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001232 IP6_STR
1233 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001234 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001235 SECONDS_STR
1236 )
1237{
hasso508e53e2004-05-18 18:57:06 +00001238 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001239 struct interface *ifp;
1240
1241 ifp = (struct interface *) vty->index;
1242 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001243
hasso508e53e2004-05-18 18:57:06 +00001244 oi = (struct ospf6_interface *) ifp->info;
1245 if (oi == NULL)
1246 oi = ospf6_interface_create (ifp);
1247 assert (oi);
1248
1249 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001250 return CMD_SUCCESS;
1251}
1252
1253/* interface variable set command */
1254DEFUN (ipv6_ospf6_retransmitinterval,
1255 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001256 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001257 IP6_STR
1258 OSPF6_STR
1259 "Time between retransmitting lost link state advertisements\n"
1260 SECONDS_STR
1261 )
1262{
hasso508e53e2004-05-18 18:57:06 +00001263 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001264 struct interface *ifp;
1265
1266 ifp = (struct interface *) vty->index;
1267 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001268
hasso508e53e2004-05-18 18:57:06 +00001269 oi = (struct ospf6_interface *) ifp->info;
1270 if (oi == NULL)
1271 oi = ospf6_interface_create (ifp);
1272 assert (oi);
1273
1274 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001275 return CMD_SUCCESS;
1276}
1277
1278/* interface variable set command */
1279DEFUN (ipv6_ospf6_priority,
1280 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001281 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001282 IP6_STR
1283 OSPF6_STR
1284 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001285 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001286 )
1287{
hasso508e53e2004-05-18 18:57:06 +00001288 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001289 struct interface *ifp;
1290
1291 ifp = (struct interface *) vty->index;
1292 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001293
hasso508e53e2004-05-18 18:57:06 +00001294 oi = (struct ospf6_interface *) ifp->info;
1295 if (oi == NULL)
1296 oi = ospf6_interface_create (ifp);
1297 assert (oi);
paul718e3742002-12-13 20:15:29 +00001298
hasso508e53e2004-05-18 18:57:06 +00001299 oi->priority = strtol (argv[0], NULL, 10);
1300
1301 if (oi->area)
1302 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001303
1304 return CMD_SUCCESS;
1305}
1306
1307DEFUN (ipv6_ospf6_instance,
1308 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001309 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001310 IP6_STR
1311 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001312 "Instance ID for this interface\n"
1313 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001314 )
1315{
hasso508e53e2004-05-18 18:57:06 +00001316 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001317 struct interface *ifp;
1318
1319 ifp = (struct interface *)vty->index;
1320 assert (ifp);
1321
hasso508e53e2004-05-18 18:57:06 +00001322 oi = (struct ospf6_interface *)ifp->info;
1323 if (oi == NULL)
1324 oi = ospf6_interface_create (ifp);
1325 assert (oi);
paul718e3742002-12-13 20:15:29 +00001326
hasso508e53e2004-05-18 18:57:06 +00001327 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001328 return CMD_SUCCESS;
1329}
1330
1331DEFUN (ipv6_ospf6_passive,
1332 ipv6_ospf6_passive_cmd,
1333 "ipv6 ospf6 passive",
1334 IP6_STR
1335 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001336 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001337 )
1338{
hasso508e53e2004-05-18 18:57:06 +00001339 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001340 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001341 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001342 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001343
1344 ifp = (struct interface *) vty->index;
1345 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001346
hasso508e53e2004-05-18 18:57:06 +00001347 oi = (struct ospf6_interface *) ifp->info;
1348 if (oi == NULL)
1349 oi = ospf6_interface_create (ifp);
1350 assert (oi);
paul718e3742002-12-13 20:15:29 +00001351
hasso508e53e2004-05-18 18:57:06 +00001352 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1353 THREAD_OFF (oi->thread_send_hello);
1354
paul1eb8ef22005-04-07 07:30:20 +00001355 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001356 {
hasso508e53e2004-05-18 18:57:06 +00001357 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001358 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001359 }
1360
1361 return CMD_SUCCESS;
1362}
1363
1364DEFUN (no_ipv6_ospf6_passive,
1365 no_ipv6_ospf6_passive_cmd,
1366 "no ipv6 ospf6 passive",
1367 NO_STR
1368 IP6_STR
1369 OSPF6_STR
1370 "passive interface: No Adjacency will be formed on this I/F\n"
1371 )
1372{
hasso508e53e2004-05-18 18:57:06 +00001373 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001374 struct interface *ifp;
1375
1376 ifp = (struct interface *) vty->index;
1377 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001378
hasso508e53e2004-05-18 18:57:06 +00001379 oi = (struct ospf6_interface *) ifp->info;
1380 if (oi == NULL)
1381 oi = ospf6_interface_create (ifp);
1382 assert (oi);
paul718e3742002-12-13 20:15:29 +00001383
hasso508e53e2004-05-18 18:57:06 +00001384 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1385 THREAD_OFF (oi->thread_send_hello);
1386 oi->thread_send_hello =
1387 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001388
1389 return CMD_SUCCESS;
1390}
1391
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001392DEFUN (ipv6_ospf6_mtu_ignore,
1393 ipv6_ospf6_mtu_ignore_cmd,
1394 "ipv6 ospf6 mtu-ignore",
1395 IP6_STR
1396 OSPF6_STR
1397 "Ignore MTU mismatch on this interface\n"
1398 )
1399{
1400 struct ospf6_interface *oi;
1401 struct interface *ifp;
1402
1403 ifp = (struct interface *) vty->index;
1404 assert (ifp);
1405
1406 oi = (struct ospf6_interface *) ifp->info;
1407 if (oi == NULL)
1408 oi = ospf6_interface_create (ifp);
1409 assert (oi);
1410
1411 oi->mtu_ignore = 1;
1412
1413 return CMD_SUCCESS;
1414}
1415
1416DEFUN (no_ipv6_ospf6_mtu_ignore,
1417 no_ipv6_ospf6_mtu_ignore_cmd,
1418 "no ipv6 ospf6 mtu-ignore",
1419 NO_STR
1420 IP6_STR
1421 OSPF6_STR
1422 "Ignore MTU mismatch on this interface\n"
1423 )
1424{
1425 struct ospf6_interface *oi;
1426 struct interface *ifp;
1427
1428 ifp = (struct interface *) vty->index;
1429 assert (ifp);
1430
1431 oi = (struct ospf6_interface *) ifp->info;
1432 if (oi == NULL)
1433 oi = ospf6_interface_create (ifp);
1434 assert (oi);
1435
1436 oi->mtu_ignore = 0;
1437
1438 return CMD_SUCCESS;
1439}
1440
paul718e3742002-12-13 20:15:29 +00001441DEFUN (ipv6_ospf6_advertise_prefix_list,
1442 ipv6_ospf6_advertise_prefix_list_cmd,
1443 "ipv6 ospf6 advertise prefix-list WORD",
1444 IP6_STR
1445 OSPF6_STR
1446 "Advertising options\n"
1447 "Filter prefix using prefix-list\n"
1448 "Prefix list name\n"
1449 )
1450{
hasso508e53e2004-05-18 18:57:06 +00001451 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001452 struct interface *ifp;
1453
1454 ifp = (struct interface *) vty->index;
1455 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001456
hasso508e53e2004-05-18 18:57:06 +00001457 oi = (struct ospf6_interface *) ifp->info;
1458 if (oi == NULL)
1459 oi = ospf6_interface_create (ifp);
1460 assert (oi);
paul718e3742002-12-13 20:15:29 +00001461
hasso508e53e2004-05-18 18:57:06 +00001462 if (oi->plist_name)
1463 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1464 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001465
hasso508e53e2004-05-18 18:57:06 +00001466 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001467
1468 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001469 {
David Ward2470e992010-01-05 02:45:39 +00001470 OSPF6_LINK_LSA_SCHEDULE (oi);
1471 if (oi->state == OSPF6_INTERFACE_DR)
1472 {
1473 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1474 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1475 }
1476 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001477 }
paul718e3742002-12-13 20:15:29 +00001478
1479 return CMD_SUCCESS;
1480}
1481
1482DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1483 no_ipv6_ospf6_advertise_prefix_list_cmd,
1484 "no ipv6 ospf6 advertise prefix-list",
1485 NO_STR
1486 IP6_STR
1487 OSPF6_STR
1488 "Advertising options\n"
1489 "Filter prefix using prefix-list\n"
1490 )
1491{
hasso508e53e2004-05-18 18:57:06 +00001492 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001493 struct interface *ifp;
1494
1495 ifp = (struct interface *) vty->index;
1496 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001497
hasso508e53e2004-05-18 18:57:06 +00001498 oi = (struct ospf6_interface *) ifp->info;
1499 if (oi == NULL)
1500 oi = ospf6_interface_create (ifp);
1501 assert (oi);
1502
1503 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001504 {
hasso508e53e2004-05-18 18:57:06 +00001505 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1506 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001507 }
1508
hasso508e53e2004-05-18 18:57:06 +00001509 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001510
1511 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001512 {
David Ward2470e992010-01-05 02:45:39 +00001513 OSPF6_LINK_LSA_SCHEDULE (oi);
1514 if (oi->state == OSPF6_INTERFACE_DR)
1515 {
1516 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1517 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1518 }
1519 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001520 }
paul718e3742002-12-13 20:15:29 +00001521
1522 return CMD_SUCCESS;
1523}
1524
Paul Jakma6ac29a52008-08-15 13:45:30 +01001525static int
hasso508e53e2004-05-18 18:57:06 +00001526config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001527{
hasso52dc7ee2004-09-23 19:18:23 +00001528 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001529 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001530 struct interface *ifp;
1531
paul1eb8ef22005-04-07 07:30:20 +00001532 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001533 {
hasso508e53e2004-05-18 18:57:06 +00001534 oi = (struct ospf6_interface *) ifp->info;
1535 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001536 continue;
1537
1538 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001539 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001540
1541 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001542 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso1203e1c2004-07-23 21:34:27 +00001543 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001544 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001545
1546 if (oi->cost != OSPF6_INTERFACE_COST)
1547 vty_out (vty, " ipv6 ospf6 cost %d%s",
1548 oi->cost, VNL);
1549
1550 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1551 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1552 oi->hello_interval, VNL);
1553
1554 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1555 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1556 oi->dead_interval, VNL);
1557
1558 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1559 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1560 oi->rxmt_interval, VNL);
1561
1562 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1563 vty_out (vty, " ipv6 ospf6 priority %d%s",
1564 oi->priority, VNL);
1565
1566 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1567 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1568 oi->transdelay, VNL);
1569
1570 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1571 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1572 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001573
hasso508e53e2004-05-18 18:57:06 +00001574 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001575 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001576 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001577
hasso508e53e2004-05-18 18:57:06 +00001578 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001579 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001580
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001581 if (oi->mtu_ignore)
1582 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1583
hasso049207c2004-08-04 20:02:13 +00001584 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001585 }
1586 return 0;
1587}
1588
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001589static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001590{
1591 INTERFACE_NODE,
1592 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001593 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001594};
1595
1596void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001597ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001598{
1599 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001600 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001601
1602 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001603 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1604 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1605 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001606 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001607 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1608 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1609 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001610 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001611 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1612 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1613 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001614 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001615 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1616 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1617 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001618
hasso508e53e2004-05-18 18:57:06 +00001619 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001620 install_default (INTERFACE_NODE);
1621 install_element (INTERFACE_NODE, &interface_desc_cmd);
1622 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1623 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001624 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001625 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001626 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1627 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1628 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1629 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1630 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1631 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001632
paul718e3742002-12-13 20:15:29 +00001633 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1634 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001635
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001636 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1637 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1638
hasso508e53e2004-05-18 18:57:06 +00001639 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1640 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1641}
1642
1643DEFUN (debug_ospf6_interface,
1644 debug_ospf6_interface_cmd,
1645 "debug ospf6 interface",
1646 DEBUG_STR
1647 OSPF6_STR
1648 "Debug OSPFv3 Interface\n"
1649 )
1650{
1651 OSPF6_DEBUG_INTERFACE_ON ();
1652 return CMD_SUCCESS;
1653}
1654
1655DEFUN (no_debug_ospf6_interface,
1656 no_debug_ospf6_interface_cmd,
1657 "no debug ospf6 interface",
1658 NO_STR
1659 DEBUG_STR
1660 OSPF6_STR
1661 "Debug OSPFv3 Interface\n"
1662 )
1663{
hasso3b687352004-08-19 06:56:53 +00001664 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001665 return CMD_SUCCESS;
1666}
1667
1668int
1669config_write_ospf6_debug_interface (struct vty *vty)
1670{
1671 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001672 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001673 return 0;
1674}
1675
1676void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001677install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001678{
1679 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1680 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1681 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1682 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001683}
1684
1685