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",
137 vty_out (vty
, " exit\n");
142 ldp_af_config_write(struct vty
*vty
, int af
, struct ldpd_conf
*conf
,
143 struct ldpd_af_conf
*af_conf
)
147 if (!(af_conf
->flags
& F_LDPD_AF_ENABLED
))
150 vty_out (vty
, " !\n");
151 vty_out (vty
, " address-family %s\n", af_name(af
));
153 if (af_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
154 af_conf
->lhello_holdtime
!= 0 )
155 vty_out (vty
, " discovery hello holdtime %u\n",
156 af_conf
->lhello_holdtime
);
157 if (af_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
158 af_conf
->lhello_interval
!= 0)
159 vty_out (vty
, " discovery hello interval %u\n",
160 af_conf
->lhello_interval
);
162 if (af_conf
->flags
& F_LDPD_AF_THELLO_ACCEPT
) {
163 vty_out(vty
, " discovery targeted-hello accept");
164 if (af_conf
->acl_thello_accept_from
[0] != '\0')
165 vty_out(vty
, " from %s",
166 af_conf
->acl_thello_accept_from
);
170 if (af_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
171 af_conf
->thello_holdtime
!= 0)
172 vty_out (vty
, " discovery targeted-hello holdtime %u\n",
173 af_conf
->thello_holdtime
);
174 if (af_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
175 af_conf
->thello_interval
!= 0)
176 vty_out (vty
, " discovery targeted-hello interval %u\n",
177 af_conf
->thello_interval
);
179 if (ldp_addrisset(af
, &af_conf
->trans_addr
))
180 vty_out (vty
, " discovery transport-address %s\n",
181 log_addr(af
, &af_conf
->trans_addr
));
184 " ! Incomplete config, specify a discovery transport-address\n");
186 if ((af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
) ||
187 af_conf
->acl_label_allocate_for
[0] != '\0') {
188 vty_out(vty
, " label local allocate");
189 if (af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
)
190 vty_out(vty
, " host-routes");
192 vty_out(vty
, " for %s",
193 af_conf
->acl_label_allocate_for
);
197 if (af_conf
->acl_label_advertise_for
[0] != '\0' ||
198 af_conf
->acl_label_advertise_to
[0] != '\0') {
199 vty_out(vty
, " label local advertise");
200 if (af_conf
->acl_label_advertise_to
[0] != '\0')
201 vty_out(vty
, " to %s",
202 af_conf
->acl_label_advertise_to
);
203 if (af_conf
->acl_label_advertise_for
[0] != '\0')
204 vty_out(vty
, " for %s",
205 af_conf
->acl_label_advertise_for
);
209 if (af_conf
->flags
& F_LDPD_AF_EXPNULL
) {
210 vty_out(vty
, " label local advertise explicit-null");
211 if (af_conf
->acl_label_expnull_for
[0] != '\0')
212 vty_out(vty
, " for %s",
213 af_conf
->acl_label_expnull_for
);
217 if (af_conf
->acl_label_accept_for
[0] != '\0' ||
218 af_conf
->acl_label_accept_from
[0] != '\0') {
219 vty_out(vty
, " label remote accept");
220 if (af_conf
->acl_label_accept_from
[0] != '\0')
221 vty_out(vty
, " from %s",
222 af_conf
->acl_label_accept_from
);
223 if (af_conf
->acl_label_accept_for
[0] != '\0')
224 vty_out(vty
, " for %s",
225 af_conf
->acl_label_accept_for
);
229 if (af_conf
->flags
& F_LDPD_AF_NO_GTSM
)
230 vty_out (vty
, " ttl-security disable\n");
232 if (af_conf
->keepalive
!= DEFAULT_KEEPALIVE
)
233 vty_out (vty
, " session holdtime %u\n",af_conf
->keepalive
);
235 RB_FOREACH(tnbr
, tnbr_head
, &ldpd_conf
->tnbr_tree
) {
236 if (tnbr
->af
== af
) {
237 vty_out (vty
, " !\n");
238 vty_out (vty
, " neighbor %s targeted\n",
239 log_addr(tnbr
->af
, &tnbr
->addr
));
243 ldp_af_iface_config_write(vty
, af
);
245 vty_out(vty
, " !\n");
246 vty_out(vty
, " exit-address-family\n");
250 ldp_config_write(struct vty
*vty
)
252 struct nbr_params
*nbrp
;
254 if (!(ldpd_conf
->flags
& F_LDPD_ENABLED
))
257 vty_out (vty
, "mpls ldp\n");
259 if (ldpd_conf
->rtr_id
.s_addr
!= INADDR_ANY
)
260 vty_out(vty
, " router-id %pI4\n", &ldpd_conf
->rtr_id
);
262 if (ldpd_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
263 ldpd_conf
->lhello_holdtime
!= 0)
264 vty_out (vty
, " discovery hello holdtime %u\n",
265 ldpd_conf
->lhello_holdtime
);
266 if (ldpd_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
267 ldpd_conf
->lhello_interval
!= 0)
268 vty_out (vty
, " discovery hello interval %u\n",
269 ldpd_conf
->lhello_interval
);
271 if (ldpd_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
272 ldpd_conf
->thello_holdtime
!= 0)
273 vty_out (vty
, " discovery targeted-hello holdtime %u\n",
274 ldpd_conf
->thello_holdtime
);
275 if (ldpd_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
276 ldpd_conf
->thello_interval
!= 0)
277 vty_out (vty
, " discovery targeted-hello interval %u\n",
278 ldpd_conf
->thello_interval
);
280 if (ldpd_conf
->trans_pref
== DUAL_STACK_LDPOV4
)
282 " dual-stack transport-connection prefer ipv4\n");
284 if (ldpd_conf
->flags
& F_LDPD_DS_CISCO_INTEROP
)
285 vty_out (vty
, " dual-stack cisco-interop\n");
287 if (ldpd_conf
->flags
& F_LDPD_ORDERED_CONTROL
)
288 vty_out (vty
, " ordered-control\n");
290 if (ldpd_conf
->wait_for_sync_interval
!= DFLT_WAIT_FOR_SYNC
&&
291 ldpd_conf
->wait_for_sync_interval
!= 0)
292 vty_out (vty
, " wait-for-sync %u\n",
293 ldpd_conf
->wait_for_sync_interval
);
295 if (ldpd_conf
->flags
& F_LDPD_ALLOW_BROKEN_LSP
)
296 vty_out(vty
, " install allow-broken-lsp\n");
298 RB_FOREACH(nbrp
, nbrp_head
, &ldpd_conf
->nbrp_tree
) {
299 if (nbrp
->flags
& F_NBRP_KEEPALIVE
)
300 vty_out (vty
, " neighbor %pI4 session holdtime %u\n",
301 &nbrp
->lsr_id
,nbrp
->keepalive
);
303 if (nbrp
->flags
& F_NBRP_GTSM
) {
304 if (nbrp
->gtsm_enabled
)
305 vty_out (vty
, " neighbor %pI4 ttl-security hops %u\n", &nbrp
->lsr_id
,
308 vty_out (vty
, " neighbor %pI4 ttl-security disable\n",&nbrp
->lsr_id
);
311 if (nbrp
->auth
.method
== AUTH_MD5SIG
)
312 vty_out (vty
, " neighbor %pI4 password %s\n",
313 &nbrp
->lsr_id
,nbrp
->auth
.md5key
);
316 ldp_af_config_write(vty
, AF_INET
, ldpd_conf
, &ldpd_conf
->ipv4
);
317 ldp_af_config_write(vty
, AF_INET6
, ldpd_conf
, &ldpd_conf
->ipv6
);
318 vty_out (vty
, " !\n");
319 vty_out (vty
, "exit\n");
320 vty_out (vty
, "!\n");
326 ldp_l2vpn_pw_config_write(struct vty
*vty
, struct l2vpn_pw
*pw
)
328 int missing_lsrid
= 0;
329 int missing_pwid
= 0;
331 vty_out (vty
, " !\n");
332 vty_out (vty
, " member pseudowire %s\n", pw
->ifname
);
334 if (pw
->lsr_id
.s_addr
!= INADDR_ANY
)
335 vty_out (vty
, " neighbor lsr-id %pI4\n",&pw
->lsr_id
);
339 if (pw
->flags
& F_PW_STATIC_NBR_ADDR
)
340 vty_out (vty
, " neighbor address %s\n",
341 log_addr(pw
->af
, &pw
->addr
));
344 vty_out (vty
, " pw-id %u\n", pw
->pwid
);
348 if (!(pw
->flags
& F_PW_CWORD_CONF
))
349 vty_out (vty
, " control-word exclude\n");
351 if (!(pw
->flags
& F_PW_STATUSTLV_CONF
))
352 vty_out (vty
, " pw-status disable\n");
356 " ! Incomplete config, specify a neighbor lsr-id\n");
358 vty_out (vty
," ! Incomplete config, specify a pw-id\n");
360 vty_out (vty
, " exit\n");
364 ldp_l2vpn_config_write(struct vty
*vty
)
367 struct l2vpn_if
*lif
;
370 RB_FOREACH(l2vpn
, l2vpn_head
, &ldpd_conf
->l2vpn_tree
) {
371 vty_out (vty
, "l2vpn %s type vpls\n", l2vpn
->name
);
373 if (l2vpn
->pw_type
!= DEFAULT_PW_TYPE
)
374 vty_out (vty
, " vc type ethernet-tagged\n");
376 if (l2vpn
->mtu
!= DEFAULT_L2VPN_MTU
)
377 vty_out (vty
, " mtu %u\n", l2vpn
->mtu
);
379 if (l2vpn
->br_ifname
[0] != '\0')
380 vty_out (vty
, " bridge %s\n",l2vpn
->br_ifname
);
382 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
383 vty_out (vty
, " member interface %s\n",lif
->ifname
);
385 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
386 ldp_l2vpn_pw_config_write(vty
, pw
);
387 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
388 ldp_l2vpn_pw_config_write(vty
, pw
);
390 vty_out (vty
, " !\n");
391 vty_out (vty
, "exit\n");
392 vty_out (vty
, "!\n");
399 ldp_vty_get_af(struct vty
*vty
)
403 case LDP_IPV4_IFACE_NODE
:
406 case LDP_IPV6_IFACE_NODE
:
409 fatalx("ldp_vty_get_af: unexpected node");
414 ldp_iface_is_configured(struct ldpd_conf
*xconf
, const char *ifname
)
418 if (if_lookup_name(xconf
, ifname
))
421 RB_FOREACH(l2vpn
, l2vpn_head
, &xconf
->l2vpn_tree
) {
422 if (l2vpn_if_find(l2vpn
, ifname
))
424 if (l2vpn_pw_find(l2vpn
, ifname
))
432 ldp_vty_mpls_ldp(struct vty
*vty
, const char *negate
)
435 vty_conf
->flags
&= ~F_LDPD_ENABLED
;
437 vty
->node
= LDP_NODE
;
438 vty_conf
->flags
|= F_LDPD_ENABLED
;
441 /* register / de-register to recv info from zebra */
442 ldp_zebra_regdereg_zebra_info(!negate
);
444 ldp_config_apply(vty
, vty_conf
);
446 return (CMD_SUCCESS
);
450 ldp_vty_address_family(struct vty
*vty
, const char *negate
, const char *af_str
)
452 struct ldpd_af_conf
*af_conf
;
456 return (CMD_WARNING_CONFIG_FAILED
);
458 if (strcmp(af_str
, "ipv4") == 0) {
460 af_conf
= &vty_conf
->ipv4
;
461 } else if (strcmp(af_str
, "ipv6") == 0) {
463 af_conf
= &vty_conf
->ipv6
;
465 return (CMD_WARNING_CONFIG_FAILED
);
468 af_conf
->flags
&= ~F_LDPD_AF_ENABLED
;
469 ldp_config_apply(vty
, vty_conf
);
470 return (CMD_SUCCESS
);
475 vty
->node
= LDP_IPV4_NODE
;
478 vty
->node
= LDP_IPV6_NODE
;
481 fatalx("ldp_vty_address_family: unknown af");
483 af_conf
->flags
|= F_LDPD_AF_ENABLED
;
485 ldp_config_apply(vty
, vty_conf
);
487 return (CMD_SUCCESS
);
490 int ldp_vty_disc_holdtime(struct vty
*vty
, const char *negate
,
491 enum hello_type hello_type
, long secs
)
493 struct ldpd_af_conf
*af_conf
;
500 switch (hello_type
) {
502 vty_conf
->lhello_holdtime
= LINK_DFLT_HOLDTIME
;
505 vty_conf
->thello_holdtime
=
506 TARGETED_DFLT_HOLDTIME
;
510 switch (hello_type
) {
512 vty_conf
->lhello_holdtime
= secs
;
515 vty_conf
->thello_holdtime
= secs
;
519 ldp_config_apply(vty
, vty_conf
);
523 af
= ldp_vty_get_af(vty
);
524 af_conf
= ldp_af_conf_get(vty_conf
, af
);
527 switch (hello_type
) {
529 af_conf
->lhello_holdtime
= 0;
532 af_conf
->thello_holdtime
= 0;
536 switch (hello_type
) {
538 af_conf
->lhello_holdtime
= secs
;
541 af_conf
->thello_holdtime
= secs
;
545 ldp_config_apply(vty
, vty_conf
);
547 case LDP_IPV4_IFACE_NODE
:
548 case LDP_IPV6_IFACE_NODE
:
549 af
= ldp_vty_get_af(vty
);
550 iface
= VTY_GET_CONTEXT(iface
);
551 VTY_CHECK_CONTEXT(iface
);
553 ia
= iface_af_get(iface
, af
);
555 ia
->hello_holdtime
= 0;
557 ia
->hello_holdtime
= secs
;
559 ldp_config_apply(vty
, vty_conf
);
562 fatalx("ldp_vty_disc_holdtime: unexpected node");
565 return (CMD_SUCCESS
);
569 ldp_vty_disc_interval(struct vty
*vty
, const char *negate
,
570 enum hello_type hello_type
, long secs
)
572 struct ldpd_af_conf
*af_conf
;
580 switch (hello_type
) {
582 vty_conf
->lhello_interval
=
583 DEFAULT_HELLO_INTERVAL
;
586 vty_conf
->thello_interval
=
587 DEFAULT_HELLO_INTERVAL
;
591 switch (hello_type
) {
593 vty_conf
->lhello_interval
= secs
;
596 vty_conf
->thello_interval
= secs
;
600 ldp_config_apply(vty
, vty_conf
);
604 af
= ldp_vty_get_af(vty
);
605 af_conf
= ldp_af_conf_get(vty_conf
, af
);
608 switch (hello_type
) {
610 af_conf
->lhello_interval
= 0;
613 af_conf
->thello_interval
= 0;
617 switch (hello_type
) {
619 af_conf
->lhello_interval
= secs
;
622 af_conf
->thello_interval
= secs
;
626 ldp_config_apply(vty
, vty_conf
);
628 case LDP_IPV4_IFACE_NODE
:
629 case LDP_IPV6_IFACE_NODE
:
630 af
= ldp_vty_get_af(vty
);
631 iface
= VTY_GET_CONTEXT(iface
);
632 VTY_CHECK_CONTEXT(iface
);
634 ia
= iface_af_get(iface
, af
);
636 ia
->hello_interval
= 0;
638 ia
->hello_interval
= secs
;
640 ldp_config_apply(vty
, vty_conf
);
643 fatalx("ldp_vty_disc_interval: unexpected node");
646 return (CMD_SUCCESS
);
650 ldp_vty_targeted_hello_accept(struct vty
*vty
, const char *negate
,
651 const char *acl_from_str
)
653 struct ldpd_af_conf
*af_conf
;
656 af
= ldp_vty_get_af(vty
);
657 af_conf
= ldp_af_conf_get(vty_conf
, af
);
660 af_conf
->flags
&= ~F_LDPD_AF_THELLO_ACCEPT
;
661 af_conf
->acl_thello_accept_from
[0] = '\0';
663 af_conf
->flags
|= F_LDPD_AF_THELLO_ACCEPT
;
665 strlcpy(af_conf
->acl_thello_accept_from
, acl_from_str
,
666 sizeof(af_conf
->acl_thello_accept_from
));
668 af_conf
->acl_thello_accept_from
[0] = '\0';
671 ldp_config_apply(vty
, vty_conf
);
673 return (CMD_SUCCESS
);
677 ldp_vty_nbr_session_holdtime(struct vty
*vty
, const char *negate
,
678 struct in_addr lsr_id
, long secs
)
680 struct nbr_params
*nbrp
;
682 if (bad_addr_v4(lsr_id
)) {
683 vty_out (vty
, "%% Malformed address\n");
684 return (CMD_WARNING_CONFIG_FAILED
);
687 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
691 return (CMD_SUCCESS
);
694 nbrp
->flags
&= ~F_NBRP_KEEPALIVE
;
697 nbrp
= nbr_params_new(lsr_id
);
698 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
699 QOBJ_REG(nbrp
, nbr_params
);
700 } else if (nbrp
->keepalive
== secs
)
701 return (CMD_SUCCESS
);
703 nbrp
->keepalive
= secs
;
704 nbrp
->flags
|= F_NBRP_KEEPALIVE
;
707 ldp_config_apply(vty
, vty_conf
);
709 return (CMD_SUCCESS
);
713 ldp_vty_af_session_holdtime(struct vty
*vty
, const char *negate
, long secs
)
715 struct ldpd_af_conf
*af_conf
;
718 af
= ldp_vty_get_af(vty
);
719 af_conf
= ldp_af_conf_get(vty_conf
, af
);
722 af_conf
->keepalive
= DEFAULT_KEEPALIVE
;
724 af_conf
->keepalive
= secs
;
726 ldp_config_apply(vty
, vty_conf
);
728 return (CMD_SUCCESS
);
732 ldp_vty_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
738 if (ifname
== NULL
) {
739 vty_out (vty
, "%% Missing IF name\n");
740 return (CMD_WARNING_CONFIG_FAILED
);
743 af
= ldp_vty_get_af(vty
);
744 iface
= if_lookup_name(vty_conf
, ifname
);
748 return (CMD_SUCCESS
);
750 ia
= iface_af_get(iface
, af
);
751 if (ia
->enabled
== 0)
752 return (CMD_SUCCESS
);
755 ia
->hello_holdtime
= 0;
756 ia
->hello_interval
= 0;
758 ldp_config_apply(vty
, vty_conf
);
760 return (CMD_SUCCESS
);
764 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
765 vty_out (vty
,"%% Interface is already in use\n");
766 return (CMD_SUCCESS
);
769 iface
= if_new(ifname
);
770 ia
= iface_af_get(iface
, af
);
772 RB_INSERT(iface_head
, &vty_conf
->iface_tree
, iface
);
773 QOBJ_REG(iface
, iface
);
775 ldp_config_apply(vty
, vty_conf
);
777 ia
= iface_af_get(iface
, af
);
780 ldp_config_apply(vty
, vty_conf
);
786 VTY_PUSH_CONTEXT(LDP_IPV4_IFACE_NODE
, iface
);
789 VTY_PUSH_CONTEXT(LDP_IPV6_IFACE_NODE
, iface
);
795 return (CMD_SUCCESS
);
799 ldp_vty_trans_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
801 struct ldpd_af_conf
*af_conf
;
804 af
= ldp_vty_get_af(vty
);
805 af_conf
= ldp_af_conf_get(vty_conf
, af
);
808 memset(&af_conf
->trans_addr
, 0, sizeof(af_conf
->trans_addr
));
811 || inet_pton(af
, addr_str
, &af_conf
->trans_addr
) != 1
812 || bad_addr(af
, &af_conf
->trans_addr
)) {
813 vty_out (vty
, "%% Malformed address\n");
814 return (CMD_SUCCESS
);
818 ldp_config_apply(vty
, vty_conf
);
820 return (CMD_SUCCESS
);
824 ldp_vty_neighbor_targeted(struct vty
*vty
, const char *negate
, const char *addr_str
)
827 union ldpd_addr addr
;
830 af
= ldp_vty_get_af(vty
);
832 if (addr_str
== NULL
|| inet_pton(af
, addr_str
, &addr
) != 1 ||
833 bad_addr(af
, &addr
)) {
834 vty_out (vty
, "%% Malformed address\n");
835 return (CMD_WARNING_CONFIG_FAILED
);
837 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
.v6
)) {
838 vty_out (vty
, "%% Address can not be link-local\n");
839 return (CMD_WARNING_CONFIG_FAILED
);
842 tnbr
= tnbr_find(vty_conf
, af
, &addr
);
846 return (CMD_SUCCESS
);
849 RB_REMOVE(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
852 ldp_config_apply(vty
, vty_conf
);
854 return (CMD_SUCCESS
);
858 return (CMD_SUCCESS
);
860 tnbr
= tnbr_new(af
, &addr
);
861 tnbr
->flags
|= F_TNBR_CONFIGURED
;
862 RB_INSERT(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
863 QOBJ_REG(tnbr
, tnbr
);
865 ldp_config_apply(vty
, vty_conf
);
867 return (CMD_SUCCESS
);
871 ldp_vty_label_advertise(struct vty
*vty
, const char *negate
, const char *acl_to_str
,
872 const char *acl_for_str
)
874 struct ldpd_af_conf
*af_conf
;
877 af
= ldp_vty_get_af(vty
);
878 af_conf
= ldp_af_conf_get(vty_conf
, af
);
881 af_conf
->acl_label_advertise_to
[0] = '\0';
882 af_conf
->acl_label_advertise_for
[0] = '\0';
885 strlcpy(af_conf
->acl_label_advertise_to
, acl_to_str
,
886 sizeof(af_conf
->acl_label_advertise_to
));
888 af_conf
->acl_label_advertise_to
[0] = '\0';
890 strlcpy(af_conf
->acl_label_advertise_for
, acl_for_str
,
891 sizeof(af_conf
->acl_label_advertise_for
));
893 af_conf
->acl_label_advertise_for
[0] = '\0';
896 ldp_config_apply(vty
, vty_conf
);
898 return (CMD_SUCCESS
);
902 ldp_vty_label_allocate(struct vty
*vty
, const char *negate
, const char *host_routes
,
903 const char *acl_for_str
)
905 struct ldpd_af_conf
*af_conf
;
908 af
= ldp_vty_get_af(vty
);
909 af_conf
= ldp_af_conf_get(vty_conf
, af
);
911 af_conf
->flags
&= ~F_LDPD_AF_ALLOCHOSTONLY
;
912 af_conf
->acl_label_allocate_for
[0] = '\0';
915 af_conf
->flags
|= F_LDPD_AF_ALLOCHOSTONLY
;
917 strlcpy(af_conf
->acl_label_allocate_for
, acl_for_str
,
918 sizeof(af_conf
->acl_label_allocate_for
));
921 ldp_config_apply(vty
, vty_conf
);
923 return (CMD_SUCCESS
);
927 ldp_vty_label_expnull(struct vty
*vty
, const char *negate
, const char *acl_for_str
)
929 struct ldpd_af_conf
*af_conf
;
932 af
= ldp_vty_get_af(vty
);
933 af_conf
= ldp_af_conf_get(vty_conf
, af
);
936 af_conf
->flags
&= ~F_LDPD_AF_EXPNULL
;
937 af_conf
->acl_label_expnull_for
[0] = '\0';
939 af_conf
->flags
|= F_LDPD_AF_EXPNULL
;
941 strlcpy(af_conf
->acl_label_expnull_for
, acl_for_str
,
942 sizeof(af_conf
->acl_label_expnull_for
));
944 af_conf
->acl_label_expnull_for
[0] = '\0';
947 ldp_config_apply(vty
, vty_conf
);
949 return (CMD_SUCCESS
);
953 ldp_vty_label_accept(struct vty
*vty
, const char *negate
, const char *acl_from_str
,
954 const char *acl_for_str
)
956 struct ldpd_af_conf
*af_conf
;
959 af
= ldp_vty_get_af(vty
);
960 af_conf
= ldp_af_conf_get(vty_conf
, af
);
963 af_conf
->acl_label_accept_from
[0] = '\0';
964 af_conf
->acl_label_accept_for
[0] = '\0';
967 strlcpy(af_conf
->acl_label_accept_from
, acl_from_str
,
968 sizeof(af_conf
->acl_label_accept_from
));
970 af_conf
->acl_label_accept_from
[0] = '\0';
972 strlcpy(af_conf
->acl_label_accept_for
, acl_for_str
,
973 sizeof(af_conf
->acl_label_accept_for
));
975 af_conf
->acl_label_accept_for
[0] = '\0';
978 ldp_config_apply(vty
, vty_conf
);
980 return (CMD_SUCCESS
);
984 ldp_vty_ttl_security(struct vty
*vty
, const char *negate
)
986 struct ldpd_af_conf
*af_conf
;
989 af
= ldp_vty_get_af(vty
);
990 af_conf
= ldp_af_conf_get(vty_conf
, af
);
993 af_conf
->flags
&= ~F_LDPD_AF_NO_GTSM
;
995 af_conf
->flags
|= F_LDPD_AF_NO_GTSM
;
997 ldp_config_apply(vty
, vty_conf
);
999 return (CMD_SUCCESS
);
1003 ldp_vty_router_id(struct vty
*vty
, const char *negate
, struct in_addr address
)
1006 vty_conf
->rtr_id
.s_addr
= INADDR_ANY
;
1008 if (bad_addr_v4(address
)) {
1009 vty_out (vty
, "%% Malformed address\n");
1010 return (CMD_SUCCESS
);
1012 vty_conf
->rtr_id
= address
;
1015 ldp_config_apply(vty
, vty_conf
);
1017 return (CMD_SUCCESS
);
1021 ldp_vty_ordered_control(struct vty
*vty
, const char *negate
)
1024 vty_conf
->flags
&= ~F_LDPD_ORDERED_CONTROL
;
1026 vty_conf
->flags
|= F_LDPD_ORDERED_CONTROL
;
1028 ldp_config_apply(vty
, vty_conf
);
1030 return (CMD_SUCCESS
);
1033 int ldp_vty_wait_for_sync_interval(struct vty
*vty
, const char *negate
,
1036 switch (vty
->node
) {
1039 vty_conf
->wait_for_sync_interval
= DFLT_WAIT_FOR_SYNC
;
1041 vty_conf
->wait_for_sync_interval
= secs
;
1043 ldp_config_apply(vty
, vty_conf
);
1046 fatalx("ldp_vty_wait_for_sync_interval: unexpected node");
1048 return (CMD_SUCCESS
);
1052 ldp_vty_allow_broken_lsp(struct vty
*vty
, const char *negate
)
1055 vty_conf
->flags
&= ~F_LDPD_ALLOW_BROKEN_LSP
;
1057 vty_conf
->flags
|= F_LDPD_ALLOW_BROKEN_LSP
;
1059 ldp_config_apply(vty
, vty_conf
);
1061 return (CMD_SUCCESS
);
1065 ldp_vty_ds_cisco_interop(struct vty
*vty
, const char * negate
)
1068 vty_conf
->flags
&= ~F_LDPD_DS_CISCO_INTEROP
;
1070 vty_conf
->flags
|= F_LDPD_DS_CISCO_INTEROP
;
1072 ldp_config_apply(vty
, vty_conf
);
1074 return (CMD_SUCCESS
);
1078 ldp_vty_trans_pref_ipv4(struct vty
*vty
, const char *negate
)
1081 vty_conf
->trans_pref
= DUAL_STACK_LDPOV6
;
1083 vty_conf
->trans_pref
= DUAL_STACK_LDPOV4
;
1085 ldp_config_apply(vty
, vty_conf
);
1087 return (CMD_SUCCESS
);
1091 ldp_vty_neighbor_password(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
,
1092 const char *password_str
)
1094 size_t password_len
;
1095 struct nbr_params
*nbrp
;
1097 if (password_str
== NULL
) {
1098 vty_out (vty
, "%% Missing password\n");
1099 return (CMD_WARNING_CONFIG_FAILED
);
1102 if (bad_addr_v4(lsr_id
)) {
1103 vty_out (vty
, "%% Malformed address\n");
1104 return (CMD_WARNING_CONFIG_FAILED
);
1107 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1111 return (CMD_SUCCESS
);
1113 memset(&nbrp
->auth
, 0, sizeof(nbrp
->auth
));
1114 nbrp
->auth
.method
= AUTH_NONE
;
1117 nbrp
= nbr_params_new(lsr_id
);
1118 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1119 QOBJ_REG(nbrp
, nbr_params
);
1120 } else if (nbrp
->auth
.method
== AUTH_MD5SIG
&&
1121 strcmp(nbrp
->auth
.md5key
, password_str
) == 0)
1122 return (CMD_SUCCESS
);
1124 password_len
= strlcpy(nbrp
->auth
.md5key
, password_str
,
1125 sizeof(nbrp
->auth
.md5key
));
1126 if (password_len
>= sizeof(nbrp
->auth
.md5key
))
1127 vty_out(vty
, "%% password has been truncated to %zu characters.", sizeof(nbrp
->auth
.md5key
) - 1);
1128 nbrp
->auth
.md5key_len
= strlen(nbrp
->auth
.md5key
);
1129 nbrp
->auth
.method
= AUTH_MD5SIG
;
1132 ldp_config_apply(vty
, vty_conf
);
1134 return (CMD_SUCCESS
);
1138 ldp_vty_neighbor_ttl_security(struct vty
*vty
, const char *negate
,
1139 struct in_addr lsr_id
, const char *hops_str
)
1141 struct nbr_params
*nbrp
;
1145 if (bad_addr_v4(lsr_id
)) {
1146 vty_out (vty
, "%% Malformed address\n");
1147 return (CMD_WARNING_CONFIG_FAILED
);
1151 hops
= strtol(hops_str
, &ep
, 10);
1152 if (*ep
!= '\0' || hops
< 1 || hops
> 254) {
1153 vty_out (vty
, "%% Invalid hop count\n");
1154 return (CMD_SUCCESS
);
1158 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1162 return (CMD_SUCCESS
);
1164 nbrp
->flags
&= ~(F_NBRP_GTSM
|F_NBRP_GTSM_HOPS
);
1165 nbrp
->gtsm_enabled
= 0;
1166 nbrp
->gtsm_hops
= 0;
1169 nbrp
= nbr_params_new(lsr_id
);
1170 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1171 QOBJ_REG(nbrp
, nbr_params
);
1174 nbrp
->flags
|= F_NBRP_GTSM
;
1175 nbrp
->flags
&= ~F_NBRP_GTSM_HOPS
;
1177 nbrp
->gtsm_enabled
= 1;
1178 nbrp
->gtsm_hops
= hops
;
1179 nbrp
->flags
|= F_NBRP_GTSM_HOPS
;
1181 nbrp
->gtsm_enabled
= 0;
1184 ldp_config_apply(vty
, vty_conf
);
1186 return (CMD_SUCCESS
);
1190 ldp_vty_l2vpn(struct vty
*vty
, const char *negate
, const char *name_str
)
1192 struct l2vpn
*l2vpn
;
1193 struct l2vpn_if
*lif
;
1194 struct l2vpn_pw
*pw
;
1196 if (name_str
== NULL
) {
1197 vty_out (vty
, "%% Missing name\n");
1198 return (CMD_WARNING_CONFIG_FAILED
);
1201 l2vpn
= l2vpn_find(vty_conf
, name_str
);
1205 return (CMD_SUCCESS
);
1207 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
1209 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
1211 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
1214 RB_REMOVE(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1217 ldp_config_apply(vty
, vty_conf
);
1219 return (CMD_SUCCESS
);
1223 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1224 return (CMD_SUCCESS
);
1227 l2vpn
= l2vpn_new(name_str
);
1228 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1229 RB_INSERT(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1230 QOBJ_REG(l2vpn
, l2vpn
);
1232 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1234 ldp_config_apply(vty
, vty_conf
);
1236 return (CMD_SUCCESS
);
1240 ldp_vty_l2vpn_bridge(struct vty
*vty
, const char *negate
, const char *ifname
)
1242 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1245 memset(l2vpn
->br_ifname
, 0, sizeof(l2vpn
->br_ifname
));
1247 if (ifname
== NULL
) {
1248 vty_out (vty
, "%% Missing IF name\n");
1249 return (CMD_WARNING_CONFIG_FAILED
);
1251 strlcpy(l2vpn
->br_ifname
, ifname
, sizeof(l2vpn
->br_ifname
));
1254 ldp_config_apply(vty
, vty_conf
);
1256 return (CMD_SUCCESS
);
1260 ldp_vty_l2vpn_mtu(struct vty
*vty
, const char *negate
, long mtu
)
1262 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1265 l2vpn
->mtu
= DEFAULT_L2VPN_MTU
;
1269 ldp_config_apply(vty
, vty_conf
);
1271 return (CMD_SUCCESS
);
1275 ldp_vty_l2vpn_pwtype(struct vty
*vty
, const char *negate
, const char *type_str
)
1277 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1280 if (type_str
== NULL
) {
1281 vty_out (vty
, "%% Missing type\n");
1282 return (CMD_WARNING_CONFIG_FAILED
);
1285 if (strcmp(type_str
, "ethernet") == 0)
1286 pw_type
= PW_TYPE_ETHERNET
;
1288 pw_type
= PW_TYPE_ETHERNET_TAGGED
;
1291 l2vpn
->pw_type
= DEFAULT_PW_TYPE
;
1293 l2vpn
->pw_type
= pw_type
;
1295 ldp_config_apply(vty
, vty_conf
);
1297 return (CMD_SUCCESS
);
1301 ldp_vty_l2vpn_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
1303 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1304 struct l2vpn_if
*lif
;
1306 if (ifname
== NULL
) {
1307 vty_out (vty
, "%% Missing IF name\n");
1308 return (CMD_WARNING_CONFIG_FAILED
);
1311 lif
= l2vpn_if_find(l2vpn
, ifname
);
1315 return (CMD_SUCCESS
);
1318 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1321 ldp_config_apply(vty
, vty_conf
);
1323 return (CMD_SUCCESS
);
1327 return (CMD_SUCCESS
);
1329 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1330 vty_out (vty
, "%% Interface is already in use\n");
1331 return (CMD_SUCCESS
);
1334 lif
= l2vpn_if_new(l2vpn
, ifname
);
1335 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1336 QOBJ_REG(lif
, l2vpn_if
);
1338 ldp_config_apply(vty
, vty_conf
);
1340 return (CMD_SUCCESS
);
1344 ldp_vty_l2vpn_pseudowire(struct vty
*vty
, const char *negate
, const char *ifname
)
1346 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1347 struct l2vpn_pw
*pw
;
1349 if (ifname
== NULL
) {
1350 vty_out (vty
, "%% Missing IF name\n");
1351 return (CMD_WARNING_CONFIG_FAILED
);
1354 pw
= l2vpn_pw_find(l2vpn
, ifname
);
1358 return (CMD_SUCCESS
);
1361 if (pw
->lsr_id
.s_addr
== INADDR_ANY
|| pw
->pwid
== 0)
1362 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1364 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1367 ldp_config_apply(vty
, vty_conf
);
1369 return (CMD_SUCCESS
);
1373 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1374 return (CMD_SUCCESS
);
1377 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1378 vty_out (vty
, "%% Interface is already in use\n");
1379 return (CMD_SUCCESS
);
1382 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1383 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1384 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1385 QOBJ_REG(pw
, l2vpn_pw
);
1387 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1389 ldp_config_apply(vty
, vty_conf
);
1391 return (CMD_SUCCESS
);
1395 ldp_vty_l2vpn_pw_cword(struct vty
*vty
, const char *negate
, const char *preference_str
)
1397 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1400 pw
->flags
|= F_PW_CWORD_CONF
;
1402 if (!preference_str
) {
1403 vty_out (vty
, "%% Missing preference\n");
1404 return (CMD_WARNING_CONFIG_FAILED
);
1406 if (preference_str
[0] == 'e')
1407 pw
->flags
&= ~F_PW_CWORD_CONF
;
1409 pw
->flags
|= F_PW_CWORD_CONF
;
1412 ldp_config_apply(vty
, vty_conf
);
1414 return (CMD_SUCCESS
);
1418 ldp_vty_l2vpn_pw_nbr_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
1420 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1422 union ldpd_addr addr
;
1424 if (ldp_get_address(addr_str
, &af
, &addr
) == -1 ||
1425 bad_addr(af
, &addr
)) {
1426 vty_out (vty
, "%% Malformed address\n");
1427 return (CMD_WARNING_CONFIG_FAILED
);
1432 memset(&pw
->addr
, 0, sizeof(pw
->addr
));
1433 pw
->flags
&= ~F_PW_STATIC_NBR_ADDR
;
1437 pw
->flags
|= F_PW_STATIC_NBR_ADDR
;
1440 ldp_config_apply(vty
, vty_conf
);
1442 return (CMD_SUCCESS
);
1446 ldp_vty_l2vpn_pw_nbr_id(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
)
1448 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1450 if (bad_addr_v4(lsr_id
)) {
1451 vty_out (vty
, "%% Malformed address\n");
1452 return (CMD_WARNING_CONFIG_FAILED
);
1456 pw
->lsr_id
.s_addr
= INADDR_ANY
;
1458 pw
->lsr_id
= lsr_id
;
1460 ldp_config_apply(vty
, vty_conf
);
1462 return (CMD_SUCCESS
);
1466 ldp_vty_l2vpn_pw_pwid(struct vty
*vty
, const char *negate
, long pwid
)
1468 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1475 ldp_config_apply(vty
, vty_conf
);
1477 return (CMD_SUCCESS
);
1481 ldp_vty_l2vpn_pw_pwstatus(struct vty
*vty
, const char *negate
)
1483 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1486 pw
->flags
|= F_PW_STATUSTLV_CONF
;
1488 pw
->flags
&= ~F_PW_STATUSTLV_CONF
;
1490 ldp_config_apply(vty
, vty_conf
);
1492 return (CMD_SUCCESS
);
1496 iface_new_api(struct ldpd_conf
*conf
, const char *name
)
1498 const char *ifname
= name
;
1499 struct iface
*iface
;
1501 if (ldp_iface_is_configured(conf
, ifname
))
1504 iface
= if_new(name
);
1505 RB_INSERT(iface_head
, &conf
->iface_tree
, iface
);
1506 QOBJ_REG(iface
, iface
);
1511 iface_del_api(struct ldpd_conf
*conf
, struct iface
*iface
)
1514 RB_REMOVE(iface_head
, &conf
->iface_tree
, iface
);
1519 tnbr_new_api(struct ldpd_conf
*conf
, int af
, union ldpd_addr
*addr
)
1523 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
->v6
))
1526 if (tnbr_find(conf
, af
, addr
))
1529 tnbr
= tnbr_new(af
, addr
);
1530 tnbr
->flags
|= F_TNBR_CONFIGURED
;
1531 RB_INSERT(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1532 QOBJ_REG(tnbr
, tnbr
);
1537 tnbr_del_api(struct ldpd_conf
*conf
, struct tnbr
*tnbr
)
1540 RB_REMOVE(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1545 nbrp_new_api(struct ldpd_conf
*conf
, struct in_addr lsr_id
)
1547 struct nbr_params
*nbrp
;
1549 if (nbr_params_find(conf
, lsr_id
))
1552 nbrp
= nbr_params_new(lsr_id
);
1553 RB_INSERT(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1554 QOBJ_REG(nbrp
, nbr_params
);
1559 nbrp_del_api(struct ldpd_conf
*conf
, struct nbr_params
*nbrp
)
1562 RB_REMOVE(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1567 l2vpn_new_api(struct ldpd_conf
*conf
, const char *name
)
1569 struct l2vpn
*l2vpn
;
1571 if (l2vpn_find(conf
, name
))
1574 l2vpn
= l2vpn_new(name
);
1575 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1576 RB_INSERT(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1577 QOBJ_REG(l2vpn
, l2vpn
);
1582 l2vpn_del_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
)
1584 struct l2vpn_if
*lif
;
1585 struct l2vpn_pw
*pw
;
1587 while (!RB_EMPTY(l2vpn_if_head
, &l2vpn
->if_tree
)) {
1588 lif
= RB_ROOT(l2vpn_if_head
, &l2vpn
->if_tree
);
1591 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1594 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_tree
)) {
1595 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_tree
);
1598 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1601 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)) {
1602 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
);
1605 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1609 RB_REMOVE(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1614 l2vpn_if_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1617 struct l2vpn_if
*lif
;
1619 if (ldp_iface_is_configured(conf
, ifname
))
1622 lif
= l2vpn_if_new(l2vpn
, ifname
);
1623 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1624 QOBJ_REG(lif
, l2vpn_if
);
1629 l2vpn_if_del_api(struct l2vpn
*l2vpn
, struct l2vpn_if
*lif
)
1632 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1637 l2vpn_pw_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1640 struct l2vpn_pw
*pw
;
1642 if (ldp_iface_is_configured(conf
, ifname
))
1645 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1646 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1647 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1648 QOBJ_REG(pw
, l2vpn_pw
);
1653 l2vpn_pw_del_api(struct l2vpn
*l2vpn
, struct l2vpn_pw
*pw
)
1656 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);