blob: ccacc237e7064c7dd0f97377637b110ab0364c9e [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
47char *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 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +000093
hasso508e53e2004-05-18 18:57:06 +000094 oi = (struct ospf6_interface *) lsa->scope;
95 switch (ntohs (lsa->header->type))
96 {
97 case OSPF6_LSTYPE_LINK:
98 if (oi->state == OSPF6_INTERFACE_DR)
99 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
100 ospf6_spf_schedule (oi->area);
101 break;
paul718e3742002-12-13 20:15:29 +0000102
hasso508e53e2004-05-18 18:57:06 +0000103 default:
104 if (IS_OSPF6_DEBUG_LSA (RECV))
105 zlog_info ("Unknown LSA in Interface %s's lsdb",
106 oi->interface->name);
107 break;
108 }
paul718e3742002-12-13 20:15:29 +0000109}
110
111/* Create new ospf6 interface structure */
112struct ospf6_interface *
113ospf6_interface_create (struct interface *ifp)
114{
hasso508e53e2004-05-18 18:57:06 +0000115 struct ospf6_interface *oi;
hasso3b4cd3a2004-05-18 19:28:32 +0000116 int iobuflen;
paul718e3742002-12-13 20:15:29 +0000117
hasso508e53e2004-05-18 18:57:06 +0000118 oi = (struct ospf6_interface *)
paul718e3742002-12-13 20:15:29 +0000119 XMALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
120
hasso508e53e2004-05-18 18:57:06 +0000121 if (oi)
122 memset (oi, 0, sizeof (struct ospf6_interface));
paul718e3742002-12-13 20:15:29 +0000123 else
124 {
125 zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
126 return (struct ospf6_interface *) NULL;
127 }
128
hasso508e53e2004-05-18 18:57:06 +0000129 oi->area = (struct ospf6_area *) NULL;
130 oi->neighbor_list = list_new ();
131 oi->neighbor_list->cmp = ospf6_neighbor_cmp;
132 oi->linklocal_addr = (struct in6_addr *) NULL;
133 oi->instance_id = 0;
134 oi->transdelay = 1;
135 oi->priority = 1;
paul718e3742002-12-13 20:15:29 +0000136
hasso508e53e2004-05-18 18:57:06 +0000137 oi->hello_interval = 10;
138 oi->dead_interval = 40;
139 oi->rxmt_interval = 5;
140 oi->cost = 1;
hasso508e53e2004-05-18 18:57:06 +0000141 oi->state = OSPF6_INTERFACE_DOWN;
142 oi->flag = 0;
paul718e3742002-12-13 20:15:29 +0000143
hassob596c712004-07-09 18:33:43 +0000144 /* Try to adjust I/O buffer size with IfMtu */
hasso1203e1c2004-07-23 21:34:27 +0000145 oi->ifmtu = ifp->mtu6;
146 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000147 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000148 {
149 zlog_info ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
150 ifp->name, iobuflen);
151 oi->ifmtu = iobuflen;
152 }
hasso3b4cd3a2004-05-18 19:28:32 +0000153
hasso508e53e2004-05-18 18:57:06 +0000154 oi->lsupdate_list = ospf6_lsdb_create ();
155 oi->lsack_list = ospf6_lsdb_create ();
156 oi->lsdb = ospf6_lsdb_create ();
157 oi->lsdb->hook_add = ospf6_interface_lsdb_hook;
158 oi->lsdb->hook_remove = ospf6_interface_lsdb_hook;
paul718e3742002-12-13 20:15:29 +0000159
hasso508e53e2004-05-18 18:57:06 +0000160 oi->route_connected = ospf6_route_table_create ();
paul718e3742002-12-13 20:15:29 +0000161
162 /* link both */
hasso508e53e2004-05-18 18:57:06 +0000163 oi->interface = ifp;
164 ifp->info = oi;
paul718e3742002-12-13 20:15:29 +0000165
hasso508e53e2004-05-18 18:57:06 +0000166 return oi;
paul718e3742002-12-13 20:15:29 +0000167}
168
169void
hasso508e53e2004-05-18 18:57:06 +0000170ospf6_interface_delete (struct ospf6_interface *oi)
paul718e3742002-12-13 20:15:29 +0000171{
172 listnode n;
hasso508e53e2004-05-18 18:57:06 +0000173 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +0000174
hasso508e53e2004-05-18 18:57:06 +0000175 for (n = listhead (oi->neighbor_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000176 {
hasso508e53e2004-05-18 18:57:06 +0000177 on = (struct ospf6_neighbor *) getdata (n);
178 ospf6_neighbor_delete (on);
paul718e3742002-12-13 20:15:29 +0000179 }
hasso508e53e2004-05-18 18:57:06 +0000180 list_delete (oi->neighbor_list);
paul718e3742002-12-13 20:15:29 +0000181
hasso508e53e2004-05-18 18:57:06 +0000182 THREAD_OFF (oi->thread_send_hello);
183 THREAD_OFF (oi->thread_send_lsupdate);
184 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000185
hasso508e53e2004-05-18 18:57:06 +0000186 ospf6_lsdb_remove_all (oi->lsdb);
187 ospf6_lsdb_remove_all (oi->lsupdate_list);
188 ospf6_lsdb_remove_all (oi->lsack_list);
189
190 ospf6_lsdb_delete (oi->lsdb);
191 ospf6_lsdb_delete (oi->lsupdate_list);
192 ospf6_lsdb_delete (oi->lsack_list);
193
194 ospf6_route_table_delete (oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000195
196 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000197 oi->interface->info = NULL;
paul718e3742002-12-13 20:15:29 +0000198
199 /* plist_name */
hasso508e53e2004-05-18 18:57:06 +0000200 if (oi->plist_name)
201 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
paul718e3742002-12-13 20:15:29 +0000202
hasso508e53e2004-05-18 18:57:06 +0000203 XFREE (MTYPE_OSPF6_IF, oi);
204}
205
206void
207ospf6_interface_enable (struct ospf6_interface *oi)
208{
209 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
210
211 oi->thread_send_hello =
212 thread_add_event (master, ospf6_hello_send, oi, 0);
213}
214
215void
216ospf6_interface_disable (struct ospf6_interface *oi)
217{
218 listnode i;
219 struct ospf6_neighbor *on;
220
221 SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
222
223 for (i = listhead (oi->neighbor_list); i; nextnode (i))
224 {
225 on = (struct ospf6_neighbor *) getdata (i);
226 ospf6_neighbor_delete (on);
227 }
228 list_delete_all_node (oi->neighbor_list);
229
230 ospf6_lsdb_remove_all (oi->lsdb);
231 ospf6_lsdb_remove_all (oi->lsupdate_list);
232 ospf6_lsdb_remove_all (oi->lsack_list);
233
234 THREAD_OFF (oi->thread_send_hello);
235 THREAD_OFF (oi->thread_send_lsupdate);
236 THREAD_OFF (oi->thread_send_lsack);
paul718e3742002-12-13 20:15:29 +0000237}
238
239static struct in6_addr *
hasso508e53e2004-05-18 18:57:06 +0000240ospf6_interface_get_linklocal_address (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000241{
242 listnode n;
243 struct connected *c;
244 struct in6_addr *l = (struct in6_addr *) NULL;
245
246 /* for each connected address */
247 for (n = listhead (ifp->connected); n; nextnode (n))
248 {
249 c = (struct connected *) getdata (n);
250
251 /* if family not AF_INET6, ignore */
252 if (c->address->family != AF_INET6)
253 continue;
254
255 /* linklocal scope check */
256 if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
257 l = &c->address->u.prefix6;
258 }
259 return l;
260}
261
262void
263ospf6_interface_if_add (struct interface *ifp)
264{
hasso508e53e2004-05-18 18:57:06 +0000265 struct ospf6_interface *oi;
hasso3b4cd3a2004-05-18 19:28:32 +0000266 int iobuflen;
paul718e3742002-12-13 20:15:29 +0000267
hasso508e53e2004-05-18 18:57:06 +0000268 oi = (struct ospf6_interface *) ifp->info;
269 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000270 return;
271
hassob596c712004-07-09 18:33:43 +0000272 /* Try to adjust I/O buffer size with IfMtu */
273 if (oi->ifmtu == 0)
hasso1203e1c2004-07-23 21:34:27 +0000274 oi->ifmtu = ifp->mtu6;
275 iobuflen = ospf6_iobuf_size (ifp->mtu6);
hassob596c712004-07-09 18:33:43 +0000276 if (oi->ifmtu > iobuflen)
hasso3b4cd3a2004-05-18 19:28:32 +0000277 {
278 zlog_info ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
279 ifp->name, iobuflen);
280 oi->ifmtu = iobuflen;
281 }
paul718e3742002-12-13 20:15:29 +0000282
283 /* interface start */
hasso508e53e2004-05-18 18:57:06 +0000284 if (oi->area)
285 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000286}
287
288void
289ospf6_interface_if_del (struct interface *ifp)
290{
hasso508e53e2004-05-18 18:57:06 +0000291 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000292
hasso508e53e2004-05-18 18:57:06 +0000293 oi = (struct ospf6_interface *) ifp->info;
294 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000295 return;
296
297 /* interface stop */
hasso508e53e2004-05-18 18:57:06 +0000298 if (oi->area)
299 thread_execute (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000300
hasso508e53e2004-05-18 18:57:06 +0000301 listnode_delete (oi->area->if_list, oi);
302 oi->area = (struct ospf6_area *) NULL;
paul718e3742002-12-13 20:15:29 +0000303
304 /* cut link */
hasso508e53e2004-05-18 18:57:06 +0000305 oi->interface = NULL;
paul718e3742002-12-13 20:15:29 +0000306 ifp->info = NULL;
307
hasso508e53e2004-05-18 18:57:06 +0000308 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000309}
310
311void
312ospf6_interface_state_update (struct interface *ifp)
313{
hasso508e53e2004-05-18 18:57:06 +0000314 struct ospf6_interface *oi;
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;
hasso508e53e2004-05-18 18:57:06 +0000319 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000320 return;
321
322 if (if_is_up (ifp))
hasso508e53e2004-05-18 18:57:06 +0000323 thread_add_event (master, interface_up, oi, 0);
paul718e3742002-12-13 20:15:29 +0000324 else
hasso508e53e2004-05-18 18:57:06 +0000325 thread_add_event (master, interface_down, oi, 0);
paul718e3742002-12-13 20:15:29 +0000326
327 return;
328}
329
330void
hasso508e53e2004-05-18 18:57:06 +0000331ospf6_interface_connected_route_update (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000332{
hasso508e53e2004-05-18 18:57:06 +0000333 struct ospf6_interface *oi;
334 struct ospf6_route *route;
335 struct connected *c;
336 listnode i;
paul718e3742002-12-13 20:15:29 +0000337
hasso508e53e2004-05-18 18:57:06 +0000338 oi = (struct ospf6_interface *) ifp->info;
339 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +0000340 return;
341
342 /* reset linklocal pointer */
hasso508e53e2004-05-18 18:57:06 +0000343 oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
paul718e3742002-12-13 20:15:29 +0000344
hasso508e53e2004-05-18 18:57:06 +0000345 /* if area is null, do not make connected-route list */
346 if (oi->area == NULL)
paul718e3742002-12-13 20:15:29 +0000347 return;
348
hasso508e53e2004-05-18 18:57:06 +0000349 /* update "route to advertise" interface route table */
350 ospf6_route_remove_all (oi->route_connected);
351 for (i = listhead (oi->interface->connected); i; nextnode (i))
352 {
353 c = (struct connected *) getdata (i);
354
355 if (c->address->family != AF_INET6)
356 continue;
357
358 CONTINUE_IF_ADDRESS_LINKLOCAL (c->address);
359 CONTINUE_IF_ADDRESS_UNSPECIFIED (c->address);
360 CONTINUE_IF_ADDRESS_LOOPBACK (c->address);
361 CONTINUE_IF_ADDRESS_V4COMPAT (c->address);
362 CONTINUE_IF_ADDRESS_V4MAPPED (c->address);
363
364 /* apply filter */
365 if (oi->plist_name)
366 {
367 struct prefix_list *plist;
368 enum prefix_list_type ret;
369 char buf[128];
370
371 prefix2str (c->address, buf, sizeof (buf));
372 plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
373 ret = prefix_list_apply (plist, (void *) c->address);
374 if (ret == PREFIX_DENY)
375 {
376 zlog_info ("%s on %s filtered by prefix-list %s ",
377 buf, oi->interface->name, oi->plist_name);
378 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 {
hasso508e53e2004-05-18 18:57:06 +0000414 zlog_info ("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);
431 if (prev_state == OSPF6_INTERFACE_DR || next_state == OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000432 {
hasso508e53e2004-05-18 18:57:06 +0000433 OSPF6_NETWORK_LSA_SCHEDULE (oi);
434 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
435 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +0000436 }
hasso508e53e2004-05-18 18:57:06 +0000437}
438
439
440/* DR Election, RFC2328 section 9.4 */
441
442#define IS_ELIGIBLE(n) \
443 ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
444
445static struct ospf6_neighbor *
446better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
447{
448 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
449 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
450 return NULL;
451 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
452 return b;
453 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
454 return a;
455
456 if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
457 return a;
458 if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
459 return b;
460
461 if (a->priority > b->priority)
462 return a;
463 if (a->priority < b->priority)
464 return b;
465
466 if (ntohl (a->router_id) > ntohl (b->router_id))
467 return a;
468 if (ntohl (a->router_id) < ntohl (b->router_id))
469 return b;
470
471 zlog_warn ("Router-ID duplicate ?");
472 return a;
473}
474
475static struct ospf6_neighbor *
476better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
477{
478 if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
479 (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
480 return NULL;
481 else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
482 return b;
483 else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
484 return a;
485
486 if (a->drouter == a->router_id && b->drouter != b->router_id)
487 return a;
488 if (a->drouter != a->router_id && b->drouter == b->router_id)
489 return b;
490
491 if (a->priority > b->priority)
492 return a;
493 if (a->priority < b->priority)
494 return b;
495
496 if (ntohl (a->router_id) > ntohl (b->router_id))
497 return a;
498 if (ntohl (a->router_id) < ntohl (b->router_id))
499 return b;
500
501 zlog_warn ("Router-ID duplicate ?");
502 return a;
503}
504
505static u_char
506dr_election (struct ospf6_interface *oi)
507{
508 listnode i;
509 struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
510 struct ospf6_neighbor *best_drouter, *best_bdrouter;
511 u_char next_state = 0;
512
513 drouter = bdrouter = NULL;
514 best_drouter = best_bdrouter = NULL;
515
516 /* pseudo neighbor myself, including noting current DR/BDR (1) */
517 memset (&myself, 0, sizeof (myself));
518 inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
519 sizeof (myself.name));
520 myself.state = OSPF6_NEIGHBOR_TWOWAY;
521 myself.drouter = oi->drouter;
522 myself.bdrouter = oi->bdrouter;
523 myself.priority = oi->priority;
524 myself.router_id = oi->area->ospf6->router_id;
525
526 /* Electing BDR (2) */
527 for (i = listhead (oi->neighbor_list); i; nextnode (i))
528 {
529 on = (struct ospf6_neighbor *) getdata (i);
530 bdrouter = better_bdrouter (bdrouter, on);
531 }
532 best_bdrouter = bdrouter;
533 bdrouter = better_bdrouter (best_bdrouter, &myself);
534
535 /* Electing DR (3) */
536 for (i = listhead (oi->neighbor_list); i; nextnode (i))
537 {
538 on = (struct ospf6_neighbor *) getdata (i);
539 drouter = better_drouter (drouter, on);
540 }
541 best_drouter = drouter;
542 drouter = better_drouter (best_drouter, &myself);
543 if (drouter == NULL)
544 drouter = bdrouter;
545
546 /* the router itself is newly/no longer DR/BDR (4) */
547 if ((drouter == &myself && myself.drouter != myself.router_id) ||
548 (drouter != &myself && myself.drouter == myself.router_id) ||
549 (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
550 (bdrouter != &myself && myself.bdrouter == myself.router_id))
551 {
552 myself.drouter = (drouter ? drouter->router_id : htonl (0));
553 myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
554
555 /* compatible to Electing BDR (2) */
556 bdrouter = better_bdrouter (best_bdrouter, &myself);
557
558 /* compatible to Electing DR (3) */
559 drouter = better_drouter (best_drouter, &myself);
560 if (drouter == NULL)
561 drouter = bdrouter;
562 }
563
564 /* Set interface state accordingly (5) */
565 if (drouter && drouter == &myself)
566 next_state = OSPF6_INTERFACE_DR;
567 else if (bdrouter && bdrouter == &myself)
568 next_state = OSPF6_INTERFACE_BDR;
569 else
570 next_state = OSPF6_INTERFACE_DROTHER;
571
572 /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
573 /* XXX */
574
575 /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
576 /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
577 accordingly after AdjOK */
578 if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
579 oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
580 {
581 if (IS_OSPF6_DEBUG_INTERFACE)
582 zlog_info ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
583 (drouter ? drouter->name : "0.0.0.0"),
584 (bdrouter ? bdrouter->name : "0.0.0.0"));
585
586 for (i = listhead (oi->neighbor_list); i; nextnode (i))
587 {
588 on = (struct ospf6_neighbor *) getdata (i);
589 if (on->state < OSPF6_NEIGHBOR_TWOWAY)
590 continue;
591 /* Schedule AdjOK. */
592 thread_add_event (master, adj_ok, on, 0);
593 }
594 }
595
596 oi->drouter = (drouter ? drouter->router_id : htonl (0));
597 oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
598 return next_state;
599}
600
601
602/* Interface State Machine */
603int
604interface_up (struct thread *thread)
605{
606 struct ospf6_interface *oi;
607
608 oi = (struct ospf6_interface *) THREAD_ARG (thread);
609 assert (oi && oi->interface);
610
611 if (IS_OSPF6_DEBUG_INTERFACE)
612 zlog_info ("Interface Event %s: [InterfaceUp]",
613 oi->interface->name);
614
615 /* check physical interface is up */
616 if (! if_is_up (oi->interface))
617 {
618 if (IS_OSPF6_DEBUG_INTERFACE)
619 zlog_info ("Interface %s is down, can't execute [InterfaceUp]",
620 oi->interface->name);
621 return 0;
622 }
623
624 /* if already enabled, do nothing */
625 if (oi->state > OSPF6_INTERFACE_DOWN)
626 {
627 if (IS_OSPF6_DEBUG_INTERFACE)
628 zlog_info ("Interface %s already enabled",
629 oi->interface->name);
630 return 0;
631 }
632
633 /* Join AllSPFRouters */
634 ospf6_join_allspfrouters (oi->interface->ifindex);
635
636 /* Update interface route */
637 ospf6_interface_connected_route_update (oi->interface);
638
639 /* Schedule Hello */
640 if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
641 thread_add_event (master, ospf6_hello_send, oi, 0);
642
643 /* decide next interface state */
644 if (if_is_pointopoint (oi->interface))
645 ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
646 else if (oi->priority == 0)
647 ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
648 else
649 {
650 ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
651 thread_add_timer (master, wait_timer, oi, oi->dead_interval);
652 }
653
654 return 0;
paul718e3742002-12-13 20:15:29 +0000655}
656
657int
hasso508e53e2004-05-18 18:57:06 +0000658wait_timer (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000659{
hasso508e53e2004-05-18 18:57:06 +0000660 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000661
hasso508e53e2004-05-18 18:57:06 +0000662 oi = (struct ospf6_interface *) THREAD_ARG (thread);
663 assert (oi && oi->interface);
paul718e3742002-12-13 20:15:29 +0000664
hasso508e53e2004-05-18 18:57:06 +0000665 if (IS_OSPF6_DEBUG_INTERFACE)
666 zlog_info ("Interface Event %s: [WaitTimer]",
667 oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000668
hasso508e53e2004-05-18 18:57:06 +0000669 if (oi->state == OSPF6_INTERFACE_WAITING)
670 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +0000671
hasso508e53e2004-05-18 18:57:06 +0000672 return 0;
paul718e3742002-12-13 20:15:29 +0000673}
674
hasso508e53e2004-05-18 18:57:06 +0000675int
676backup_seen (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000677{
hasso508e53e2004-05-18 18:57:06 +0000678 struct ospf6_interface *oi;
679
680 oi = (struct ospf6_interface *) THREAD_ARG (thread);
681 assert (oi && oi->interface);
682
683 if (IS_OSPF6_DEBUG_INTERFACE)
684 zlog_info ("Interface Event %s: [BackupSeen]",
685 oi->interface->name);
686
687 if (oi->state == OSPF6_INTERFACE_WAITING)
688 ospf6_interface_state_change (dr_election (oi), oi);
689
690 return 0;
paul718e3742002-12-13 20:15:29 +0000691}
692
hasso508e53e2004-05-18 18:57:06 +0000693int
694neighbor_change (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000695{
hasso508e53e2004-05-18 18:57:06 +0000696 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)
702 zlog_info ("Interface Event %s: [NeighborChange]",
703 oi->interface->name);
704
705 if (oi->state == OSPF6_INTERFACE_DROTHER ||
706 oi->state == OSPF6_INTERFACE_BDR ||
707 oi->state == OSPF6_INTERFACE_DR)
708 ospf6_interface_state_change (dr_election (oi), oi);
709
710 return 0;
paul718e3742002-12-13 20:15:29 +0000711}
712
hasso508e53e2004-05-18 18:57:06 +0000713int
714loopind (struct thread *thread)
715{
716 struct ospf6_interface *oi;
717
718 oi = (struct ospf6_interface *) THREAD_ARG (thread);
719 assert (oi && oi->interface);
720
721 if (IS_OSPF6_DEBUG_INTERFACE)
722 zlog_info ("Interface Event %s: [LoopInd]",
723 oi->interface->name);
724
725 /* XXX not yet */
726
727 return 0;
728}
729
730int
731interface_down (struct thread *thread)
732{
733 struct ospf6_interface *oi;
734 listnode n;
735 struct ospf6_neighbor *on;
736
737 oi = (struct ospf6_interface *) THREAD_ARG (thread);
738 assert (oi && oi->interface);
739
740 if (IS_OSPF6_DEBUG_INTERFACE)
741 zlog_info ("Interface Event %s: [InterfaceDown]",
742 oi->interface->name);
743
744 /* Leave AllSPFRouters */
745 if (oi->state > OSPF6_INTERFACE_DOWN)
746 ospf6_leave_allspfrouters (oi->interface->ifindex);
747
748 ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
749
750 for (n = listhead (oi->neighbor_list); n; nextnode (n))
751 {
752 on = (struct ospf6_neighbor *) getdata (n);
753 ospf6_neighbor_delete (on);
754 }
755 list_delete_all_node (oi->neighbor_list);
756
757 return 0;
758}
759
760
paul718e3742002-12-13 20:15:29 +0000761/* show specified interface structure */
762int
hasso508e53e2004-05-18 18:57:06 +0000763ospf6_interface_show (struct vty *vty, struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000764{
hasso508e53e2004-05-18 18:57:06 +0000765 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000766 struct connected *c;
767 struct prefix *p;
768 listnode i;
hasso508e53e2004-05-18 18:57:06 +0000769 char strbuf[64], drouter[32], bdrouter[32];
paul718e3742002-12-13 20:15:29 +0000770 char *updown[3] = {"down", "up", NULL};
771 char *type;
hasso508e53e2004-05-18 18:57:06 +0000772 struct timeval res, now;
773 char duration[32];
774 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000775
776 /* check physical interface type */
hasso508e53e2004-05-18 18:57:06 +0000777 if (if_is_loopback (ifp))
paul718e3742002-12-13 20:15:29 +0000778 type = "LOOPBACK";
hasso508e53e2004-05-18 18:57:06 +0000779 else if (if_is_broadcast (ifp))
paul718e3742002-12-13 20:15:29 +0000780 type = "BROADCAST";
hasso508e53e2004-05-18 18:57:06 +0000781 else if (if_is_pointopoint (ifp))
paul718e3742002-12-13 20:15:29 +0000782 type = "POINTOPOINT";
783 else
784 type = "UNKNOWN";
785
786 vty_out (vty, "%s is %s, type %s%s",
hasso508e53e2004-05-18 18:57:06 +0000787 ifp->name, updown[if_is_up (ifp)], type,
hasso049207c2004-08-04 20:02:13 +0000788 VNL);
789 vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
paul718e3742002-12-13 20:15:29 +0000790
hasso508e53e2004-05-18 18:57:06 +0000791 if (ifp->info == NULL)
paul718e3742002-12-13 20:15:29 +0000792 {
hasso049207c2004-08-04 20:02:13 +0000793 vty_out (vty, " OSPF not enabled on this interface%s", VNL);
paul718e3742002-12-13 20:15:29 +0000794 return 0;
795 }
796 else
hasso508e53e2004-05-18 18:57:06 +0000797 oi = (struct ospf6_interface *) ifp->info;
paul718e3742002-12-13 20:15:29 +0000798
hasso049207c2004-08-04 20:02:13 +0000799 vty_out (vty, " Internet Address:%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000800 for (i = listhead (ifp->connected); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000801 {
802 c = (struct connected *)getdata (i);
803 p = c->address;
804 prefix2str (p, strbuf, sizeof (strbuf));
805 switch (p->family)
806 {
807 case AF_INET:
hasso508e53e2004-05-18 18:57:06 +0000808 vty_out (vty, " inet : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000809 VNL);
paul718e3742002-12-13 20:15:29 +0000810 break;
811 case AF_INET6:
hasso508e53e2004-05-18 18:57:06 +0000812 vty_out (vty, " inet6: %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000813 VNL);
paul718e3742002-12-13 20:15:29 +0000814 break;
815 default:
hasso508e53e2004-05-18 18:57:06 +0000816 vty_out (vty, " ??? : %s%s", strbuf,
hasso049207c2004-08-04 20:02:13 +0000817 VNL);
paul718e3742002-12-13 20:15:29 +0000818 break;
819 }
820 }
821
hasso508e53e2004-05-18 18:57:06 +0000822 if (oi->area)
paul718e3742002-12-13 20:15:29 +0000823 {
hasso508e53e2004-05-18 18:57:06 +0000824 vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
hasso049207c2004-08-04 20:02:13 +0000825 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
hasso508e53e2004-05-18 18:57:06 +0000826 inet_ntop (AF_INET, &oi->area->area_id,
paul718e3742002-12-13 20:15:29 +0000827 strbuf, sizeof (strbuf));
hasso508e53e2004-05-18 18:57:06 +0000828 vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
hasso049207c2004-08-04 20:02:13 +0000829 VNL);
paul718e3742002-12-13 20:15:29 +0000830 }
831 else
hasso049207c2004-08-04 20:02:13 +0000832 vty_out (vty, " Not Attached to Area%s", VNL);
paul718e3742002-12-13 20:15:29 +0000833
834 vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
hasso508e53e2004-05-18 18:57:06 +0000835 ospf6_interface_state_str[oi->state],
836 oi->transdelay, oi->priority,
hasso049207c2004-08-04 20:02:13 +0000837 VNL);
838 vty_out (vty, " Timer intervals configured:%s", VNL);
paul718e3742002-12-13 20:15:29 +0000839 vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
hasso508e53e2004-05-18 18:57:06 +0000840 oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
hasso049207c2004-08-04 20:02:13 +0000841 VNL);
paul718e3742002-12-13 20:15:29 +0000842
hasso508e53e2004-05-18 18:57:06 +0000843 inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
844 inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
hasso049207c2004-08-04 20:02:13 +0000845 vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
paul718e3742002-12-13 20:15:29 +0000846
847 vty_out (vty, " Number of I/F scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000848 oi->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000849
850 gettimeofday (&now, (struct timezone *) NULL);
paul718e3742002-12-13 20:15:29 +0000851
hasso508e53e2004-05-18 18:57:06 +0000852 timerclear (&res);
853 if (oi->thread_send_lsupdate)
854 timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
855 timerstring (&res, duration, sizeof (duration));
856 vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
857 oi->lsupdate_list->count, duration,
858 (oi->thread_send_lsupdate ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000859 VNL);
hasso508e53e2004-05-18 18:57:06 +0000860 for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
861 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000862 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000863
hasso508e53e2004-05-18 18:57:06 +0000864 timerclear (&res);
865 if (oi->thread_send_lsack)
866 timersub (&oi->thread_send_lsack->u.sands, &now, &res);
867 timerstring (&res, duration, sizeof (duration));
868 vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
869 oi->lsack_list->count, duration,
870 (oi->thread_send_lsack ? "on" : "off"),
hasso049207c2004-08-04 20:02:13 +0000871 VNL);
hasso508e53e2004-05-18 18:57:06 +0000872 for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
873 lsa = ospf6_lsdb_next (lsa))
hasso049207c2004-08-04 20:02:13 +0000874 vty_out (vty, " %s%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000875
hasso508e53e2004-05-18 18:57:06 +0000876 return 0;
paul718e3742002-12-13 20:15:29 +0000877}
878
879/* show interface */
880DEFUN (show_ipv6_ospf6_interface,
881 show_ipv6_ospf6_interface_ifname_cmd,
882 "show ipv6 ospf6 interface IFNAME",
883 SHOW_STR
884 IP6_STR
885 OSPF6_STR
886 INTERFACE_STR
887 IFNAME_STR
888 )
889{
890 struct interface *ifp;
891 listnode i;
892
893 if (argc)
894 {
895 ifp = if_lookup_by_name (argv[0]);
hasso508e53e2004-05-18 18:57:06 +0000896 if (ifp == NULL)
paul718e3742002-12-13 20:15:29 +0000897 {
898 vty_out (vty, "No such Interface: %s%s", argv[0],
hasso049207c2004-08-04 20:02:13 +0000899 VNL);
paul718e3742002-12-13 20:15:29 +0000900 return CMD_WARNING;
901 }
902 ospf6_interface_show (vty, ifp);
903 }
904 else
905 {
906 for (i = listhead (iflist); i; nextnode (i))
907 {
hasso508e53e2004-05-18 18:57:06 +0000908 ifp = (struct interface *) getdata (i);
paul718e3742002-12-13 20:15:29 +0000909 ospf6_interface_show (vty, ifp);
910 }
911 }
hasso508e53e2004-05-18 18:57:06 +0000912
paul718e3742002-12-13 20:15:29 +0000913 return CMD_SUCCESS;
914}
915
916ALIAS (show_ipv6_ospf6_interface,
917 show_ipv6_ospf6_interface_cmd,
918 "show ipv6 ospf6 interface",
919 SHOW_STR
920 IP6_STR
921 OSPF6_STR
922 INTERFACE_STR
hasso508e53e2004-05-18 18:57:06 +0000923 );
paul718e3742002-12-13 20:15:29 +0000924
hasso508e53e2004-05-18 18:57:06 +0000925DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
926 show_ipv6_ospf6_interface_ifname_prefix_cmd,
927 "show ipv6 ospf6 interface IFNAME prefix",
928 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000929 IP6_STR
930 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000931 INTERFACE_STR
932 IFNAME_STR
933 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000934 )
935{
paul718e3742002-12-13 20:15:29 +0000936 struct interface *ifp;
hasso508e53e2004-05-18 18:57:06 +0000937 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000938
hasso508e53e2004-05-18 18:57:06 +0000939 ifp = if_lookup_by_name (argv[0]);
940 if (ifp == NULL)
941 {
hasso049207c2004-08-04 20:02:13 +0000942 vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000943 return CMD_WARNING;
944 }
paul718e3742002-12-13 20:15:29 +0000945
hasso508e53e2004-05-18 18:57:06 +0000946 oi = ifp->info;
947 if (oi == NULL)
948 {
hasso049207c2004-08-04 20:02:13 +0000949 vty_out (vty, "OSPFv3 is not enabled on %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 argc--;
954 argv++;
955 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
paul718e3742002-12-13 20:15:29 +0000956
957 return CMD_SUCCESS;
958}
959
hasso508e53e2004-05-18 18:57:06 +0000960ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
961 show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
962 "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
963 SHOW_STR
paul718e3742002-12-13 20:15:29 +0000964 IP6_STR
965 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000966 INTERFACE_STR
967 IFNAME_STR
968 "Display connected prefixes to advertise\n"
969 OSPF6_ROUTE_ADDRESS_STR
970 OSPF6_ROUTE_PREFIX_STR
971 "Dispaly details of the prefixes\n"
972 );
973
974ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
975 show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
976 "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
977 SHOW_STR
978 IP6_STR
979 OSPF6_STR
980 INTERFACE_STR
981 IFNAME_STR
982 "Display connected prefixes to advertise\n"
983 OSPF6_ROUTE_PREFIX_STR
984 OSPF6_ROUTE_MATCH_STR
985 "Dispaly details of the prefixes\n"
986 );
987
988DEFUN (show_ipv6_ospf6_interface_prefix,
989 show_ipv6_ospf6_interface_prefix_cmd,
990 "show ipv6 ospf6 interface prefix",
991 SHOW_STR
992 IP6_STR
993 OSPF6_STR
994 INTERFACE_STR
995 "Display connected prefixes to advertise\n"
paul718e3742002-12-13 20:15:29 +0000996 )
997{
hasso508e53e2004-05-18 18:57:06 +0000998 listnode i;
999 struct ospf6_interface *oi;
1000 struct interface *ifp;
1001
1002 for (i = listhead (iflist); i; nextnode (i))
1003 {
1004 ifp = (struct interface *) getdata (i);
1005 oi = (struct ospf6_interface *) ifp->info;
1006 if (oi == NULL)
1007 continue;
1008
1009 ospf6_route_table_show (vty, argc, argv, oi->route_connected);
1010 }
1011
1012 return CMD_SUCCESS;
1013}
1014
1015ALIAS (show_ipv6_ospf6_interface_prefix,
1016 show_ipv6_ospf6_interface_prefix_detail_cmd,
1017 "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
1018 SHOW_STR
1019 IP6_STR
1020 OSPF6_STR
1021 INTERFACE_STR
1022 "Display connected prefixes to advertise\n"
1023 OSPF6_ROUTE_ADDRESS_STR
1024 OSPF6_ROUTE_PREFIX_STR
1025 "Dispaly details of the prefixes\n"
1026 );
1027
1028ALIAS (show_ipv6_ospf6_interface_prefix,
1029 show_ipv6_ospf6_interface_prefix_match_cmd,
1030 "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
1031 SHOW_STR
1032 IP6_STR
1033 OSPF6_STR
1034 INTERFACE_STR
1035 "Display connected prefixes to advertise\n"
1036 OSPF6_ROUTE_PREFIX_STR
1037 OSPF6_ROUTE_MATCH_STR
1038 "Dispaly details of the prefixes\n"
1039 );
1040
1041
1042/* interface variable set command */
hassob596c712004-07-09 18:33:43 +00001043DEFUN (ipv6_ospf6_ifmtu,
1044 ipv6_ospf6_ifmtu_cmd,
1045 "ipv6 ospf6 ifmtu <1-65535>",
1046 IP6_STR
1047 OSPF6_STR
1048 "Interface MTU\n"
1049 "OSPFv3 Interface MTU\n"
1050 )
1051{
1052 struct ospf6_interface *oi;
1053 struct interface *ifp;
1054 int ifmtu, iobuflen;
1055 listnode node;
1056 struct ospf6_neighbor *on;
1057
1058 ifp = (struct interface *) vty->index;
1059 assert (ifp);
1060
1061 oi = (struct ospf6_interface *) ifp->info;
1062 if (oi == NULL)
1063 oi = ospf6_interface_create (ifp);
1064 assert (oi);
1065
1066 ifmtu = strtol (argv[0], NULL, 10);
1067
1068 if (oi->ifmtu == ifmtu)
1069 return CMD_SUCCESS;
1070
hasso1203e1c2004-07-23 21:34:27 +00001071 if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
hassob596c712004-07-09 18:33:43 +00001072 {
1073 vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
hasso049207c2004-08-04 20:02:13 +00001074 ifp->name, ifp->mtu6, VNL);
hassob596c712004-07-09 18:33:43 +00001075 return CMD_WARNING;
1076 }
1077
1078 if (oi->ifmtu < ifmtu)
1079 {
1080 iobuflen = ospf6_iobuf_size (ifmtu);
1081 if (iobuflen < ifmtu)
1082 {
1083 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
hasso049207c2004-08-04 20:02:13 +00001084 ifp->name, iobuflen, VNL);
hassob596c712004-07-09 18:33:43 +00001085 oi->ifmtu = iobuflen;
1086 }
1087 else
1088 oi->ifmtu = ifmtu;
1089 }
1090 else
1091 oi->ifmtu = ifmtu;
1092
1093 /* re-establish adjacencies */
1094 for (node = listhead (oi->neighbor_list); node; nextnode (node))
1095 {
1096 on = (struct ospf6_neighbor *) getdata (node);
1097 THREAD_OFF (on->inactivity_timer);
1098 thread_execute (master, inactivity_timer, on, 0);
1099 }
1100
1101 return CMD_SUCCESS;
1102}
1103
hasso049207c2004-08-04 20:02:13 +00001104DEFUN (no_ipv6_ospf6_ifmtu,
1105 no_ipv6_ospf6_ifmtu_cmd,
1106 "no ipv6 ospf6 ifmtu",
1107 NO_STR
1108 IP6_STR
1109 OSPF6_STR
1110 "Interface MTU\n"
1111 )
1112{
1113 struct ospf6_interface *oi;
1114 struct interface *ifp;
1115 int iobuflen;
1116 listnode node;
1117 struct ospf6_neighbor *on;
1118
1119 ifp = (struct interface *) vty->index;
1120 assert (ifp);
1121
1122 oi = (struct ospf6_interface *) ifp->info;
1123 if (oi == NULL)
1124 oi = ospf6_interface_create (ifp);
1125 assert (oi);
1126
1127 if (oi->ifmtu < ifp->mtu)
1128 {
1129 iobuflen = ospf6_iobuf_size (ifp->mtu);
1130 if (iobuflen < ifp->mtu)
1131 {
1132 vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
1133 ifp->name, iobuflen, VNL);
1134 oi->ifmtu = iobuflen;
1135 }
1136 else
1137 oi->ifmtu = ifp->mtu;
1138 }
1139 else
1140 oi->ifmtu = ifp->mtu;
1141
1142 /* re-establish adjacencies */
1143 for (node = listhead (oi->neighbor_list); node; nextnode (node))
1144 {
1145 on = (struct ospf6_neighbor *) getdata (node);
1146 THREAD_OFF (on->inactivity_timer);
1147 thread_execute (master, inactivity_timer, on, 0);
1148 }
1149
1150 return CMD_SUCCESS;
1151}
1152
hasso508e53e2004-05-18 18:57:06 +00001153DEFUN (ipv6_ospf6_cost,
1154 ipv6_ospf6_cost_cmd,
1155 "ipv6 ospf6 cost <1-65535>",
1156 IP6_STR
1157 OSPF6_STR
1158 "Interface cost\n"
1159 "Outgoing metric of this interface\n"
1160 )
1161{
1162 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001163 struct interface *ifp;
1164
1165 ifp = (struct interface *) vty->index;
1166 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001167
hasso508e53e2004-05-18 18:57:06 +00001168 oi = (struct ospf6_interface *) ifp->info;
1169 if (oi == NULL)
1170 oi = ospf6_interface_create (ifp);
1171 assert (oi);
1172
1173 if (oi->cost == strtol (argv[0], NULL, 10))
1174 return CMD_SUCCESS;
1175
1176 oi->cost = strtol (argv[0], NULL, 10);
1177
1178 /* update cost held in route_connected list in ospf6_interface */
1179 ospf6_interface_connected_route_update (oi->interface);
1180
1181 /* execute LSA hooks */
1182 if (oi->area)
1183 {
1184 OSPF6_LINK_LSA_SCHEDULE (oi);
1185 OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
1186 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1187 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1188 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
1189 }
1190
1191 return CMD_SUCCESS;
1192}
1193
1194DEFUN (ipv6_ospf6_hellointerval,
1195 ipv6_ospf6_hellointerval_cmd,
1196 "ipv6 ospf6 hello-interval <1-65535>",
1197 IP6_STR
1198 OSPF6_STR
1199 "Interval time of Hello packets\n"
1200 SECONDS_STR
1201 )
1202{
1203 struct ospf6_interface *oi;
1204 struct interface *ifp;
1205
1206 ifp = (struct interface *) vty->index;
1207 assert (ifp);
1208
1209 oi = (struct ospf6_interface *) ifp->info;
1210 if (oi == NULL)
1211 oi = ospf6_interface_create (ifp);
1212 assert (oi);
1213
1214 oi->hello_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001215 return CMD_SUCCESS;
1216}
1217
1218/* interface variable set command */
1219DEFUN (ipv6_ospf6_deadinterval,
1220 ipv6_ospf6_deadinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001221 "ipv6 ospf6 dead-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001222 IP6_STR
1223 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001224 "Interval time after which a neighbor is declared down\n"
paul718e3742002-12-13 20:15:29 +00001225 SECONDS_STR
1226 )
1227{
hasso508e53e2004-05-18 18:57:06 +00001228 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001229 struct interface *ifp;
1230
1231 ifp = (struct interface *) vty->index;
1232 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001233
hasso508e53e2004-05-18 18:57:06 +00001234 oi = (struct ospf6_interface *) ifp->info;
1235 if (oi == NULL)
1236 oi = ospf6_interface_create (ifp);
1237 assert (oi);
1238
1239 oi->dead_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001240 return CMD_SUCCESS;
1241}
1242
1243/* interface variable set command */
1244DEFUN (ipv6_ospf6_transmitdelay,
1245 ipv6_ospf6_transmitdelay_cmd,
hasso508e53e2004-05-18 18:57:06 +00001246 "ipv6 ospf6 transmit-delay <1-3600>",
paul718e3742002-12-13 20:15:29 +00001247 IP6_STR
1248 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001249 "Transmit delay of this interface\n"
paul718e3742002-12-13 20:15:29 +00001250 SECONDS_STR
1251 )
1252{
hasso508e53e2004-05-18 18:57:06 +00001253 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001254 struct interface *ifp;
1255
1256 ifp = (struct interface *) vty->index;
1257 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001258
hasso508e53e2004-05-18 18:57:06 +00001259 oi = (struct ospf6_interface *) ifp->info;
1260 if (oi == NULL)
1261 oi = ospf6_interface_create (ifp);
1262 assert (oi);
1263
1264 oi->transdelay = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001265 return CMD_SUCCESS;
1266}
1267
1268/* interface variable set command */
1269DEFUN (ipv6_ospf6_retransmitinterval,
1270 ipv6_ospf6_retransmitinterval_cmd,
hasso508e53e2004-05-18 18:57:06 +00001271 "ipv6 ospf6 retransmit-interval <1-65535>",
paul718e3742002-12-13 20:15:29 +00001272 IP6_STR
1273 OSPF6_STR
1274 "Time between retransmitting lost link state advertisements\n"
1275 SECONDS_STR
1276 )
1277{
hasso508e53e2004-05-18 18:57:06 +00001278 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001279 struct interface *ifp;
1280
1281 ifp = (struct interface *) vty->index;
1282 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001283
hasso508e53e2004-05-18 18:57:06 +00001284 oi = (struct ospf6_interface *) ifp->info;
1285 if (oi == NULL)
1286 oi = ospf6_interface_create (ifp);
1287 assert (oi);
1288
1289 oi->rxmt_interval = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001290 return CMD_SUCCESS;
1291}
1292
1293/* interface variable set command */
1294DEFUN (ipv6_ospf6_priority,
1295 ipv6_ospf6_priority_cmd,
hasso508e53e2004-05-18 18:57:06 +00001296 "ipv6 ospf6 priority <0-255>",
paul718e3742002-12-13 20:15:29 +00001297 IP6_STR
1298 OSPF6_STR
1299 "Router priority\n"
hasso508e53e2004-05-18 18:57:06 +00001300 "Priority value\n"
paul718e3742002-12-13 20:15:29 +00001301 )
1302{
hasso508e53e2004-05-18 18:57:06 +00001303 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001304 struct interface *ifp;
1305
1306 ifp = (struct interface *) vty->index;
1307 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001308
hasso508e53e2004-05-18 18:57:06 +00001309 oi = (struct ospf6_interface *) ifp->info;
1310 if (oi == NULL)
1311 oi = ospf6_interface_create (ifp);
1312 assert (oi);
paul718e3742002-12-13 20:15:29 +00001313
hasso508e53e2004-05-18 18:57:06 +00001314 oi->priority = strtol (argv[0], NULL, 10);
1315
1316 if (oi->area)
1317 ospf6_interface_state_change (dr_election (oi), oi);
paul718e3742002-12-13 20:15:29 +00001318
1319 return CMD_SUCCESS;
1320}
1321
1322DEFUN (ipv6_ospf6_instance,
1323 ipv6_ospf6_instance_cmd,
hasso508e53e2004-05-18 18:57:06 +00001324 "ipv6 ospf6 instance-id <0-255>",
paul718e3742002-12-13 20:15:29 +00001325 IP6_STR
1326 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001327 "Instance ID for this interface\n"
1328 "Instance ID value\n"
paul718e3742002-12-13 20:15:29 +00001329 )
1330{
hasso508e53e2004-05-18 18:57:06 +00001331 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001332 struct interface *ifp;
1333
1334 ifp = (struct interface *)vty->index;
1335 assert (ifp);
1336
hasso508e53e2004-05-18 18:57:06 +00001337 oi = (struct ospf6_interface *)ifp->info;
1338 if (oi == NULL)
1339 oi = ospf6_interface_create (ifp);
1340 assert (oi);
paul718e3742002-12-13 20:15:29 +00001341
hasso508e53e2004-05-18 18:57:06 +00001342 oi->instance_id = strtol (argv[0], NULL, 10);
paul718e3742002-12-13 20:15:29 +00001343 return CMD_SUCCESS;
1344}
1345
1346DEFUN (ipv6_ospf6_passive,
1347 ipv6_ospf6_passive_cmd,
1348 "ipv6 ospf6 passive",
1349 IP6_STR
1350 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001351 "passive interface, No adjacency will be formed on this interface\n"
paul718e3742002-12-13 20:15:29 +00001352 )
1353{
hasso508e53e2004-05-18 18:57:06 +00001354 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001355 struct interface *ifp;
1356 listnode node;
hasso508e53e2004-05-18 18:57:06 +00001357 struct ospf6_neighbor *on;
paul718e3742002-12-13 20:15:29 +00001358
1359 ifp = (struct interface *) vty->index;
1360 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001361
hasso508e53e2004-05-18 18:57:06 +00001362 oi = (struct ospf6_interface *) ifp->info;
1363 if (oi == NULL)
1364 oi = ospf6_interface_create (ifp);
1365 assert (oi);
paul718e3742002-12-13 20:15:29 +00001366
hasso508e53e2004-05-18 18:57:06 +00001367 SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1368 THREAD_OFF (oi->thread_send_hello);
1369
1370 for (node = listhead (oi->neighbor_list); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00001371 {
hasso508e53e2004-05-18 18:57:06 +00001372 on = (struct ospf6_neighbor *) getdata (node);
1373 THREAD_OFF (on->inactivity_timer);
1374 thread_execute (master, inactivity_timer, on, 0);
paul718e3742002-12-13 20:15:29 +00001375 }
1376
1377 return CMD_SUCCESS;
1378}
1379
1380DEFUN (no_ipv6_ospf6_passive,
1381 no_ipv6_ospf6_passive_cmd,
1382 "no ipv6 ospf6 passive",
1383 NO_STR
1384 IP6_STR
1385 OSPF6_STR
1386 "passive interface: No Adjacency will be formed on this I/F\n"
1387 )
1388{
hasso508e53e2004-05-18 18:57:06 +00001389 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001390 struct interface *ifp;
1391
1392 ifp = (struct interface *) vty->index;
1393 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001394
hasso508e53e2004-05-18 18:57:06 +00001395 oi = (struct ospf6_interface *) ifp->info;
1396 if (oi == NULL)
1397 oi = ospf6_interface_create (ifp);
1398 assert (oi);
paul718e3742002-12-13 20:15:29 +00001399
hasso508e53e2004-05-18 18:57:06 +00001400 UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
1401 THREAD_OFF (oi->thread_send_hello);
1402 oi->thread_send_hello =
1403 thread_add_event (master, ospf6_hello_send, oi, 0);
paul718e3742002-12-13 20:15:29 +00001404
1405 return CMD_SUCCESS;
1406}
1407
1408DEFUN (ipv6_ospf6_advertise_prefix_list,
1409 ipv6_ospf6_advertise_prefix_list_cmd,
1410 "ipv6 ospf6 advertise prefix-list WORD",
1411 IP6_STR
1412 OSPF6_STR
1413 "Advertising options\n"
1414 "Filter prefix using prefix-list\n"
1415 "Prefix list name\n"
1416 )
1417{
hasso508e53e2004-05-18 18:57:06 +00001418 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001419 struct interface *ifp;
1420
1421 ifp = (struct interface *) vty->index;
1422 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001423
hasso508e53e2004-05-18 18:57:06 +00001424 oi = (struct ospf6_interface *) ifp->info;
1425 if (oi == NULL)
1426 oi = ospf6_interface_create (ifp);
1427 assert (oi);
paul718e3742002-12-13 20:15:29 +00001428
hasso508e53e2004-05-18 18:57:06 +00001429 if (oi->plist_name)
1430 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1431 oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
paul718e3742002-12-13 20:15:29 +00001432
hasso508e53e2004-05-18 18:57:06 +00001433 ospf6_interface_connected_route_update (oi->interface);
1434 OSPF6_LINK_LSA_SCHEDULE (oi);
1435 if (oi->state == OSPF6_INTERFACE_DR)
1436 {
1437 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1438 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1439 }
1440 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001441
1442 return CMD_SUCCESS;
1443}
1444
1445DEFUN (no_ipv6_ospf6_advertise_prefix_list,
1446 no_ipv6_ospf6_advertise_prefix_list_cmd,
1447 "no ipv6 ospf6 advertise prefix-list",
1448 NO_STR
1449 IP6_STR
1450 OSPF6_STR
1451 "Advertising options\n"
1452 "Filter prefix using prefix-list\n"
1453 )
1454{
hasso508e53e2004-05-18 18:57:06 +00001455 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001456 struct interface *ifp;
1457
1458 ifp = (struct interface *) vty->index;
1459 assert (ifp);
paul718e3742002-12-13 20:15:29 +00001460
hasso508e53e2004-05-18 18:57:06 +00001461 oi = (struct ospf6_interface *) ifp->info;
1462 if (oi == NULL)
1463 oi = ospf6_interface_create (ifp);
1464 assert (oi);
1465
1466 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001467 {
hasso508e53e2004-05-18 18:57:06 +00001468 XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
1469 oi->plist_name = NULL;
paul718e3742002-12-13 20:15:29 +00001470 }
1471
hasso508e53e2004-05-18 18:57:06 +00001472 ospf6_interface_connected_route_update (oi->interface);
1473 OSPF6_LINK_LSA_SCHEDULE (oi);
1474 if (oi->state == OSPF6_INTERFACE_DR)
1475 {
1476 OSPF6_NETWORK_LSA_SCHEDULE (oi);
1477 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
1478 }
1479 OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
paul718e3742002-12-13 20:15:29 +00001480
1481 return CMD_SUCCESS;
1482}
1483
1484int
hasso508e53e2004-05-18 18:57:06 +00001485config_write_ospf6_interface (struct vty *vty)
paul718e3742002-12-13 20:15:29 +00001486{
1487 listnode i;
hasso508e53e2004-05-18 18:57:06 +00001488 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +00001489 struct interface *ifp;
1490
1491 for (i = listhead (iflist); i; nextnode (i))
1492 {
1493 ifp = (struct interface *) getdata (i);
hasso508e53e2004-05-18 18:57:06 +00001494 oi = (struct ospf6_interface *) ifp->info;
1495 if (oi == NULL)
paul718e3742002-12-13 20:15:29 +00001496 continue;
1497
1498 vty_out (vty, "interface %s%s",
hasso049207c2004-08-04 20:02:13 +00001499 oi->interface->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001500
1501 if (ifp->desc)
hasso049207c2004-08-04 20:02:13 +00001502 vty_out (vty, " description %s%s", ifp->desc, VNL);
hasso508e53e2004-05-18 18:57:06 +00001503
hasso1203e1c2004-07-23 21:34:27 +00001504 if (ifp->mtu6 != oi->ifmtu)
hasso049207c2004-08-04 20:02:13 +00001505 vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
paul718e3742002-12-13 20:15:29 +00001506 vty_out (vty, " ipv6 ospf6 cost %d%s",
hasso049207c2004-08-04 20:02:13 +00001507 oi->cost, VNL);
paul718e3742002-12-13 20:15:29 +00001508 vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001509 oi->hello_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001510 vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001511 oi->dead_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001512 vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
hasso049207c2004-08-04 20:02:13 +00001513 oi->rxmt_interval, VNL);
paul718e3742002-12-13 20:15:29 +00001514 vty_out (vty, " ipv6 ospf6 priority %d%s",
hasso049207c2004-08-04 20:02:13 +00001515 oi->priority, VNL);
paul718e3742002-12-13 20:15:29 +00001516 vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
hasso049207c2004-08-04 20:02:13 +00001517 oi->transdelay, VNL);
paul718e3742002-12-13 20:15:29 +00001518 vty_out (vty, " ipv6 ospf6 instance-id %d%s",
hasso049207c2004-08-04 20:02:13 +00001519 oi->instance_id, VNL);
paul718e3742002-12-13 20:15:29 +00001520
hasso508e53e2004-05-18 18:57:06 +00001521 if (oi->plist_name)
paul718e3742002-12-13 20:15:29 +00001522 vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
hasso049207c2004-08-04 20:02:13 +00001523 oi->plist_name, VNL);
paul718e3742002-12-13 20:15:29 +00001524
hasso508e53e2004-05-18 18:57:06 +00001525 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
hasso049207c2004-08-04 20:02:13 +00001526 vty_out (vty, " ipv6 ospf6 passive%s", VNL);
paul718e3742002-12-13 20:15:29 +00001527
hasso049207c2004-08-04 20:02:13 +00001528 vty_out (vty, "!%s", VNL);
paul718e3742002-12-13 20:15:29 +00001529 }
1530 return 0;
1531}
1532
1533struct cmd_node interface_node =
1534{
1535 INTERFACE_NODE,
1536 "%s(config-if)# ",
paul718e3742002-12-13 20:15:29 +00001537};
1538
1539void
1540ospf6_interface_init ()
1541{
1542 /* Install interface node. */
hasso508e53e2004-05-18 18:57:06 +00001543 install_node (&interface_node, config_write_ospf6_interface);
paul718e3742002-12-13 20:15:29 +00001544
1545 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001546 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1547 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1548 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001549 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001550 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1551 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1552 install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001553 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
hasso508e53e2004-05-18 18:57:06 +00001554 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
1555 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
1556 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001557 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
hasso508e53e2004-05-18 18:57:06 +00001558 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
1559 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
1560 install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
paul718e3742002-12-13 20:15:29 +00001561
hasso508e53e2004-05-18 18:57:06 +00001562 install_element (CONFIG_NODE, &interface_cmd);
paul718e3742002-12-13 20:15:29 +00001563 install_default (INTERFACE_NODE);
1564 install_element (INTERFACE_NODE, &interface_desc_cmd);
1565 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1566 install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
hassob596c712004-07-09 18:33:43 +00001567 install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
hasso049207c2004-08-04 20:02:13 +00001568 install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
paul718e3742002-12-13 20:15:29 +00001569 install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
1570 install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
1571 install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
1572 install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
1573 install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
1574 install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
hasso508e53e2004-05-18 18:57:06 +00001575
paul718e3742002-12-13 20:15:29 +00001576 install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
1577 install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
hasso508e53e2004-05-18 18:57:06 +00001578
1579 install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
1580 install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
1581}
1582
1583DEFUN (debug_ospf6_interface,
1584 debug_ospf6_interface_cmd,
1585 "debug ospf6 interface",
1586 DEBUG_STR
1587 OSPF6_STR
1588 "Debug OSPFv3 Interface\n"
1589 )
1590{
1591 OSPF6_DEBUG_INTERFACE_ON ();
1592 return CMD_SUCCESS;
1593}
1594
1595DEFUN (no_debug_ospf6_interface,
1596 no_debug_ospf6_interface_cmd,
1597 "no debug ospf6 interface",
1598 NO_STR
1599 DEBUG_STR
1600 OSPF6_STR
1601 "Debug OSPFv3 Interface\n"
1602 )
1603{
1604 OSPF6_DEBUG_INTERFACE_ON ();
1605 return CMD_SUCCESS;
1606}
1607
1608int
1609config_write_ospf6_debug_interface (struct vty *vty)
1610{
1611 if (IS_OSPF6_DEBUG_INTERFACE)
hasso049207c2004-08-04 20:02:13 +00001612 vty_out (vty, "debug ospf6 interface%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001613 return 0;
1614}
1615
1616void
1617install_element_ospf6_debug_interface ()
1618{
1619 install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
1620 install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
1621 install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
1622 install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
paul718e3742002-12-13 20:15:29 +00001623}
1624
1625