int
ldp_get_address(const char *str, int *af, union ldpd_addr *addr)
{
+ if (!str || !af || !addr)
+ return (-1);
+
memset(addr, 0, sizeof(*addr));
if (inet_pton(AF_INET, str, &addr->v4) == 1) {
if (!ia->enabled)
continue;
- vty_outln (vty, " !");
- vty_outln (vty, " interface %s", iface->name);
+ vty_out (vty, " !\n");
+ vty_out (vty, " interface %s\n", iface->name);
if (ia->hello_holdtime != LINK_DFLT_HOLDTIME &&
ia->hello_holdtime != 0)
- vty_outln (vty, " discovery hello holdtime %u",
+ vty_out (vty, " discovery hello holdtime %u\n",
ia->hello_holdtime);
if (ia->hello_interval != DEFAULT_HELLO_INTERVAL &&
ia->hello_interval != 0)
- vty_outln (vty, " discovery hello interval %u",
+ vty_out (vty, " discovery hello interval %u\n",
ia->hello_interval);
}
}
if (!(af_conf->flags & F_LDPD_AF_ENABLED))
return;
- vty_outln (vty, " !");
- vty_outln (vty, " address-family %s", af_name(af));
+ vty_out (vty, " !\n");
+ vty_out (vty, " address-family %s\n", af_name(af));
if (af_conf->lhello_holdtime != LINK_DFLT_HOLDTIME &&
af_conf->lhello_holdtime != 0 )
- vty_outln (vty, " discovery hello holdtime %u",
+ vty_out (vty, " discovery hello holdtime %u\n",
af_conf->lhello_holdtime);
if (af_conf->lhello_interval != DEFAULT_HELLO_INTERVAL &&
af_conf->lhello_interval != 0)
- vty_outln (vty, " discovery hello interval %u",
+ vty_out (vty, " discovery hello interval %u\n",
af_conf->lhello_interval);
if (af_conf->flags & F_LDPD_AF_THELLO_ACCEPT) {
if (af_conf->acl_thello_accept_from[0] != '\0')
vty_out(vty, " from %s",
af_conf->acl_thello_accept_from);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
if (af_conf->thello_holdtime != TARGETED_DFLT_HOLDTIME &&
af_conf->thello_holdtime != 0)
- vty_outln (vty, " discovery targeted-hello holdtime %u",
+ vty_out (vty, " discovery targeted-hello holdtime %u\n",
af_conf->thello_holdtime);
if (af_conf->thello_interval != DEFAULT_HELLO_INTERVAL &&
af_conf->thello_interval != 0)
- vty_outln (vty, " discovery targeted-hello interval %u",
+ vty_out (vty, " discovery targeted-hello interval %u\n",
af_conf->thello_interval);
if (ldp_addrisset(af, &af_conf->trans_addr))
- vty_outln (vty, " discovery transport-address %s",
+ vty_out (vty, " discovery transport-address %s\n",
log_addr(af, &af_conf->trans_addr));
else
- vty_outln (vty,
- " ! Incomplete config, specify a discovery " "transport-address");
+ vty_out (vty,
+ " ! Incomplete config, specify a discovery transport-address\n");
if ((af_conf->flags & F_LDPD_AF_ALLOCHOSTONLY) ||
af_conf->acl_label_allocate_for[0] != '\0') {
else
vty_out(vty, " for %s",
af_conf->acl_label_allocate_for);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
if (af_conf->acl_label_advertise_for[0] != '\0' ||
if (af_conf->acl_label_advertise_for[0] != '\0')
vty_out(vty, " for %s",
af_conf->acl_label_advertise_for);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
if (af_conf->flags & F_LDPD_AF_EXPNULL) {
if (af_conf->acl_label_expnull_for[0] != '\0')
vty_out(vty, " for %s",
af_conf->acl_label_expnull_for);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
if (af_conf->acl_label_accept_for[0] != '\0' ||
if (af_conf->acl_label_accept_for[0] != '\0')
vty_out(vty, " for %s",
af_conf->acl_label_accept_for);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
if (af_conf->flags & F_LDPD_AF_NO_GTSM)
- vty_outln (vty, " ttl-security disable");
+ vty_out (vty, " ttl-security disable\n");
if (af_conf->keepalive != DEFAULT_KEEPALIVE)
- vty_outln (vty, " session holdtime %u",af_conf->keepalive);
+ vty_out (vty, " session holdtime %u\n",af_conf->keepalive);
RB_FOREACH(tnbr, tnbr_head, &ldpd_conf->tnbr_tree) {
if (tnbr->af == af) {
- vty_outln (vty, " !");
- vty_outln (vty, " neighbor %s targeted",
+ vty_out (vty, " !\n");
+ vty_out (vty, " neighbor %s targeted\n",
log_addr(tnbr->af, &tnbr->addr));
}
}
ldp_af_iface_config_write(vty, af);
- vty_outln (vty, " !");
+ vty_out(vty, " !\n");
+ vty_out(vty, " exit-address-family\n");
}
int
if (!(ldpd_conf->flags & F_LDPD_ENABLED))
return (0);
- vty_outln (vty, "mpls ldp");
+ vty_out (vty, "mpls ldp\n");
if (ldpd_conf->rtr_id.s_addr != 0)
- vty_outln (vty, " router-id %s",
+ vty_out (vty, " router-id %s\n",
inet_ntoa(ldpd_conf->rtr_id));
if (ldpd_conf->lhello_holdtime != LINK_DFLT_HOLDTIME &&
ldpd_conf->lhello_holdtime != 0)
- vty_outln (vty, " discovery hello holdtime %u",
+ vty_out (vty, " discovery hello holdtime %u\n",
ldpd_conf->lhello_holdtime);
if (ldpd_conf->lhello_interval != DEFAULT_HELLO_INTERVAL &&
ldpd_conf->lhello_interval != 0)
- vty_outln (vty, " discovery hello interval %u",
+ vty_out (vty, " discovery hello interval %u\n",
ldpd_conf->lhello_interval);
if (ldpd_conf->thello_holdtime != TARGETED_DFLT_HOLDTIME &&
ldpd_conf->thello_holdtime != 0)
- vty_outln (vty, " discovery targeted-hello holdtime %u",
+ vty_out (vty, " discovery targeted-hello holdtime %u\n",
ldpd_conf->thello_holdtime);
if (ldpd_conf->thello_interval != DEFAULT_HELLO_INTERVAL &&
ldpd_conf->thello_interval != 0)
- vty_outln (vty, " discovery targeted-hello interval %u",
+ vty_out (vty, " discovery targeted-hello interval %u\n",
ldpd_conf->thello_interval);
if (ldpd_conf->trans_pref == DUAL_STACK_LDPOV4)
- vty_outln (vty,
- " dual-stack transport-connection prefer ipv4");
+ vty_out (vty,
+ " dual-stack transport-connection prefer ipv4\n");
if (ldpd_conf->flags & F_LDPD_DS_CISCO_INTEROP)
- vty_outln (vty, " dual-stack cisco-interop");
+ vty_out (vty, " dual-stack cisco-interop\n");
RB_FOREACH(nbrp, nbrp_head, &ldpd_conf->nbrp_tree) {
if (nbrp->flags & F_NBRP_KEEPALIVE)
- vty_outln (vty, " neighbor %s session holdtime %u",
+ vty_out (vty, " neighbor %s session holdtime %u\n",
inet_ntoa(nbrp->lsr_id),nbrp->keepalive);
if (nbrp->flags & F_NBRP_GTSM) {
if (nbrp->gtsm_enabled)
- vty_outln (vty, " neighbor %s ttl-security hops "
- "%u", inet_ntoa(nbrp->lsr_id),
+ vty_out (vty, " neighbor %s ttl-security hops "
+ "%u\n", inet_ntoa(nbrp->lsr_id),
nbrp->gtsm_hops);
else
- vty_outln (vty, " neighbor %s ttl-security "
- "disable",inet_ntoa(nbrp->lsr_id));
+ vty_out (vty, " neighbor %s ttl-security "
+ "disable\n",inet_ntoa(nbrp->lsr_id));
}
if (nbrp->auth.method == AUTH_MD5SIG)
- vty_outln (vty, " neighbor %s password %s",
+ vty_out (vty, " neighbor %s password %s\n",
inet_ntoa(nbrp->lsr_id),nbrp->auth.md5key);
}
ldp_af_config_write(vty, AF_INET, ldpd_conf, &ldpd_conf->ipv4);
ldp_af_config_write(vty, AF_INET6, ldpd_conf, &ldpd_conf->ipv6);
- vty_outln (vty, " !");
- vty_outln (vty, "!");
+ vty_out (vty, " !\n");
+ vty_out (vty, "!\n");
return (1);
}
int missing_lsrid = 0;
int missing_pwid = 0;
- vty_outln (vty, " !");
- vty_outln (vty, " member pseudowire %s", pw->ifname);
+ vty_out (vty, " !\n");
+ vty_out (vty, " member pseudowire %s\n", pw->ifname);
if (pw->lsr_id.s_addr != INADDR_ANY)
- vty_outln (vty, " neighbor lsr-id %s",inet_ntoa(pw->lsr_id));
+ vty_out (vty, " neighbor lsr-id %s\n",inet_ntoa(pw->lsr_id));
else
missing_lsrid = 1;
if (pw->flags & F_PW_STATIC_NBR_ADDR)
- vty_outln (vty, " neighbor address %s",
+ vty_out (vty, " neighbor address %s\n",
log_addr(pw->af, &pw->addr));
if (pw->pwid != 0)
- vty_outln (vty, " pw-id %u", pw->pwid);
+ vty_out (vty, " pw-id %u\n", pw->pwid);
else
missing_pwid = 1;
if (!(pw->flags & F_PW_CWORD_CONF))
- vty_outln (vty, " control-word exclude");
+ vty_out (vty, " control-word exclude\n");
if (!(pw->flags & F_PW_STATUSTLV_CONF))
- vty_outln (vty, " pw-status disable");
+ vty_out (vty, " pw-status disable\n");
if (missing_lsrid)
- vty_outln (vty,
- " ! Incomplete config, specify a neighbor " "lsr-id");
+ vty_out (vty,
+ " ! Incomplete config, specify a neighbor lsr-id\n");
if (missing_pwid)
- vty_outln (vty," ! Incomplete config, specify a pw-id");
+ vty_out (vty," ! Incomplete config, specify a pw-id\n");
}
int
struct l2vpn_pw *pw;
RB_FOREACH(l2vpn, l2vpn_head, &ldpd_conf->l2vpn_tree) {
- vty_outln (vty, "l2vpn %s type vpls", l2vpn->name);
+ vty_out (vty, "l2vpn %s type vpls\n", l2vpn->name);
if (l2vpn->pw_type != DEFAULT_PW_TYPE)
- vty_outln (vty, " vc type ethernet-tagged");
+ vty_out (vty, " vc type ethernet-tagged\n");
if (l2vpn->mtu != DEFAULT_L2VPN_MTU)
- vty_outln (vty, " mtu %u", l2vpn->mtu);
+ vty_out (vty, " mtu %u\n", l2vpn->mtu);
if (l2vpn->br_ifname[0] != '\0')
- vty_outln (vty, " bridge %s",l2vpn->br_ifname);
+ vty_out (vty, " bridge %s\n",l2vpn->br_ifname);
RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree)
- vty_outln (vty, " member interface %s",lif->ifname);
+ vty_out (vty, " member interface %s\n",lif->ifname);
RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree)
ldp_l2vpn_pw_config_write(vty, pw);
RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree)
ldp_l2vpn_pw_config_write(vty, pw);
- vty_outln (vty, " !");
- vty_outln (vty, "!");
+ vty_out (vty, " !\n");
+ vty_out (vty, "!\n");
}
return (0);
}
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;
}
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;
+ if (af_str == NULL)
+ return (CMD_WARNING_CONFIG_FAILED);
+
if (strcmp(af_str, "ipv4") == 0) {
af = AF_INET;
af_conf = &vty_conf->ipv4;
} 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);
return (CMD_SUCCESS);
}
-int
-ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
- const char *seconds_str)
+int ldp_vty_disc_holdtime(struct vty *vty, const char *negate,
+ enum hello_type hello_type, 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_outln (vty, "%% Invalid holdtime");
- return (CMD_WARNING_CONFIG_FAILED);
- }
-
- if (hello_type_str[0] == 'h')
- hello_type = HELLO_LINK;
- else
- hello_type = HELLO_TARGETED;
switch (vty->node) {
case LDP_NODE:
- if (disable) {
+ if (negate) {
switch (hello_type) {
case HELLO_LINK:
vty_conf->lhello_holdtime = LINK_DFLT_HOLDTIME;
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;
VTY_CHECK_CONTEXT(iface);
ia = iface_af_get(iface, af);
- if (disable)
+ if (negate)
ia->hello_holdtime = 0;
else
ia->hello_holdtime = secs;
}
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,
+ enum hello_type hello_type, 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_outln (vty, "%% Invalid interval");
- return (CMD_WARNING_CONFIG_FAILED);
- }
-
- if (hello_type_str[0] == 'h')
- hello_type = HELLO_LINK;
- else
- hello_type = HELLO_TARGETED;
switch (vty->node) {
case LDP_NODE:
- if (disable) {
+ if (negate) {
switch (hello_type) {
case HELLO_LINK:
- vty_conf->lhello_interval = LINK_DFLT_HOLDTIME;
+ vty_conf->lhello_interval =
+ DEFAULT_HELLO_INTERVAL;
break;
case HELLO_TARGETED:
vty_conf->thello_interval =
- TARGETED_DFLT_HOLDTIME;
+ DEFAULT_HELLO_INTERVAL;
break;
}
} else {
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;
VTY_CHECK_CONTEXT(iface);
ia = iface_af_get(iface, af);
- if (disable)
+ if (negate)
ia->hello_interval = 0;
else
ia->hello_interval = secs;
}
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;
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 {
}
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)) {
- vty_outln (vty, "%% Malformed address");
+ 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_outln (vty, "%% Invalid holdtime");
- return (CMD_SUCCESS);
- }
-
nbrp = nbr_params_find(vty_conf, lsr_id);
- if (disable) {
+ if (negate) {
if (nbrp == NULL)
return (CMD_SUCCESS);
}
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_outln (vty, "%% Invalid holdtime");
- 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;
}
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;
struct iface_af *ia;
+ if (ifname == NULL) {
+ vty_out (vty, "%% Missing IF name\n");
+ return (CMD_WARNING_CONFIG_FAILED);
+ }
+
af = ldp_vty_get_af(vty);
iface = if_lookup_name(vty_conf, ifname);
- if (disable) {
+ if (negate) {
if (iface == NULL)
return (CMD_SUCCESS);
if (iface == NULL) {
if (ldp_iface_is_configured(vty_conf, ifname)) {
- vty_outln (vty,"%% Interface is already in use");
+ vty_out (vty,"%% Interface is already in use\n");
return (CMD_SUCCESS);
}
}
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;
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 ||
- bad_addr(af, &af_conf->trans_addr)) {
- vty_outln (vty, "%% Malformed address");
+ if (addr_str == NULL
+ || inet_pton(af, addr_str, &af_conf->trans_addr) != 1
+ || bad_addr(af, &af_conf->trans_addr)) {
+ vty_out (vty, "%% Malformed address\n");
return (CMD_SUCCESS);
}
}
}
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;
af = ldp_vty_get_af(vty);
- if (inet_pton(af, addr_str, &addr) != 1 ||
+ if (addr_str == NULL || inet_pton(af, addr_str, &addr) != 1 ||
bad_addr(af, &addr)) {
- vty_outln (vty, "%% Malformed address");
+ vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
if (af == AF_INET6 && IN6_IS_SCOPE_EMBED(&addr.v6)) {
- vty_outln (vty, "%% Address can not be link-local");
+ vty_out (vty, "%% Address can not be link-local\n");
return (CMD_WARNING_CONFIG_FAILED);
}
tnbr = tnbr_find(vty_conf, af, &addr);
- if (disable) {
+ if (negate) {
if (tnbr == NULL)
return (CMD_SUCCESS);
}
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;
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 {
}
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;
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
}
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;
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 {
}
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;
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 {
}
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;
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;
}
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)) {
- vty_outln (vty, "%% Malformed address");
+ 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);
}
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;
}
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;
}
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)) {
- vty_outln (vty, "%% Malformed address");
+ if (password_str == NULL) {
+ vty_out (vty, "%% Missing password\n");
+ return (CMD_WARNING_CONFIG_FAILED);
+ }
+
+ 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);
}
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)) {
- vty_outln (vty, "%% Malformed address");
+ if (bad_addr_v4(lsr_id)) {
+ vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
if (hops_str) {
hops = strtol(hops_str, &ep, 10);
if (*ep != '\0' || hops < 1 || hops > 254) {
- vty_outln (vty, "%% Invalid hop count");
+ vty_out (vty, "%% Invalid hop count\n");
return (CMD_SUCCESS);
}
}
nbrp = nbr_params_find(vty_conf, lsr_id);
- if (disable) {
+ if (negate) {
if (nbrp == NULL)
return (CMD_SUCCESS);
}
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;
struct l2vpn_pw *pw;
+ if (name_str == NULL) {
+ vty_out (vty, "%% Missing name\n");
+ return (CMD_WARNING_CONFIG_FAILED);
+ }
+
l2vpn = l2vpn_find(vty_conf, name_str);
- if (disable) {
+ if (negate) {
if (l2vpn == NULL)
return (CMD_SUCCESS);
}
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
+ else {
+ if (ifname == NULL) {
+ vty_out (vty, "%% Missing IF name\n");
+ return (CMD_WARNING_CONFIG_FAILED);
+ }
strlcpy(l2vpn->br_ifname, ifname, sizeof(l2vpn->br_ifname));
+ }
ldp_config_apply(vty, vty_conf);
}
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_outln (vty, "%% Invalid MTU");
- return (CMD_WARNING_CONFIG_FAILED);
- }
- if (disable)
+ if (negate)
l2vpn->mtu = DEFAULT_L2VPN_MTU;
else
l2vpn->mtu = mtu;
}
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;
+ if (type_str == NULL) {
+ vty_out (vty, "%% Missing type\n");
+ return (CMD_WARNING_CONFIG_FAILED);
+ }
+
if (strcmp(type_str, "ethernet") == 0)
pw_type = PW_TYPE_ETHERNET;
else
pw_type = PW_TYPE_ETHERNET_TAGGED;
- if (disable)
+ if (negate)
l2vpn->pw_type = DEFAULT_PW_TYPE;
else
l2vpn->pw_type = pw_type;
}
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;
+ if (ifname == NULL) {
+ vty_out (vty, "%% Missing IF name\n");
+ return (CMD_WARNING_CONFIG_FAILED);
+ }
+
lif = l2vpn_if_find(l2vpn, ifname);
- if (disable) {
+ if (negate) {
if (lif == NULL)
return (CMD_SUCCESS);
return (CMD_SUCCESS);
if (ldp_iface_is_configured(vty_conf, ifname)) {
- vty_outln (vty, "%% Interface is already in use");
+ vty_out (vty, "%% Interface is already in use\n");
return (CMD_SUCCESS);
}
}
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;
+ if (ifname == NULL) {
+ vty_out (vty, "%% Missing IF name\n");
+ return (CMD_WARNING_CONFIG_FAILED);
+ }
+
pw = l2vpn_pw_find(l2vpn, ifname);
- if (disable) {
+ if (negate) {
if (pw == NULL)
return (CMD_SUCCESS);
}
if (ldp_iface_is_configured(vty_conf, ifname)) {
- vty_outln (vty, "%% Interface is already in use");
+ vty_out (vty, "%% Interface is already in use\n");
return (CMD_SUCCESS);
}
}
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) {
+ vty_out (vty, "%% Missing preference\n");
+ return (CMD_WARNING_CONFIG_FAILED);
+ }
if (preference_str[0] == 'e')
pw->flags &= ~F_PW_CWORD_CONF;
else
}
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;
if (ldp_get_address(addr_str, &af, &addr) == -1 ||
bad_addr(af, &addr)) {
- vty_outln (vty, "%% Malformed address");
+ vty_out (vty, "%% Malformed address\n");
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;
}
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)) {
- vty_outln (vty, "%% Malformed address");
+ 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;
}
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_outln (vty, "%% Invalid pw-id");
- return (CMD_WARNING_CONFIG_FAILED);
- }
- if (disable)
+ if (negate)
pw->pwid = 0;
else
pw->pwid = pwid;
}
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;
struct l2vpn_if *lif;
struct l2vpn_pw *pw;
- while ((lif = RB_ROOT(l2vpn_if_head, &l2vpn->if_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_if_head, &l2vpn->if_tree)) {
+ lif = RB_ROOT(l2vpn_if_head, &l2vpn->if_tree);
+
QOBJ_UNREG(lif);
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
free(lif);
}
- while ((pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_tree)) {
+ pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree);
+
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw);
free(pw);
}
- while ((pw = RB_ROOT(l2vpn_pw_head,
- &l2vpn->pw_inactive_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_inactive_tree)) {
+ pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_inactive_tree);
+
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
free(pw);