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 %s\n", inet_ntoa(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 %s session holdtime %u\n",
296 inet_ntoa(nbrp
->lsr_id
),nbrp
->keepalive
);
298 if (nbrp
->flags
& F_NBRP_GTSM
) {
299 if (nbrp
->gtsm_enabled
)
300 vty_out (vty
, " neighbor %s ttl-security hops %u\n", inet_ntoa(nbrp
->lsr_id
),
303 vty_out (vty
, " neighbor %s ttl-security disable\n",inet_ntoa(nbrp
->lsr_id
));
306 if (nbrp
->auth
.method
== AUTH_MD5SIG
)
307 vty_out (vty
, " neighbor %s password %s\n",
308 inet_ntoa(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 %s\n",inet_ntoa(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 ldp_config_apply(vty
, vty_conf
);
434 return (CMD_SUCCESS
);
438 ldp_vty_address_family(struct vty
*vty
, const char *negate
, const char *af_str
)
440 struct ldpd_af_conf
*af_conf
;
444 return (CMD_WARNING_CONFIG_FAILED
);
446 if (strcmp(af_str
, "ipv4") == 0) {
448 af_conf
= &vty_conf
->ipv4
;
449 } else if (strcmp(af_str
, "ipv6") == 0) {
451 af_conf
= &vty_conf
->ipv6
;
453 return (CMD_WARNING_CONFIG_FAILED
);
456 af_conf
->flags
&= ~F_LDPD_AF_ENABLED
;
457 ldp_config_apply(vty
, vty_conf
);
458 return (CMD_SUCCESS
);
463 vty
->node
= LDP_IPV4_NODE
;
466 vty
->node
= LDP_IPV6_NODE
;
469 fatalx("ldp_vty_address_family: unknown af");
471 af_conf
->flags
|= F_LDPD_AF_ENABLED
;
473 ldp_config_apply(vty
, vty_conf
);
475 return (CMD_SUCCESS
);
478 int ldp_vty_disc_holdtime(struct vty
*vty
, const char *negate
,
479 enum hello_type hello_type
, long secs
)
481 struct ldpd_af_conf
*af_conf
;
488 switch (hello_type
) {
490 vty_conf
->lhello_holdtime
= LINK_DFLT_HOLDTIME
;
493 vty_conf
->thello_holdtime
=
494 TARGETED_DFLT_HOLDTIME
;
498 switch (hello_type
) {
500 vty_conf
->lhello_holdtime
= secs
;
503 vty_conf
->thello_holdtime
= secs
;
507 ldp_config_apply(vty
, vty_conf
);
511 af
= ldp_vty_get_af(vty
);
512 af_conf
= ldp_af_conf_get(vty_conf
, af
);
515 switch (hello_type
) {
517 af_conf
->lhello_holdtime
= 0;
520 af_conf
->thello_holdtime
= 0;
524 switch (hello_type
) {
526 af_conf
->lhello_holdtime
= secs
;
529 af_conf
->thello_holdtime
= secs
;
533 ldp_config_apply(vty
, vty_conf
);
535 case LDP_IPV4_IFACE_NODE
:
536 case LDP_IPV6_IFACE_NODE
:
537 af
= ldp_vty_get_af(vty
);
538 iface
= VTY_GET_CONTEXT(iface
);
539 VTY_CHECK_CONTEXT(iface
);
541 ia
= iface_af_get(iface
, af
);
543 ia
->hello_holdtime
= 0;
545 ia
->hello_holdtime
= secs
;
547 ldp_config_apply(vty
, vty_conf
);
550 fatalx("ldp_vty_disc_holdtime: unexpected node");
553 return (CMD_SUCCESS
);
557 ldp_vty_disc_interval(struct vty
*vty
, const char *negate
,
558 enum hello_type hello_type
, long secs
)
560 struct ldpd_af_conf
*af_conf
;
568 switch (hello_type
) {
570 vty_conf
->lhello_interval
=
571 DEFAULT_HELLO_INTERVAL
;
574 vty_conf
->thello_interval
=
575 DEFAULT_HELLO_INTERVAL
;
579 switch (hello_type
) {
581 vty_conf
->lhello_interval
= secs
;
584 vty_conf
->thello_interval
= secs
;
588 ldp_config_apply(vty
, vty_conf
);
592 af
= ldp_vty_get_af(vty
);
593 af_conf
= ldp_af_conf_get(vty_conf
, af
);
596 switch (hello_type
) {
598 af_conf
->lhello_interval
= 0;
601 af_conf
->thello_interval
= 0;
605 switch (hello_type
) {
607 af_conf
->lhello_interval
= secs
;
610 af_conf
->thello_interval
= secs
;
614 ldp_config_apply(vty
, vty_conf
);
616 case LDP_IPV4_IFACE_NODE
:
617 case LDP_IPV6_IFACE_NODE
:
618 af
= ldp_vty_get_af(vty
);
619 iface
= VTY_GET_CONTEXT(iface
);
620 VTY_CHECK_CONTEXT(iface
);
622 ia
= iface_af_get(iface
, af
);
624 ia
->hello_interval
= 0;
626 ia
->hello_interval
= secs
;
628 ldp_config_apply(vty
, vty_conf
);
631 fatalx("ldp_vty_disc_interval: unexpected node");
634 return (CMD_SUCCESS
);
638 ldp_vty_targeted_hello_accept(struct vty
*vty
, const char *negate
,
639 const char *acl_from_str
)
641 struct ldpd_af_conf
*af_conf
;
644 af
= ldp_vty_get_af(vty
);
645 af_conf
= ldp_af_conf_get(vty_conf
, af
);
648 af_conf
->flags
&= ~F_LDPD_AF_THELLO_ACCEPT
;
649 af_conf
->acl_thello_accept_from
[0] = '\0';
651 af_conf
->flags
|= F_LDPD_AF_THELLO_ACCEPT
;
653 strlcpy(af_conf
->acl_thello_accept_from
, acl_from_str
,
654 sizeof(af_conf
->acl_thello_accept_from
));
656 af_conf
->acl_thello_accept_from
[0] = '\0';
659 ldp_config_apply(vty
, vty_conf
);
661 return (CMD_SUCCESS
);
665 ldp_vty_nbr_session_holdtime(struct vty
*vty
, const char *negate
,
666 struct in_addr lsr_id
, long secs
)
668 struct nbr_params
*nbrp
;
670 if (bad_addr_v4(lsr_id
)) {
671 vty_out (vty
, "%% Malformed address\n");
672 return (CMD_WARNING_CONFIG_FAILED
);
675 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
679 return (CMD_SUCCESS
);
682 nbrp
->flags
&= ~F_NBRP_KEEPALIVE
;
685 nbrp
= nbr_params_new(lsr_id
);
686 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
687 QOBJ_REG(nbrp
, nbr_params
);
688 } else if (nbrp
->keepalive
== secs
)
689 return (CMD_SUCCESS
);
691 nbrp
->keepalive
= secs
;
692 nbrp
->flags
|= F_NBRP_KEEPALIVE
;
695 ldp_config_apply(vty
, vty_conf
);
697 return (CMD_SUCCESS
);
701 ldp_vty_af_session_holdtime(struct vty
*vty
, const char *negate
, long secs
)
703 struct ldpd_af_conf
*af_conf
;
706 af
= ldp_vty_get_af(vty
);
707 af_conf
= ldp_af_conf_get(vty_conf
, af
);
710 af_conf
->keepalive
= DEFAULT_KEEPALIVE
;
712 af_conf
->keepalive
= secs
;
714 ldp_config_apply(vty
, vty_conf
);
716 return (CMD_SUCCESS
);
720 ldp_vty_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
726 if (ifname
== NULL
) {
727 vty_out (vty
, "%% Missing IF name\n");
728 return (CMD_WARNING_CONFIG_FAILED
);
731 af
= ldp_vty_get_af(vty
);
732 iface
= if_lookup_name(vty_conf
, ifname
);
736 return (CMD_SUCCESS
);
738 ia
= iface_af_get(iface
, af
);
739 if (ia
->enabled
== 0)
740 return (CMD_SUCCESS
);
743 ia
->hello_holdtime
= 0;
744 ia
->hello_interval
= 0;
746 ldp_config_apply(vty
, vty_conf
);
748 return (CMD_SUCCESS
);
752 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
753 vty_out (vty
,"%% Interface is already in use\n");
754 return (CMD_SUCCESS
);
757 iface
= if_new(ifname
);
758 ia
= iface_af_get(iface
, af
);
760 RB_INSERT(iface_head
, &vty_conf
->iface_tree
, iface
);
761 QOBJ_REG(iface
, iface
);
763 ldp_config_apply(vty
, vty_conf
);
765 ia
= iface_af_get(iface
, af
);
768 ldp_config_apply(vty
, vty_conf
);
774 VTY_PUSH_CONTEXT(LDP_IPV4_IFACE_NODE
, iface
);
777 VTY_PUSH_CONTEXT(LDP_IPV6_IFACE_NODE
, iface
);
783 return (CMD_SUCCESS
);
787 ldp_vty_trans_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
789 struct ldpd_af_conf
*af_conf
;
792 af
= ldp_vty_get_af(vty
);
793 af_conf
= ldp_af_conf_get(vty_conf
, af
);
796 memset(&af_conf
->trans_addr
, 0, sizeof(af_conf
->trans_addr
));
799 || inet_pton(af
, addr_str
, &af_conf
->trans_addr
) != 1
800 || bad_addr(af
, &af_conf
->trans_addr
)) {
801 vty_out (vty
, "%% Malformed address\n");
802 return (CMD_SUCCESS
);
806 ldp_config_apply(vty
, vty_conf
);
808 return (CMD_SUCCESS
);
812 ldp_vty_neighbor_targeted(struct vty
*vty
, const char *negate
, const char *addr_str
)
815 union ldpd_addr addr
;
818 af
= ldp_vty_get_af(vty
);
820 if (addr_str
== NULL
|| inet_pton(af
, addr_str
, &addr
) != 1 ||
821 bad_addr(af
, &addr
)) {
822 vty_out (vty
, "%% Malformed address\n");
823 return (CMD_WARNING_CONFIG_FAILED
);
825 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
.v6
)) {
826 vty_out (vty
, "%% Address can not be link-local\n");
827 return (CMD_WARNING_CONFIG_FAILED
);
830 tnbr
= tnbr_find(vty_conf
, af
, &addr
);
834 return (CMD_SUCCESS
);
837 RB_REMOVE(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
840 ldp_config_apply(vty
, vty_conf
);
842 return (CMD_SUCCESS
);
846 return (CMD_SUCCESS
);
848 tnbr
= tnbr_new(af
, &addr
);
849 tnbr
->flags
|= F_TNBR_CONFIGURED
;
850 RB_INSERT(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
851 QOBJ_REG(tnbr
, tnbr
);
853 ldp_config_apply(vty
, vty_conf
);
855 return (CMD_SUCCESS
);
859 ldp_vty_label_advertise(struct vty
*vty
, const char *negate
, const char *acl_to_str
,
860 const char *acl_for_str
)
862 struct ldpd_af_conf
*af_conf
;
865 af
= ldp_vty_get_af(vty
);
866 af_conf
= ldp_af_conf_get(vty_conf
, af
);
869 af_conf
->acl_label_advertise_to
[0] = '\0';
870 af_conf
->acl_label_advertise_for
[0] = '\0';
873 strlcpy(af_conf
->acl_label_advertise_to
, acl_to_str
,
874 sizeof(af_conf
->acl_label_advertise_to
));
876 af_conf
->acl_label_advertise_to
[0] = '\0';
878 strlcpy(af_conf
->acl_label_advertise_for
, acl_for_str
,
879 sizeof(af_conf
->acl_label_advertise_for
));
881 af_conf
->acl_label_advertise_for
[0] = '\0';
884 ldp_config_apply(vty
, vty_conf
);
886 return (CMD_SUCCESS
);
890 ldp_vty_label_allocate(struct vty
*vty
, const char *negate
, const char *host_routes
,
891 const char *acl_for_str
)
893 struct ldpd_af_conf
*af_conf
;
896 af
= ldp_vty_get_af(vty
);
897 af_conf
= ldp_af_conf_get(vty_conf
, af
);
899 af_conf
->flags
&= ~F_LDPD_AF_ALLOCHOSTONLY
;
900 af_conf
->acl_label_allocate_for
[0] = '\0';
903 af_conf
->flags
|= F_LDPD_AF_ALLOCHOSTONLY
;
905 strlcpy(af_conf
->acl_label_allocate_for
, acl_for_str
,
906 sizeof(af_conf
->acl_label_allocate_for
));
909 ldp_config_apply(vty
, vty_conf
);
911 return (CMD_SUCCESS
);
915 ldp_vty_label_expnull(struct vty
*vty
, const char *negate
, const char *acl_for_str
)
917 struct ldpd_af_conf
*af_conf
;
920 af
= ldp_vty_get_af(vty
);
921 af_conf
= ldp_af_conf_get(vty_conf
, af
);
924 af_conf
->flags
&= ~F_LDPD_AF_EXPNULL
;
925 af_conf
->acl_label_expnull_for
[0] = '\0';
927 af_conf
->flags
|= F_LDPD_AF_EXPNULL
;
929 strlcpy(af_conf
->acl_label_expnull_for
, acl_for_str
,
930 sizeof(af_conf
->acl_label_expnull_for
));
932 af_conf
->acl_label_expnull_for
[0] = '\0';
935 ldp_config_apply(vty
, vty_conf
);
937 return (CMD_SUCCESS
);
941 ldp_vty_label_accept(struct vty
*vty
, const char *negate
, const char *acl_from_str
,
942 const char *acl_for_str
)
944 struct ldpd_af_conf
*af_conf
;
947 af
= ldp_vty_get_af(vty
);
948 af_conf
= ldp_af_conf_get(vty_conf
, af
);
951 af_conf
->acl_label_accept_from
[0] = '\0';
952 af_conf
->acl_label_accept_for
[0] = '\0';
955 strlcpy(af_conf
->acl_label_accept_from
, acl_from_str
,
956 sizeof(af_conf
->acl_label_accept_from
));
958 af_conf
->acl_label_accept_from
[0] = '\0';
960 strlcpy(af_conf
->acl_label_accept_for
, acl_for_str
,
961 sizeof(af_conf
->acl_label_accept_for
));
963 af_conf
->acl_label_accept_for
[0] = '\0';
966 ldp_config_apply(vty
, vty_conf
);
968 return (CMD_SUCCESS
);
972 ldp_vty_ttl_security(struct vty
*vty
, const char *negate
)
974 struct ldpd_af_conf
*af_conf
;
977 af
= ldp_vty_get_af(vty
);
978 af_conf
= ldp_af_conf_get(vty_conf
, af
);
981 af_conf
->flags
&= ~F_LDPD_AF_NO_GTSM
;
983 af_conf
->flags
|= F_LDPD_AF_NO_GTSM
;
985 ldp_config_apply(vty
, vty_conf
);
987 return (CMD_SUCCESS
);
991 ldp_vty_router_id(struct vty
*vty
, const char *negate
, struct in_addr address
)
994 vty_conf
->rtr_id
.s_addr
= INADDR_ANY
;
996 if (bad_addr_v4(address
)) {
997 vty_out (vty
, "%% Malformed address\n");
998 return (CMD_SUCCESS
);
1000 vty_conf
->rtr_id
= address
;
1003 ldp_config_apply(vty
, vty_conf
);
1005 return (CMD_SUCCESS
);
1009 ldp_vty_ordered_control(struct vty
*vty
, const char *negate
)
1012 vty_conf
->flags
&= ~F_LDPD_ORDERED_CONTROL
;
1014 vty_conf
->flags
|= F_LDPD_ORDERED_CONTROL
;
1016 ldp_config_apply(vty
, vty_conf
);
1018 return (CMD_SUCCESS
);
1021 int ldp_vty_wait_for_sync_interval(struct vty
*vty
, const char *negate
,
1024 switch (vty
->node
) {
1027 vty_conf
->wait_for_sync_interval
= DFLT_WAIT_FOR_SYNC
;
1029 vty_conf
->wait_for_sync_interval
= secs
;
1031 ldp_config_apply(vty
, vty_conf
);
1034 fatalx("ldp_vty_wait_for_sync_interval: unexpected node");
1036 return (CMD_SUCCESS
);
1040 ldp_vty_ds_cisco_interop(struct vty
*vty
, const char * negate
)
1043 vty_conf
->flags
&= ~F_LDPD_DS_CISCO_INTEROP
;
1045 vty_conf
->flags
|= F_LDPD_DS_CISCO_INTEROP
;
1047 ldp_config_apply(vty
, vty_conf
);
1049 return (CMD_SUCCESS
);
1053 ldp_vty_trans_pref_ipv4(struct vty
*vty
, const char *negate
)
1056 vty_conf
->trans_pref
= DUAL_STACK_LDPOV6
;
1058 vty_conf
->trans_pref
= DUAL_STACK_LDPOV4
;
1060 ldp_config_apply(vty
, vty_conf
);
1062 return (CMD_SUCCESS
);
1066 ldp_vty_neighbor_password(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
,
1067 const char *password_str
)
1069 size_t password_len
;
1070 struct nbr_params
*nbrp
;
1072 if (password_str
== NULL
) {
1073 vty_out (vty
, "%% Missing password\n");
1074 return (CMD_WARNING_CONFIG_FAILED
);
1077 if (bad_addr_v4(lsr_id
)) {
1078 vty_out (vty
, "%% Malformed address\n");
1079 return (CMD_WARNING_CONFIG_FAILED
);
1082 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1086 return (CMD_SUCCESS
);
1088 memset(&nbrp
->auth
, 0, sizeof(nbrp
->auth
));
1089 nbrp
->auth
.method
= AUTH_NONE
;
1092 nbrp
= nbr_params_new(lsr_id
);
1093 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1094 QOBJ_REG(nbrp
, nbr_params
);
1095 } else if (nbrp
->auth
.method
== AUTH_MD5SIG
&&
1096 strcmp(nbrp
->auth
.md5key
, password_str
) == 0)
1097 return (CMD_SUCCESS
);
1099 password_len
= strlcpy(nbrp
->auth
.md5key
, password_str
,
1100 sizeof(nbrp
->auth
.md5key
));
1101 if (password_len
>= sizeof(nbrp
->auth
.md5key
))
1102 vty_out(vty
, "%% password has been truncated to %zu characters.", sizeof(nbrp
->auth
.md5key
) - 1);
1103 nbrp
->auth
.md5key_len
= strlen(nbrp
->auth
.md5key
);
1104 nbrp
->auth
.method
= AUTH_MD5SIG
;
1107 ldp_config_apply(vty
, vty_conf
);
1109 return (CMD_SUCCESS
);
1113 ldp_vty_neighbor_ttl_security(struct vty
*vty
, const char *negate
,
1114 struct in_addr lsr_id
, const char *hops_str
)
1116 struct nbr_params
*nbrp
;
1120 if (bad_addr_v4(lsr_id
)) {
1121 vty_out (vty
, "%% Malformed address\n");
1122 return (CMD_WARNING_CONFIG_FAILED
);
1126 hops
= strtol(hops_str
, &ep
, 10);
1127 if (*ep
!= '\0' || hops
< 1 || hops
> 254) {
1128 vty_out (vty
, "%% Invalid hop count\n");
1129 return (CMD_SUCCESS
);
1133 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1137 return (CMD_SUCCESS
);
1139 nbrp
->flags
&= ~(F_NBRP_GTSM
|F_NBRP_GTSM_HOPS
);
1140 nbrp
->gtsm_enabled
= 0;
1141 nbrp
->gtsm_hops
= 0;
1144 nbrp
= nbr_params_new(lsr_id
);
1145 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1146 QOBJ_REG(nbrp
, nbr_params
);
1149 nbrp
->flags
|= F_NBRP_GTSM
;
1150 nbrp
->flags
&= ~F_NBRP_GTSM_HOPS
;
1152 nbrp
->gtsm_enabled
= 1;
1153 nbrp
->gtsm_hops
= hops
;
1154 nbrp
->flags
|= F_NBRP_GTSM_HOPS
;
1156 nbrp
->gtsm_enabled
= 0;
1159 ldp_config_apply(vty
, vty_conf
);
1161 return (CMD_SUCCESS
);
1165 ldp_vty_l2vpn(struct vty
*vty
, const char *negate
, const char *name_str
)
1167 struct l2vpn
*l2vpn
;
1168 struct l2vpn_if
*lif
;
1169 struct l2vpn_pw
*pw
;
1171 if (name_str
== NULL
) {
1172 vty_out (vty
, "%% Missing name\n");
1173 return (CMD_WARNING_CONFIG_FAILED
);
1176 l2vpn
= l2vpn_find(vty_conf
, name_str
);
1180 return (CMD_SUCCESS
);
1182 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
1184 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
1186 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
1189 RB_REMOVE(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1192 ldp_config_apply(vty
, vty_conf
);
1194 return (CMD_SUCCESS
);
1198 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1199 return (CMD_SUCCESS
);
1202 l2vpn
= l2vpn_new(name_str
);
1203 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1204 RB_INSERT(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1205 QOBJ_REG(l2vpn
, l2vpn
);
1207 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1209 ldp_config_apply(vty
, vty_conf
);
1211 return (CMD_SUCCESS
);
1215 ldp_vty_l2vpn_bridge(struct vty
*vty
, const char *negate
, const char *ifname
)
1217 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1220 memset(l2vpn
->br_ifname
, 0, sizeof(l2vpn
->br_ifname
));
1222 if (ifname
== NULL
) {
1223 vty_out (vty
, "%% Missing IF name\n");
1224 return (CMD_WARNING_CONFIG_FAILED
);
1226 strlcpy(l2vpn
->br_ifname
, ifname
, sizeof(l2vpn
->br_ifname
));
1229 ldp_config_apply(vty
, vty_conf
);
1231 return (CMD_SUCCESS
);
1235 ldp_vty_l2vpn_mtu(struct vty
*vty
, const char *negate
, long mtu
)
1237 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1240 l2vpn
->mtu
= DEFAULT_L2VPN_MTU
;
1244 ldp_config_apply(vty
, vty_conf
);
1246 return (CMD_SUCCESS
);
1250 ldp_vty_l2vpn_pwtype(struct vty
*vty
, const char *negate
, const char *type_str
)
1252 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1255 if (type_str
== NULL
) {
1256 vty_out (vty
, "%% Missing type\n");
1257 return (CMD_WARNING_CONFIG_FAILED
);
1260 if (strcmp(type_str
, "ethernet") == 0)
1261 pw_type
= PW_TYPE_ETHERNET
;
1263 pw_type
= PW_TYPE_ETHERNET_TAGGED
;
1266 l2vpn
->pw_type
= DEFAULT_PW_TYPE
;
1268 l2vpn
->pw_type
= pw_type
;
1270 ldp_config_apply(vty
, vty_conf
);
1272 return (CMD_SUCCESS
);
1276 ldp_vty_l2vpn_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
1278 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1279 struct l2vpn_if
*lif
;
1281 if (ifname
== NULL
) {
1282 vty_out (vty
, "%% Missing IF name\n");
1283 return (CMD_WARNING_CONFIG_FAILED
);
1286 lif
= l2vpn_if_find(l2vpn
, ifname
);
1290 return (CMD_SUCCESS
);
1293 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1296 ldp_config_apply(vty
, vty_conf
);
1298 return (CMD_SUCCESS
);
1302 return (CMD_SUCCESS
);
1304 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1305 vty_out (vty
, "%% Interface is already in use\n");
1306 return (CMD_SUCCESS
);
1309 lif
= l2vpn_if_new(l2vpn
, ifname
);
1310 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1311 QOBJ_REG(lif
, l2vpn_if
);
1313 ldp_config_apply(vty
, vty_conf
);
1315 return (CMD_SUCCESS
);
1319 ldp_vty_l2vpn_pseudowire(struct vty
*vty
, const char *negate
, const char *ifname
)
1321 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1322 struct l2vpn_pw
*pw
;
1324 if (ifname
== NULL
) {
1325 vty_out (vty
, "%% Missing IF name\n");
1326 return (CMD_WARNING_CONFIG_FAILED
);
1329 pw
= l2vpn_pw_find(l2vpn
, ifname
);
1333 return (CMD_SUCCESS
);
1336 if (pw
->lsr_id
.s_addr
== INADDR_ANY
|| pw
->pwid
== 0)
1337 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1339 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1342 ldp_config_apply(vty
, vty_conf
);
1344 return (CMD_SUCCESS
);
1348 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1349 return (CMD_SUCCESS
);
1352 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1353 vty_out (vty
, "%% Interface is already in use\n");
1354 return (CMD_SUCCESS
);
1357 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1358 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1359 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1360 QOBJ_REG(pw
, l2vpn_pw
);
1362 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1364 ldp_config_apply(vty
, vty_conf
);
1366 return (CMD_SUCCESS
);
1370 ldp_vty_l2vpn_pw_cword(struct vty
*vty
, const char *negate
, const char *preference_str
)
1372 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1375 pw
->flags
|= F_PW_CWORD_CONF
;
1377 if (!preference_str
) {
1378 vty_out (vty
, "%% Missing preference\n");
1379 return (CMD_WARNING_CONFIG_FAILED
);
1381 if (preference_str
[0] == 'e')
1382 pw
->flags
&= ~F_PW_CWORD_CONF
;
1384 pw
->flags
|= F_PW_CWORD_CONF
;
1387 ldp_config_apply(vty
, vty_conf
);
1389 return (CMD_SUCCESS
);
1393 ldp_vty_l2vpn_pw_nbr_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
1395 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1397 union ldpd_addr addr
;
1399 if (ldp_get_address(addr_str
, &af
, &addr
) == -1 ||
1400 bad_addr(af
, &addr
)) {
1401 vty_out (vty
, "%% Malformed address\n");
1402 return (CMD_WARNING_CONFIG_FAILED
);
1407 memset(&pw
->addr
, 0, sizeof(pw
->addr
));
1408 pw
->flags
&= ~F_PW_STATIC_NBR_ADDR
;
1412 pw
->flags
|= F_PW_STATIC_NBR_ADDR
;
1415 ldp_config_apply(vty
, vty_conf
);
1417 return (CMD_SUCCESS
);
1421 ldp_vty_l2vpn_pw_nbr_id(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
)
1423 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1425 if (bad_addr_v4(lsr_id
)) {
1426 vty_out (vty
, "%% Malformed address\n");
1427 return (CMD_WARNING_CONFIG_FAILED
);
1431 pw
->lsr_id
.s_addr
= INADDR_ANY
;
1433 pw
->lsr_id
= lsr_id
;
1435 ldp_config_apply(vty
, vty_conf
);
1437 return (CMD_SUCCESS
);
1441 ldp_vty_l2vpn_pw_pwid(struct vty
*vty
, const char *negate
, long pwid
)
1443 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1450 ldp_config_apply(vty
, vty_conf
);
1452 return (CMD_SUCCESS
);
1456 ldp_vty_l2vpn_pw_pwstatus(struct vty
*vty
, const char *negate
)
1458 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1461 pw
->flags
|= F_PW_STATUSTLV_CONF
;
1463 pw
->flags
&= ~F_PW_STATUSTLV_CONF
;
1465 ldp_config_apply(vty
, vty_conf
);
1467 return (CMD_SUCCESS
);
1471 iface_new_api(struct ldpd_conf
*conf
, const char *name
)
1473 const char *ifname
= name
;
1474 struct iface
*iface
;
1476 if (ldp_iface_is_configured(conf
, ifname
))
1479 iface
= if_new(name
);
1480 RB_INSERT(iface_head
, &conf
->iface_tree
, iface
);
1481 QOBJ_REG(iface
, iface
);
1486 iface_del_api(struct ldpd_conf
*conf
, struct iface
*iface
)
1489 RB_REMOVE(iface_head
, &conf
->iface_tree
, iface
);
1494 tnbr_new_api(struct ldpd_conf
*conf
, int af
, union ldpd_addr
*addr
)
1498 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
->v6
))
1501 if (tnbr_find(conf
, af
, addr
))
1504 tnbr
= tnbr_new(af
, addr
);
1505 tnbr
->flags
|= F_TNBR_CONFIGURED
;
1506 RB_INSERT(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1507 QOBJ_REG(tnbr
, tnbr
);
1512 tnbr_del_api(struct ldpd_conf
*conf
, struct tnbr
*tnbr
)
1515 RB_REMOVE(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1520 nbrp_new_api(struct ldpd_conf
*conf
, struct in_addr lsr_id
)
1522 struct nbr_params
*nbrp
;
1524 if (nbr_params_find(conf
, lsr_id
))
1527 nbrp
= nbr_params_new(lsr_id
);
1528 RB_INSERT(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1529 QOBJ_REG(nbrp
, nbr_params
);
1534 nbrp_del_api(struct ldpd_conf
*conf
, struct nbr_params
*nbrp
)
1537 RB_REMOVE(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1542 l2vpn_new_api(struct ldpd_conf
*conf
, const char *name
)
1544 struct l2vpn
*l2vpn
;
1546 if (l2vpn_find(conf
, name
))
1549 l2vpn
= l2vpn_new(name
);
1550 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1551 RB_INSERT(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1552 QOBJ_REG(l2vpn
, l2vpn
);
1557 l2vpn_del_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
)
1559 struct l2vpn_if
*lif
;
1560 struct l2vpn_pw
*pw
;
1562 while (!RB_EMPTY(l2vpn_if_head
, &l2vpn
->if_tree
)) {
1563 lif
= RB_ROOT(l2vpn_if_head
, &l2vpn
->if_tree
);
1566 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1569 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_tree
)) {
1570 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_tree
);
1573 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1576 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)) {
1577 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
);
1580 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1584 RB_REMOVE(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1589 l2vpn_if_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1592 struct l2vpn_if
*lif
;
1594 if (ldp_iface_is_configured(conf
, ifname
))
1597 lif
= l2vpn_if_new(l2vpn
, ifname
);
1598 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1599 QOBJ_REG(lif
, l2vpn_if
);
1604 l2vpn_if_del_api(struct l2vpn
*l2vpn
, struct l2vpn_if
*lif
)
1607 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1612 l2vpn_pw_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1615 struct l2vpn_pw
*pw
;
1617 if (ldp_iface_is_configured(conf
, ifname
))
1620 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1621 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1622 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1623 QOBJ_REG(pw
, l2vpn_pw
);
1628 l2vpn_pw_del_api(struct l2vpn
*l2vpn
, struct l2vpn_pw
*pw
)
1631 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);