blob: 95464b63a159932d153e4d3e26e46df4ef76bf2a [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 */
paul718e3742002-12-13 20:15:29 +000075void
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 *)
paul718e3742002-12-13 20:15:29 +000099 XMALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
100
hasso508e53e2004-05-18 18:57:06 +0000101 if (oi)
102 memset (oi, 0, sizeof (struct ospf6_interface));
paul718e3742002-12-13 20:15:29 +0000103 else
104 {
105 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
106 return (struct ospf6_interface *) NULL;
107 }
108
hasso508e53e2004-05-18 18:57:06 +0000109 oi->area = (struct ospf6_area *) NULL;
110 oi->neighbor_list = list_new ();
111 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
112 oi->linklocal_addr = (struct in6_addr *) NULL;
113 oi->instance_id = 0;
114 oi->transdelay = 1;
115 oi->priority = 1;
paul718e3742002-12-13 20:15:29 +0000116
hasso508e53e2004-05-18 18:57:06 +0000117 oi->hello_interval = 10;
118 oi->dead_interval = 40;
119 oi->rxmt_interval = 5;
120 oi->cost = 1;
hasso508e53e2004-05-18 18:57:06 +0000121 oi->state = OSPF6_INTERFACE_DOWN;
122 oi->flag = 0;
paul718e3742002-12-13 20:15:29 +0000123
hassob596c712004-07-09 18:33:43 +0000124 /* Try to adjust I/O buffer size with IfMtu */
hasso1203e1c2004-07-23 21:34:27 +0000125 oi->ifmtu = ifp->mtu6;
126 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000127 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000128 {
hasso1e058382004-09-01 21:36:14 +0000129 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000130 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
131 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000132 oi->ifmtu = iobuflen;
133 }
hasso3b4cd3a2004-05-18 19:28:32 +0000134
hasso6452df02004-08-15 05:52:07 +0000135 oi->lsupdate_list = ospf6_lsdb_create (oi);
136 oi->lsack_list = ospf6_lsdb_create (oi);
137 oi->lsdb = ospf6_lsdb_create (oi);
hasso508e53e2004-05-18 18:57:06 +0000138 oi->lsdb->hook_add = ospf6_interface_lsdb_hook;
139 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook;
hasso6452df02004-08-15 05:52:07 +0000140 oi->lsdb_self = ospf6_lsdb_create (oi);
paul718e3742002-12-13 20:15:29 +0000141
Paul Jakmacf1ce252006-05-15 10:46:07 +0000142 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
143 oi->route_connected->scope = oi;
paul718e3742002-12-13 20:15:29 +0000144
145 /* link both */
hasso508e53e2004-05-18 18:57:06 +0000146 oi->interface = ifp;
147 ifp->info = oi;
paul718e3742002-12-13 20:15:29 +0000148
hasso508e53e2004-05-18 18:57:06 +0000149 return oi;
paul718e3742002-12-13 20:15:29 +0000150}
151
152void
hasso508e53e2004-05-18 18:57:06 +0000153ospf6_interface_delete (struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000154{
paul1eb8ef22005-04-07 07:30:20 +0000155 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000156 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000157
paul1eb8ef22005-04-07 07:30:20 +0000158 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000159 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000160
hasso508e53e2004-05-18 18:57:06 +0000161 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000162
hasso508e53e2004-05-18 18:57:06 +0000163 THREAD_OFF (oi->thread_send_hello);
164 THREAD_OFF (oi->thread_send_lsupdate);
165 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000166
hasso508e53e2004-05-18 18:57:06 +0000167 ospf6_lsdb_remove_all (oi->lsdb);
168 ospf6_lsdb_remove_all (oi->lsupdate_list);
169 ospf6_lsdb_remove_all (oi->lsack_list);
170
171 ospf6_lsdb_delete (oi->lsdb);
hasso6452df02004-08-15 05:52:07 +0000172 ospf6_lsdb_delete (oi->lsdb_self);
173
hasso508e53e2004-05-18 18:57:06 +0000174 ospf6_lsdb_delete (oi->lsupdate_list);
175 ospf6_lsdb_delete (oi->lsack_list);
176
177 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000178
179 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000180 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000181
182 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000183 if (oi->plist_name)
184 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000185
hasso508e53e2004-05-18 18:57:06 +0000186 XFREE (MTYPE_OSPF6_IF, oi);
187}
188
189void
190ospf6_interface_enable (struct ospf6_interface *oi)
191{
192 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
193
194 oi->thread_send_hello =
195 thread_add_event (master, ospf6_hello_send, oi, 0);
196}
197
198void
199ospf6_interface_disable (struct ospf6_interface *oi)
200{
paul1eb8ef22005-04-07 07:30:20 +0000201 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000202 struct ospf6_neighbor *on;
203
204 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
205
paul1eb8ef22005-04-07 07:30:20 +0000206 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000207 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000208
hasso508e53e2004-05-18 18:57:06 +0000209 list_delete_all_node (oi->neighbor_list);
210
211 ospf6_lsdb_remove_all (oi->lsdb);
212 ospf6_lsdb_remove_all (oi->lsupdate_list);
213 ospf6_lsdb_remove_all (oi->lsack_list);
214
215 THREAD_OFF (oi->thread_send_hello);
216 THREAD_OFF (oi->thread_send_lsupdate);
217 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000218}
219
220static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000221ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000222{
hasso52dc7ee2004-09-23 19:18:23 +0000223 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000224 struct connected *c;
225 struct in6_addr *l = (struct in6_addr *) NULL;
226
227 /* for each connected address */
paul1eb8ef22005-04-07 07:30:20 +0000228 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
paul718e3742002-12-13 20:15:29 +0000229 {
paul718e3742002-12-13 20:15:29 +0000230 /* if family not AF_INET6, ignore */
231 if (c->address->family != AF_INET6)
232 continue;
233
234 /* linklocal scope check */
235 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
236 l = &c->address->u.prefix6;
237 }
238 return l;
239}
240
241void
242ospf6_interface_if_add (struct interface *ifp)
243{
hasso508e53e2004-05-18 18:57:06 +0000244 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000245 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000246
hasso508e53e2004-05-18 18:57:06 +0000247 oi = (struct ospf6_interface *) ifp->info;
248 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000249 return;
250
hassob596c712004-07-09 18:33:43 +0000251 /* Try to adjust I/O buffer size with IfMtu */
252 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000253 oi->ifmtu = ifp->mtu6;
254 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000255 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000256 {
hasso1e058382004-09-01 21:36:14 +0000257 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000258 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
259 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000260 oi->ifmtu = iobuflen;
261 }
paul718e3742002-12-13 20:15:29 +0000262
263 /* interface start */
hasso508e53e2004-05-18 18:57:06 +0000264 if (oi->area)
265 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000266}
267
268void
269ospf6_interface_if_del (struct interface *ifp)
270{
hasso508e53e2004-05-18 18:57:06 +0000271 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000272
hasso508e53e2004-05-18 18:57:06 +0000273 oi = (struct ospf6_interface *) ifp->info;
274 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000275 return;
276
277 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000278 if (oi->area)
279 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000280
hasso508e53e2004-05-18 18:57:06 +0000281 listnode_delete (oi->area->if_list, oi);
282 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000283
284 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000285 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000286 ifp->info = NULL;
287
hasso508e53e2004-05-18 18:57:06 +0000288 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000289}
290
291void
292ospf6_interface_state_update (struct interface *ifp)
293{
hasso508e53e2004-05-18 18:57:06 +0000294 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000295
hasso508e53e2004-05-18 18:57:06 +0000296 oi = (struct ospf6_interface *) ifp->info;
297 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000298 return;
hasso508e53e2004-05-18 18:57:06 +0000299 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000300 return;
301
302 if (if_is_up (ifp))
hasso508e53e2004-05-18 18:57:06 +0000303 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000304 else
hasso508e53e2004-05-18 18:57:06 +0000305 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000306
307 return;
308}
309
310void
hasso508e53e2004-05-18 18:57:06 +0000311ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000312{
hasso508e53e2004-05-18 18:57:06 +0000313 struct ospf6_interface *oi;
314 struct ospf6_route *route;
315 struct connected *c;
paul1eb8ef22005-04-07 07:30:20 +0000316 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +0000317
hasso508e53e2004-05-18 18:57:06 +0000318 oi = (struct ospf6_interface *) ifp->info;
319 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000320 return;
321
322 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000323 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000324
hasso508e53e2004-05-18 18:57:06 +0000325 /* if area is null, do not make connected-route list */
326 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000327 return;
328
hasso508e53e2004-05-18 18:57:06 +0000329 /* update "route to advertise" interface route table */
330 ospf6_route_remove_all (oi->route_connected);
hasso508e53e2004-05-18 18:57:06 +0000331
paul1eb8ef22005-04-07 07:30:20 +0000332 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
333 {
hasso508e53e2004-05-18 18:57:06 +0000334 if (c->address->family != AF_INET6)
335 continue;
336
hasso1e058382004-09-01 21:36:14 +0000337 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
338 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
339 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
340 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
341 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000342
343 /* apply filter */
344 if (oi->plist_name)
345 {
346 struct prefix_list *plist;
347 enum prefix_list_type ret;
348 char buf[128];
349
350 prefix2str (c->address, buf, sizeof (buf));
351 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
352 ret = prefix_list_apply (plist, (void *) c->address);
353 if (ret == PREFIX_DENY)
354 {
hasso1e058382004-09-01 21:36:14 +0000355 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000356 zlog_debug ("%s on %s filtered by prefix-list %s ",
357 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000358 continue;
359 }
360 }
361
362 route = ospf6_route_create ();
363 memcpy (&route->prefix, c->address, sizeof (struct prefix));
364 apply_mask (&route->prefix);
365 route->type = OSPF6_DEST_TYPE_NETWORK;
366 route->path.area_id = oi->area->area_id;
367 route->path.type = OSPF6_PATH_TYPE_INTRA;
368 route->path.cost = oi->cost;
369 route->nexthop[0].ifindex = oi->interface->ifindex;
370 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
371 ospf6_route_add (route, oi->route_connected);
372 }
373
paul718e3742002-12-13 20:15:29 +0000374 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000375 OSPF6_LINK_LSA_SCHEDULE (oi);
376 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
377 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000378}
379
hasso508e53e2004-05-18 18:57:06 +0000380static void
381ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000382{
hasso508e53e2004-05-18 18:57:06 +0000383 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000384
hasso508e53e2004-05-18 18:57:06 +0000385 prev_state = oi->state;
386 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000387
hasso508e53e2004-05-18 18:57:06 +0000388 if (prev_state == next_state)
389 return;
paul718e3742002-12-13 20:15:29 +0000390
hasso508e53e2004-05-18 18:57:06 +0000391 /* log */
392 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000393 {
hassoc6487d62004-12-24 06:00:11 +0000394 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
395 ospf6_interface_state_str[prev_state],
396 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000397 }
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))
403 ospf6_leave_alldrouters (oi->interface->ifindex);
404 if ((prev_state != OSPF6_INTERFACE_DR &&
405 prev_state != OSPF6_INTERFACE_BDR) &&
406 (next_state == OSPF6_INTERFACE_DR ||
407 next_state == OSPF6_INTERFACE_BDR))
408 ospf6_join_alldrouters (oi->interface->ifindex);
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 */
616 ospf6_join_allspfrouters (oi->interface->ifindex);
617
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
696loopind (struct thread *thread)
697{
698 struct ospf6_interface *oi;
699
700 oi = (struct ospf6_interface *) THREAD_ARG (thread);
701 assert (oi && oi->interface);
702
703 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000704 zlog_debug ("Interface Event %s: [LoopInd]",
705 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000706
707 /* XXX not yet */
708
709 return 0;
710}
711
712int
713interface_down (struct thread *thread)
714{
715 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000716 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000717 struct ospf6_neighbor *on;
718
719 oi = (struct ospf6_interface *) THREAD_ARG (thread);
720 assert (oi && oi->interface);
721
722 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000723 zlog_debug ("Interface Event %s: [InterfaceDown]",
724 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000725
726 /* Leave AllSPFRouters */
727 if (oi->state > OSPF6_INTERFACE_DOWN)
728 ospf6_leave_allspfrouters (oi->interface->ifindex);
729
730 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
731
paul1eb8ef22005-04-07 07:30:20 +0000732 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
733 ospf6_neighbor_delete (on);
734
hasso508e53e2004-05-18 18:57:06 +0000735 list_delete_all_node (oi->neighbor_list);
736
737 return 0;
738}
739
740
paul718e3742002-12-13 20:15:29 +0000741/* show specified interface structure */
742int
hasso508e53e2004-05-18 18:57:06 +0000743ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000744{
hasso508e53e2004-05-18 18:57:06 +0000745 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000746 struct connected *c;
747 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000748 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000749 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000750 const char *updown[3] = {"down", "up", NULL};
751 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000752 struct timeval res, now;
753 char duration[32];
754 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000755
756 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000757 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000758 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000759 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000760 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000761 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000762 type = "POINTOPOINT";
763 else
764 type = "UNKNOWN";
765
766 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000767 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000768 VNL);
769 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000770
hasso508e53e2004-05-18 18:57:06 +0000771 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000772 {
hasso049207c2004-08-04 20:02:13 +0000773 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000774 return 0;
775 }
776 else
hasso508e53e2004-05-18 18:57:06 +0000777 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000778
hasso049207c2004-08-04 20:02:13 +0000779 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000780
781 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000782 {
paul718e3742002-12-13 20:15:29 +0000783 p = c->address;
784 prefix2str (p, strbuf, sizeof (strbuf));
785 switch (p->family)
786 {
787 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000788 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000789 VNL);
paul718e3742002-12-13 20:15:29 +0000790 break;
791 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000792 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000793 VNL);
paul718e3742002-12-13 20:15:29 +0000794 break;
795 default:
hasso508e53e2004-05-18 18:57:06 +0000796 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000797 VNL);
paul718e3742002-12-13 20:15:29 +0000798 break;
799 }
800 }
801
hasso508e53e2004-05-18 18:57:06 +0000802 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000803 {
hasso508e53e2004-05-18 18:57:06 +0000804 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000805 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
hasso508e53e2004-05-18 18:57:06 +0000806 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000807 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000808 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000809 VNL);
paul718e3742002-12-13 20:15:29 +0000810 }
811 else
hasso049207c2004-08-04 20:02:13 +0000812 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000813
814 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000815 ospf6_interface_state_str[oi->state],
816 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000817 VNL);
818 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000819 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000820 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000821 VNL);
paul718e3742002-12-13 20:15:29 +0000822
hasso508e53e2004-05-18 18:57:06 +0000823 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
824 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000825 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000826
827 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000828 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000829
830 gettimeofday (&now, (struct timezone *) NULL);
paul718e3742002-12-13 20:15:29 +0000831
hasso508e53e2004-05-18 18:57:06 +0000832 timerclear (&res);
833 if (oi->thread_send_lsupdate)
834 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
835 timerstring (&res, duration, sizeof (duration));
836 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
837 oi->lsupdate_list->count, duration,
838 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000839 VNL);
hasso508e53e2004-05-18 18:57:06 +0000840 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
841 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000842 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000843
hasso508e53e2004-05-18 18:57:06 +0000844 timerclear (&res);
845 if (oi->thread_send_lsack)
846 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
847 timerstring (&res, duration, sizeof (duration));
848 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
849 oi->lsack_list->count, duration,
850 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000851 VNL);
hasso508e53e2004-05-18 18:57:06 +0000852 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
853 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000854 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000855
hasso508e53e2004-05-18 18:57:06 +0000856 return 0;
paul718e3742002-12-13 20:15:29 +0000857}
858
859/* show interface */
860DEFUN (show_ipv6_ospf6_interface,
861 show_ipv6_ospf6_interface_ifname_cmd,
862 "show ipv6 ospf6 interface IFNAME",
863 SHOW_STR
864 IP6_STR
865 OSPF6_STR
866 INTERFACE_STR
867 IFNAME_STR
868 )
869{
870 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000871 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000872
873 if (argc)
874 {
875 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000876 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000877 {
878 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000879 VNL);
paul718e3742002-12-13 20:15:29 +0000880 return CMD_WARNING;
881 }
882 ospf6_interface_show (vty, ifp);
883 }
884 else
885 {
paul1eb8ef22005-04-07 07:30:20 +0000886 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
887 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000888 }
hasso508e53e2004-05-18 18:57:06 +0000889
paul718e3742002-12-13 20:15:29 +0000890 return CMD_SUCCESS;
891}
892
893ALIAS (show_ipv6_ospf6_interface,
894 show_ipv6_ospf6_interface_cmd,
895 "show ipv6 ospf6 interface",
896 SHOW_STR
897 IP6_STR
898 OSPF6_STR
899 INTERFACE_STR
hasso508e53e2004-05-18 18:57:06 +0000900 );
paul718e3742002-12-13 20:15:29 +0000901
hasso508e53e2004-05-18 18:57:06 +0000902DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
903 show_ipv6_ospf6_interface_ifname_prefix_cmd,
904 "show ipv6 ospf6 interface IFNAME prefix",
905 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000906 IP6_STR
907 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000908 INTERFACE_STR
909 IFNAME_STR
910 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000911 )
912{
paul718e3742002-12-13 20:15:29 +0000913 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000914 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000915
hasso508e53e2004-05-18 18:57:06 +0000916 ifp = if_lookup_by_name (argv[0]);
917 if (ifp == NULL)
918 {
hasso049207c2004-08-04 20:02:13 +0000919 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000920 return CMD_WARNING;
921 }
paul718e3742002-12-13 20:15:29 +0000922
hasso508e53e2004-05-18 18:57:06 +0000923 oi = ifp->info;
924 if (oi == NULL)
925 {
hasso049207c2004-08-04 20:02:13 +0000926 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000927 return CMD_WARNING;
928 }
paul718e3742002-12-13 20:15:29 +0000929
hasso508e53e2004-05-18 18:57:06 +0000930 argc--;
931 argv++;
932 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000933
934 return CMD_SUCCESS;
935}
936
hasso508e53e2004-05-18 18:57:06 +0000937ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
938 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
939 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
940 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000941 IP6_STR
942 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000943 INTERFACE_STR
944 IFNAME_STR
945 "Display connected prefixes to advertise\n"
946 OSPF6_ROUTE_ADDRESS_STR
947 OSPF6_ROUTE_PREFIX_STR
948 "Dispaly details of the prefixes\n"
949 );
950
951ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
952 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
953 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
954 SHOW_STR
955 IP6_STR
956 OSPF6_STR
957 INTERFACE_STR
958 IFNAME_STR
959 "Display connected prefixes to advertise\n"
960 OSPF6_ROUTE_PREFIX_STR
961 OSPF6_ROUTE_MATCH_STR
962 "Dispaly details of the prefixes\n"
963 );
964
965DEFUN (show_ipv6_ospf6_interface_prefix,
966 show_ipv6_ospf6_interface_prefix_cmd,
967 "show ipv6 ospf6 interface prefix",
968 SHOW_STR
969 IP6_STR
970 OSPF6_STR
971 INTERFACE_STR
972 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000973 )
974{
hasso52dc7ee2004-09-23 19:18:23 +0000975 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000976 struct ospf6_interface *oi;
977 struct interface *ifp;
978
paul1eb8ef22005-04-07 07:30:20 +0000979 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +0000980 {
hasso508e53e2004-05-18 18:57:06 +0000981 oi = (struct ospf6_interface *) ifp->info;
982 if (oi == NULL)
983 continue;
984
985 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
986 }
987
988 return CMD_SUCCESS;
989}
990
991ALIAS (show_ipv6_ospf6_interface_prefix,
992 show_ipv6_ospf6_interface_prefix_detail_cmd,
993 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
994 SHOW_STR
995 IP6_STR
996 OSPF6_STR
997 INTERFACE_STR
998 "Display connected prefixes to advertise\n"
999 OSPF6_ROUTE_ADDRESS_STR
1000 OSPF6_ROUTE_PREFIX_STR
1001 "Dispaly details of the prefixes\n"
1002 );
1003
1004ALIAS (show_ipv6_ospf6_interface_prefix,
1005 show_ipv6_ospf6_interface_prefix_match_cmd,
1006 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1007 SHOW_STR
1008 IP6_STR
1009 OSPF6_STR
1010 INTERFACE_STR
1011 "Display connected prefixes to advertise\n"
1012 OSPF6_ROUTE_PREFIX_STR
1013 OSPF6_ROUTE_MATCH_STR
1014 "Dispaly details of the prefixes\n"
1015 );
1016
1017
1018/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001019DEFUN (ipv6_ospf6_ifmtu,
1020 ipv6_ospf6_ifmtu_cmd,
1021 "ipv6 ospf6 ifmtu <1-65535>",
1022 IP6_STR
1023 OSPF6_STR
1024 "Interface MTU\n"
1025 "OSPFv3 Interface MTU\n"
1026 )
1027{
1028 struct ospf6_interface *oi;
1029 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001030 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001031 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001032 struct ospf6_neighbor *on;
1033
1034 ifp = (struct interface *) vty->index;
1035 assert (ifp);
1036
1037 oi = (struct ospf6_interface *) ifp->info;
1038 if (oi == NULL)
1039 oi = ospf6_interface_create (ifp);
1040 assert (oi);
1041
1042 ifmtu = strtol (argv[0], NULL, 10);
1043
1044 if (oi->ifmtu == ifmtu)
1045 return CMD_SUCCESS;
1046
hasso1203e1c2004-07-23 21:34:27 +00001047 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001048 {
1049 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001050 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001051 return CMD_WARNING;
1052 }
1053
1054 if (oi->ifmtu < ifmtu)
1055 {
1056 iobuflen = ospf6_iobuf_size (ifmtu);
1057 if (iobuflen < ifmtu)
1058 {
1059 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001060 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001061 oi->ifmtu = iobuflen;
1062 }
1063 else
1064 oi->ifmtu = ifmtu;
1065 }
1066 else
1067 oi->ifmtu = ifmtu;
1068
1069 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001070 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001071 {
hassob596c712004-07-09 18:33:43 +00001072 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001073 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001074 }
1075
1076 return CMD_SUCCESS;
1077}
1078
hasso049207c2004-08-04 20:02:13 +00001079DEFUN (no_ipv6_ospf6_ifmtu,
1080 no_ipv6_ospf6_ifmtu_cmd,
1081 "no ipv6 ospf6 ifmtu",
1082 NO_STR
1083 IP6_STR
1084 OSPF6_STR
1085 "Interface MTU\n"
1086 )
1087{
1088 struct ospf6_interface *oi;
1089 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001090 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001091 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001092 struct ospf6_neighbor *on;
1093
1094 ifp = (struct interface *) vty->index;
1095 assert (ifp);
1096
1097 oi = (struct ospf6_interface *) ifp->info;
1098 if (oi == NULL)
1099 oi = ospf6_interface_create (ifp);
1100 assert (oi);
1101
1102 if (oi->ifmtu < ifp->mtu)
1103 {
1104 iobuflen = ospf6_iobuf_size (ifp->mtu);
1105 if (iobuflen < ifp->mtu)
1106 {
1107 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1108 ifp->name, iobuflen, VNL);
1109 oi->ifmtu = iobuflen;
1110 }
1111 else
1112 oi->ifmtu = ifp->mtu;
1113 }
1114 else
1115 oi->ifmtu = ifp->mtu;
1116
1117 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001118 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001119 {
hasso049207c2004-08-04 20:02:13 +00001120 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001121 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001122 }
1123
1124 return CMD_SUCCESS;
1125}
1126
hasso508e53e2004-05-18 18:57:06 +00001127DEFUN (ipv6_ospf6_cost,
1128 ipv6_ospf6_cost_cmd,
1129 "ipv6 ospf6 cost <1-65535>",
1130 IP6_STR
1131 OSPF6_STR
1132 "Interface cost\n"
1133 "Outgoing metric of this interface\n"
1134 )
1135{
1136 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001137 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001138 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001139
1140 ifp = (struct interface *) vty->index;
1141 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001142
hasso508e53e2004-05-18 18:57:06 +00001143 oi = (struct ospf6_interface *) ifp->info;
1144 if (oi == NULL)
1145 oi = ospf6_interface_create (ifp);
1146 assert (oi);
1147
paul0c083ee2004-10-10 12:54:58 +00001148 lcost = strtol (argv[0], NULL, 10);
1149
1150 if (lcost > UINT32_MAX)
1151 {
1152 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1153 return CMD_WARNING;
1154 }
1155
1156 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001157 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001158
1159 oi->cost = lcost;
1160
hasso508e53e2004-05-18 18:57:06 +00001161 /* update cost held in route_connected list in ospf6_interface */
1162 ospf6_interface_connected_route_update (oi->interface);
1163
1164 /* execute LSA hooks */
1165 if (oi->area)
1166 {
1167 OSPF6_LINK_LSA_SCHEDULE (oi);
1168 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1169 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1170 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1171 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1172 }
1173
1174 return CMD_SUCCESS;
1175}
1176
1177DEFUN (ipv6_ospf6_hellointerval,
1178 ipv6_ospf6_hellointerval_cmd,
1179 "ipv6 ospf6 hello-interval <1-65535>",
1180 IP6_STR
1181 OSPF6_STR
1182 "Interval time of Hello packets\n"
1183 SECONDS_STR
1184 )
1185{
1186 struct ospf6_interface *oi;
1187 struct interface *ifp;
1188
1189 ifp = (struct interface *) vty->index;
1190 assert (ifp);
1191
1192 oi = (struct ospf6_interface *) ifp->info;
1193 if (oi == NULL)
1194 oi = ospf6_interface_create (ifp);
1195 assert (oi);
1196
1197 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001198 return CMD_SUCCESS;
1199}
1200
1201/* interface variable set command */
1202DEFUN (ipv6_ospf6_deadinterval,
1203 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001204 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001205 IP6_STR
1206 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001207 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001208 SECONDS_STR
1209 )
1210{
hasso508e53e2004-05-18 18:57:06 +00001211 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001212 struct interface *ifp;
1213
1214 ifp = (struct interface *) vty->index;
1215 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001216
hasso508e53e2004-05-18 18:57:06 +00001217 oi = (struct ospf6_interface *) ifp->info;
1218 if (oi == NULL)
1219 oi = ospf6_interface_create (ifp);
1220 assert (oi);
1221
1222 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001223 return CMD_SUCCESS;
1224}
1225
1226/* interface variable set command */
1227DEFUN (ipv6_ospf6_transmitdelay,
1228 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001229 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001230 IP6_STR
1231 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001232 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001233 SECONDS_STR
1234 )
1235{
hasso508e53e2004-05-18 18:57:06 +00001236 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001237 struct interface *ifp;
1238
1239 ifp = (struct interface *) vty->index;
1240 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001241
hasso508e53e2004-05-18 18:57:06 +00001242 oi = (struct ospf6_interface *) ifp->info;
1243 if (oi == NULL)
1244 oi = ospf6_interface_create (ifp);
1245 assert (oi);
1246
1247 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001248 return CMD_SUCCESS;
1249}
1250
1251/* interface variable set command */
1252DEFUN (ipv6_ospf6_retransmitinterval,
1253 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001254 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001255 IP6_STR
1256 OSPF6_STR
1257 "Time between retransmitting lost link state advertisements\n"
1258 SECONDS_STR
1259 )
1260{
hasso508e53e2004-05-18 18:57:06 +00001261 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001262 struct interface *ifp;
1263
1264 ifp = (struct interface *) vty->index;
1265 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001266
hasso508e53e2004-05-18 18:57:06 +00001267 oi = (struct ospf6_interface *) ifp->info;
1268 if (oi == NULL)
1269 oi = ospf6_interface_create (ifp);
1270 assert (oi);
1271
1272 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001273 return CMD_SUCCESS;
1274}
1275
1276/* interface variable set command */
1277DEFUN (ipv6_ospf6_priority,
1278 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001279 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001280 IP6_STR
1281 OSPF6_STR
1282 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001283 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001284 )
1285{
hasso508e53e2004-05-18 18:57:06 +00001286 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001287 struct interface *ifp;
1288
1289 ifp = (struct interface *) vty->index;
1290 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001291
hasso508e53e2004-05-18 18:57:06 +00001292 oi = (struct ospf6_interface *) ifp->info;
1293 if (oi == NULL)
1294 oi = ospf6_interface_create (ifp);
1295 assert (oi);
paul718e3742002-12-13 20:15:29 +00001296
hasso508e53e2004-05-18 18:57:06 +00001297 oi->priority = strtol (argv[0], NULL, 10);
1298
1299 if (oi->area)
1300 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001301
1302 return CMD_SUCCESS;
1303}
1304
1305DEFUN (ipv6_ospf6_instance,
1306 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001307 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001308 IP6_STR
1309 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001310 "Instance ID for this interface\n"
1311 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001312 )
1313{
hasso508e53e2004-05-18 18:57:06 +00001314 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001315 struct interface *ifp;
1316
1317 ifp = (struct interface *)vty->index;
1318 assert (ifp);
1319
hasso508e53e2004-05-18 18:57:06 +00001320 oi = (struct ospf6_interface *)ifp->info;
1321 if (oi == NULL)
1322 oi = ospf6_interface_create (ifp);
1323 assert (oi);
paul718e3742002-12-13 20:15:29 +00001324
hasso508e53e2004-05-18 18:57:06 +00001325 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001326 return CMD_SUCCESS;
1327}
1328
1329DEFUN (ipv6_ospf6_passive,
1330 ipv6_ospf6_passive_cmd,
1331 "ipv6 ospf6 passive",
1332 IP6_STR
1333 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001334 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001335 )
1336{
hasso508e53e2004-05-18 18:57:06 +00001337 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001338 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001339 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001340 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001341
1342 ifp = (struct interface *) vty->index;
1343 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001344
hasso508e53e2004-05-18 18:57:06 +00001345 oi = (struct ospf6_interface *) ifp->info;
1346 if (oi == NULL)
1347 oi = ospf6_interface_create (ifp);
1348 assert (oi);
paul718e3742002-12-13 20:15:29 +00001349
hasso508e53e2004-05-18 18:57:06 +00001350 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1351 THREAD_OFF (oi->thread_send_hello);
1352
paul1eb8ef22005-04-07 07:30:20 +00001353 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001354 {
hasso508e53e2004-05-18 18:57:06 +00001355 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001356 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001357 }
1358
1359 return CMD_SUCCESS;
1360}
1361
1362DEFUN (no_ipv6_ospf6_passive,
1363 no_ipv6_ospf6_passive_cmd,
1364 "no ipv6 ospf6 passive",
1365 NO_STR
1366 IP6_STR
1367 OSPF6_STR
1368 "passive interface: No Adjacency will be formed on this I/F\n"
1369 )
1370{
hasso508e53e2004-05-18 18:57:06 +00001371 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001372 struct interface *ifp;
1373
1374 ifp = (struct interface *) vty->index;
1375 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001376
hasso508e53e2004-05-18 18:57:06 +00001377 oi = (struct ospf6_interface *) ifp->info;
1378 if (oi == NULL)
1379 oi = ospf6_interface_create (ifp);
1380 assert (oi);
paul718e3742002-12-13 20:15:29 +00001381
hasso508e53e2004-05-18 18:57:06 +00001382 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1383 THREAD_OFF (oi->thread_send_hello);
1384 oi->thread_send_hello =
1385 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001386
1387 return CMD_SUCCESS;
1388}
1389
1390DEFUN (ipv6_ospf6_advertise_prefix_list,
1391 ipv6_ospf6_advertise_prefix_list_cmd,
1392 "ipv6 ospf6 advertise prefix-list WORD",
1393 IP6_STR
1394 OSPF6_STR
1395 "Advertising options\n"
1396 "Filter prefix using prefix-list\n"
1397 "Prefix list name\n"
1398 )
1399{
hasso508e53e2004-05-18 18:57:06 +00001400 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001401 struct interface *ifp;
1402
1403 ifp = (struct interface *) vty->index;
1404 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001405
hasso508e53e2004-05-18 18:57:06 +00001406 oi = (struct ospf6_interface *) ifp->info;
1407 if (oi == NULL)
1408 oi = ospf6_interface_create (ifp);
1409 assert (oi);
paul718e3742002-12-13 20:15:29 +00001410
hasso508e53e2004-05-18 18:57:06 +00001411 if (oi->plist_name)
1412 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1413 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001414
hasso508e53e2004-05-18 18:57:06 +00001415 ospf6_interface_connected_route_update (oi->interface);
1416 OSPF6_LINK_LSA_SCHEDULE (oi);
1417 if (oi->state == OSPF6_INTERFACE_DR)
1418 {
1419 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1420 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1421 }
1422 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001423
1424 return CMD_SUCCESS;
1425}
1426
1427DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1428 no_ipv6_ospf6_advertise_prefix_list_cmd,
1429 "no ipv6 ospf6 advertise prefix-list",
1430 NO_STR
1431 IP6_STR
1432 OSPF6_STR
1433 "Advertising options\n"
1434 "Filter prefix using prefix-list\n"
1435 )
1436{
hasso508e53e2004-05-18 18:57:06 +00001437 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001438 struct interface *ifp;
1439
1440 ifp = (struct interface *) vty->index;
1441 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001442
hasso508e53e2004-05-18 18:57:06 +00001443 oi = (struct ospf6_interface *) ifp->info;
1444 if (oi == NULL)
1445 oi = ospf6_interface_create (ifp);
1446 assert (oi);
1447
1448 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001449 {
hasso508e53e2004-05-18 18:57:06 +00001450 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1451 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001452 }
1453
hasso508e53e2004-05-18 18:57:06 +00001454 ospf6_interface_connected_route_update (oi->interface);
1455 OSPF6_LINK_LSA_SCHEDULE (oi);
1456 if (oi->state == OSPF6_INTERFACE_DR)
1457 {
1458 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1459 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1460 }
1461 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001462
1463 return CMD_SUCCESS;
1464}
1465
1466int
hasso508e53e2004-05-18 18:57:06 +00001467config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001468{
hasso52dc7ee2004-09-23 19:18:23 +00001469 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001470 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001471 struct interface *ifp;
1472
paul1eb8ef22005-04-07 07:30:20 +00001473 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001474 {
hasso508e53e2004-05-18 18:57:06 +00001475 oi = (struct ospf6_interface *) ifp->info;
1476 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001477 continue;
1478
1479 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001480 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001481
1482 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001483 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso508e53e2004-05-18 18:57:06 +00001484
hasso1203e1c2004-07-23 21:34:27 +00001485 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001486 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
paul718e3742002-12-13 20:15:29 +00001487 vty_out (vty, " ipv6 ospf6 cost %d%s",
hasso049207c2004-08-04 20:02:13 +00001488 oi->cost, VNL);
paul718e3742002-12-13 20:15:29 +00001489 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001490 oi->hello_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001491 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001492 oi->dead_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001493 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001494 oi->rxmt_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001495 vty_out (vty, " ipv6 ospf6 priority %d%s",
hasso049207c2004-08-04 20:02:13 +00001496 oi->priority, VNL);
paul718e3742002-12-13 20:15:29 +00001497 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
hasso049207c2004-08-04 20:02:13 +00001498 oi->transdelay, VNL);
paul718e3742002-12-13 20:15:29 +00001499 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
hasso049207c2004-08-04 20:02:13 +00001500 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001501
hasso508e53e2004-05-18 18:57:06 +00001502 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001503 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001504 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001505
hasso508e53e2004-05-18 18:57:06 +00001506 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001507 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001508
hasso049207c2004-08-04 20:02:13 +00001509 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001510 }
1511 return 0;
1512}
1513
1514struct cmd_node interface_node =
1515{
1516 INTERFACE_NODE,
1517 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001518 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001519};
1520
1521void
1522ospf6_interface_init ()
1523{
1524 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001525 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001526
1527 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001528 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1529 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1530 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001531 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001532 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1533 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1534 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001535 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001536 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1537 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1538 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001539 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001540 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1541 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1542 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001543
hasso508e53e2004-05-18 18:57:06 +00001544 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001545 install_default (INTERFACE_NODE);
1546 install_element (INTERFACE_NODE, &interface_desc_cmd);
1547 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1548 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001549 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001550 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001551 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1552 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1553 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1554 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1555 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1556 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001557
paul718e3742002-12-13 20:15:29 +00001558 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1559 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001560
1561 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1562 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1563}
1564
1565DEFUN (debug_ospf6_interface,
1566 debug_ospf6_interface_cmd,
1567 "debug ospf6 interface",
1568 DEBUG_STR
1569 OSPF6_STR
1570 "Debug OSPFv3 Interface\n"
1571 )
1572{
1573 OSPF6_DEBUG_INTERFACE_ON ();
1574 return CMD_SUCCESS;
1575}
1576
1577DEFUN (no_debug_ospf6_interface,
1578 no_debug_ospf6_interface_cmd,
1579 "no debug ospf6 interface",
1580 NO_STR
1581 DEBUG_STR
1582 OSPF6_STR
1583 "Debug OSPFv3 Interface\n"
1584 )
1585{
hasso3b687352004-08-19 06:56:53 +00001586 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001587 return CMD_SUCCESS;
1588}
1589
1590int
1591config_write_ospf6_debug_interface (struct vty *vty)
1592{
1593 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001594 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001595 return 0;
1596}
1597
1598void
1599install_element_ospf6_debug_interface ()
1600{
1601 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1602 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1603 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1604 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001605}
1606
1607