1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
/*
* Copyright (C) 2020 NetDEF, Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "libfrr.h"
#include "pathd/path_nb.h"
static int iter_objfun_cb(const struct lyd_node *dnode, void *arg);
static int dummy_create(struct nb_cb_create_args *args);
static int dummy_modify(struct nb_cb_modify_args *args);
static int dummy_destroy(struct nb_cb_destroy_args *args);
struct of_cb_pref {
uint32_t index;
enum objfun_type type;
struct of_cb_pref *next;
};
struct of_cb_args {
struct of_cb_pref *first;
uint32_t free_slot;
struct of_cb_pref prefs[MAX_OBJFUN_TYPE];
};
/* clang-format off */
const struct frr_yang_module_info frr_pathd_info = {
.name = "frr-pathd",
.nodes = {
{
.xpath = "/frr-pathd:pathd",
.cbs = {
.apply_finish = pathd_apply_finish,
},
.priority = NB_DFLT_PRIORITY + 1
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list",
.cbs = {
.create = pathd_srte_segment_list_create,
.cli_show = cli_show_srte_segment_list,
.cli_show_end = cli_show_srte_segment_list_end,
.destroy = pathd_srte_segment_list_destroy,
.get_next = pathd_srte_segment_list_get_next,
.get_keys = pathd_srte_segment_list_get_keys,
.lookup_entry = pathd_srte_segment_list_lookup_entry,
},
.priority = NB_DFLT_PRIORITY - 1
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/protocol-origin",
.cbs = {
.modify = pathd_srte_segment_list_protocol_origin_modify,
},
.priority = NB_DFLT_PRIORITY - 1
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/originator",
.cbs = {
.modify = pathd_srte_segment_list_originator_modify,
},
.priority = NB_DFLT_PRIORITY - 1
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment",
.cbs = {
.create = pathd_srte_segment_list_segment_create,
.cli_show = cli_show_srte_segment_list_segment,
.destroy = pathd_srte_segment_list_segment_destroy,
},
.priority = NB_DFLT_PRIORITY - 1
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment/sid-value",
.cbs = {
.modify = pathd_srte_segment_list_segment_sid_value_modify,
.destroy = pathd_srte_segment_list_segment_sid_value_destroy,
},
.priority = NB_DFLT_PRIORITY - 1
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment/nai",
.cbs = {
.create = dummy_create,
.destroy = pathd_srte_segment_list_segment_nai_destroy,
.apply_finish = pathd_srte_segment_list_segment_nai_apply_finish
},
.priority = NB_DFLT_PRIORITY - 1
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment/nai/type",
.cbs = {.modify = dummy_modify}
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment/nai/local-address",
.cbs = {.modify = dummy_modify}
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment/nai/local-interface",
.cbs = {.modify = dummy_modify, .destroy = dummy_destroy}
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment/nai/local-prefix-len",
.cbs = {.modify = dummy_modify, .destroy = dummy_destroy}
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment/nai/remote-address",
.cbs = {.modify = dummy_modify, .destroy = dummy_destroy}
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment/nai/remote-interface",
.cbs = {.modify = dummy_modify, .destroy = dummy_destroy}
},
{
.xpath = "/frr-pathd:pathd/srte/segment-list/segment/nai/algorithm",
.cbs = {.modify = dummy_modify, .destroy = dummy_destroy}
},
{
.xpath = "/frr-pathd:pathd/srte/policy",
.cbs = {
.create = pathd_srte_policy_create,
.cli_show = cli_show_srte_policy,
.cli_show_end = cli_show_srte_policy_end,
.destroy = pathd_srte_policy_destroy,
.get_next = pathd_srte_policy_get_next,
.get_keys = pathd_srte_policy_get_keys,
.lookup_entry = pathd_srte_policy_lookup_entry,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/name",
.cbs = {
.modify = pathd_srte_policy_name_modify,
.cli_show = cli_show_srte_policy_name,
.destroy = pathd_srte_policy_name_destroy,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/binding-sid",
.cbs = {
.modify = pathd_srte_policy_binding_sid_modify,
.cli_show = cli_show_srte_policy_binding_sid,
.destroy = pathd_srte_policy_binding_sid_destroy,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/is-operational",
.cbs = {
.get_elem = pathd_srte_policy_is_operational_get_elem
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path",
.cbs = {
.create = pathd_srte_policy_candidate_path_create,
.cli_show = cli_show_srte_policy_candidate_path,
.cli_show_end = cli_show_srte_policy_candidate_path_end,
.destroy = pathd_srte_policy_candidate_path_destroy,
.get_next = pathd_srte_policy_candidate_path_get_next,
.get_keys = pathd_srte_policy_candidate_path_get_keys,
.lookup_entry = pathd_srte_policy_candidate_path_lookup_entry,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/name",
.cbs = {
.modify = pathd_srte_policy_candidate_path_name_modify,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/is-best-candidate-path",
.cbs = {
.get_elem = pathd_srte_policy_candidate_path_is_best_candidate_path_get_elem,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/protocol-origin",
.cbs = {
.modify = pathd_srte_policy_candidate_path_protocol_origin_modify,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/originator",
.cbs = {
.modify = pathd_srte_policy_candidate_path_originator_modify,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/discriminator",
.cbs = {
.get_elem = pathd_srte_policy_candidate_path_discriminator_get_elem,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/type",
.cbs = {
.modify = pathd_srte_policy_candidate_path_type_modify,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/segment-list-name",
.cbs = {
.destroy = pathd_srte_policy_candidate_path_segment_list_name_destroy,
.modify = pathd_srte_policy_candidate_path_segment_list_name_modify,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/bandwidth",
.cbs = {
.create = dummy_create,
.destroy = pathd_srte_policy_candidate_path_bandwidth_destroy,
.apply_finish = pathd_srte_policy_candidate_path_bandwidth_apply_finish
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/bandwidth/required",
.cbs = {.modify = dummy_modify}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/bandwidth/value",
.cbs = {.modify = dummy_modify}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/affinity/exclude-any",
.cbs = {
.modify = pathd_srte_policy_candidate_path_exclude_any_modify,
.destroy = pathd_srte_policy_candidate_path_exclude_any_destroy,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/affinity/include-any",
.cbs = {
.modify = pathd_srte_policy_candidate_path_include_any_modify,
.destroy = pathd_srte_policy_candidate_path_include_any_destroy,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/affinity/include-all",
.cbs = {
.modify = pathd_srte_policy_candidate_path_include_all_modify,
.destroy = pathd_srte_policy_candidate_path_include_all_destroy,
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics",
.cbs = {
.create = dummy_create,
.destroy = pathd_srte_policy_candidate_path_metrics_destroy,
.apply_finish = pathd_srte_policy_candidate_path_metrics_apply_finish
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics/value",
.cbs = {.modify = dummy_modify}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics/required",
.cbs = {.modify = dummy_modify}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics/is-bound",
.cbs = {.modify = dummy_modify, .destroy = dummy_destroy}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics/is-computed",
.cbs = {.modify = dummy_modify, .destroy = dummy_destroy}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/objective-function",
.cbs = {
.create = dummy_create,
.destroy = pathd_srte_policy_candidate_path_objfun_destroy,
.apply_finish = pathd_srte_policy_candidate_path_objfun_apply_finish
}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/objective-function/required",
.cbs = {.modify = dummy_modify}
},
{
.xpath = "/frr-pathd:pathd/srte/policy/candidate-path/constraints/objective-function/type",
.cbs = {.modify = dummy_modify}
},
{
.xpath = NULL,
},
}
};
void iter_objfun_prefs(const struct lyd_node *dnode, const char* path,
of_pref_cp_t fun, void *arg)
{
struct of_cb_args args = {0};
struct of_cb_pref *p;
yang_dnode_iterate(iter_objfun_cb, &args, dnode, "%s", path);
for (p = args.first; p != NULL; p = p->next)
fun(p->type, arg);
}
int iter_objfun_cb(const struct lyd_node *dnode, void *arg)
{
struct of_cb_args *of_arg = arg;
struct of_cb_pref *pref;
struct of_cb_pref **p;
if (of_arg->free_slot >= MAX_OBJFUN_TYPE)
return YANG_ITER_STOP;
pref = &of_arg->prefs[of_arg->free_slot++];
pref->index = yang_dnode_get_uint32(dnode, "./index");
pref->type = yang_dnode_get_enum(dnode, "./type");
/* Simplistic insertion sort */
p = &of_arg->first;
while (true) {
if (*p == NULL) {
*p = pref;
break;
}
if ((*p)->index >= pref->index) {
pref->next = *p;
*p = pref;
break;
}
p = &(*p)->next;
}
return YANG_ITER_CONTINUE;
}
int dummy_create(struct nb_cb_create_args *args)
{
return NB_OK;
}
int dummy_modify(struct nb_cb_modify_args *args)
{
return NB_OK;
}
int dummy_destroy(struct nb_cb_destroy_args *args)
{
return NB_OK;
}
|