1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2020 Volta Networks, Inc
5 * You should have received a copy of the GNU Lesser General Public License
6 * along with this program. If not, see <https://www.gnu.org/licenses/>.
29 #include "link_state.h"
31 extern struct ted_state ted_state_g
;
32 #define TIMER_RETRY_DELAY 5 /* Timeout in seconds between ls sync request */
35 #define TED_NAME "PATHD TED"
44 struct thread_master
*main
;
45 /* Status of TED: enable or disable */
47 /* From which igp is going to receive data */
48 enum igp_import import
;
49 /* The TED itself as in link_state.h */
51 /* Timer for ted sync */
52 struct thread
*t_link_state_sync
;
53 /* Timer for refresh sid in segment list */
54 struct thread
*t_segment_list_refresh
;
55 /* delay interval in seconds */
56 uint32_t link_state_delay_interval
;
57 /* delay interval refresh in seconds */
58 uint32_t segment_list_refresh_interval
;
62 #define PATH_TED_DEBUG_BASIC 0x01
63 #define PATH_TED_DEBUG(fmt, ...) \
65 if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
66 DEBUGD(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
69 #define PATH_TED_ERROR(fmt, ...) \
71 if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
72 DEBUGE(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
74 #define PATH_TED_WARN(fmt, ...) \
76 if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
77 DEBUGW(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
79 #define PATH_TED_INFO(fmt, ...) \
81 if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
82 DEBUGI(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
85 /* TED management functions */
86 bool path_ted_is_initialized(void);
87 void path_ted_init(struct thread_master
*master
);
88 uint32_t path_ted_teardown(void);
89 void path_ted_timer_sync_cancel(void);
90 void path_ted_timer_refresh_cancel(void);
91 int path_ted_segment_list_refresh(void);
93 /* TED configuration functions */
94 uint32_t path_ted_config_write(struct vty
*vty
);
95 void path_ted_show_debugging(struct vty
*vty
);
97 /* TED util functions */
98 /* clang-format off */
99 #define LS_MSG_EVENT_PRINT(event) event == LS_MSG_EVENT_ADD?"add"\
100 : event == LS_MSG_EVENT_DELETE?"del"\
101 : event == LS_MSG_EVENT_UPDATE?"upd"\
102 : event == LS_MSG_EVENT_SYNC?"syn"\
103 : event == LS_MSG_EVENT_SYNC?"und" : "none"
104 #define LS_MSG_TYPE_PRINT(type) type == LS_MSG_TYPE_NODE?"node"\
105 : type == LS_MSG_TYPE_ATTRIBUTES?"att"\
106 : type == LS_MSG_TYPE_PREFIX?"pre" : "none"
107 #define LS_IGP_PRINT(type) type == ISIS_L1?"ISIS_L1"\
108 : type == ISIS_L2?"ISIS_L2"\
109 : type == DIRECT?"DIRECT"\
110 : type == STATIC?"STATIC"\
111 : type == OSPFv2?"OSPFv2" : "none"
112 #define PATH_TED_IGP_PRINT(type) type == IMPORT_OSPFv2?"OSPFv2"\
113 : type == IMPORT_OSPFv3?"OSPFv3"\
114 : type == IMPORT_ISIS?"ISIS" : "none"
115 /* clang-format on */
118 uint32_t path_ted_get_current_igp(uint32_t);
119 /* TED Query functions */
122 * Type of queries from draft-ietf-spring-segment-routing-policy-07 for types
127 * Search for sid based in prefix and optional algo
129 * @param prefix Net prefix to resolv
130 * @param algo Algorithm for link state
132 * @return sid of attribute
134 uint32_t path_ted_query_type_c(struct prefix
*prefix
, uint8_t algo
);
137 * Search for sid based in prefix and interface id
139 * @param prefix Net prefix to resolv
140 * @param iface_id The interface id
142 * @return sid of attribute
144 uint32_t path_ted_query_type_e(struct prefix
*prefix
, uint32_t iface_id
);
147 * Search for sid based in local, remote pair
149 * @param local local ip of attribute
150 * @param remote remote ip of attribute
152 * @return sid of attribute
154 uint32_t path_ted_query_type_f(struct ipaddr
*local
, struct ipaddr
*remote
);
158 * Handle the received opaque msg
160 * @param msg Holds the ted data
162 * @return sid of attribute
164 uint32_t path_ted_rcvd_message(struct ls_message
*msg
);
170 #endif /* _PATH_TED_H */