]> git.proxmox.com Git - mirror_frr.git/blobdiff - pathd/path_pcep_cli.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / pathd / path_pcep_cli.c
index db5f256a8643d41645b947f86f9ddb90f7697b83..6c660a3d085cbe053acb2ee21b20e7371de313f7 100644 (file)
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 2020 Volta Networks, Inc
  *                     Brady Johnson
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -40,9 +27,7 @@
 #include "pathd/path_pcep_lib.h"
 #include "pathd/path_pcep_pcc.h"
 
-#ifndef VTYSH_EXTRACT_PL
 #include "pathd/path_pcep_cli_clippy.c"
-#endif
 
 #define DEFAULT_PCE_PRECEDENCE 255
 #define DEFAULT_PCC_MSD 4
@@ -69,7 +54,7 @@ static int pcep_cli_pcep_pce_config_write(struct vty *vty);
 /* Internal Util Function declarations */
 static struct pce_opts_cli *pcep_cli_find_pce(const char *pce_name);
 static bool pcep_cli_add_pce(struct pce_opts_cli *pce_opts_cli);
-static struct pce_opts_cli *pcep_cli_create_pce_opts();
+static struct pce_opts_cli *pcep_cli_create_pce_opts(const char *name);
 static void pcep_cli_delete_pce(const char *pce_name);
 static void
 pcep_cli_merge_pcep_pce_config_options(struct pce_opts_cli *pce_opts_cli);
@@ -175,7 +160,6 @@ static struct cmd_node pcep_node = {
        .name = "srte pcep",
        .node = PCEP_NODE,
        .parent_node = SR_TRAFFIC_ENG_NODE,
-       .config_write = pcep_cli_pcep_config_write,
        .prompt = "%s(config-sr-te-pcep)# "
 };
 
@@ -183,7 +167,6 @@ static struct cmd_node pcep_pcc_node = {
        .name = "srte pcep pcc",
        .node = PCEP_PCC_NODE,
        .parent_node = PCEP_NODE,
-       .config_write = pcep_cli_pcc_config_write,
        .prompt = "%s(config-sr-te-pcep-pcc)# "
 };
 
@@ -191,7 +174,6 @@ static struct cmd_node pcep_pce_node = {
        .name = "srte pcep pce",
        .node = PCEP_PCE_NODE,
        .parent_node = PCEP_NODE,
-       .config_write = pcep_cli_pce_config_write,
        .prompt = "%s(config-sr-te-pcep-pce)# "
 };
 
@@ -199,7 +181,6 @@ static struct cmd_node pcep_pce_config_node = {
        .name = "srte pcep pce-config",
        .node = PCEP_PCE_CONFIG_NODE,
        .parent_node = PCEP_NODE,
-       .config_write = pcep_cli_pcep_pce_config_write,
        .prompt = "%s(pce-sr-te-pcep-pce-config)# "
 };
 
@@ -1031,7 +1012,7 @@ static int path_pcep_cli_pcc_pcc_peer(struct vty *vty, const char *peer_name,
 
        /* Verify the PCE has the IP set */
        struct in6_addr zero_v6_addr;
-       memset(&zero_v6_addr, 0, sizeof(struct in6_addr));
+       memset(&zero_v6_addr, 0, sizeof(zero_v6_addr));
        if (memcmp(&pce_opts->addr.ip, &zero_v6_addr, IPADDRSZ(&pce_opts->addr))
            == 0) {
                vty_out(vty,
@@ -1444,6 +1425,10 @@ int pcep_cli_debug_set_all(uint32_t flags, bool set)
 int pcep_cli_pcep_config_write(struct vty *vty)
 {
        vty_out(vty, "  pcep\n");
+       pcep_cli_pcep_pce_config_write(vty);
+       pcep_cli_pce_config_write(vty);
+       pcep_cli_pcc_config_write(vty);
+       vty_out(vty, "  exit\n");
        return 1;
 }
 
@@ -1468,7 +1453,7 @@ int pcep_cli_pcc_config_write(struct vty *vty)
        }
 
        if (pce_connections_g.num_connections == 0) {
-               return lines;
+               goto exit;
        }
 
        buf[0] = 0;
@@ -1495,6 +1480,8 @@ int pcep_cli_pcc_config_write(struct vty *vty)
                lines++;
                buf[0] = 0;
        }
+exit:
+       vty_out(vty, "   exit\n");
 
        return lines;
 }
@@ -1655,6 +1642,8 @@ int pcep_cli_pce_config_write(struct vty *vty)
 
                vty_out(vty, "%s", buf);
                buf[0] = '\0';
+
+               vty_out(vty, "   exit\n");
        }
 
        return lines;
@@ -1679,6 +1668,8 @@ int pcep_cli_pcep_pce_config_write(struct vty *vty)
                        pcep_cli_print_pce_config(group_opts, buf, sizeof(buf));
                vty_out(vty, "%s", buf);
                buf[0] = 0;
+
+               vty_out(vty, "   exit\n");
        }
 
        return lines;
@@ -1999,6 +1990,7 @@ DEFPY(pcep_cli_clear_srte_pcep_session,
 
 void pcep_cli_init(void)
 {
+       hook_register(pathd_srte_config_write, pcep_cli_pcep_config_write);
        hook_register(nb_client_debug_config_write,
                      pcep_cli_debug_config_write);
        hook_register(nb_client_debug_set_all, pcep_cli_debug_set_all);