]> git.proxmox.com Git - mirror_frr.git/blob - pathd/path_ted.h
doc: Add `show ipv6 rpf X:X::X:X` command to docs
[mirror_frr.git] / pathd / path_ted.h
1 /*
2 * Copyright (C) 2020 Volta Networks, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 */
18
19 #ifndef _PATH_TED_H
20 #define _PATH_TED_H
21
22 #ifdef __cplusplus
23
24 extern "C" {
25 #endif
26
27 #include <zebra.h>
28
29 #include <stdbool.h>
30
31 #include <debug.h>
32 #include "linklist.h"
33 #include "log.h"
34 #include "command.h"
35 #include "stream.h"
36 #include "prefix.h"
37 #include "zclient.h"
38 #include "link_state.h"
39
40 extern struct ted_state ted_state_g;
41 #define TIMER_RETRY_DELAY 5 /* Timeout in seconds between ls sync request */
42 #define TED_KEY 1
43 #define TED_ASN 1
44 #define TED_NAME "PATHD TED"
45
46 enum igp_import {
47 IMPORT_UNKNOWN = 0,
48 IMPORT_ISIS,
49 IMPORT_OSPFv2,
50 IMPORT_OSPFv3
51 };
52 struct ted_state {
53 struct thread_master *main;
54 /* Status of TED: enable or disable */
55 bool enabled;
56 /* From which igp is going to receive data */
57 enum igp_import import;
58 /* The TED itself as in link_state.h */
59 struct ls_ted *ted;
60 /* Timer for ted sync */
61 struct thread *t_link_state_sync;
62 /* Timer for refresh sid in segment list */
63 struct thread *t_segment_list_refresh;
64 /* delay interval in seconds */
65 uint32_t link_state_delay_interval;
66 /* delay interval refresh in seconds */
67 uint32_t segment_list_refresh_interval;
68 struct debug dbg;
69 };
70 /* Debug flags. */
71 #define PATH_TED_DEBUG_BASIC 0x01
72 #define PATH_TED_DEBUG(fmt, ...) \
73 do { \
74 if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
75 DEBUGD(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
76 } while (0)
77
78 #define PATH_TED_ERROR(fmt, ...) \
79 do { \
80 if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
81 DEBUGE(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
82 } while (0)
83 #define PATH_TED_WARN(fmt, ...) \
84 do { \
85 if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
86 DEBUGW(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
87 } while (0)
88 #define PATH_TED_INFO(fmt, ...) \
89 do { \
90 if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
91 DEBUGI(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
92 } while (0)
93
94 /* TED management functions */
95 bool path_ted_is_initialized(void);
96 void path_ted_init(struct thread_master *master);
97 uint32_t path_ted_teardown(void);
98 void path_ted_timer_sync_cancel(void);
99 void path_ted_timer_refresh_cancel(void);
100 int path_ted_segment_list_refresh(void);
101
102 /* TED configuration functions */
103 uint32_t path_ted_config_write(struct vty *vty);
104 void path_ted_show_debugging(struct vty *vty);
105
106 /* TED util functions */
107 /* clang-format off */
108 #define LS_MSG_EVENT_PRINT(event) event == LS_MSG_EVENT_ADD?"add"\
109 : event == LS_MSG_EVENT_DELETE?"del"\
110 : event == LS_MSG_EVENT_UPDATE?"upd"\
111 : event == LS_MSG_EVENT_SYNC?"syn"\
112 : event == LS_MSG_EVENT_SYNC?"und" : "none"
113 #define LS_MSG_TYPE_PRINT(type) type == LS_MSG_TYPE_NODE?"node"\
114 : type == LS_MSG_TYPE_ATTRIBUTES?"att"\
115 : type == LS_MSG_TYPE_PREFIX?"pre" : "none"
116 #define LS_IGP_PRINT(type) type == ISIS_L1?"ISIS_L1"\
117 : type == ISIS_L2?"ISIS_L2"\
118 : type == DIRECT?"DIRECT"\
119 : type == STATIC?"STATIC"\
120 : type == OSPFv2?"OSPFv2" : "none"
121 #define PATH_TED_IGP_PRINT(type) type == IMPORT_OSPFv2?"OSPFv2"\
122 : type == IMPORT_OSPFv3?"OSPFv3"\
123 : type == IMPORT_ISIS?"ISIS" : "none"
124 /* clang-format on */
125
126
127 uint32_t path_ted_get_current_igp(uint32_t);
128 /* TED Query functions */
129
130 /*
131 * Type of queries from draft-ietf-spring-segment-routing-policy-07 for types
132 * f,c,e
133 */
134
135 /**
136 * Search for sid based in prefix and optional algo
137 *
138 * @param prefix Net prefix to resolv
139 * @param algo Algorithm for link state
140 *
141 * @return sid of attribute
142 */
143 uint32_t path_ted_query_type_c(struct prefix *prefix, uint8_t algo);
144
145 /**
146 * Search for sid based in prefix and interface id
147 *
148 * @param prefix Net prefix to resolv
149 * @param iface_id The interface id
150 *
151 * @return sid of attribute
152 */
153 uint32_t path_ted_query_type_e(struct prefix *prefix, uint32_t iface_id);
154
155 /**
156 * Search for sid based in local, remote pair
157 *
158 * @param local local ip of attribute
159 * @param remote remote ip of attribute
160 *
161 * @return sid of attribute
162 */
163 uint32_t path_ted_query_type_f(struct ipaddr *local, struct ipaddr *remote);
164
165
166 /**
167 * Handle the received opaque msg
168 *
169 * @param msg Holds the ted data
170 *
171 * @return sid of attribute
172 */
173 uint32_t path_ted_rcvd_message(struct ls_message *msg);
174
175 #ifdef __cplusplus
176 }
177 #endif
178
179 #endif /* _PATH_TED_H */