]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_top.c
[trivia] finish off static'ification of ospf6d and ripngd
[mirror_frr.git] / ospf6d / ospf6_top.c
index b0fe5ca7d286fb704a651e6291cfdaca8e43420d..f59b6f95c30289bac495365e1883a6e8a143b6c3 100644 (file)
@@ -51,7 +51,7 @@
 /* global ospf6d variable */
 struct ospf6 *ospf6;
 
-void
+static void
 ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
 {
   switch (ntohs (lsa->header->type))
@@ -65,7 +65,7 @@ ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
     }
 }
 
-void
+static void
 ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
 {
   switch (ntohs (lsa->header->type))
@@ -79,21 +79,21 @@ ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
     }
 }
 
-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_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
@@ -101,7 +101,7 @@ ospf6_top_brouter_hook_add (struct ospf6_route *route)
   ospf6_abr_originate_summary (route);
 }
 
-void
+static void
 ospf6_top_brouter_hook_remove (struct ospf6_route *route)
 {
   ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
@@ -109,8 +109,8 @@ ospf6_top_brouter_hook_remove (struct ospf6_route *route)
   ospf6_abr_originate_summary (route);
 }
 
-struct ospf6 *
-ospf6_create ()
+static struct ospf6 *
+ospf6_create (void)
 {
   struct ospf6 *o;
 
@@ -126,31 +126,32 @@ ospf6_create ()
   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)
 {
-  struct 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);
@@ -164,37 +165,32 @@ ospf6_delete (struct ospf6 *o)
   XFREE (MTYPE_OSPF6_TOP, o);
 }
 
-void
+static void
 ospf6_enable (struct ospf6 *o)
 {
-  struct 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)
 {
-  struct 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);
@@ -202,7 +198,7 @@ ospf6_disable (struct ospf6 *o)
     }
 }
 
-int
+static int
 ospf6_maxage_remover (struct thread *thread)
 {
   struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
@@ -213,15 +209,12 @@ ospf6_maxage_remover (struct thread *thread)
 
   o->maxage_remover = (struct thread *) NULL;
 
-  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;
@@ -231,14 +224,11 @@ ospf6_maxage_remover (struct thread *thread)
         }
     }
 
-  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);
@@ -437,7 +427,7 @@ DEFUN (no_ospf6_interface_area,
   return CMD_SUCCESS;
 }
 
-void
+static void
 ospf6_show (struct vty *vty, struct ospf6 *o)
 {
   struct listnode *n;
@@ -466,11 +456,9 @@ ospf6_show (struct vty *vty, struct ospf6 *o)
   /* 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 */
@@ -511,7 +499,7 @@ ALIAS (show_ipv6_ospf6_route,
        "Specify IPv6 prefix\n"
        "Detailed information\n"
        "Summary of route table\n"
-       );
+       )
 
 DEFUN (show_ipv6_ospf6_route_match,
        show_ipv6_ospf6_route_match_cmd,
@@ -565,6 +553,29 @@ DEFUN (show_ipv6_ospf6_route_match_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)",
@@ -576,7 +587,7 @@ ALIAS (show_ipv6_ospf6_route,
        "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,
@@ -607,7 +618,7 @@ DEFUN (show_ipv6_ospf6_route_type_detail,
 }
 
 /* OSPF configuration write function. */
-int
+static int
 config_write_ospf6 (struct vty *vty)
 {
   char router_id[16];
@@ -629,15 +640,11 @@ config_write_ospf6 (struct vty *vty)
   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;
@@ -653,7 +660,7 @@ struct cmd_node ospf6_node =
 
 /* Install ospf related commands. */
 void
-ospf6_top_init ()
+ospf6_top_init (void)
 {
   /* Install ospf6 top node. */
   install_node (&ospf6_node, config_write_ospf6);
@@ -666,12 +673,16 @@ ospf6_top_init ()
   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);