2 * Copyright (C) 2016 by Open Source Routing.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; see the file COPYING; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
33 static int ldp_config_write(struct vty
*);
34 static void ldp_af_iface_config_write(struct vty
*, int);
35 static void ldp_af_config_write(struct vty
*, int, struct ldpd_conf
*,
36 struct ldpd_af_conf
*);
37 static int ldp_l2vpn_config_write(struct vty
*);
38 static void ldp_l2vpn_pw_config_write(struct vty
*, struct l2vpn_pw
*);
39 static int ldp_vty_get_af(struct vty
*);
40 static int ldp_iface_is_configured(struct ldpd_conf
*, const char *);
42 struct cmd_node ldp_node
= {
45 .parent_node
= CONFIG_NODE
,
46 .prompt
= "%s(config-ldp)# ",
47 .config_write
= ldp_config_write
,
50 struct cmd_node ldp_ipv4_node
= {
52 .node
= LDP_IPV4_NODE
,
53 .parent_node
= LDP_NODE
,
54 .prompt
= "%s(config-ldp-af)# ",
57 struct cmd_node ldp_ipv6_node
= {
59 .node
= LDP_IPV6_NODE
,
60 .parent_node
= LDP_NODE
,
61 .prompt
= "%s(config-ldp-af)# ",
64 struct cmd_node ldp_ipv4_iface_node
= {
65 .name
= "ldp ipv4 interface",
66 .node
= LDP_IPV4_IFACE_NODE
,
67 .parent_node
= LDP_IPV4_NODE
,
68 .prompt
= "%s(config-ldp-af-if)# ",
71 struct cmd_node ldp_ipv6_iface_node
= {
72 .name
= "ldp ipv6 interface",
73 .node
= LDP_IPV6_IFACE_NODE
,
74 .parent_node
= LDP_IPV6_NODE
,
75 .prompt
= "%s(config-ldp-af-if)# ",
78 struct cmd_node ldp_l2vpn_node
= {
80 .node
= LDP_L2VPN_NODE
,
81 .parent_node
= CONFIG_NODE
,
82 .prompt
= "%s(config-l2vpn)# ",
83 .config_write
= ldp_l2vpn_config_write
,
86 struct cmd_node ldp_pseudowire_node
= {
88 .node
= LDP_PSEUDOWIRE_NODE
,
89 .parent_node
= LDP_L2VPN_NODE
,
90 .prompt
= "%s(config-l2vpn-pw)# ",
94 ldp_get_address(const char *str
, int *af
, union ldpd_addr
*addr
)
96 if (!str
|| !af
|| !addr
)
99 memset(addr
, 0, sizeof(*addr
));
101 if (inet_pton(AF_INET
, str
, &addr
->v4
) == 1) {
106 if (inet_pton(AF_INET6
, str
, &addr
->v6
) == 1) {
115 ldp_af_iface_config_write(struct vty
*vty
, int af
)
120 RB_FOREACH(iface
, iface_head
, &ldpd_conf
->iface_tree
) {
121 ia
= iface_af_get(iface
, af
);
125 vty_out (vty
, " !\n");
126 vty_out (vty
, " interface %s\n", iface
->name
);
128 if (ia
->hello_holdtime
!= LINK_DFLT_HOLDTIME
&&
129 ia
->hello_holdtime
!= 0)
130 vty_out (vty
, " discovery hello holdtime %u\n",
132 if (ia
->hello_interval
!= DEFAULT_HELLO_INTERVAL
&&
133 ia
->hello_interval
!= 0)
134 vty_out (vty
, " discovery hello interval %u\n",
140 ldp_af_config_write(struct vty
*vty
, int af
, struct ldpd_conf
*conf
,
141 struct ldpd_af_conf
*af_conf
)
145 if (!(af_conf
->flags
& F_LDPD_AF_ENABLED
))
148 vty_out (vty
, " !\n");
149 vty_out (vty
, " address-family %s\n", af_name(af
));
151 if (af_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
152 af_conf
->lhello_holdtime
!= 0 )
153 vty_out (vty
, " discovery hello holdtime %u\n",
154 af_conf
->lhello_holdtime
);
155 if (af_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
156 af_conf
->lhello_interval
!= 0)
157 vty_out (vty
, " discovery hello interval %u\n",
158 af_conf
->lhello_interval
);
160 if (af_conf
->flags
& F_LDPD_AF_THELLO_ACCEPT
) {
161 vty_out(vty
, " discovery targeted-hello accept");
162 if (af_conf
->acl_thello_accept_from
[0] != '\0')
163 vty_out(vty
, " from %s",
164 af_conf
->acl_thello_accept_from
);
168 if (af_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
169 af_conf
->thello_holdtime
!= 0)
170 vty_out (vty
, " discovery targeted-hello holdtime %u\n",
171 af_conf
->thello_holdtime
);
172 if (af_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
173 af_conf
->thello_interval
!= 0)
174 vty_out (vty
, " discovery targeted-hello interval %u\n",
175 af_conf
->thello_interval
);
177 if (ldp_addrisset(af
, &af_conf
->trans_addr
))
178 vty_out (vty
, " discovery transport-address %s\n",
179 log_addr(af
, &af_conf
->trans_addr
));
182 " ! Incomplete config, specify a discovery transport-address\n");
184 if ((af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
) ||
185 af_conf
->acl_label_allocate_for
[0] != '\0') {
186 vty_out(vty
, " label local allocate");
187 if (af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
)
188 vty_out(vty
, " host-routes");
190 vty_out(vty
, " for %s",
191 af_conf
->acl_label_allocate_for
);
195 if (af_conf
->acl_label_advertise_for
[0] != '\0' ||
196 af_conf
->acl_label_advertise_to
[0] != '\0') {
197 vty_out(vty
, " label local advertise");
198 if (af_conf
->acl_label_advertise_to
[0] != '\0')
199 vty_out(vty
, " to %s",
200 af_conf
->acl_label_advertise_to
);
201 if (af_conf
->acl_label_advertise_for
[0] != '\0')
202 vty_out(vty
, " for %s",
203 af_conf
->acl_label_advertise_for
);
207 if (af_conf
->flags
& F_LDPD_AF_EXPNULL
) {
208 vty_out(vty
, " label local advertise explicit-null");
209 if (af_conf
->acl_label_expnull_for
[0] != '\0')
210 vty_out(vty
, " for %s",
211 af_conf
->acl_label_expnull_for
);
215 if (af_conf
->acl_label_accept_for
[0] != '\0' ||
216 af_conf
->acl_label_accept_from
[0] != '\0') {
217 vty_out(vty
, " label remote accept");
218 if (af_conf
->acl_label_accept_from
[0] != '\0')
219 vty_out(vty
, " from %s",
220 af_conf
->acl_label_accept_from
);
221 if (af_conf
->acl_label_accept_for
[0] != '\0')
222 vty_out(vty
, " for %s",
223 af_conf
->acl_label_accept_for
);
227 if (af_conf
->flags
& F_LDPD_AF_NO_GTSM
)
228 vty_out (vty
, " ttl-security disable\n");
230 if (af_conf
->keepalive
!= DEFAULT_KEEPALIVE
)
231 vty_out (vty
, " session holdtime %u\n",af_conf
->keepalive
);
233 RB_FOREACH(tnbr
, tnbr_head
, &ldpd_conf
->tnbr_tree
) {
234 if (tnbr
->af
== af
) {
235 vty_out (vty
, " !\n");
236 vty_out (vty
, " neighbor %s targeted\n",
237 log_addr(tnbr
->af
, &tnbr
->addr
));
241 ldp_af_iface_config_write(vty
, af
);
243 vty_out(vty
, " !\n");
244 vty_out(vty
, " exit-address-family\n");
248 ldp_config_write(struct vty
*vty
)
250 struct nbr_params
*nbrp
;
252 if (!(ldpd_conf
->flags
& F_LDPD_ENABLED
))
255 vty_out (vty
, "mpls ldp\n");
257 if (ldpd_conf
->rtr_id
.s_addr
!= INADDR_ANY
)
258 vty_out(vty
, " router-id %pI4\n", &ldpd_conf
->rtr_id
);
260 if (ldpd_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
261 ldpd_conf
->lhello_holdtime
!= 0)
262 vty_out (vty
, " discovery hello holdtime %u\n",
263 ldpd_conf
->lhello_holdtime
);
264 if (ldpd_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
265 ldpd_conf
->lhello_interval
!= 0)
266 vty_out (vty
, " discovery hello interval %u\n",
267 ldpd_conf
->lhello_interval
);
269 if (ldpd_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
270 ldpd_conf
->thello_holdtime
!= 0)
271 vty_out (vty
, " discovery targeted-hello holdtime %u\n",
272 ldpd_conf
->thello_holdtime
);
273 if (ldpd_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
274 ldpd_conf
->thello_interval
!= 0)
275 vty_out (vty
, " discovery targeted-hello interval %u\n",
276 ldpd_conf
->thello_interval
);
278 if (ldpd_conf
->trans_pref
== DUAL_STACK_LDPOV4
)
280 " dual-stack transport-connection prefer ipv4\n");
282 if (ldpd_conf
->flags
& F_LDPD_DS_CISCO_INTEROP
)
283 vty_out (vty
, " dual-stack cisco-interop\n");
285 if (ldpd_conf
->flags
& F_LDPD_ORDERED_CONTROL
)
286 vty_out (vty
, " ordered-control\n");
288 if (ldpd_conf
->wait_for_sync_interval
!= DFLT_WAIT_FOR_SYNC
&&
289 ldpd_conf
->wait_for_sync_interval
!= 0)
290 vty_out (vty
, " wait-for-sync %u\n",
291 ldpd_conf
->wait_for_sync_interval
);
293 RB_FOREACH(nbrp
, nbrp_head
, &ldpd_conf
->nbrp_tree
) {
294 if (nbrp
->flags
& F_NBRP_KEEPALIVE
)
295 vty_out (vty
, " neighbor %pI4 session holdtime %u\n",
296 &nbrp
->lsr_id
,nbrp
->keepalive
);
298 if (nbrp
->flags
& F_NBRP_GTSM
) {
299 if (nbrp
->gtsm_enabled
)
300 vty_out (vty
, " neighbor %pI4 ttl-security hops %u\n", &nbrp
->lsr_id
,
303 vty_out (vty
, " neighbor %pI4 ttl-security disable\n",&nbrp
->lsr_id
);
306 if (nbrp
->auth
.method
== AUTH_MD5SIG
)
307 vty_out (vty
, " neighbor %pI4 password %s\n",
308 &nbrp
->lsr_id
,nbrp
->auth
.md5key
);
311 ldp_af_config_write(vty
, AF_INET
, ldpd_conf
, &ldpd_conf
->ipv4
);
312 ldp_af_config_write(vty
, AF_INET6
, ldpd_conf
, &ldpd_conf
->ipv6
);
313 vty_out (vty
, " !\n");
314 vty_out (vty
, "!\n");
320 ldp_l2vpn_pw_config_write(struct vty
*vty
, struct l2vpn_pw
*pw
)
322 int missing_lsrid
= 0;
323 int missing_pwid
= 0;
325 vty_out (vty
, " !\n");
326 vty_out (vty
, " member pseudowire %s\n", pw
->ifname
);
328 if (pw
->lsr_id
.s_addr
!= INADDR_ANY
)
329 vty_out (vty
, " neighbor lsr-id %pI4\n",&pw
->lsr_id
);
333 if (pw
->flags
& F_PW_STATIC_NBR_ADDR
)
334 vty_out (vty
, " neighbor address %s\n",
335 log_addr(pw
->af
, &pw
->addr
));
338 vty_out (vty
, " pw-id %u\n", pw
->pwid
);
342 if (!(pw
->flags
& F_PW_CWORD_CONF
))
343 vty_out (vty
, " control-word exclude\n");
345 if (!(pw
->flags
& F_PW_STATUSTLV_CONF
))
346 vty_out (vty
, " pw-status disable\n");
350 " ! Incomplete config, specify a neighbor lsr-id\n");
352 vty_out (vty
," ! Incomplete config, specify a pw-id\n");
356 ldp_l2vpn_config_write(struct vty
*vty
)
359 struct l2vpn_if
*lif
;
362 RB_FOREACH(l2vpn
, l2vpn_head
, &ldpd_conf
->l2vpn_tree
) {
363 vty_out (vty
, "l2vpn %s type vpls\n", l2vpn
->name
);
365 if (l2vpn
->pw_type
!= DEFAULT_PW_TYPE
)
366 vty_out (vty
, " vc type ethernet-tagged\n");
368 if (l2vpn
->mtu
!= DEFAULT_L2VPN_MTU
)
369 vty_out (vty
, " mtu %u\n", l2vpn
->mtu
);
371 if (l2vpn
->br_ifname
[0] != '\0')
372 vty_out (vty
, " bridge %s\n",l2vpn
->br_ifname
);
374 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
375 vty_out (vty
, " member interface %s\n",lif
->ifname
);
377 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
378 ldp_l2vpn_pw_config_write(vty
, pw
);
379 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
380 ldp_l2vpn_pw_config_write(vty
, pw
);
382 vty_out (vty
, " !\n");
383 vty_out (vty
, "!\n");
390 ldp_vty_get_af(struct vty
*vty
)
394 case LDP_IPV4_IFACE_NODE
:
397 case LDP_IPV6_IFACE_NODE
:
400 fatalx("ldp_vty_get_af: unexpected node");
405 ldp_iface_is_configured(struct ldpd_conf
*xconf
, const char *ifname
)
409 if (if_lookup_name(xconf
, ifname
))
412 RB_FOREACH(l2vpn
, l2vpn_head
, &xconf
->l2vpn_tree
) {
413 if (l2vpn_if_find(l2vpn
, ifname
))
415 if (l2vpn_pw_find(l2vpn
, ifname
))
423 ldp_vty_mpls_ldp(struct vty
*vty
, const char *negate
)
426 vty_conf
->flags
&= ~F_LDPD_ENABLED
;
428 vty
->node
= LDP_NODE
;
429 vty_conf
->flags
|= F_LDPD_ENABLED
;
432 /* register / de-register to recv info from zebra */
433 ldp_zebra_regdereg_zebra_info(!negate
);
435 ldp_config_apply(vty
, vty_conf
);
437 return (CMD_SUCCESS
);
441 ldp_vty_address_family(struct vty
*vty
, const char *negate
, const char *af_str
)
443 struct ldpd_af_conf
*af_conf
;
447 return (CMD_WARNING_CONFIG_FAILED
);
449 if (strcmp(af_str
, "ipv4") == 0) {
451 af_conf
= &vty_conf
->ipv4
;
452 } else if (strcmp(af_str
, "ipv6") == 0) {
454 af_conf
= &vty_conf
->ipv6
;
456 return (CMD_WARNING_CONFIG_FAILED
);
459 af_conf
->flags
&= ~F_LDPD_AF_ENABLED
;
460 ldp_config_apply(vty
, vty_conf
);
461 return (CMD_SUCCESS
);
466 vty
->node
= LDP_IPV4_NODE
;
469 vty
->node
= LDP_IPV6_NODE
;
472 fatalx("ldp_vty_address_family: unknown af");
474 af_conf
->flags
|= F_LDPD_AF_ENABLED
;
476 ldp_config_apply(vty
, vty_conf
);
478 return (CMD_SUCCESS
);
481 int ldp_vty_disc_holdtime(struct vty
*vty
, const char *negate
,
482 enum hello_type hello_type
, long secs
)
484 struct ldpd_af_conf
*af_conf
;
491 switch (hello_type
) {
493 vty_conf
->lhello_holdtime
= LINK_DFLT_HOLDTIME
;
496 vty_conf
->thello_holdtime
=
497 TARGETED_DFLT_HOLDTIME
;
501 switch (hello_type
) {
503 vty_conf
->lhello_holdtime
= secs
;
506 vty_conf
->thello_holdtime
= secs
;
510 ldp_config_apply(vty
, vty_conf
);
514 af
= ldp_vty_get_af(vty
);
515 af_conf
= ldp_af_conf_get(vty_conf
, af
);
518 switch (hello_type
) {
520 af_conf
->lhello_holdtime
= 0;
523 af_conf
->thello_holdtime
= 0;
527 switch (hello_type
) {
529 af_conf
->lhello_holdtime
= secs
;
532 af_conf
->thello_holdtime
= secs
;
536 ldp_config_apply(vty
, vty_conf
);
538 case LDP_IPV4_IFACE_NODE
:
539 case LDP_IPV6_IFACE_NODE
:
540 af
= ldp_vty_get_af(vty
);
541 iface
= VTY_GET_CONTEXT(iface
);
542 VTY_CHECK_CONTEXT(iface
);
544 ia
= iface_af_get(iface
, af
);
546 ia
->hello_holdtime
= 0;
548 ia
->hello_holdtime
= secs
;
550 ldp_config_apply(vty
, vty_conf
);
553 fatalx("ldp_vty_disc_holdtime: unexpected node");
556 return (CMD_SUCCESS
);
560 ldp_vty_disc_interval(struct vty
*vty
, const char *negate
,
561 enum hello_type hello_type
, long secs
)
563 struct ldpd_af_conf
*af_conf
;
571 switch (hello_type
) {
573 vty_conf
->lhello_interval
=
574 DEFAULT_HELLO_INTERVAL
;
577 vty_conf
->thello_interval
=
578 DEFAULT_HELLO_INTERVAL
;
582 switch (hello_type
) {
584 vty_conf
->lhello_interval
= secs
;
587 vty_conf
->thello_interval
= secs
;
591 ldp_config_apply(vty
, vty_conf
);
595 af
= ldp_vty_get_af(vty
);
596 af_conf
= ldp_af_conf_get(vty_conf
, af
);
599 switch (hello_type
) {
601 af_conf
->lhello_interval
= 0;
604 af_conf
->thello_interval
= 0;
608 switch (hello_type
) {
610 af_conf
->lhello_interval
= secs
;
613 af_conf
->thello_interval
= secs
;
617 ldp_config_apply(vty
, vty_conf
);
619 case LDP_IPV4_IFACE_NODE
:
620 case LDP_IPV6_IFACE_NODE
:
621 af
= ldp_vty_get_af(vty
);
622 iface
= VTY_GET_CONTEXT(iface
);
623 VTY_CHECK_CONTEXT(iface
);
625 ia
= iface_af_get(iface
, af
);
627 ia
->hello_interval
= 0;
629 ia
->hello_interval
= secs
;
631 ldp_config_apply(vty
, vty_conf
);
634 fatalx("ldp_vty_disc_interval: unexpected node");
637 return (CMD_SUCCESS
);
641 ldp_vty_targeted_hello_accept(struct vty
*vty
, const char *negate
,
642 const char *acl_from_str
)
644 struct ldpd_af_conf
*af_conf
;
647 af
= ldp_vty_get_af(vty
);
648 af_conf
= ldp_af_conf_get(vty_conf
, af
);
651 af_conf
->flags
&= ~F_LDPD_AF_THELLO_ACCEPT
;
652 af_conf
->acl_thello_accept_from
[0] = '\0';
654 af_conf
->flags
|= F_LDPD_AF_THELLO_ACCEPT
;
656 strlcpy(af_conf
->acl_thello_accept_from
, acl_from_str
,
657 sizeof(af_conf
->acl_thello_accept_from
));
659 af_conf
->acl_thello_accept_from
[0] = '\0';
662 ldp_config_apply(vty
, vty_conf
);
664 return (CMD_SUCCESS
);
668 ldp_vty_nbr_session_holdtime(struct vty
*vty
, const char *negate
,
669 struct in_addr lsr_id
, long secs
)
671 struct nbr_params
*nbrp
;
673 if (bad_addr_v4(lsr_id
)) {
674 vty_out (vty
, "%% Malformed address\n");
675 return (CMD_WARNING_CONFIG_FAILED
);
678 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
682 return (CMD_SUCCESS
);
685 nbrp
->flags
&= ~F_NBRP_KEEPALIVE
;
688 nbrp
= nbr_params_new(lsr_id
);
689 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
690 QOBJ_REG(nbrp
, nbr_params
);
691 } else if (nbrp
->keepalive
== secs
)
692 return (CMD_SUCCESS
);
694 nbrp
->keepalive
= secs
;
695 nbrp
->flags
|= F_NBRP_KEEPALIVE
;
698 ldp_config_apply(vty
, vty_conf
);
700 return (CMD_SUCCESS
);
704 ldp_vty_af_session_holdtime(struct vty
*vty
, const char *negate
, long secs
)
706 struct ldpd_af_conf
*af_conf
;
709 af
= ldp_vty_get_af(vty
);
710 af_conf
= ldp_af_conf_get(vty_conf
, af
);
713 af_conf
->keepalive
= DEFAULT_KEEPALIVE
;
715 af_conf
->keepalive
= secs
;
717 ldp_config_apply(vty
, vty_conf
);
719 return (CMD_SUCCESS
);
723 ldp_vty_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
729 if (ifname
== NULL
) {
730 vty_out (vty
, "%% Missing IF name\n");
731 return (CMD_WARNING_CONFIG_FAILED
);
734 af
= ldp_vty_get_af(vty
);
735 iface
= if_lookup_name(vty_conf
, ifname
);
739 return (CMD_SUCCESS
);
741 ia
= iface_af_get(iface
, af
);
742 if (ia
->enabled
== 0)
743 return (CMD_SUCCESS
);
746 ia
->hello_holdtime
= 0;
747 ia
->hello_interval
= 0;
749 ldp_config_apply(vty
, vty_conf
);
751 return (CMD_SUCCESS
);
755 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
756 vty_out (vty
,"%% Interface is already in use\n");
757 return (CMD_SUCCESS
);
760 iface
= if_new(ifname
);
761 ia
= iface_af_get(iface
, af
);
763 RB_INSERT(iface_head
, &vty_conf
->iface_tree
, iface
);
764 QOBJ_REG(iface
, iface
);
766 ldp_config_apply(vty
, vty_conf
);
768 ia
= iface_af_get(iface
, af
);
771 ldp_config_apply(vty
, vty_conf
);
777 VTY_PUSH_CONTEXT(LDP_IPV4_IFACE_NODE
, iface
);
780 VTY_PUSH_CONTEXT(LDP_IPV6_IFACE_NODE
, iface
);
786 return (CMD_SUCCESS
);
790 ldp_vty_trans_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
792 struct ldpd_af_conf
*af_conf
;
795 af
= ldp_vty_get_af(vty
);
796 af_conf
= ldp_af_conf_get(vty_conf
, af
);
799 memset(&af_conf
->trans_addr
, 0, sizeof(af_conf
->trans_addr
));
802 || inet_pton(af
, addr_str
, &af_conf
->trans_addr
) != 1
803 || bad_addr(af
, &af_conf
->trans_addr
)) {
804 vty_out (vty
, "%% Malformed address\n");
805 return (CMD_SUCCESS
);
809 ldp_config_apply(vty
, vty_conf
);
811 return (CMD_SUCCESS
);
815 ldp_vty_neighbor_targeted(struct vty
*vty
, const char *negate
, const char *addr_str
)
818 union ldpd_addr addr
;
821 af
= ldp_vty_get_af(vty
);
823 if (addr_str
== NULL
|| inet_pton(af
, addr_str
, &addr
) != 1 ||
824 bad_addr(af
, &addr
)) {
825 vty_out (vty
, "%% Malformed address\n");
826 return (CMD_WARNING_CONFIG_FAILED
);
828 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
.v6
)) {
829 vty_out (vty
, "%% Address can not be link-local\n");
830 return (CMD_WARNING_CONFIG_FAILED
);
833 tnbr
= tnbr_find(vty_conf
, af
, &addr
);
837 return (CMD_SUCCESS
);
840 RB_REMOVE(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
843 ldp_config_apply(vty
, vty_conf
);
845 return (CMD_SUCCESS
);
849 return (CMD_SUCCESS
);
851 tnbr
= tnbr_new(af
, &addr
);
852 tnbr
->flags
|= F_TNBR_CONFIGURED
;
853 RB_INSERT(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
854 QOBJ_REG(tnbr
, tnbr
);
856 ldp_config_apply(vty
, vty_conf
);
858 return (CMD_SUCCESS
);
862 ldp_vty_label_advertise(struct vty
*vty
, const char *negate
, const char *acl_to_str
,
863 const char *acl_for_str
)
865 struct ldpd_af_conf
*af_conf
;
868 af
= ldp_vty_get_af(vty
);
869 af_conf
= ldp_af_conf_get(vty_conf
, af
);
872 af_conf
->acl_label_advertise_to
[0] = '\0';
873 af_conf
->acl_label_advertise_for
[0] = '\0';
876 strlcpy(af_conf
->acl_label_advertise_to
, acl_to_str
,
877 sizeof(af_conf
->acl_label_advertise_to
));
879 af_conf
->acl_label_advertise_to
[0] = '\0';
881 strlcpy(af_conf
->acl_label_advertise_for
, acl_for_str
,
882 sizeof(af_conf
->acl_label_advertise_for
));
884 af_conf
->acl_label_advertise_for
[0] = '\0';
887 ldp_config_apply(vty
, vty_conf
);
889 return (CMD_SUCCESS
);
893 ldp_vty_label_allocate(struct vty
*vty
, const char *negate
, const char *host_routes
,
894 const char *acl_for_str
)
896 struct ldpd_af_conf
*af_conf
;
899 af
= ldp_vty_get_af(vty
);
900 af_conf
= ldp_af_conf_get(vty_conf
, af
);
902 af_conf
->flags
&= ~F_LDPD_AF_ALLOCHOSTONLY
;
903 af_conf
->acl_label_allocate_for
[0] = '\0';
906 af_conf
->flags
|= F_LDPD_AF_ALLOCHOSTONLY
;
908 strlcpy(af_conf
->acl_label_allocate_for
, acl_for_str
,
909 sizeof(af_conf
->acl_label_allocate_for
));
912 ldp_config_apply(vty
, vty_conf
);
914 return (CMD_SUCCESS
);
918 ldp_vty_label_expnull(struct vty
*vty
, const char *negate
, const char *acl_for_str
)
920 struct ldpd_af_conf
*af_conf
;
923 af
= ldp_vty_get_af(vty
);
924 af_conf
= ldp_af_conf_get(vty_conf
, af
);
927 af_conf
->flags
&= ~F_LDPD_AF_EXPNULL
;
928 af_conf
->acl_label_expnull_for
[0] = '\0';
930 af_conf
->flags
|= F_LDPD_AF_EXPNULL
;
932 strlcpy(af_conf
->acl_label_expnull_for
, acl_for_str
,
933 sizeof(af_conf
->acl_label_expnull_for
));
935 af_conf
->acl_label_expnull_for
[0] = '\0';
938 ldp_config_apply(vty
, vty_conf
);
940 return (CMD_SUCCESS
);
944 ldp_vty_label_accept(struct vty
*vty
, const char *negate
, const char *acl_from_str
,
945 const char *acl_for_str
)
947 struct ldpd_af_conf
*af_conf
;
950 af
= ldp_vty_get_af(vty
);
951 af_conf
= ldp_af_conf_get(vty_conf
, af
);
954 af_conf
->acl_label_accept_from
[0] = '\0';
955 af_conf
->acl_label_accept_for
[0] = '\0';
958 strlcpy(af_conf
->acl_label_accept_from
, acl_from_str
,
959 sizeof(af_conf
->acl_label_accept_from
));
961 af_conf
->acl_label_accept_from
[0] = '\0';
963 strlcpy(af_conf
->acl_label_accept_for
, acl_for_str
,
964 sizeof(af_conf
->acl_label_accept_for
));
966 af_conf
->acl_label_accept_for
[0] = '\0';
969 ldp_config_apply(vty
, vty_conf
);
971 return (CMD_SUCCESS
);
975 ldp_vty_ttl_security(struct vty
*vty
, const char *negate
)
977 struct ldpd_af_conf
*af_conf
;
980 af
= ldp_vty_get_af(vty
);
981 af_conf
= ldp_af_conf_get(vty_conf
, af
);
984 af_conf
->flags
&= ~F_LDPD_AF_NO_GTSM
;
986 af_conf
->flags
|= F_LDPD_AF_NO_GTSM
;
988 ldp_config_apply(vty
, vty_conf
);
990 return (CMD_SUCCESS
);
994 ldp_vty_router_id(struct vty
*vty
, const char *negate
, struct in_addr address
)
997 vty_conf
->rtr_id
.s_addr
= INADDR_ANY
;
999 if (bad_addr_v4(address
)) {
1000 vty_out (vty
, "%% Malformed address\n");
1001 return (CMD_SUCCESS
);
1003 vty_conf
->rtr_id
= address
;
1006 ldp_config_apply(vty
, vty_conf
);
1008 return (CMD_SUCCESS
);
1012 ldp_vty_ordered_control(struct vty
*vty
, const char *negate
)
1015 vty_conf
->flags
&= ~F_LDPD_ORDERED_CONTROL
;
1017 vty_conf
->flags
|= F_LDPD_ORDERED_CONTROL
;
1019 ldp_config_apply(vty
, vty_conf
);
1021 return (CMD_SUCCESS
);
1024 int ldp_vty_wait_for_sync_interval(struct vty
*vty
, const char *negate
,
1027 switch (vty
->node
) {
1030 vty_conf
->wait_for_sync_interval
= DFLT_WAIT_FOR_SYNC
;
1032 vty_conf
->wait_for_sync_interval
= secs
;
1034 ldp_config_apply(vty
, vty_conf
);
1037 fatalx("ldp_vty_wait_for_sync_interval: unexpected node");
1039 return (CMD_SUCCESS
);
1043 ldp_vty_ds_cisco_interop(struct vty
*vty
, const char * negate
)
1046 vty_conf
->flags
&= ~F_LDPD_DS_CISCO_INTEROP
;
1048 vty_conf
->flags
|= F_LDPD_DS_CISCO_INTEROP
;
1050 ldp_config_apply(vty
, vty_conf
);
1052 return (CMD_SUCCESS
);
1056 ldp_vty_trans_pref_ipv4(struct vty
*vty
, const char *negate
)
1059 vty_conf
->trans_pref
= DUAL_STACK_LDPOV6
;
1061 vty_conf
->trans_pref
= DUAL_STACK_LDPOV4
;
1063 ldp_config_apply(vty
, vty_conf
);
1065 return (CMD_SUCCESS
);
1069 ldp_vty_neighbor_password(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
,
1070 const char *password_str
)
1072 size_t password_len
;
1073 struct nbr_params
*nbrp
;
1075 if (password_str
== NULL
) {
1076 vty_out (vty
, "%% Missing password\n");
1077 return (CMD_WARNING_CONFIG_FAILED
);
1080 if (bad_addr_v4(lsr_id
)) {
1081 vty_out (vty
, "%% Malformed address\n");
1082 return (CMD_WARNING_CONFIG_FAILED
);
1085 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1089 return (CMD_SUCCESS
);
1091 memset(&nbrp
->auth
, 0, sizeof(nbrp
->auth
));
1092 nbrp
->auth
.method
= AUTH_NONE
;
1095 nbrp
= nbr_params_new(lsr_id
);
1096 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1097 QOBJ_REG(nbrp
, nbr_params
);
1098 } else if (nbrp
->auth
.method
== AUTH_MD5SIG
&&
1099 strcmp(nbrp
->auth
.md5key
, password_str
) == 0)
1100 return (CMD_SUCCESS
);
1102 password_len
= strlcpy(nbrp
->auth
.md5key
, password_str
,
1103 sizeof(nbrp
->auth
.md5key
));
1104 if (password_len
>= sizeof(nbrp
->auth
.md5key
))
1105 vty_out(vty
, "%% password has been truncated to %zu characters.", sizeof(nbrp
->auth
.md5key
) - 1);
1106 nbrp
->auth
.md5key_len
= strlen(nbrp
->auth
.md5key
);
1107 nbrp
->auth
.method
= AUTH_MD5SIG
;
1110 ldp_config_apply(vty
, vty_conf
);
1112 return (CMD_SUCCESS
);
1116 ldp_vty_neighbor_ttl_security(struct vty
*vty
, const char *negate
,
1117 struct in_addr lsr_id
, const char *hops_str
)
1119 struct nbr_params
*nbrp
;
1123 if (bad_addr_v4(lsr_id
)) {
1124 vty_out (vty
, "%% Malformed address\n");
1125 return (CMD_WARNING_CONFIG_FAILED
);
1129 hops
= strtol(hops_str
, &ep
, 10);
1130 if (*ep
!= '\0' || hops
< 1 || hops
> 254) {
1131 vty_out (vty
, "%% Invalid hop count\n");
1132 return (CMD_SUCCESS
);
1136 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1140 return (CMD_SUCCESS
);
1142 nbrp
->flags
&= ~(F_NBRP_GTSM
|F_NBRP_GTSM_HOPS
);
1143 nbrp
->gtsm_enabled
= 0;
1144 nbrp
->gtsm_hops
= 0;
1147 nbrp
= nbr_params_new(lsr_id
);
1148 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1149 QOBJ_REG(nbrp
, nbr_params
);
1152 nbrp
->flags
|= F_NBRP_GTSM
;
1153 nbrp
->flags
&= ~F_NBRP_GTSM_HOPS
;
1155 nbrp
->gtsm_enabled
= 1;
1156 nbrp
->gtsm_hops
= hops
;
1157 nbrp
->flags
|= F_NBRP_GTSM_HOPS
;
1159 nbrp
->gtsm_enabled
= 0;
1162 ldp_config_apply(vty
, vty_conf
);
1164 return (CMD_SUCCESS
);
1168 ldp_vty_l2vpn(struct vty
*vty
, const char *negate
, const char *name_str
)
1170 struct l2vpn
*l2vpn
;
1171 struct l2vpn_if
*lif
;
1172 struct l2vpn_pw
*pw
;
1174 if (name_str
== NULL
) {
1175 vty_out (vty
, "%% Missing name\n");
1176 return (CMD_WARNING_CONFIG_FAILED
);
1179 l2vpn
= l2vpn_find(vty_conf
, name_str
);
1183 return (CMD_SUCCESS
);
1185 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
1187 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
1189 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
1192 RB_REMOVE(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1195 ldp_config_apply(vty
, vty_conf
);
1197 return (CMD_SUCCESS
);
1201 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1202 return (CMD_SUCCESS
);
1205 l2vpn
= l2vpn_new(name_str
);
1206 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1207 RB_INSERT(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1208 QOBJ_REG(l2vpn
, l2vpn
);
1210 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1212 ldp_config_apply(vty
, vty_conf
);
1214 return (CMD_SUCCESS
);
1218 ldp_vty_l2vpn_bridge(struct vty
*vty
, const char *negate
, const char *ifname
)
1220 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1223 memset(l2vpn
->br_ifname
, 0, sizeof(l2vpn
->br_ifname
));
1225 if (ifname
== NULL
) {
1226 vty_out (vty
, "%% Missing IF name\n");
1227 return (CMD_WARNING_CONFIG_FAILED
);
1229 strlcpy(l2vpn
->br_ifname
, ifname
, sizeof(l2vpn
->br_ifname
));
1232 ldp_config_apply(vty
, vty_conf
);
1234 return (CMD_SUCCESS
);
1238 ldp_vty_l2vpn_mtu(struct vty
*vty
, const char *negate
, long mtu
)
1240 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1243 l2vpn
->mtu
= DEFAULT_L2VPN_MTU
;
1247 ldp_config_apply(vty
, vty_conf
);
1249 return (CMD_SUCCESS
);
1253 ldp_vty_l2vpn_pwtype(struct vty
*vty
, const char *negate
, const char *type_str
)
1255 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1258 if (type_str
== NULL
) {
1259 vty_out (vty
, "%% Missing type\n");
1260 return (CMD_WARNING_CONFIG_FAILED
);
1263 if (strcmp(type_str
, "ethernet") == 0)
1264 pw_type
= PW_TYPE_ETHERNET
;
1266 pw_type
= PW_TYPE_ETHERNET_TAGGED
;
1269 l2vpn
->pw_type
= DEFAULT_PW_TYPE
;
1271 l2vpn
->pw_type
= pw_type
;
1273 ldp_config_apply(vty
, vty_conf
);
1275 return (CMD_SUCCESS
);
1279 ldp_vty_l2vpn_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
1281 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1282 struct l2vpn_if
*lif
;
1284 if (ifname
== NULL
) {
1285 vty_out (vty
, "%% Missing IF name\n");
1286 return (CMD_WARNING_CONFIG_FAILED
);
1289 lif
= l2vpn_if_find(l2vpn
, ifname
);
1293 return (CMD_SUCCESS
);
1296 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1299 ldp_config_apply(vty
, vty_conf
);
1301 return (CMD_SUCCESS
);
1305 return (CMD_SUCCESS
);
1307 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1308 vty_out (vty
, "%% Interface is already in use\n");
1309 return (CMD_SUCCESS
);
1312 lif
= l2vpn_if_new(l2vpn
, ifname
);
1313 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1314 QOBJ_REG(lif
, l2vpn_if
);
1316 ldp_config_apply(vty
, vty_conf
);
1318 return (CMD_SUCCESS
);
1322 ldp_vty_l2vpn_pseudowire(struct vty
*vty
, const char *negate
, const char *ifname
)
1324 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1325 struct l2vpn_pw
*pw
;
1327 if (ifname
== NULL
) {
1328 vty_out (vty
, "%% Missing IF name\n");
1329 return (CMD_WARNING_CONFIG_FAILED
);
1332 pw
= l2vpn_pw_find(l2vpn
, ifname
);
1336 return (CMD_SUCCESS
);
1339 if (pw
->lsr_id
.s_addr
== INADDR_ANY
|| pw
->pwid
== 0)
1340 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1342 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1345 ldp_config_apply(vty
, vty_conf
);
1347 return (CMD_SUCCESS
);
1351 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1352 return (CMD_SUCCESS
);
1355 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1356 vty_out (vty
, "%% Interface is already in use\n");
1357 return (CMD_SUCCESS
);
1360 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1361 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1362 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1363 QOBJ_REG(pw
, l2vpn_pw
);
1365 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1367 ldp_config_apply(vty
, vty_conf
);
1369 return (CMD_SUCCESS
);
1373 ldp_vty_l2vpn_pw_cword(struct vty
*vty
, const char *negate
, const char *preference_str
)
1375 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1378 pw
->flags
|= F_PW_CWORD_CONF
;
1380 if (!preference_str
) {
1381 vty_out (vty
, "%% Missing preference\n");
1382 return (CMD_WARNING_CONFIG_FAILED
);
1384 if (preference_str
[0] == 'e')
1385 pw
->flags
&= ~F_PW_CWORD_CONF
;
1387 pw
->flags
|= F_PW_CWORD_CONF
;
1390 ldp_config_apply(vty
, vty_conf
);
1392 return (CMD_SUCCESS
);
1396 ldp_vty_l2vpn_pw_nbr_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
1398 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1400 union ldpd_addr addr
;
1402 if (ldp_get_address(addr_str
, &af
, &addr
) == -1 ||
1403 bad_addr(af
, &addr
)) {
1404 vty_out (vty
, "%% Malformed address\n");
1405 return (CMD_WARNING_CONFIG_FAILED
);
1410 memset(&pw
->addr
, 0, sizeof(pw
->addr
));
1411 pw
->flags
&= ~F_PW_STATIC_NBR_ADDR
;
1415 pw
->flags
|= F_PW_STATIC_NBR_ADDR
;
1418 ldp_config_apply(vty
, vty_conf
);
1420 return (CMD_SUCCESS
);
1424 ldp_vty_l2vpn_pw_nbr_id(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
)
1426 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1428 if (bad_addr_v4(lsr_id
)) {
1429 vty_out (vty
, "%% Malformed address\n");
1430 return (CMD_WARNING_CONFIG_FAILED
);
1434 pw
->lsr_id
.s_addr
= INADDR_ANY
;
1436 pw
->lsr_id
= lsr_id
;
1438 ldp_config_apply(vty
, vty_conf
);
1440 return (CMD_SUCCESS
);
1444 ldp_vty_l2vpn_pw_pwid(struct vty
*vty
, const char *negate
, long pwid
)
1446 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1453 ldp_config_apply(vty
, vty_conf
);
1455 return (CMD_SUCCESS
);
1459 ldp_vty_l2vpn_pw_pwstatus(struct vty
*vty
, const char *negate
)
1461 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1464 pw
->flags
|= F_PW_STATUSTLV_CONF
;
1466 pw
->flags
&= ~F_PW_STATUSTLV_CONF
;
1468 ldp_config_apply(vty
, vty_conf
);
1470 return (CMD_SUCCESS
);
1474 iface_new_api(struct ldpd_conf
*conf
, const char *name
)
1476 const char *ifname
= name
;
1477 struct iface
*iface
;
1479 if (ldp_iface_is_configured(conf
, ifname
))
1482 iface
= if_new(name
);
1483 RB_INSERT(iface_head
, &conf
->iface_tree
, iface
);
1484 QOBJ_REG(iface
, iface
);
1489 iface_del_api(struct ldpd_conf
*conf
, struct iface
*iface
)
1492 RB_REMOVE(iface_head
, &conf
->iface_tree
, iface
);
1497 tnbr_new_api(struct ldpd_conf
*conf
, int af
, union ldpd_addr
*addr
)
1501 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
->v6
))
1504 if (tnbr_find(conf
, af
, addr
))
1507 tnbr
= tnbr_new(af
, addr
);
1508 tnbr
->flags
|= F_TNBR_CONFIGURED
;
1509 RB_INSERT(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1510 QOBJ_REG(tnbr
, tnbr
);
1515 tnbr_del_api(struct ldpd_conf
*conf
, struct tnbr
*tnbr
)
1518 RB_REMOVE(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1523 nbrp_new_api(struct ldpd_conf
*conf
, struct in_addr lsr_id
)
1525 struct nbr_params
*nbrp
;
1527 if (nbr_params_find(conf
, lsr_id
))
1530 nbrp
= nbr_params_new(lsr_id
);
1531 RB_INSERT(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1532 QOBJ_REG(nbrp
, nbr_params
);
1537 nbrp_del_api(struct ldpd_conf
*conf
, struct nbr_params
*nbrp
)
1540 RB_REMOVE(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1545 l2vpn_new_api(struct ldpd_conf
*conf
, const char *name
)
1547 struct l2vpn
*l2vpn
;
1549 if (l2vpn_find(conf
, name
))
1552 l2vpn
= l2vpn_new(name
);
1553 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1554 RB_INSERT(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1555 QOBJ_REG(l2vpn
, l2vpn
);
1560 l2vpn_del_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
)
1562 struct l2vpn_if
*lif
;
1563 struct l2vpn_pw
*pw
;
1565 while (!RB_EMPTY(l2vpn_if_head
, &l2vpn
->if_tree
)) {
1566 lif
= RB_ROOT(l2vpn_if_head
, &l2vpn
->if_tree
);
1569 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1572 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_tree
)) {
1573 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_tree
);
1576 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1579 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)) {
1580 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
);
1583 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1587 RB_REMOVE(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1592 l2vpn_if_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1595 struct l2vpn_if
*lif
;
1597 if (ldp_iface_is_configured(conf
, ifname
))
1600 lif
= l2vpn_if_new(l2vpn
, ifname
);
1601 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1602 QOBJ_REG(lif
, l2vpn_if
);
1607 l2vpn_if_del_api(struct l2vpn
*l2vpn
, struct l2vpn_if
*lif
)
1610 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1615 l2vpn_pw_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1618 struct l2vpn_pw
*pw
;
1620 if (ldp_iface_is_configured(conf
, ifname
))
1623 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1624 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1625 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1626 QOBJ_REG(pw
, l2vpn_pw
);
1631 l2vpn_pw_del_api(struct l2vpn
*l2vpn
, struct l2vpn_pw
*pw
)
1634 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);