/* global ospf6d variable */
struct ospf6 *ospf6;
-void
+static void
ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
{
switch (ntohs (lsa->header->type))
break;
default:
- if (IS_OSPF6_DEBUG_LSA (RECV))
- zlog_info ("Unknown LSA in AS-scoped lsdb");
break;
}
}
-void
+static void
ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
{
switch (ntohs (lsa->header->type))
break;
default:
- if (IS_OSPF6_DEBUG_LSA (RECV))
- zlog_info ("Unknown LSA in AS-scoped lsdb");
break;
}
}
-void
+static void
ospf6_top_route_hook_add (struct ospf6_route *route)
{
ospf6_abr_originate_summary (route);
ospf6_zebra_route_update_add (route);
}
-void
+static void
ospf6_top_route_hook_remove (struct ospf6_route *route)
{
ospf6_abr_originate_summary (route);
ospf6_zebra_route_update_remove (route);
}
-void
+static void
ospf6_top_brouter_hook_add (struct ospf6_route *route)
{
- ospf6_abr_originate_summary (route);
+ ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
ospf6_asbr_lsentry_add (route);
+ ospf6_abr_originate_summary (route);
}
-void
+static void
ospf6_top_brouter_hook_remove (struct ospf6_route *route)
{
- ospf6_abr_originate_summary (route);
+ ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
ospf6_asbr_lsentry_remove (route);
+ ospf6_abr_originate_summary (route);
}
-struct ospf6 *
-ospf6_create ()
+static struct ospf6 *
+ospf6_create (void)
{
struct ospf6 *o;
o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
- o->route_table = ospf6_route_table_create ();
+ o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
+ o->route_table->scope = o;
o->route_table->hook_add = ospf6_top_route_hook_add;
o->route_table->hook_remove = ospf6_top_route_hook_remove;
- o->brouter_table = ospf6_route_table_create ();
+ o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
+ o->brouter_table->scope = o;
o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
- o->external_table = ospf6_route_table_create ();
+ o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
+ o->external_table->scope = o;
+
o->external_id_table = route_table_init ();
return o;
}
-void
+static void
ospf6_delete (struct ospf6 *o)
{
- listnode i;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
- for (i = listhead (o->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- ospf6_area_delete (oa);
- }
+ for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
+ ospf6_area_delete (oa);
ospf6_lsdb_delete (o->lsdb);
ospf6_lsdb_delete (o->lsdb_self);
XFREE (MTYPE_OSPF6_TOP, o);
}
-void
+static void
ospf6_enable (struct ospf6 *o)
{
- listnode i;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
{
UNSET_FLAG (o->flag, OSPF6_DISABLED);
- for (i = listhead (o->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- ospf6_area_enable (oa);
- }
+ for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
+ ospf6_area_enable (oa);
}
}
-void
+static void
ospf6_disable (struct ospf6 *o)
{
- listnode i;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
{
SET_FLAG (o->flag, OSPF6_DISABLED);
- for (i = listhead (o->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- ospf6_area_disable (oa);
- }
+
+ for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
+ ospf6_area_disable (oa);
ospf6_lsdb_remove_all (o->lsdb);
ospf6_route_remove_all (o->route_table);
}
}
-int
+static int
ospf6_maxage_remover (struct thread *thread)
{
struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
struct ospf6_area *oa;
struct ospf6_interface *oi;
struct ospf6_neighbor *on;
- listnode i, j, k;
+ struct listnode *i, *j, *k;
o->maxage_remover = (struct thread *) NULL;
- if (IS_OSPF6_DEBUG_LSA (TIMER))
- zlog_info ("Maxage Remover");
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
{
- on = (struct ospf6_neighbor *) getdata (k);
if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
on->state != OSPF6_NEIGHBOR_LOADING)
continue;
- if (IS_OSPF6_DEBUG_LSA (TIMER))
- zlog_info ("Maxage Remover End: %s exchange or loading",
- on->name);
return 0;
}
}
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = (struct ospf6_interface *) getdata (j);
- OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
- }
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
+
OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);
}
OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
- if (IS_OSPF6_DEBUG_LSA (TIMER))
- zlog_info ("Maxage Remover End");
-
return 0;
}
return CMD_SUCCESS;
}
- o->router_id = router_id;
+ o->router_id_static = router_id;
+ if (o->router_id == 0)
+ o->router_id = router_id;
+
return CMD_SUCCESS;
}
)
{
struct ospf6 *o;
- struct ospf6_area *oa, *area;
+ struct ospf6_area *oa;
struct ospf6_interface *oi;
struct interface *ifp;
u_int32_t area_id;
- listnode node;
- struct ospf6_route *ro;
o = (struct ospf6 *) vty->index;
/* start up */
thread_add_event (master, interface_up, oi, 0);
- /* ABR stuff, redistribute inter-area LSAs and
- re-originate Router-LSA (B-bit may have been changed) */
- for (node = listhead (o->area_list); node; nextnode (node))
- {
- area = OSPF6_AREA (getdata (node));
- OSPF6_ROUTER_LSA_SCHEDULE (area);
-
- for (ro = ospf6_route_head (area->range_table); ro;
- ro = ospf6_route_next (ro))
- ospf6_abr_originate_summary_to_area (ro, oa);
- }
-
- for (ro = ospf6_route_head (o->brouter_table); ro;
- ro = ospf6_route_next (ro))
- ospf6_abr_originate_summary_to_area (ro, oa);
-
- for (ro = ospf6_route_head (o->route_table); ro;
- ro = ospf6_route_next (ro))
- ospf6_abr_originate_summary_to_area (ro, oa);
+ /* If the router is ABR, originate summary routes */
+ if (ospf6_is_router_abr (o))
+ ospf6_abr_enable_area (oa);
return CMD_SUCCESS;
}
{
struct ospf6 *o;
struct ospf6_interface *oi;
- struct ospf6_area *oa, *area;
+ struct ospf6_area *oa;
struct interface *ifp;
u_int32_t area_id;
- listnode node;
- struct ospf6_route *ro;
- struct ospf6_lsa *old;
o = (struct ospf6 *) vty->index;
if (oa->if_list->count == 0)
{
UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
-
- for (ro = ospf6_route_head (oa->summary_prefix); ro;
- ro = ospf6_route_next (ro))
- {
- old = ospf6_lsdb_lookup (ro->path.origin.type,
- ro->path.origin.id,
- oa->ospf6->router_id, oa->lsdb);
- if (old)
- ospf6_lsa_purge (old);
- ospf6_route_remove (ro, oa->summary_prefix);
- }
- for (ro = ospf6_route_head (oa->summary_router); ro;
- ro = ospf6_route_next (ro))
- {
- old = ospf6_lsdb_lookup (ro->path.origin.type,
- ro->path.origin.id,
- oa->ospf6->router_id, oa->lsdb);
- if (old)
- ospf6_lsa_purge (old);
- ospf6_route_remove (ro, oa->summary_router);
- }
- }
-
- /* Schedule Refreshment of Router-LSA for each area
- (ABR status may change) */
- for (node = listhead (o->area_list); node; nextnode (node))
- {
- area = OSPF6_AREA (getdata (node));
- OSPF6_ROUTER_LSA_SCHEDULE (area);
+ ospf6_abr_disable_area (oa);
}
return CMD_SUCCESS;
}
-void
+static void
ospf6_show (struct vty *vty, struct ospf6 *o)
{
- listnode n;
+ struct listnode *n;
struct ospf6_area *oa;
char router_id[16], duration[32];
struct timeval now, running;
/* Areas */
vty_out (vty, " Number of areas in this router is %u%s",
listcount (o->area_list), VNL);
- for (n = listhead (o->area_list); n; nextnode (n))
- {
- oa = (struct ospf6_area *) getdata (n);
- ospf6_area_show (vty, oa);
- }
+
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
+ ospf6_area_show (vty, oa);
}
/* show top level structures */
ALIAS (show_ipv6_ospf6_route,
show_ipv6_ospf6_route_detail_cmd,
- "show ipv6 ospf6 route (X::X|X::X/M|detail|summary)",
+ "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
SHOW_STR
IP6_STR
OSPF6_STR
"Specify IPv6 prefix\n"
"Detailed information\n"
"Summary of route table\n"
- );
+ )
DEFUN (show_ipv6_ospf6_route_match,
show_ipv6_ospf6_route_match_cmd,
- "show ipv6 ospf6 route X::X/M match",
+ "show ipv6 ospf6 route X:X::X:X/M match",
SHOW_STR
IP6_STR
OSPF6_STR
"Display routes which match the specified route\n"
)
{
- char *sargv[CMD_ARGC_MAX];
+ const char *sargv[CMD_ARGC_MAX];
int i, sargc;
/* copy argv to sargv and then append "match" */
DEFUN (show_ipv6_ospf6_route_match_detail,
show_ipv6_ospf6_route_match_detail_cmd,
- "show ipv6 ospf6 route X::X/M match detail",
+ "show ipv6 ospf6 route X:X::X:X/M match detail",
SHOW_STR
IP6_STR
OSPF6_STR
"Detailed information\n"
)
{
- char *sargv[CMD_ARGC_MAX];
+ const char *sargv[CMD_ARGC_MAX];
int i, sargc;
/* copy argv to sargv and then append "match" and "detail" */
return CMD_SUCCESS;
}
+ALIAS (show_ipv6_ospf6_route_match,
+ show_ipv6_ospf6_route_longer_cmd,
+ "show ipv6 ospf6 route X:X::X:X/M longer",
+ SHOW_STR
+ IP6_STR
+ OSPF6_STR
+ ROUTE_STR
+ "Specify IPv6 prefix\n"
+ "Display routes longer than the specified route\n"
+ )
+
+DEFUN (show_ipv6_ospf6_route_match_detail,
+ show_ipv6_ospf6_route_longer_detail_cmd,
+ "show ipv6 ospf6 route X:X::X:X/M longer detail",
+ SHOW_STR
+ IP6_STR
+ OSPF6_STR
+ ROUTE_STR
+ "Specify IPv6 prefix\n"
+ "Display routes longer than the specified route\n"
+ "Detailed information\n"
+ );
+
+ALIAS (show_ipv6_ospf6_route,
+ show_ipv6_ospf6_route_type_cmd,
+ "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
+ SHOW_STR
+ IP6_STR
+ OSPF6_STR
+ ROUTE_STR
+ "Dispaly Intra-Area routes\n"
+ "Dispaly Inter-Area routes\n"
+ "Dispaly Type-1 External routes\n"
+ "Dispaly Type-2 External routes\n"
+ )
+
+DEFUN (show_ipv6_ospf6_route_type_detail,
+ show_ipv6_ospf6_route_type_detail_cmd,
+ "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
+ SHOW_STR
+ IP6_STR
+ OSPF6_STR
+ ROUTE_STR
+ "Dispaly Intra-Area routes\n"
+ "Dispaly Inter-Area routes\n"
+ "Dispaly Type-1 External routes\n"
+ "Dispaly Type-2 External routes\n"
+ "Detailed information\n"
+ )
+{
+ const char *sargv[CMD_ARGC_MAX];
+ int i, sargc;
+
+ /* copy argv to sargv and then append "detail" */
+ for (i = 0; i < argc; i++)
+ sargv[i] = argv[i];
+ sargc = argc;
+ sargv[sargc++] = "detail";
+ sargv[sargc] = NULL;
+
+ ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
+ return CMD_SUCCESS;
+}
/* OSPF configuration write function. */
-int
+static int
config_write_ospf6 (struct vty *vty)
{
char router_id[16];
- listnode j, k;
+ struct listnode *j, *k;
struct ospf6_area *oa;
struct ospf6_interface *oi;
if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
return CMD_SUCCESS;
- inet_ntop (AF_INET, &ospf6->router_id, router_id, sizeof (router_id));
+ inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
vty_out (vty, "router ospf6%s", VNL);
- vty_out (vty, " router-id %s%s", router_id, VNL);
+ if (ospf6->router_id_static != 0)
+ vty_out (vty, " router-id %s%s", router_id, VNL);
ospf6_redistribute_config_write (vty);
ospf6_area_config_write (vty);
- for (j = listhead (ospf6->area_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
{
- oa = (struct ospf6_area *) getdata (j);
- for (k = listhead (oa->if_list); k; nextnode (k))
- {
- oi = (struct ospf6_interface *) getdata (k);
- vty_out (vty, " interface %s area %s%s",
- oi->interface->name, oa->name, VNL);
- }
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
+ vty_out (vty, " interface %s area %s%s",
+ oi->interface->name, oa->name, VNL);
}
vty_out (vty, "!%s", VNL);
return 0;
{
OSPF6_NODE,
"%s(config-ospf6)# ",
+ 1 /* VTYSH */
};
/* Install ospf related commands. */
void
-ospf6_top_init ()
+ospf6_top_init (void)
{
/* Install ospf6 top node. */
install_node (&ospf6_node, config_write_ospf6);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
+ install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
+ install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
+ install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
+ install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
+ install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_cmd);
+ install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
+ install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd);
+ install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
install_default (OSPF6_NODE);
install_element (OSPF6_NODE, &ospf6_router_id_cmd);