1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2020 NetDEF, Inc.
8 #include "northbound.h"
11 #include "pathd/path_nb.h"
13 static int iter_objfun_cb(const struct lyd_node
*dnode
, void *arg
);
14 static int dummy_create(struct nb_cb_create_args
*args
);
15 static int dummy_modify(struct nb_cb_modify_args
*args
);
16 static int dummy_destroy(struct nb_cb_destroy_args
*args
);
20 enum objfun_type type
;
21 struct of_cb_pref
*next
;
25 struct of_cb_pref
*first
;
27 struct of_cb_pref prefs
[MAX_OBJFUN_TYPE
];
30 /* clang-format off */
31 const struct frr_yang_module_info frr_pathd_info
= {
35 .xpath
= "/frr-pathd:pathd",
37 .apply_finish
= pathd_apply_finish
,
39 .priority
= NB_DFLT_PRIORITY
+ 1
42 .xpath
= "/frr-pathd:pathd/srte/segment-list",
44 .create
= pathd_srte_segment_list_create
,
45 .cli_show
= cli_show_srte_segment_list
,
46 .cli_show_end
= cli_show_srte_segment_list_end
,
47 .destroy
= pathd_srte_segment_list_destroy
,
48 .get_next
= pathd_srte_segment_list_get_next
,
49 .get_keys
= pathd_srte_segment_list_get_keys
,
50 .lookup_entry
= pathd_srte_segment_list_lookup_entry
,
52 .priority
= NB_DFLT_PRIORITY
- 1
55 .xpath
= "/frr-pathd:pathd/srte/segment-list/protocol-origin",
57 .modify
= pathd_srte_segment_list_protocol_origin_modify
,
59 .priority
= NB_DFLT_PRIORITY
- 1
62 .xpath
= "/frr-pathd:pathd/srte/segment-list/originator",
64 .modify
= pathd_srte_segment_list_originator_modify
,
66 .priority
= NB_DFLT_PRIORITY
- 1
69 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment",
71 .create
= pathd_srte_segment_list_segment_create
,
72 .cli_show
= cli_show_srte_segment_list_segment
,
73 .destroy
= pathd_srte_segment_list_segment_destroy
,
75 .priority
= NB_DFLT_PRIORITY
- 1
78 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment/sid-value",
80 .modify
= pathd_srte_segment_list_segment_sid_value_modify
,
81 .destroy
= pathd_srte_segment_list_segment_sid_value_destroy
,
83 .priority
= NB_DFLT_PRIORITY
- 1
86 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment/nai",
88 .create
= dummy_create
,
89 .destroy
= pathd_srte_segment_list_segment_nai_destroy
,
90 .apply_finish
= pathd_srte_segment_list_segment_nai_apply_finish
92 .priority
= NB_DFLT_PRIORITY
- 1
95 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment/nai/type",
96 .cbs
= {.modify
= dummy_modify
}
99 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment/nai/local-address",
100 .cbs
= {.modify
= dummy_modify
}
103 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment/nai/local-interface",
104 .cbs
= {.modify
= dummy_modify
, .destroy
= dummy_destroy
}
107 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment/nai/local-prefix-len",
108 .cbs
= {.modify
= dummy_modify
, .destroy
= dummy_destroy
}
111 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment/nai/remote-address",
112 .cbs
= {.modify
= dummy_modify
, .destroy
= dummy_destroy
}
115 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment/nai/remote-interface",
116 .cbs
= {.modify
= dummy_modify
, .destroy
= dummy_destroy
}
119 .xpath
= "/frr-pathd:pathd/srte/segment-list/segment/nai/algorithm",
120 .cbs
= {.modify
= dummy_modify
, .destroy
= dummy_destroy
}
123 .xpath
= "/frr-pathd:pathd/srte/policy",
125 .create
= pathd_srte_policy_create
,
126 .cli_show
= cli_show_srte_policy
,
127 .cli_show_end
= cli_show_srte_policy_end
,
128 .destroy
= pathd_srte_policy_destroy
,
129 .get_next
= pathd_srte_policy_get_next
,
130 .get_keys
= pathd_srte_policy_get_keys
,
131 .lookup_entry
= pathd_srte_policy_lookup_entry
,
135 .xpath
= "/frr-pathd:pathd/srte/policy/name",
137 .modify
= pathd_srte_policy_name_modify
,
138 .cli_show
= cli_show_srte_policy_name
,
139 .destroy
= pathd_srte_policy_name_destroy
,
143 .xpath
= "/frr-pathd:pathd/srte/policy/binding-sid",
145 .modify
= pathd_srte_policy_binding_sid_modify
,
146 .cli_show
= cli_show_srte_policy_binding_sid
,
147 .destroy
= pathd_srte_policy_binding_sid_destroy
,
151 .xpath
= "/frr-pathd:pathd/srte/policy/is-operational",
153 .get_elem
= pathd_srte_policy_is_operational_get_elem
157 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path",
159 .create
= pathd_srte_policy_candidate_path_create
,
160 .cli_show
= cli_show_srte_policy_candidate_path
,
161 .cli_show_end
= cli_show_srte_policy_candidate_path_end
,
162 .destroy
= pathd_srte_policy_candidate_path_destroy
,
163 .get_next
= pathd_srte_policy_candidate_path_get_next
,
164 .get_keys
= pathd_srte_policy_candidate_path_get_keys
,
165 .lookup_entry
= pathd_srte_policy_candidate_path_lookup_entry
,
169 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/name",
171 .modify
= pathd_srte_policy_candidate_path_name_modify
,
175 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/is-best-candidate-path",
177 .get_elem
= pathd_srte_policy_candidate_path_is_best_candidate_path_get_elem
,
181 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/protocol-origin",
183 .modify
= pathd_srte_policy_candidate_path_protocol_origin_modify
,
187 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/originator",
189 .modify
= pathd_srte_policy_candidate_path_originator_modify
,
193 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/discriminator",
195 .get_elem
= pathd_srte_policy_candidate_path_discriminator_get_elem
,
199 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/type",
201 .modify
= pathd_srte_policy_candidate_path_type_modify
,
205 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/segment-list-name",
207 .destroy
= pathd_srte_policy_candidate_path_segment_list_name_destroy
,
208 .modify
= pathd_srte_policy_candidate_path_segment_list_name_modify
,
212 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/bandwidth",
214 .create
= dummy_create
,
215 .destroy
= pathd_srte_policy_candidate_path_bandwidth_destroy
,
216 .apply_finish
= pathd_srte_policy_candidate_path_bandwidth_apply_finish
220 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/bandwidth/required",
221 .cbs
= {.modify
= dummy_modify
}
224 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/bandwidth/value",
225 .cbs
= {.modify
= dummy_modify
}
228 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/affinity/exclude-any",
230 .modify
= pathd_srte_policy_candidate_path_exclude_any_modify
,
231 .destroy
= pathd_srte_policy_candidate_path_exclude_any_destroy
,
235 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/affinity/include-any",
237 .modify
= pathd_srte_policy_candidate_path_include_any_modify
,
238 .destroy
= pathd_srte_policy_candidate_path_include_any_destroy
,
242 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/affinity/include-all",
244 .modify
= pathd_srte_policy_candidate_path_include_all_modify
,
245 .destroy
= pathd_srte_policy_candidate_path_include_all_destroy
,
249 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics",
251 .create
= dummy_create
,
252 .destroy
= pathd_srte_policy_candidate_path_metrics_destroy
,
253 .apply_finish
= pathd_srte_policy_candidate_path_metrics_apply_finish
257 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics/value",
258 .cbs
= {.modify
= dummy_modify
}
261 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics/required",
262 .cbs
= {.modify
= dummy_modify
}
265 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics/is-bound",
266 .cbs
= {.modify
= dummy_modify
, .destroy
= dummy_destroy
}
269 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/metrics/is-computed",
270 .cbs
= {.modify
= dummy_modify
, .destroy
= dummy_destroy
}
273 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/objective-function",
275 .create
= dummy_create
,
276 .destroy
= pathd_srte_policy_candidate_path_objfun_destroy
,
277 .apply_finish
= pathd_srte_policy_candidate_path_objfun_apply_finish
281 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/objective-function/required",
282 .cbs
= {.modify
= dummy_modify
}
285 .xpath
= "/frr-pathd:pathd/srte/policy/candidate-path/constraints/objective-function/type",
286 .cbs
= {.modify
= dummy_modify
}
294 void iter_objfun_prefs(const struct lyd_node
*dnode
, const char* path
,
295 of_pref_cp_t fun
, void *arg
)
297 struct of_cb_args args
= {0};
298 struct of_cb_pref
*p
;
300 yang_dnode_iterate(iter_objfun_cb
, &args
, dnode
, "%s", path
);
301 for (p
= args
.first
; p
!= NULL
; p
= p
->next
)
305 int iter_objfun_cb(const struct lyd_node
*dnode
, void *arg
)
307 struct of_cb_args
*of_arg
= arg
;
308 struct of_cb_pref
*pref
;
309 struct of_cb_pref
**p
;
311 if (of_arg
->free_slot
>= MAX_OBJFUN_TYPE
)
312 return YANG_ITER_STOP
;
314 pref
= &of_arg
->prefs
[of_arg
->free_slot
++];
316 pref
->index
= yang_dnode_get_uint32(dnode
, "./index");
317 pref
->type
= yang_dnode_get_enum(dnode
, "./type");
319 /* Simplistic insertion sort */
326 if ((*p
)->index
>= pref
->index
) {
334 return YANG_ITER_CONTINUE
;
337 int dummy_create(struct nb_cb_create_args
*args
)
342 int dummy_modify(struct nb_cb_modify_args
*args
)
347 int dummy_destroy(struct nb_cb_destroy_args
*args
)