diff options
| author | Mobashshera Rasool <mrasool@vmware.com> | 2022-02-25 00:59:14 -0800 |
|---|---|---|
| committer | Mobashshera Rasool <mrasool@vmware.com> | 2022-02-28 01:38:41 -0800 |
| commit | 2328b7ef1e4a3cf0bc8d686ce5df639fbb5eb468 (patch) | |
| tree | d39dd37a6a1caf614691eea5bc56ba10a82fbdec /pimd/pim_cmd_common.c | |
| parent | 26cd3d66127d69aca75c5961c917c62792b60066 (diff) | |
pimd: Moving pim_cli_get_vrf_name function to common file
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
Diffstat (limited to 'pimd/pim_cmd_common.c')
| -rw-r--r-- | pimd/pim_cmd_common.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 23fff2f477..a85a2f0b4d 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -37,4 +37,28 @@ #include "pim_errors.h" #include "pim_nb.h" +/** + * Get current node VRF name. + * + * NOTE: + * In case of failure it will print error message to user. + * + * \returns name or NULL if failed to get VRF. + */ +const char *pim_cli_get_vrf_name(struct vty *vty) +{ + const struct lyd_node *vrf_node; + + /* Not inside any VRF context. */ + if (vty->xpath_index == 0) + return VRF_DEFAULT_NAME; + + vrf_node = yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH); + if (vrf_node == NULL) { + vty_out(vty, "%% Failed to get vrf dnode in configuration\n"); + return NULL; + } + + return yang_dnode_get_string(vrf_node, "./name"); +} |
