2 * ldp_sync.c: LDP-SYNC handling routines
3 * Copyright (C) 2020 Volta Networks, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 DEFINE_MTYPE_STATIC(LIB
, LDP_SYNC_INFO
, "LDP SYNC info");
37 * ldp_sync_info_create - Allocate the LDP_SYNC information
39 struct ldp_sync_info
*ldp_sync_info_create(void)
41 struct ldp_sync_info
*ldp_sync_info
;
43 ldp_sync_info
= XCALLOC(MTYPE_LDP_SYNC_INFO
,
44 sizeof(struct ldp_sync_info
));
45 assert(ldp_sync_info
);
47 ldp_sync_info
->flags
= 0;
48 ldp_sync_info
->enabled
= LDP_IGP_SYNC_DEFAULT
;
49 ldp_sync_info
->state
= LDP_IGP_SYNC_STATE_NOT_REQUIRED
;
50 ldp_sync_info
->holddown
= LDP_IGP_SYNC_HOLDDOWN_DEFAULT
;
51 ldp_sync_info
->t_holddown
= NULL
;
56 * ldp_sync_info_free - Free the LDP_SYNC information.
58 void ldp_sync_info_free(struct ldp_sync_info
**ldp_sync_info
)
61 XFREE(MTYPE_LDP_SYNC_INFO
, *ldp_sync_info
);
64 bool ldp_sync_if_is_enabled(struct ldp_sync_info
*ldp_sync_info
)
66 /* return true if LDP-SYNC is configured on this interface */
68 ldp_sync_info
->enabled
== LDP_IGP_SYNC_ENABLED
&&
69 ldp_sync_info
->state
== LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP
)
75 bool ldp_sync_if_down(struct ldp_sync_info
*ldp_sync_info
)
77 /* Stop LDP-SYNC on this interface:
78 * if holddown timer is running stop it
81 if (ldp_sync_info
&& ldp_sync_info
->enabled
== LDP_IGP_SYNC_ENABLED
) {
82 THREAD_OFF(ldp_sync_info
->t_holddown
);
84 if (ldp_sync_info
->state
== LDP_IGP_SYNC_STATE_REQUIRED_UP
)
85 ldp_sync_info
->state
=
86 LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP
;