blob: 236baf17a96040e5de4fead80e09f144734c244b [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;
111 oi->instance_id = 0;
112 oi->transdelay = 1;
113 oi->priority = 1;
paul718e3742002-12-13 20:15:29 +0000114
hasso508e53e2004-05-18 18:57:06 +0000115 oi->hello_interval = 10;
116 oi->dead_interval = 40;
117 oi->rxmt_interval = 5;
118 oi->cost = 1;
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 }
paul718e3742002-12-13 20:15:29 +0000397
hasso508e53e2004-05-18 18:57:06 +0000398 if ((prev_state == OSPF6_INTERFACE_DR ||
399 prev_state == OSPF6_INTERFACE_BDR) &&
400 (next_state != OSPF6_INTERFACE_DR &&
401 next_state != OSPF6_INTERFACE_BDR))
402 ospf6_leave_alldrouters (oi->interface->ifindex);
403 if ((prev_state != OSPF6_INTERFACE_DR &&
404 prev_state != OSPF6_INTERFACE_BDR) &&
405 (next_state == OSPF6_INTERFACE_DR ||
406 next_state == OSPF6_INTERFACE_BDR))
407 ospf6_join_alldrouters (oi->interface->ifindex);
paul718e3742002-12-13 20:15:29 +0000408
hasso508e53e2004-05-18 18:57:06 +0000409 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000410 if (next_state == OSPF6_INTERFACE_DOWN)
411 {
412 OSPF6_NETWORK_LSA_EXECUTE (oi);
413 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
414 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
415 }
416 else if (prev_state == OSPF6_INTERFACE_DR ||
417 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000418 {
hasso508e53e2004-05-18 18:57:06 +0000419 OSPF6_NETWORK_LSA_SCHEDULE (oi);
420 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
421 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000422 }
hasso508e53e2004-05-18 18:57:06 +0000423}
424
425
426/* DR Election, RFC2328 section 9.4 */
427
428#define IS_ELIGIBLE(n) \
429 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
430
431static struct ospf6_neighbor *
432better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
433{
434 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
435 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
436 return NULL;
437 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
438 return b;
439 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
440 return a;
441
442 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
443 return a;
444 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
445 return b;
446
447 if (a->priority > b->priority)
448 return a;
449 if (a->priority < b->priority)
450 return b;
451
452 if (ntohl (a->router_id) > ntohl (b->router_id))
453 return a;
454 if (ntohl (a->router_id) < ntohl (b->router_id))
455 return b;
456
457 zlog_warn ("Router-ID duplicate ?");
458 return a;
459}
460
461static struct ospf6_neighbor *
462better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
463{
464 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
465 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
466 return NULL;
467 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
468 return b;
469 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
470 return a;
471
472 if (a->drouter == a->router_id && b->drouter != b->router_id)
473 return a;
474 if (a->drouter != a->router_id && b->drouter == b->router_id)
475 return b;
476
477 if (a->priority > b->priority)
478 return a;
479 if (a->priority < b->priority)
480 return b;
481
482 if (ntohl (a->router_id) > ntohl (b->router_id))
483 return a;
484 if (ntohl (a->router_id) < ntohl (b->router_id))
485 return b;
486
487 zlog_warn ("Router-ID duplicate ?");
488 return a;
489}
490
491static u_char
492dr_election (struct ospf6_interface *oi)
493{
paul1eb8ef22005-04-07 07:30:20 +0000494 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000495 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
496 struct ospf6_neighbor *best_drouter, *best_bdrouter;
497 u_char next_state = 0;
498
499 drouter = bdrouter = NULL;
500 best_drouter = best_bdrouter = NULL;
501
502 /* pseudo neighbor myself, including noting current DR/BDR (1) */
503 memset (&myself, 0, sizeof (myself));
504 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
505 sizeof (myself.name));
506 myself.state = OSPF6_NEIGHBOR_TWOWAY;
507 myself.drouter = oi->drouter;
508 myself.bdrouter = oi->bdrouter;
509 myself.priority = oi->priority;
510 myself.router_id = oi->area->ospf6->router_id;
511
512 /* Electing BDR (2) */
paul1eb8ef22005-04-07 07:30:20 +0000513 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
514 bdrouter = better_bdrouter (bdrouter, on);
515
hasso508e53e2004-05-18 18:57:06 +0000516 best_bdrouter = bdrouter;
517 bdrouter = better_bdrouter (best_bdrouter, &myself);
518
519 /* Electing DR (3) */
paul1eb8ef22005-04-07 07:30:20 +0000520 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
521 drouter = better_drouter (drouter, on);
522
hasso508e53e2004-05-18 18:57:06 +0000523 best_drouter = drouter;
524 drouter = better_drouter (best_drouter, &myself);
525 if (drouter == NULL)
526 drouter = bdrouter;
527
528 /* the router itself is newly/no longer DR/BDR (4) */
529 if ((drouter == &myself && myself.drouter != myself.router_id) ||
530 (drouter != &myself && myself.drouter == myself.router_id) ||
531 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
532 (bdrouter != &myself && myself.bdrouter == myself.router_id))
533 {
534 myself.drouter = (drouter ? drouter->router_id : htonl (0));
535 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
536
537 /* compatible to Electing BDR (2) */
538 bdrouter = better_bdrouter (best_bdrouter, &myself);
539
540 /* compatible to Electing DR (3) */
541 drouter = better_drouter (best_drouter, &myself);
542 if (drouter == NULL)
543 drouter = bdrouter;
544 }
545
546 /* Set interface state accordingly (5) */
547 if (drouter && drouter == &myself)
548 next_state = OSPF6_INTERFACE_DR;
549 else if (bdrouter && bdrouter == &myself)
550 next_state = OSPF6_INTERFACE_BDR;
551 else
552 next_state = OSPF6_INTERFACE_DROTHER;
553
554 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
555 /* XXX */
556
557 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
558 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
559 accordingly after AdjOK */
560 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
561 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
562 {
563 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000564 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
565 (drouter ? drouter->name : "0.0.0.0"),
566 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000567
paul1eb8ef22005-04-07 07:30:20 +0000568 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
hasso508e53e2004-05-18 18:57:06 +0000569 {
hasso508e53e2004-05-18 18:57:06 +0000570 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
571 continue;
572 /* Schedule AdjOK. */
573 thread_add_event (master, adj_ok, on, 0);
574 }
575 }
576
577 oi->drouter = (drouter ? drouter->router_id : htonl (0));
578 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
579 return next_state;
580}
581
582
583/* Interface State Machine */
584int
585interface_up (struct thread *thread)
586{
587 struct ospf6_interface *oi;
588
589 oi = (struct ospf6_interface *) THREAD_ARG (thread);
590 assert (oi && oi->interface);
591
592 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000593 zlog_debug ("Interface Event %s: [InterfaceUp]",
594 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000595
596 /* check physical interface is up */
597 if (! if_is_up (oi->interface))
598 {
599 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000600 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
601 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000602 return 0;
603 }
604
605 /* if already enabled, do nothing */
606 if (oi->state > OSPF6_INTERFACE_DOWN)
607 {
608 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000609 zlog_debug ("Interface %s already enabled",
610 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000611 return 0;
612 }
613
614 /* Join AllSPFRouters */
615 ospf6_join_allspfrouters (oi->interface->ifindex);
616
617 /* Update interface route */
618 ospf6_interface_connected_route_update (oi->interface);
619
620 /* Schedule Hello */
621 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
622 thread_add_event (master, ospf6_hello_send, oi, 0);
623
624 /* decide next interface state */
625 if (if_is_pointopoint (oi->interface))
626 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
627 else if (oi->priority == 0)
628 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
629 else
630 {
631 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
632 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
633 }
634
635 return 0;
paul718e3742002-12-13 20:15:29 +0000636}
637
638int
hasso508e53e2004-05-18 18:57:06 +0000639wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000640{
hasso508e53e2004-05-18 18:57:06 +0000641 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000642
hasso508e53e2004-05-18 18:57:06 +0000643 oi = (struct ospf6_interface *) THREAD_ARG (thread);
644 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000645
hasso508e53e2004-05-18 18:57:06 +0000646 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000647 zlog_debug ("Interface Event %s: [WaitTimer]",
648 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000649
hasso508e53e2004-05-18 18:57:06 +0000650 if (oi->state == OSPF6_INTERFACE_WAITING)
651 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000652
hasso508e53e2004-05-18 18:57:06 +0000653 return 0;
paul718e3742002-12-13 20:15:29 +0000654}
655
hasso508e53e2004-05-18 18:57:06 +0000656int
657backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000658{
hasso508e53e2004-05-18 18:57:06 +0000659 struct ospf6_interface *oi;
660
661 oi = (struct ospf6_interface *) THREAD_ARG (thread);
662 assert (oi && oi->interface);
663
664 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000665 zlog_debug ("Interface Event %s: [BackupSeen]",
666 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000667
668 if (oi->state == OSPF6_INTERFACE_WAITING)
669 ospf6_interface_state_change (dr_election (oi), oi);
670
671 return 0;
paul718e3742002-12-13 20:15:29 +0000672}
673
hasso508e53e2004-05-18 18:57:06 +0000674int
675neighbor_change (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: [NeighborChange]",
684 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000685
686 if (oi->state == OSPF6_INTERFACE_DROTHER ||
687 oi->state == OSPF6_INTERFACE_BDR ||
688 oi->state == OSPF6_INTERFACE_DR)
689 ospf6_interface_state_change (dr_election (oi), oi);
690
691 return 0;
paul718e3742002-12-13 20:15:29 +0000692}
693
hasso508e53e2004-05-18 18:57:06 +0000694int
695interface_down (struct thread *thread)
696{
697 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000698 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000699 struct ospf6_neighbor *on;
700
701 oi = (struct ospf6_interface *) THREAD_ARG (thread);
702 assert (oi && oi->interface);
703
704 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000705 zlog_debug ("Interface Event %s: [InterfaceDown]",
706 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000707
708 /* Leave AllSPFRouters */
709 if (oi->state > OSPF6_INTERFACE_DOWN)
710 ospf6_leave_allspfrouters (oi->interface->ifindex);
711
712 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
713
paul1eb8ef22005-04-07 07:30:20 +0000714 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
715 ospf6_neighbor_delete (on);
716
hasso508e53e2004-05-18 18:57:06 +0000717 list_delete_all_node (oi->neighbor_list);
718
719 return 0;
720}
721
722
paul718e3742002-12-13 20:15:29 +0000723/* show specified interface structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100724static int
hasso508e53e2004-05-18 18:57:06 +0000725ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000726{
hasso508e53e2004-05-18 18:57:06 +0000727 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000728 struct connected *c;
729 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000730 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000731 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000732 const char *updown[3] = {"down", "up", NULL};
733 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000734 struct timeval res, now;
735 char duration[32];
736 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000737
738 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000739 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000740 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000741 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000742 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000743 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000744 type = "POINTOPOINT";
745 else
746 type = "UNKNOWN";
747
748 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000749 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000750 VNL);
751 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000752
hasso508e53e2004-05-18 18:57:06 +0000753 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000754 {
hasso049207c2004-08-04 20:02:13 +0000755 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000756 return 0;
757 }
758 else
hasso508e53e2004-05-18 18:57:06 +0000759 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000760
hasso049207c2004-08-04 20:02:13 +0000761 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000762
763 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000764 {
paul718e3742002-12-13 20:15:29 +0000765 p = c->address;
766 prefix2str (p, strbuf, sizeof (strbuf));
767 switch (p->family)
768 {
769 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000770 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000771 VNL);
paul718e3742002-12-13 20:15:29 +0000772 break;
773 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000774 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000775 VNL);
paul718e3742002-12-13 20:15:29 +0000776 break;
777 default:
hasso508e53e2004-05-18 18:57:06 +0000778 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000779 VNL);
paul718e3742002-12-13 20:15:29 +0000780 break;
781 }
782 }
783
hasso508e53e2004-05-18 18:57:06 +0000784 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000785 {
hasso508e53e2004-05-18 18:57:06 +0000786 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000787 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400788 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
789 "disabled" : "enabled", VNL);
hasso508e53e2004-05-18 18:57:06 +0000790 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000791 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000792 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000793 VNL);
paul718e3742002-12-13 20:15:29 +0000794 }
795 else
hasso049207c2004-08-04 20:02:13 +0000796 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000797
798 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000799 ospf6_interface_state_str[oi->state],
800 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000801 VNL);
802 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000803 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000804 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000805 VNL);
paul718e3742002-12-13 20:15:29 +0000806
hasso508e53e2004-05-18 18:57:06 +0000807 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
808 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000809 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000810
811 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000812 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000813
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900814 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
paul718e3742002-12-13 20:15:29 +0000815
hasso508e53e2004-05-18 18:57:06 +0000816 timerclear (&res);
817 if (oi->thread_send_lsupdate)
818 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
819 timerstring (&res, duration, sizeof (duration));
820 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
821 oi->lsupdate_list->count, duration,
822 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000823 VNL);
hasso508e53e2004-05-18 18:57:06 +0000824 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
825 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000826 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000827
hasso508e53e2004-05-18 18:57:06 +0000828 timerclear (&res);
829 if (oi->thread_send_lsack)
830 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
831 timerstring (&res, duration, sizeof (duration));
832 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
833 oi->lsack_list->count, duration,
834 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000835 VNL);
hasso508e53e2004-05-18 18:57:06 +0000836 for (lsa = ospf6_lsdb_head (oi->lsack_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 return 0;
paul718e3742002-12-13 20:15:29 +0000841}
842
843/* show interface */
844DEFUN (show_ipv6_ospf6_interface,
845 show_ipv6_ospf6_interface_ifname_cmd,
846 "show ipv6 ospf6 interface IFNAME",
847 SHOW_STR
848 IP6_STR
849 OSPF6_STR
850 INTERFACE_STR
851 IFNAME_STR
852 )
853{
854 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000855 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000856
857 if (argc)
858 {
859 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000860 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000861 {
862 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000863 VNL);
paul718e3742002-12-13 20:15:29 +0000864 return CMD_WARNING;
865 }
866 ospf6_interface_show (vty, ifp);
867 }
868 else
869 {
paul1eb8ef22005-04-07 07:30:20 +0000870 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
871 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000872 }
hasso508e53e2004-05-18 18:57:06 +0000873
paul718e3742002-12-13 20:15:29 +0000874 return CMD_SUCCESS;
875}
876
877ALIAS (show_ipv6_ospf6_interface,
878 show_ipv6_ospf6_interface_cmd,
879 "show ipv6 ospf6 interface",
880 SHOW_STR
881 IP6_STR
882 OSPF6_STR
883 INTERFACE_STR
Paul Jakma6ac29a52008-08-15 13:45:30 +0100884 )
paul718e3742002-12-13 20:15:29 +0000885
hasso508e53e2004-05-18 18:57:06 +0000886DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
887 show_ipv6_ospf6_interface_ifname_prefix_cmd,
888 "show ipv6 ospf6 interface IFNAME prefix",
889 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000890 IP6_STR
891 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000892 INTERFACE_STR
893 IFNAME_STR
894 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000895 )
896{
paul718e3742002-12-13 20:15:29 +0000897 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000898 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000899
hasso508e53e2004-05-18 18:57:06 +0000900 ifp = if_lookup_by_name (argv[0]);
901 if (ifp == NULL)
902 {
hasso049207c2004-08-04 20:02:13 +0000903 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000904 return CMD_WARNING;
905 }
paul718e3742002-12-13 20:15:29 +0000906
hasso508e53e2004-05-18 18:57:06 +0000907 oi = ifp->info;
908 if (oi == NULL)
909 {
hasso049207c2004-08-04 20:02:13 +0000910 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000911 return CMD_WARNING;
912 }
paul718e3742002-12-13 20:15:29 +0000913
hasso508e53e2004-05-18 18:57:06 +0000914 argc--;
915 argv++;
916 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000917
918 return CMD_SUCCESS;
919}
920
hasso508e53e2004-05-18 18:57:06 +0000921ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
922 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
923 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
924 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000925 IP6_STR
926 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000927 INTERFACE_STR
928 IFNAME_STR
929 "Display connected prefixes to advertise\n"
930 OSPF6_ROUTE_ADDRESS_STR
931 OSPF6_ROUTE_PREFIX_STR
932 "Dispaly details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100933 )
hasso508e53e2004-05-18 18:57:06 +0000934
935ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
936 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
937 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
938 SHOW_STR
939 IP6_STR
940 OSPF6_STR
941 INTERFACE_STR
942 IFNAME_STR
943 "Display connected prefixes to advertise\n"
944 OSPF6_ROUTE_PREFIX_STR
945 OSPF6_ROUTE_MATCH_STR
946 "Dispaly details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100947 )
hasso508e53e2004-05-18 18:57:06 +0000948
949DEFUN (show_ipv6_ospf6_interface_prefix,
950 show_ipv6_ospf6_interface_prefix_cmd,
951 "show ipv6 ospf6 interface prefix",
952 SHOW_STR
953 IP6_STR
954 OSPF6_STR
955 INTERFACE_STR
956 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000957 )
958{
hasso52dc7ee2004-09-23 19:18:23 +0000959 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000960 struct ospf6_interface *oi;
961 struct interface *ifp;
962
paul1eb8ef22005-04-07 07:30:20 +0000963 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +0000964 {
hasso508e53e2004-05-18 18:57:06 +0000965 oi = (struct ospf6_interface *) ifp->info;
966 if (oi == NULL)
967 continue;
968
969 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
970 }
971
972 return CMD_SUCCESS;
973}
974
975ALIAS (show_ipv6_ospf6_interface_prefix,
976 show_ipv6_ospf6_interface_prefix_detail_cmd,
977 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
978 SHOW_STR
979 IP6_STR
980 OSPF6_STR
981 INTERFACE_STR
982 "Display connected prefixes to advertise\n"
983 OSPF6_ROUTE_ADDRESS_STR
984 OSPF6_ROUTE_PREFIX_STR
985 "Dispaly details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100986 )
hasso508e53e2004-05-18 18:57:06 +0000987
988ALIAS (show_ipv6_ospf6_interface_prefix,
989 show_ipv6_ospf6_interface_prefix_match_cmd,
990 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
991 SHOW_STR
992 IP6_STR
993 OSPF6_STR
994 INTERFACE_STR
995 "Display connected prefixes to advertise\n"
996 OSPF6_ROUTE_PREFIX_STR
997 OSPF6_ROUTE_MATCH_STR
998 "Dispaly details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100999 )
hasso508e53e2004-05-18 18:57:06 +00001000
1001
1002/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001003DEFUN (ipv6_ospf6_ifmtu,
1004 ipv6_ospf6_ifmtu_cmd,
1005 "ipv6 ospf6 ifmtu <1-65535>",
1006 IP6_STR
1007 OSPF6_STR
1008 "Interface MTU\n"
1009 "OSPFv3 Interface MTU\n"
1010 )
1011{
1012 struct ospf6_interface *oi;
1013 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001014 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001015 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001016 struct ospf6_neighbor *on;
1017
1018 ifp = (struct interface *) vty->index;
1019 assert (ifp);
1020
1021 oi = (struct ospf6_interface *) ifp->info;
1022 if (oi == NULL)
1023 oi = ospf6_interface_create (ifp);
1024 assert (oi);
1025
1026 ifmtu = strtol (argv[0], NULL, 10);
1027
1028 if (oi->ifmtu == ifmtu)
1029 return CMD_SUCCESS;
1030
hasso1203e1c2004-07-23 21:34:27 +00001031 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001032 {
1033 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001034 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001035 return CMD_WARNING;
1036 }
1037
1038 if (oi->ifmtu < ifmtu)
1039 {
1040 iobuflen = ospf6_iobuf_size (ifmtu);
1041 if (iobuflen < ifmtu)
1042 {
1043 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001044 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001045 oi->ifmtu = iobuflen;
1046 }
1047 else
1048 oi->ifmtu = ifmtu;
1049 }
1050 else
1051 oi->ifmtu = ifmtu;
1052
1053 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001054 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001055 {
hassob596c712004-07-09 18:33:43 +00001056 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001057 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001058 }
1059
1060 return CMD_SUCCESS;
1061}
1062
hasso049207c2004-08-04 20:02:13 +00001063DEFUN (no_ipv6_ospf6_ifmtu,
1064 no_ipv6_ospf6_ifmtu_cmd,
1065 "no ipv6 ospf6 ifmtu",
1066 NO_STR
1067 IP6_STR
1068 OSPF6_STR
1069 "Interface MTU\n"
1070 )
1071{
1072 struct ospf6_interface *oi;
1073 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001074 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001075 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001076 struct ospf6_neighbor *on;
1077
1078 ifp = (struct interface *) vty->index;
1079 assert (ifp);
1080
1081 oi = (struct ospf6_interface *) ifp->info;
1082 if (oi == NULL)
1083 oi = ospf6_interface_create (ifp);
1084 assert (oi);
1085
1086 if (oi->ifmtu < ifp->mtu)
1087 {
1088 iobuflen = ospf6_iobuf_size (ifp->mtu);
1089 if (iobuflen < ifp->mtu)
1090 {
1091 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1092 ifp->name, iobuflen, VNL);
1093 oi->ifmtu = iobuflen;
1094 }
1095 else
1096 oi->ifmtu = ifp->mtu;
1097 }
1098 else
1099 oi->ifmtu = ifp->mtu;
1100
1101 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001102 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001103 {
hasso049207c2004-08-04 20:02:13 +00001104 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001105 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001106 }
1107
1108 return CMD_SUCCESS;
1109}
1110
hasso508e53e2004-05-18 18:57:06 +00001111DEFUN (ipv6_ospf6_cost,
1112 ipv6_ospf6_cost_cmd,
1113 "ipv6 ospf6 cost <1-65535>",
1114 IP6_STR
1115 OSPF6_STR
1116 "Interface cost\n"
1117 "Outgoing metric of this interface\n"
1118 )
1119{
1120 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001121 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001122 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001123
1124 ifp = (struct interface *) vty->index;
1125 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001126
hasso508e53e2004-05-18 18:57:06 +00001127 oi = (struct ospf6_interface *) ifp->info;
1128 if (oi == NULL)
1129 oi = ospf6_interface_create (ifp);
1130 assert (oi);
1131
paul0c083ee2004-10-10 12:54:58 +00001132 lcost = strtol (argv[0], NULL, 10);
1133
1134 if (lcost > UINT32_MAX)
1135 {
1136 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1137 return CMD_WARNING;
1138 }
1139
1140 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001141 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001142
1143 oi->cost = lcost;
1144
hasso508e53e2004-05-18 18:57:06 +00001145 /* update cost held in route_connected list in ospf6_interface */
1146 ospf6_interface_connected_route_update (oi->interface);
1147
1148 /* execute LSA hooks */
1149 if (oi->area)
1150 {
1151 OSPF6_LINK_LSA_SCHEDULE (oi);
1152 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1153 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1154 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1155 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1156 }
1157
1158 return CMD_SUCCESS;
1159}
1160
1161DEFUN (ipv6_ospf6_hellointerval,
1162 ipv6_ospf6_hellointerval_cmd,
1163 "ipv6 ospf6 hello-interval <1-65535>",
1164 IP6_STR
1165 OSPF6_STR
1166 "Interval time of Hello packets\n"
1167 SECONDS_STR
1168 )
1169{
1170 struct ospf6_interface *oi;
1171 struct interface *ifp;
1172
1173 ifp = (struct interface *) vty->index;
1174 assert (ifp);
1175
1176 oi = (struct ospf6_interface *) ifp->info;
1177 if (oi == NULL)
1178 oi = ospf6_interface_create (ifp);
1179 assert (oi);
1180
1181 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001182 return CMD_SUCCESS;
1183}
1184
1185/* interface variable set command */
1186DEFUN (ipv6_ospf6_deadinterval,
1187 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001188 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001189 IP6_STR
1190 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001191 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001192 SECONDS_STR
1193 )
1194{
hasso508e53e2004-05-18 18:57:06 +00001195 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001196 struct interface *ifp;
1197
1198 ifp = (struct interface *) vty->index;
1199 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001200
hasso508e53e2004-05-18 18:57:06 +00001201 oi = (struct ospf6_interface *) ifp->info;
1202 if (oi == NULL)
1203 oi = ospf6_interface_create (ifp);
1204 assert (oi);
1205
1206 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001207 return CMD_SUCCESS;
1208}
1209
1210/* interface variable set command */
1211DEFUN (ipv6_ospf6_transmitdelay,
1212 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001213 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001214 IP6_STR
1215 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001216 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001217 SECONDS_STR
1218 )
1219{
hasso508e53e2004-05-18 18:57:06 +00001220 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001221 struct interface *ifp;
1222
1223 ifp = (struct interface *) vty->index;
1224 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001225
hasso508e53e2004-05-18 18:57:06 +00001226 oi = (struct ospf6_interface *) ifp->info;
1227 if (oi == NULL)
1228 oi = ospf6_interface_create (ifp);
1229 assert (oi);
1230
1231 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001232 return CMD_SUCCESS;
1233}
1234
1235/* interface variable set command */
1236DEFUN (ipv6_ospf6_retransmitinterval,
1237 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001238 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001239 IP6_STR
1240 OSPF6_STR
1241 "Time between retransmitting lost link state advertisements\n"
1242 SECONDS_STR
1243 )
1244{
hasso508e53e2004-05-18 18:57:06 +00001245 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001246 struct interface *ifp;
1247
1248 ifp = (struct interface *) vty->index;
1249 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001250
hasso508e53e2004-05-18 18:57:06 +00001251 oi = (struct ospf6_interface *) ifp->info;
1252 if (oi == NULL)
1253 oi = ospf6_interface_create (ifp);
1254 assert (oi);
1255
1256 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001257 return CMD_SUCCESS;
1258}
1259
1260/* interface variable set command */
1261DEFUN (ipv6_ospf6_priority,
1262 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001263 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001264 IP6_STR
1265 OSPF6_STR
1266 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001267 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001268 )
1269{
hasso508e53e2004-05-18 18:57:06 +00001270 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001271 struct interface *ifp;
1272
1273 ifp = (struct interface *) vty->index;
1274 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001275
hasso508e53e2004-05-18 18:57:06 +00001276 oi = (struct ospf6_interface *) ifp->info;
1277 if (oi == NULL)
1278 oi = ospf6_interface_create (ifp);
1279 assert (oi);
paul718e3742002-12-13 20:15:29 +00001280
hasso508e53e2004-05-18 18:57:06 +00001281 oi->priority = strtol (argv[0], NULL, 10);
1282
1283 if (oi->area)
1284 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001285
1286 return CMD_SUCCESS;
1287}
1288
1289DEFUN (ipv6_ospf6_instance,
1290 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001291 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001292 IP6_STR
1293 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001294 "Instance ID for this interface\n"
1295 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001296 )
1297{
hasso508e53e2004-05-18 18:57:06 +00001298 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001299 struct interface *ifp;
1300
1301 ifp = (struct interface *)vty->index;
1302 assert (ifp);
1303
hasso508e53e2004-05-18 18:57:06 +00001304 oi = (struct ospf6_interface *)ifp->info;
1305 if (oi == NULL)
1306 oi = ospf6_interface_create (ifp);
1307 assert (oi);
paul718e3742002-12-13 20:15:29 +00001308
hasso508e53e2004-05-18 18:57:06 +00001309 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001310 return CMD_SUCCESS;
1311}
1312
1313DEFUN (ipv6_ospf6_passive,
1314 ipv6_ospf6_passive_cmd,
1315 "ipv6 ospf6 passive",
1316 IP6_STR
1317 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001318 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001319 )
1320{
hasso508e53e2004-05-18 18:57:06 +00001321 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001322 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001323 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001324 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001325
1326 ifp = (struct interface *) vty->index;
1327 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001328
hasso508e53e2004-05-18 18:57:06 +00001329 oi = (struct ospf6_interface *) ifp->info;
1330 if (oi == NULL)
1331 oi = ospf6_interface_create (ifp);
1332 assert (oi);
paul718e3742002-12-13 20:15:29 +00001333
hasso508e53e2004-05-18 18:57:06 +00001334 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1335 THREAD_OFF (oi->thread_send_hello);
1336
paul1eb8ef22005-04-07 07:30:20 +00001337 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001338 {
hasso508e53e2004-05-18 18:57:06 +00001339 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001340 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001341 }
1342
1343 return CMD_SUCCESS;
1344}
1345
1346DEFUN (no_ipv6_ospf6_passive,
1347 no_ipv6_ospf6_passive_cmd,
1348 "no ipv6 ospf6 passive",
1349 NO_STR
1350 IP6_STR
1351 OSPF6_STR
1352 "passive interface: No Adjacency will be formed on this I/F\n"
1353 )
1354{
hasso508e53e2004-05-18 18:57:06 +00001355 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001356 struct interface *ifp;
1357
1358 ifp = (struct interface *) vty->index;
1359 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001360
hasso508e53e2004-05-18 18:57:06 +00001361 oi = (struct ospf6_interface *) ifp->info;
1362 if (oi == NULL)
1363 oi = ospf6_interface_create (ifp);
1364 assert (oi);
paul718e3742002-12-13 20:15:29 +00001365
hasso508e53e2004-05-18 18:57:06 +00001366 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1367 THREAD_OFF (oi->thread_send_hello);
1368 oi->thread_send_hello =
1369 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001370
1371 return CMD_SUCCESS;
1372}
1373
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001374DEFUN (ipv6_ospf6_mtu_ignore,
1375 ipv6_ospf6_mtu_ignore_cmd,
1376 "ipv6 ospf6 mtu-ignore",
1377 IP6_STR
1378 OSPF6_STR
1379 "Ignore MTU mismatch on this interface\n"
1380 )
1381{
1382 struct ospf6_interface *oi;
1383 struct interface *ifp;
1384
1385 ifp = (struct interface *) vty->index;
1386 assert (ifp);
1387
1388 oi = (struct ospf6_interface *) ifp->info;
1389 if (oi == NULL)
1390 oi = ospf6_interface_create (ifp);
1391 assert (oi);
1392
1393 oi->mtu_ignore = 1;
1394
1395 return CMD_SUCCESS;
1396}
1397
1398DEFUN (no_ipv6_ospf6_mtu_ignore,
1399 no_ipv6_ospf6_mtu_ignore_cmd,
1400 "no ipv6 ospf6 mtu-ignore",
1401 NO_STR
1402 IP6_STR
1403 OSPF6_STR
1404 "Ignore MTU mismatch on this interface\n"
1405 )
1406{
1407 struct ospf6_interface *oi;
1408 struct interface *ifp;
1409
1410 ifp = (struct interface *) vty->index;
1411 assert (ifp);
1412
1413 oi = (struct ospf6_interface *) ifp->info;
1414 if (oi == NULL)
1415 oi = ospf6_interface_create (ifp);
1416 assert (oi);
1417
1418 oi->mtu_ignore = 0;
1419
1420 return CMD_SUCCESS;
1421}
1422
paul718e3742002-12-13 20:15:29 +00001423DEFUN (ipv6_ospf6_advertise_prefix_list,
1424 ipv6_ospf6_advertise_prefix_list_cmd,
1425 "ipv6 ospf6 advertise prefix-list WORD",
1426 IP6_STR
1427 OSPF6_STR
1428 "Advertising options\n"
1429 "Filter prefix using prefix-list\n"
1430 "Prefix list name\n"
1431 )
1432{
hasso508e53e2004-05-18 18:57:06 +00001433 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001434 struct interface *ifp;
1435
1436 ifp = (struct interface *) vty->index;
1437 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001438
hasso508e53e2004-05-18 18:57:06 +00001439 oi = (struct ospf6_interface *) ifp->info;
1440 if (oi == NULL)
1441 oi = ospf6_interface_create (ifp);
1442 assert (oi);
paul718e3742002-12-13 20:15:29 +00001443
hasso508e53e2004-05-18 18:57:06 +00001444 if (oi->plist_name)
1445 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1446 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001447
hasso508e53e2004-05-18 18:57:06 +00001448 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001449
1450 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001451 {
David Ward2470e992010-01-05 02:45:39 +00001452 OSPF6_LINK_LSA_SCHEDULE (oi);
1453 if (oi->state == OSPF6_INTERFACE_DR)
1454 {
1455 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1456 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1457 }
1458 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001459 }
paul718e3742002-12-13 20:15:29 +00001460
1461 return CMD_SUCCESS;
1462}
1463
1464DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1465 no_ipv6_ospf6_advertise_prefix_list_cmd,
1466 "no ipv6 ospf6 advertise prefix-list",
1467 NO_STR
1468 IP6_STR
1469 OSPF6_STR
1470 "Advertising options\n"
1471 "Filter prefix using prefix-list\n"
1472 )
1473{
hasso508e53e2004-05-18 18:57:06 +00001474 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001475 struct interface *ifp;
1476
1477 ifp = (struct interface *) vty->index;
1478 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001479
hasso508e53e2004-05-18 18:57:06 +00001480 oi = (struct ospf6_interface *) ifp->info;
1481 if (oi == NULL)
1482 oi = ospf6_interface_create (ifp);
1483 assert (oi);
1484
1485 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001486 {
hasso508e53e2004-05-18 18:57:06 +00001487 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1488 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001489 }
1490
hasso508e53e2004-05-18 18:57:06 +00001491 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001492
1493 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001494 {
David Ward2470e992010-01-05 02:45:39 +00001495 OSPF6_LINK_LSA_SCHEDULE (oi);
1496 if (oi->state == OSPF6_INTERFACE_DR)
1497 {
1498 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1499 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1500 }
1501 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001502 }
paul718e3742002-12-13 20:15:29 +00001503
1504 return CMD_SUCCESS;
1505}
1506
Paul Jakma6ac29a52008-08-15 13:45:30 +01001507static int
hasso508e53e2004-05-18 18:57:06 +00001508config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001509{
hasso52dc7ee2004-09-23 19:18:23 +00001510 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001511 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001512 struct interface *ifp;
1513
paul1eb8ef22005-04-07 07:30:20 +00001514 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001515 {
hasso508e53e2004-05-18 18:57:06 +00001516 oi = (struct ospf6_interface *) ifp->info;
1517 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001518 continue;
1519
1520 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001521 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001522
1523 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001524 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso508e53e2004-05-18 18:57:06 +00001525
hasso1203e1c2004-07-23 21:34:27 +00001526 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001527 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
paul718e3742002-12-13 20:15:29 +00001528 vty_out (vty, " ipv6 ospf6 cost %d%s",
hasso049207c2004-08-04 20:02:13 +00001529 oi->cost, VNL);
paul718e3742002-12-13 20:15:29 +00001530 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001531 oi->hello_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001532 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001533 oi->dead_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001534 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001535 oi->rxmt_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001536 vty_out (vty, " ipv6 ospf6 priority %d%s",
hasso049207c2004-08-04 20:02:13 +00001537 oi->priority, VNL);
paul718e3742002-12-13 20:15:29 +00001538 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
hasso049207c2004-08-04 20:02:13 +00001539 oi->transdelay, VNL);
paul718e3742002-12-13 20:15:29 +00001540 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
hasso049207c2004-08-04 20:02:13 +00001541 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001542
hasso508e53e2004-05-18 18:57:06 +00001543 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001544 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001545 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001546
hasso508e53e2004-05-18 18:57:06 +00001547 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001548 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001549
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001550 if (oi->mtu_ignore)
1551 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1552
hasso049207c2004-08-04 20:02:13 +00001553 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001554 }
1555 return 0;
1556}
1557
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001558static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001559{
1560 INTERFACE_NODE,
1561 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001562 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001563};
1564
1565void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001566ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001567{
1568 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001569 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001570
1571 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001572 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1573 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1574 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001575 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001576 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1577 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1578 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001579 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001580 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1581 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1582 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001583 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001584 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1585 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1586 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001587
hasso508e53e2004-05-18 18:57:06 +00001588 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001589 install_default (INTERFACE_NODE);
1590 install_element (INTERFACE_NODE, &interface_desc_cmd);
1591 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1592 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001593 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001594 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001595 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1596 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1597 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1598 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1599 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1600 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001601
paul718e3742002-12-13 20:15:29 +00001602 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1603 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001604
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001605 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1606 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1607
hasso508e53e2004-05-18 18:57:06 +00001608 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1609 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1610}
1611
1612DEFUN (debug_ospf6_interface,
1613 debug_ospf6_interface_cmd,
1614 "debug ospf6 interface",
1615 DEBUG_STR
1616 OSPF6_STR
1617 "Debug OSPFv3 Interface\n"
1618 )
1619{
1620 OSPF6_DEBUG_INTERFACE_ON ();
1621 return CMD_SUCCESS;
1622}
1623
1624DEFUN (no_debug_ospf6_interface,
1625 no_debug_ospf6_interface_cmd,
1626 "no debug ospf6 interface",
1627 NO_STR
1628 DEBUG_STR
1629 OSPF6_STR
1630 "Debug OSPFv3 Interface\n"
1631 )
1632{
hasso3b687352004-08-19 06:56:53 +00001633 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001634 return CMD_SUCCESS;
1635}
1636
1637int
1638config_write_ospf6_debug_interface (struct vty *vty)
1639{
1640 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001641 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001642 return 0;
1643}
1644
1645void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001646install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001647{
1648 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1649 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1650 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1651 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001652}
1653
1654