blob: 3ca5e2d1e64af22ead5881cdf273be83091ddfd0 [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
hasso508e53e2004-05-18 18:57:06 +0000142 oi->route_connected = ospf6_route_table_create ();
paul718e3742002-12-13 20:15:29 +0000143
144 /* link both */
hasso508e53e2004-05-18 18:57:06 +0000145 oi->interface = ifp;
146 ifp->info = oi;
paul718e3742002-12-13 20:15:29 +0000147
hasso508e53e2004-05-18 18:57:06 +0000148 return oi;
paul718e3742002-12-13 20:15:29 +0000149}
150
151void
hasso508e53e2004-05-18 18:57:06 +0000152ospf6_interface_delete (struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000153{
paul1eb8ef22005-04-07 07:30:20 +0000154 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000155 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000156
paul1eb8ef22005-04-07 07:30:20 +0000157 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000158 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000159
hasso508e53e2004-05-18 18:57:06 +0000160 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000161
hasso508e53e2004-05-18 18:57:06 +0000162 THREAD_OFF (oi->thread_send_hello);
163 THREAD_OFF (oi->thread_send_lsupdate);
164 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000165
hasso508e53e2004-05-18 18:57:06 +0000166 ospf6_lsdb_remove_all (oi->lsdb);
167 ospf6_lsdb_remove_all (oi->lsupdate_list);
168 ospf6_lsdb_remove_all (oi->lsack_list);
169
170 ospf6_lsdb_delete (oi->lsdb);
hasso6452df02004-08-15 05:52:07 +0000171 ospf6_lsdb_delete (oi->lsdb_self);
172
hasso508e53e2004-05-18 18:57:06 +0000173 ospf6_lsdb_delete (oi->lsupdate_list);
174 ospf6_lsdb_delete (oi->lsack_list);
175
176 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000177
178 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000179 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000180
181 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000182 if (oi->plist_name)
183 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000184
hasso508e53e2004-05-18 18:57:06 +0000185 XFREE (MTYPE_OSPF6_IF, oi);
186}
187
188void
189ospf6_interface_enable (struct ospf6_interface *oi)
190{
191 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
192
193 oi->thread_send_hello =
194 thread_add_event (master, ospf6_hello_send, oi, 0);
195}
196
197void
198ospf6_interface_disable (struct ospf6_interface *oi)
199{
paul1eb8ef22005-04-07 07:30:20 +0000200 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000201 struct ospf6_neighbor *on;
202
203 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
204
paul1eb8ef22005-04-07 07:30:20 +0000205 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000206 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000207
hasso508e53e2004-05-18 18:57:06 +0000208 list_delete_all_node (oi->neighbor_list);
209
210 ospf6_lsdb_remove_all (oi->lsdb);
211 ospf6_lsdb_remove_all (oi->lsupdate_list);
212 ospf6_lsdb_remove_all (oi->lsack_list);
213
214 THREAD_OFF (oi->thread_send_hello);
215 THREAD_OFF (oi->thread_send_lsupdate);
216 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000217}
218
219static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000220ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000221{
hasso52dc7ee2004-09-23 19:18:23 +0000222 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000223 struct connected *c;
224 struct in6_addr *l = (struct in6_addr *) NULL;
225
226 /* for each connected address */
paul1eb8ef22005-04-07 07:30:20 +0000227 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
paul718e3742002-12-13 20:15:29 +0000228 {
paul718e3742002-12-13 20:15:29 +0000229 /* if family not AF_INET6, ignore */
230 if (c->address->family != AF_INET6)
231 continue;
232
233 /* linklocal scope check */
234 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
235 l = &c->address->u.prefix6;
236 }
237 return l;
238}
239
240void
241ospf6_interface_if_add (struct interface *ifp)
242{
hasso508e53e2004-05-18 18:57:06 +0000243 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000244 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000245
hasso508e53e2004-05-18 18:57:06 +0000246 oi = (struct ospf6_interface *) ifp->info;
247 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000248 return;
249
hassob596c712004-07-09 18:33:43 +0000250 /* Try to adjust I/O buffer size with IfMtu */
251 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000252 oi->ifmtu = ifp->mtu6;
253 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000254 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000255 {
hasso1e058382004-09-01 21:36:14 +0000256 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000257 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
258 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000259 oi->ifmtu = iobuflen;
260 }
paul718e3742002-12-13 20:15:29 +0000261
262 /* interface start */
hasso508e53e2004-05-18 18:57:06 +0000263 if (oi->area)
264 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000265}
266
267void
268ospf6_interface_if_del (struct interface *ifp)
269{
hasso508e53e2004-05-18 18:57:06 +0000270 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000271
hasso508e53e2004-05-18 18:57:06 +0000272 oi = (struct ospf6_interface *) ifp->info;
273 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000274 return;
275
276 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000277 if (oi->area)
278 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000279
hasso508e53e2004-05-18 18:57:06 +0000280 listnode_delete (oi->area->if_list, oi);
281 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000282
283 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000284 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000285 ifp->info = NULL;
286
hasso508e53e2004-05-18 18:57:06 +0000287 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000288}
289
290void
291ospf6_interface_state_update (struct interface *ifp)
292{
hasso508e53e2004-05-18 18:57:06 +0000293 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000294
hasso508e53e2004-05-18 18:57:06 +0000295 oi = (struct ospf6_interface *) ifp->info;
296 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000297 return;
hasso508e53e2004-05-18 18:57:06 +0000298 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000299 return;
300
301 if (if_is_up (ifp))
hasso508e53e2004-05-18 18:57:06 +0000302 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000303 else
hasso508e53e2004-05-18 18:57:06 +0000304 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000305
306 return;
307}
308
309void
hasso508e53e2004-05-18 18:57:06 +0000310ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000311{
hasso508e53e2004-05-18 18:57:06 +0000312 struct ospf6_interface *oi;
313 struct ospf6_route *route;
314 struct connected *c;
paul1eb8ef22005-04-07 07:30:20 +0000315 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +0000316
hasso508e53e2004-05-18 18:57:06 +0000317 oi = (struct ospf6_interface *) ifp->info;
318 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000319 return;
320
321 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000322 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000323
hasso508e53e2004-05-18 18:57:06 +0000324 /* if area is null, do not make connected-route list */
325 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000326 return;
327
hasso508e53e2004-05-18 18:57:06 +0000328 /* update "route to advertise" interface route table */
329 ospf6_route_remove_all (oi->route_connected);
hasso508e53e2004-05-18 18:57:06 +0000330
paul1eb8ef22005-04-07 07:30:20 +0000331 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
332 {
hasso508e53e2004-05-18 18:57:06 +0000333 if (c->address->family != AF_INET6)
334 continue;
335
hasso1e058382004-09-01 21:36:14 +0000336 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
337 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
338 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
339 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
340 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000341
342 /* apply filter */
343 if (oi->plist_name)
344 {
345 struct prefix_list *plist;
346 enum prefix_list_type ret;
347 char buf[128];
348
349 prefix2str (c->address, buf, sizeof (buf));
350 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
351 ret = prefix_list_apply (plist, (void *) c->address);
352 if (ret == PREFIX_DENY)
353 {
hasso1e058382004-09-01 21:36:14 +0000354 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000355 zlog_debug ("%s on %s filtered by prefix-list %s ",
356 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000357 continue;
358 }
359 }
360
361 route = ospf6_route_create ();
362 memcpy (&route->prefix, c->address, sizeof (struct prefix));
363 apply_mask (&route->prefix);
364 route->type = OSPF6_DEST_TYPE_NETWORK;
365 route->path.area_id = oi->area->area_id;
366 route->path.type = OSPF6_PATH_TYPE_INTRA;
367 route->path.cost = oi->cost;
368 route->nexthop[0].ifindex = oi->interface->ifindex;
369 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
370 ospf6_route_add (route, oi->route_connected);
371 }
372
paul718e3742002-12-13 20:15:29 +0000373 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000374 OSPF6_LINK_LSA_SCHEDULE (oi);
375 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
376 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000377}
378
hasso508e53e2004-05-18 18:57:06 +0000379static void
380ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000381{
hasso508e53e2004-05-18 18:57:06 +0000382 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000383
hasso508e53e2004-05-18 18:57:06 +0000384 prev_state = oi->state;
385 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000386
hasso508e53e2004-05-18 18:57:06 +0000387 if (prev_state == next_state)
388 return;
paul718e3742002-12-13 20:15:29 +0000389
hasso508e53e2004-05-18 18:57:06 +0000390 /* log */
391 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000392 {
hassoc6487d62004-12-24 06:00:11 +0000393 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
394 ospf6_interface_state_str[prev_state],
395 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000396 }
paul718e3742002-12-13 20:15:29 +0000397
hasso508e53e2004-05-18 18:57:06 +0000398 if ((prev_state == OSPF6_INTERFACE_DR ||
399 prev_state == OSPF6_INTERFACE_BDR) &&
400 (next_state != OSPF6_INTERFACE_DR &&
401 next_state != OSPF6_INTERFACE_BDR))
402 ospf6_leave_alldrouters (oi->interface->ifindex);
403 if ((prev_state != OSPF6_INTERFACE_DR &&
404 prev_state != OSPF6_INTERFACE_BDR) &&
405 (next_state == OSPF6_INTERFACE_DR ||
406 next_state == OSPF6_INTERFACE_BDR))
407 ospf6_join_alldrouters (oi->interface->ifindex);
paul718e3742002-12-13 20:15:29 +0000408
hasso508e53e2004-05-18 18:57:06 +0000409 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000410 if (next_state == OSPF6_INTERFACE_DOWN)
411 {
412 OSPF6_NETWORK_LSA_EXECUTE (oi);
413 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
414 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
415 }
416 else if (prev_state == OSPF6_INTERFACE_DR ||
417 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000418 {
hasso508e53e2004-05-18 18:57:06 +0000419 OSPF6_NETWORK_LSA_SCHEDULE (oi);
420 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
421 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000422 }
hasso508e53e2004-05-18 18:57:06 +0000423}
424
425
426/* DR Election, RFC2328 section 9.4 */
427
428#define IS_ELIGIBLE(n) \
429 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
430
431static struct ospf6_neighbor *
432better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
433{
434 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
435 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
436 return NULL;
437 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
438 return b;
439 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
440 return a;
441
442 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
443 return a;
444 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
445 return b;
446
447 if (a->priority > b->priority)
448 return a;
449 if (a->priority < b->priority)
450 return b;
451
452 if (ntohl (a->router_id) > ntohl (b->router_id))
453 return a;
454 if (ntohl (a->router_id) < ntohl (b->router_id))
455 return b;
456
457 zlog_warn ("Router-ID duplicate ?");
458 return a;
459}
460
461static struct ospf6_neighbor *
462better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
463{
464 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
465 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
466 return NULL;
467 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
468 return b;
469 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
470 return a;
471
472 if (a->drouter == a->router_id && b->drouter != b->router_id)
473 return a;
474 if (a->drouter != a->router_id && b->drouter == b->router_id)
475 return b;
476
477 if (a->priority > b->priority)
478 return a;
479 if (a->priority < b->priority)
480 return b;
481
482 if (ntohl (a->router_id) > ntohl (b->router_id))
483 return a;
484 if (ntohl (a->router_id) < ntohl (b->router_id))
485 return b;
486
487 zlog_warn ("Router-ID duplicate ?");
488 return a;
489}
490
491static u_char
492dr_election (struct ospf6_interface *oi)
493{
paul1eb8ef22005-04-07 07:30:20 +0000494 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000495 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
496 struct ospf6_neighbor *best_drouter, *best_bdrouter;
497 u_char next_state = 0;
498
499 drouter = bdrouter = NULL;
500 best_drouter = best_bdrouter = NULL;
501
502 /* pseudo neighbor myself, including noting current DR/BDR (1) */
503 memset (&myself, 0, sizeof (myself));
504 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
505 sizeof (myself.name));
506 myself.state = OSPF6_NEIGHBOR_TWOWAY;
507 myself.drouter = oi->drouter;
508 myself.bdrouter = oi->bdrouter;
509 myself.priority = oi->priority;
510 myself.router_id = oi->area->ospf6->router_id;
511
512 /* Electing BDR (2) */
paul1eb8ef22005-04-07 07:30:20 +0000513 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
514 bdrouter = better_bdrouter (bdrouter, on);
515
hasso508e53e2004-05-18 18:57:06 +0000516 best_bdrouter = bdrouter;
517 bdrouter = better_bdrouter (best_bdrouter, &myself);
518
519 /* Electing DR (3) */
paul1eb8ef22005-04-07 07:30:20 +0000520 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
521 drouter = better_drouter (drouter, on);
522
hasso508e53e2004-05-18 18:57:06 +0000523 best_drouter = drouter;
524 drouter = better_drouter (best_drouter, &myself);
525 if (drouter == NULL)
526 drouter = bdrouter;
527
528 /* the router itself is newly/no longer DR/BDR (4) */
529 if ((drouter == &myself && myself.drouter != myself.router_id) ||
530 (drouter != &myself && myself.drouter == myself.router_id) ||
531 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
532 (bdrouter != &myself && myself.bdrouter == myself.router_id))
533 {
534 myself.drouter = (drouter ? drouter->router_id : htonl (0));
535 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
536
537 /* compatible to Electing BDR (2) */
538 bdrouter = better_bdrouter (best_bdrouter, &myself);
539
540 /* compatible to Electing DR (3) */
541 drouter = better_drouter (best_drouter, &myself);
542 if (drouter == NULL)
543 drouter = bdrouter;
544 }
545
546 /* Set interface state accordingly (5) */
547 if (drouter && drouter == &myself)
548 next_state = OSPF6_INTERFACE_DR;
549 else if (bdrouter && bdrouter == &myself)
550 next_state = OSPF6_INTERFACE_BDR;
551 else
552 next_state = OSPF6_INTERFACE_DROTHER;
553
554 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
555 /* XXX */
556
557 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
558 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
559 accordingly after AdjOK */
560 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
561 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
562 {
563 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000564 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
565 (drouter ? drouter->name : "0.0.0.0"),
566 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000567
paul1eb8ef22005-04-07 07:30:20 +0000568 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
hasso508e53e2004-05-18 18:57:06 +0000569 {
hasso508e53e2004-05-18 18:57:06 +0000570 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
571 continue;
572 /* Schedule AdjOK. */
573 thread_add_event (master, adj_ok, on, 0);
574 }
575 }
576
577 oi->drouter = (drouter ? drouter->router_id : htonl (0));
578 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
579 return next_state;
580}
581
582
583/* Interface State Machine */
584int
585interface_up (struct thread *thread)
586{
587 struct ospf6_interface *oi;
588
589 oi = (struct ospf6_interface *) THREAD_ARG (thread);
590 assert (oi && oi->interface);
591
592 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000593 zlog_debug ("Interface Event %s: [InterfaceUp]",
594 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000595
596 /* check physical interface is up */
597 if (! if_is_up (oi->interface))
598 {
599 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000600 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
601 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000602 return 0;
603 }
604
605 /* if already enabled, do nothing */
606 if (oi->state > OSPF6_INTERFACE_DOWN)
607 {
608 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000609 zlog_debug ("Interface %s already enabled",
610 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000611 return 0;
612 }
613
614 /* Join AllSPFRouters */
615 ospf6_join_allspfrouters (oi->interface->ifindex);
616
617 /* Update interface route */
618 ospf6_interface_connected_route_update (oi->interface);
619
620 /* Schedule Hello */
621 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
622 thread_add_event (master, ospf6_hello_send, oi, 0);
623
624 /* decide next interface state */
625 if (if_is_pointopoint (oi->interface))
626 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
627 else if (oi->priority == 0)
628 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
629 else
630 {
631 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
632 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
633 }
634
635 return 0;
paul718e3742002-12-13 20:15:29 +0000636}
637
638int
hasso508e53e2004-05-18 18:57:06 +0000639wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000640{
hasso508e53e2004-05-18 18:57:06 +0000641 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000642
hasso508e53e2004-05-18 18:57:06 +0000643 oi = (struct ospf6_interface *) THREAD_ARG (thread);
644 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000645
hasso508e53e2004-05-18 18:57:06 +0000646 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000647 zlog_debug ("Interface Event %s: [WaitTimer]",
648 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000649
hasso508e53e2004-05-18 18:57:06 +0000650 if (oi->state == OSPF6_INTERFACE_WAITING)
651 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000652
hasso508e53e2004-05-18 18:57:06 +0000653 return 0;
paul718e3742002-12-13 20:15:29 +0000654}
655
hasso508e53e2004-05-18 18:57:06 +0000656int
657backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000658{
hasso508e53e2004-05-18 18:57:06 +0000659 struct ospf6_interface *oi;
660
661 oi = (struct ospf6_interface *) THREAD_ARG (thread);
662 assert (oi && oi->interface);
663
664 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000665 zlog_debug ("Interface Event %s: [BackupSeen]",
666 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000667
668 if (oi->state == OSPF6_INTERFACE_WAITING)
669 ospf6_interface_state_change (dr_election (oi), oi);
670
671 return 0;
paul718e3742002-12-13 20:15:29 +0000672}
673
hasso508e53e2004-05-18 18:57:06 +0000674int
675neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000676{
hasso508e53e2004-05-18 18:57:06 +0000677 struct ospf6_interface *oi;
678
679 oi = (struct ospf6_interface *) THREAD_ARG (thread);
680 assert (oi && oi->interface);
681
682 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000683 zlog_debug ("Interface Event %s: [NeighborChange]",
684 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000685
686 if (oi->state == OSPF6_INTERFACE_DROTHER ||
687 oi->state == OSPF6_INTERFACE_BDR ||
688 oi->state == OSPF6_INTERFACE_DR)
689 ospf6_interface_state_change (dr_election (oi), oi);
690
691 return 0;
paul718e3742002-12-13 20:15:29 +0000692}
693
hasso508e53e2004-05-18 18:57:06 +0000694int
695loopind (struct thread *thread)
696{
697 struct ospf6_interface *oi;
698
699 oi = (struct ospf6_interface *) THREAD_ARG (thread);
700 assert (oi && oi->interface);
701
702 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000703 zlog_debug ("Interface Event %s: [LoopInd]",
704 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000705
706 /* XXX not yet */
707
708 return 0;
709}
710
711int
712interface_down (struct thread *thread)
713{
714 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000715 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000716 struct ospf6_neighbor *on;
717
718 oi = (struct ospf6_interface *) THREAD_ARG (thread);
719 assert (oi && oi->interface);
720
721 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000722 zlog_debug ("Interface Event %s: [InterfaceDown]",
723 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000724
725 /* Leave AllSPFRouters */
726 if (oi->state > OSPF6_INTERFACE_DOWN)
727 ospf6_leave_allspfrouters (oi->interface->ifindex);
728
729 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
730
paul1eb8ef22005-04-07 07:30:20 +0000731 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
732 ospf6_neighbor_delete (on);
733
hasso508e53e2004-05-18 18:57:06 +0000734 list_delete_all_node (oi->neighbor_list);
735
736 return 0;
737}
738
739
paul718e3742002-12-13 20:15:29 +0000740/* show specified interface structure */
741int
hasso508e53e2004-05-18 18:57:06 +0000742ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000743{
hasso508e53e2004-05-18 18:57:06 +0000744 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000745 struct connected *c;
746 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000747 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000748 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000749 const char *updown[3] = {"down", "up", NULL};
750 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000751 struct timeval res, now;
752 char duration[32];
753 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000754
755 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000756 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000757 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000758 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000759 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000760 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000761 type = "POINTOPOINT";
762 else
763 type = "UNKNOWN";
764
765 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000766 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000767 VNL);
768 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000769
hasso508e53e2004-05-18 18:57:06 +0000770 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000771 {
hasso049207c2004-08-04 20:02:13 +0000772 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000773 return 0;
774 }
775 else
hasso508e53e2004-05-18 18:57:06 +0000776 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000777
hasso049207c2004-08-04 20:02:13 +0000778 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000779
780 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000781 {
paul718e3742002-12-13 20:15:29 +0000782 p = c->address;
783 prefix2str (p, strbuf, sizeof (strbuf));
784 switch (p->family)
785 {
786 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000787 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000788 VNL);
paul718e3742002-12-13 20:15:29 +0000789 break;
790 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000791 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000792 VNL);
paul718e3742002-12-13 20:15:29 +0000793 break;
794 default:
hasso508e53e2004-05-18 18:57:06 +0000795 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000796 VNL);
paul718e3742002-12-13 20:15:29 +0000797 break;
798 }
799 }
800
hasso508e53e2004-05-18 18:57:06 +0000801 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000802 {
hasso508e53e2004-05-18 18:57:06 +0000803 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000804 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
hasso508e53e2004-05-18 18:57:06 +0000805 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000806 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000807 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000808 VNL);
paul718e3742002-12-13 20:15:29 +0000809 }
810 else
hasso049207c2004-08-04 20:02:13 +0000811 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000812
813 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000814 ospf6_interface_state_str[oi->state],
815 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000816 VNL);
817 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000818 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000819 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000820 VNL);
paul718e3742002-12-13 20:15:29 +0000821
hasso508e53e2004-05-18 18:57:06 +0000822 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
823 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000824 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000825
826 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000827 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000828
829 gettimeofday (&now, (struct timezone *) NULL);
paul718e3742002-12-13 20:15:29 +0000830
hasso508e53e2004-05-18 18:57:06 +0000831 timerclear (&res);
832 if (oi->thread_send_lsupdate)
833 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
834 timerstring (&res, duration, sizeof (duration));
835 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
836 oi->lsupdate_list->count, duration,
837 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000838 VNL);
hasso508e53e2004-05-18 18:57:06 +0000839 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
840 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000841 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000842
hasso508e53e2004-05-18 18:57:06 +0000843 timerclear (&res);
844 if (oi->thread_send_lsack)
845 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
846 timerstring (&res, duration, sizeof (duration));
847 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
848 oi->lsack_list->count, duration,
849 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000850 VNL);
hasso508e53e2004-05-18 18:57:06 +0000851 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
852 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000853 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000854
hasso508e53e2004-05-18 18:57:06 +0000855 return 0;
paul718e3742002-12-13 20:15:29 +0000856}
857
858/* show interface */
859DEFUN (show_ipv6_ospf6_interface,
860 show_ipv6_ospf6_interface_ifname_cmd,
861 "show ipv6 ospf6 interface IFNAME",
862 SHOW_STR
863 IP6_STR
864 OSPF6_STR
865 INTERFACE_STR
866 IFNAME_STR
867 )
868{
869 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000870 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000871
872 if (argc)
873 {
874 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000875 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000876 {
877 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000878 VNL);
paul718e3742002-12-13 20:15:29 +0000879 return CMD_WARNING;
880 }
881 ospf6_interface_show (vty, ifp);
882 }
883 else
884 {
paul1eb8ef22005-04-07 07:30:20 +0000885 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
886 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000887 }
hasso508e53e2004-05-18 18:57:06 +0000888
paul718e3742002-12-13 20:15:29 +0000889 return CMD_SUCCESS;
890}
891
892ALIAS (show_ipv6_ospf6_interface,
893 show_ipv6_ospf6_interface_cmd,
894 "show ipv6 ospf6 interface",
895 SHOW_STR
896 IP6_STR
897 OSPF6_STR
898 INTERFACE_STR
hasso508e53e2004-05-18 18:57:06 +0000899 );
paul718e3742002-12-13 20:15:29 +0000900
hasso508e53e2004-05-18 18:57:06 +0000901DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
902 show_ipv6_ospf6_interface_ifname_prefix_cmd,
903 "show ipv6 ospf6 interface IFNAME prefix",
904 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000905 IP6_STR
906 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000907 INTERFACE_STR
908 IFNAME_STR
909 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000910 )
911{
paul718e3742002-12-13 20:15:29 +0000912 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000913 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000914
hasso508e53e2004-05-18 18:57:06 +0000915 ifp = if_lookup_by_name (argv[0]);
916 if (ifp == NULL)
917 {
hasso049207c2004-08-04 20:02:13 +0000918 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000919 return CMD_WARNING;
920 }
paul718e3742002-12-13 20:15:29 +0000921
hasso508e53e2004-05-18 18:57:06 +0000922 oi = ifp->info;
923 if (oi == NULL)
924 {
hasso049207c2004-08-04 20:02:13 +0000925 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000926 return CMD_WARNING;
927 }
paul718e3742002-12-13 20:15:29 +0000928
hasso508e53e2004-05-18 18:57:06 +0000929 argc--;
930 argv++;
931 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000932
933 return CMD_SUCCESS;
934}
935
hasso508e53e2004-05-18 18:57:06 +0000936ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
937 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
938 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
939 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000940 IP6_STR
941 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000942 INTERFACE_STR
943 IFNAME_STR
944 "Display connected prefixes to advertise\n"
945 OSPF6_ROUTE_ADDRESS_STR
946 OSPF6_ROUTE_PREFIX_STR
947 "Dispaly details of the prefixes\n"
948 );
949
950ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
951 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
952 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
953 SHOW_STR
954 IP6_STR
955 OSPF6_STR
956 INTERFACE_STR
957 IFNAME_STR
958 "Display connected prefixes to advertise\n"
959 OSPF6_ROUTE_PREFIX_STR
960 OSPF6_ROUTE_MATCH_STR
961 "Dispaly details of the prefixes\n"
962 );
963
964DEFUN (show_ipv6_ospf6_interface_prefix,
965 show_ipv6_ospf6_interface_prefix_cmd,
966 "show ipv6 ospf6 interface prefix",
967 SHOW_STR
968 IP6_STR
969 OSPF6_STR
970 INTERFACE_STR
971 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000972 )
973{
hasso52dc7ee2004-09-23 19:18:23 +0000974 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000975 struct ospf6_interface *oi;
976 struct interface *ifp;
977
paul1eb8ef22005-04-07 07:30:20 +0000978 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +0000979 {
hasso508e53e2004-05-18 18:57:06 +0000980 oi = (struct ospf6_interface *) ifp->info;
981 if (oi == NULL)
982 continue;
983
984 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
985 }
986
987 return CMD_SUCCESS;
988}
989
990ALIAS (show_ipv6_ospf6_interface_prefix,
991 show_ipv6_ospf6_interface_prefix_detail_cmd,
992 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
993 SHOW_STR
994 IP6_STR
995 OSPF6_STR
996 INTERFACE_STR
997 "Display connected prefixes to advertise\n"
998 OSPF6_ROUTE_ADDRESS_STR
999 OSPF6_ROUTE_PREFIX_STR
1000 "Dispaly details of the prefixes\n"
1001 );
1002
1003ALIAS (show_ipv6_ospf6_interface_prefix,
1004 show_ipv6_ospf6_interface_prefix_match_cmd,
1005 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1006 SHOW_STR
1007 IP6_STR
1008 OSPF6_STR
1009 INTERFACE_STR
1010 "Display connected prefixes to advertise\n"
1011 OSPF6_ROUTE_PREFIX_STR
1012 OSPF6_ROUTE_MATCH_STR
1013 "Dispaly details of the prefixes\n"
1014 );
1015
1016
1017/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001018DEFUN (ipv6_ospf6_ifmtu,
1019 ipv6_ospf6_ifmtu_cmd,
1020 "ipv6 ospf6 ifmtu <1-65535>",
1021 IP6_STR
1022 OSPF6_STR
1023 "Interface MTU\n"
1024 "OSPFv3 Interface MTU\n"
1025 )
1026{
1027 struct ospf6_interface *oi;
1028 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001029 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001030 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001031 struct ospf6_neighbor *on;
1032
1033 ifp = (struct interface *) vty->index;
1034 assert (ifp);
1035
1036 oi = (struct ospf6_interface *) ifp->info;
1037 if (oi == NULL)
1038 oi = ospf6_interface_create (ifp);
1039 assert (oi);
1040
1041 ifmtu = strtol (argv[0], NULL, 10);
1042
1043 if (oi->ifmtu == ifmtu)
1044 return CMD_SUCCESS;
1045
hasso1203e1c2004-07-23 21:34:27 +00001046 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001047 {
1048 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001049 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001050 return CMD_WARNING;
1051 }
1052
1053 if (oi->ifmtu < ifmtu)
1054 {
1055 iobuflen = ospf6_iobuf_size (ifmtu);
1056 if (iobuflen < ifmtu)
1057 {
1058 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001059 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001060 oi->ifmtu = iobuflen;
1061 }
1062 else
1063 oi->ifmtu = ifmtu;
1064 }
1065 else
1066 oi->ifmtu = ifmtu;
1067
1068 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001069 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001070 {
hassob596c712004-07-09 18:33:43 +00001071 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001072 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001073 }
1074
1075 return CMD_SUCCESS;
1076}
1077
hasso049207c2004-08-04 20:02:13 +00001078DEFUN (no_ipv6_ospf6_ifmtu,
1079 no_ipv6_ospf6_ifmtu_cmd,
1080 "no ipv6 ospf6 ifmtu",
1081 NO_STR
1082 IP6_STR
1083 OSPF6_STR
1084 "Interface MTU\n"
1085 )
1086{
1087 struct ospf6_interface *oi;
1088 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001089 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001090 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001091 struct ospf6_neighbor *on;
1092
1093 ifp = (struct interface *) vty->index;
1094 assert (ifp);
1095
1096 oi = (struct ospf6_interface *) ifp->info;
1097 if (oi == NULL)
1098 oi = ospf6_interface_create (ifp);
1099 assert (oi);
1100
1101 if (oi->ifmtu < ifp->mtu)
1102 {
1103 iobuflen = ospf6_iobuf_size (ifp->mtu);
1104 if (iobuflen < ifp->mtu)
1105 {
1106 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1107 ifp->name, iobuflen, VNL);
1108 oi->ifmtu = iobuflen;
1109 }
1110 else
1111 oi->ifmtu = ifp->mtu;
1112 }
1113 else
1114 oi->ifmtu = ifp->mtu;
1115
1116 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001117 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001118 {
hasso049207c2004-08-04 20:02:13 +00001119 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001120 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001121 }
1122
1123 return CMD_SUCCESS;
1124}
1125
hasso508e53e2004-05-18 18:57:06 +00001126DEFUN (ipv6_ospf6_cost,
1127 ipv6_ospf6_cost_cmd,
1128 "ipv6 ospf6 cost <1-65535>",
1129 IP6_STR
1130 OSPF6_STR
1131 "Interface cost\n"
1132 "Outgoing metric of this interface\n"
1133 )
1134{
1135 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001136 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001137 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001138
1139 ifp = (struct interface *) vty->index;
1140 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001141
hasso508e53e2004-05-18 18:57:06 +00001142 oi = (struct ospf6_interface *) ifp->info;
1143 if (oi == NULL)
1144 oi = ospf6_interface_create (ifp);
1145 assert (oi);
1146
paul0c083ee2004-10-10 12:54:58 +00001147 lcost = strtol (argv[0], NULL, 10);
1148
1149 if (lcost > UINT32_MAX)
1150 {
1151 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1152 return CMD_WARNING;
1153 }
1154
1155 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001156 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001157
1158 oi->cost = lcost;
1159
hasso508e53e2004-05-18 18:57:06 +00001160 /* update cost held in route_connected list in ospf6_interface */
1161 ospf6_interface_connected_route_update (oi->interface);
1162
1163 /* execute LSA hooks */
1164 if (oi->area)
1165 {
1166 OSPF6_LINK_LSA_SCHEDULE (oi);
1167 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1168 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1169 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1170 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1171 }
1172
1173 return CMD_SUCCESS;
1174}
1175
1176DEFUN (ipv6_ospf6_hellointerval,
1177 ipv6_ospf6_hellointerval_cmd,
1178 "ipv6 ospf6 hello-interval <1-65535>",
1179 IP6_STR
1180 OSPF6_STR
1181 "Interval time of Hello packets\n"
1182 SECONDS_STR
1183 )
1184{
1185 struct ospf6_interface *oi;
1186 struct interface *ifp;
1187
1188 ifp = (struct interface *) vty->index;
1189 assert (ifp);
1190
1191 oi = (struct ospf6_interface *) ifp->info;
1192 if (oi == NULL)
1193 oi = ospf6_interface_create (ifp);
1194 assert (oi);
1195
1196 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001197 return CMD_SUCCESS;
1198}
1199
1200/* interface variable set command */
1201DEFUN (ipv6_ospf6_deadinterval,
1202 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001203 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001204 IP6_STR
1205 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001206 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001207 SECONDS_STR
1208 )
1209{
hasso508e53e2004-05-18 18:57:06 +00001210 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001211 struct interface *ifp;
1212
1213 ifp = (struct interface *) vty->index;
1214 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001215
hasso508e53e2004-05-18 18:57:06 +00001216 oi = (struct ospf6_interface *) ifp->info;
1217 if (oi == NULL)
1218 oi = ospf6_interface_create (ifp);
1219 assert (oi);
1220
1221 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001222 return CMD_SUCCESS;
1223}
1224
1225/* interface variable set command */
1226DEFUN (ipv6_ospf6_transmitdelay,
1227 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001228 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001229 IP6_STR
1230 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001231 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001232 SECONDS_STR
1233 )
1234{
hasso508e53e2004-05-18 18:57:06 +00001235 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001236 struct interface *ifp;
1237
1238 ifp = (struct interface *) vty->index;
1239 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001240
hasso508e53e2004-05-18 18:57:06 +00001241 oi = (struct ospf6_interface *) ifp->info;
1242 if (oi == NULL)
1243 oi = ospf6_interface_create (ifp);
1244 assert (oi);
1245
1246 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001247 return CMD_SUCCESS;
1248}
1249
1250/* interface variable set command */
1251DEFUN (ipv6_ospf6_retransmitinterval,
1252 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001253 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001254 IP6_STR
1255 OSPF6_STR
1256 "Time between retransmitting lost link state advertisements\n"
1257 SECONDS_STR
1258 )
1259{
hasso508e53e2004-05-18 18:57:06 +00001260 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001261 struct interface *ifp;
1262
1263 ifp = (struct interface *) vty->index;
1264 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001265
hasso508e53e2004-05-18 18:57:06 +00001266 oi = (struct ospf6_interface *) ifp->info;
1267 if (oi == NULL)
1268 oi = ospf6_interface_create (ifp);
1269 assert (oi);
1270
1271 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001272 return CMD_SUCCESS;
1273}
1274
1275/* interface variable set command */
1276DEFUN (ipv6_ospf6_priority,
1277 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001278 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001279 IP6_STR
1280 OSPF6_STR
1281 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001282 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001283 )
1284{
hasso508e53e2004-05-18 18:57:06 +00001285 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001286 struct interface *ifp;
1287
1288 ifp = (struct interface *) vty->index;
1289 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001290
hasso508e53e2004-05-18 18:57:06 +00001291 oi = (struct ospf6_interface *) ifp->info;
1292 if (oi == NULL)
1293 oi = ospf6_interface_create (ifp);
1294 assert (oi);
paul718e3742002-12-13 20:15:29 +00001295
hasso508e53e2004-05-18 18:57:06 +00001296 oi->priority = strtol (argv[0], NULL, 10);
1297
1298 if (oi->area)
1299 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001300
1301 return CMD_SUCCESS;
1302}
1303
1304DEFUN (ipv6_ospf6_instance,
1305 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001306 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001307 IP6_STR
1308 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001309 "Instance ID for this interface\n"
1310 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001311 )
1312{
hasso508e53e2004-05-18 18:57:06 +00001313 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001314 struct interface *ifp;
1315
1316 ifp = (struct interface *)vty->index;
1317 assert (ifp);
1318
hasso508e53e2004-05-18 18:57:06 +00001319 oi = (struct ospf6_interface *)ifp->info;
1320 if (oi == NULL)
1321 oi = ospf6_interface_create (ifp);
1322 assert (oi);
paul718e3742002-12-13 20:15:29 +00001323
hasso508e53e2004-05-18 18:57:06 +00001324 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001325 return CMD_SUCCESS;
1326}
1327
1328DEFUN (ipv6_ospf6_passive,
1329 ipv6_ospf6_passive_cmd,
1330 "ipv6 ospf6 passive",
1331 IP6_STR
1332 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001333 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001334 )
1335{
hasso508e53e2004-05-18 18:57:06 +00001336 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001337 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001338 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001339 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001340
1341 ifp = (struct interface *) vty->index;
1342 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001343
hasso508e53e2004-05-18 18:57:06 +00001344 oi = (struct ospf6_interface *) ifp->info;
1345 if (oi == NULL)
1346 oi = ospf6_interface_create (ifp);
1347 assert (oi);
paul718e3742002-12-13 20:15:29 +00001348
hasso508e53e2004-05-18 18:57:06 +00001349 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1350 THREAD_OFF (oi->thread_send_hello);
1351
paul1eb8ef22005-04-07 07:30:20 +00001352 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001353 {
hasso508e53e2004-05-18 18:57:06 +00001354 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001355 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001356 }
1357
1358 return CMD_SUCCESS;
1359}
1360
1361DEFUN (no_ipv6_ospf6_passive,
1362 no_ipv6_ospf6_passive_cmd,
1363 "no ipv6 ospf6 passive",
1364 NO_STR
1365 IP6_STR
1366 OSPF6_STR
1367 "passive interface: No Adjacency will be formed on this I/F\n"
1368 )
1369{
hasso508e53e2004-05-18 18:57:06 +00001370 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001371 struct interface *ifp;
1372
1373 ifp = (struct interface *) vty->index;
1374 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001375
hasso508e53e2004-05-18 18:57:06 +00001376 oi = (struct ospf6_interface *) ifp->info;
1377 if (oi == NULL)
1378 oi = ospf6_interface_create (ifp);
1379 assert (oi);
paul718e3742002-12-13 20:15:29 +00001380
hasso508e53e2004-05-18 18:57:06 +00001381 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1382 THREAD_OFF (oi->thread_send_hello);
1383 oi->thread_send_hello =
1384 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001385
1386 return CMD_SUCCESS;
1387}
1388
1389DEFUN (ipv6_ospf6_advertise_prefix_list,
1390 ipv6_ospf6_advertise_prefix_list_cmd,
1391 "ipv6 ospf6 advertise prefix-list WORD",
1392 IP6_STR
1393 OSPF6_STR
1394 "Advertising options\n"
1395 "Filter prefix using prefix-list\n"
1396 "Prefix list name\n"
1397 )
1398{
hasso508e53e2004-05-18 18:57:06 +00001399 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001400 struct interface *ifp;
1401
1402 ifp = (struct interface *) vty->index;
1403 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001404
hasso508e53e2004-05-18 18:57:06 +00001405 oi = (struct ospf6_interface *) ifp->info;
1406 if (oi == NULL)
1407 oi = ospf6_interface_create (ifp);
1408 assert (oi);
paul718e3742002-12-13 20:15:29 +00001409
hasso508e53e2004-05-18 18:57:06 +00001410 if (oi->plist_name)
1411 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1412 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001413
hasso508e53e2004-05-18 18:57:06 +00001414 ospf6_interface_connected_route_update (oi->interface);
1415 OSPF6_LINK_LSA_SCHEDULE (oi);
1416 if (oi->state == OSPF6_INTERFACE_DR)
1417 {
1418 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1419 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1420 }
1421 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001422
1423 return CMD_SUCCESS;
1424}
1425
1426DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1427 no_ipv6_ospf6_advertise_prefix_list_cmd,
1428 "no ipv6 ospf6 advertise prefix-list",
1429 NO_STR
1430 IP6_STR
1431 OSPF6_STR
1432 "Advertising options\n"
1433 "Filter prefix using prefix-list\n"
1434 )
1435{
hasso508e53e2004-05-18 18:57:06 +00001436 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001437 struct interface *ifp;
1438
1439 ifp = (struct interface *) vty->index;
1440 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001441
hasso508e53e2004-05-18 18:57:06 +00001442 oi = (struct ospf6_interface *) ifp->info;
1443 if (oi == NULL)
1444 oi = ospf6_interface_create (ifp);
1445 assert (oi);
1446
1447 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001448 {
hasso508e53e2004-05-18 18:57:06 +00001449 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1450 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001451 }
1452
hasso508e53e2004-05-18 18:57:06 +00001453 ospf6_interface_connected_route_update (oi->interface);
1454 OSPF6_LINK_LSA_SCHEDULE (oi);
1455 if (oi->state == OSPF6_INTERFACE_DR)
1456 {
1457 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1458 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1459 }
1460 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001461
1462 return CMD_SUCCESS;
1463}
1464
1465int
hasso508e53e2004-05-18 18:57:06 +00001466config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001467{
hasso52dc7ee2004-09-23 19:18:23 +00001468 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001469 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001470 struct interface *ifp;
1471
paul1eb8ef22005-04-07 07:30:20 +00001472 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001473 {
hasso508e53e2004-05-18 18:57:06 +00001474 oi = (struct ospf6_interface *) ifp->info;
1475 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001476 continue;
1477
1478 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001479 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001480
1481 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001482 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso508e53e2004-05-18 18:57:06 +00001483
hasso1203e1c2004-07-23 21:34:27 +00001484 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001485 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
paul718e3742002-12-13 20:15:29 +00001486 vty_out (vty, " ipv6 ospf6 cost %d%s",
hasso049207c2004-08-04 20:02:13 +00001487 oi->cost, VNL);
paul718e3742002-12-13 20:15:29 +00001488 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001489 oi->hello_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001490 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001491 oi->dead_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001492 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001493 oi->rxmt_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001494 vty_out (vty, " ipv6 ospf6 priority %d%s",
hasso049207c2004-08-04 20:02:13 +00001495 oi->priority, VNL);
paul718e3742002-12-13 20:15:29 +00001496 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
hasso049207c2004-08-04 20:02:13 +00001497 oi->transdelay, VNL);
paul718e3742002-12-13 20:15:29 +00001498 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
hasso049207c2004-08-04 20:02:13 +00001499 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001500
hasso508e53e2004-05-18 18:57:06 +00001501 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001502 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001503 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001504
hasso508e53e2004-05-18 18:57:06 +00001505 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001506 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001507
hasso049207c2004-08-04 20:02:13 +00001508 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001509 }
1510 return 0;
1511}
1512
1513struct cmd_node interface_node =
1514{
1515 INTERFACE_NODE,
1516 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001517 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001518};
1519
1520void
1521ospf6_interface_init ()
1522{
1523 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001524 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001525
1526 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001527 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1528 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1529 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001530 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001531 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1532 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1533 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001534 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001535 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1536 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1537 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001538 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001539 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1540 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1541 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001542
hasso508e53e2004-05-18 18:57:06 +00001543 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001544 install_default (INTERFACE_NODE);
1545 install_element (INTERFACE_NODE, &interface_desc_cmd);
1546 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1547 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001548 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001549 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001550 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1551 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1552 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1553 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1554 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1555 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001556
paul718e3742002-12-13 20:15:29 +00001557 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1558 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001559
1560 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1561 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1562}
1563
1564DEFUN (debug_ospf6_interface,
1565 debug_ospf6_interface_cmd,
1566 "debug ospf6 interface",
1567 DEBUG_STR
1568 OSPF6_STR
1569 "Debug OSPFv3 Interface\n"
1570 )
1571{
1572 OSPF6_DEBUG_INTERFACE_ON ();
1573 return CMD_SUCCESS;
1574}
1575
1576DEFUN (no_debug_ospf6_interface,
1577 no_debug_ospf6_interface_cmd,
1578 "no debug ospf6 interface",
1579 NO_STR
1580 DEBUG_STR
1581 OSPF6_STR
1582 "Debug OSPFv3 Interface\n"
1583 )
1584{
hasso3b687352004-08-19 06:56:53 +00001585 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001586 return CMD_SUCCESS;
1587}
1588
1589int
1590config_write_ospf6_debug_interface (struct vty *vty)
1591{
1592 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001593 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001594 return 0;
1595}
1596
1597void
1598install_element_ospf6_debug_interface ()
1599{
1600 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1601 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1602 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1603 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001604}
1605
1606