blob: d4180d92ef43b65297557dad6919a7d67101edf2 [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{
hasso52dc7ee2004-09-23 19:18:23 +0000154 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +0000155 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000156
hasso508e53e2004-05-18 18:57:06 +0000157 for (n = listhead (oi->neighbor_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000158 {
hasso508e53e2004-05-18 18:57:06 +0000159 on = (struct ospf6_neighbor *) getdata (n);
160 ospf6_neighbor_delete (on);
paul718e3742002-12-13 20:15:29 +0000161 }
hasso508e53e2004-05-18 18:57:06 +0000162 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000163
hasso508e53e2004-05-18 18:57:06 +0000164 THREAD_OFF (oi->thread_send_hello);
165 THREAD_OFF (oi->thread_send_lsupdate);
166 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000167
hasso508e53e2004-05-18 18:57:06 +0000168 ospf6_lsdb_remove_all (oi->lsdb);
169 ospf6_lsdb_remove_all (oi->lsupdate_list);
170 ospf6_lsdb_remove_all (oi->lsack_list);
171
172 ospf6_lsdb_delete (oi->lsdb);
hasso6452df02004-08-15 05:52:07 +0000173 ospf6_lsdb_delete (oi->lsdb_self);
174
hasso508e53e2004-05-18 18:57:06 +0000175 ospf6_lsdb_delete (oi->lsupdate_list);
176 ospf6_lsdb_delete (oi->lsack_list);
177
178 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000179
180 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000181 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000182
183 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000184 if (oi->plist_name)
185 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000186
hasso508e53e2004-05-18 18:57:06 +0000187 XFREE (MTYPE_OSPF6_IF, oi);
188}
189
190void
191ospf6_interface_enable (struct ospf6_interface *oi)
192{
193 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
194
195 oi->thread_send_hello =
196 thread_add_event (master, ospf6_hello_send, oi, 0);
197}
198
199void
200ospf6_interface_disable (struct ospf6_interface *oi)
201{
hasso52dc7ee2004-09-23 19:18:23 +0000202 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000203 struct ospf6_neighbor *on;
204
205 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
206
207 for (i = listhead (oi->neighbor_list); i; nextnode (i))
208 {
209 on = (struct ospf6_neighbor *) getdata (i);
210 ospf6_neighbor_delete (on);
211 }
212 list_delete_all_node (oi->neighbor_list);
213
214 ospf6_lsdb_remove_all (oi->lsdb);
215 ospf6_lsdb_remove_all (oi->lsupdate_list);
216 ospf6_lsdb_remove_all (oi->lsack_list);
217
218 THREAD_OFF (oi->thread_send_hello);
219 THREAD_OFF (oi->thread_send_lsupdate);
220 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000221}
222
223static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000224ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000225{
hasso52dc7ee2004-09-23 19:18:23 +0000226 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000227 struct connected *c;
228 struct in6_addr *l = (struct in6_addr *) NULL;
229
230 /* for each connected address */
231 for (n = listhead (ifp->connected); n; nextnode (n))
232 {
233 c = (struct connected *) getdata (n);
234
235 /* if family not AF_INET6, ignore */
236 if (c->address->family != AF_INET6)
237 continue;
238
239 /* linklocal scope check */
240 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
241 l = &c->address->u.prefix6;
242 }
243 return l;
244}
245
246void
247ospf6_interface_if_add (struct interface *ifp)
248{
hasso508e53e2004-05-18 18:57:06 +0000249 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000250 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000251
hasso508e53e2004-05-18 18:57:06 +0000252 oi = (struct ospf6_interface *) ifp->info;
253 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000254 return;
255
hassob596c712004-07-09 18:33:43 +0000256 /* Try to adjust I/O buffer size with IfMtu */
257 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000258 oi->ifmtu = ifp->mtu6;
259 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000260 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000261 {
hasso1e058382004-09-01 21:36:14 +0000262 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000263 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
264 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000265 oi->ifmtu = iobuflen;
266 }
paul718e3742002-12-13 20:15:29 +0000267
268 /* interface start */
hasso508e53e2004-05-18 18:57:06 +0000269 if (oi->area)
270 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000271}
272
273void
274ospf6_interface_if_del (struct interface *ifp)
275{
hasso508e53e2004-05-18 18:57:06 +0000276 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000277
hasso508e53e2004-05-18 18:57:06 +0000278 oi = (struct ospf6_interface *) ifp->info;
279 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000280 return;
281
282 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000283 if (oi->area)
284 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000285
hasso508e53e2004-05-18 18:57:06 +0000286 listnode_delete (oi->area->if_list, oi);
287 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000288
289 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000290 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000291 ifp->info = NULL;
292
hasso508e53e2004-05-18 18:57:06 +0000293 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000294}
295
296void
297ospf6_interface_state_update (struct interface *ifp)
298{
hasso508e53e2004-05-18 18:57:06 +0000299 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000300
hasso508e53e2004-05-18 18:57:06 +0000301 oi = (struct ospf6_interface *) ifp->info;
302 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000303 return;
hasso508e53e2004-05-18 18:57:06 +0000304 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000305 return;
306
307 if (if_is_up (ifp))
hasso508e53e2004-05-18 18:57:06 +0000308 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000309 else
hasso508e53e2004-05-18 18:57:06 +0000310 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000311
312 return;
313}
314
315void
hasso508e53e2004-05-18 18:57:06 +0000316ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000317{
hasso508e53e2004-05-18 18:57:06 +0000318 struct ospf6_interface *oi;
319 struct ospf6_route *route;
320 struct connected *c;
hasso52dc7ee2004-09-23 19:18:23 +0000321 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000322
hasso508e53e2004-05-18 18:57:06 +0000323 oi = (struct ospf6_interface *) ifp->info;
324 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000325 return;
326
327 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000328 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000329
hasso508e53e2004-05-18 18:57:06 +0000330 /* if area is null, do not make connected-route list */
331 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000332 return;
333
hasso508e53e2004-05-18 18:57:06 +0000334 /* update "route to advertise" interface route table */
335 ospf6_route_remove_all (oi->route_connected);
336 for (i = listhead (oi->interface->connected); i; nextnode (i))
337 {
338 c = (struct connected *) getdata (i);
339
340 if (c->address->family != AF_INET6)
341 continue;
342
hasso1e058382004-09-01 21:36:14 +0000343 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
344 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
345 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
346 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
347 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000348
349 /* apply filter */
350 if (oi->plist_name)
351 {
352 struct prefix_list *plist;
353 enum prefix_list_type ret;
354 char buf[128];
355
356 prefix2str (c->address, buf, sizeof (buf));
357 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
358 ret = prefix_list_apply (plist, (void *) c->address);
359 if (ret == PREFIX_DENY)
360 {
hasso1e058382004-09-01 21:36:14 +0000361 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000362 zlog_debug ("%s on %s filtered by prefix-list %s ",
363 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000364 continue;
365 }
366 }
367
368 route = ospf6_route_create ();
369 memcpy (&route->prefix, c->address, sizeof (struct prefix));
370 apply_mask (&route->prefix);
371 route->type = OSPF6_DEST_TYPE_NETWORK;
372 route->path.area_id = oi->area->area_id;
373 route->path.type = OSPF6_PATH_TYPE_INTRA;
374 route->path.cost = oi->cost;
375 route->nexthop[0].ifindex = oi->interface->ifindex;
376 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
377 ospf6_route_add (route, oi->route_connected);
378 }
379
paul718e3742002-12-13 20:15:29 +0000380 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000381 OSPF6_LINK_LSA_SCHEDULE (oi);
382 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
383 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000384}
385
hasso508e53e2004-05-18 18:57:06 +0000386static void
387ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000388{
hasso508e53e2004-05-18 18:57:06 +0000389 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000390
hasso508e53e2004-05-18 18:57:06 +0000391 prev_state = oi->state;
392 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000393
hasso508e53e2004-05-18 18:57:06 +0000394 if (prev_state == next_state)
395 return;
paul718e3742002-12-13 20:15:29 +0000396
hasso508e53e2004-05-18 18:57:06 +0000397 /* log */
398 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000399 {
hassoc6487d62004-12-24 06:00:11 +0000400 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
401 ospf6_interface_state_str[prev_state],
402 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000403 }
paul718e3742002-12-13 20:15:29 +0000404
hasso508e53e2004-05-18 18:57:06 +0000405 if ((prev_state == OSPF6_INTERFACE_DR ||
406 prev_state == OSPF6_INTERFACE_BDR) &&
407 (next_state != OSPF6_INTERFACE_DR &&
408 next_state != OSPF6_INTERFACE_BDR))
409 ospf6_leave_alldrouters (oi->interface->ifindex);
410 if ((prev_state != OSPF6_INTERFACE_DR &&
411 prev_state != OSPF6_INTERFACE_BDR) &&
412 (next_state == OSPF6_INTERFACE_DR ||
413 next_state == OSPF6_INTERFACE_BDR))
414 ospf6_join_alldrouters (oi->interface->ifindex);
paul718e3742002-12-13 20:15:29 +0000415
hasso508e53e2004-05-18 18:57:06 +0000416 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000417 if (next_state == OSPF6_INTERFACE_DOWN)
418 {
419 OSPF6_NETWORK_LSA_EXECUTE (oi);
420 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
421 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
422 }
423 else if (prev_state == OSPF6_INTERFACE_DR ||
424 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000425 {
hasso508e53e2004-05-18 18:57:06 +0000426 OSPF6_NETWORK_LSA_SCHEDULE (oi);
427 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
428 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000429 }
hasso508e53e2004-05-18 18:57:06 +0000430}
431
432
433/* DR Election, RFC2328 section 9.4 */
434
435#define IS_ELIGIBLE(n) \
436 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
437
438static struct ospf6_neighbor *
439better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
440{
441 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
442 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
443 return NULL;
444 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
445 return b;
446 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
447 return a;
448
449 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
450 return a;
451 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
452 return b;
453
454 if (a->priority > b->priority)
455 return a;
456 if (a->priority < b->priority)
457 return b;
458
459 if (ntohl (a->router_id) > ntohl (b->router_id))
460 return a;
461 if (ntohl (a->router_id) < ntohl (b->router_id))
462 return b;
463
464 zlog_warn ("Router-ID duplicate ?");
465 return a;
466}
467
468static struct ospf6_neighbor *
469better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
470{
471 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
472 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
473 return NULL;
474 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
475 return b;
476 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
477 return a;
478
479 if (a->drouter == a->router_id && b->drouter != b->router_id)
480 return a;
481 if (a->drouter != a->router_id && b->drouter == b->router_id)
482 return b;
483
484 if (a->priority > b->priority)
485 return a;
486 if (a->priority < b->priority)
487 return b;
488
489 if (ntohl (a->router_id) > ntohl (b->router_id))
490 return a;
491 if (ntohl (a->router_id) < ntohl (b->router_id))
492 return b;
493
494 zlog_warn ("Router-ID duplicate ?");
495 return a;
496}
497
498static u_char
499dr_election (struct ospf6_interface *oi)
500{
hasso52dc7ee2004-09-23 19:18:23 +0000501 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000502 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
503 struct ospf6_neighbor *best_drouter, *best_bdrouter;
504 u_char next_state = 0;
505
506 drouter = bdrouter = NULL;
507 best_drouter = best_bdrouter = NULL;
508
509 /* pseudo neighbor myself, including noting current DR/BDR (1) */
510 memset (&myself, 0, sizeof (myself));
511 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
512 sizeof (myself.name));
513 myself.state = OSPF6_NEIGHBOR_TWOWAY;
514 myself.drouter = oi->drouter;
515 myself.bdrouter = oi->bdrouter;
516 myself.priority = oi->priority;
517 myself.router_id = oi->area->ospf6->router_id;
518
519 /* Electing BDR (2) */
520 for (i = listhead (oi->neighbor_list); i; nextnode (i))
521 {
522 on = (struct ospf6_neighbor *) getdata (i);
523 bdrouter = better_bdrouter (bdrouter, on);
524 }
525 best_bdrouter = bdrouter;
526 bdrouter = better_bdrouter (best_bdrouter, &myself);
527
528 /* Electing DR (3) */
529 for (i = listhead (oi->neighbor_list); i; nextnode (i))
530 {
531 on = (struct ospf6_neighbor *) getdata (i);
532 drouter = better_drouter (drouter, on);
533 }
534 best_drouter = drouter;
535 drouter = better_drouter (best_drouter, &myself);
536 if (drouter == NULL)
537 drouter = bdrouter;
538
539 /* the router itself is newly/no longer DR/BDR (4) */
540 if ((drouter == &myself && myself.drouter != myself.router_id) ||
541 (drouter != &myself && myself.drouter == myself.router_id) ||
542 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
543 (bdrouter != &myself && myself.bdrouter == myself.router_id))
544 {
545 myself.drouter = (drouter ? drouter->router_id : htonl (0));
546 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
547
548 /* compatible to Electing BDR (2) */
549 bdrouter = better_bdrouter (best_bdrouter, &myself);
550
551 /* compatible to Electing DR (3) */
552 drouter = better_drouter (best_drouter, &myself);
553 if (drouter == NULL)
554 drouter = bdrouter;
555 }
556
557 /* Set interface state accordingly (5) */
558 if (drouter && drouter == &myself)
559 next_state = OSPF6_INTERFACE_DR;
560 else if (bdrouter && bdrouter == &myself)
561 next_state = OSPF6_INTERFACE_BDR;
562 else
563 next_state = OSPF6_INTERFACE_DROTHER;
564
565 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
566 /* XXX */
567
568 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
569 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
570 accordingly after AdjOK */
571 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
572 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
573 {
574 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000575 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
576 (drouter ? drouter->name : "0.0.0.0"),
577 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000578
579 for (i = listhead (oi->neighbor_list); i; nextnode (i))
580 {
581 on = (struct ospf6_neighbor *) getdata (i);
582 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
583 continue;
584 /* Schedule AdjOK. */
585 thread_add_event (master, adj_ok, on, 0);
586 }
587 }
588
589 oi->drouter = (drouter ? drouter->router_id : htonl (0));
590 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
591 return next_state;
592}
593
594
595/* Interface State Machine */
596int
597interface_up (struct thread *thread)
598{
599 struct ospf6_interface *oi;
600
601 oi = (struct ospf6_interface *) THREAD_ARG (thread);
602 assert (oi && oi->interface);
603
604 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000605 zlog_debug ("Interface Event %s: [InterfaceUp]",
606 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000607
608 /* check physical interface is up */
609 if (! if_is_up (oi->interface))
610 {
611 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000612 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
613 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000614 return 0;
615 }
616
617 /* if already enabled, do nothing */
618 if (oi->state > OSPF6_INTERFACE_DOWN)
619 {
620 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000621 zlog_debug ("Interface %s already enabled",
622 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000623 return 0;
624 }
625
626 /* Join AllSPFRouters */
627 ospf6_join_allspfrouters (oi->interface->ifindex);
628
629 /* Update interface route */
630 ospf6_interface_connected_route_update (oi->interface);
631
632 /* Schedule Hello */
633 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
634 thread_add_event (master, ospf6_hello_send, oi, 0);
635
636 /* decide next interface state */
637 if (if_is_pointopoint (oi->interface))
638 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
639 else if (oi->priority == 0)
640 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
641 else
642 {
643 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
644 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
645 }
646
647 return 0;
paul718e3742002-12-13 20:15:29 +0000648}
649
650int
hasso508e53e2004-05-18 18:57:06 +0000651wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000652{
hasso508e53e2004-05-18 18:57:06 +0000653 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000654
hasso508e53e2004-05-18 18:57:06 +0000655 oi = (struct ospf6_interface *) THREAD_ARG (thread);
656 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000657
hasso508e53e2004-05-18 18:57:06 +0000658 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000659 zlog_debug ("Interface Event %s: [WaitTimer]",
660 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000661
hasso508e53e2004-05-18 18:57:06 +0000662 if (oi->state == OSPF6_INTERFACE_WAITING)
663 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000664
hasso508e53e2004-05-18 18:57:06 +0000665 return 0;
paul718e3742002-12-13 20:15:29 +0000666}
667
hasso508e53e2004-05-18 18:57:06 +0000668int
669backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000670{
hasso508e53e2004-05-18 18:57:06 +0000671 struct ospf6_interface *oi;
672
673 oi = (struct ospf6_interface *) THREAD_ARG (thread);
674 assert (oi && oi->interface);
675
676 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000677 zlog_debug ("Interface Event %s: [BackupSeen]",
678 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000679
680 if (oi->state == OSPF6_INTERFACE_WAITING)
681 ospf6_interface_state_change (dr_election (oi), oi);
682
683 return 0;
paul718e3742002-12-13 20:15:29 +0000684}
685
hasso508e53e2004-05-18 18:57:06 +0000686int
687neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000688{
hasso508e53e2004-05-18 18:57:06 +0000689 struct ospf6_interface *oi;
690
691 oi = (struct ospf6_interface *) THREAD_ARG (thread);
692 assert (oi && oi->interface);
693
694 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000695 zlog_debug ("Interface Event %s: [NeighborChange]",
696 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000697
698 if (oi->state == OSPF6_INTERFACE_DROTHER ||
699 oi->state == OSPF6_INTERFACE_BDR ||
700 oi->state == OSPF6_INTERFACE_DR)
701 ospf6_interface_state_change (dr_election (oi), oi);
702
703 return 0;
paul718e3742002-12-13 20:15:29 +0000704}
705
hasso508e53e2004-05-18 18:57:06 +0000706int
707loopind (struct thread *thread)
708{
709 struct ospf6_interface *oi;
710
711 oi = (struct ospf6_interface *) THREAD_ARG (thread);
712 assert (oi && oi->interface);
713
714 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000715 zlog_debug ("Interface Event %s: [LoopInd]",
716 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000717
718 /* XXX not yet */
719
720 return 0;
721}
722
723int
724interface_down (struct thread *thread)
725{
726 struct ospf6_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +0000727 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +0000728 struct ospf6_neighbor *on;
729
730 oi = (struct ospf6_interface *) THREAD_ARG (thread);
731 assert (oi && oi->interface);
732
733 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000734 zlog_debug ("Interface Event %s: [InterfaceDown]",
735 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000736
737 /* Leave AllSPFRouters */
738 if (oi->state > OSPF6_INTERFACE_DOWN)
739 ospf6_leave_allspfrouters (oi->interface->ifindex);
740
741 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
742
743 for (n = listhead (oi->neighbor_list); n; nextnode (n))
744 {
745 on = (struct ospf6_neighbor *) getdata (n);
746 ospf6_neighbor_delete (on);
747 }
748 list_delete_all_node (oi->neighbor_list);
749
750 return 0;
751}
752
753
paul718e3742002-12-13 20:15:29 +0000754/* show specified interface structure */
755int
hasso508e53e2004-05-18 18:57:06 +0000756ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000757{
hasso508e53e2004-05-18 18:57:06 +0000758 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000759 struct connected *c;
760 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000761 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000762 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000763 const char *updown[3] = {"down", "up", NULL};
764 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000765 struct timeval res, now;
766 char duration[32];
767 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000768
769 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000770 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000771 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000772 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000773 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000774 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000775 type = "POINTOPOINT";
776 else
777 type = "UNKNOWN";
778
779 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000780 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000781 VNL);
782 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000783
hasso508e53e2004-05-18 18:57:06 +0000784 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000785 {
hasso049207c2004-08-04 20:02:13 +0000786 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000787 return 0;
788 }
789 else
hasso508e53e2004-05-18 18:57:06 +0000790 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000791
hasso049207c2004-08-04 20:02:13 +0000792 vty_out (vty, " Internet Address:%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000793 for (i = listhead (ifp->connected); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000794 {
795 c = (struct connected *)getdata (i);
796 p = c->address;
797 prefix2str (p, strbuf, sizeof (strbuf));
798 switch (p->family)
799 {
800 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000801 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000802 VNL);
paul718e3742002-12-13 20:15:29 +0000803 break;
804 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000805 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000806 VNL);
paul718e3742002-12-13 20:15:29 +0000807 break;
808 default:
hasso508e53e2004-05-18 18:57:06 +0000809 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000810 VNL);
paul718e3742002-12-13 20:15:29 +0000811 break;
812 }
813 }
814
hasso508e53e2004-05-18 18:57:06 +0000815 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000816 {
hasso508e53e2004-05-18 18:57:06 +0000817 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000818 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
hasso508e53e2004-05-18 18:57:06 +0000819 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000820 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000821 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000822 VNL);
paul718e3742002-12-13 20:15:29 +0000823 }
824 else
hasso049207c2004-08-04 20:02:13 +0000825 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000826
827 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000828 ospf6_interface_state_str[oi->state],
829 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000830 VNL);
831 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000832 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000833 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000834 VNL);
paul718e3742002-12-13 20:15:29 +0000835
hasso508e53e2004-05-18 18:57:06 +0000836 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
837 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000838 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000839
840 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000841 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000842
843 gettimeofday (&now, (struct timezone *) NULL);
paul718e3742002-12-13 20:15:29 +0000844
hasso508e53e2004-05-18 18:57:06 +0000845 timerclear (&res);
846 if (oi->thread_send_lsupdate)
847 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
848 timerstring (&res, duration, sizeof (duration));
849 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
850 oi->lsupdate_list->count, duration,
851 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000852 VNL);
hasso508e53e2004-05-18 18:57:06 +0000853 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
854 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000855 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000856
hasso508e53e2004-05-18 18:57:06 +0000857 timerclear (&res);
858 if (oi->thread_send_lsack)
859 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
860 timerstring (&res, duration, sizeof (duration));
861 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
862 oi->lsack_list->count, duration,
863 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000864 VNL);
hasso508e53e2004-05-18 18:57:06 +0000865 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
866 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000867 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000868
hasso508e53e2004-05-18 18:57:06 +0000869 return 0;
paul718e3742002-12-13 20:15:29 +0000870}
871
872/* show interface */
873DEFUN (show_ipv6_ospf6_interface,
874 show_ipv6_ospf6_interface_ifname_cmd,
875 "show ipv6 ospf6 interface IFNAME",
876 SHOW_STR
877 IP6_STR
878 OSPF6_STR
879 INTERFACE_STR
880 IFNAME_STR
881 )
882{
883 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000884 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000885
886 if (argc)
887 {
888 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000889 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000890 {
891 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000892 VNL);
paul718e3742002-12-13 20:15:29 +0000893 return CMD_WARNING;
894 }
895 ospf6_interface_show (vty, ifp);
896 }
897 else
898 {
899 for (i = listhead (iflist); i; nextnode (i))
900 {
hasso508e53e2004-05-18 18:57:06 +0000901 ifp = (struct interface *) getdata (i);
paul718e3742002-12-13 20:15:29 +0000902 ospf6_interface_show (vty, ifp);
903 }
904 }
hasso508e53e2004-05-18 18:57:06 +0000905
paul718e3742002-12-13 20:15:29 +0000906 return CMD_SUCCESS;
907}
908
909ALIAS (show_ipv6_ospf6_interface,
910 show_ipv6_ospf6_interface_cmd,
911 "show ipv6 ospf6 interface",
912 SHOW_STR
913 IP6_STR
914 OSPF6_STR
915 INTERFACE_STR
hasso508e53e2004-05-18 18:57:06 +0000916 );
paul718e3742002-12-13 20:15:29 +0000917
hasso508e53e2004-05-18 18:57:06 +0000918DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
919 show_ipv6_ospf6_interface_ifname_prefix_cmd,
920 "show ipv6 ospf6 interface IFNAME prefix",
921 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000922 IP6_STR
923 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000924 INTERFACE_STR
925 IFNAME_STR
926 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000927 )
928{
paul718e3742002-12-13 20:15:29 +0000929 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000930 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000931
hasso508e53e2004-05-18 18:57:06 +0000932 ifp = if_lookup_by_name (argv[0]);
933 if (ifp == NULL)
934 {
hasso049207c2004-08-04 20:02:13 +0000935 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000936 return CMD_WARNING;
937 }
paul718e3742002-12-13 20:15:29 +0000938
hasso508e53e2004-05-18 18:57:06 +0000939 oi = ifp->info;
940 if (oi == NULL)
941 {
hasso049207c2004-08-04 20:02:13 +0000942 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000943 return CMD_WARNING;
944 }
paul718e3742002-12-13 20:15:29 +0000945
hasso508e53e2004-05-18 18:57:06 +0000946 argc--;
947 argv++;
948 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000949
950 return CMD_SUCCESS;
951}
952
hasso508e53e2004-05-18 18:57:06 +0000953ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
954 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
955 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
956 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000957 IP6_STR
958 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000959 INTERFACE_STR
960 IFNAME_STR
961 "Display connected prefixes to advertise\n"
962 OSPF6_ROUTE_ADDRESS_STR
963 OSPF6_ROUTE_PREFIX_STR
964 "Dispaly details of the prefixes\n"
965 );
966
967ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
968 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
969 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
970 SHOW_STR
971 IP6_STR
972 OSPF6_STR
973 INTERFACE_STR
974 IFNAME_STR
975 "Display connected prefixes to advertise\n"
976 OSPF6_ROUTE_PREFIX_STR
977 OSPF6_ROUTE_MATCH_STR
978 "Dispaly details of the prefixes\n"
979 );
980
981DEFUN (show_ipv6_ospf6_interface_prefix,
982 show_ipv6_ospf6_interface_prefix_cmd,
983 "show ipv6 ospf6 interface prefix",
984 SHOW_STR
985 IP6_STR
986 OSPF6_STR
987 INTERFACE_STR
988 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000989 )
990{
hasso52dc7ee2004-09-23 19:18:23 +0000991 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000992 struct ospf6_interface *oi;
993 struct interface *ifp;
994
995 for (i = listhead (iflist); i; nextnode (i))
996 {
997 ifp = (struct interface *) getdata (i);
998 oi = (struct ospf6_interface *) ifp->info;
999 if (oi == NULL)
1000 continue;
1001
1002 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1003 }
1004
1005 return CMD_SUCCESS;
1006}
1007
1008ALIAS (show_ipv6_ospf6_interface_prefix,
1009 show_ipv6_ospf6_interface_prefix_detail_cmd,
1010 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1011 SHOW_STR
1012 IP6_STR
1013 OSPF6_STR
1014 INTERFACE_STR
1015 "Display connected prefixes to advertise\n"
1016 OSPF6_ROUTE_ADDRESS_STR
1017 OSPF6_ROUTE_PREFIX_STR
1018 "Dispaly details of the prefixes\n"
1019 );
1020
1021ALIAS (show_ipv6_ospf6_interface_prefix,
1022 show_ipv6_ospf6_interface_prefix_match_cmd,
1023 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1024 SHOW_STR
1025 IP6_STR
1026 OSPF6_STR
1027 INTERFACE_STR
1028 "Display connected prefixes to advertise\n"
1029 OSPF6_ROUTE_PREFIX_STR
1030 OSPF6_ROUTE_MATCH_STR
1031 "Dispaly details of the prefixes\n"
1032 );
1033
1034
1035/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001036DEFUN (ipv6_ospf6_ifmtu,
1037 ipv6_ospf6_ifmtu_cmd,
1038 "ipv6 ospf6 ifmtu <1-65535>",
1039 IP6_STR
1040 OSPF6_STR
1041 "Interface MTU\n"
1042 "OSPFv3 Interface MTU\n"
1043 )
1044{
1045 struct ospf6_interface *oi;
1046 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001047 unsigned int ifmtu, iobuflen;
hasso52dc7ee2004-09-23 19:18:23 +00001048 struct listnode *node;
hassob596c712004-07-09 18:33:43 +00001049 struct ospf6_neighbor *on;
1050
1051 ifp = (struct interface *) vty->index;
1052 assert (ifp);
1053
1054 oi = (struct ospf6_interface *) ifp->info;
1055 if (oi == NULL)
1056 oi = ospf6_interface_create (ifp);
1057 assert (oi);
1058
1059 ifmtu = strtol (argv[0], NULL, 10);
1060
1061 if (oi->ifmtu == ifmtu)
1062 return CMD_SUCCESS;
1063
hasso1203e1c2004-07-23 21:34:27 +00001064 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001065 {
1066 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001067 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001068 return CMD_WARNING;
1069 }
1070
1071 if (oi->ifmtu < ifmtu)
1072 {
1073 iobuflen = ospf6_iobuf_size (ifmtu);
1074 if (iobuflen < ifmtu)
1075 {
1076 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001077 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001078 oi->ifmtu = iobuflen;
1079 }
1080 else
1081 oi->ifmtu = ifmtu;
1082 }
1083 else
1084 oi->ifmtu = ifmtu;
1085
1086 /* re-establish adjacencies */
1087 for (node = listhead (oi->neighbor_list); node; nextnode (node))
1088 {
1089 on = (struct ospf6_neighbor *) getdata (node);
1090 THREAD_OFF (on->inactivity_timer);
1091 thread_execute (master, inactivity_timer, on, 0);
1092 }
1093
1094 return CMD_SUCCESS;
1095}
1096
hasso049207c2004-08-04 20:02:13 +00001097DEFUN (no_ipv6_ospf6_ifmtu,
1098 no_ipv6_ospf6_ifmtu_cmd,
1099 "no ipv6 ospf6 ifmtu",
1100 NO_STR
1101 IP6_STR
1102 OSPF6_STR
1103 "Interface MTU\n"
1104 )
1105{
1106 struct ospf6_interface *oi;
1107 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001108 unsigned int iobuflen;
hasso52dc7ee2004-09-23 19:18:23 +00001109 struct listnode *node;
hasso049207c2004-08-04 20:02:13 +00001110 struct ospf6_neighbor *on;
1111
1112 ifp = (struct interface *) vty->index;
1113 assert (ifp);
1114
1115 oi = (struct ospf6_interface *) ifp->info;
1116 if (oi == NULL)
1117 oi = ospf6_interface_create (ifp);
1118 assert (oi);
1119
1120 if (oi->ifmtu < ifp->mtu)
1121 {
1122 iobuflen = ospf6_iobuf_size (ifp->mtu);
1123 if (iobuflen < ifp->mtu)
1124 {
1125 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1126 ifp->name, iobuflen, VNL);
1127 oi->ifmtu = iobuflen;
1128 }
1129 else
1130 oi->ifmtu = ifp->mtu;
1131 }
1132 else
1133 oi->ifmtu = ifp->mtu;
1134
1135 /* re-establish adjacencies */
1136 for (node = listhead (oi->neighbor_list); node; nextnode (node))
1137 {
1138 on = (struct ospf6_neighbor *) getdata (node);
1139 THREAD_OFF (on->inactivity_timer);
1140 thread_execute (master, inactivity_timer, on, 0);
1141 }
1142
1143 return CMD_SUCCESS;
1144}
1145
hasso508e53e2004-05-18 18:57:06 +00001146DEFUN (ipv6_ospf6_cost,
1147 ipv6_ospf6_cost_cmd,
1148 "ipv6 ospf6 cost <1-65535>",
1149 IP6_STR
1150 OSPF6_STR
1151 "Interface cost\n"
1152 "Outgoing metric of this interface\n"
1153 )
1154{
1155 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001156 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001157 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001158
1159 ifp = (struct interface *) vty->index;
1160 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001161
hasso508e53e2004-05-18 18:57:06 +00001162 oi = (struct ospf6_interface *) ifp->info;
1163 if (oi == NULL)
1164 oi = ospf6_interface_create (ifp);
1165 assert (oi);
1166
paul0c083ee2004-10-10 12:54:58 +00001167 lcost = strtol (argv[0], NULL, 10);
1168
1169 if (lcost > UINT32_MAX)
1170 {
1171 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1172 return CMD_WARNING;
1173 }
1174
1175 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001176 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001177
1178 oi->cost = lcost;
1179
hasso508e53e2004-05-18 18:57:06 +00001180 /* update cost held in route_connected list in ospf6_interface */
1181 ospf6_interface_connected_route_update (oi->interface);
1182
1183 /* execute LSA hooks */
1184 if (oi->area)
1185 {
1186 OSPF6_LINK_LSA_SCHEDULE (oi);
1187 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1188 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1189 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1190 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1191 }
1192
1193 return CMD_SUCCESS;
1194}
1195
1196DEFUN (ipv6_ospf6_hellointerval,
1197 ipv6_ospf6_hellointerval_cmd,
1198 "ipv6 ospf6 hello-interval <1-65535>",
1199 IP6_STR
1200 OSPF6_STR
1201 "Interval time of Hello packets\n"
1202 SECONDS_STR
1203 )
1204{
1205 struct ospf6_interface *oi;
1206 struct interface *ifp;
1207
1208 ifp = (struct interface *) vty->index;
1209 assert (ifp);
1210
1211 oi = (struct ospf6_interface *) ifp->info;
1212 if (oi == NULL)
1213 oi = ospf6_interface_create (ifp);
1214 assert (oi);
1215
1216 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001217 return CMD_SUCCESS;
1218}
1219
1220/* interface variable set command */
1221DEFUN (ipv6_ospf6_deadinterval,
1222 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001223 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001224 IP6_STR
1225 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001226 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001227 SECONDS_STR
1228 )
1229{
hasso508e53e2004-05-18 18:57:06 +00001230 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001231 struct interface *ifp;
1232
1233 ifp = (struct interface *) vty->index;
1234 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001235
hasso508e53e2004-05-18 18:57:06 +00001236 oi = (struct ospf6_interface *) ifp->info;
1237 if (oi == NULL)
1238 oi = ospf6_interface_create (ifp);
1239 assert (oi);
1240
1241 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001242 return CMD_SUCCESS;
1243}
1244
1245/* interface variable set command */
1246DEFUN (ipv6_ospf6_transmitdelay,
1247 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001248 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001249 IP6_STR
1250 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001251 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001252 SECONDS_STR
1253 )
1254{
hasso508e53e2004-05-18 18:57:06 +00001255 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001256 struct interface *ifp;
1257
1258 ifp = (struct interface *) vty->index;
1259 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001260
hasso508e53e2004-05-18 18:57:06 +00001261 oi = (struct ospf6_interface *) ifp->info;
1262 if (oi == NULL)
1263 oi = ospf6_interface_create (ifp);
1264 assert (oi);
1265
1266 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001267 return CMD_SUCCESS;
1268}
1269
1270/* interface variable set command */
1271DEFUN (ipv6_ospf6_retransmitinterval,
1272 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001273 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001274 IP6_STR
1275 OSPF6_STR
1276 "Time between retransmitting lost link state advertisements\n"
1277 SECONDS_STR
1278 )
1279{
hasso508e53e2004-05-18 18:57:06 +00001280 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001281 struct interface *ifp;
1282
1283 ifp = (struct interface *) vty->index;
1284 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001285
hasso508e53e2004-05-18 18:57:06 +00001286 oi = (struct ospf6_interface *) ifp->info;
1287 if (oi == NULL)
1288 oi = ospf6_interface_create (ifp);
1289 assert (oi);
1290
1291 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001292 return CMD_SUCCESS;
1293}
1294
1295/* interface variable set command */
1296DEFUN (ipv6_ospf6_priority,
1297 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001298 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001299 IP6_STR
1300 OSPF6_STR
1301 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001302 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001303 )
1304{
hasso508e53e2004-05-18 18:57:06 +00001305 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001306 struct interface *ifp;
1307
1308 ifp = (struct interface *) vty->index;
1309 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001310
hasso508e53e2004-05-18 18:57:06 +00001311 oi = (struct ospf6_interface *) ifp->info;
1312 if (oi == NULL)
1313 oi = ospf6_interface_create (ifp);
1314 assert (oi);
paul718e3742002-12-13 20:15:29 +00001315
hasso508e53e2004-05-18 18:57:06 +00001316 oi->priority = strtol (argv[0], NULL, 10);
1317
1318 if (oi->area)
1319 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001320
1321 return CMD_SUCCESS;
1322}
1323
1324DEFUN (ipv6_ospf6_instance,
1325 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001326 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001327 IP6_STR
1328 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001329 "Instance ID for this interface\n"
1330 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001331 )
1332{
hasso508e53e2004-05-18 18:57:06 +00001333 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001334 struct interface *ifp;
1335
1336 ifp = (struct interface *)vty->index;
1337 assert (ifp);
1338
hasso508e53e2004-05-18 18:57:06 +00001339 oi = (struct ospf6_interface *)ifp->info;
1340 if (oi == NULL)
1341 oi = ospf6_interface_create (ifp);
1342 assert (oi);
paul718e3742002-12-13 20:15:29 +00001343
hasso508e53e2004-05-18 18:57:06 +00001344 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001345 return CMD_SUCCESS;
1346}
1347
1348DEFUN (ipv6_ospf6_passive,
1349 ipv6_ospf6_passive_cmd,
1350 "ipv6 ospf6 passive",
1351 IP6_STR
1352 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001353 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001354 )
1355{
hasso508e53e2004-05-18 18:57:06 +00001356 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001357 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +00001358 struct listnode *node;
hasso508e53e2004-05-18 18:57:06 +00001359 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001360
1361 ifp = (struct interface *) vty->index;
1362 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001363
hasso508e53e2004-05-18 18:57:06 +00001364 oi = (struct ospf6_interface *) ifp->info;
1365 if (oi == NULL)
1366 oi = ospf6_interface_create (ifp);
1367 assert (oi);
paul718e3742002-12-13 20:15:29 +00001368
hasso508e53e2004-05-18 18:57:06 +00001369 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1370 THREAD_OFF (oi->thread_send_hello);
1371
1372 for (node = listhead (oi->neighbor_list); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001373 {
hasso508e53e2004-05-18 18:57:06 +00001374 on = (struct ospf6_neighbor *) getdata (node);
1375 THREAD_OFF (on->inactivity_timer);
1376 thread_execute (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001377 }
1378
1379 return CMD_SUCCESS;
1380}
1381
1382DEFUN (no_ipv6_ospf6_passive,
1383 no_ipv6_ospf6_passive_cmd,
1384 "no ipv6 ospf6 passive",
1385 NO_STR
1386 IP6_STR
1387 OSPF6_STR
1388 "passive interface: No Adjacency will be formed on this I/F\n"
1389 )
1390{
hasso508e53e2004-05-18 18:57:06 +00001391 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001392 struct interface *ifp;
1393
1394 ifp = (struct interface *) vty->index;
1395 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001396
hasso508e53e2004-05-18 18:57:06 +00001397 oi = (struct ospf6_interface *) ifp->info;
1398 if (oi == NULL)
1399 oi = ospf6_interface_create (ifp);
1400 assert (oi);
paul718e3742002-12-13 20:15:29 +00001401
hasso508e53e2004-05-18 18:57:06 +00001402 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1403 THREAD_OFF (oi->thread_send_hello);
1404 oi->thread_send_hello =
1405 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001406
1407 return CMD_SUCCESS;
1408}
1409
1410DEFUN (ipv6_ospf6_advertise_prefix_list,
1411 ipv6_ospf6_advertise_prefix_list_cmd,
1412 "ipv6 ospf6 advertise prefix-list WORD",
1413 IP6_STR
1414 OSPF6_STR
1415 "Advertising options\n"
1416 "Filter prefix using prefix-list\n"
1417 "Prefix list name\n"
1418 )
1419{
hasso508e53e2004-05-18 18:57:06 +00001420 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001421 struct interface *ifp;
1422
1423 ifp = (struct interface *) vty->index;
1424 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001425
hasso508e53e2004-05-18 18:57:06 +00001426 oi = (struct ospf6_interface *) ifp->info;
1427 if (oi == NULL)
1428 oi = ospf6_interface_create (ifp);
1429 assert (oi);
paul718e3742002-12-13 20:15:29 +00001430
hasso508e53e2004-05-18 18:57:06 +00001431 if (oi->plist_name)
1432 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1433 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001434
hasso508e53e2004-05-18 18:57:06 +00001435 ospf6_interface_connected_route_update (oi->interface);
1436 OSPF6_LINK_LSA_SCHEDULE (oi);
1437 if (oi->state == OSPF6_INTERFACE_DR)
1438 {
1439 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1440 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1441 }
1442 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001443
1444 return CMD_SUCCESS;
1445}
1446
1447DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1448 no_ipv6_ospf6_advertise_prefix_list_cmd,
1449 "no ipv6 ospf6 advertise prefix-list",
1450 NO_STR
1451 IP6_STR
1452 OSPF6_STR
1453 "Advertising options\n"
1454 "Filter prefix using prefix-list\n"
1455 )
1456{
hasso508e53e2004-05-18 18:57:06 +00001457 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001458 struct interface *ifp;
1459
1460 ifp = (struct interface *) vty->index;
1461 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001462
hasso508e53e2004-05-18 18:57:06 +00001463 oi = (struct ospf6_interface *) ifp->info;
1464 if (oi == NULL)
1465 oi = ospf6_interface_create (ifp);
1466 assert (oi);
1467
1468 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001469 {
hasso508e53e2004-05-18 18:57:06 +00001470 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1471 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001472 }
1473
hasso508e53e2004-05-18 18:57:06 +00001474 ospf6_interface_connected_route_update (oi->interface);
1475 OSPF6_LINK_LSA_SCHEDULE (oi);
1476 if (oi->state == OSPF6_INTERFACE_DR)
1477 {
1478 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1479 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1480 }
1481 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001482
1483 return CMD_SUCCESS;
1484}
1485
1486int
hasso508e53e2004-05-18 18:57:06 +00001487config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001488{
hasso52dc7ee2004-09-23 19:18:23 +00001489 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001490 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001491 struct interface *ifp;
1492
1493 for (i = listhead (iflist); i; nextnode (i))
1494 {
1495 ifp = (struct interface *) getdata (i);
hasso508e53e2004-05-18 18:57:06 +00001496 oi = (struct ospf6_interface *) ifp->info;
1497 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001498 continue;
1499
1500 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001501 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001502
1503 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001504 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso508e53e2004-05-18 18:57:06 +00001505
hasso1203e1c2004-07-23 21:34:27 +00001506 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001507 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
paul718e3742002-12-13 20:15:29 +00001508 vty_out (vty, " ipv6 ospf6 cost %d%s",
hasso049207c2004-08-04 20:02:13 +00001509 oi->cost, VNL);
paul718e3742002-12-13 20:15:29 +00001510 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001511 oi->hello_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001512 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001513 oi->dead_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001514 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001515 oi->rxmt_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001516 vty_out (vty, " ipv6 ospf6 priority %d%s",
hasso049207c2004-08-04 20:02:13 +00001517 oi->priority, VNL);
paul718e3742002-12-13 20:15:29 +00001518 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
hasso049207c2004-08-04 20:02:13 +00001519 oi->transdelay, VNL);
paul718e3742002-12-13 20:15:29 +00001520 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
hasso049207c2004-08-04 20:02:13 +00001521 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001522
hasso508e53e2004-05-18 18:57:06 +00001523 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001524 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001525 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001526
hasso508e53e2004-05-18 18:57:06 +00001527 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001528 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001529
hasso049207c2004-08-04 20:02:13 +00001530 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001531 }
1532 return 0;
1533}
1534
1535struct cmd_node interface_node =
1536{
1537 INTERFACE_NODE,
1538 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001539 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001540};
1541
1542void
1543ospf6_interface_init ()
1544{
1545 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001546 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001547
1548 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001549 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1550 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1551 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001552 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001553 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1554 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1555 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001556 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001557 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1558 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1559 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001560 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001561 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1562 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1563 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001564
hasso508e53e2004-05-18 18:57:06 +00001565 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001566 install_default (INTERFACE_NODE);
1567 install_element (INTERFACE_NODE, &interface_desc_cmd);
1568 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1569 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001570 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001571 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001572 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1573 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1574 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1575 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1576 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1577 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001578
paul718e3742002-12-13 20:15:29 +00001579 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1580 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001581
1582 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1583 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1584}
1585
1586DEFUN (debug_ospf6_interface,
1587 debug_ospf6_interface_cmd,
1588 "debug ospf6 interface",
1589 DEBUG_STR
1590 OSPF6_STR
1591 "Debug OSPFv3 Interface\n"
1592 )
1593{
1594 OSPF6_DEBUG_INTERFACE_ON ();
1595 return CMD_SUCCESS;
1596}
1597
1598DEFUN (no_debug_ospf6_interface,
1599 no_debug_ospf6_interface_cmd,
1600 "no debug ospf6 interface",
1601 NO_STR
1602 DEBUG_STR
1603 OSPF6_STR
1604 "Debug OSPFv3 Interface\n"
1605 )
1606{
hasso3b687352004-08-19 06:56:53 +00001607 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001608 return CMD_SUCCESS;
1609}
1610
1611int
1612config_write_ospf6_debug_interface (struct vty *vty)
1613{
1614 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001615 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001616 return 0;
1617}
1618
1619void
1620install_element_ospf6_debug_interface ()
1621{
1622 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1623 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1624 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1625 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001626}
1627
1628