summaryrefslogtreecommitdiff
path: root/ldpd/ldp_vty_exec.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2017-06-12 11:39:12 -0300
committerRenato Westphal <renato@openbsd.org>2017-06-16 14:43:42 -0300
commitc740f7d3678a8ea2c70a062c1207157e999bd6e8 (patch)
tree43dd4ca1494eb53827854efa1476ee0ae9e5b838 /ldpd/ldp_vty_exec.c
parent62e4232010330e515630399838288f6281d04de6 (diff)
ldpd: convert cli and get rid of the xml interface
The xml2cli.pl script was useful years ago when the vty code was very rudimentary. This is not the case anymore, so convert all ldpd CLI commands to use DEFUNs directly and get rid of the XML interface. The benefits are: * Consistency with the other daemons; * One less build dependency (the LibXML perl module); * Easier to add new commands. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ldpd/ldp_vty_exec.c')
-rw-r--r--ldpd/ldp_vty_exec.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c
index 3463fb6c63..5ea3ec6452 100644
--- a/ldpd/ldp_vty_exec.c
+++ b/ldpd/ldp_vty_exec.c
@@ -1582,24 +1582,22 @@ ldp_vty_get_af(const char *str, int *af)
}
int
-ldp_vty_show_binding(struct vty *vty, struct vty_arg *args[])
+ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
{
struct imsgbuf ibuf;
struct show_params params;
- const char *af_str;
int af;
if (ldp_vty_connect(&ibuf) < 0)
return (CMD_WARNING);
- af_str = vty_get_arg_value(args, "address-family");
if (ldp_vty_get_af(af_str, &af) < 0)
return (CMD_ERR_NO_MATCH);
memset(&params, 0, sizeof(params));
params.family = af;
- params.detail = vty_get_arg_value(args, "detail") ? 1 : 0;
- params.json = vty_get_arg_value(args, "json") ? 1 : 0;
+ params.detail = detail;
+ params.json = json;
if (!params.detail && !params.json)
vty_out(vty, "%-4s %-20s %-15s %-11s %-13s %6s%s", "AF",
@@ -1611,24 +1609,23 @@ ldp_vty_show_binding(struct vty *vty, struct vty_arg *args[])
}
int
-ldp_vty_show_discovery(struct vty *vty, struct vty_arg *args[])
+ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
+ int json)
{
struct imsgbuf ibuf;
struct show_params params;
- const char *af_str;
int af;
if (ldp_vty_connect(&ibuf) < 0)
return (CMD_WARNING);
- af_str = vty_get_arg_value(args, "address-family");
if (ldp_vty_get_af(af_str, &af) < 0)
return (CMD_ERR_NO_MATCH);
memset(&params, 0, sizeof(params));
params.family = af;
- params.detail = vty_get_arg_value(args, "detail") ? 1 : 0;
- params.json = vty_get_arg_value(args, "json") ? 1 : 0;
+ params.detail = detail;
+ params.json = json;
if (!params.detail && !params.json)
vty_out(vty, "%-4s %-15s %-8s %-15s %9s%s",
@@ -1643,24 +1640,22 @@ ldp_vty_show_discovery(struct vty *vty, struct vty_arg *args[])
}
int
-ldp_vty_show_interface(struct vty *vty, struct vty_arg *args[])
+ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
{
struct imsgbuf ibuf;
struct show_params params;
unsigned int ifidx = 0;
- const char *af_str;
int af;
if (ldp_vty_connect(&ibuf) < 0)
return (CMD_WARNING);
- af_str = vty_get_arg_value(args, "address-family");
if (ldp_vty_get_af(af_str, &af) < 0)
return (CMD_ERR_NO_MATCH);
memset(&params, 0, sizeof(params));
params.family = af;
- params.json = vty_get_arg_value(args, "json") ? 1 : 0;
+ params.json = json;
/* header */
if (!params.json) {
@@ -1675,9 +1670,9 @@ ldp_vty_show_interface(struct vty *vty, struct vty_arg *args[])
}
int
-ldp_vty_show_capabilities(struct vty *vty, struct vty_arg *args[])
+ldp_vty_show_capabilities(struct vty *vty, int json)
{
- if (vty_get_arg_value(args, "json")) {
+ if (json) {
json_object *json;
json_object *json_array;
json_object *json_cap;
@@ -1727,7 +1722,7 @@ ldp_vty_show_capabilities(struct vty *vty, struct vty_arg *args[])
}
int
-ldp_vty_show_neighbor(struct vty *vty, struct vty_arg *args[])
+ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
{
struct imsgbuf ibuf;
struct show_params params;
@@ -1736,9 +1731,9 @@ ldp_vty_show_neighbor(struct vty *vty, struct vty_arg *args[])
return (CMD_WARNING);
memset(&params, 0, sizeof(params));
- params.capabilities = vty_get_arg_value(args, "capabilities") ? 1 : 0;
- params.detail = vty_get_arg_value(args, "detail") ? 1 : 0;
- params.json = vty_get_arg_value(args, "json") ? 1 : 0;
+ params.capabilities = capabilities;
+ params.detail = detail;
+ params.json = json;
if (params.capabilities)
params.detail = 1;
@@ -1753,7 +1748,7 @@ ldp_vty_show_neighbor(struct vty *vty, struct vty_arg *args[])
}
int
-ldp_vty_show_atom_binding(struct vty *vty, struct vty_arg *args[])
+ldp_vty_show_atom_binding(struct vty *vty, int json)
{
struct imsgbuf ibuf;
struct show_params params;
@@ -1762,14 +1757,14 @@ ldp_vty_show_atom_binding(struct vty *vty, struct vty_arg *args[])
return (CMD_WARNING);
memset(&params, 0, sizeof(params));
- params.json = vty_get_arg_value(args, "json") ? 1 : 0;
+ params.json = json;
imsg_compose(&ibuf, IMSG_CTL_SHOW_L2VPN_BINDING, 0, 0, -1, NULL, 0);
return (ldp_vty_dispatch(vty, &ibuf, SHOW_L2VPN_BINDING, &params));
}
int
-ldp_vty_show_atom_vc(struct vty *vty, struct vty_arg *args[])
+ldp_vty_show_atom_vc(struct vty *vty, int json)
{
struct imsgbuf ibuf;
struct show_params params;
@@ -1778,7 +1773,7 @@ ldp_vty_show_atom_vc(struct vty *vty, struct vty_arg *args[])
return (CMD_WARNING);
memset(&params, 0, sizeof(params));
- params.json = vty_get_arg_value(args, "json") ? 1 : 0;
+ params.json = json;
if (!params.json) {
/* header */
@@ -1795,14 +1790,11 @@ ldp_vty_show_atom_vc(struct vty *vty, struct vty_arg *args[])
}
int
-ldp_vty_clear_nbr(struct vty *vty, struct vty_arg *args[])
+ldp_vty_clear_nbr(struct vty *vty, const char *addr_str)
{
struct imsgbuf ibuf;
- const char *addr_str;
struct ctl_nbr nbr;
- addr_str = vty_get_arg_value(args, "addr");
-
memset(&nbr, 0, sizeof(nbr));
if (addr_str &&
(ldp_get_address(addr_str, &nbr.af, &nbr.raddr) == -1 ||