]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6d.c
zebra: Convert socket interface to use `union sockunion`
[mirror_frr.git] / ospf6d / ospf6d.c
index 6b47fca578d0cd8e4e691615bbd4155863c27063..db61fe087bb0155c1942f598b7d151df419476c4 100644 (file)
@@ -24,6 +24,7 @@
 #include "linklist.h"
 #include "vty.h"
 #include "command.h"
+#include "plist.h"
 
 #include "ospf6_proto.h"
 #include "ospf6_network.h"
@@ -44,8 +45,6 @@
 #include "ospf6d.h"
 #include "ospf6_bfd.h"
 
-char ospf6_daemon_version[] = OSPF6_DAEMON_VERSION;
-
 struct route_node *route_prev(struct route_node *node)
 {
        struct route_node *end;
@@ -70,21 +69,6 @@ struct route_node *route_prev(struct route_node *node)
        return prev;
 }
 
-
-/* show database functions */
-DEFUN (show_version_ospf6,
-       show_version_ospf6_cmd,
-       "show version ospf6",
-       SHOW_STR
-       "Display version\n"
-       "Display ospf6d version\n"
-      )
-{
-       vty_out(vty, "Zebra OSPF6d Version: %s\n", ospf6_daemon_version);
-
-       return CMD_SUCCESS;
-}
-
 static struct cmd_node debug_node = {
        DEBUG_NODE, "", 1 /* VTYSH */
 };
@@ -102,10 +86,24 @@ static int config_write_ospf6_debug(struct vty *vty)
        config_write_ospf6_debug_asbr(vty);
        config_write_ospf6_debug_abr(vty);
        config_write_ospf6_debug_flood(vty);
-       vty_out(vty, "!\n");
+
        return 0;
 }
 
+DEFUN_NOSH (show_debugging_ospf6,
+           show_debugging_ospf6_cmd,
+           "show debugging [ospf6]",
+           SHOW_STR
+           DEBUG_STR
+           OSPF6_STR)
+{
+       vty_out(vty, "OSPF6 debugging status:\n");
+
+       config_write_ospf6_debug(vty);
+
+       return CMD_SUCCESS;
+}
+
 #define AREA_LSDB_TITLE_FORMAT                                                 \
        "\n        Area Scoped Link State Database (Area %s)\n\n"
 #define IF_LSDB_TITLE_FORMAT                                                   \
@@ -128,9 +126,9 @@ static int parse_show_level(int idx_level, int argc, struct cmd_token **argv)
        return level;
 }
 
-static u_int16_t parse_type_spec(int idx_lsa, int argc, struct cmd_token **argv)
+static uint16_t parse_type_spec(int idx_lsa, int argc, struct cmd_token **argv)
 {
-       u_int16_t type = 0;
+       uint16_t type = 0;
 
        if (argc > idx_lsa) {
                if (strmatch(argv[idx_lsa]->text, "router"))
@@ -222,7 +220,7 @@ DEFUN (show_ipv6_ospf6_database_type,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int16_t type = 0;
+       uint16_t type = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
 
@@ -284,7 +282,7 @@ DEFUN (show_ipv6_ospf6_database_id,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int32_t id = 0;
+       uint32_t id = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
 
@@ -335,7 +333,7 @@ DEFUN (show_ipv6_ospf6_database_router,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int32_t adv_router = 0;
+       uint32_t adv_router = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
        inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
@@ -362,6 +360,49 @@ DEFUN (show_ipv6_ospf6_database_router,
        return CMD_SUCCESS;
 }
 
+DEFUN_HIDDEN (show_ipv6_ospf6_database_aggr_router,
+       show_ipv6_ospf6_database_aggr_router_cmd,
+       "show ipv6 ospf6 database aggr adv-router A.B.C.D",
+       SHOW_STR
+       IPV6_STR
+       OSPF6_STR
+       "Display Link state database\n"
+       "Aggregated Router LSA\n"
+       "Search by Advertising Router\n"
+       "Specify Advertising Router as IPv4 address notation\n")
+{
+       int level = OSPF6_LSDB_SHOW_LEVEL_DETAIL;
+       uint16_t type = htons(OSPF6_LSTYPE_ROUTER);
+       int idx_ipv4 = 6;
+       struct listnode *i;
+       struct ospf6 *o = ospf6;
+       struct ospf6_area *oa;
+       struct ospf6_lsdb *lsdb;
+       uint32_t adv_router = 0;
+
+       inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
+
+       for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+               if (adv_router == o->router_id)
+                       lsdb = oa->lsdb_self;
+               else
+                       lsdb = oa->lsdb;
+               if (ospf6_create_single_router_lsa(oa, lsdb, adv_router)
+                   == NULL) {
+                       vty_out(vty, "Adv router is not found in LSDB.");
+                       return CMD_SUCCESS;
+               }
+               ospf6_lsdb_show(vty, level, &type, NULL, NULL,
+                               oa->temp_router_lsa_lsdb);
+               /* Remove the temp cache */
+               ospf6_remove_temp_router_lsa(oa);
+       }
+
+       vty_out(vty, "\n");
+
+       return CMD_SUCCESS;
+}
+
 DEFUN (show_ipv6_ospf6_database_type_id,
        show_ipv6_ospf6_database_type_id_cmd,
        "show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> linkstate-id A.B.C.D [<detail|dump|internal>]",
@@ -393,8 +434,8 @@ DEFUN (show_ipv6_ospf6_database_type_id,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int16_t type = 0;
-       u_int32_t id = 0;
+       uint16_t type = 0;
+       uint32_t id = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
 
@@ -467,8 +508,8 @@ DEFUN (show_ipv6_ospf6_database_type_router,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int16_t type = 0;
-       u_int32_t adv_router = 0;
+       uint16_t type = 0;
+       uint32_t adv_router = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
 
@@ -534,8 +575,8 @@ DEFUN (show_ipv6_ospf6_database_id_router,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int32_t id = 0;
-       u_int32_t adv_router = 0;
+       uint32_t id = 0;
+       uint32_t adv_router = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
        inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
@@ -587,8 +628,8 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int32_t id = 0;
-       u_int32_t adv_router = 0;
+       uint32_t id = 0;
+       uint32_t adv_router = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
        inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
@@ -646,9 +687,9 @@ DEFUN (show_ipv6_ospf6_database_type_id_router,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int16_t type = 0;
-       u_int32_t id = 0;
-       u_int32_t adv_router = 0;
+       uint16_t type = 0;
+       uint32_t id = 0;
+       uint32_t adv_router = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
 
@@ -724,9 +765,9 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int16_t type = 0;
-       u_int32_t id = 0;
-       u_int32_t adv_router = 0;
+       uint16_t type = 0;
+       uint32_t id = 0;
+       uint32_t adv_router = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
 
@@ -787,7 +828,7 @@ DEFUN (show_ipv6_ospf6_database_self_originated,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int32_t adv_router = 0;
+       uint32_t adv_router = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
        level = parse_show_level(idx_level, argc, argv);
@@ -843,8 +884,8 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int16_t type = 0;
-       u_int32_t adv_router = 0;
+       uint16_t type = 0;
+       uint32_t adv_router = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
 
@@ -918,9 +959,9 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int16_t type = 0;
-       u_int32_t adv_router = 0;
-       u_int32_t id = 0;
+       uint16_t type = 0;
+       uint32_t adv_router = 0;
+       uint32_t id = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
 
@@ -993,9 +1034,9 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated,
        struct ospf6 *o = ospf6;
        struct ospf6_area *oa;
        struct ospf6_interface *oi;
-       u_int16_t type = 0;
-       u_int32_t adv_router = 0;
-       u_int32_t id = 0;
+       uint16_t type = 0;
+       uint32_t adv_router = 0;
+       uint32_t id = 0;
 
        OSPF6_CMD_CHECK_RUNNING();
 
@@ -1049,7 +1090,7 @@ DEFUN (show_ipv6_ospf6_border_routers,
        "Show detailed output\n")
 {
        int idx_ipv4 = 4;
-       u_int32_t adv_router;
+       uint32_t adv_router;
        struct ospf6_route *ro;
        struct prefix prefix;
 
@@ -1100,7 +1141,7 @@ DEFUN (show_ipv6_ospf6_linkstate,
        "Specify Router ID as IPv4 address notation\n"
        "Specify Link state ID as IPv4 address notation\n")
 {
-       int idx_ipv4 = 4;
+       int idx_ipv4 = 5;
        struct listnode *node;
        struct ospf6_area *oa;
 
@@ -1142,6 +1183,20 @@ DEFUN (show_ipv6_ospf6_linkstate_detail,
        return CMD_SUCCESS;
 }
 
+static void ospf6_plist_add(struct prefix_list *plist)
+{
+       if (prefix_list_afi(plist) != AFI_IP6)
+               return;
+       ospf6_area_plist_update(plist, 1);
+}
+
+static void ospf6_plist_del(struct prefix_list *plist)
+{
+       if (prefix_list_afi(plist) != AFI_IP6)
+               return;
+       ospf6_area_plist_update(plist, 0);
+}
+
 /* Install ospf related commands. */
 void ospf6_init(void)
 {
@@ -1157,6 +1212,9 @@ void ospf6_init(void)
        ospf6_asbr_init();
        ospf6_abr_init();
 
+       prefix_list_add_hook(ospf6_plist_add);
+       prefix_list_delete_hook(ospf6_plist_del);
+
        ospf6_bfd_init();
        install_node(&debug_node, config_write_ospf6_debug);
 
@@ -1174,7 +1232,7 @@ void ospf6_init(void)
 
        install_element_ospf6_clear_interface();
 
-       install_element(VIEW_NODE, &show_version_ospf6_cmd);
+       install_element(VIEW_NODE, &show_debugging_ospf6_cmd);
 
        install_element(VIEW_NODE, &show_ipv6_ospf6_border_routers_cmd);
 
@@ -1204,6 +1262,7 @@ void ospf6_init(void)
        install_element(
                VIEW_NODE,
                &show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd);
+       install_element(VIEW_NODE, &show_ipv6_ospf6_database_aggr_router_cmd);
 
        /* Make ospf protocol socket. */
        ospf6_serv_sock();