blob: 2cd5303fdb27f9fdb437b6fc441b1e4554d5eaa3 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
hasso508e53e2004-05-18 18:57:06 +000022#include <zebra.h>
paul718e3742002-12-13 20:15:29 +000023
hasso508e53e2004-05-18 18:57:06 +000024#include "memory.h"
paul718e3742002-12-13 20:15:29 +000025#include "if.h"
26#include "log.h"
27#include "command.h"
hasso508e53e2004-05-18 18:57:06 +000028#include "thread.h"
29#include "prefix.h"
30#include "plist.h"
paul718e3742002-12-13 20:15:29 +000031
hasso508e53e2004-05-18 18:57:06 +000032#include "ospf6_lsa.h"
paul718e3742002-12-13 20:15:29 +000033#include "ospf6_lsdb.h"
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_network.h"
35#include "ospf6_message.h"
36#include "ospf6_route.h"
paul718e3742002-12-13 20:15:29 +000037#include "ospf6_top.h"
38#include "ospf6_area.h"
39#include "ospf6_interface.h"
hasso508e53e2004-05-18 18:57:06 +000040#include "ospf6_neighbor.h"
41#include "ospf6_intra.h"
42#include "ospf6_spf.h"
hasso049207c2004-08-04 20:02:13 +000043#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000044
hasso508e53e2004-05-18 18:57:06 +000045unsigned char conf_debug_ospf6_interface = 0;
46
paul0c083ee2004-10-10 12:54:58 +000047const char *ospf6_interface_state_str[] =
paul718e3742002-12-13 20:15:29 +000048{
hasso508e53e2004-05-18 18:57:06 +000049 "None",
50 "Down",
51 "Loopback",
52 "Waiting",
53 "PointToPoint",
54 "DROther",
55 "BDR",
56 "DR",
57 NULL
paul718e3742002-12-13 20:15:29 +000058};
59
hasso508e53e2004-05-18 18:57:06 +000060struct ospf6_interface *
61ospf6_interface_lookup_by_ifindex (int ifindex)
paul718e3742002-12-13 20:15:29 +000062{
hasso508e53e2004-05-18 18:57:06 +000063 struct ospf6_interface *oi;
64 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +000065
hasso508e53e2004-05-18 18:57:06 +000066 ifp = if_lookup_by_index (ifindex);
67 if (ifp == NULL)
68 return (struct ospf6_interface *) NULL;
69
70 oi = (struct ospf6_interface *) ifp->info;
71 return oi;
paul718e3742002-12-13 20:15:29 +000072}
73
hasso508e53e2004-05-18 18:57:06 +000074/* schedule routing table recalculation */
Paul Jakma6ac29a52008-08-15 13:45:30 +010075static void
hasso508e53e2004-05-18 18:57:06 +000076ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000077{
hasso508e53e2004-05-18 18:57:06 +000078 switch (ntohs (lsa->header->type))
79 {
80 case OSPF6_LSTYPE_LINK:
hasso6452df02004-08-15 05:52:07 +000081 if (OSPF6_INTERFACE (lsa->lsdb->data)->state == OSPF6_INTERFACE_DR)
82 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (OSPF6_INTERFACE (lsa->lsdb->data));
83 ospf6_spf_schedule (OSPF6_INTERFACE (lsa->lsdb->data)->area);
hasso508e53e2004-05-18 18:57:06 +000084 break;
paul718e3742002-12-13 20:15:29 +000085
hasso508e53e2004-05-18 18:57:06 +000086 default:
hasso508e53e2004-05-18 18:57:06 +000087 break;
88 }
paul718e3742002-12-13 20:15:29 +000089}
90
91/* Create new ospf6 interface structure */
92struct ospf6_interface *
93ospf6_interface_create (struct interface *ifp)
94{
hasso508e53e2004-05-18 18:57:06 +000095 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +000096 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +000097
hasso508e53e2004-05-18 18:57:06 +000098 oi = (struct ospf6_interface *)
Stephen Hemminger393deb92008-08-18 14:13:29 -070099 XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
paul718e3742002-12-13 20:15:29 +0000100
Stephen Hemminger393deb92008-08-18 14:13:29 -0700101 if (!oi)
paul718e3742002-12-13 20:15:29 +0000102 {
103 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
104 return (struct ospf6_interface *) NULL;
105 }
106
hasso508e53e2004-05-18 18:57:06 +0000107 oi->area = (struct ospf6_area *) NULL;
108 oi->neighbor_list = list_new ();
109 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
110 oi->linklocal_addr = (struct in6_addr *) NULL;
111 oi->instance_id = 0;
112 oi->transdelay = 1;
113 oi->priority = 1;
paul718e3742002-12-13 20:15:29 +0000114
hasso508e53e2004-05-18 18:57:06 +0000115 oi->hello_interval = 10;
116 oi->dead_interval = 40;
117 oi->rxmt_interval = 5;
118 oi->cost = 1;
hasso508e53e2004-05-18 18:57:06 +0000119 oi->state = OSPF6_INTERFACE_DOWN;
120 oi->flag = 0;
paul718e3742002-12-13 20:15:29 +0000121
hassob596c712004-07-09 18:33:43 +0000122 /* Try to adjust I/O buffer size with IfMtu */
hasso1203e1c2004-07-23 21:34:27 +0000123 oi->ifmtu = ifp->mtu6;
124 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000125 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000126 {
hasso1e058382004-09-01 21:36:14 +0000127 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000128 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
129 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000130 oi->ifmtu = iobuflen;
131 }
hasso3b4cd3a2004-05-18 19:28:32 +0000132
hasso6452df02004-08-15 05:52:07 +0000133 oi->lsupdate_list = ospf6_lsdb_create (oi);
134 oi->lsack_list = ospf6_lsdb_create (oi);
135 oi->lsdb = ospf6_lsdb_create (oi);
hasso508e53e2004-05-18 18:57:06 +0000136 oi->lsdb->hook_add = ospf6_interface_lsdb_hook;
137 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook;
hasso6452df02004-08-15 05:52:07 +0000138 oi->lsdb_self = ospf6_lsdb_create (oi);
paul718e3742002-12-13 20:15:29 +0000139
Paul Jakmacf1ce252006-05-15 10:46:07 +0000140 oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
141 oi->route_connected->scope = oi;
paul718e3742002-12-13 20:15:29 +0000142
143 /* link both */
hasso508e53e2004-05-18 18:57:06 +0000144 oi->interface = ifp;
145 ifp->info = oi;
paul718e3742002-12-13 20:15:29 +0000146
hasso508e53e2004-05-18 18:57:06 +0000147 return oi;
paul718e3742002-12-13 20:15:29 +0000148}
149
150void
hasso508e53e2004-05-18 18:57:06 +0000151ospf6_interface_delete (struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000152{
paul1eb8ef22005-04-07 07:30:20 +0000153 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000154 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000155
paul1eb8ef22005-04-07 07:30:20 +0000156 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000157 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000158
hasso508e53e2004-05-18 18:57:06 +0000159 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000160
hasso508e53e2004-05-18 18:57:06 +0000161 THREAD_OFF (oi->thread_send_hello);
162 THREAD_OFF (oi->thread_send_lsupdate);
163 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000164
hasso508e53e2004-05-18 18:57:06 +0000165 ospf6_lsdb_remove_all (oi->lsdb);
166 ospf6_lsdb_remove_all (oi->lsupdate_list);
167 ospf6_lsdb_remove_all (oi->lsack_list);
168
169 ospf6_lsdb_delete (oi->lsdb);
hasso6452df02004-08-15 05:52:07 +0000170 ospf6_lsdb_delete (oi->lsdb_self);
171
hasso508e53e2004-05-18 18:57:06 +0000172 ospf6_lsdb_delete (oi->lsupdate_list);
173 ospf6_lsdb_delete (oi->lsack_list);
174
175 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000176
177 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000178 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000179
180 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000181 if (oi->plist_name)
182 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000183
hasso508e53e2004-05-18 18:57:06 +0000184 XFREE (MTYPE_OSPF6_IF, oi);
185}
186
187void
188ospf6_interface_enable (struct ospf6_interface *oi)
189{
190 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
191
192 oi->thread_send_hello =
193 thread_add_event (master, ospf6_hello_send, oi, 0);
194}
195
196void
197ospf6_interface_disable (struct ospf6_interface *oi)
198{
paul1eb8ef22005-04-07 07:30:20 +0000199 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000200 struct ospf6_neighbor *on;
201
202 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
203
paul1eb8ef22005-04-07 07:30:20 +0000204 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso508e53e2004-05-18 18:57:06 +0000205 ospf6_neighbor_delete (on);
paul1eb8ef22005-04-07 07:30:20 +0000206
hasso508e53e2004-05-18 18:57:06 +0000207 list_delete_all_node (oi->neighbor_list);
208
209 ospf6_lsdb_remove_all (oi->lsdb);
210 ospf6_lsdb_remove_all (oi->lsupdate_list);
211 ospf6_lsdb_remove_all (oi->lsack_list);
212
213 THREAD_OFF (oi->thread_send_hello);
214 THREAD_OFF (oi->thread_send_lsupdate);
215 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000216}
217
218static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000219ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000220{
hasso52dc7ee2004-09-23 19:18:23 +0000221 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000222 struct connected *c;
223 struct in6_addr *l = (struct in6_addr *) NULL;
224
225 /* for each connected address */
paul1eb8ef22005-04-07 07:30:20 +0000226 for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
paul718e3742002-12-13 20:15:29 +0000227 {
paul718e3742002-12-13 20:15:29 +0000228 /* if family not AF_INET6, ignore */
229 if (c->address->family != AF_INET6)
230 continue;
231
232 /* linklocal scope check */
233 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
234 l = &c->address->u.prefix6;
235 }
236 return l;
237}
238
239void
240ospf6_interface_if_add (struct interface *ifp)
241{
hasso508e53e2004-05-18 18:57:06 +0000242 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000243 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000244
hasso508e53e2004-05-18 18:57:06 +0000245 oi = (struct ospf6_interface *) ifp->info;
246 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000247 return;
248
hassob596c712004-07-09 18:33:43 +0000249 /* Try to adjust I/O buffer size with IfMtu */
250 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000251 oi->ifmtu = ifp->mtu6;
252 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000253 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000254 {
hasso1e058382004-09-01 21:36:14 +0000255 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000256 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
257 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000258 oi->ifmtu = iobuflen;
259 }
paul718e3742002-12-13 20:15:29 +0000260
261 /* interface start */
hasso508e53e2004-05-18 18:57:06 +0000262 if (oi->area)
263 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000264}
265
266void
267ospf6_interface_if_del (struct interface *ifp)
268{
hasso508e53e2004-05-18 18:57:06 +0000269 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000270
hasso508e53e2004-05-18 18:57:06 +0000271 oi = (struct ospf6_interface *) ifp->info;
272 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000273 return;
274
275 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000276 if (oi->area)
277 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000278
hasso508e53e2004-05-18 18:57:06 +0000279 listnode_delete (oi->area->if_list, oi);
280 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000281
282 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000283 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000284 ifp->info = NULL;
285
hasso508e53e2004-05-18 18:57:06 +0000286 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000287}
288
289void
290ospf6_interface_state_update (struct interface *ifp)
291{
hasso508e53e2004-05-18 18:57:06 +0000292 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000293
hasso508e53e2004-05-18 18:57:06 +0000294 oi = (struct ospf6_interface *) ifp->info;
295 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000296 return;
hasso508e53e2004-05-18 18:57:06 +0000297 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000298 return;
299
300 if (if_is_up (ifp))
hasso508e53e2004-05-18 18:57:06 +0000301 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000302 else
hasso508e53e2004-05-18 18:57:06 +0000303 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000304
305 return;
306}
307
308void
hasso508e53e2004-05-18 18:57:06 +0000309ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000310{
hasso508e53e2004-05-18 18:57:06 +0000311 struct ospf6_interface *oi;
312 struct ospf6_route *route;
313 struct connected *c;
paul1eb8ef22005-04-07 07:30:20 +0000314 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +0000315
hasso508e53e2004-05-18 18:57:06 +0000316 oi = (struct ospf6_interface *) ifp->info;
317 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000318 return;
319
320 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000321 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000322
hasso508e53e2004-05-18 18:57:06 +0000323 /* if area is null, do not make connected-route list */
324 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000325 return;
326
hasso508e53e2004-05-18 18:57:06 +0000327 /* update "route to advertise" interface route table */
328 ospf6_route_remove_all (oi->route_connected);
hasso508e53e2004-05-18 18:57:06 +0000329
paul1eb8ef22005-04-07 07:30:20 +0000330 for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
331 {
hasso508e53e2004-05-18 18:57:06 +0000332 if (c->address->family != AF_INET6)
333 continue;
334
hasso1e058382004-09-01 21:36:14 +0000335 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
336 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
337 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
338 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
339 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000340
341 /* apply filter */
342 if (oi->plist_name)
343 {
344 struct prefix_list *plist;
345 enum prefix_list_type ret;
346 char buf[128];
347
348 prefix2str (c->address, buf, sizeof (buf));
349 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
350 ret = prefix_list_apply (plist, (void *) c->address);
351 if (ret == PREFIX_DENY)
352 {
hasso1e058382004-09-01 21:36:14 +0000353 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000354 zlog_debug ("%s on %s filtered by prefix-list %s ",
355 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000356 continue;
357 }
358 }
359
360 route = ospf6_route_create ();
361 memcpy (&route->prefix, c->address, sizeof (struct prefix));
362 apply_mask (&route->prefix);
363 route->type = OSPF6_DEST_TYPE_NETWORK;
364 route->path.area_id = oi->area->area_id;
365 route->path.type = OSPF6_PATH_TYPE_INTRA;
366 route->path.cost = oi->cost;
367 route->nexthop[0].ifindex = oi->interface->ifindex;
368 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
369 ospf6_route_add (route, oi->route_connected);
370 }
371
paul718e3742002-12-13 20:15:29 +0000372 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000373 OSPF6_LINK_LSA_SCHEDULE (oi);
374 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
375 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000376}
377
hasso508e53e2004-05-18 18:57:06 +0000378static void
379ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000380{
hasso508e53e2004-05-18 18:57:06 +0000381 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000382
hasso508e53e2004-05-18 18:57:06 +0000383 prev_state = oi->state;
384 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000385
hasso508e53e2004-05-18 18:57:06 +0000386 if (prev_state == next_state)
387 return;
paul718e3742002-12-13 20:15:29 +0000388
hasso508e53e2004-05-18 18:57:06 +0000389 /* log */
390 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000391 {
hassoc6487d62004-12-24 06:00:11 +0000392 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
393 ospf6_interface_state_str[prev_state],
394 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000395 }
paul718e3742002-12-13 20:15:29 +0000396
hasso508e53e2004-05-18 18:57:06 +0000397 if ((prev_state == OSPF6_INTERFACE_DR ||
398 prev_state == OSPF6_INTERFACE_BDR) &&
399 (next_state != OSPF6_INTERFACE_DR &&
400 next_state != OSPF6_INTERFACE_BDR))
401 ospf6_leave_alldrouters (oi->interface->ifindex);
402 if ((prev_state != OSPF6_INTERFACE_DR &&
403 prev_state != OSPF6_INTERFACE_BDR) &&
404 (next_state == OSPF6_INTERFACE_DR ||
405 next_state == OSPF6_INTERFACE_BDR))
406 ospf6_join_alldrouters (oi->interface->ifindex);
paul718e3742002-12-13 20:15:29 +0000407
hasso508e53e2004-05-18 18:57:06 +0000408 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000409 if (next_state == OSPF6_INTERFACE_DOWN)
410 {
411 OSPF6_NETWORK_LSA_EXECUTE (oi);
412 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
413 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
414 }
415 else if (prev_state == OSPF6_INTERFACE_DR ||
416 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000417 {
hasso508e53e2004-05-18 18:57:06 +0000418 OSPF6_NETWORK_LSA_SCHEDULE (oi);
419 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
420 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000421 }
hasso508e53e2004-05-18 18:57:06 +0000422}
423
424
425/* DR Election, RFC2328 section 9.4 */
426
427#define IS_ELIGIBLE(n) \
428 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
429
430static struct ospf6_neighbor *
431better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
432{
433 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
434 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
435 return NULL;
436 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
437 return b;
438 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
439 return a;
440
441 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
442 return a;
443 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
444 return b;
445
446 if (a->priority > b->priority)
447 return a;
448 if (a->priority < b->priority)
449 return b;
450
451 if (ntohl (a->router_id) > ntohl (b->router_id))
452 return a;
453 if (ntohl (a->router_id) < ntohl (b->router_id))
454 return b;
455
456 zlog_warn ("Router-ID duplicate ?");
457 return a;
458}
459
460static struct ospf6_neighbor *
461better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
462{
463 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
464 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
465 return NULL;
466 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
467 return b;
468 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
469 return a;
470
471 if (a->drouter == a->router_id && b->drouter != b->router_id)
472 return a;
473 if (a->drouter != a->router_id && b->drouter == b->router_id)
474 return b;
475
476 if (a->priority > b->priority)
477 return a;
478 if (a->priority < b->priority)
479 return b;
480
481 if (ntohl (a->router_id) > ntohl (b->router_id))
482 return a;
483 if (ntohl (a->router_id) < ntohl (b->router_id))
484 return b;
485
486 zlog_warn ("Router-ID duplicate ?");
487 return a;
488}
489
490static u_char
491dr_election (struct ospf6_interface *oi)
492{
paul1eb8ef22005-04-07 07:30:20 +0000493 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000494 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
495 struct ospf6_neighbor *best_drouter, *best_bdrouter;
496 u_char next_state = 0;
497
498 drouter = bdrouter = NULL;
499 best_drouter = best_bdrouter = NULL;
500
501 /* pseudo neighbor myself, including noting current DR/BDR (1) */
502 memset (&myself, 0, sizeof (myself));
503 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
504 sizeof (myself.name));
505 myself.state = OSPF6_NEIGHBOR_TWOWAY;
506 myself.drouter = oi->drouter;
507 myself.bdrouter = oi->bdrouter;
508 myself.priority = oi->priority;
509 myself.router_id = oi->area->ospf6->router_id;
510
511 /* Electing BDR (2) */
paul1eb8ef22005-04-07 07:30:20 +0000512 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
513 bdrouter = better_bdrouter (bdrouter, on);
514
hasso508e53e2004-05-18 18:57:06 +0000515 best_bdrouter = bdrouter;
516 bdrouter = better_bdrouter (best_bdrouter, &myself);
517
518 /* Electing DR (3) */
paul1eb8ef22005-04-07 07:30:20 +0000519 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
520 drouter = better_drouter (drouter, on);
521
hasso508e53e2004-05-18 18:57:06 +0000522 best_drouter = drouter;
523 drouter = better_drouter (best_drouter, &myself);
524 if (drouter == NULL)
525 drouter = bdrouter;
526
527 /* the router itself is newly/no longer DR/BDR (4) */
528 if ((drouter == &myself && myself.drouter != myself.router_id) ||
529 (drouter != &myself && myself.drouter == myself.router_id) ||
530 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
531 (bdrouter != &myself && myself.bdrouter == myself.router_id))
532 {
533 myself.drouter = (drouter ? drouter->router_id : htonl (0));
534 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
535
536 /* compatible to Electing BDR (2) */
537 bdrouter = better_bdrouter (best_bdrouter, &myself);
538
539 /* compatible to Electing DR (3) */
540 drouter = better_drouter (best_drouter, &myself);
541 if (drouter == NULL)
542 drouter = bdrouter;
543 }
544
545 /* Set interface state accordingly (5) */
546 if (drouter && drouter == &myself)
547 next_state = OSPF6_INTERFACE_DR;
548 else if (bdrouter && bdrouter == &myself)
549 next_state = OSPF6_INTERFACE_BDR;
550 else
551 next_state = OSPF6_INTERFACE_DROTHER;
552
553 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
554 /* XXX */
555
556 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
557 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
558 accordingly after AdjOK */
559 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
560 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
561 {
562 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000563 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
564 (drouter ? drouter->name : "0.0.0.0"),
565 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000566
paul1eb8ef22005-04-07 07:30:20 +0000567 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
hasso508e53e2004-05-18 18:57:06 +0000568 {
hasso508e53e2004-05-18 18:57:06 +0000569 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
570 continue;
571 /* Schedule AdjOK. */
572 thread_add_event (master, adj_ok, on, 0);
573 }
574 }
575
576 oi->drouter = (drouter ? drouter->router_id : htonl (0));
577 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
578 return next_state;
579}
580
581
582/* Interface State Machine */
583int
584interface_up (struct thread *thread)
585{
586 struct ospf6_interface *oi;
587
588 oi = (struct ospf6_interface *) THREAD_ARG (thread);
589 assert (oi && oi->interface);
590
591 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000592 zlog_debug ("Interface Event %s: [InterfaceUp]",
593 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000594
595 /* check physical interface is up */
596 if (! if_is_up (oi->interface))
597 {
598 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000599 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
600 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000601 return 0;
602 }
603
604 /* if already enabled, do nothing */
605 if (oi->state > OSPF6_INTERFACE_DOWN)
606 {
607 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000608 zlog_debug ("Interface %s already enabled",
609 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000610 return 0;
611 }
612
613 /* Join AllSPFRouters */
614 ospf6_join_allspfrouters (oi->interface->ifindex);
615
616 /* Update interface route */
617 ospf6_interface_connected_route_update (oi->interface);
618
619 /* Schedule Hello */
620 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
621 thread_add_event (master, ospf6_hello_send, oi, 0);
622
623 /* decide next interface state */
624 if (if_is_pointopoint (oi->interface))
625 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
626 else if (oi->priority == 0)
627 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
628 else
629 {
630 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
631 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
632 }
633
634 return 0;
paul718e3742002-12-13 20:15:29 +0000635}
636
637int
hasso508e53e2004-05-18 18:57:06 +0000638wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000639{
hasso508e53e2004-05-18 18:57:06 +0000640 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000641
hasso508e53e2004-05-18 18:57:06 +0000642 oi = (struct ospf6_interface *) THREAD_ARG (thread);
643 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000644
hasso508e53e2004-05-18 18:57:06 +0000645 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000646 zlog_debug ("Interface Event %s: [WaitTimer]",
647 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000648
hasso508e53e2004-05-18 18:57:06 +0000649 if (oi->state == OSPF6_INTERFACE_WAITING)
650 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000651
hasso508e53e2004-05-18 18:57:06 +0000652 return 0;
paul718e3742002-12-13 20:15:29 +0000653}
654
hasso508e53e2004-05-18 18:57:06 +0000655int
656backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000657{
hasso508e53e2004-05-18 18:57:06 +0000658 struct ospf6_interface *oi;
659
660 oi = (struct ospf6_interface *) THREAD_ARG (thread);
661 assert (oi && oi->interface);
662
663 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000664 zlog_debug ("Interface Event %s: [BackupSeen]",
665 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000666
667 if (oi->state == OSPF6_INTERFACE_WAITING)
668 ospf6_interface_state_change (dr_election (oi), oi);
669
670 return 0;
paul718e3742002-12-13 20:15:29 +0000671}
672
hasso508e53e2004-05-18 18:57:06 +0000673int
674neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000675{
hasso508e53e2004-05-18 18:57:06 +0000676 struct ospf6_interface *oi;
677
678 oi = (struct ospf6_interface *) THREAD_ARG (thread);
679 assert (oi && oi->interface);
680
681 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000682 zlog_debug ("Interface Event %s: [NeighborChange]",
683 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000684
685 if (oi->state == OSPF6_INTERFACE_DROTHER ||
686 oi->state == OSPF6_INTERFACE_BDR ||
687 oi->state == OSPF6_INTERFACE_DR)
688 ospf6_interface_state_change (dr_election (oi), oi);
689
690 return 0;
paul718e3742002-12-13 20:15:29 +0000691}
692
Paul Jakma6ac29a52008-08-15 13:45:30 +0100693static int
hasso508e53e2004-05-18 18:57:06 +0000694loopind (struct thread *thread)
695{
696 struct ospf6_interface *oi;
697
698 oi = (struct ospf6_interface *) THREAD_ARG (thread);
699 assert (oi && oi->interface);
700
701 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000702 zlog_debug ("Interface Event %s: [LoopInd]",
703 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000704
705 /* XXX not yet */
706
707 return 0;
708}
709
710int
711interface_down (struct thread *thread)
712{
713 struct ospf6_interface *oi;
paul1eb8ef22005-04-07 07:30:20 +0000714 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000715 struct ospf6_neighbor *on;
716
717 oi = (struct ospf6_interface *) THREAD_ARG (thread);
718 assert (oi && oi->interface);
719
720 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000721 zlog_debug ("Interface Event %s: [InterfaceDown]",
722 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000723
724 /* Leave AllSPFRouters */
725 if (oi->state > OSPF6_INTERFACE_DOWN)
726 ospf6_leave_allspfrouters (oi->interface->ifindex);
727
728 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
729
paul1eb8ef22005-04-07 07:30:20 +0000730 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
731 ospf6_neighbor_delete (on);
732
hasso508e53e2004-05-18 18:57:06 +0000733 list_delete_all_node (oi->neighbor_list);
734
735 return 0;
736}
737
738
paul718e3742002-12-13 20:15:29 +0000739/* show specified interface structure */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100740static int
hasso508e53e2004-05-18 18:57:06 +0000741ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000742{
hasso508e53e2004-05-18 18:57:06 +0000743 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000744 struct connected *c;
745 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000746 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000747 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000748 const char *updown[3] = {"down", "up", NULL};
749 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000750 struct timeval res, now;
751 char duration[32];
752 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000753
754 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000755 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000756 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000757 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000758 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000759 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000760 type = "POINTOPOINT";
761 else
762 type = "UNKNOWN";
763
764 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000765 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000766 VNL);
767 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000768
hasso508e53e2004-05-18 18:57:06 +0000769 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000770 {
hasso049207c2004-08-04 20:02:13 +0000771 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000772 return 0;
773 }
774 else
hasso508e53e2004-05-18 18:57:06 +0000775 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000776
hasso049207c2004-08-04 20:02:13 +0000777 vty_out (vty, " Internet Address:%s", VNL);
paul1eb8ef22005-04-07 07:30:20 +0000778
779 for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
paul718e3742002-12-13 20:15:29 +0000780 {
paul718e3742002-12-13 20:15:29 +0000781 p = c->address;
782 prefix2str (p, strbuf, sizeof (strbuf));
783 switch (p->family)
784 {
785 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000786 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000787 VNL);
paul718e3742002-12-13 20:15:29 +0000788 break;
789 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000790 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000791 VNL);
paul718e3742002-12-13 20:15:29 +0000792 break;
793 default:
hasso508e53e2004-05-18 18:57:06 +0000794 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000795 VNL);
paul718e3742002-12-13 20:15:29 +0000796 break;
797 }
798 }
799
hasso508e53e2004-05-18 18:57:06 +0000800 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000801 {
hasso508e53e2004-05-18 18:57:06 +0000802 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000803 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
hasso508e53e2004-05-18 18:57:06 +0000804 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000805 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000806 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000807 VNL);
paul718e3742002-12-13 20:15:29 +0000808 }
809 else
hasso049207c2004-08-04 20:02:13 +0000810 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000811
812 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000813 ospf6_interface_state_str[oi->state],
814 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000815 VNL);
816 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000817 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000818 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000819 VNL);
paul718e3742002-12-13 20:15:29 +0000820
hasso508e53e2004-05-18 18:57:06 +0000821 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
822 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000823 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000824
825 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000826 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000827
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900828 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
paul718e3742002-12-13 20:15:29 +0000829
hasso508e53e2004-05-18 18:57:06 +0000830 timerclear (&res);
831 if (oi->thread_send_lsupdate)
832 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
833 timerstring (&res, duration, sizeof (duration));
834 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
835 oi->lsupdate_list->count, duration,
836 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000837 VNL);
hasso508e53e2004-05-18 18:57:06 +0000838 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
839 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000840 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000841
hasso508e53e2004-05-18 18:57:06 +0000842 timerclear (&res);
843 if (oi->thread_send_lsack)
844 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
845 timerstring (&res, duration, sizeof (duration));
846 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
847 oi->lsack_list->count, duration,
848 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000849 VNL);
hasso508e53e2004-05-18 18:57:06 +0000850 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
851 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000852 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000853
hasso508e53e2004-05-18 18:57:06 +0000854 return 0;
paul718e3742002-12-13 20:15:29 +0000855}
856
857/* show interface */
858DEFUN (show_ipv6_ospf6_interface,
859 show_ipv6_ospf6_interface_ifname_cmd,
860 "show ipv6 ospf6 interface IFNAME",
861 SHOW_STR
862 IP6_STR
863 OSPF6_STR
864 INTERFACE_STR
865 IFNAME_STR
866 )
867{
868 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000869 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000870
871 if (argc)
872 {
873 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000874 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000875 {
876 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000877 VNL);
paul718e3742002-12-13 20:15:29 +0000878 return CMD_WARNING;
879 }
880 ospf6_interface_show (vty, ifp);
881 }
882 else
883 {
paul1eb8ef22005-04-07 07:30:20 +0000884 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
885 ospf6_interface_show (vty, ifp);
paul718e3742002-12-13 20:15:29 +0000886 }
hasso508e53e2004-05-18 18:57:06 +0000887
paul718e3742002-12-13 20:15:29 +0000888 return CMD_SUCCESS;
889}
890
891ALIAS (show_ipv6_ospf6_interface,
892 show_ipv6_ospf6_interface_cmd,
893 "show ipv6 ospf6 interface",
894 SHOW_STR
895 IP6_STR
896 OSPF6_STR
897 INTERFACE_STR
Paul Jakma6ac29a52008-08-15 13:45:30 +0100898 )
paul718e3742002-12-13 20:15:29 +0000899
hasso508e53e2004-05-18 18:57:06 +0000900DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
901 show_ipv6_ospf6_interface_ifname_prefix_cmd,
902 "show ipv6 ospf6 interface IFNAME prefix",
903 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000904 IP6_STR
905 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000906 INTERFACE_STR
907 IFNAME_STR
908 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000909 )
910{
paul718e3742002-12-13 20:15:29 +0000911 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000912 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000913
hasso508e53e2004-05-18 18:57:06 +0000914 ifp = if_lookup_by_name (argv[0]);
915 if (ifp == NULL)
916 {
hasso049207c2004-08-04 20:02:13 +0000917 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000918 return CMD_WARNING;
919 }
paul718e3742002-12-13 20:15:29 +0000920
hasso508e53e2004-05-18 18:57:06 +0000921 oi = ifp->info;
922 if (oi == NULL)
923 {
hasso049207c2004-08-04 20:02:13 +0000924 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000925 return CMD_WARNING;
926 }
paul718e3742002-12-13 20:15:29 +0000927
hasso508e53e2004-05-18 18:57:06 +0000928 argc--;
929 argv++;
930 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000931
932 return CMD_SUCCESS;
933}
934
hasso508e53e2004-05-18 18:57:06 +0000935ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
936 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
937 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
938 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000939 IP6_STR
940 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000941 INTERFACE_STR
942 IFNAME_STR
943 "Display connected prefixes to advertise\n"
944 OSPF6_ROUTE_ADDRESS_STR
945 OSPF6_ROUTE_PREFIX_STR
946 "Dispaly details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100947 )
hasso508e53e2004-05-18 18:57:06 +0000948
949ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
950 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
951 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
952 SHOW_STR
953 IP6_STR
954 OSPF6_STR
955 INTERFACE_STR
956 IFNAME_STR
957 "Display connected prefixes to advertise\n"
958 OSPF6_ROUTE_PREFIX_STR
959 OSPF6_ROUTE_MATCH_STR
960 "Dispaly details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100961 )
hasso508e53e2004-05-18 18:57:06 +0000962
963DEFUN (show_ipv6_ospf6_interface_prefix,
964 show_ipv6_ospf6_interface_prefix_cmd,
965 "show ipv6 ospf6 interface prefix",
966 SHOW_STR
967 IP6_STR
968 OSPF6_STR
969 INTERFACE_STR
970 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000971 )
972{
hasso52dc7ee2004-09-23 19:18:23 +0000973 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000974 struct ospf6_interface *oi;
975 struct interface *ifp;
976
paul1eb8ef22005-04-07 07:30:20 +0000977 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
hasso508e53e2004-05-18 18:57:06 +0000978 {
hasso508e53e2004-05-18 18:57:06 +0000979 oi = (struct ospf6_interface *) ifp->info;
980 if (oi == NULL)
981 continue;
982
983 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
984 }
985
986 return CMD_SUCCESS;
987}
988
989ALIAS (show_ipv6_ospf6_interface_prefix,
990 show_ipv6_ospf6_interface_prefix_detail_cmd,
991 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
992 SHOW_STR
993 IP6_STR
994 OSPF6_STR
995 INTERFACE_STR
996 "Display connected prefixes to advertise\n"
997 OSPF6_ROUTE_ADDRESS_STR
998 OSPF6_ROUTE_PREFIX_STR
999 "Dispaly details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001000 )
hasso508e53e2004-05-18 18:57:06 +00001001
1002ALIAS (show_ipv6_ospf6_interface_prefix,
1003 show_ipv6_ospf6_interface_prefix_match_cmd,
1004 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1005 SHOW_STR
1006 IP6_STR
1007 OSPF6_STR
1008 INTERFACE_STR
1009 "Display connected prefixes to advertise\n"
1010 OSPF6_ROUTE_PREFIX_STR
1011 OSPF6_ROUTE_MATCH_STR
1012 "Dispaly details of the prefixes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001013 )
hasso508e53e2004-05-18 18:57:06 +00001014
1015
1016/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001017DEFUN (ipv6_ospf6_ifmtu,
1018 ipv6_ospf6_ifmtu_cmd,
1019 "ipv6 ospf6 ifmtu <1-65535>",
1020 IP6_STR
1021 OSPF6_STR
1022 "Interface MTU\n"
1023 "OSPFv3 Interface MTU\n"
1024 )
1025{
1026 struct ospf6_interface *oi;
1027 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001028 unsigned int ifmtu, iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001029 struct listnode *node, *nnode;
hassob596c712004-07-09 18:33:43 +00001030 struct ospf6_neighbor *on;
1031
1032 ifp = (struct interface *) vty->index;
1033 assert (ifp);
1034
1035 oi = (struct ospf6_interface *) ifp->info;
1036 if (oi == NULL)
1037 oi = ospf6_interface_create (ifp);
1038 assert (oi);
1039
1040 ifmtu = strtol (argv[0], NULL, 10);
1041
1042 if (oi->ifmtu == ifmtu)
1043 return CMD_SUCCESS;
1044
hasso1203e1c2004-07-23 21:34:27 +00001045 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001046 {
1047 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001048 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001049 return CMD_WARNING;
1050 }
1051
1052 if (oi->ifmtu < ifmtu)
1053 {
1054 iobuflen = ospf6_iobuf_size (ifmtu);
1055 if (iobuflen < ifmtu)
1056 {
1057 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001058 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001059 oi->ifmtu = iobuflen;
1060 }
1061 else
1062 oi->ifmtu = ifmtu;
1063 }
1064 else
1065 oi->ifmtu = ifmtu;
1066
1067 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001068 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hassob596c712004-07-09 18:33:43 +00001069 {
hassob596c712004-07-09 18:33:43 +00001070 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001071 thread_add_event (master, inactivity_timer, on, 0);
hassob596c712004-07-09 18:33:43 +00001072 }
1073
1074 return CMD_SUCCESS;
1075}
1076
hasso049207c2004-08-04 20:02:13 +00001077DEFUN (no_ipv6_ospf6_ifmtu,
1078 no_ipv6_ospf6_ifmtu_cmd,
1079 "no ipv6 ospf6 ifmtu",
1080 NO_STR
1081 IP6_STR
1082 OSPF6_STR
1083 "Interface MTU\n"
1084 )
1085{
1086 struct ospf6_interface *oi;
1087 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001088 unsigned int iobuflen;
paul1eb8ef22005-04-07 07:30:20 +00001089 struct listnode *node, *nnode;
hasso049207c2004-08-04 20:02:13 +00001090 struct ospf6_neighbor *on;
1091
1092 ifp = (struct interface *) vty->index;
1093 assert (ifp);
1094
1095 oi = (struct ospf6_interface *) ifp->info;
1096 if (oi == NULL)
1097 oi = ospf6_interface_create (ifp);
1098 assert (oi);
1099
1100 if (oi->ifmtu < ifp->mtu)
1101 {
1102 iobuflen = ospf6_iobuf_size (ifp->mtu);
1103 if (iobuflen < ifp->mtu)
1104 {
1105 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1106 ifp->name, iobuflen, VNL);
1107 oi->ifmtu = iobuflen;
1108 }
1109 else
1110 oi->ifmtu = ifp->mtu;
1111 }
1112 else
1113 oi->ifmtu = ifp->mtu;
1114
1115 /* re-establish adjacencies */
paul1eb8ef22005-04-07 07:30:20 +00001116 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
hasso049207c2004-08-04 20:02:13 +00001117 {
hasso049207c2004-08-04 20:02:13 +00001118 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001119 thread_add_event (master, inactivity_timer, on, 0);
hasso049207c2004-08-04 20:02:13 +00001120 }
1121
1122 return CMD_SUCCESS;
1123}
1124
hasso508e53e2004-05-18 18:57:06 +00001125DEFUN (ipv6_ospf6_cost,
1126 ipv6_ospf6_cost_cmd,
1127 "ipv6 ospf6 cost <1-65535>",
1128 IP6_STR
1129 OSPF6_STR
1130 "Interface cost\n"
1131 "Outgoing metric of this interface\n"
1132 )
1133{
1134 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001135 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001136 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001137
1138 ifp = (struct interface *) vty->index;
1139 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001140
hasso508e53e2004-05-18 18:57:06 +00001141 oi = (struct ospf6_interface *) ifp->info;
1142 if (oi == NULL)
1143 oi = ospf6_interface_create (ifp);
1144 assert (oi);
1145
paul0c083ee2004-10-10 12:54:58 +00001146 lcost = strtol (argv[0], NULL, 10);
1147
1148 if (lcost > UINT32_MAX)
1149 {
1150 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1151 return CMD_WARNING;
1152 }
1153
1154 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001155 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001156
1157 oi->cost = lcost;
1158
hasso508e53e2004-05-18 18:57:06 +00001159 /* update cost held in route_connected list in ospf6_interface */
1160 ospf6_interface_connected_route_update (oi->interface);
1161
1162 /* execute LSA hooks */
1163 if (oi->area)
1164 {
1165 OSPF6_LINK_LSA_SCHEDULE (oi);
1166 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1167 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1168 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1169 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1170 }
1171
1172 return CMD_SUCCESS;
1173}
1174
1175DEFUN (ipv6_ospf6_hellointerval,
1176 ipv6_ospf6_hellointerval_cmd,
1177 "ipv6 ospf6 hello-interval <1-65535>",
1178 IP6_STR
1179 OSPF6_STR
1180 "Interval time of Hello packets\n"
1181 SECONDS_STR
1182 )
1183{
1184 struct ospf6_interface *oi;
1185 struct interface *ifp;
1186
1187 ifp = (struct interface *) vty->index;
1188 assert (ifp);
1189
1190 oi = (struct ospf6_interface *) ifp->info;
1191 if (oi == NULL)
1192 oi = ospf6_interface_create (ifp);
1193 assert (oi);
1194
1195 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001196 return CMD_SUCCESS;
1197}
1198
1199/* interface variable set command */
1200DEFUN (ipv6_ospf6_deadinterval,
1201 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001202 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001203 IP6_STR
1204 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001205 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001206 SECONDS_STR
1207 )
1208{
hasso508e53e2004-05-18 18:57:06 +00001209 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001210 struct interface *ifp;
1211
1212 ifp = (struct interface *) vty->index;
1213 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001214
hasso508e53e2004-05-18 18:57:06 +00001215 oi = (struct ospf6_interface *) ifp->info;
1216 if (oi == NULL)
1217 oi = ospf6_interface_create (ifp);
1218 assert (oi);
1219
1220 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001221 return CMD_SUCCESS;
1222}
1223
1224/* interface variable set command */
1225DEFUN (ipv6_ospf6_transmitdelay,
1226 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001227 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001228 IP6_STR
1229 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001230 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001231 SECONDS_STR
1232 )
1233{
hasso508e53e2004-05-18 18:57:06 +00001234 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001235 struct interface *ifp;
1236
1237 ifp = (struct interface *) vty->index;
1238 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001239
hasso508e53e2004-05-18 18:57:06 +00001240 oi = (struct ospf6_interface *) ifp->info;
1241 if (oi == NULL)
1242 oi = ospf6_interface_create (ifp);
1243 assert (oi);
1244
1245 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001246 return CMD_SUCCESS;
1247}
1248
1249/* interface variable set command */
1250DEFUN (ipv6_ospf6_retransmitinterval,
1251 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001252 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001253 IP6_STR
1254 OSPF6_STR
1255 "Time between retransmitting lost link state advertisements\n"
1256 SECONDS_STR
1257 )
1258{
hasso508e53e2004-05-18 18:57:06 +00001259 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001260 struct interface *ifp;
1261
1262 ifp = (struct interface *) vty->index;
1263 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001264
hasso508e53e2004-05-18 18:57:06 +00001265 oi = (struct ospf6_interface *) ifp->info;
1266 if (oi == NULL)
1267 oi = ospf6_interface_create (ifp);
1268 assert (oi);
1269
1270 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001271 return CMD_SUCCESS;
1272}
1273
1274/* interface variable set command */
1275DEFUN (ipv6_ospf6_priority,
1276 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001277 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001278 IP6_STR
1279 OSPF6_STR
1280 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001281 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001282 )
1283{
hasso508e53e2004-05-18 18:57:06 +00001284 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001285 struct interface *ifp;
1286
1287 ifp = (struct interface *) vty->index;
1288 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001289
hasso508e53e2004-05-18 18:57:06 +00001290 oi = (struct ospf6_interface *) ifp->info;
1291 if (oi == NULL)
1292 oi = ospf6_interface_create (ifp);
1293 assert (oi);
paul718e3742002-12-13 20:15:29 +00001294
hasso508e53e2004-05-18 18:57:06 +00001295 oi->priority = strtol (argv[0], NULL, 10);
1296
1297 if (oi->area)
1298 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001299
1300 return CMD_SUCCESS;
1301}
1302
1303DEFUN (ipv6_ospf6_instance,
1304 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001305 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001306 IP6_STR
1307 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001308 "Instance ID for this interface\n"
1309 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001310 )
1311{
hasso508e53e2004-05-18 18:57:06 +00001312 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001313 struct interface *ifp;
1314
1315 ifp = (struct interface *)vty->index;
1316 assert (ifp);
1317
hasso508e53e2004-05-18 18:57:06 +00001318 oi = (struct ospf6_interface *)ifp->info;
1319 if (oi == NULL)
1320 oi = ospf6_interface_create (ifp);
1321 assert (oi);
paul718e3742002-12-13 20:15:29 +00001322
hasso508e53e2004-05-18 18:57:06 +00001323 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001324 return CMD_SUCCESS;
1325}
1326
1327DEFUN (ipv6_ospf6_passive,
1328 ipv6_ospf6_passive_cmd,
1329 "ipv6 ospf6 passive",
1330 IP6_STR
1331 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001332 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001333 )
1334{
hasso508e53e2004-05-18 18:57:06 +00001335 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001336 struct interface *ifp;
paul1eb8ef22005-04-07 07:30:20 +00001337 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +00001338 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001339
1340 ifp = (struct interface *) vty->index;
1341 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001342
hasso508e53e2004-05-18 18:57:06 +00001343 oi = (struct ospf6_interface *) ifp->info;
1344 if (oi == NULL)
1345 oi = ospf6_interface_create (ifp);
1346 assert (oi);
paul718e3742002-12-13 20:15:29 +00001347
hasso508e53e2004-05-18 18:57:06 +00001348 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1349 THREAD_OFF (oi->thread_send_hello);
1350
paul1eb8ef22005-04-07 07:30:20 +00001351 for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
paul718e3742002-12-13 20:15:29 +00001352 {
hasso508e53e2004-05-18 18:57:06 +00001353 THREAD_OFF (on->inactivity_timer);
hasso3e834b12005-06-24 07:50:12 +00001354 thread_add_event (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001355 }
1356
1357 return CMD_SUCCESS;
1358}
1359
1360DEFUN (no_ipv6_ospf6_passive,
1361 no_ipv6_ospf6_passive_cmd,
1362 "no ipv6 ospf6 passive",
1363 NO_STR
1364 IP6_STR
1365 OSPF6_STR
1366 "passive interface: No Adjacency will be formed on this I/F\n"
1367 )
1368{
hasso508e53e2004-05-18 18:57:06 +00001369 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001370 struct interface *ifp;
1371
1372 ifp = (struct interface *) vty->index;
1373 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001374
hasso508e53e2004-05-18 18:57:06 +00001375 oi = (struct ospf6_interface *) ifp->info;
1376 if (oi == NULL)
1377 oi = ospf6_interface_create (ifp);
1378 assert (oi);
paul718e3742002-12-13 20:15:29 +00001379
hasso508e53e2004-05-18 18:57:06 +00001380 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1381 THREAD_OFF (oi->thread_send_hello);
1382 oi->thread_send_hello =
1383 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001384
1385 return CMD_SUCCESS;
1386}
1387
1388DEFUN (ipv6_ospf6_advertise_prefix_list,
1389 ipv6_ospf6_advertise_prefix_list_cmd,
1390 "ipv6 ospf6 advertise prefix-list WORD",
1391 IP6_STR
1392 OSPF6_STR
1393 "Advertising options\n"
1394 "Filter prefix using prefix-list\n"
1395 "Prefix list name\n"
1396 )
1397{
hasso508e53e2004-05-18 18:57:06 +00001398 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001399 struct interface *ifp;
1400
1401 ifp = (struct interface *) vty->index;
1402 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001403
hasso508e53e2004-05-18 18:57:06 +00001404 oi = (struct ospf6_interface *) ifp->info;
1405 if (oi == NULL)
1406 oi = ospf6_interface_create (ifp);
1407 assert (oi);
paul718e3742002-12-13 20:15:29 +00001408
hasso508e53e2004-05-18 18:57:06 +00001409 if (oi->plist_name)
1410 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1411 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001412
hasso508e53e2004-05-18 18:57:06 +00001413 ospf6_interface_connected_route_update (oi->interface);
1414 OSPF6_LINK_LSA_SCHEDULE (oi);
1415 if (oi->state == OSPF6_INTERFACE_DR)
1416 {
1417 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1418 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1419 }
1420 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001421
1422 return CMD_SUCCESS;
1423}
1424
1425DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1426 no_ipv6_ospf6_advertise_prefix_list_cmd,
1427 "no ipv6 ospf6 advertise prefix-list",
1428 NO_STR
1429 IP6_STR
1430 OSPF6_STR
1431 "Advertising options\n"
1432 "Filter prefix using prefix-list\n"
1433 )
1434{
hasso508e53e2004-05-18 18:57:06 +00001435 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001436 struct interface *ifp;
1437
1438 ifp = (struct interface *) vty->index;
1439 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001440
hasso508e53e2004-05-18 18:57:06 +00001441 oi = (struct ospf6_interface *) ifp->info;
1442 if (oi == NULL)
1443 oi = ospf6_interface_create (ifp);
1444 assert (oi);
1445
1446 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001447 {
hasso508e53e2004-05-18 18:57:06 +00001448 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1449 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001450 }
1451
hasso508e53e2004-05-18 18:57:06 +00001452 ospf6_interface_connected_route_update (oi->interface);
1453 OSPF6_LINK_LSA_SCHEDULE (oi);
1454 if (oi->state == OSPF6_INTERFACE_DR)
1455 {
1456 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1457 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1458 }
1459 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001460
1461 return CMD_SUCCESS;
1462}
1463
Paul Jakma6ac29a52008-08-15 13:45:30 +01001464static int
hasso508e53e2004-05-18 18:57:06 +00001465config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001466{
hasso52dc7ee2004-09-23 19:18:23 +00001467 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001468 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001469 struct interface *ifp;
1470
paul1eb8ef22005-04-07 07:30:20 +00001471 for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
paul718e3742002-12-13 20:15:29 +00001472 {
hasso508e53e2004-05-18 18:57:06 +00001473 oi = (struct ospf6_interface *) ifp->info;
1474 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001475 continue;
1476
1477 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001478 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001479
1480 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001481 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso508e53e2004-05-18 18:57:06 +00001482
hasso1203e1c2004-07-23 21:34:27 +00001483 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001484 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
paul718e3742002-12-13 20:15:29 +00001485 vty_out (vty, " ipv6 ospf6 cost %d%s",
hasso049207c2004-08-04 20:02:13 +00001486 oi->cost, VNL);
paul718e3742002-12-13 20:15:29 +00001487 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001488 oi->hello_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001489 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001490 oi->dead_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001491 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001492 oi->rxmt_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001493 vty_out (vty, " ipv6 ospf6 priority %d%s",
hasso049207c2004-08-04 20:02:13 +00001494 oi->priority, VNL);
paul718e3742002-12-13 20:15:29 +00001495 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
hasso049207c2004-08-04 20:02:13 +00001496 oi->transdelay, VNL);
paul718e3742002-12-13 20:15:29 +00001497 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
hasso049207c2004-08-04 20:02:13 +00001498 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001499
hasso508e53e2004-05-18 18:57:06 +00001500 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001501 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001502 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001503
hasso508e53e2004-05-18 18:57:06 +00001504 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001505 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001506
hasso049207c2004-08-04 20:02:13 +00001507 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001508 }
1509 return 0;
1510}
1511
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001512static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001513{
1514 INTERFACE_NODE,
1515 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001516 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001517};
1518
1519void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001520ospf6_interface_init (void)
paul718e3742002-12-13 20:15:29 +00001521{
1522 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001523 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001524
1525 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001526 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1527 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1528 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001529 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001530 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1531 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1532 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001533 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001534 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1535 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1536 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001537 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001538 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1539 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1540 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001541
hasso508e53e2004-05-18 18:57:06 +00001542 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001543 install_default (INTERFACE_NODE);
1544 install_element (INTERFACE_NODE, &interface_desc_cmd);
1545 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1546 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001547 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001548 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001549 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1550 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1551 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1552 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1553 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1554 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001555
paul718e3742002-12-13 20:15:29 +00001556 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1557 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001558
1559 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1560 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1561}
1562
1563DEFUN (debug_ospf6_interface,
1564 debug_ospf6_interface_cmd,
1565 "debug ospf6 interface",
1566 DEBUG_STR
1567 OSPF6_STR
1568 "Debug OSPFv3 Interface\n"
1569 )
1570{
1571 OSPF6_DEBUG_INTERFACE_ON ();
1572 return CMD_SUCCESS;
1573}
1574
1575DEFUN (no_debug_ospf6_interface,
1576 no_debug_ospf6_interface_cmd,
1577 "no debug ospf6 interface",
1578 NO_STR
1579 DEBUG_STR
1580 OSPF6_STR
1581 "Debug OSPFv3 Interface\n"
1582 )
1583{
hasso3b687352004-08-19 06:56:53 +00001584 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001585 return CMD_SUCCESS;
1586}
1587
1588int
1589config_write_ospf6_debug_interface (struct vty *vty)
1590{
1591 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001592 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001593 return 0;
1594}
1595
1596void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001597install_element_ospf6_debug_interface (void)
hasso508e53e2004-05-18 18:57:06 +00001598{
1599 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1600 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1601 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1602 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001603}
1604
1605