blob: 467479b1cd3c3e6a064495d196a70b72cde9ca1a [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{
hasso508e53e2004-05-18 18:57:06 +000078 switch (ntohs (lsa->header->type))
79 {
80 case OSPF6_LSTYPE_LINK:
hasso6452df02004-08-15 05:52:07 +000081 if (OSPF6_INTERFACE (lsa->lsdb->data)->state == OSPF6_INTERFACE_DR)
82 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (OSPF6_INTERFACE (lsa->lsdb->data));
83 ospf6_spf_schedule (OSPF6_INTERFACE (lsa->lsdb->data)->area);
hasso508e53e2004-05-18 18:57:06 +000084 break;
paul718e3742002-12-13 20:15:29 +000085
hasso508e53e2004-05-18 18:57:06 +000086 default:
hasso508e53e2004-05-18 18:57:06 +000087 break;
88 }
paul718e3742002-12-13 20:15:29 +000089}
90
91/* Create new ospf6 interface structure */
92struct ospf6_interface *
93ospf6_interface_create (struct interface *ifp)
94{
hasso508e53e2004-05-18 18:57:06 +000095 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +000096 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +000097
hasso508e53e2004-05-18 18:57:06 +000098 oi = (struct ospf6_interface *)
Stephen Hemminger393deb92008-08-18 14:13:29 -070099 XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
paul718e3742002-12-13 20:15:29 +0000100
Stephen Hemminger393deb92008-08-18 14:13:29 -0700101 if (!oi)
paul718e3742002-12-13 20:15:29 +0000102 {
103 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
104 return (struct ospf6_interface *) NULL;
105 }
106
hasso508e53e2004-05-18 18:57:06 +0000107 oi->area = (struct ospf6_area *) NULL;
108 oi->neighbor_list = list_new ();
109 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
110 oi->linklocal_addr = (struct in6_addr *) NULL;
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +0400111 oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
112 oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
113 oi->priority = OSPF6_INTERFACE_PRIORITY;
paul718e3742002-12-13 20:15:29 +0000114
Dinesh Dutt8551e6d2013-10-22 17:42:18 -0700115 oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
116 oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
117 oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +0400118 oi->cost = OSPF6_INTERFACE_COST;
hasso508e53e2004-05-18 18:57:06 +0000119 oi->state = OSPF6_INTERFACE_DOWN;
120 oi->flag = 0;
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400121 oi->mtu_ignore = 0;
paul718e3742002-12-13 20:15:29 +0000122
hassob596c712004-07-09 18:33:43 +0000123 /* Try to adjust I/O buffer size with IfMtu */
hasso1203e1c2004-07-23 21:34:27 +0000124 oi->ifmtu = ifp->mtu6;
125 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000126 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000127 {
hasso1e058382004-09-01 21:36:14 +0000128 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000129 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
130 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000131 oi->ifmtu = iobuflen;
132 }
hasso3b4cd3a2004-05-18 19:28:32 +0000133
hasso6452df02004-08-15 05:52:07 +0000134 oi->lsupdate_list = ospf6_lsdb_create (oi);
135 oi->lsack_list = ospf6_lsdb_create (oi);
136 oi->lsdb = ospf6_lsdb_create (oi);
hasso508e53e2004-05-18 18:57:06 +0000137 oi->lsdb->hook_add = ospf6_interface_lsdb_hook;
138 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook;
hasso6452df02004-08-15 05:52:07 +0000139 oi->lsdb_self = ospf6_lsdb_create (oi);
paul718e3742002-12-13 20:15:29 +0000140
Paul Jakmacf1ce252006-05-15 10:46:07 +0000141 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
142 oi->route_connected->scope = oi;
paul718e3742002-12-13 20:15:29 +0000143
144 /* link both */
hasso508e53e2004-05-18 18:57:06 +0000145 oi->interface = ifp;
146 ifp->info = oi;
paul718e3742002-12-13 20:15:29 +0000147
hasso508e53e2004-05-18 18:57:06 +0000148 return oi;
paul718e3742002-12-13 20:15:29 +0000149}
150
151void
hasso508e53e2004-05-18 18:57:06 +0000152ospf6_interface_delete (struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000153{
paul1eb8ef22005-04-07 07:30:20 +0000154 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000155 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000156
paul1eb8ef22005-04-07 07:30:20 +0000157 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000158 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000159
hasso508e53e2004-05-18 18:57:06 +0000160 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000161
hasso508e53e2004-05-18 18:57:06 +0000162 THREAD_OFF (oi->thread_send_hello);
163 THREAD_OFF (oi->thread_send_lsupdate);
164 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000165
hasso508e53e2004-05-18 18:57:06 +0000166 ospf6_lsdb_remove_all (oi->lsdb);
167 ospf6_lsdb_remove_all (oi->lsupdate_list);
168 ospf6_lsdb_remove_all (oi->lsack_list);
169
170 ospf6_lsdb_delete (oi->lsdb);
hasso6452df02004-08-15 05:52:07 +0000171 ospf6_lsdb_delete (oi->lsdb_self);
172
hasso508e53e2004-05-18 18:57:06 +0000173 ospf6_lsdb_delete (oi->lsupdate_list);
174 ospf6_lsdb_delete (oi->lsack_list);
175
176 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000177
178 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000179 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000180
181 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000182 if (oi->plist_name)
183 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000184
hasso508e53e2004-05-18 18:57:06 +0000185 XFREE (MTYPE_OSPF6_IF, oi);
186}
187
188void
189ospf6_interface_enable (struct ospf6_interface *oi)
190{
191 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
192
193 oi->thread_send_hello =
194 thread_add_event (master, ospf6_hello_send, oi, 0);
195}
196
197void
198ospf6_interface_disable (struct ospf6_interface *oi)
199{
paul1eb8ef22005-04-07 07:30:20 +0000200 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000201 struct ospf6_neighbor *on;
202
203 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
204
paul1eb8ef22005-04-07 07:30:20 +0000205 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000206 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000207
hasso508e53e2004-05-18 18:57:06 +0000208 list_delete_all_node (oi->neighbor_list);
209
210 ospf6_lsdb_remove_all (oi->lsdb);
211 ospf6_lsdb_remove_all (oi->lsupdate_list);
212 ospf6_lsdb_remove_all (oi->lsack_list);
213
214 THREAD_OFF (oi->thread_send_hello);
215 THREAD_OFF (oi->thread_send_lsupdate);
216 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000217}
218
219static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000220ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000221{
hasso52dc7ee2004-09-23 19:18:23 +0000222 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000223 struct connected *c;
224 struct in6_addr *l = (struct in6_addr *) NULL;
225
226 /* for each connected address */
paul1eb8ef22005-04-07 07:30:20 +0000227 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
paul718e3742002-12-13 20:15:29 +0000228 {
paul718e3742002-12-13 20:15:29 +0000229 /* if family not AF_INET6, ignore */
230 if (c->address->family != AF_INET6)
231 continue;
232
233 /* linklocal scope check */
234 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
235 l = &c->address->u.prefix6;
236 }
237 return l;
238}
239
240void
241ospf6_interface_if_add (struct interface *ifp)
242{
hasso508e53e2004-05-18 18:57:06 +0000243 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000244 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000245
hasso508e53e2004-05-18 18:57:06 +0000246 oi = (struct ospf6_interface *) ifp->info;
247 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000248 return;
249
hassob596c712004-07-09 18:33:43 +0000250 /* Try to adjust I/O buffer size with IfMtu */
251 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000252 oi->ifmtu = ifp->mtu6;
253 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000254 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000255 {
hasso1e058382004-09-01 21:36:14 +0000256 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000257 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
258 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000259 oi->ifmtu = iobuflen;
260 }
paul718e3742002-12-13 20:15:29 +0000261
262 /* interface start */
hasso508e53e2004-05-18 18:57:06 +0000263 if (oi->area)
264 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000265}
266
267void
268ospf6_interface_if_del (struct interface *ifp)
269{
hasso508e53e2004-05-18 18:57:06 +0000270 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000271
hasso508e53e2004-05-18 18:57:06 +0000272 oi = (struct ospf6_interface *) ifp->info;
273 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000274 return;
275
276 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000277 if (oi->area)
278 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000279
hasso508e53e2004-05-18 18:57:06 +0000280 listnode_delete (oi->area->if_list, oi);
281 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000282
283 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000284 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000285 ifp->info = NULL;
286
hasso508e53e2004-05-18 18:57:06 +0000287 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000288}
289
290void
291ospf6_interface_state_update (struct interface *ifp)
292{
hasso508e53e2004-05-18 18:57:06 +0000293 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000294
hasso508e53e2004-05-18 18:57:06 +0000295 oi = (struct ospf6_interface *) ifp->info;
296 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000297 return;
hasso508e53e2004-05-18 18:57:06 +0000298 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000299 return;
300
301 if (if_is_up (ifp))
hasso508e53e2004-05-18 18:57:06 +0000302 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000303 else
hasso508e53e2004-05-18 18:57:06 +0000304 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000305
306 return;
307}
308
309void
hasso508e53e2004-05-18 18:57:06 +0000310ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000311{
hasso508e53e2004-05-18 18:57:06 +0000312 struct ospf6_interface *oi;
313 struct ospf6_route *route;
314 struct connected *c;
paul1eb8ef22005-04-07 07:30:20 +0000315 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +0000316
hasso508e53e2004-05-18 18:57:06 +0000317 oi = (struct ospf6_interface *) ifp->info;
318 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000319 return;
320
321 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000322 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000323
hasso508e53e2004-05-18 18:57:06 +0000324 /* if area is null, do not make connected-route list */
325 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000326 return;
327
hasso508e53e2004-05-18 18:57:06 +0000328 /* update "route to advertise" interface route table */
329 ospf6_route_remove_all (oi->route_connected);
hasso508e53e2004-05-18 18:57:06 +0000330
paul1eb8ef22005-04-07 07:30:20 +0000331 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
332 {
hasso508e53e2004-05-18 18:57:06 +0000333 if (c->address->family != AF_INET6)
334 continue;
335
hasso1e058382004-09-01 21:36:14 +0000336 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
337 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
338 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
339 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
340 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000341
342 /* apply filter */
343 if (oi->plist_name)
344 {
345 struct prefix_list *plist;
346 enum prefix_list_type ret;
347 char buf[128];
348
349 prefix2str (c->address, buf, sizeof (buf));
350 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
351 ret = prefix_list_apply (plist, (void *) c->address);
352 if (ret == PREFIX_DENY)
353 {
hasso1e058382004-09-01 21:36:14 +0000354 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000355 zlog_debug ("%s on %s filtered by prefix-list %s ",
356 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000357 continue;
358 }
359 }
360
361 route = ospf6_route_create ();
362 memcpy (&route->prefix, c->address, sizeof (struct prefix));
363 apply_mask (&route->prefix);
364 route->type = OSPF6_DEST_TYPE_NETWORK;
365 route->path.area_id = oi->area->area_id;
366 route->path.type = OSPF6_PATH_TYPE_INTRA;
367 route->path.cost = oi->cost;
368 route->nexthop[0].ifindex = oi->interface->ifindex;
369 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
370 ospf6_route_add (route, oi->route_connected);
371 }
372
paul718e3742002-12-13 20:15:29 +0000373 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000374 OSPF6_LINK_LSA_SCHEDULE (oi);
375 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
376 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000377}
378
hasso508e53e2004-05-18 18:57:06 +0000379static void
380ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000381{
hasso508e53e2004-05-18 18:57:06 +0000382 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000383
hasso508e53e2004-05-18 18:57:06 +0000384 prev_state = oi->state;
385 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000386
hasso508e53e2004-05-18 18:57:06 +0000387 if (prev_state == next_state)
388 return;
paul718e3742002-12-13 20:15:29 +0000389
hasso508e53e2004-05-18 18:57:06 +0000390 /* log */
391 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000392 {
hassoc6487d62004-12-24 06:00:11 +0000393 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
394 ospf6_interface_state_str[prev_state],
395 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000396 }
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200397 oi->state_change++;
paul718e3742002-12-13 20:15:29 +0000398
hasso508e53e2004-05-18 18:57:06 +0000399 if ((prev_state == OSPF6_INTERFACE_DR ||
400 prev_state == OSPF6_INTERFACE_BDR) &&
401 (next_state != OSPF6_INTERFACE_DR &&
402 next_state != OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400403 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000404 if ((prev_state != OSPF6_INTERFACE_DR &&
405 prev_state != OSPF6_INTERFACE_BDR) &&
406 (next_state == OSPF6_INTERFACE_DR ||
407 next_state == OSPF6_INTERFACE_BDR))
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400408 ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
paul718e3742002-12-13 20:15:29 +0000409
hasso508e53e2004-05-18 18:57:06 +0000410 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000411 if (next_state == OSPF6_INTERFACE_DOWN)
412 {
413 OSPF6_NETWORK_LSA_EXECUTE (oi);
414 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
415 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
416 }
417 else if (prev_state == OSPF6_INTERFACE_DR ||
418 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000419 {
hasso508e53e2004-05-18 18:57:06 +0000420 OSPF6_NETWORK_LSA_SCHEDULE (oi);
421 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
422 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000423 }
Vincent Bernatbf836662012-06-04 14:36:12 +0200424
425#ifdef HAVE_SNMP
426 /* Terminal state or regression */
427 if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
428 (next_state == OSPF6_INTERFACE_DROTHER) ||
429 (next_state == OSPF6_INTERFACE_BDR) ||
430 (next_state == OSPF6_INTERFACE_DR) ||
431 (next_state < prev_state))
432 ospf6TrapIfStateChange (oi);
433#endif
434
hasso508e53e2004-05-18 18:57:06 +0000435}
436
437
438/* DR Election, RFC2328 section 9.4 */
439
440#define IS_ELIGIBLE(n) \
441 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
442
443static struct ospf6_neighbor *
444better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
445{
446 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
447 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
448 return NULL;
449 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
450 return b;
451 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
452 return a;
453
454 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
455 return a;
456 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
457 return b;
458
459 if (a->priority > b->priority)
460 return a;
461 if (a->priority < b->priority)
462 return b;
463
464 if (ntohl (a->router_id) > ntohl (b->router_id))
465 return a;
466 if (ntohl (a->router_id) < ntohl (b->router_id))
467 return b;
468
469 zlog_warn ("Router-ID duplicate ?");
470 return a;
471}
472
473static struct ospf6_neighbor *
474better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
475{
476 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
477 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
478 return NULL;
479 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
480 return b;
481 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
482 return a;
483
484 if (a->drouter == a->router_id && b->drouter != b->router_id)
485 return a;
486 if (a->drouter != a->router_id && b->drouter == b->router_id)
487 return b;
488
489 if (a->priority > b->priority)
490 return a;
491 if (a->priority < b->priority)
492 return b;
493
494 if (ntohl (a->router_id) > ntohl (b->router_id))
495 return a;
496 if (ntohl (a->router_id) < ntohl (b->router_id))
497 return b;
498
499 zlog_warn ("Router-ID duplicate ?");
500 return a;
501}
502
503static u_char
504dr_election (struct ospf6_interface *oi)
505{
paul1eb8ef22005-04-07 07:30:20 +0000506 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000507 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
508 struct ospf6_neighbor *best_drouter, *best_bdrouter;
509 u_char next_state = 0;
510
511 drouter = bdrouter = NULL;
512 best_drouter = best_bdrouter = NULL;
513
514 /* pseudo neighbor myself, including noting current DR/BDR (1) */
515 memset (&myself, 0, sizeof (myself));
516 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
517 sizeof (myself.name));
518 myself.state = OSPF6_NEIGHBOR_TWOWAY;
519 myself.drouter = oi->drouter;
520 myself.bdrouter = oi->bdrouter;
521 myself.priority = oi->priority;
522 myself.router_id = oi->area->ospf6->router_id;
523
524 /* Electing BDR (2) */
paul1eb8ef22005-04-07 07:30:20 +0000525 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
526 bdrouter = better_bdrouter (bdrouter, on);
527
hasso508e53e2004-05-18 18:57:06 +0000528 best_bdrouter = bdrouter;
529 bdrouter = better_bdrouter (best_bdrouter, &myself);
530
531 /* Electing DR (3) */
paul1eb8ef22005-04-07 07:30:20 +0000532 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
533 drouter = better_drouter (drouter, on);
534
hasso508e53e2004-05-18 18:57:06 +0000535 best_drouter = drouter;
536 drouter = better_drouter (best_drouter, &myself);
537 if (drouter == NULL)
538 drouter = bdrouter;
539
540 /* the router itself is newly/no longer DR/BDR (4) */
541 if ((drouter == &myself && myself.drouter != myself.router_id) ||
542 (drouter != &myself && myself.drouter == myself.router_id) ||
543 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
544 (bdrouter != &myself && myself.bdrouter == myself.router_id))
545 {
546 myself.drouter = (drouter ? drouter->router_id : htonl (0));
547 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
548
549 /* compatible to Electing BDR (2) */
550 bdrouter = better_bdrouter (best_bdrouter, &myself);
551
552 /* compatible to Electing DR (3) */
553 drouter = better_drouter (best_drouter, &myself);
554 if (drouter == NULL)
555 drouter = bdrouter;
556 }
557
558 /* Set interface state accordingly (5) */
559 if (drouter && drouter == &myself)
560 next_state = OSPF6_INTERFACE_DR;
561 else if (bdrouter && bdrouter == &myself)
562 next_state = OSPF6_INTERFACE_BDR;
563 else
564 next_state = OSPF6_INTERFACE_DROTHER;
565
566 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
567 /* XXX */
568
569 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
570 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
571 accordingly after AdjOK */
572 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
573 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
574 {
575 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000576 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
577 (drouter ? drouter->name : "0.0.0.0"),
578 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000579
paul1eb8ef22005-04-07 07:30:20 +0000580 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
hasso508e53e2004-05-18 18:57:06 +0000581 {
hasso508e53e2004-05-18 18:57:06 +0000582 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
583 continue;
584 /* Schedule AdjOK. */
585 thread_add_event (master, adj_ok, on, 0);
586 }
587 }
588
589 oi->drouter = (drouter ? drouter->router_id : htonl (0));
590 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
591 return next_state;
592}
593
594
595/* Interface State Machine */
596int
597interface_up (struct thread *thread)
598{
599 struct ospf6_interface *oi;
600
601 oi = (struct ospf6_interface *) THREAD_ARG (thread);
602 assert (oi && oi->interface);
603
604 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000605 zlog_debug ("Interface Event %s: [InterfaceUp]",
606 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000607
608 /* check physical interface is up */
609 if (! if_is_up (oi->interface))
610 {
611 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000612 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
613 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000614 return 0;
615 }
616
617 /* if already enabled, do nothing */
618 if (oi->state > OSPF6_INTERFACE_DOWN)
619 {
620 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000621 zlog_debug ("Interface %s already enabled",
622 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000623 return 0;
624 }
625
626 /* Join AllSPFRouters */
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400627 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000628
629 /* Update interface route */
630 ospf6_interface_connected_route_update (oi->interface);
631
632 /* Schedule Hello */
633 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
634 thread_add_event (master, ospf6_hello_send, oi, 0);
635
636 /* decide next interface state */
637 if (if_is_pointopoint (oi->interface))
638 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
639 else if (oi->priority == 0)
640 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
641 else
642 {
643 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
644 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
645 }
646
647 return 0;
paul718e3742002-12-13 20:15:29 +0000648}
649
650int
hasso508e53e2004-05-18 18:57:06 +0000651wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000652{
hasso508e53e2004-05-18 18:57:06 +0000653 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000654
hasso508e53e2004-05-18 18:57:06 +0000655 oi = (struct ospf6_interface *) THREAD_ARG (thread);
656 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000657
hasso508e53e2004-05-18 18:57:06 +0000658 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000659 zlog_debug ("Interface Event %s: [WaitTimer]",
660 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000661
hasso508e53e2004-05-18 18:57:06 +0000662 if (oi->state == OSPF6_INTERFACE_WAITING)
663 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000664
hasso508e53e2004-05-18 18:57:06 +0000665 return 0;
paul718e3742002-12-13 20:15:29 +0000666}
667
hasso508e53e2004-05-18 18:57:06 +0000668int
669backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000670{
hasso508e53e2004-05-18 18:57:06 +0000671 struct ospf6_interface *oi;
672
673 oi = (struct ospf6_interface *) THREAD_ARG (thread);
674 assert (oi && oi->interface);
675
676 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000677 zlog_debug ("Interface Event %s: [BackupSeen]",
678 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000679
680 if (oi->state == OSPF6_INTERFACE_WAITING)
681 ospf6_interface_state_change (dr_election (oi), oi);
682
683 return 0;
paul718e3742002-12-13 20:15:29 +0000684}
685
hasso508e53e2004-05-18 18:57:06 +0000686int
687neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000688{
hasso508e53e2004-05-18 18:57:06 +0000689 struct ospf6_interface *oi;
690
691 oi = (struct ospf6_interface *) THREAD_ARG (thread);
692 assert (oi && oi->interface);
693
694 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000695 zlog_debug ("Interface Event %s: [NeighborChange]",
696 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000697
698 if (oi->state == OSPF6_INTERFACE_DROTHER ||
699 oi->state == OSPF6_INTERFACE_BDR ||
700 oi->state == OSPF6_INTERFACE_DR)
701 ospf6_interface_state_change (dr_election (oi), oi);
702
703 return 0;
paul718e3742002-12-13 20:15:29 +0000704}
705
hasso508e53e2004-05-18 18:57:06 +0000706int
707interface_down (struct thread *thread)
708{
709 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000710 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000711 struct ospf6_neighbor *on;
712
713 oi = (struct ospf6_interface *) THREAD_ARG (thread);
714 assert (oi && oi->interface);
715
716 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000717 zlog_debug ("Interface Event %s: [InterfaceDown]",
718 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000719
720 /* Leave AllSPFRouters */
721 if (oi->state > OSPF6_INTERFACE_DOWN)
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400722 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000723
724 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
725
paul1eb8ef22005-04-07 07:30:20 +0000726 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
727 ospf6_neighbor_delete (on);
728
hasso508e53e2004-05-18 18:57:06 +0000729 list_delete_all_node (oi->neighbor_list);
730
731 return 0;
732}
733
734
paul718e3742002-12-13 20:15:29 +0000735/* show specified interface structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100736static int
hasso508e53e2004-05-18 18:57:06 +0000737ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000738{
hasso508e53e2004-05-18 18:57:06 +0000739 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000740 struct connected *c;
741 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000742 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000743 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000744 const char *updown[3] = {"down", "up", NULL};
745 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000746 struct timeval res, now;
747 char duration[32];
748 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000749
750 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000751 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000752 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000753 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000754 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000755 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000756 type = "POINTOPOINT";
757 else
758 type = "UNKNOWN";
759
760 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000761 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000762 VNL);
763 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000764
hasso508e53e2004-05-18 18:57:06 +0000765 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000766 {
hasso049207c2004-08-04 20:02:13 +0000767 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000768 return 0;
769 }
770 else
hasso508e53e2004-05-18 18:57:06 +0000771 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000772
hasso049207c2004-08-04 20:02:13 +0000773 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000774
775 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000776 {
paul718e3742002-12-13 20:15:29 +0000777 p = c->address;
778 prefix2str (p, strbuf, sizeof (strbuf));
779 switch (p->family)
780 {
781 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000782 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000783 VNL);
paul718e3742002-12-13 20:15:29 +0000784 break;
785 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000786 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000787 VNL);
paul718e3742002-12-13 20:15:29 +0000788 break;
789 default:
hasso508e53e2004-05-18 18:57:06 +0000790 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000791 VNL);
paul718e3742002-12-13 20:15:29 +0000792 break;
793 }
794 }
795
hasso508e53e2004-05-18 18:57:06 +0000796 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000797 {
hasso508e53e2004-05-18 18:57:06 +0000798 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000799 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400800 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
801 "disabled" : "enabled", VNL);
hasso508e53e2004-05-18 18:57:06 +0000802 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000803 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000804 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000805 VNL);
paul718e3742002-12-13 20:15:29 +0000806 }
807 else
hasso049207c2004-08-04 20:02:13 +0000808 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000809
810 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000811 ospf6_interface_state_str[oi->state],
812 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000813 VNL);
814 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000815 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000816 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000817 VNL);
paul718e3742002-12-13 20:15:29 +0000818
hasso508e53e2004-05-18 18:57:06 +0000819 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
820 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000821 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000822
823 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000824 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000825
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900826 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
paul718e3742002-12-13 20:15:29 +0000827
hasso508e53e2004-05-18 18:57:06 +0000828 timerclear (&res);
829 if (oi->thread_send_lsupdate)
830 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
831 timerstring (&res, duration, sizeof (duration));
832 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
833 oi->lsupdate_list->count, duration,
834 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000835 VNL);
hasso508e53e2004-05-18 18:57:06 +0000836 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
837 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000838 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000839
hasso508e53e2004-05-18 18:57:06 +0000840 timerclear (&res);
841 if (oi->thread_send_lsack)
842 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
843 timerstring (&res, duration, sizeof (duration));
844 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
845 oi->lsack_list->count, duration,
846 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000847 VNL);
hasso508e53e2004-05-18 18:57:06 +0000848 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
849 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000850 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000851
hasso508e53e2004-05-18 18:57:06 +0000852 return 0;
paul718e3742002-12-13 20:15:29 +0000853}
854
855/* show interface */
856DEFUN (show_ipv6_ospf6_interface,
857 show_ipv6_ospf6_interface_ifname_cmd,
858 "show ipv6 ospf6 interface IFNAME",
859 SHOW_STR
860 IP6_STR
861 OSPF6_STR
862 INTERFACE_STR
863 IFNAME_STR
864 )
865{
866 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000867 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000868
869 if (argc)
870 {
871 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000872 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000873 {
874 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000875 VNL);
paul718e3742002-12-13 20:15:29 +0000876 return CMD_WARNING;
877 }
878 ospf6_interface_show (vty, ifp);
879 }
880 else
881 {
paul1eb8ef22005-04-07 07:30:20 +0000882 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
883 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000884 }
hasso508e53e2004-05-18 18:57:06 +0000885
paul718e3742002-12-13 20:15:29 +0000886 return CMD_SUCCESS;
887}
888
889ALIAS (show_ipv6_ospf6_interface,
890 show_ipv6_ospf6_interface_cmd,
891 "show ipv6 ospf6 interface",
892 SHOW_STR
893 IP6_STR
894 OSPF6_STR
895 INTERFACE_STR
Paul Jakma6ac29a52008-08-15 13:45:30 +0100896 )
paul718e3742002-12-13 20:15:29 +0000897
hasso508e53e2004-05-18 18:57:06 +0000898DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
899 show_ipv6_ospf6_interface_ifname_prefix_cmd,
900 "show ipv6 ospf6 interface IFNAME prefix",
901 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000902 IP6_STR
903 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000904 INTERFACE_STR
905 IFNAME_STR
906 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000907 )
908{
paul718e3742002-12-13 20:15:29 +0000909 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000910 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000911
hasso508e53e2004-05-18 18:57:06 +0000912 ifp = if_lookup_by_name (argv[0]);
913 if (ifp == NULL)
914 {
hasso049207c2004-08-04 20:02:13 +0000915 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000916 return CMD_WARNING;
917 }
paul718e3742002-12-13 20:15:29 +0000918
hasso508e53e2004-05-18 18:57:06 +0000919 oi = ifp->info;
920 if (oi == NULL)
921 {
hasso049207c2004-08-04 20:02:13 +0000922 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000923 return CMD_WARNING;
924 }
paul718e3742002-12-13 20:15:29 +0000925
hasso508e53e2004-05-18 18:57:06 +0000926 argc--;
927 argv++;
928 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000929
930 return CMD_SUCCESS;
931}
932
hasso508e53e2004-05-18 18:57:06 +0000933ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
934 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
935 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
936 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000937 IP6_STR
938 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000939 INTERFACE_STR
940 IFNAME_STR
941 "Display connected prefixes to advertise\n"
942 OSPF6_ROUTE_ADDRESS_STR
943 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400944 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100945 )
hasso508e53e2004-05-18 18:57:06 +0000946
947ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
948 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
949 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
950 SHOW_STR
951 IP6_STR
952 OSPF6_STR
953 INTERFACE_STR
954 IFNAME_STR
955 "Display connected prefixes to advertise\n"
956 OSPF6_ROUTE_PREFIX_STR
957 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400958 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100959 )
hasso508e53e2004-05-18 18:57:06 +0000960
961DEFUN (show_ipv6_ospf6_interface_prefix,
962 show_ipv6_ospf6_interface_prefix_cmd,
963 "show ipv6 ospf6 interface prefix",
964 SHOW_STR
965 IP6_STR
966 OSPF6_STR
967 INTERFACE_STR
968 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000969 )
970{
hasso52dc7ee2004-09-23 19:18:23 +0000971 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000972 struct ospf6_interface *oi;
973 struct interface *ifp;
974
paul1eb8ef22005-04-07 07:30:20 +0000975 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +0000976 {
hasso508e53e2004-05-18 18:57:06 +0000977 oi = (struct ospf6_interface *) ifp->info;
978 if (oi == NULL)
979 continue;
980
981 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
982 }
983
984 return CMD_SUCCESS;
985}
986
987ALIAS (show_ipv6_ospf6_interface_prefix,
988 show_ipv6_ospf6_interface_prefix_detail_cmd,
989 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
990 SHOW_STR
991 IP6_STR
992 OSPF6_STR
993 INTERFACE_STR
994 "Display connected prefixes to advertise\n"
995 OSPF6_ROUTE_ADDRESS_STR
996 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400997 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100998 )
hasso508e53e2004-05-18 18:57:06 +0000999
1000ALIAS (show_ipv6_ospf6_interface_prefix,
1001 show_ipv6_ospf6_interface_prefix_match_cmd,
1002 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1003 SHOW_STR
1004 IP6_STR
1005 OSPF6_STR
1006 INTERFACE_STR
1007 "Display connected prefixes to advertise\n"
1008 OSPF6_ROUTE_PREFIX_STR
1009 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001010 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001011 )
hasso508e53e2004-05-18 18:57:06 +00001012
1013
1014/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001015DEFUN (ipv6_ospf6_ifmtu,
1016 ipv6_ospf6_ifmtu_cmd,
1017 "ipv6 ospf6 ifmtu <1-65535>",
1018 IP6_STR
1019 OSPF6_STR
1020 "Interface MTU\n"
1021 "OSPFv3 Interface MTU\n"
1022 )
1023{
1024 struct ospf6_interface *oi;
1025 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001026 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001027 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001028 struct ospf6_neighbor *on;
1029
1030 ifp = (struct interface *) vty->index;
1031 assert (ifp);
1032
1033 oi = (struct ospf6_interface *) ifp->info;
1034 if (oi == NULL)
1035 oi = ospf6_interface_create (ifp);
1036 assert (oi);
1037
1038 ifmtu = strtol (argv[0], NULL, 10);
1039
1040 if (oi->ifmtu == ifmtu)
1041 return CMD_SUCCESS;
1042
hasso1203e1c2004-07-23 21:34:27 +00001043 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001044 {
1045 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001046 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001047 return CMD_WARNING;
1048 }
1049
1050 if (oi->ifmtu < ifmtu)
1051 {
1052 iobuflen = ospf6_iobuf_size (ifmtu);
1053 if (iobuflen < ifmtu)
1054 {
1055 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001056 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001057 oi->ifmtu = iobuflen;
1058 }
1059 else
1060 oi->ifmtu = ifmtu;
1061 }
1062 else
1063 oi->ifmtu = ifmtu;
1064
1065 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001066 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001067 {
hassob596c712004-07-09 18:33:43 +00001068 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001069 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001070 }
1071
1072 return CMD_SUCCESS;
1073}
1074
hasso049207c2004-08-04 20:02:13 +00001075DEFUN (no_ipv6_ospf6_ifmtu,
1076 no_ipv6_ospf6_ifmtu_cmd,
1077 "no ipv6 ospf6 ifmtu",
1078 NO_STR
1079 IP6_STR
1080 OSPF6_STR
1081 "Interface MTU\n"
1082 )
1083{
1084 struct ospf6_interface *oi;
1085 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001086 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001087 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001088 struct ospf6_neighbor *on;
1089
1090 ifp = (struct interface *) vty->index;
1091 assert (ifp);
1092
1093 oi = (struct ospf6_interface *) ifp->info;
1094 if (oi == NULL)
1095 oi = ospf6_interface_create (ifp);
1096 assert (oi);
1097
1098 if (oi->ifmtu < ifp->mtu)
1099 {
1100 iobuflen = ospf6_iobuf_size (ifp->mtu);
1101 if (iobuflen < ifp->mtu)
1102 {
1103 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1104 ifp->name, iobuflen, VNL);
1105 oi->ifmtu = iobuflen;
1106 }
1107 else
1108 oi->ifmtu = ifp->mtu;
1109 }
1110 else
1111 oi->ifmtu = ifp->mtu;
1112
1113 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001114 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001115 {
hasso049207c2004-08-04 20:02:13 +00001116 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001117 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001118 }
1119
1120 return CMD_SUCCESS;
1121}
1122
hasso508e53e2004-05-18 18:57:06 +00001123DEFUN (ipv6_ospf6_cost,
1124 ipv6_ospf6_cost_cmd,
1125 "ipv6 ospf6 cost <1-65535>",
1126 IP6_STR
1127 OSPF6_STR
1128 "Interface cost\n"
1129 "Outgoing metric of this interface\n"
1130 )
1131{
1132 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001133 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001134 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001135
1136 ifp = (struct interface *) vty->index;
1137 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001138
hasso508e53e2004-05-18 18:57:06 +00001139 oi = (struct ospf6_interface *) ifp->info;
1140 if (oi == NULL)
1141 oi = ospf6_interface_create (ifp);
1142 assert (oi);
1143
paul0c083ee2004-10-10 12:54:58 +00001144 lcost = strtol (argv[0], NULL, 10);
1145
1146 if (lcost > UINT32_MAX)
1147 {
1148 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1149 return CMD_WARNING;
1150 }
1151
1152 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001153 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001154
1155 oi->cost = lcost;
1156
hasso508e53e2004-05-18 18:57:06 +00001157 /* update cost held in route_connected list in ospf6_interface */
1158 ospf6_interface_connected_route_update (oi->interface);
1159
1160 /* execute LSA hooks */
1161 if (oi->area)
1162 {
1163 OSPF6_LINK_LSA_SCHEDULE (oi);
1164 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1165 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1166 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1167 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1168 }
1169
1170 return CMD_SUCCESS;
1171}
1172
1173DEFUN (ipv6_ospf6_hellointerval,
1174 ipv6_ospf6_hellointerval_cmd,
1175 "ipv6 ospf6 hello-interval <1-65535>",
1176 IP6_STR
1177 OSPF6_STR
1178 "Interval time of Hello packets\n"
1179 SECONDS_STR
1180 )
1181{
1182 struct ospf6_interface *oi;
1183 struct interface *ifp;
1184
1185 ifp = (struct interface *) vty->index;
1186 assert (ifp);
1187
1188 oi = (struct ospf6_interface *) ifp->info;
1189 if (oi == NULL)
1190 oi = ospf6_interface_create (ifp);
1191 assert (oi);
1192
1193 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001194 return CMD_SUCCESS;
1195}
1196
1197/* interface variable set command */
1198DEFUN (ipv6_ospf6_deadinterval,
1199 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001200 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001201 IP6_STR
1202 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001203 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001204 SECONDS_STR
1205 )
1206{
hasso508e53e2004-05-18 18:57:06 +00001207 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001208 struct interface *ifp;
1209
1210 ifp = (struct interface *) vty->index;
1211 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001212
hasso508e53e2004-05-18 18:57:06 +00001213 oi = (struct ospf6_interface *) ifp->info;
1214 if (oi == NULL)
1215 oi = ospf6_interface_create (ifp);
1216 assert (oi);
1217
1218 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001219 return CMD_SUCCESS;
1220}
1221
1222/* interface variable set command */
1223DEFUN (ipv6_ospf6_transmitdelay,
1224 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001225 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001226 IP6_STR
1227 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001228 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001229 SECONDS_STR
1230 )
1231{
hasso508e53e2004-05-18 18:57:06 +00001232 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001233 struct interface *ifp;
1234
1235 ifp = (struct interface *) vty->index;
1236 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001237
hasso508e53e2004-05-18 18:57:06 +00001238 oi = (struct ospf6_interface *) ifp->info;
1239 if (oi == NULL)
1240 oi = ospf6_interface_create (ifp);
1241 assert (oi);
1242
1243 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001244 return CMD_SUCCESS;
1245}
1246
1247/* interface variable set command */
1248DEFUN (ipv6_ospf6_retransmitinterval,
1249 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001250 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001251 IP6_STR
1252 OSPF6_STR
1253 "Time between retransmitting lost link state advertisements\n"
1254 SECONDS_STR
1255 )
1256{
hasso508e53e2004-05-18 18:57:06 +00001257 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001258 struct interface *ifp;
1259
1260 ifp = (struct interface *) vty->index;
1261 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001262
hasso508e53e2004-05-18 18:57:06 +00001263 oi = (struct ospf6_interface *) ifp->info;
1264 if (oi == NULL)
1265 oi = ospf6_interface_create (ifp);
1266 assert (oi);
1267
1268 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001269 return CMD_SUCCESS;
1270}
1271
1272/* interface variable set command */
1273DEFUN (ipv6_ospf6_priority,
1274 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001275 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001276 IP6_STR
1277 OSPF6_STR
1278 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001279 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001280 )
1281{
hasso508e53e2004-05-18 18:57:06 +00001282 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001283 struct interface *ifp;
1284
1285 ifp = (struct interface *) vty->index;
1286 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001287
hasso508e53e2004-05-18 18:57:06 +00001288 oi = (struct ospf6_interface *) ifp->info;
1289 if (oi == NULL)
1290 oi = ospf6_interface_create (ifp);
1291 assert (oi);
paul718e3742002-12-13 20:15:29 +00001292
hasso508e53e2004-05-18 18:57:06 +00001293 oi->priority = strtol (argv[0], NULL, 10);
1294
1295 if (oi->area)
1296 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001297
1298 return CMD_SUCCESS;
1299}
1300
1301DEFUN (ipv6_ospf6_instance,
1302 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001303 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001304 IP6_STR
1305 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001306 "Instance ID for this interface\n"
1307 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001308 )
1309{
hasso508e53e2004-05-18 18:57:06 +00001310 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001311 struct interface *ifp;
1312
1313 ifp = (struct interface *)vty->index;
1314 assert (ifp);
1315
hasso508e53e2004-05-18 18:57:06 +00001316 oi = (struct ospf6_interface *)ifp->info;
1317 if (oi == NULL)
1318 oi = ospf6_interface_create (ifp);
1319 assert (oi);
paul718e3742002-12-13 20:15:29 +00001320
hasso508e53e2004-05-18 18:57:06 +00001321 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001322 return CMD_SUCCESS;
1323}
1324
1325DEFUN (ipv6_ospf6_passive,
1326 ipv6_ospf6_passive_cmd,
1327 "ipv6 ospf6 passive",
1328 IP6_STR
1329 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001330 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001331 )
1332{
hasso508e53e2004-05-18 18:57:06 +00001333 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001334 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001335 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001336 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001337
1338 ifp = (struct interface *) vty->index;
1339 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001340
hasso508e53e2004-05-18 18:57:06 +00001341 oi = (struct ospf6_interface *) ifp->info;
1342 if (oi == NULL)
1343 oi = ospf6_interface_create (ifp);
1344 assert (oi);
paul718e3742002-12-13 20:15:29 +00001345
hasso508e53e2004-05-18 18:57:06 +00001346 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1347 THREAD_OFF (oi->thread_send_hello);
1348
paul1eb8ef22005-04-07 07:30:20 +00001349 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001350 {
hasso508e53e2004-05-18 18:57:06 +00001351 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001352 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001353 }
1354
1355 return CMD_SUCCESS;
1356}
1357
1358DEFUN (no_ipv6_ospf6_passive,
1359 no_ipv6_ospf6_passive_cmd,
1360 "no ipv6 ospf6 passive",
1361 NO_STR
1362 IP6_STR
1363 OSPF6_STR
1364 "passive interface: No Adjacency will be formed on this I/F\n"
1365 )
1366{
hasso508e53e2004-05-18 18:57:06 +00001367 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001368 struct interface *ifp;
1369
1370 ifp = (struct interface *) vty->index;
1371 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001372
hasso508e53e2004-05-18 18:57:06 +00001373 oi = (struct ospf6_interface *) ifp->info;
1374 if (oi == NULL)
1375 oi = ospf6_interface_create (ifp);
1376 assert (oi);
paul718e3742002-12-13 20:15:29 +00001377
hasso508e53e2004-05-18 18:57:06 +00001378 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1379 THREAD_OFF (oi->thread_send_hello);
1380 oi->thread_send_hello =
1381 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001382
1383 return CMD_SUCCESS;
1384}
1385
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001386DEFUN (ipv6_ospf6_mtu_ignore,
1387 ipv6_ospf6_mtu_ignore_cmd,
1388 "ipv6 ospf6 mtu-ignore",
1389 IP6_STR
1390 OSPF6_STR
1391 "Ignore MTU mismatch on this interface\n"
1392 )
1393{
1394 struct ospf6_interface *oi;
1395 struct interface *ifp;
1396
1397 ifp = (struct interface *) vty->index;
1398 assert (ifp);
1399
1400 oi = (struct ospf6_interface *) ifp->info;
1401 if (oi == NULL)
1402 oi = ospf6_interface_create (ifp);
1403 assert (oi);
1404
1405 oi->mtu_ignore = 1;
1406
1407 return CMD_SUCCESS;
1408}
1409
1410DEFUN (no_ipv6_ospf6_mtu_ignore,
1411 no_ipv6_ospf6_mtu_ignore_cmd,
1412 "no ipv6 ospf6 mtu-ignore",
1413 NO_STR
1414 IP6_STR
1415 OSPF6_STR
1416 "Ignore MTU mismatch on this interface\n"
1417 )
1418{
1419 struct ospf6_interface *oi;
1420 struct interface *ifp;
1421
1422 ifp = (struct interface *) vty->index;
1423 assert (ifp);
1424
1425 oi = (struct ospf6_interface *) ifp->info;
1426 if (oi == NULL)
1427 oi = ospf6_interface_create (ifp);
1428 assert (oi);
1429
1430 oi->mtu_ignore = 0;
1431
1432 return CMD_SUCCESS;
1433}
1434
paul718e3742002-12-13 20:15:29 +00001435DEFUN (ipv6_ospf6_advertise_prefix_list,
1436 ipv6_ospf6_advertise_prefix_list_cmd,
1437 "ipv6 ospf6 advertise prefix-list WORD",
1438 IP6_STR
1439 OSPF6_STR
1440 "Advertising options\n"
1441 "Filter prefix using prefix-list\n"
1442 "Prefix list name\n"
1443 )
1444{
hasso508e53e2004-05-18 18:57:06 +00001445 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001446 struct interface *ifp;
1447
1448 ifp = (struct interface *) vty->index;
1449 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001450
hasso508e53e2004-05-18 18:57:06 +00001451 oi = (struct ospf6_interface *) ifp->info;
1452 if (oi == NULL)
1453 oi = ospf6_interface_create (ifp);
1454 assert (oi);
paul718e3742002-12-13 20:15:29 +00001455
hasso508e53e2004-05-18 18:57:06 +00001456 if (oi->plist_name)
1457 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1458 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001459
hasso508e53e2004-05-18 18:57:06 +00001460 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001461
1462 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001463 {
David Ward2470e992010-01-05 02:45:39 +00001464 OSPF6_LINK_LSA_SCHEDULE (oi);
1465 if (oi->state == OSPF6_INTERFACE_DR)
1466 {
1467 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1468 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1469 }
1470 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001471 }
paul718e3742002-12-13 20:15:29 +00001472
1473 return CMD_SUCCESS;
1474}
1475
1476DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1477 no_ipv6_ospf6_advertise_prefix_list_cmd,
1478 "no ipv6 ospf6 advertise prefix-list",
1479 NO_STR
1480 IP6_STR
1481 OSPF6_STR
1482 "Advertising options\n"
1483 "Filter prefix using prefix-list\n"
1484 )
1485{
hasso508e53e2004-05-18 18:57:06 +00001486 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001487 struct interface *ifp;
1488
1489 ifp = (struct interface *) vty->index;
1490 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001491
hasso508e53e2004-05-18 18:57:06 +00001492 oi = (struct ospf6_interface *) ifp->info;
1493 if (oi == NULL)
1494 oi = ospf6_interface_create (ifp);
1495 assert (oi);
1496
1497 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001498 {
hasso508e53e2004-05-18 18:57:06 +00001499 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1500 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001501 }
1502
hasso508e53e2004-05-18 18:57:06 +00001503 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001504
1505 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001506 {
David Ward2470e992010-01-05 02:45:39 +00001507 OSPF6_LINK_LSA_SCHEDULE (oi);
1508 if (oi->state == OSPF6_INTERFACE_DR)
1509 {
1510 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1511 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1512 }
1513 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001514 }
paul718e3742002-12-13 20:15:29 +00001515
1516 return CMD_SUCCESS;
1517}
1518
Paul Jakma6ac29a52008-08-15 13:45:30 +01001519static int
hasso508e53e2004-05-18 18:57:06 +00001520config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001521{
hasso52dc7ee2004-09-23 19:18:23 +00001522 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001523 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001524 struct interface *ifp;
1525
paul1eb8ef22005-04-07 07:30:20 +00001526 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001527 {
hasso508e53e2004-05-18 18:57:06 +00001528 oi = (struct ospf6_interface *) ifp->info;
1529 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001530 continue;
1531
1532 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001533 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001534
1535 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001536 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso1203e1c2004-07-23 21:34:27 +00001537 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001538 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001539
1540 if (oi->cost != OSPF6_INTERFACE_COST)
1541 vty_out (vty, " ipv6 ospf6 cost %d%s",
1542 oi->cost, VNL);
1543
1544 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1545 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1546 oi->hello_interval, VNL);
1547
1548 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1549 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1550 oi->dead_interval, VNL);
1551
1552 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1553 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1554 oi->rxmt_interval, VNL);
1555
1556 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1557 vty_out (vty, " ipv6 ospf6 priority %d%s",
1558 oi->priority, VNL);
1559
1560 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1561 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1562 oi->transdelay, VNL);
1563
1564 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1565 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1566 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001567
hasso508e53e2004-05-18 18:57:06 +00001568 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001569 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001570 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001571
hasso508e53e2004-05-18 18:57:06 +00001572 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001573 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001574
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001575 if (oi->mtu_ignore)
1576 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1577
hasso049207c2004-08-04 20:02:13 +00001578 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001579 }
1580 return 0;
1581}
1582
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001583static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001584{
1585 INTERFACE_NODE,
1586 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001587 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001588};
1589
1590void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001591ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001592{
1593 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001594 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001595
1596 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001597 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1598 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1599 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001600 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001601 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1602 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1603 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001604 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001605 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1606 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1607 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001608 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001609 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1610 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1611 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001612
hasso508e53e2004-05-18 18:57:06 +00001613 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001614 install_default (INTERFACE_NODE);
1615 install_element (INTERFACE_NODE, &interface_desc_cmd);
1616 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1617 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001618 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001619 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001620 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1621 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1622 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1623 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1624 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1625 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001626
paul718e3742002-12-13 20:15:29 +00001627 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1628 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001629
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001630 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1631 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1632
hasso508e53e2004-05-18 18:57:06 +00001633 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1634 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1635}
1636
1637DEFUN (debug_ospf6_interface,
1638 debug_ospf6_interface_cmd,
1639 "debug ospf6 interface",
1640 DEBUG_STR
1641 OSPF6_STR
1642 "Debug OSPFv3 Interface\n"
1643 )
1644{
1645 OSPF6_DEBUG_INTERFACE_ON ();
1646 return CMD_SUCCESS;
1647}
1648
1649DEFUN (no_debug_ospf6_interface,
1650 no_debug_ospf6_interface_cmd,
1651 "no debug ospf6 interface",
1652 NO_STR
1653 DEBUG_STR
1654 OSPF6_STR
1655 "Debug OSPFv3 Interface\n"
1656 )
1657{
hasso3b687352004-08-19 06:56:53 +00001658 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001659 return CMD_SUCCESS;
1660}
1661
1662int
1663config_write_ospf6_debug_interface (struct vty *vty)
1664{
1665 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001666 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001667 return 0;
1668}
1669
1670void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001671install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001672{
1673 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1674 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1675 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1676 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001677}
1678
1679