blob: 8a7ef1b018de249b87766de9efaa9de89b733fbf [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 +000074struct ospf6_interface *
75ospf6_interface_lookup_by_name (char *ifname)
paul718e3742002-12-13 20:15:29 +000076{
hasso508e53e2004-05-18 18:57:06 +000077 struct ospf6_interface *oi;
78 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +000079
hasso508e53e2004-05-18 18:57:06 +000080 ifp = if_lookup_by_name (ifname);
81 if (ifp == NULL)
82 return (struct ospf6_interface *) NULL;
paul718e3742002-12-13 20:15:29 +000083
hasso508e53e2004-05-18 18:57:06 +000084 oi = (struct ospf6_interface *) ifp->info;
85 return oi;
paul718e3742002-12-13 20:15:29 +000086}
87
hasso508e53e2004-05-18 18:57:06 +000088/* schedule routing table recalculation */
paul718e3742002-12-13 20:15:29 +000089void
hasso508e53e2004-05-18 18:57:06 +000090ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000091{
hasso508e53e2004-05-18 18:57:06 +000092 switch (ntohs (lsa->header->type))
93 {
94 case OSPF6_LSTYPE_LINK:
hasso6452df02004-08-15 05:52:07 +000095 if (OSPF6_INTERFACE (lsa->lsdb->data)->state == OSPF6_INTERFACE_DR)
96 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (OSPF6_INTERFACE (lsa->lsdb->data));
97 ospf6_spf_schedule (OSPF6_INTERFACE (lsa->lsdb->data)->area);
hasso508e53e2004-05-18 18:57:06 +000098 break;
paul718e3742002-12-13 20:15:29 +000099
hasso508e53e2004-05-18 18:57:06 +0000100 default:
hasso508e53e2004-05-18 18:57:06 +0000101 break;
102 }
paul718e3742002-12-13 20:15:29 +0000103}
104
105/* Create new ospf6 interface structure */
106struct ospf6_interface *
107ospf6_interface_create (struct interface *ifp)
108{
hasso508e53e2004-05-18 18:57:06 +0000109 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000110 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000111
hasso508e53e2004-05-18 18:57:06 +0000112 oi = (struct ospf6_interface *)
paul718e3742002-12-13 20:15:29 +0000113 XMALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
114
hasso508e53e2004-05-18 18:57:06 +0000115 if (oi)
116 memset (oi, 0, sizeof (struct ospf6_interface));
paul718e3742002-12-13 20:15:29 +0000117 else
118 {
119 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
120 return (struct ospf6_interface *) NULL;
121 }
122
hasso508e53e2004-05-18 18:57:06 +0000123 oi->area = (struct ospf6_area *) NULL;
124 oi->neighbor_list = list_new ();
125 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
126 oi->linklocal_addr = (struct in6_addr *) NULL;
127 oi->instance_id = 0;
128 oi->transdelay = 1;
129 oi->priority = 1;
paul718e3742002-12-13 20:15:29 +0000130
hasso508e53e2004-05-18 18:57:06 +0000131 oi->hello_interval = 10;
132 oi->dead_interval = 40;
133 oi->rxmt_interval = 5;
134 oi->cost = 1;
hasso508e53e2004-05-18 18:57:06 +0000135 oi->state = OSPF6_INTERFACE_DOWN;
136 oi->flag = 0;
paul718e3742002-12-13 20:15:29 +0000137
hassob596c712004-07-09 18:33:43 +0000138 /* Try to adjust I/O buffer size with IfMtu */
hasso1203e1c2004-07-23 21:34:27 +0000139 oi->ifmtu = ifp->mtu6;
140 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000141 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000142 {
hasso1e058382004-09-01 21:36:14 +0000143 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000144 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
145 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000146 oi->ifmtu = iobuflen;
147 }
hasso3b4cd3a2004-05-18 19:28:32 +0000148
hasso6452df02004-08-15 05:52:07 +0000149 oi->lsupdate_list = ospf6_lsdb_create (oi);
150 oi->lsack_list = ospf6_lsdb_create (oi);
151 oi->lsdb = ospf6_lsdb_create (oi);
hasso508e53e2004-05-18 18:57:06 +0000152 oi->lsdb->hook_add = ospf6_interface_lsdb_hook;
153 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook;
hasso6452df02004-08-15 05:52:07 +0000154 oi->lsdb_self = ospf6_lsdb_create (oi);
paul718e3742002-12-13 20:15:29 +0000155
hasso508e53e2004-05-18 18:57:06 +0000156 oi->route_connected = ospf6_route_table_create ();
paul718e3742002-12-13 20:15:29 +0000157
158 /* link both */
hasso508e53e2004-05-18 18:57:06 +0000159 oi->interface = ifp;
160 ifp->info = oi;
paul718e3742002-12-13 20:15:29 +0000161
hasso508e53e2004-05-18 18:57:06 +0000162 return oi;
paul718e3742002-12-13 20:15:29 +0000163}
164
165void
hasso508e53e2004-05-18 18:57:06 +0000166ospf6_interface_delete (struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000167{
hasso52dc7ee2004-09-23 19:18:23 +0000168 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +0000169 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000170
hasso508e53e2004-05-18 18:57:06 +0000171 for (n = listhead (oi->neighbor_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000172 {
hasso508e53e2004-05-18 18:57:06 +0000173 on = (struct ospf6_neighbor *) getdata (n);
174 ospf6_neighbor_delete (on);
paul718e3742002-12-13 20:15:29 +0000175 }
hasso508e53e2004-05-18 18:57:06 +0000176 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000177
hasso508e53e2004-05-18 18:57:06 +0000178 THREAD_OFF (oi->thread_send_hello);
179 THREAD_OFF (oi->thread_send_lsupdate);
180 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000181
hasso508e53e2004-05-18 18:57:06 +0000182 ospf6_lsdb_remove_all (oi->lsdb);
183 ospf6_lsdb_remove_all (oi->lsupdate_list);
184 ospf6_lsdb_remove_all (oi->lsack_list);
185
186 ospf6_lsdb_delete (oi->lsdb);
hasso6452df02004-08-15 05:52:07 +0000187 ospf6_lsdb_delete (oi->lsdb_self);
188
hasso508e53e2004-05-18 18:57:06 +0000189 ospf6_lsdb_delete (oi->lsupdate_list);
190 ospf6_lsdb_delete (oi->lsack_list);
191
192 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000193
194 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000195 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000196
197 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000198 if (oi->plist_name)
199 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000200
hasso508e53e2004-05-18 18:57:06 +0000201 XFREE (MTYPE_OSPF6_IF, oi);
202}
203
204void
205ospf6_interface_enable (struct ospf6_interface *oi)
206{
207 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
208
209 oi->thread_send_hello =
210 thread_add_event (master, ospf6_hello_send, oi, 0);
211}
212
213void
214ospf6_interface_disable (struct ospf6_interface *oi)
215{
hasso52dc7ee2004-09-23 19:18:23 +0000216 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000217 struct ospf6_neighbor *on;
218
219 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
220
221 for (i = listhead (oi->neighbor_list); i; nextnode (i))
222 {
223 on = (struct ospf6_neighbor *) getdata (i);
224 ospf6_neighbor_delete (on);
225 }
226 list_delete_all_node (oi->neighbor_list);
227
228 ospf6_lsdb_remove_all (oi->lsdb);
229 ospf6_lsdb_remove_all (oi->lsupdate_list);
230 ospf6_lsdb_remove_all (oi->lsack_list);
231
232 THREAD_OFF (oi->thread_send_hello);
233 THREAD_OFF (oi->thread_send_lsupdate);
234 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000235}
236
237static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000238ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000239{
hasso52dc7ee2004-09-23 19:18:23 +0000240 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000241 struct connected *c;
242 struct in6_addr *l = (struct in6_addr *) NULL;
243
244 /* for each connected address */
245 for (n = listhead (ifp->connected); n; nextnode (n))
246 {
247 c = (struct connected *) getdata (n);
248
249 /* if family not AF_INET6, ignore */
250 if (c->address->family != AF_INET6)
251 continue;
252
253 /* linklocal scope check */
254 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
255 l = &c->address->u.prefix6;
256 }
257 return l;
258}
259
260void
261ospf6_interface_if_add (struct interface *ifp)
262{
hasso508e53e2004-05-18 18:57:06 +0000263 struct ospf6_interface *oi;
paul0c083ee2004-10-10 12:54:58 +0000264 unsigned int iobuflen;
paul718e3742002-12-13 20:15:29 +0000265
hasso508e53e2004-05-18 18:57:06 +0000266 oi = (struct ospf6_interface *) ifp->info;
267 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000268 return;
269
hassob596c712004-07-09 18:33:43 +0000270 /* Try to adjust I/O buffer size with IfMtu */
271 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000272 oi->ifmtu = ifp->mtu6;
273 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000274 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000275 {
hasso1e058382004-09-01 21:36:14 +0000276 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000277 zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
278 ifp->name, iobuflen);
hasso3b4cd3a2004-05-18 19:28:32 +0000279 oi->ifmtu = iobuflen;
280 }
paul718e3742002-12-13 20:15:29 +0000281
282 /* interface start */
hasso508e53e2004-05-18 18:57:06 +0000283 if (oi->area)
284 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000285}
286
287void
288ospf6_interface_if_del (struct interface *ifp)
289{
hasso508e53e2004-05-18 18:57:06 +0000290 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000291
hasso508e53e2004-05-18 18:57:06 +0000292 oi = (struct ospf6_interface *) ifp->info;
293 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000294 return;
295
296 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000297 if (oi->area)
298 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000299
hasso508e53e2004-05-18 18:57:06 +0000300 listnode_delete (oi->area->if_list, oi);
301 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000302
303 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000304 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000305 ifp->info = NULL;
306
hasso508e53e2004-05-18 18:57:06 +0000307 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000308}
309
310void
311ospf6_interface_state_update (struct interface *ifp)
312{
hasso508e53e2004-05-18 18:57:06 +0000313 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000314
hasso508e53e2004-05-18 18:57:06 +0000315 oi = (struct ospf6_interface *) ifp->info;
316 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000317 return;
hasso508e53e2004-05-18 18:57:06 +0000318 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000319 return;
320
321 if (if_is_up (ifp))
hasso508e53e2004-05-18 18:57:06 +0000322 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000323 else
hasso508e53e2004-05-18 18:57:06 +0000324 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000325
326 return;
327}
328
329void
hasso508e53e2004-05-18 18:57:06 +0000330ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000331{
hasso508e53e2004-05-18 18:57:06 +0000332 struct ospf6_interface *oi;
333 struct ospf6_route *route;
334 struct connected *c;
hasso52dc7ee2004-09-23 19:18:23 +0000335 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000336
hasso508e53e2004-05-18 18:57:06 +0000337 oi = (struct ospf6_interface *) ifp->info;
338 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000339 return;
340
341 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000342 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000343
hasso508e53e2004-05-18 18:57:06 +0000344 /* if area is null, do not make connected-route list */
345 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000346 return;
347
hasso508e53e2004-05-18 18:57:06 +0000348 /* update "route to advertise" interface route table */
349 ospf6_route_remove_all (oi->route_connected);
350 for (i = listhead (oi->interface->connected); i; nextnode (i))
351 {
352 c = (struct connected *) getdata (i);
353
354 if (c->address->family != AF_INET6)
355 continue;
356
hasso1e058382004-09-01 21:36:14 +0000357 CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
358 CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
359 CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
360 CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
361 CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
hasso508e53e2004-05-18 18:57:06 +0000362
363 /* apply filter */
364 if (oi->plist_name)
365 {
366 struct prefix_list *plist;
367 enum prefix_list_type ret;
368 char buf[128];
369
370 prefix2str (c->address, buf, sizeof (buf));
371 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
372 ret = prefix_list_apply (plist, (void *) c->address);
373 if (ret == PREFIX_DENY)
374 {
hasso1e058382004-09-01 21:36:14 +0000375 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000376 zlog_debug ("%s on %s filtered by prefix-list %s ",
377 buf, oi->interface->name, oi->plist_name);
hasso508e53e2004-05-18 18:57:06 +0000378 continue;
379 }
380 }
381
382 route = ospf6_route_create ();
383 memcpy (&route->prefix, c->address, sizeof (struct prefix));
384 apply_mask (&route->prefix);
385 route->type = OSPF6_DEST_TYPE_NETWORK;
386 route->path.area_id = oi->area->area_id;
387 route->path.type = OSPF6_PATH_TYPE_INTRA;
388 route->path.cost = oi->cost;
389 route->nexthop[0].ifindex = oi->interface->ifindex;
390 inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
391 ospf6_route_add (route, oi->route_connected);
392 }
393
paul718e3742002-12-13 20:15:29 +0000394 /* create new Link-LSA */
hasso508e53e2004-05-18 18:57:06 +0000395 OSPF6_LINK_LSA_SCHEDULE (oi);
396 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
397 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000398}
399
hasso508e53e2004-05-18 18:57:06 +0000400static void
401ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000402{
hasso508e53e2004-05-18 18:57:06 +0000403 u_char prev_state;
paul718e3742002-12-13 20:15:29 +0000404
hasso508e53e2004-05-18 18:57:06 +0000405 prev_state = oi->state;
406 oi->state = next_state;
paul718e3742002-12-13 20:15:29 +0000407
hasso508e53e2004-05-18 18:57:06 +0000408 if (prev_state == next_state)
409 return;
paul718e3742002-12-13 20:15:29 +0000410
hasso508e53e2004-05-18 18:57:06 +0000411 /* log */
412 if (IS_OSPF6_DEBUG_INTERFACE)
paul718e3742002-12-13 20:15:29 +0000413 {
hassoc6487d62004-12-24 06:00:11 +0000414 zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
415 ospf6_interface_state_str[prev_state],
416 ospf6_interface_state_str[next_state]);
paul718e3742002-12-13 20:15:29 +0000417 }
paul718e3742002-12-13 20:15:29 +0000418
hasso508e53e2004-05-18 18:57:06 +0000419 if ((prev_state == OSPF6_INTERFACE_DR ||
420 prev_state == OSPF6_INTERFACE_BDR) &&
421 (next_state != OSPF6_INTERFACE_DR &&
422 next_state != OSPF6_INTERFACE_BDR))
423 ospf6_leave_alldrouters (oi->interface->ifindex);
424 if ((prev_state != OSPF6_INTERFACE_DR &&
425 prev_state != OSPF6_INTERFACE_BDR) &&
426 (next_state == OSPF6_INTERFACE_DR ||
427 next_state == OSPF6_INTERFACE_BDR))
428 ospf6_join_alldrouters (oi->interface->ifindex);
paul718e3742002-12-13 20:15:29 +0000429
hasso508e53e2004-05-18 18:57:06 +0000430 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
hasso6452df02004-08-15 05:52:07 +0000431 if (next_state == OSPF6_INTERFACE_DOWN)
432 {
433 OSPF6_NETWORK_LSA_EXECUTE (oi);
434 OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
435 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
436 }
437 else if (prev_state == OSPF6_INTERFACE_DR ||
438 next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000439 {
hasso508e53e2004-05-18 18:57:06 +0000440 OSPF6_NETWORK_LSA_SCHEDULE (oi);
441 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
442 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000443 }
hasso508e53e2004-05-18 18:57:06 +0000444}
445
446
447/* DR Election, RFC2328 section 9.4 */
448
449#define IS_ELIGIBLE(n) \
450 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
451
452static struct ospf6_neighbor *
453better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
454{
455 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
456 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
457 return NULL;
458 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
459 return b;
460 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
461 return a;
462
463 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
464 return a;
465 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
466 return b;
467
468 if (a->priority > b->priority)
469 return a;
470 if (a->priority < b->priority)
471 return b;
472
473 if (ntohl (a->router_id) > ntohl (b->router_id))
474 return a;
475 if (ntohl (a->router_id) < ntohl (b->router_id))
476 return b;
477
478 zlog_warn ("Router-ID duplicate ?");
479 return a;
480}
481
482static struct ospf6_neighbor *
483better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
484{
485 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
486 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
487 return NULL;
488 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
489 return b;
490 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
491 return a;
492
493 if (a->drouter == a->router_id && b->drouter != b->router_id)
494 return a;
495 if (a->drouter != a->router_id && b->drouter == b->router_id)
496 return b;
497
498 if (a->priority > b->priority)
499 return a;
500 if (a->priority < b->priority)
501 return b;
502
503 if (ntohl (a->router_id) > ntohl (b->router_id))
504 return a;
505 if (ntohl (a->router_id) < ntohl (b->router_id))
506 return b;
507
508 zlog_warn ("Router-ID duplicate ?");
509 return a;
510}
511
512static u_char
513dr_election (struct ospf6_interface *oi)
514{
hasso52dc7ee2004-09-23 19:18:23 +0000515 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000516 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
517 struct ospf6_neighbor *best_drouter, *best_bdrouter;
518 u_char next_state = 0;
519
520 drouter = bdrouter = NULL;
521 best_drouter = best_bdrouter = NULL;
522
523 /* pseudo neighbor myself, including noting current DR/BDR (1) */
524 memset (&myself, 0, sizeof (myself));
525 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
526 sizeof (myself.name));
527 myself.state = OSPF6_NEIGHBOR_TWOWAY;
528 myself.drouter = oi->drouter;
529 myself.bdrouter = oi->bdrouter;
530 myself.priority = oi->priority;
531 myself.router_id = oi->area->ospf6->router_id;
532
533 /* Electing BDR (2) */
534 for (i = listhead (oi->neighbor_list); i; nextnode (i))
535 {
536 on = (struct ospf6_neighbor *) getdata (i);
537 bdrouter = better_bdrouter (bdrouter, on);
538 }
539 best_bdrouter = bdrouter;
540 bdrouter = better_bdrouter (best_bdrouter, &myself);
541
542 /* Electing DR (3) */
543 for (i = listhead (oi->neighbor_list); i; nextnode (i))
544 {
545 on = (struct ospf6_neighbor *) getdata (i);
546 drouter = better_drouter (drouter, on);
547 }
548 best_drouter = drouter;
549 drouter = better_drouter (best_drouter, &myself);
550 if (drouter == NULL)
551 drouter = bdrouter;
552
553 /* the router itself is newly/no longer DR/BDR (4) */
554 if ((drouter == &myself && myself.drouter != myself.router_id) ||
555 (drouter != &myself && myself.drouter == myself.router_id) ||
556 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
557 (bdrouter != &myself && myself.bdrouter == myself.router_id))
558 {
559 myself.drouter = (drouter ? drouter->router_id : htonl (0));
560 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
561
562 /* compatible to Electing BDR (2) */
563 bdrouter = better_bdrouter (best_bdrouter, &myself);
564
565 /* compatible to Electing DR (3) */
566 drouter = better_drouter (best_drouter, &myself);
567 if (drouter == NULL)
568 drouter = bdrouter;
569 }
570
571 /* Set interface state accordingly (5) */
572 if (drouter && drouter == &myself)
573 next_state = OSPF6_INTERFACE_DR;
574 else if (bdrouter && bdrouter == &myself)
575 next_state = OSPF6_INTERFACE_BDR;
576 else
577 next_state = OSPF6_INTERFACE_DROTHER;
578
579 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
580 /* XXX */
581
582 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
583 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
584 accordingly after AdjOK */
585 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
586 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
587 {
588 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000589 zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
590 (drouter ? drouter->name : "0.0.0.0"),
591 (bdrouter ? bdrouter->name : "0.0.0.0"));
hasso508e53e2004-05-18 18:57:06 +0000592
593 for (i = listhead (oi->neighbor_list); i; nextnode (i))
594 {
595 on = (struct ospf6_neighbor *) getdata (i);
596 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
597 continue;
598 /* Schedule AdjOK. */
599 thread_add_event (master, adj_ok, on, 0);
600 }
601 }
602
603 oi->drouter = (drouter ? drouter->router_id : htonl (0));
604 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
605 return next_state;
606}
607
608
609/* Interface State Machine */
610int
611interface_up (struct thread *thread)
612{
613 struct ospf6_interface *oi;
614
615 oi = (struct ospf6_interface *) THREAD_ARG (thread);
616 assert (oi && oi->interface);
617
618 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000619 zlog_debug ("Interface Event %s: [InterfaceUp]",
620 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000621
622 /* check physical interface is up */
623 if (! if_is_up (oi->interface))
624 {
625 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000626 zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
627 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000628 return 0;
629 }
630
631 /* if already enabled, do nothing */
632 if (oi->state > OSPF6_INTERFACE_DOWN)
633 {
634 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000635 zlog_debug ("Interface %s already enabled",
636 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000637 return 0;
638 }
639
640 /* Join AllSPFRouters */
641 ospf6_join_allspfrouters (oi->interface->ifindex);
642
643 /* Update interface route */
644 ospf6_interface_connected_route_update (oi->interface);
645
646 /* Schedule Hello */
647 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
648 thread_add_event (master, ospf6_hello_send, oi, 0);
649
650 /* decide next interface state */
651 if (if_is_pointopoint (oi->interface))
652 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
653 else if (oi->priority == 0)
654 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
655 else
656 {
657 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
658 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
659 }
660
661 return 0;
paul718e3742002-12-13 20:15:29 +0000662}
663
664int
hasso508e53e2004-05-18 18:57:06 +0000665wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000666{
hasso508e53e2004-05-18 18:57:06 +0000667 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000668
hasso508e53e2004-05-18 18:57:06 +0000669 oi = (struct ospf6_interface *) THREAD_ARG (thread);
670 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000671
hasso508e53e2004-05-18 18:57:06 +0000672 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000673 zlog_debug ("Interface Event %s: [WaitTimer]",
674 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000675
hasso508e53e2004-05-18 18:57:06 +0000676 if (oi->state == OSPF6_INTERFACE_WAITING)
677 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000678
hasso508e53e2004-05-18 18:57:06 +0000679 return 0;
paul718e3742002-12-13 20:15:29 +0000680}
681
hasso508e53e2004-05-18 18:57:06 +0000682int
683backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000684{
hasso508e53e2004-05-18 18:57:06 +0000685 struct ospf6_interface *oi;
686
687 oi = (struct ospf6_interface *) THREAD_ARG (thread);
688 assert (oi && oi->interface);
689
690 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000691 zlog_debug ("Interface Event %s: [BackupSeen]",
692 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000693
694 if (oi->state == OSPF6_INTERFACE_WAITING)
695 ospf6_interface_state_change (dr_election (oi), oi);
696
697 return 0;
paul718e3742002-12-13 20:15:29 +0000698}
699
hasso508e53e2004-05-18 18:57:06 +0000700int
701neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000702{
hasso508e53e2004-05-18 18:57:06 +0000703 struct ospf6_interface *oi;
704
705 oi = (struct ospf6_interface *) THREAD_ARG (thread);
706 assert (oi && oi->interface);
707
708 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000709 zlog_debug ("Interface Event %s: [NeighborChange]",
710 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000711
712 if (oi->state == OSPF6_INTERFACE_DROTHER ||
713 oi->state == OSPF6_INTERFACE_BDR ||
714 oi->state == OSPF6_INTERFACE_DR)
715 ospf6_interface_state_change (dr_election (oi), oi);
716
717 return 0;
paul718e3742002-12-13 20:15:29 +0000718}
719
hasso508e53e2004-05-18 18:57:06 +0000720int
721loopind (struct thread *thread)
722{
723 struct ospf6_interface *oi;
724
725 oi = (struct ospf6_interface *) THREAD_ARG (thread);
726 assert (oi && oi->interface);
727
728 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000729 zlog_debug ("Interface Event %s: [LoopInd]",
730 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000731
732 /* XXX not yet */
733
734 return 0;
735}
736
737int
738interface_down (struct thread *thread)
739{
740 struct ospf6_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +0000741 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +0000742 struct ospf6_neighbor *on;
743
744 oi = (struct ospf6_interface *) THREAD_ARG (thread);
745 assert (oi && oi->interface);
746
747 if (IS_OSPF6_DEBUG_INTERFACE)
hassoc6487d62004-12-24 06:00:11 +0000748 zlog_debug ("Interface Event %s: [InterfaceDown]",
749 oi->interface->name);
hasso508e53e2004-05-18 18:57:06 +0000750
751 /* Leave AllSPFRouters */
752 if (oi->state > OSPF6_INTERFACE_DOWN)
753 ospf6_leave_allspfrouters (oi->interface->ifindex);
754
755 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
756
757 for (n = listhead (oi->neighbor_list); n; nextnode (n))
758 {
759 on = (struct ospf6_neighbor *) getdata (n);
760 ospf6_neighbor_delete (on);
761 }
762 list_delete_all_node (oi->neighbor_list);
763
764 return 0;
765}
766
767
paul718e3742002-12-13 20:15:29 +0000768/* show specified interface structure */
769int
hasso508e53e2004-05-18 18:57:06 +0000770ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000771{
hasso508e53e2004-05-18 18:57:06 +0000772 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000773 struct connected *c;
774 struct prefix *p;
hasso52dc7ee2004-09-23 19:18:23 +0000775 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000776 char strbuf[64], drouter[32], bdrouter[32];
paul0c083ee2004-10-10 12:54:58 +0000777 const char *updown[3] = {"down", "up", NULL};
778 const char *type;
hasso508e53e2004-05-18 18:57:06 +0000779 struct timeval res, now;
780 char duration[32];
781 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000782
783 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000784 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000785 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000786 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000787 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000788 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000789 type = "POINTOPOINT";
790 else
791 type = "UNKNOWN";
792
793 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000794 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000795 VNL);
796 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000797
hasso508e53e2004-05-18 18:57:06 +0000798 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000799 {
hasso049207c2004-08-04 20:02:13 +0000800 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000801 return 0;
802 }
803 else
hasso508e53e2004-05-18 18:57:06 +0000804 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000805
hasso049207c2004-08-04 20:02:13 +0000806 vty_out (vty, " Internet Address:%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000807 for (i = listhead (ifp->connected); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000808 {
809 c = (struct connected *)getdata (i);
810 p = c->address;
811 prefix2str (p, strbuf, sizeof (strbuf));
812 switch (p->family)
813 {
814 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000815 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000816 VNL);
paul718e3742002-12-13 20:15:29 +0000817 break;
818 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000819 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000820 VNL);
paul718e3742002-12-13 20:15:29 +0000821 break;
822 default:
hasso508e53e2004-05-18 18:57:06 +0000823 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000824 VNL);
paul718e3742002-12-13 20:15:29 +0000825 break;
826 }
827 }
828
hasso508e53e2004-05-18 18:57:06 +0000829 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000830 {
hasso508e53e2004-05-18 18:57:06 +0000831 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000832 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
hasso508e53e2004-05-18 18:57:06 +0000833 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000834 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000835 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000836 VNL);
paul718e3742002-12-13 20:15:29 +0000837 }
838 else
hasso049207c2004-08-04 20:02:13 +0000839 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000840
841 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000842 ospf6_interface_state_str[oi->state],
843 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000844 VNL);
845 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000846 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000847 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000848 VNL);
paul718e3742002-12-13 20:15:29 +0000849
hasso508e53e2004-05-18 18:57:06 +0000850 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
851 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000852 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000853
854 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000855 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000856
857 gettimeofday (&now, (struct timezone *) NULL);
paul718e3742002-12-13 20:15:29 +0000858
hasso508e53e2004-05-18 18:57:06 +0000859 timerclear (&res);
860 if (oi->thread_send_lsupdate)
861 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
862 timerstring (&res, duration, sizeof (duration));
863 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
864 oi->lsupdate_list->count, duration,
865 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000866 VNL);
hasso508e53e2004-05-18 18:57:06 +0000867 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
868 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000869 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000870
hasso508e53e2004-05-18 18:57:06 +0000871 timerclear (&res);
872 if (oi->thread_send_lsack)
873 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
874 timerstring (&res, duration, sizeof (duration));
875 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
876 oi->lsack_list->count, duration,
877 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000878 VNL);
hasso508e53e2004-05-18 18:57:06 +0000879 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
880 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000881 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000882
hasso508e53e2004-05-18 18:57:06 +0000883 return 0;
paul718e3742002-12-13 20:15:29 +0000884}
885
886/* show interface */
887DEFUN (show_ipv6_ospf6_interface,
888 show_ipv6_ospf6_interface_ifname_cmd,
889 "show ipv6 ospf6 interface IFNAME",
890 SHOW_STR
891 IP6_STR
892 OSPF6_STR
893 INTERFACE_STR
894 IFNAME_STR
895 )
896{
897 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000898 struct listnode *i;
paul718e3742002-12-13 20:15:29 +0000899
900 if (argc)
901 {
902 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000903 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000904 {
905 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000906 VNL);
paul718e3742002-12-13 20:15:29 +0000907 return CMD_WARNING;
908 }
909 ospf6_interface_show (vty, ifp);
910 }
911 else
912 {
913 for (i = listhead (iflist); i; nextnode (i))
914 {
hasso508e53e2004-05-18 18:57:06 +0000915 ifp = (struct interface *) getdata (i);
paul718e3742002-12-13 20:15:29 +0000916 ospf6_interface_show (vty, ifp);
917 }
918 }
hasso508e53e2004-05-18 18:57:06 +0000919
paul718e3742002-12-13 20:15:29 +0000920 return CMD_SUCCESS;
921}
922
923ALIAS (show_ipv6_ospf6_interface,
924 show_ipv6_ospf6_interface_cmd,
925 "show ipv6 ospf6 interface",
926 SHOW_STR
927 IP6_STR
928 OSPF6_STR
929 INTERFACE_STR
hasso508e53e2004-05-18 18:57:06 +0000930 );
paul718e3742002-12-13 20:15:29 +0000931
hasso508e53e2004-05-18 18:57:06 +0000932DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
933 show_ipv6_ospf6_interface_ifname_prefix_cmd,
934 "show ipv6 ospf6 interface IFNAME prefix",
935 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000936 IP6_STR
937 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000938 INTERFACE_STR
939 IFNAME_STR
940 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000941 )
942{
paul718e3742002-12-13 20:15:29 +0000943 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000944 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000945
hasso508e53e2004-05-18 18:57:06 +0000946 ifp = if_lookup_by_name (argv[0]);
947 if (ifp == NULL)
948 {
hasso049207c2004-08-04 20:02:13 +0000949 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000950 return CMD_WARNING;
951 }
paul718e3742002-12-13 20:15:29 +0000952
hasso508e53e2004-05-18 18:57:06 +0000953 oi = ifp->info;
954 if (oi == NULL)
955 {
hasso049207c2004-08-04 20:02:13 +0000956 vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000957 return CMD_WARNING;
958 }
paul718e3742002-12-13 20:15:29 +0000959
hasso508e53e2004-05-18 18:57:06 +0000960 argc--;
961 argv++;
962 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000963
964 return CMD_SUCCESS;
965}
966
hasso508e53e2004-05-18 18:57:06 +0000967ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
968 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
969 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
970 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000971 IP6_STR
972 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000973 INTERFACE_STR
974 IFNAME_STR
975 "Display connected prefixes to advertise\n"
976 OSPF6_ROUTE_ADDRESS_STR
977 OSPF6_ROUTE_PREFIX_STR
978 "Dispaly details of the prefixes\n"
979 );
980
981ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
982 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
983 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
984 SHOW_STR
985 IP6_STR
986 OSPF6_STR
987 INTERFACE_STR
988 IFNAME_STR
989 "Display connected prefixes to advertise\n"
990 OSPF6_ROUTE_PREFIX_STR
991 OSPF6_ROUTE_MATCH_STR
992 "Dispaly details of the prefixes\n"
993 );
994
995DEFUN (show_ipv6_ospf6_interface_prefix,
996 show_ipv6_ospf6_interface_prefix_cmd,
997 "show ipv6 ospf6 interface prefix",
998 SHOW_STR
999 IP6_STR
1000 OSPF6_STR
1001 INTERFACE_STR
1002 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +00001003 )
1004{
hasso52dc7ee2004-09-23 19:18:23 +00001005 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001006 struct ospf6_interface *oi;
1007 struct interface *ifp;
1008
1009 for (i = listhead (iflist); i; nextnode (i))
1010 {
1011 ifp = (struct interface *) getdata (i);
1012 oi = (struct ospf6_interface *) ifp->info;
1013 if (oi == NULL)
1014 continue;
1015
1016 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1017 }
1018
1019 return CMD_SUCCESS;
1020}
1021
1022ALIAS (show_ipv6_ospf6_interface_prefix,
1023 show_ipv6_ospf6_interface_prefix_detail_cmd,
1024 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1025 SHOW_STR
1026 IP6_STR
1027 OSPF6_STR
1028 INTERFACE_STR
1029 "Display connected prefixes to advertise\n"
1030 OSPF6_ROUTE_ADDRESS_STR
1031 OSPF6_ROUTE_PREFIX_STR
1032 "Dispaly details of the prefixes\n"
1033 );
1034
1035ALIAS (show_ipv6_ospf6_interface_prefix,
1036 show_ipv6_ospf6_interface_prefix_match_cmd,
1037 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1038 SHOW_STR
1039 IP6_STR
1040 OSPF6_STR
1041 INTERFACE_STR
1042 "Display connected prefixes to advertise\n"
1043 OSPF6_ROUTE_PREFIX_STR
1044 OSPF6_ROUTE_MATCH_STR
1045 "Dispaly details of the prefixes\n"
1046 );
1047
1048
1049/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001050DEFUN (ipv6_ospf6_ifmtu,
1051 ipv6_ospf6_ifmtu_cmd,
1052 "ipv6 ospf6 ifmtu <1-65535>",
1053 IP6_STR
1054 OSPF6_STR
1055 "Interface MTU\n"
1056 "OSPFv3 Interface MTU\n"
1057 )
1058{
1059 struct ospf6_interface *oi;
1060 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001061 unsigned int ifmtu, iobuflen;
hasso52dc7ee2004-09-23 19:18:23 +00001062 struct listnode *node;
hassob596c712004-07-09 18:33:43 +00001063 struct ospf6_neighbor *on;
1064
1065 ifp = (struct interface *) vty->index;
1066 assert (ifp);
1067
1068 oi = (struct ospf6_interface *) ifp->info;
1069 if (oi == NULL)
1070 oi = ospf6_interface_create (ifp);
1071 assert (oi);
1072
1073 ifmtu = strtol (argv[0], NULL, 10);
1074
1075 if (oi->ifmtu == ifmtu)
1076 return CMD_SUCCESS;
1077
hasso1203e1c2004-07-23 21:34:27 +00001078 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001079 {
1080 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001081 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001082 return CMD_WARNING;
1083 }
1084
1085 if (oi->ifmtu < ifmtu)
1086 {
1087 iobuflen = ospf6_iobuf_size (ifmtu);
1088 if (iobuflen < ifmtu)
1089 {
1090 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001091 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001092 oi->ifmtu = iobuflen;
1093 }
1094 else
1095 oi->ifmtu = ifmtu;
1096 }
1097 else
1098 oi->ifmtu = ifmtu;
1099
1100 /* re-establish adjacencies */
1101 for (node = listhead (oi->neighbor_list); node; nextnode (node))
1102 {
1103 on = (struct ospf6_neighbor *) getdata (node);
1104 THREAD_OFF (on->inactivity_timer);
1105 thread_execute (master, inactivity_timer, on, 0);
1106 }
1107
1108 return CMD_SUCCESS;
1109}
1110
hasso049207c2004-08-04 20:02:13 +00001111DEFUN (no_ipv6_ospf6_ifmtu,
1112 no_ipv6_ospf6_ifmtu_cmd,
1113 "no ipv6 ospf6 ifmtu",
1114 NO_STR
1115 IP6_STR
1116 OSPF6_STR
1117 "Interface MTU\n"
1118 )
1119{
1120 struct ospf6_interface *oi;
1121 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001122 unsigned int iobuflen;
hasso52dc7ee2004-09-23 19:18:23 +00001123 struct listnode *node;
hasso049207c2004-08-04 20:02:13 +00001124 struct ospf6_neighbor *on;
1125
1126 ifp = (struct interface *) vty->index;
1127 assert (ifp);
1128
1129 oi = (struct ospf6_interface *) ifp->info;
1130 if (oi == NULL)
1131 oi = ospf6_interface_create (ifp);
1132 assert (oi);
1133
1134 if (oi->ifmtu < ifp->mtu)
1135 {
1136 iobuflen = ospf6_iobuf_size (ifp->mtu);
1137 if (iobuflen < ifp->mtu)
1138 {
1139 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1140 ifp->name, iobuflen, VNL);
1141 oi->ifmtu = iobuflen;
1142 }
1143 else
1144 oi->ifmtu = ifp->mtu;
1145 }
1146 else
1147 oi->ifmtu = ifp->mtu;
1148
1149 /* re-establish adjacencies */
1150 for (node = listhead (oi->neighbor_list); node; nextnode (node))
1151 {
1152 on = (struct ospf6_neighbor *) getdata (node);
1153 THREAD_OFF (on->inactivity_timer);
1154 thread_execute (master, inactivity_timer, on, 0);
1155 }
1156
1157 return CMD_SUCCESS;
1158}
1159
hasso508e53e2004-05-18 18:57:06 +00001160DEFUN (ipv6_ospf6_cost,
1161 ipv6_ospf6_cost_cmd,
1162 "ipv6 ospf6 cost <1-65535>",
1163 IP6_STR
1164 OSPF6_STR
1165 "Interface cost\n"
1166 "Outgoing metric of this interface\n"
1167 )
1168{
1169 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001170 struct interface *ifp;
paul0c083ee2004-10-10 12:54:58 +00001171 unsigned long int lcost;
paul718e3742002-12-13 20:15:29 +00001172
1173 ifp = (struct interface *) vty->index;
1174 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001175
hasso508e53e2004-05-18 18:57:06 +00001176 oi = (struct ospf6_interface *) ifp->info;
1177 if (oi == NULL)
1178 oi = ospf6_interface_create (ifp);
1179 assert (oi);
1180
paul0c083ee2004-10-10 12:54:58 +00001181 lcost = strtol (argv[0], NULL, 10);
1182
1183 if (lcost > UINT32_MAX)
1184 {
1185 vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
1186 return CMD_WARNING;
1187 }
1188
1189 if (oi->cost == lcost)
hasso508e53e2004-05-18 18:57:06 +00001190 return CMD_SUCCESS;
paul0c083ee2004-10-10 12:54:58 +00001191
1192 oi->cost = lcost;
1193
hasso508e53e2004-05-18 18:57:06 +00001194 /* update cost held in route_connected list in ospf6_interface */
1195 ospf6_interface_connected_route_update (oi->interface);
1196
1197 /* execute LSA hooks */
1198 if (oi->area)
1199 {
1200 OSPF6_LINK_LSA_SCHEDULE (oi);
1201 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1202 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1203 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1204 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1205 }
1206
1207 return CMD_SUCCESS;
1208}
1209
1210DEFUN (ipv6_ospf6_hellointerval,
1211 ipv6_ospf6_hellointerval_cmd,
1212 "ipv6 ospf6 hello-interval <1-65535>",
1213 IP6_STR
1214 OSPF6_STR
1215 "Interval time of Hello packets\n"
1216 SECONDS_STR
1217 )
1218{
1219 struct ospf6_interface *oi;
1220 struct interface *ifp;
1221
1222 ifp = (struct interface *) vty->index;
1223 assert (ifp);
1224
1225 oi = (struct ospf6_interface *) ifp->info;
1226 if (oi == NULL)
1227 oi = ospf6_interface_create (ifp);
1228 assert (oi);
1229
1230 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001231 return CMD_SUCCESS;
1232}
1233
1234/* interface variable set command */
1235DEFUN (ipv6_ospf6_deadinterval,
1236 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001237 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001238 IP6_STR
1239 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001240 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001241 SECONDS_STR
1242 )
1243{
hasso508e53e2004-05-18 18:57:06 +00001244 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001245 struct interface *ifp;
1246
1247 ifp = (struct interface *) vty->index;
1248 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001249
hasso508e53e2004-05-18 18:57:06 +00001250 oi = (struct ospf6_interface *) ifp->info;
1251 if (oi == NULL)
1252 oi = ospf6_interface_create (ifp);
1253 assert (oi);
1254
1255 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001256 return CMD_SUCCESS;
1257}
1258
1259/* interface variable set command */
1260DEFUN (ipv6_ospf6_transmitdelay,
1261 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001262 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001263 IP6_STR
1264 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001265 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001266 SECONDS_STR
1267 )
1268{
hasso508e53e2004-05-18 18:57:06 +00001269 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001270 struct interface *ifp;
1271
1272 ifp = (struct interface *) vty->index;
1273 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001274
hasso508e53e2004-05-18 18:57:06 +00001275 oi = (struct ospf6_interface *) ifp->info;
1276 if (oi == NULL)
1277 oi = ospf6_interface_create (ifp);
1278 assert (oi);
1279
1280 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001281 return CMD_SUCCESS;
1282}
1283
1284/* interface variable set command */
1285DEFUN (ipv6_ospf6_retransmitinterval,
1286 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001287 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001288 IP6_STR
1289 OSPF6_STR
1290 "Time between retransmitting lost link state advertisements\n"
1291 SECONDS_STR
1292 )
1293{
hasso508e53e2004-05-18 18:57:06 +00001294 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001295 struct interface *ifp;
1296
1297 ifp = (struct interface *) vty->index;
1298 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001299
hasso508e53e2004-05-18 18:57:06 +00001300 oi = (struct ospf6_interface *) ifp->info;
1301 if (oi == NULL)
1302 oi = ospf6_interface_create (ifp);
1303 assert (oi);
1304
1305 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001306 return CMD_SUCCESS;
1307}
1308
1309/* interface variable set command */
1310DEFUN (ipv6_ospf6_priority,
1311 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001312 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001313 IP6_STR
1314 OSPF6_STR
1315 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001316 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001317 )
1318{
hasso508e53e2004-05-18 18:57:06 +00001319 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001320 struct interface *ifp;
1321
1322 ifp = (struct interface *) vty->index;
1323 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001324
hasso508e53e2004-05-18 18:57:06 +00001325 oi = (struct ospf6_interface *) ifp->info;
1326 if (oi == NULL)
1327 oi = ospf6_interface_create (ifp);
1328 assert (oi);
paul718e3742002-12-13 20:15:29 +00001329
hasso508e53e2004-05-18 18:57:06 +00001330 oi->priority = strtol (argv[0], NULL, 10);
1331
1332 if (oi->area)
1333 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001334
1335 return CMD_SUCCESS;
1336}
1337
1338DEFUN (ipv6_ospf6_instance,
1339 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001340 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001341 IP6_STR
1342 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001343 "Instance ID for this interface\n"
1344 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001345 )
1346{
hasso508e53e2004-05-18 18:57:06 +00001347 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001348 struct interface *ifp;
1349
1350 ifp = (struct interface *)vty->index;
1351 assert (ifp);
1352
hasso508e53e2004-05-18 18:57:06 +00001353 oi = (struct ospf6_interface *)ifp->info;
1354 if (oi == NULL)
1355 oi = ospf6_interface_create (ifp);
1356 assert (oi);
paul718e3742002-12-13 20:15:29 +00001357
hasso508e53e2004-05-18 18:57:06 +00001358 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001359 return CMD_SUCCESS;
1360}
1361
1362DEFUN (ipv6_ospf6_passive,
1363 ipv6_ospf6_passive_cmd,
1364 "ipv6 ospf6 passive",
1365 IP6_STR
1366 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001367 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001368 )
1369{
hasso508e53e2004-05-18 18:57:06 +00001370 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001371 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +00001372 struct listnode *node;
hasso508e53e2004-05-18 18:57:06 +00001373 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001374
1375 ifp = (struct interface *) vty->index;
1376 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001377
hasso508e53e2004-05-18 18:57:06 +00001378 oi = (struct ospf6_interface *) ifp->info;
1379 if (oi == NULL)
1380 oi = ospf6_interface_create (ifp);
1381 assert (oi);
paul718e3742002-12-13 20:15:29 +00001382
hasso508e53e2004-05-18 18:57:06 +00001383 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1384 THREAD_OFF (oi->thread_send_hello);
1385
1386 for (node = listhead (oi->neighbor_list); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001387 {
hasso508e53e2004-05-18 18:57:06 +00001388 on = (struct ospf6_neighbor *) getdata (node);
1389 THREAD_OFF (on->inactivity_timer);
1390 thread_execute (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001391 }
1392
1393 return CMD_SUCCESS;
1394}
1395
1396DEFUN (no_ipv6_ospf6_passive,
1397 no_ipv6_ospf6_passive_cmd,
1398 "no ipv6 ospf6 passive",
1399 NO_STR
1400 IP6_STR
1401 OSPF6_STR
1402 "passive interface: No Adjacency will be formed on this I/F\n"
1403 )
1404{
hasso508e53e2004-05-18 18:57:06 +00001405 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001406 struct interface *ifp;
1407
1408 ifp = (struct interface *) vty->index;
1409 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001410
hasso508e53e2004-05-18 18:57:06 +00001411 oi = (struct ospf6_interface *) ifp->info;
1412 if (oi == NULL)
1413 oi = ospf6_interface_create (ifp);
1414 assert (oi);
paul718e3742002-12-13 20:15:29 +00001415
hasso508e53e2004-05-18 18:57:06 +00001416 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1417 THREAD_OFF (oi->thread_send_hello);
1418 oi->thread_send_hello =
1419 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001420
1421 return CMD_SUCCESS;
1422}
1423
1424DEFUN (ipv6_ospf6_advertise_prefix_list,
1425 ipv6_ospf6_advertise_prefix_list_cmd,
1426 "ipv6 ospf6 advertise prefix-list WORD",
1427 IP6_STR
1428 OSPF6_STR
1429 "Advertising options\n"
1430 "Filter prefix using prefix-list\n"
1431 "Prefix list name\n"
1432 )
1433{
hasso508e53e2004-05-18 18:57:06 +00001434 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001435 struct interface *ifp;
1436
1437 ifp = (struct interface *) vty->index;
1438 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001439
hasso508e53e2004-05-18 18:57:06 +00001440 oi = (struct ospf6_interface *) ifp->info;
1441 if (oi == NULL)
1442 oi = ospf6_interface_create (ifp);
1443 assert (oi);
paul718e3742002-12-13 20:15:29 +00001444
hasso508e53e2004-05-18 18:57:06 +00001445 if (oi->plist_name)
1446 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1447 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001448
hasso508e53e2004-05-18 18:57:06 +00001449 ospf6_interface_connected_route_update (oi->interface);
1450 OSPF6_LINK_LSA_SCHEDULE (oi);
1451 if (oi->state == OSPF6_INTERFACE_DR)
1452 {
1453 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1454 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1455 }
1456 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001457
1458 return CMD_SUCCESS;
1459}
1460
1461DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1462 no_ipv6_ospf6_advertise_prefix_list_cmd,
1463 "no ipv6 ospf6 advertise prefix-list",
1464 NO_STR
1465 IP6_STR
1466 OSPF6_STR
1467 "Advertising options\n"
1468 "Filter prefix using prefix-list\n"
1469 )
1470{
hasso508e53e2004-05-18 18:57:06 +00001471 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001472 struct interface *ifp;
1473
1474 ifp = (struct interface *) vty->index;
1475 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001476
hasso508e53e2004-05-18 18:57:06 +00001477 oi = (struct ospf6_interface *) ifp->info;
1478 if (oi == NULL)
1479 oi = ospf6_interface_create (ifp);
1480 assert (oi);
1481
1482 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001483 {
hasso508e53e2004-05-18 18:57:06 +00001484 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1485 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001486 }
1487
hasso508e53e2004-05-18 18:57:06 +00001488 ospf6_interface_connected_route_update (oi->interface);
1489 OSPF6_LINK_LSA_SCHEDULE (oi);
1490 if (oi->state == OSPF6_INTERFACE_DR)
1491 {
1492 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1493 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1494 }
1495 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001496
1497 return CMD_SUCCESS;
1498}
1499
1500int
hasso508e53e2004-05-18 18:57:06 +00001501config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001502{
hasso52dc7ee2004-09-23 19:18:23 +00001503 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +00001504 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001505 struct interface *ifp;
1506
1507 for (i = listhead (iflist); i; nextnode (i))
1508 {
1509 ifp = (struct interface *) getdata (i);
hasso508e53e2004-05-18 18:57:06 +00001510 oi = (struct ospf6_interface *) ifp->info;
1511 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001512 continue;
1513
1514 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001515 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001516
1517 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001518 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso508e53e2004-05-18 18:57:06 +00001519
hasso1203e1c2004-07-23 21:34:27 +00001520 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001521 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
paul718e3742002-12-13 20:15:29 +00001522 vty_out (vty, " ipv6 ospf6 cost %d%s",
hasso049207c2004-08-04 20:02:13 +00001523 oi->cost, VNL);
paul718e3742002-12-13 20:15:29 +00001524 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001525 oi->hello_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001526 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001527 oi->dead_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001528 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001529 oi->rxmt_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001530 vty_out (vty, " ipv6 ospf6 priority %d%s",
hasso049207c2004-08-04 20:02:13 +00001531 oi->priority, VNL);
paul718e3742002-12-13 20:15:29 +00001532 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
hasso049207c2004-08-04 20:02:13 +00001533 oi->transdelay, VNL);
paul718e3742002-12-13 20:15:29 +00001534 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
hasso049207c2004-08-04 20:02:13 +00001535 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001536
hasso508e53e2004-05-18 18:57:06 +00001537 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001538 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001539 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001540
hasso508e53e2004-05-18 18:57:06 +00001541 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001542 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001543
hasso049207c2004-08-04 20:02:13 +00001544 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001545 }
1546 return 0;
1547}
1548
1549struct cmd_node interface_node =
1550{
1551 INTERFACE_NODE,
1552 "%s(config-if)# ",
hasso69b4a812004-08-26 18:10:36 +00001553 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001554};
1555
1556void
1557ospf6_interface_init ()
1558{
1559 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001560 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001561
1562 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001563 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1564 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1565 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001566 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001567 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1568 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1569 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001570 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001571 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1572 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1573 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001574 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001575 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1576 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1577 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001578
hasso508e53e2004-05-18 18:57:06 +00001579 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001580 install_default (INTERFACE_NODE);
1581 install_element (INTERFACE_NODE, &interface_desc_cmd);
1582 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1583 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001584 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001585 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001586 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1587 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1588 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1589 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1590 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1591 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001592
paul718e3742002-12-13 20:15:29 +00001593 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1594 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001595
1596 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1597 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1598}
1599
1600DEFUN (debug_ospf6_interface,
1601 debug_ospf6_interface_cmd,
1602 "debug ospf6 interface",
1603 DEBUG_STR
1604 OSPF6_STR
1605 "Debug OSPFv3 Interface\n"
1606 )
1607{
1608 OSPF6_DEBUG_INTERFACE_ON ();
1609 return CMD_SUCCESS;
1610}
1611
1612DEFUN (no_debug_ospf6_interface,
1613 no_debug_ospf6_interface_cmd,
1614 "no debug ospf6 interface",
1615 NO_STR
1616 DEBUG_STR
1617 OSPF6_STR
1618 "Debug OSPFv3 Interface\n"
1619 )
1620{
hasso3b687352004-08-19 06:56:53 +00001621 OSPF6_DEBUG_INTERFACE_OFF ();
hasso508e53e2004-05-18 18:57:06 +00001622 return CMD_SUCCESS;
1623}
1624
1625int
1626config_write_ospf6_debug_interface (struct vty *vty)
1627{
1628 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001629 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001630 return 0;
1631}
1632
1633void
1634install_element_ospf6_debug_interface ()
1635{
1636 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1637 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1638 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1639 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001640}
1641
1642