blob: 6f7aaa8af2174d4e403cf35a81a52c8a2c4d0037 [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
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +0400115 oi->hello_interval = OSPF6_INTERFACE_HELLO_INTERVAL;
116 oi->dead_interval = OSPF6_INTERFACE_DEAD_INTERVAL;
117 oi->rxmt_interval = OSPF6_INTERFACE_RXMT_INTERVAL;
118 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 }
hasso508e53e2004-05-18 18:57:06 +0000424}
425
426
427/* DR Election, RFC2328 section 9.4 */
428
429#define IS_ELIGIBLE(n) \
430 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
431
432static struct ospf6_neighbor *
433better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
434{
435 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
436 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
437 return NULL;
438 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
439 return b;
440 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
441 return a;
442
443 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
444 return a;
445 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
446 return b;
447
448 if (a->priority > b->priority)
449 return a;
450 if (a->priority < b->priority)
451 return b;
452
453 if (ntohl (a->router_id) > ntohl (b->router_id))
454 return a;
455 if (ntohl (a->router_id) < ntohl (b->router_id))
456 return b;
457
458 zlog_warn ("Router-ID duplicate ?");
459 return a;
460}
461
462static struct ospf6_neighbor *
463better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
464{
465 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
466 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
467 return NULL;
468 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
469 return b;
470 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
471 return a;
472
473 if (a->drouter == a->router_id && b->drouter != b->router_id)
474 return a;
475 if (a->drouter != a->router_id && b->drouter == b->router_id)
476 return b;
477
478 if (a->priority > b->priority)
479 return a;
480 if (a->priority < b->priority)
481 return b;
482
483 if (ntohl (a->router_id) > ntohl (b->router_id))
484 return a;
485 if (ntohl (a->router_id) < ntohl (b->router_id))
486 return b;
487
488 zlog_warn ("Router-ID duplicate ?");
489 return a;
490}
491
492static u_char
493dr_election (struct ospf6_interface *oi)
494{
paul1eb8ef22005-04-07 07:30:20 +0000495 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000496 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
497 struct ospf6_neighbor *best_drouter, *best_bdrouter;
498 u_char next_state = 0;
499
500 drouter = bdrouter = NULL;
501 best_drouter = best_bdrouter = NULL;
502
503 /* pseudo neighbor myself, including noting current DR/BDR (1) */
504 memset (&myself, 0, sizeof (myself));
505 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
506 sizeof (myself.name));
507 myself.state = OSPF6_NEIGHBOR_TWOWAY;
508 myself.drouter = oi->drouter;
509 myself.bdrouter = oi->bdrouter;
510 myself.priority = oi->priority;
511 myself.router_id = oi->area->ospf6->router_id;
512
513 /* Electing BDR (2) */
paul1eb8ef22005-04-07 07:30:20 +0000514 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
515 bdrouter = better_bdrouter (bdrouter, on);
516
hasso508e53e2004-05-18 18:57:06 +0000517 best_bdrouter = bdrouter;
518 bdrouter = better_bdrouter (best_bdrouter, &myself);
519
520 /* Electing DR (3) */
paul1eb8ef22005-04-07 07:30:20 +0000521 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
522 drouter = better_drouter (drouter, on);
523
hasso508e53e2004-05-18 18:57:06 +0000524 best_drouter = drouter;
525 drouter = better_drouter (best_drouter, &myself);
526 if (drouter == NULL)
527 drouter = bdrouter;
528
529 /* the router itself is newly/no longer DR/BDR (4) */
530 if ((drouter == &myself && myself.drouter != myself.router_id) ||
531 (drouter != &myself && myself.drouter == myself.router_id) ||
532 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
533 (bdrouter != &myself && myself.bdrouter == myself.router_id))
534 {
535 myself.drouter = (drouter ? drouter->router_id : htonl (0));
536 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
537
538 /* compatible to Electing BDR (2) */
539 bdrouter = better_bdrouter (best_bdrouter, &myself);
540
541 /* compatible to Electing DR (3) */
542 drouter = better_drouter (best_drouter, &myself);
543 if (drouter == NULL)
544 drouter = bdrouter;
545 }
546
547 /* Set interface state accordingly (5) */
548 if (drouter && drouter == &myself)
549 next_state = OSPF6_INTERFACE_DR;
550 else if (bdrouter && bdrouter == &myself)
551 next_state = OSPF6_INTERFACE_BDR;
552 else
553 next_state = OSPF6_INTERFACE_DROTHER;
554
555 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
556 /* XXX */
557
558 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
559 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
560 accordingly after AdjOK */
561 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
562 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
563 {
564 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000565 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
566 (drouter ? drouter->name : "0.0.0.0"),
567 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000568
paul1eb8ef22005-04-07 07:30:20 +0000569 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
hasso508e53e2004-05-18 18:57:06 +0000570 {
hasso508e53e2004-05-18 18:57:06 +0000571 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
572 continue;
573 /* Schedule AdjOK. */
574 thread_add_event (master, adj_ok, on, 0);
575 }
576 }
577
578 oi->drouter = (drouter ? drouter->router_id : htonl (0));
579 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
580 return next_state;
581}
582
583
584/* Interface State Machine */
585int
586interface_up (struct thread *thread)
587{
588 struct ospf6_interface *oi;
589
590 oi = (struct ospf6_interface *) THREAD_ARG (thread);
591 assert (oi && oi->interface);
592
593 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000594 zlog_debug ("Interface Event %s: [InterfaceUp]",
595 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000596
597 /* check physical interface is up */
598 if (! if_is_up (oi->interface))
599 {
600 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000601 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
602 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000603 return 0;
604 }
605
606 /* if already enabled, do nothing */
607 if (oi->state > OSPF6_INTERFACE_DOWN)
608 {
609 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000610 zlog_debug ("Interface %s already enabled",
611 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000612 return 0;
613 }
614
615 /* Join AllSPFRouters */
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400616 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000617
618 /* Update interface route */
619 ospf6_interface_connected_route_update (oi->interface);
620
621 /* Schedule Hello */
622 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
623 thread_add_event (master, ospf6_hello_send, oi, 0);
624
625 /* decide next interface state */
626 if (if_is_pointopoint (oi->interface))
627 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
628 else if (oi->priority == 0)
629 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
630 else
631 {
632 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
633 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
634 }
635
636 return 0;
paul718e3742002-12-13 20:15:29 +0000637}
638
639int
hasso508e53e2004-05-18 18:57:06 +0000640wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000641{
hasso508e53e2004-05-18 18:57:06 +0000642 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000643
hasso508e53e2004-05-18 18:57:06 +0000644 oi = (struct ospf6_interface *) THREAD_ARG (thread);
645 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000646
hasso508e53e2004-05-18 18:57:06 +0000647 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000648 zlog_debug ("Interface Event %s: [WaitTimer]",
649 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000650
hasso508e53e2004-05-18 18:57:06 +0000651 if (oi->state == OSPF6_INTERFACE_WAITING)
652 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000653
hasso508e53e2004-05-18 18:57:06 +0000654 return 0;
paul718e3742002-12-13 20:15:29 +0000655}
656
hasso508e53e2004-05-18 18:57:06 +0000657int
658backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000659{
hasso508e53e2004-05-18 18:57:06 +0000660 struct ospf6_interface *oi;
661
662 oi = (struct ospf6_interface *) THREAD_ARG (thread);
663 assert (oi && oi->interface);
664
665 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000666 zlog_debug ("Interface Event %s: [BackupSeen]",
667 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000668
669 if (oi->state == OSPF6_INTERFACE_WAITING)
670 ospf6_interface_state_change (dr_election (oi), oi);
671
672 return 0;
paul718e3742002-12-13 20:15:29 +0000673}
674
hasso508e53e2004-05-18 18:57:06 +0000675int
676neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000677{
hasso508e53e2004-05-18 18:57:06 +0000678 struct ospf6_interface *oi;
679
680 oi = (struct ospf6_interface *) THREAD_ARG (thread);
681 assert (oi && oi->interface);
682
683 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000684 zlog_debug ("Interface Event %s: [NeighborChange]",
685 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000686
687 if (oi->state == OSPF6_INTERFACE_DROTHER ||
688 oi->state == OSPF6_INTERFACE_BDR ||
689 oi->state == OSPF6_INTERFACE_DR)
690 ospf6_interface_state_change (dr_election (oi), oi);
691
692 return 0;
paul718e3742002-12-13 20:15:29 +0000693}
694
hasso508e53e2004-05-18 18:57:06 +0000695int
696interface_down (struct thread *thread)
697{
698 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000699 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000700 struct ospf6_neighbor *on;
701
702 oi = (struct ospf6_interface *) THREAD_ARG (thread);
703 assert (oi && oi->interface);
704
705 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000706 zlog_debug ("Interface Event %s: [InterfaceDown]",
707 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000708
709 /* Leave AllSPFRouters */
710 if (oi->state > OSPF6_INTERFACE_DOWN)
Vyacheslav Trushkin9a9446e2011-11-21 20:26:39 +0400711 ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
hasso508e53e2004-05-18 18:57:06 +0000712
713 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
714
paul1eb8ef22005-04-07 07:30:20 +0000715 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
716 ospf6_neighbor_delete (on);
717
hasso508e53e2004-05-18 18:57:06 +0000718 list_delete_all_node (oi->neighbor_list);
719
720 return 0;
721}
722
723
paul718e3742002-12-13 20:15:29 +0000724/* show specified interface structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100725static int
hasso508e53e2004-05-18 18:57:06 +0000726ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000727{
hasso508e53e2004-05-18 18:57:06 +0000728 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000729 struct connected *c;
730 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000731 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000732 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000733 const char *updown[3] = {"down", "up", NULL};
734 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000735 struct timeval res, now;
736 char duration[32];
737 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000738
739 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000740 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000741 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000742 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000743 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000744 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000745 type = "POINTOPOINT";
746 else
747 type = "UNKNOWN";
748
749 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000750 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000751 VNL);
752 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000753
hasso508e53e2004-05-18 18:57:06 +0000754 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000755 {
hasso049207c2004-08-04 20:02:13 +0000756 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000757 return 0;
758 }
759 else
hasso508e53e2004-05-18 18:57:06 +0000760 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000761
hasso049207c2004-08-04 20:02:13 +0000762 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000763
764 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000765 {
paul718e3742002-12-13 20:15:29 +0000766 p = c->address;
767 prefix2str (p, strbuf, sizeof (strbuf));
768 switch (p->family)
769 {
770 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000771 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000772 VNL);
paul718e3742002-12-13 20:15:29 +0000773 break;
774 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000775 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000776 VNL);
paul718e3742002-12-13 20:15:29 +0000777 break;
778 default:
hasso508e53e2004-05-18 18:57:06 +0000779 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000780 VNL);
paul718e3742002-12-13 20:15:29 +0000781 break;
782 }
783 }
784
hasso508e53e2004-05-18 18:57:06 +0000785 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000786 {
hasso508e53e2004-05-18 18:57:06 +0000787 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000788 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +0400789 vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
790 "disabled" : "enabled", VNL);
hasso508e53e2004-05-18 18:57:06 +0000791 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000792 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000793 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000794 VNL);
paul718e3742002-12-13 20:15:29 +0000795 }
796 else
hasso049207c2004-08-04 20:02:13 +0000797 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000798
799 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000800 ospf6_interface_state_str[oi->state],
801 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000802 VNL);
803 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000804 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000805 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000806 VNL);
paul718e3742002-12-13 20:15:29 +0000807
hasso508e53e2004-05-18 18:57:06 +0000808 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
809 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000810 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000811
812 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000813 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000814
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900815 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
paul718e3742002-12-13 20:15:29 +0000816
hasso508e53e2004-05-18 18:57:06 +0000817 timerclear (&res);
818 if (oi->thread_send_lsupdate)
819 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
820 timerstring (&res, duration, sizeof (duration));
821 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
822 oi->lsupdate_list->count, duration,
823 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000824 VNL);
hasso508e53e2004-05-18 18:57:06 +0000825 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
826 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000827 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000828
hasso508e53e2004-05-18 18:57:06 +0000829 timerclear (&res);
830 if (oi->thread_send_lsack)
831 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
832 timerstring (&res, duration, sizeof (duration));
833 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
834 oi->lsack_list->count, duration,
835 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000836 VNL);
hasso508e53e2004-05-18 18:57:06 +0000837 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
838 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000839 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000840
hasso508e53e2004-05-18 18:57:06 +0000841 return 0;
paul718e3742002-12-13 20:15:29 +0000842}
843
844/* show interface */
845DEFUN (show_ipv6_ospf6_interface,
846 show_ipv6_ospf6_interface_ifname_cmd,
847 "show ipv6 ospf6 interface IFNAME",
848 SHOW_STR
849 IP6_STR
850 OSPF6_STR
851 INTERFACE_STR
852 IFNAME_STR
853 )
854{
855 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000856 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000857
858 if (argc)
859 {
860 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000861 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000862 {
863 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000864 VNL);
paul718e3742002-12-13 20:15:29 +0000865 return CMD_WARNING;
866 }
867 ospf6_interface_show (vty, ifp);
868 }
869 else
870 {
paul1eb8ef22005-04-07 07:30:20 +0000871 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
872 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000873 }
hasso508e53e2004-05-18 18:57:06 +0000874
paul718e3742002-12-13 20:15:29 +0000875 return CMD_SUCCESS;
876}
877
878ALIAS (show_ipv6_ospf6_interface,
879 show_ipv6_ospf6_interface_cmd,
880 "show ipv6 ospf6 interface",
881 SHOW_STR
882 IP6_STR
883 OSPF6_STR
884 INTERFACE_STR
Paul Jakma6ac29a52008-08-15 13:45:30 +0100885 )
paul718e3742002-12-13 20:15:29 +0000886
hasso508e53e2004-05-18 18:57:06 +0000887DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
888 show_ipv6_ospf6_interface_ifname_prefix_cmd,
889 "show ipv6 ospf6 interface IFNAME prefix",
890 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000891 IP6_STR
892 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000893 INTERFACE_STR
894 IFNAME_STR
895 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000896 )
897{
paul718e3742002-12-13 20:15:29 +0000898 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000899 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000900
hasso508e53e2004-05-18 18:57:06 +0000901 ifp = if_lookup_by_name (argv[0]);
902 if (ifp == NULL)
903 {
hasso049207c2004-08-04 20:02:13 +0000904 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000905 return CMD_WARNING;
906 }
paul718e3742002-12-13 20:15:29 +0000907
hasso508e53e2004-05-18 18:57:06 +0000908 oi = ifp->info;
909 if (oi == NULL)
910 {
hasso049207c2004-08-04 20:02:13 +0000911 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000912 return CMD_WARNING;
913 }
paul718e3742002-12-13 20:15:29 +0000914
hasso508e53e2004-05-18 18:57:06 +0000915 argc--;
916 argv++;
917 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000918
919 return CMD_SUCCESS;
920}
921
hasso508e53e2004-05-18 18:57:06 +0000922ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
923 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
924 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
925 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000926 IP6_STR
927 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000928 INTERFACE_STR
929 IFNAME_STR
930 "Display connected prefixes to advertise\n"
931 OSPF6_ROUTE_ADDRESS_STR
932 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400933 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100934 )
hasso508e53e2004-05-18 18:57:06 +0000935
936ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
937 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
938 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
939 SHOW_STR
940 IP6_STR
941 OSPF6_STR
942 INTERFACE_STR
943 IFNAME_STR
944 "Display connected prefixes to advertise\n"
945 OSPF6_ROUTE_PREFIX_STR
946 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400947 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100948 )
hasso508e53e2004-05-18 18:57:06 +0000949
950DEFUN (show_ipv6_ospf6_interface_prefix,
951 show_ipv6_ospf6_interface_prefix_cmd,
952 "show ipv6 ospf6 interface prefix",
953 SHOW_STR
954 IP6_STR
955 OSPF6_STR
956 INTERFACE_STR
957 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000958 )
959{
hasso52dc7ee2004-09-23 19:18:23 +0000960 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000961 struct ospf6_interface *oi;
962 struct interface *ifp;
963
paul1eb8ef22005-04-07 07:30:20 +0000964 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +0000965 {
hasso508e53e2004-05-18 18:57:06 +0000966 oi = (struct ospf6_interface *) ifp->info;
967 if (oi == NULL)
968 continue;
969
970 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
971 }
972
973 return CMD_SUCCESS;
974}
975
976ALIAS (show_ipv6_ospf6_interface_prefix,
977 show_ipv6_ospf6_interface_prefix_detail_cmd,
978 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
979 SHOW_STR
980 IP6_STR
981 OSPF6_STR
982 INTERFACE_STR
983 "Display connected prefixes to advertise\n"
984 OSPF6_ROUTE_ADDRESS_STR
985 OSPF6_ROUTE_PREFIX_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400986 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100987 )
hasso508e53e2004-05-18 18:57:06 +0000988
989ALIAS (show_ipv6_ospf6_interface_prefix,
990 show_ipv6_ospf6_interface_prefix_match_cmd,
991 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
992 SHOW_STR
993 IP6_STR
994 OSPF6_STR
995 INTERFACE_STR
996 "Display connected prefixes to advertise\n"
997 OSPF6_ROUTE_PREFIX_STR
998 OSPF6_ROUTE_MATCH_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400999 "Display details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001000 )
hasso508e53e2004-05-18 18:57:06 +00001001
1002
1003/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001004DEFUN (ipv6_ospf6_ifmtu,
1005 ipv6_ospf6_ifmtu_cmd,
1006 "ipv6 ospf6 ifmtu <1-65535>",
1007 IP6_STR
1008 OSPF6_STR
1009 "Interface MTU\n"
1010 "OSPFv3 Interface MTU\n"
1011 )
1012{
1013 struct ospf6_interface *oi;
1014 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001015 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001016 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001017 struct ospf6_neighbor *on;
1018
1019 ifp = (struct interface *) vty->index;
1020 assert (ifp);
1021
1022 oi = (struct ospf6_interface *) ifp->info;
1023 if (oi == NULL)
1024 oi = ospf6_interface_create (ifp);
1025 assert (oi);
1026
1027 ifmtu = strtol (argv[0], NULL, 10);
1028
1029 if (oi->ifmtu == ifmtu)
1030 return CMD_SUCCESS;
1031
hasso1203e1c2004-07-23 21:34:27 +00001032 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001033 {
1034 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001035 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001036 return CMD_WARNING;
1037 }
1038
1039 if (oi->ifmtu < ifmtu)
1040 {
1041 iobuflen = ospf6_iobuf_size (ifmtu);
1042 if (iobuflen < ifmtu)
1043 {
1044 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001045 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001046 oi->ifmtu = iobuflen;
1047 }
1048 else
1049 oi->ifmtu = ifmtu;
1050 }
1051 else
1052 oi->ifmtu = ifmtu;
1053
1054 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001055 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001056 {
hassob596c712004-07-09 18:33:43 +00001057 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001058 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001059 }
1060
1061 return CMD_SUCCESS;
1062}
1063
hasso049207c2004-08-04 20:02:13 +00001064DEFUN (no_ipv6_ospf6_ifmtu,
1065 no_ipv6_ospf6_ifmtu_cmd,
1066 "no ipv6 ospf6 ifmtu",
1067 NO_STR
1068 IP6_STR
1069 OSPF6_STR
1070 "Interface MTU\n"
1071 )
1072{
1073 struct ospf6_interface *oi;
1074 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001075 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001076 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001077 struct ospf6_neighbor *on;
1078
1079 ifp = (struct interface *) vty->index;
1080 assert (ifp);
1081
1082 oi = (struct ospf6_interface *) ifp->info;
1083 if (oi == NULL)
1084 oi = ospf6_interface_create (ifp);
1085 assert (oi);
1086
1087 if (oi->ifmtu < ifp->mtu)
1088 {
1089 iobuflen = ospf6_iobuf_size (ifp->mtu);
1090 if (iobuflen < ifp->mtu)
1091 {
1092 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1093 ifp->name, iobuflen, VNL);
1094 oi->ifmtu = iobuflen;
1095 }
1096 else
1097 oi->ifmtu = ifp->mtu;
1098 }
1099 else
1100 oi->ifmtu = ifp->mtu;
1101
1102 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001103 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001104 {
hasso049207c2004-08-04 20:02:13 +00001105 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001106 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001107 }
1108
1109 return CMD_SUCCESS;
1110}
1111
hasso508e53e2004-05-18 18:57:06 +00001112DEFUN (ipv6_ospf6_cost,
1113 ipv6_ospf6_cost_cmd,
1114 "ipv6 ospf6 cost <1-65535>",
1115 IP6_STR
1116 OSPF6_STR
1117 "Interface cost\n"
1118 "Outgoing metric of this interface\n"
1119 )
1120{
1121 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001122 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001123 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001124
1125 ifp = (struct interface *) vty->index;
1126 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001127
hasso508e53e2004-05-18 18:57:06 +00001128 oi = (struct ospf6_interface *) ifp->info;
1129 if (oi == NULL)
1130 oi = ospf6_interface_create (ifp);
1131 assert (oi);
1132
paul0c083ee2004-10-10 12:54:58 +00001133 lcost = strtol (argv[0], NULL, 10);
1134
1135 if (lcost > UINT32_MAX)
1136 {
1137 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1138 return CMD_WARNING;
1139 }
1140
1141 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001142 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001143
1144 oi->cost = lcost;
1145
hasso508e53e2004-05-18 18:57:06 +00001146 /* update cost held in route_connected list in ospf6_interface */
1147 ospf6_interface_connected_route_update (oi->interface);
1148
1149 /* execute LSA hooks */
1150 if (oi->area)
1151 {
1152 OSPF6_LINK_LSA_SCHEDULE (oi);
1153 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1154 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1155 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1156 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1157 }
1158
1159 return CMD_SUCCESS;
1160}
1161
1162DEFUN (ipv6_ospf6_hellointerval,
1163 ipv6_ospf6_hellointerval_cmd,
1164 "ipv6 ospf6 hello-interval <1-65535>",
1165 IP6_STR
1166 OSPF6_STR
1167 "Interval time of Hello packets\n"
1168 SECONDS_STR
1169 )
1170{
1171 struct ospf6_interface *oi;
1172 struct interface *ifp;
1173
1174 ifp = (struct interface *) vty->index;
1175 assert (ifp);
1176
1177 oi = (struct ospf6_interface *) ifp->info;
1178 if (oi == NULL)
1179 oi = ospf6_interface_create (ifp);
1180 assert (oi);
1181
1182 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001183 return CMD_SUCCESS;
1184}
1185
1186/* interface variable set command */
1187DEFUN (ipv6_ospf6_deadinterval,
1188 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001189 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001190 IP6_STR
1191 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001192 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001193 SECONDS_STR
1194 )
1195{
hasso508e53e2004-05-18 18:57:06 +00001196 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001197 struct interface *ifp;
1198
1199 ifp = (struct interface *) vty->index;
1200 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001201
hasso508e53e2004-05-18 18:57:06 +00001202 oi = (struct ospf6_interface *) ifp->info;
1203 if (oi == NULL)
1204 oi = ospf6_interface_create (ifp);
1205 assert (oi);
1206
1207 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001208 return CMD_SUCCESS;
1209}
1210
1211/* interface variable set command */
1212DEFUN (ipv6_ospf6_transmitdelay,
1213 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001214 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001215 IP6_STR
1216 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001217 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001218 SECONDS_STR
1219 )
1220{
hasso508e53e2004-05-18 18:57:06 +00001221 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001222 struct interface *ifp;
1223
1224 ifp = (struct interface *) vty->index;
1225 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001226
hasso508e53e2004-05-18 18:57:06 +00001227 oi = (struct ospf6_interface *) ifp->info;
1228 if (oi == NULL)
1229 oi = ospf6_interface_create (ifp);
1230 assert (oi);
1231
1232 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001233 return CMD_SUCCESS;
1234}
1235
1236/* interface variable set command */
1237DEFUN (ipv6_ospf6_retransmitinterval,
1238 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001239 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001240 IP6_STR
1241 OSPF6_STR
1242 "Time between retransmitting lost link state advertisements\n"
1243 SECONDS_STR
1244 )
1245{
hasso508e53e2004-05-18 18:57:06 +00001246 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001247 struct interface *ifp;
1248
1249 ifp = (struct interface *) vty->index;
1250 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001251
hasso508e53e2004-05-18 18:57:06 +00001252 oi = (struct ospf6_interface *) ifp->info;
1253 if (oi == NULL)
1254 oi = ospf6_interface_create (ifp);
1255 assert (oi);
1256
1257 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001258 return CMD_SUCCESS;
1259}
1260
1261/* interface variable set command */
1262DEFUN (ipv6_ospf6_priority,
1263 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001264 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001265 IP6_STR
1266 OSPF6_STR
1267 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001268 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001269 )
1270{
hasso508e53e2004-05-18 18:57:06 +00001271 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001272 struct interface *ifp;
1273
1274 ifp = (struct interface *) vty->index;
1275 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001276
hasso508e53e2004-05-18 18:57:06 +00001277 oi = (struct ospf6_interface *) ifp->info;
1278 if (oi == NULL)
1279 oi = ospf6_interface_create (ifp);
1280 assert (oi);
paul718e3742002-12-13 20:15:29 +00001281
hasso508e53e2004-05-18 18:57:06 +00001282 oi->priority = strtol (argv[0], NULL, 10);
1283
1284 if (oi->area)
1285 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001286
1287 return CMD_SUCCESS;
1288}
1289
1290DEFUN (ipv6_ospf6_instance,
1291 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001292 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001293 IP6_STR
1294 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001295 "Instance ID for this interface\n"
1296 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001297 )
1298{
hasso508e53e2004-05-18 18:57:06 +00001299 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001300 struct interface *ifp;
1301
1302 ifp = (struct interface *)vty->index;
1303 assert (ifp);
1304
hasso508e53e2004-05-18 18:57:06 +00001305 oi = (struct ospf6_interface *)ifp->info;
1306 if (oi == NULL)
1307 oi = ospf6_interface_create (ifp);
1308 assert (oi);
paul718e3742002-12-13 20:15:29 +00001309
hasso508e53e2004-05-18 18:57:06 +00001310 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001311 return CMD_SUCCESS;
1312}
1313
1314DEFUN (ipv6_ospf6_passive,
1315 ipv6_ospf6_passive_cmd,
1316 "ipv6 ospf6 passive",
1317 IP6_STR
1318 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001319 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001320 )
1321{
hasso508e53e2004-05-18 18:57:06 +00001322 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001323 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001324 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001325 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001326
1327 ifp = (struct interface *) vty->index;
1328 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001329
hasso508e53e2004-05-18 18:57:06 +00001330 oi = (struct ospf6_interface *) ifp->info;
1331 if (oi == NULL)
1332 oi = ospf6_interface_create (ifp);
1333 assert (oi);
paul718e3742002-12-13 20:15:29 +00001334
hasso508e53e2004-05-18 18:57:06 +00001335 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1336 THREAD_OFF (oi->thread_send_hello);
1337
paul1eb8ef22005-04-07 07:30:20 +00001338 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001339 {
hasso508e53e2004-05-18 18:57:06 +00001340 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001341 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001342 }
1343
1344 return CMD_SUCCESS;
1345}
1346
1347DEFUN (no_ipv6_ospf6_passive,
1348 no_ipv6_ospf6_passive_cmd,
1349 "no ipv6 ospf6 passive",
1350 NO_STR
1351 IP6_STR
1352 OSPF6_STR
1353 "passive interface: No Adjacency will be formed on this I/F\n"
1354 )
1355{
hasso508e53e2004-05-18 18:57:06 +00001356 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001357 struct interface *ifp;
1358
1359 ifp = (struct interface *) vty->index;
1360 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001361
hasso508e53e2004-05-18 18:57:06 +00001362 oi = (struct ospf6_interface *) ifp->info;
1363 if (oi == NULL)
1364 oi = ospf6_interface_create (ifp);
1365 assert (oi);
paul718e3742002-12-13 20:15:29 +00001366
hasso508e53e2004-05-18 18:57:06 +00001367 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1368 THREAD_OFF (oi->thread_send_hello);
1369 oi->thread_send_hello =
1370 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001371
1372 return CMD_SUCCESS;
1373}
1374
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001375DEFUN (ipv6_ospf6_mtu_ignore,
1376 ipv6_ospf6_mtu_ignore_cmd,
1377 "ipv6 ospf6 mtu-ignore",
1378 IP6_STR
1379 OSPF6_STR
1380 "Ignore MTU mismatch on this interface\n"
1381 )
1382{
1383 struct ospf6_interface *oi;
1384 struct interface *ifp;
1385
1386 ifp = (struct interface *) vty->index;
1387 assert (ifp);
1388
1389 oi = (struct ospf6_interface *) ifp->info;
1390 if (oi == NULL)
1391 oi = ospf6_interface_create (ifp);
1392 assert (oi);
1393
1394 oi->mtu_ignore = 1;
1395
1396 return CMD_SUCCESS;
1397}
1398
1399DEFUN (no_ipv6_ospf6_mtu_ignore,
1400 no_ipv6_ospf6_mtu_ignore_cmd,
1401 "no ipv6 ospf6 mtu-ignore",
1402 NO_STR
1403 IP6_STR
1404 OSPF6_STR
1405 "Ignore MTU mismatch on this interface\n"
1406 )
1407{
1408 struct ospf6_interface *oi;
1409 struct interface *ifp;
1410
1411 ifp = (struct interface *) vty->index;
1412 assert (ifp);
1413
1414 oi = (struct ospf6_interface *) ifp->info;
1415 if (oi == NULL)
1416 oi = ospf6_interface_create (ifp);
1417 assert (oi);
1418
1419 oi->mtu_ignore = 0;
1420
1421 return CMD_SUCCESS;
1422}
1423
paul718e3742002-12-13 20:15:29 +00001424DEFUN (ipv6_ospf6_advertise_prefix_list,
1425 ipv6_ospf6_advertise_prefix_list_cmd,
1426 "ipv6 ospf6 advertise prefix-list WORD",
1427 IP6_STR
1428 OSPF6_STR
1429 "Advertising options\n"
1430 "Filter prefix using prefix-list\n"
1431 "Prefix list name\n"
1432 )
1433{
hasso508e53e2004-05-18 18:57:06 +00001434 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001435 struct interface *ifp;
1436
1437 ifp = (struct interface *) vty->index;
1438 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001439
hasso508e53e2004-05-18 18:57:06 +00001440 oi = (struct ospf6_interface *) ifp->info;
1441 if (oi == NULL)
1442 oi = ospf6_interface_create (ifp);
1443 assert (oi);
paul718e3742002-12-13 20:15:29 +00001444
hasso508e53e2004-05-18 18:57:06 +00001445 if (oi->plist_name)
1446 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1447 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001448
hasso508e53e2004-05-18 18:57:06 +00001449 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001450
1451 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001452 {
David Ward2470e992010-01-05 02:45:39 +00001453 OSPF6_LINK_LSA_SCHEDULE (oi);
1454 if (oi->state == OSPF6_INTERFACE_DR)
1455 {
1456 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1457 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1458 }
1459 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001460 }
paul718e3742002-12-13 20:15:29 +00001461
1462 return CMD_SUCCESS;
1463}
1464
1465DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1466 no_ipv6_ospf6_advertise_prefix_list_cmd,
1467 "no ipv6 ospf6 advertise prefix-list",
1468 NO_STR
1469 IP6_STR
1470 OSPF6_STR
1471 "Advertising options\n"
1472 "Filter prefix using prefix-list\n"
1473 )
1474{
hasso508e53e2004-05-18 18:57:06 +00001475 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001476 struct interface *ifp;
1477
1478 ifp = (struct interface *) vty->index;
1479 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001480
hasso508e53e2004-05-18 18:57:06 +00001481 oi = (struct ospf6_interface *) ifp->info;
1482 if (oi == NULL)
1483 oi = ospf6_interface_create (ifp);
1484 assert (oi);
1485
1486 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001487 {
hasso508e53e2004-05-18 18:57:06 +00001488 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1489 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001490 }
1491
hasso508e53e2004-05-18 18:57:06 +00001492 ospf6_interface_connected_route_update (oi->interface);
David Ward2470e992010-01-05 02:45:39 +00001493
1494 if (oi->area)
hasso508e53e2004-05-18 18:57:06 +00001495 {
David Ward2470e992010-01-05 02:45:39 +00001496 OSPF6_LINK_LSA_SCHEDULE (oi);
1497 if (oi->state == OSPF6_INTERFACE_DR)
1498 {
1499 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1500 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1501 }
1502 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
hasso508e53e2004-05-18 18:57:06 +00001503 }
paul718e3742002-12-13 20:15:29 +00001504
1505 return CMD_SUCCESS;
1506}
1507
Paul Jakma6ac29a52008-08-15 13:45:30 +01001508static int
hasso508e53e2004-05-18 18:57:06 +00001509config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001510{
hasso52dc7ee2004-09-23 19:18:23 +00001511 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001512 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001513 struct interface *ifp;
1514
paul1eb8ef22005-04-07 07:30:20 +00001515 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001516 {
hasso508e53e2004-05-18 18:57:06 +00001517 oi = (struct ospf6_interface *) ifp->info;
1518 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001519 continue;
1520
1521 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001522 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001523
1524 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001525 vty_out (vty, " description %s%s", ifp->desc, VNL);
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);
Vyacheslav Trushkinb51a3a32012-02-10 10:42:45 +04001528
1529 if (oi->cost != OSPF6_INTERFACE_COST)
1530 vty_out (vty, " ipv6 ospf6 cost %d%s",
1531 oi->cost, VNL);
1532
1533 if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
1534 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
1535 oi->hello_interval, VNL);
1536
1537 if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
1538 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
1539 oi->dead_interval, VNL);
1540
1541 if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
1542 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
1543 oi->rxmt_interval, VNL);
1544
1545 if (oi->priority != OSPF6_INTERFACE_PRIORITY)
1546 vty_out (vty, " ipv6 ospf6 priority %d%s",
1547 oi->priority, VNL);
1548
1549 if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
1550 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
1551 oi->transdelay, VNL);
1552
1553 if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
1554 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
1555 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001556
hasso508e53e2004-05-18 18:57:06 +00001557 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001558 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001559 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001560
hasso508e53e2004-05-18 18:57:06 +00001561 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001562 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001563
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001564 if (oi->mtu_ignore)
1565 vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
1566
hasso049207c2004-08-04 20:02:13 +00001567 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001568 }
1569 return 0;
1570}
1571
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001572static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001573{
1574 INTERFACE_NODE,
1575 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001576 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001577};
1578
1579void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001580ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001581{
1582 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001583 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001584
1585 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001586 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1587 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1588 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001589 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001590 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1591 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1592 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001593 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001594 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1595 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1596 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001597 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001598 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1599 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1600 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001601
hasso508e53e2004-05-18 18:57:06 +00001602 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001603 install_default (INTERFACE_NODE);
1604 install_element (INTERFACE_NODE, &interface_desc_cmd);
1605 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1606 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001607 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001608 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001609 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1610 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1611 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1612 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1613 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1614 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001615
paul718e3742002-12-13 20:15:29 +00001616 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1617 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001618
Dmitrij Tejblumd42306d2011-04-22 19:27:54 +04001619 install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
1620 install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
1621
hasso508e53e2004-05-18 18:57:06 +00001622 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1623 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1624}
1625
1626DEFUN (debug_ospf6_interface,
1627 debug_ospf6_interface_cmd,
1628 "debug ospf6 interface",
1629 DEBUG_STR
1630 OSPF6_STR
1631 "Debug OSPFv3 Interface\n"
1632 )
1633{
1634 OSPF6_DEBUG_INTERFACE_ON ();
1635 return CMD_SUCCESS;
1636}
1637
1638DEFUN (no_debug_ospf6_interface,
1639 no_debug_ospf6_interface_cmd,
1640 "no debug ospf6 interface",
1641 NO_STR
1642 DEBUG_STR
1643 OSPF6_STR
1644 "Debug OSPFv3 Interface\n"
1645 )
1646{
hasso3b687352004-08-19 06:56:53 +00001647 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001648 return CMD_SUCCESS;
1649}
1650
1651int
1652config_write_ospf6_debug_interface (struct vty *vty)
1653{
1654 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001655 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001656 return 0;
1657}
1658
1659void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001660install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001661{
1662 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1663 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1664 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1665 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001666}
1667
1668