ldpd: convert CLI code to use DEFPY

Yay :)

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2017-07-24 21:45:33 -03:00
parent cd49efdac8
commit 1224e5c434
6 changed files with 276 additions and 736 deletions

View File

@ -1,5 +1,7 @@
## Process this file with automake to produce Makefile.in.
include ../common.am
AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
@ -16,6 +18,8 @@ libldp_a_SOURCES = \
socket.c util.c ldp_vty_cmds.c ldp_vty_conf.c ldp_vty_exec.c \
ldp_debug.c ldp_zebra.c
ldp_vty_cmds.o: ldp_vty_cmds_clippy.c
noinst_HEADERS = \
control.h lde.h ldpd.h ldpe.h ldp.h log.h ldp_debug.h ldp_vty.h

View File

@ -38,31 +38,31 @@ struct cmd_node ldp_debug_node =
};
int
ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
const char *dir_str, int all)
ldp_vty_debug(struct vty *vty, const char *negate, const char *type_str,
const char *dir_str, const char *all)
{
if (strcmp(type_str, "discovery") == 0) {
if (dir_str == NULL)
return (CMD_WARNING_CONFIG_FAILED);
if (dir_str[0] == 'r') {
if (disable)
if (negate)
DEBUG_OFF(hello, HELLO_RECV);
else
DEBUG_ON(hello, HELLO_RECV);
} else {
if (disable)
if (negate)
DEBUG_OFF(hello, HELLO_SEND);
else
DEBUG_ON(hello, HELLO_SEND);
}
} else if (strcmp(type_str, "errors") == 0) {
if (disable)
if (negate)
DEBUG_OFF(errors, ERRORS);
else
DEBUG_ON(errors, ERRORS);
} else if (strcmp(type_str, "event") == 0) {
if (disable)
if (negate)
DEBUG_OFF(event, EVENT);
else
DEBUG_ON(event, EVENT);
@ -71,7 +71,7 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
return (CMD_WARNING_CONFIG_FAILED);
if (dir_str[0] == 'r') {
if (disable) {
if (negate) {
DEBUG_OFF(msg, MSG_RECV);
DEBUG_OFF(msg, MSG_RECV_ALL);
} else {
@ -80,7 +80,7 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
DEBUG_ON(msg, MSG_RECV_ALL);
}
} else {
if (disable) {
if (negate) {
DEBUG_OFF(msg, MSG_SEND);
DEBUG_OFF(msg, MSG_SEND_ALL);
} else {
@ -90,7 +90,7 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
}
}
} else if (strcmp(type_str, "zebra") == 0) {
if (disable)
if (negate)
DEBUG_OFF(zebra, ZEBRA);
else
DEBUG_ON(zebra, ZEBRA);

View File

@ -36,46 +36,46 @@ int ldp_get_address(const char *, int *, union ldpd_addr *);
int ldp_config_write(struct vty *);
int ldp_l2vpn_config_write(struct vty *);
int ldp_debug_config_write(struct vty *);
int ldp_vty_mpls_ldp (struct vty *, int);
int ldp_vty_address_family (struct vty *, int, const char *);
int ldp_vty_disc_holdtime(struct vty *, int, const char *, const char *);
int ldp_vty_disc_interval(struct vty *, int, const char *, const char *);
int ldp_vty_targeted_hello_accept(struct vty *, int, const char *);
int ldp_vty_nbr_session_holdtime(struct vty *, int, const char *, const char *);
int ldp_vty_af_session_holdtime(struct vty *, int, const char *);
int ldp_vty_interface(struct vty *, int, const char *);
int ldp_vty_trans_addr(struct vty *, int, const char *);
int ldp_vty_neighbor_targeted(struct vty *, int, const char *);
int ldp_vty_label_advertise(struct vty *, int, const char *, const char *);
int ldp_vty_label_allocate(struct vty *, int, int, const char *);
int ldp_vty_label_expnull(struct vty *, int, const char *);
int ldp_vty_label_accept(struct vty *, int, const char *, const char *);
int ldp_vty_ttl_security(struct vty *, int);
int ldp_vty_router_id(struct vty *, int, const char *);
int ldp_vty_ds_cisco_interop(struct vty *, int);
int ldp_vty_trans_pref_ipv4(struct vty *, int);
int ldp_vty_neighbor_password(struct vty *, int, const char *, const char *);
int ldp_vty_neighbor_ttl_security(struct vty *, int, const char *, const char *);
int ldp_vty_l2vpn(struct vty *, int, const char *);
int ldp_vty_l2vpn_bridge(struct vty *, int, const char *);
int ldp_vty_l2vpn_mtu(struct vty *, int, const char *);
int ldp_vty_l2vpn_pwtype(struct vty *, int, const char *);
int ldp_vty_l2vpn_interface(struct vty *, int, const char *);
int ldp_vty_l2vpn_pseudowire(struct vty *, int, const char *);
int ldp_vty_l2vpn_pw_cword(struct vty *, int, const char *);
int ldp_vty_l2vpn_pw_nbr_addr(struct vty *, int, const char *);
int ldp_vty_l2vpn_pw_nbr_id(struct vty *, int, const char *);
int ldp_vty_l2vpn_pw_pwid(struct vty *, int, const char *);
int ldp_vty_l2vpn_pw_pwstatus(struct vty *, int);
int ldp_vty_mpls_ldp (struct vty *, const char *);
int ldp_vty_address_family (struct vty *, const char *, const char *);
int ldp_vty_disc_holdtime(struct vty *, const char *, const char *, long);
int ldp_vty_disc_interval(struct vty *, const char *, const char *, long);
int ldp_vty_targeted_hello_accept(struct vty *, const char *, const char *);
int ldp_vty_nbr_session_holdtime(struct vty *, const char *, struct in_addr, long);
int ldp_vty_af_session_holdtime(struct vty *, const char *, long);
int ldp_vty_interface(struct vty *, const char *, const char *);
int ldp_vty_trans_addr(struct vty *, const char *, const char *);
int ldp_vty_neighbor_targeted(struct vty *, const char *, const char *);
int ldp_vty_label_advertise(struct vty *, const char *, const char *, const char *);
int ldp_vty_label_allocate(struct vty *, const char *, const char *, const char *);
int ldp_vty_label_expnull(struct vty *, const char *, const char *);
int ldp_vty_label_accept(struct vty *, const char *, const char *, const char *);
int ldp_vty_ttl_security(struct vty *, const char *);
int ldp_vty_router_id(struct vty *, const char *, struct in_addr);
int ldp_vty_ds_cisco_interop(struct vty *, const char *);
int ldp_vty_trans_pref_ipv4(struct vty *, const char *);
int ldp_vty_neighbor_password(struct vty *, const char *, struct in_addr, const char *);
int ldp_vty_neighbor_ttl_security(struct vty *, const char *, struct in_addr, const char *);
int ldp_vty_l2vpn(struct vty *, const char *, const char *);
int ldp_vty_l2vpn_bridge(struct vty *, const char *, const char *);
int ldp_vty_l2vpn_mtu(struct vty *, const char *, long);
int ldp_vty_l2vpn_pwtype(struct vty *, const char *, const char *);
int ldp_vty_l2vpn_interface(struct vty *, const char *, const char *);
int ldp_vty_l2vpn_pseudowire(struct vty *, const char *, const char *);
int ldp_vty_l2vpn_pw_cword(struct vty *, const char *, const char *);
int ldp_vty_l2vpn_pw_nbr_addr(struct vty *, const char *, const char *);
int ldp_vty_l2vpn_pw_nbr_id(struct vty *, const char *, struct in_addr);
int ldp_vty_l2vpn_pw_pwid(struct vty *, const char *, long);
int ldp_vty_l2vpn_pw_pwstatus(struct vty *, const char *);
int ldp_vty_clear_nbr(struct vty *, const char *);
int ldp_vty_debug(struct vty *, int, const char *, const char *, int);
int ldp_vty_show_binding(struct vty *, const char *, int, int);
int ldp_vty_show_discovery(struct vty *, const char *, int, int);
int ldp_vty_show_interface(struct vty *, const char *, int);
int ldp_vty_show_capabilities(struct vty *, int);
int ldp_vty_show_neighbor(struct vty *, int, int, int);
int ldp_vty_show_atom_binding(struct vty *, int);
int ldp_vty_show_atom_vc(struct vty *, int);
int ldp_vty_debug(struct vty *, const char *, const char *, const char *, const char *);
int ldp_vty_show_binding(struct vty *, const char *, const char *, const char *);
int ldp_vty_show_discovery(struct vty *, const char *, const char *, const char *);
int ldp_vty_show_interface(struct vty *, const char *, const char *);
int ldp_vty_show_capabilities(struct vty *, const char *);
int ldp_vty_show_neighbor(struct vty *, int, const char *, const char *);
int ldp_vty_show_atom_binding(struct vty *, const char *);
int ldp_vty_show_atom_vc(struct vty *, const char *);
int ldp_vty_show_debugging(struct vty *);
void ldp_vty_init(void);

File diff suppressed because it is too large Load Diff

View File

@ -407,9 +407,9 @@ ldp_iface_is_configured(struct ldpd_conf *xconf, const char *ifname)
}
int
ldp_vty_mpls_ldp(struct vty *vty, int disable)
ldp_vty_mpls_ldp(struct vty *vty, const char *negate)
{
if (disable)
if (negate)
vty_conf->flags &= ~F_LDPD_ENABLED;
else {
vty->node = LDP_NODE;
@ -422,7 +422,7 @@ ldp_vty_mpls_ldp(struct vty *vty, int disable)
}
int
ldp_vty_address_family(struct vty *vty, int disable, const char *af_str)
ldp_vty_address_family(struct vty *vty, const char *negate, const char *af_str)
{
struct ldpd_af_conf *af_conf;
int af;
@ -436,7 +436,7 @@ ldp_vty_address_family(struct vty *vty, int disable, const char *af_str)
} else
return (CMD_WARNING_CONFIG_FAILED);
if (disable) {
if (negate) {
af_conf->flags &= ~F_LDPD_AF_ENABLED;
ldp_config_apply(vty, vty_conf);
return (CMD_SUCCESS);
@ -460,23 +460,15 @@ ldp_vty_address_family(struct vty *vty, int disable, const char *af_str)
}
int
ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
const char *seconds_str)
ldp_vty_disc_holdtime(struct vty *vty, const char *negate,
const char *hello_type_str, long secs)
{
struct ldpd_af_conf *af_conf;
struct iface *iface;
struct iface_af *ia;
int af;
char *ep;
long int secs;
enum hello_type hello_type;
secs = strtol(seconds_str, &ep, 10);
if (*ep != '\0' || secs < MIN_HOLDTIME || secs > MAX_HOLDTIME) {
vty_out (vty, "%% Invalid holdtime\n");
return (CMD_WARNING_CONFIG_FAILED);
}
if (hello_type_str[0] == 'h')
hello_type = HELLO_LINK;
else
@ -484,7 +476,7 @@ ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
switch (vty->node) {
case LDP_NODE:
if (disable) {
if (negate) {
switch (hello_type) {
case HELLO_LINK:
vty_conf->lhello_holdtime = LINK_DFLT_HOLDTIME;
@ -511,7 +503,7 @@ ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (disable) {
if (negate) {
switch (hello_type) {
case HELLO_LINK:
af_conf->lhello_holdtime = 0;
@ -539,7 +531,7 @@ ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
VTY_CHECK_CONTEXT(iface);
ia = iface_af_get(iface, af);
if (disable)
if (negate)
ia->hello_holdtime = 0;
else
ia->hello_holdtime = secs;
@ -554,24 +546,15 @@ ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
}
int
ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
const char *seconds_str)
ldp_vty_disc_interval(struct vty *vty, const char *negate,
const char *hello_type_str, long secs)
{
struct ldpd_af_conf *af_conf;
struct iface *iface;
struct iface_af *ia;
int af;
char *ep;
long int secs;
enum hello_type hello_type;
secs = strtol(seconds_str, &ep, 10);
if (*ep != '\0' || secs < MIN_HELLO_INTERVAL ||
secs > MAX_HELLO_INTERVAL) {
vty_out (vty, "%% Invalid interval\n");
return (CMD_WARNING_CONFIG_FAILED);
}
if (hello_type_str[0] == 'h')
hello_type = HELLO_LINK;
else
@ -579,7 +562,7 @@ ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
switch (vty->node) {
case LDP_NODE:
if (disable) {
if (negate) {
switch (hello_type) {
case HELLO_LINK:
vty_conf->lhello_interval =
@ -607,7 +590,7 @@ ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (disable) {
if (negate) {
switch (hello_type) {
case HELLO_LINK:
af_conf->lhello_interval = 0;
@ -635,7 +618,7 @@ ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
VTY_CHECK_CONTEXT(iface);
ia = iface_af_get(iface, af);
if (disable)
if (negate)
ia->hello_interval = 0;
else
ia->hello_interval = secs;
@ -650,7 +633,7 @@ ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
}
int
ldp_vty_targeted_hello_accept(struct vty *vty, int disable,
ldp_vty_targeted_hello_accept(struct vty *vty, const char *negate,
const char *acl_from_str)
{
struct ldpd_af_conf *af_conf;
@ -659,7 +642,7 @@ ldp_vty_targeted_hello_accept(struct vty *vty, int disable,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (disable) {
if (negate) {
af_conf->flags &= ~F_LDPD_AF_THELLO_ACCEPT;
af_conf->acl_thello_accept_from[0] = '\0';
} else {
@ -677,29 +660,19 @@ ldp_vty_targeted_hello_accept(struct vty *vty, int disable,
}
int
ldp_vty_nbr_session_holdtime(struct vty *vty, int disable,
const char *lsr_id_str, const char *seconds_str)
ldp_vty_nbr_session_holdtime(struct vty *vty, const char *negate,
struct in_addr lsr_id, long secs)
{
char *ep;
long int secs;
struct in_addr lsr_id;
struct nbr_params *nbrp;
if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 ||
bad_addr_v4(lsr_id)) {
if (bad_addr_v4(lsr_id)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
secs = strtol(seconds_str, &ep, 10);
if (*ep != '\0' || secs < MIN_KEEPALIVE || secs > MAX_KEEPALIVE) {
vty_out (vty, "%% Invalid holdtime\n");
return (CMD_SUCCESS);
}
nbrp = nbr_params_find(vty_conf, lsr_id);
if (disable) {
if (negate) {
if (nbrp == NULL)
return (CMD_SUCCESS);
@ -723,24 +696,15 @@ ldp_vty_nbr_session_holdtime(struct vty *vty, int disable,
}
int
ldp_vty_af_session_holdtime(struct vty *vty, int disable,
const char *seconds_str)
ldp_vty_af_session_holdtime(struct vty *vty, const char *negate, long secs)
{
struct ldpd_af_conf *af_conf;
int af;
char *ep;
long int secs;
secs = strtol(seconds_str, &ep, 10);
if (*ep != '\0' || secs < MIN_KEEPALIVE || secs > MAX_KEEPALIVE) {
vty_out (vty, "%% Invalid holdtime\n");
return (CMD_SUCCESS);
}
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (disable)
if (negate)
af_conf->keepalive = DEFAULT_KEEPALIVE;
else
af_conf->keepalive = secs;
@ -751,7 +715,7 @@ ldp_vty_af_session_holdtime(struct vty *vty, int disable,
}
int
ldp_vty_interface(struct vty *vty, int disable, const char *ifname)
ldp_vty_interface(struct vty *vty, const char *negate, const char *ifname)
{
int af;
struct iface *iface;
@ -760,7 +724,7 @@ ldp_vty_interface(struct vty *vty, int disable, const char *ifname)
af = ldp_vty_get_af(vty);
iface = if_lookup_name(vty_conf, ifname);
if (disable) {
if (negate) {
if (iface == NULL)
return (CMD_SUCCESS);
@ -813,7 +777,7 @@ ldp_vty_interface(struct vty *vty, int disable, const char *ifname)
}
int
ldp_vty_trans_addr(struct vty *vty, int disable, const char *addr_str)
ldp_vty_trans_addr(struct vty *vty, const char *negate, const char *addr_str)
{
struct ldpd_af_conf *af_conf;
int af;
@ -821,7 +785,7 @@ ldp_vty_trans_addr(struct vty *vty, int disable, const char *addr_str)
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (disable)
if (negate)
memset(&af_conf->trans_addr, 0, sizeof(af_conf->trans_addr));
else {
if (inet_pton(af, addr_str, &af_conf->trans_addr) != 1 ||
@ -837,7 +801,7 @@ ldp_vty_trans_addr(struct vty *vty, int disable, const char *addr_str)
}
int
ldp_vty_neighbor_targeted(struct vty *vty, int disable, const char *addr_str)
ldp_vty_neighbor_targeted(struct vty *vty, const char *negate, const char *addr_str)
{
int af;
union ldpd_addr addr;
@ -857,7 +821,7 @@ ldp_vty_neighbor_targeted(struct vty *vty, int disable, const char *addr_str)
tnbr = tnbr_find(vty_conf, af, &addr);
if (disable) {
if (negate) {
if (tnbr == NULL)
return (CMD_SUCCESS);
@ -884,7 +848,7 @@ ldp_vty_neighbor_targeted(struct vty *vty, int disable, const char *addr_str)
}
int
ldp_vty_label_advertise(struct vty *vty, int disable, const char *acl_to_str,
ldp_vty_label_advertise(struct vty *vty, const char *negate, const char *acl_to_str,
const char *acl_for_str)
{
struct ldpd_af_conf *af_conf;
@ -893,7 +857,7 @@ ldp_vty_label_advertise(struct vty *vty, int disable, const char *acl_to_str,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (disable) {
if (negate) {
af_conf->acl_label_advertise_to[0] = '\0';
af_conf->acl_label_advertise_for[0] = '\0';
} else {
@ -915,7 +879,7 @@ ldp_vty_label_advertise(struct vty *vty, int disable, const char *acl_to_str,
}
int
ldp_vty_label_allocate(struct vty *vty, int disable, int host_routes,
ldp_vty_label_allocate(struct vty *vty, const char *negate, const char *host_routes,
const char *acl_for_str)
{
struct ldpd_af_conf *af_conf;
@ -926,7 +890,7 @@ ldp_vty_label_allocate(struct vty *vty, int disable, int host_routes,
af_conf->flags &= ~F_LDPD_AF_ALLOCHOSTONLY;
af_conf->acl_label_allocate_for[0] = '\0';
if (!disable) {
if (!negate) {
if (host_routes)
af_conf->flags |= F_LDPD_AF_ALLOCHOSTONLY;
else
@ -940,7 +904,7 @@ ldp_vty_label_allocate(struct vty *vty, int disable, int host_routes,
}
int
ldp_vty_label_expnull(struct vty *vty, int disable, const char *acl_for_str)
ldp_vty_label_expnull(struct vty *vty, const char *negate, const char *acl_for_str)
{
struct ldpd_af_conf *af_conf;
int af;
@ -948,7 +912,7 @@ ldp_vty_label_expnull(struct vty *vty, int disable, const char *acl_for_str)
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (disable) {
if (negate) {
af_conf->flags &= ~F_LDPD_AF_EXPNULL;
af_conf->acl_label_expnull_for[0] = '\0';
} else {
@ -966,7 +930,7 @@ ldp_vty_label_expnull(struct vty *vty, int disable, const char *acl_for_str)
}
int
ldp_vty_label_accept(struct vty *vty, int disable, const char *acl_from_str,
ldp_vty_label_accept(struct vty *vty, const char *negate, const char *acl_from_str,
const char *acl_for_str)
{
struct ldpd_af_conf *af_conf;
@ -975,7 +939,7 @@ ldp_vty_label_accept(struct vty *vty, int disable, const char *acl_from_str,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (disable) {
if (negate) {
af_conf->acl_label_accept_from[0] = '\0';
af_conf->acl_label_accept_for[0] = '\0';
} else {
@ -997,7 +961,7 @@ ldp_vty_label_accept(struct vty *vty, int disable, const char *acl_from_str,
}
int
ldp_vty_ttl_security(struct vty *vty, int disable)
ldp_vty_ttl_security(struct vty *vty, const char *negate)
{
struct ldpd_af_conf *af_conf;
int af;
@ -1005,7 +969,7 @@ ldp_vty_ttl_security(struct vty *vty, int disable)
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (disable)
if (negate)
af_conf->flags &= ~F_LDPD_AF_NO_GTSM;
else
af_conf->flags |= F_LDPD_AF_NO_GTSM;
@ -1016,16 +980,16 @@ ldp_vty_ttl_security(struct vty *vty, int disable)
}
int
ldp_vty_router_id(struct vty *vty, int disable, const char *addr_str)
ldp_vty_router_id(struct vty *vty, const char *negate, struct in_addr address)
{
if (disable)
if (negate)
vty_conf->rtr_id.s_addr = INADDR_ANY;
else {
if (inet_pton(AF_INET, addr_str, &vty_conf->rtr_id) != 1 ||
bad_addr_v4(vty_conf->rtr_id)) {
if (bad_addr_v4(address)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_SUCCESS);
}
vty_conf->rtr_id = address;
}
ldp_config_apply(vty, vty_conf);
@ -1034,9 +998,9 @@ ldp_vty_router_id(struct vty *vty, int disable, const char *addr_str)
}
int
ldp_vty_ds_cisco_interop(struct vty *vty, int disable)
ldp_vty_ds_cisco_interop(struct vty *vty, const char * negate)
{
if (disable)
if (negate)
vty_conf->flags &= ~F_LDPD_DS_CISCO_INTEROP;
else
vty_conf->flags |= F_LDPD_DS_CISCO_INTEROP;
@ -1047,9 +1011,9 @@ ldp_vty_ds_cisco_interop(struct vty *vty, int disable)
}
int
ldp_vty_trans_pref_ipv4(struct vty *vty, int disable)
ldp_vty_trans_pref_ipv4(struct vty *vty, const char *negate)
{
if (disable)
if (negate)
vty_conf->trans_pref = DUAL_STACK_LDPOV6;
else
vty_conf->trans_pref = DUAL_STACK_LDPOV4;
@ -1060,22 +1024,20 @@ ldp_vty_trans_pref_ipv4(struct vty *vty, int disable)
}
int
ldp_vty_neighbor_password(struct vty *vty, int disable, const char *lsr_id_str,
ldp_vty_neighbor_password(struct vty *vty, const char *negate, struct in_addr lsr_id,
const char *password_str)
{
struct in_addr lsr_id;
size_t password_len;
struct nbr_params *nbrp;
if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 ||
bad_addr_v4(lsr_id)) {
if (bad_addr_v4(lsr_id)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
nbrp = nbr_params_find(vty_conf, lsr_id);
if (disable) {
if (negate) {
if (nbrp == NULL)
return (CMD_SUCCESS);
@ -1105,16 +1067,14 @@ ldp_vty_neighbor_password(struct vty *vty, int disable, const char *lsr_id_str,
}
int
ldp_vty_neighbor_ttl_security(struct vty *vty, int disable,
const char *lsr_id_str, const char *hops_str)
ldp_vty_neighbor_ttl_security(struct vty *vty, const char *negate,
struct in_addr lsr_id, const char *hops_str)
{
struct in_addr lsr_id;
struct nbr_params *nbrp;
long int hops = 0;
char *ep;
if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 ||
bad_addr_v4(lsr_id)) {
if (bad_addr_v4(lsr_id)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
@ -1129,7 +1089,7 @@ ldp_vty_neighbor_ttl_security(struct vty *vty, int disable,
nbrp = nbr_params_find(vty_conf, lsr_id);
if (disable) {
if (negate) {
if (nbrp == NULL)
return (CMD_SUCCESS);
@ -1159,7 +1119,7 @@ ldp_vty_neighbor_ttl_security(struct vty *vty, int disable,
}
int
ldp_vty_l2vpn(struct vty *vty, int disable, const char *name_str)
ldp_vty_l2vpn(struct vty *vty, const char *negate, const char *name_str)
{
struct l2vpn *l2vpn;
struct l2vpn_if *lif;
@ -1167,7 +1127,7 @@ ldp_vty_l2vpn(struct vty *vty, int disable, const char *name_str)
l2vpn = l2vpn_find(vty_conf, name_str);
if (disable) {
if (negate) {
if (l2vpn == NULL)
return (CMD_SUCCESS);
@ -1204,11 +1164,11 @@ ldp_vty_l2vpn(struct vty *vty, int disable, const char *name_str)
}
int
ldp_vty_l2vpn_bridge(struct vty *vty, int disable, const char *ifname)
ldp_vty_l2vpn_bridge(struct vty *vty, const char *negate, const char *ifname)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
if (disable)
if (negate)
memset(l2vpn->br_ifname, 0, sizeof(l2vpn->br_ifname));
else
strlcpy(l2vpn->br_ifname, ifname, sizeof(l2vpn->br_ifname));
@ -1219,19 +1179,11 @@ ldp_vty_l2vpn_bridge(struct vty *vty, int disable, const char *ifname)
}
int
ldp_vty_l2vpn_mtu(struct vty *vty, int disable, const char *mtu_str)
ldp_vty_l2vpn_mtu(struct vty *vty, const char *negate, long mtu)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
char *ep;
int mtu;
mtu = strtol(mtu_str, &ep, 10);
if (*ep != '\0' || mtu < MIN_L2VPN_MTU || mtu > MAX_L2VPN_MTU) {
vty_out (vty, "%% Invalid MTU\n");
return (CMD_WARNING_CONFIG_FAILED);
}
if (disable)
if (negate)
l2vpn->mtu = DEFAULT_L2VPN_MTU;
else
l2vpn->mtu = mtu;
@ -1242,7 +1194,7 @@ ldp_vty_l2vpn_mtu(struct vty *vty, int disable, const char *mtu_str)
}
int
ldp_vty_l2vpn_pwtype(struct vty *vty, int disable, const char *type_str)
ldp_vty_l2vpn_pwtype(struct vty *vty, const char *negate, const char *type_str)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
int pw_type;
@ -1252,7 +1204,7 @@ ldp_vty_l2vpn_pwtype(struct vty *vty, int disable, const char *type_str)
else
pw_type = PW_TYPE_ETHERNET_TAGGED;
if (disable)
if (negate)
l2vpn->pw_type = DEFAULT_PW_TYPE;
else
l2vpn->pw_type = pw_type;
@ -1263,14 +1215,14 @@ ldp_vty_l2vpn_pwtype(struct vty *vty, int disable, const char *type_str)
}
int
ldp_vty_l2vpn_interface(struct vty *vty, int disable, const char *ifname)
ldp_vty_l2vpn_interface(struct vty *vty, const char *negate, const char *ifname)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
struct l2vpn_if *lif;
lif = l2vpn_if_find(l2vpn, ifname);
if (disable) {
if (negate) {
if (lif == NULL)
return (CMD_SUCCESS);
@ -1301,14 +1253,14 @@ ldp_vty_l2vpn_interface(struct vty *vty, int disable, const char *ifname)
}
int
ldp_vty_l2vpn_pseudowire(struct vty *vty, int disable, const char *ifname)
ldp_vty_l2vpn_pseudowire(struct vty *vty, const char *negate, const char *ifname)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
struct l2vpn_pw *pw;
pw = l2vpn_pw_find(l2vpn, ifname);
if (disable) {
if (negate) {
if (pw == NULL)
return (CMD_SUCCESS);
@ -1347,11 +1299,11 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, int disable, const char *ifname)
}
int
ldp_vty_l2vpn_pw_cword(struct vty *vty, int disable, const char *preference_str)
ldp_vty_l2vpn_pw_cword(struct vty *vty, const char *negate, const char *preference_str)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
if (disable)
if (negate)
pw->flags |= F_PW_CWORD_CONF;
else {
if (preference_str[0] == 'e')
@ -1366,7 +1318,7 @@ ldp_vty_l2vpn_pw_cword(struct vty *vty, int disable, const char *preference_str)
}
int
ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, int disable, const char *addr_str)
ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, const char *negate, const char *addr_str)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
int af;
@ -1378,7 +1330,7 @@ ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, int disable, const char *addr_str)
return (CMD_WARNING_CONFIG_FAILED);
}
if (disable) {
if (negate) {
pw->af = AF_UNSPEC;
memset(&pw->addr, 0, sizeof(pw->addr));
pw->flags &= ~F_PW_STATIC_NBR_ADDR;
@ -1394,18 +1346,16 @@ ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, int disable, const char *addr_str)
}
int
ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, int disable, const char *lsr_id_str)
ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, const char *negate, struct in_addr lsr_id)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
struct in_addr lsr_id;
if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 ||
bad_addr_v4(lsr_id)) {
if (bad_addr_v4(lsr_id)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
if (disable)
if (negate)
pw->lsr_id.s_addr = INADDR_ANY;
else
pw->lsr_id = lsr_id;
@ -1416,19 +1366,11 @@ ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, int disable, const char *lsr_id_str)
}
int
ldp_vty_l2vpn_pw_pwid(struct vty *vty, int disable, const char *pwid_str)
ldp_vty_l2vpn_pw_pwid(struct vty *vty, const char *negate, long pwid)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
char *ep;
uint32_t pwid;
pwid = strtol(pwid_str, &ep, 10);
if (*ep != '\0' || pwid < MIN_PWID_ID || pwid > MAX_PWID_ID) {
vty_out (vty, "%% Invalid pw-id\n");
return (CMD_WARNING_CONFIG_FAILED);
}
if (disable)
if (negate)
pw->pwid = 0;
else
pw->pwid = pwid;
@ -1439,11 +1381,11 @@ ldp_vty_l2vpn_pw_pwid(struct vty *vty, int disable, const char *pwid_str)
}
int
ldp_vty_l2vpn_pw_pwstatus(struct vty *vty, int disable)
ldp_vty_l2vpn_pw_pwstatus(struct vty *vty, const char *negate)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
if (disable)
if (negate)
pw->flags |= F_PW_STATUSTLV_CONF;
else
pw->flags &= ~F_PW_STATUSTLV_CONF;

View File

@ -1565,7 +1565,7 @@ ldp_vty_get_af(const char *str, int *af)
}
int
ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
ldp_vty_show_binding(struct vty *vty, const char *af_str, const char *detail, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@ -1579,8 +1579,8 @@ ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
memset(&params, 0, sizeof(params));
params.family = af;
params.detail = detail;
params.json = json;
params.detail = (detail) ? 1 : 0;
params.json = (json) ? 1 : 0;
if (!params.detail && !params.json)
vty_out (vty, "%-4s %-20s %-15s %-11s %-13s %6s\n", "AF",
@ -1592,8 +1592,8 @@ ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
}
int
ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
int json)
ldp_vty_show_discovery(struct vty *vty, const char *af_str, const char *detail,
const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@ -1607,8 +1607,8 @@ ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
memset(&params, 0, sizeof(params));
params.family = af;
params.detail = detail;
params.json = json;
params.detail = (detail) ? 1 : 0;
params.json = (json) ? 1 : 0;
if (!params.detail && !params.json)
vty_out (vty, "%-4s %-15s %-8s %-15s %9s\n",
@ -1623,7 +1623,7 @@ ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
}
int
ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
ldp_vty_show_interface(struct vty *vty, const char *af_str, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@ -1638,7 +1638,7 @@ ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
memset(&params, 0, sizeof(params));
params.family = af;
params.json = json;
params.json = (json) ? 1 : 0;
/* header */
if (!params.json) {
@ -1652,7 +1652,7 @@ ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
}
int
ldp_vty_show_capabilities(struct vty *vty, int json)
ldp_vty_show_capabilities(struct vty *vty, const char *json)
{
if (json) {
json_object *json;
@ -1703,7 +1703,7 @@ ldp_vty_show_capabilities(struct vty *vty, int json)
}
int
ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
ldp_vty_show_neighbor(struct vty *vty, int capabilities, const char *detail, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@ -1713,8 +1713,8 @@ ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
memset(&params, 0, sizeof(params));
params.capabilities = capabilities;
params.detail = detail;
params.json = json;
params.detail = (detail) ? 1 : 0;
params.json = (json) ? 1 : 0;
if (params.capabilities)
params.detail = 1;
@ -1728,7 +1728,7 @@ ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
}
int
ldp_vty_show_atom_binding(struct vty *vty, int json)
ldp_vty_show_atom_binding(struct vty *vty, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@ -1737,14 +1737,14 @@ ldp_vty_show_atom_binding(struct vty *vty, int json)
return (CMD_WARNING);
memset(&params, 0, sizeof(params));
params.json = json;
params.json = (json) ? 1 : 0;
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, int json)
ldp_vty_show_atom_vc(struct vty *vty, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@ -1753,7 +1753,7 @@ ldp_vty_show_atom_vc(struct vty *vty, int json)
return (CMD_WARNING);
memset(&params, 0, sizeof(params));
params.json = json;
params.json = (json) ? 1 : 0;
if (!params.json) {
/* header */