/src/open5gs/lib/sbi/openapi/model/nf_service.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "nf_service.h" |
6 | | |
7 | | OpenAPI_nf_service_t *OpenAPI_nf_service_create( |
8 | | char *service_instance_id, |
9 | | OpenAPI_service_name_e service_name, |
10 | | OpenAPI_list_t *versions, |
11 | | OpenAPI_uri_scheme_e scheme, |
12 | | OpenAPI_nf_service_status_e nf_service_status, |
13 | | char *fqdn, |
14 | | char *inter_plmn_fqdn, |
15 | | OpenAPI_list_t *ip_end_points, |
16 | | char *api_prefix, |
17 | | OpenAPI_list_t *callback_uri_prefix_list, |
18 | | OpenAPI_list_t *default_notification_subscriptions, |
19 | | OpenAPI_list_t *allowed_plmns, |
20 | | OpenAPI_list_t *allowed_snpns, |
21 | | OpenAPI_list_t *allowed_nf_types, |
22 | | OpenAPI_list_t *allowed_nf_domains, |
23 | | OpenAPI_list_t *allowed_nssais, |
24 | | OpenAPI_list_t* allowed_operations_per_nf_type, |
25 | | OpenAPI_list_t* allowed_operations_per_nf_instance, |
26 | | bool is_allowed_operations_per_nf_instance_overrides, |
27 | | int allowed_operations_per_nf_instance_overrides, |
28 | | OpenAPI_list_t* allowed_scopes_rule_set, |
29 | | bool is_priority, |
30 | | int priority, |
31 | | bool is_capacity, |
32 | | int capacity, |
33 | | bool is_load, |
34 | | int load, |
35 | | char *load_time_stamp, |
36 | | char *recovery_time, |
37 | | char *supported_features, |
38 | | OpenAPI_list_t *nf_service_set_id_list, |
39 | | OpenAPI_list_t *s_nssais, |
40 | | OpenAPI_list_t *per_plmn_snssai_list, |
41 | | char *vendor_id, |
42 | | OpenAPI_list_t* supported_vendor_specific_features, |
43 | | bool is_oauth2_required, |
44 | | int oauth2_required, |
45 | | OpenAPI_plmn_oauth2_t *per_plmn_oauth2_req_list, |
46 | | OpenAPI_selection_conditions_t *selection_conditions, |
47 | | bool is_canary_release, |
48 | | int canary_release, |
49 | | bool is_exclusive_canary_release_selection, |
50 | | int exclusive_canary_release_selection, |
51 | | char *shared_service_data_id, |
52 | | char *shutdown_time, |
53 | | bool is_canary_precedence_over_preferred, |
54 | | int canary_precedence_over_preferred |
55 | | ) |
56 | 3.04k | { |
57 | 3.04k | OpenAPI_nf_service_t *nf_service_local_var = ogs_malloc(sizeof(OpenAPI_nf_service_t)); |
58 | 3.04k | ogs_assert(nf_service_local_var); |
59 | | |
60 | 3.04k | nf_service_local_var->service_instance_id = service_instance_id; |
61 | 3.04k | nf_service_local_var->service_name = service_name; |
62 | 3.04k | nf_service_local_var->versions = versions; |
63 | 3.04k | nf_service_local_var->scheme = scheme; |
64 | 3.04k | nf_service_local_var->nf_service_status = nf_service_status; |
65 | 3.04k | nf_service_local_var->fqdn = fqdn; |
66 | 3.04k | nf_service_local_var->inter_plmn_fqdn = inter_plmn_fqdn; |
67 | 3.04k | nf_service_local_var->ip_end_points = ip_end_points; |
68 | 3.04k | nf_service_local_var->api_prefix = api_prefix; |
69 | 3.04k | nf_service_local_var->callback_uri_prefix_list = callback_uri_prefix_list; |
70 | 3.04k | nf_service_local_var->default_notification_subscriptions = default_notification_subscriptions; |
71 | 3.04k | nf_service_local_var->allowed_plmns = allowed_plmns; |
72 | 3.04k | nf_service_local_var->allowed_snpns = allowed_snpns; |
73 | 3.04k | nf_service_local_var->allowed_nf_types = allowed_nf_types; |
74 | 3.04k | nf_service_local_var->allowed_nf_domains = allowed_nf_domains; |
75 | 3.04k | nf_service_local_var->allowed_nssais = allowed_nssais; |
76 | 3.04k | nf_service_local_var->allowed_operations_per_nf_type = allowed_operations_per_nf_type; |
77 | 3.04k | nf_service_local_var->allowed_operations_per_nf_instance = allowed_operations_per_nf_instance; |
78 | 3.04k | nf_service_local_var->is_allowed_operations_per_nf_instance_overrides = is_allowed_operations_per_nf_instance_overrides; |
79 | 3.04k | nf_service_local_var->allowed_operations_per_nf_instance_overrides = allowed_operations_per_nf_instance_overrides; |
80 | 3.04k | nf_service_local_var->allowed_scopes_rule_set = allowed_scopes_rule_set; |
81 | 3.04k | nf_service_local_var->is_priority = is_priority; |
82 | 3.04k | nf_service_local_var->priority = priority; |
83 | 3.04k | nf_service_local_var->is_capacity = is_capacity; |
84 | 3.04k | nf_service_local_var->capacity = capacity; |
85 | 3.04k | nf_service_local_var->is_load = is_load; |
86 | 3.04k | nf_service_local_var->load = load; |
87 | 3.04k | nf_service_local_var->load_time_stamp = load_time_stamp; |
88 | 3.04k | nf_service_local_var->recovery_time = recovery_time; |
89 | 3.04k | nf_service_local_var->supported_features = supported_features; |
90 | 3.04k | nf_service_local_var->nf_service_set_id_list = nf_service_set_id_list; |
91 | 3.04k | nf_service_local_var->s_nssais = s_nssais; |
92 | 3.04k | nf_service_local_var->per_plmn_snssai_list = per_plmn_snssai_list; |
93 | 3.04k | nf_service_local_var->vendor_id = vendor_id; |
94 | 3.04k | nf_service_local_var->supported_vendor_specific_features = supported_vendor_specific_features; |
95 | 3.04k | nf_service_local_var->is_oauth2_required = is_oauth2_required; |
96 | 3.04k | nf_service_local_var->oauth2_required = oauth2_required; |
97 | 3.04k | nf_service_local_var->per_plmn_oauth2_req_list = per_plmn_oauth2_req_list; |
98 | 3.04k | nf_service_local_var->selection_conditions = selection_conditions; |
99 | 3.04k | nf_service_local_var->is_canary_release = is_canary_release; |
100 | 3.04k | nf_service_local_var->canary_release = canary_release; |
101 | 3.04k | nf_service_local_var->is_exclusive_canary_release_selection = is_exclusive_canary_release_selection; |
102 | 3.04k | nf_service_local_var->exclusive_canary_release_selection = exclusive_canary_release_selection; |
103 | 3.04k | nf_service_local_var->shared_service_data_id = shared_service_data_id; |
104 | 3.04k | nf_service_local_var->shutdown_time = shutdown_time; |
105 | 3.04k | nf_service_local_var->is_canary_precedence_over_preferred = is_canary_precedence_over_preferred; |
106 | 3.04k | nf_service_local_var->canary_precedence_over_preferred = canary_precedence_over_preferred; |
107 | | |
108 | 3.04k | return nf_service_local_var; |
109 | 3.04k | } |
110 | | |
111 | | void OpenAPI_nf_service_free(OpenAPI_nf_service_t *nf_service) |
112 | 4.50k | { |
113 | 4.50k | OpenAPI_lnode_t *node = NULL; |
114 | | |
115 | 4.50k | if (NULL == nf_service) { |
116 | 1.46k | return; |
117 | 1.46k | } |
118 | 3.04k | if (nf_service->service_instance_id) { |
119 | 3.04k | ogs_free(nf_service->service_instance_id); |
120 | 3.04k | nf_service->service_instance_id = NULL; |
121 | 3.04k | } |
122 | 3.04k | if (nf_service->versions) { |
123 | 3.04k | OpenAPI_list_for_each(nf_service->versions, node) { |
124 | 100 | OpenAPI_nf_service_version_free(node->data); |
125 | 100 | } |
126 | 3.04k | OpenAPI_list_free(nf_service->versions); |
127 | 3.04k | nf_service->versions = NULL; |
128 | 3.04k | } |
129 | 3.04k | if (nf_service->fqdn) { |
130 | 1 | ogs_free(nf_service->fqdn); |
131 | 1 | nf_service->fqdn = NULL; |
132 | 1 | } |
133 | 3.04k | if (nf_service->inter_plmn_fqdn) { |
134 | 66 | ogs_free(nf_service->inter_plmn_fqdn); |
135 | 66 | nf_service->inter_plmn_fqdn = NULL; |
136 | 66 | } |
137 | 3.04k | if (nf_service->ip_end_points) { |
138 | 1.83k | OpenAPI_list_for_each(nf_service->ip_end_points, node) { |
139 | 1.83k | OpenAPI_ip_end_point_free(node->data); |
140 | 1.83k | } |
141 | 176 | OpenAPI_list_free(nf_service->ip_end_points); |
142 | 176 | nf_service->ip_end_points = NULL; |
143 | 176 | } |
144 | 3.04k | if (nf_service->api_prefix) { |
145 | 1 | ogs_free(nf_service->api_prefix); |
146 | 1 | nf_service->api_prefix = NULL; |
147 | 1 | } |
148 | 3.04k | if (nf_service->callback_uri_prefix_list) { |
149 | 1 | OpenAPI_list_for_each(nf_service->callback_uri_prefix_list, node) { |
150 | 0 | OpenAPI_callback_uri_prefix_item_free(node->data); |
151 | 0 | } |
152 | 1 | OpenAPI_list_free(nf_service->callback_uri_prefix_list); |
153 | 1 | nf_service->callback_uri_prefix_list = NULL; |
154 | 1 | } |
155 | 3.04k | if (nf_service->default_notification_subscriptions) { |
156 | 1 | OpenAPI_list_for_each(nf_service->default_notification_subscriptions, node) { |
157 | 0 | OpenAPI_default_notification_subscription_free(node->data); |
158 | 0 | } |
159 | 1 | OpenAPI_list_free(nf_service->default_notification_subscriptions); |
160 | 1 | nf_service->default_notification_subscriptions = NULL; |
161 | 1 | } |
162 | 3.04k | if (nf_service->allowed_plmns) { |
163 | 114 | OpenAPI_list_for_each(nf_service->allowed_plmns, node) { |
164 | 114 | OpenAPI_plmn_id_free(node->data); |
165 | 114 | } |
166 | 11 | OpenAPI_list_free(nf_service->allowed_plmns); |
167 | 11 | nf_service->allowed_plmns = NULL; |
168 | 11 | } |
169 | 3.04k | if (nf_service->allowed_snpns) { |
170 | 74 | OpenAPI_list_for_each(nf_service->allowed_snpns, node) { |
171 | 74 | OpenAPI_plmn_id_nid_free(node->data); |
172 | 74 | } |
173 | 9 | OpenAPI_list_free(nf_service->allowed_snpns); |
174 | 9 | nf_service->allowed_snpns = NULL; |
175 | 9 | } |
176 | 3.04k | if (nf_service->allowed_nf_types) { |
177 | 44 | OpenAPI_list_free(nf_service->allowed_nf_types); |
178 | 44 | nf_service->allowed_nf_types = NULL; |
179 | 44 | } |
180 | 3.04k | if (nf_service->allowed_nf_domains) { |
181 | 436 | OpenAPI_list_for_each(nf_service->allowed_nf_domains, node) { |
182 | 436 | ogs_free(node->data); |
183 | 436 | } |
184 | 142 | OpenAPI_list_free(nf_service->allowed_nf_domains); |
185 | 142 | nf_service->allowed_nf_domains = NULL; |
186 | 142 | } |
187 | 3.04k | if (nf_service->allowed_nssais) { |
188 | 324 | OpenAPI_list_for_each(nf_service->allowed_nssais, node) { |
189 | 324 | OpenAPI_ext_snssai_free(node->data); |
190 | 324 | } |
191 | 148 | OpenAPI_list_free(nf_service->allowed_nssais); |
192 | 148 | nf_service->allowed_nssais = NULL; |
193 | 148 | } |
194 | 3.04k | if (nf_service->allowed_operations_per_nf_type) { |
195 | 1 | OpenAPI_list_for_each(nf_service->allowed_operations_per_nf_type, node) { |
196 | 0 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
197 | 0 | ogs_free(localKeyValue->key); |
198 | 0 | ogs_free(localKeyValue->value); |
199 | 0 | OpenAPI_map_free(localKeyValue); |
200 | 0 | } |
201 | 1 | OpenAPI_list_free(nf_service->allowed_operations_per_nf_type); |
202 | 1 | nf_service->allowed_operations_per_nf_type = NULL; |
203 | 1 | } |
204 | 3.04k | if (nf_service->allowed_operations_per_nf_instance) { |
205 | 1 | OpenAPI_list_for_each(nf_service->allowed_operations_per_nf_instance, node) { |
206 | 0 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
207 | 0 | ogs_free(localKeyValue->key); |
208 | 0 | ogs_free(localKeyValue->value); |
209 | 0 | OpenAPI_map_free(localKeyValue); |
210 | 0 | } |
211 | 1 | OpenAPI_list_free(nf_service->allowed_operations_per_nf_instance); |
212 | 1 | nf_service->allowed_operations_per_nf_instance = NULL; |
213 | 1 | } |
214 | 3.04k | if (nf_service->allowed_scopes_rule_set) { |
215 | 472 | OpenAPI_list_for_each(nf_service->allowed_scopes_rule_set, node) { |
216 | 472 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
217 | 472 | ogs_free(localKeyValue->key); |
218 | 472 | OpenAPI_rule_set_free(localKeyValue->value); |
219 | 472 | OpenAPI_map_free(localKeyValue); |
220 | 472 | } |
221 | 176 | OpenAPI_list_free(nf_service->allowed_scopes_rule_set); |
222 | 176 | nf_service->allowed_scopes_rule_set = NULL; |
223 | 176 | } |
224 | 3.04k | if (nf_service->load_time_stamp) { |
225 | 66 | ogs_free(nf_service->load_time_stamp); |
226 | 66 | nf_service->load_time_stamp = NULL; |
227 | 66 | } |
228 | 3.04k | if (nf_service->recovery_time) { |
229 | 66 | ogs_free(nf_service->recovery_time); |
230 | 66 | nf_service->recovery_time = NULL; |
231 | 66 | } |
232 | 3.04k | if (nf_service->supported_features) { |
233 | 66 | ogs_free(nf_service->supported_features); |
234 | 66 | nf_service->supported_features = NULL; |
235 | 66 | } |
236 | 3.04k | if (nf_service->nf_service_set_id_list) { |
237 | 294 | OpenAPI_list_for_each(nf_service->nf_service_set_id_list, node) { |
238 | 294 | ogs_free(node->data); |
239 | 294 | } |
240 | 166 | OpenAPI_list_free(nf_service->nf_service_set_id_list); |
241 | 166 | nf_service->nf_service_set_id_list = NULL; |
242 | 166 | } |
243 | 3.04k | if (nf_service->s_nssais) { |
244 | 331 | OpenAPI_list_for_each(nf_service->s_nssais, node) { |
245 | 331 | OpenAPI_ext_snssai_free(node->data); |
246 | 331 | } |
247 | 107 | OpenAPI_list_free(nf_service->s_nssais); |
248 | 107 | nf_service->s_nssais = NULL; |
249 | 107 | } |
250 | 3.04k | if (nf_service->per_plmn_snssai_list) { |
251 | 1 | OpenAPI_list_for_each(nf_service->per_plmn_snssai_list, node) { |
252 | 0 | OpenAPI_plmn_snssai_free(node->data); |
253 | 0 | } |
254 | 1 | OpenAPI_list_free(nf_service->per_plmn_snssai_list); |
255 | 1 | nf_service->per_plmn_snssai_list = NULL; |
256 | 1 | } |
257 | 3.04k | if (nf_service->vendor_id) { |
258 | 102 | ogs_free(nf_service->vendor_id); |
259 | 102 | nf_service->vendor_id = NULL; |
260 | 102 | } |
261 | 3.04k | if (nf_service->supported_vendor_specific_features) { |
262 | 667 | OpenAPI_list_for_each(nf_service->supported_vendor_specific_features, node) { |
263 | 667 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
264 | 667 | ogs_free(localKeyValue->key); |
265 | 667 | OpenAPI_vendor_specific_feature_free(localKeyValue->value); |
266 | 667 | OpenAPI_map_free(localKeyValue); |
267 | 667 | } |
268 | 20 | OpenAPI_list_free(nf_service->supported_vendor_specific_features); |
269 | 20 | nf_service->supported_vendor_specific_features = NULL; |
270 | 20 | } |
271 | 3.04k | if (nf_service->per_plmn_oauth2_req_list) { |
272 | 66 | OpenAPI_plmn_oauth2_free(nf_service->per_plmn_oauth2_req_list); |
273 | 66 | nf_service->per_plmn_oauth2_req_list = NULL; |
274 | 66 | } |
275 | 3.04k | if (nf_service->selection_conditions) { |
276 | 66 | OpenAPI_selection_conditions_free(nf_service->selection_conditions); |
277 | 66 | nf_service->selection_conditions = NULL; |
278 | 66 | } |
279 | 3.04k | if (nf_service->shared_service_data_id) { |
280 | 66 | ogs_free(nf_service->shared_service_data_id); |
281 | 66 | nf_service->shared_service_data_id = NULL; |
282 | 66 | } |
283 | 3.04k | if (nf_service->shutdown_time) { |
284 | 66 | ogs_free(nf_service->shutdown_time); |
285 | 66 | nf_service->shutdown_time = NULL; |
286 | 66 | } |
287 | 3.04k | ogs_free(nf_service); |
288 | 3.04k | } |
289 | | |
290 | | cJSON *OpenAPI_nf_service_convertToJSON(OpenAPI_nf_service_t *nf_service) |
291 | 0 | { |
292 | 0 | cJSON *item = NULL; |
293 | 0 | OpenAPI_lnode_t *node = NULL; |
294 | |
|
295 | 0 | if (nf_service == NULL) { |
296 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [NFService]"); |
297 | 0 | return NULL; |
298 | 0 | } |
299 | | |
300 | 0 | item = cJSON_CreateObject(); |
301 | 0 | if (!nf_service->service_instance_id) { |
302 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [service_instance_id]"); |
303 | 0 | return NULL; |
304 | 0 | } |
305 | 0 | if (cJSON_AddStringToObject(item, "serviceInstanceId", nf_service->service_instance_id) == NULL) { |
306 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [service_instance_id]"); |
307 | 0 | goto end; |
308 | 0 | } |
309 | | |
310 | 0 | if (nf_service->service_name == OpenAPI_service_name_NULL) { |
311 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [service_name]"); |
312 | 0 | return NULL; |
313 | 0 | } |
314 | 0 | if (cJSON_AddStringToObject(item, "serviceName", OpenAPI_service_name_ToString(nf_service->service_name)) == NULL) { |
315 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [service_name]"); |
316 | 0 | goto end; |
317 | 0 | } |
318 | | |
319 | 0 | if (!nf_service->versions) { |
320 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [versions]"); |
321 | 0 | return NULL; |
322 | 0 | } |
323 | 0 | cJSON *versionsList = cJSON_AddArrayToObject(item, "versions"); |
324 | 0 | if (versionsList == NULL) { |
325 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [versions]"); |
326 | 0 | goto end; |
327 | 0 | } |
328 | 0 | OpenAPI_list_for_each(nf_service->versions, node) { |
329 | 0 | cJSON *itemLocal = OpenAPI_nf_service_version_convertToJSON(node->data); |
330 | 0 | if (itemLocal == NULL) { |
331 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [versions]"); |
332 | 0 | goto end; |
333 | 0 | } |
334 | 0 | cJSON_AddItemToArray(versionsList, itemLocal); |
335 | 0 | } |
336 | | |
337 | 0 | if (nf_service->scheme == OpenAPI_uri_scheme_NULL) { |
338 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [scheme]"); |
339 | 0 | return NULL; |
340 | 0 | } |
341 | 0 | if (cJSON_AddStringToObject(item, "scheme", OpenAPI_uri_scheme_ToString(nf_service->scheme)) == NULL) { |
342 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [scheme]"); |
343 | 0 | goto end; |
344 | 0 | } |
345 | | |
346 | 0 | if (nf_service->nf_service_status == OpenAPI_nf_service_status_NULL) { |
347 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [nf_service_status]"); |
348 | 0 | return NULL; |
349 | 0 | } |
350 | 0 | if (cJSON_AddStringToObject(item, "nfServiceStatus", OpenAPI_nf_service_status_ToString(nf_service->nf_service_status)) == NULL) { |
351 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [nf_service_status]"); |
352 | 0 | goto end; |
353 | 0 | } |
354 | | |
355 | 0 | if (nf_service->fqdn) { |
356 | 0 | if (cJSON_AddStringToObject(item, "fqdn", nf_service->fqdn) == NULL) { |
357 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [fqdn]"); |
358 | 0 | goto end; |
359 | 0 | } |
360 | 0 | } |
361 | | |
362 | 0 | if (nf_service->inter_plmn_fqdn) { |
363 | 0 | if (cJSON_AddStringToObject(item, "interPlmnFqdn", nf_service->inter_plmn_fqdn) == NULL) { |
364 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [inter_plmn_fqdn]"); |
365 | 0 | goto end; |
366 | 0 | } |
367 | 0 | } |
368 | | |
369 | 0 | if (nf_service->ip_end_points) { |
370 | 0 | cJSON *ip_end_pointsList = cJSON_AddArrayToObject(item, "ipEndPoints"); |
371 | 0 | if (ip_end_pointsList == NULL) { |
372 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [ip_end_points]"); |
373 | 0 | goto end; |
374 | 0 | } |
375 | 0 | OpenAPI_list_for_each(nf_service->ip_end_points, node) { |
376 | 0 | cJSON *itemLocal = OpenAPI_ip_end_point_convertToJSON(node->data); |
377 | 0 | if (itemLocal == NULL) { |
378 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [ip_end_points]"); |
379 | 0 | goto end; |
380 | 0 | } |
381 | 0 | cJSON_AddItemToArray(ip_end_pointsList, itemLocal); |
382 | 0 | } |
383 | 0 | } |
384 | | |
385 | 0 | if (nf_service->api_prefix) { |
386 | 0 | if (cJSON_AddStringToObject(item, "apiPrefix", nf_service->api_prefix) == NULL) { |
387 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [api_prefix]"); |
388 | 0 | goto end; |
389 | 0 | } |
390 | 0 | } |
391 | | |
392 | 0 | if (nf_service->callback_uri_prefix_list) { |
393 | 0 | cJSON *callback_uri_prefix_listList = cJSON_AddArrayToObject(item, "callbackUriPrefixList"); |
394 | 0 | if (callback_uri_prefix_listList == NULL) { |
395 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [callback_uri_prefix_list]"); |
396 | 0 | goto end; |
397 | 0 | } |
398 | 0 | OpenAPI_list_for_each(nf_service->callback_uri_prefix_list, node) { |
399 | 0 | cJSON *itemLocal = OpenAPI_callback_uri_prefix_item_convertToJSON(node->data); |
400 | 0 | if (itemLocal == NULL) { |
401 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [callback_uri_prefix_list]"); |
402 | 0 | goto end; |
403 | 0 | } |
404 | 0 | cJSON_AddItemToArray(callback_uri_prefix_listList, itemLocal); |
405 | 0 | } |
406 | 0 | } |
407 | | |
408 | 0 | if (nf_service->default_notification_subscriptions) { |
409 | 0 | cJSON *default_notification_subscriptionsList = cJSON_AddArrayToObject(item, "defaultNotificationSubscriptions"); |
410 | 0 | if (default_notification_subscriptionsList == NULL) { |
411 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [default_notification_subscriptions]"); |
412 | 0 | goto end; |
413 | 0 | } |
414 | 0 | OpenAPI_list_for_each(nf_service->default_notification_subscriptions, node) { |
415 | 0 | cJSON *itemLocal = OpenAPI_default_notification_subscription_convertToJSON(node->data); |
416 | 0 | if (itemLocal == NULL) { |
417 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [default_notification_subscriptions]"); |
418 | 0 | goto end; |
419 | 0 | } |
420 | 0 | cJSON_AddItemToArray(default_notification_subscriptionsList, itemLocal); |
421 | 0 | } |
422 | 0 | } |
423 | | |
424 | 0 | if (nf_service->allowed_plmns) { |
425 | 0 | cJSON *allowed_plmnsList = cJSON_AddArrayToObject(item, "allowedPlmns"); |
426 | 0 | if (allowed_plmnsList == NULL) { |
427 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_plmns]"); |
428 | 0 | goto end; |
429 | 0 | } |
430 | 0 | OpenAPI_list_for_each(nf_service->allowed_plmns, node) { |
431 | 0 | cJSON *itemLocal = OpenAPI_plmn_id_convertToJSON(node->data); |
432 | 0 | if (itemLocal == NULL) { |
433 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_plmns]"); |
434 | 0 | goto end; |
435 | 0 | } |
436 | 0 | cJSON_AddItemToArray(allowed_plmnsList, itemLocal); |
437 | 0 | } |
438 | 0 | } |
439 | | |
440 | 0 | if (nf_service->allowed_snpns) { |
441 | 0 | cJSON *allowed_snpnsList = cJSON_AddArrayToObject(item, "allowedSnpns"); |
442 | 0 | if (allowed_snpnsList == NULL) { |
443 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_snpns]"); |
444 | 0 | goto end; |
445 | 0 | } |
446 | 0 | OpenAPI_list_for_each(nf_service->allowed_snpns, node) { |
447 | 0 | cJSON *itemLocal = OpenAPI_plmn_id_nid_convertToJSON(node->data); |
448 | 0 | if (itemLocal == NULL) { |
449 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_snpns]"); |
450 | 0 | goto end; |
451 | 0 | } |
452 | 0 | cJSON_AddItemToArray(allowed_snpnsList, itemLocal); |
453 | 0 | } |
454 | 0 | } |
455 | | |
456 | 0 | if (nf_service->allowed_nf_types != OpenAPI_nf_type_NULL) { |
457 | 0 | cJSON *allowed_nf_typesList = cJSON_AddArrayToObject(item, "allowedNfTypes"); |
458 | 0 | if (allowed_nf_typesList == NULL) { |
459 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_nf_types]"); |
460 | 0 | goto end; |
461 | 0 | } |
462 | 0 | OpenAPI_list_for_each(nf_service->allowed_nf_types, node) { |
463 | 0 | if (cJSON_AddStringToObject(allowed_nf_typesList, "", OpenAPI_nf_type_ToString((intptr_t)node->data)) == NULL) { |
464 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_nf_types]"); |
465 | 0 | goto end; |
466 | 0 | } |
467 | 0 | } |
468 | 0 | } |
469 | | |
470 | 0 | if (nf_service->allowed_nf_domains) { |
471 | 0 | cJSON *allowed_nf_domainsList = cJSON_AddArrayToObject(item, "allowedNfDomains"); |
472 | 0 | if (allowed_nf_domainsList == NULL) { |
473 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_nf_domains]"); |
474 | 0 | goto end; |
475 | 0 | } |
476 | 0 | OpenAPI_list_for_each(nf_service->allowed_nf_domains, node) { |
477 | 0 | if (cJSON_AddStringToObject(allowed_nf_domainsList, "", (char*)node->data) == NULL) { |
478 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_nf_domains]"); |
479 | 0 | goto end; |
480 | 0 | } |
481 | 0 | } |
482 | 0 | } |
483 | | |
484 | 0 | if (nf_service->allowed_nssais) { |
485 | 0 | cJSON *allowed_nssaisList = cJSON_AddArrayToObject(item, "allowedNssais"); |
486 | 0 | if (allowed_nssaisList == NULL) { |
487 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_nssais]"); |
488 | 0 | goto end; |
489 | 0 | } |
490 | 0 | OpenAPI_list_for_each(nf_service->allowed_nssais, node) { |
491 | 0 | cJSON *itemLocal = OpenAPI_ext_snssai_convertToJSON(node->data); |
492 | 0 | if (itemLocal == NULL) { |
493 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_nssais]"); |
494 | 0 | goto end; |
495 | 0 | } |
496 | 0 | cJSON_AddItemToArray(allowed_nssaisList, itemLocal); |
497 | 0 | } |
498 | 0 | } |
499 | | |
500 | 0 | if (nf_service->allowed_operations_per_nf_type) { |
501 | 0 | cJSON *allowed_operations_per_nf_type = cJSON_AddObjectToObject(item, "allowedOperationsPerNfType"); |
502 | 0 | if (allowed_operations_per_nf_type == NULL) { |
503 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_operations_per_nf_type]"); |
504 | 0 | goto end; |
505 | 0 | } |
506 | 0 | cJSON *localMapObject = allowed_operations_per_nf_type; |
507 | 0 | if (nf_service->allowed_operations_per_nf_type) { |
508 | 0 | OpenAPI_list_for_each(nf_service->allowed_operations_per_nf_type, node) { |
509 | 0 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
510 | 0 | if (localKeyValue == NULL) { |
511 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_operations_per_nf_type]"); |
512 | 0 | goto end; |
513 | 0 | } |
514 | 0 | if (localKeyValue->key == NULL) { |
515 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_operations_per_nf_type]"); |
516 | 0 | goto end; |
517 | 0 | } |
518 | 0 | } |
519 | 0 | } |
520 | 0 | } |
521 | | |
522 | 0 | if (nf_service->allowed_operations_per_nf_instance) { |
523 | 0 | cJSON *allowed_operations_per_nf_instance = cJSON_AddObjectToObject(item, "allowedOperationsPerNfInstance"); |
524 | 0 | if (allowed_operations_per_nf_instance == NULL) { |
525 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_operations_per_nf_instance]"); |
526 | 0 | goto end; |
527 | 0 | } |
528 | 0 | cJSON *localMapObject = allowed_operations_per_nf_instance; |
529 | 0 | if (nf_service->allowed_operations_per_nf_instance) { |
530 | 0 | OpenAPI_list_for_each(nf_service->allowed_operations_per_nf_instance, node) { |
531 | 0 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
532 | 0 | if (localKeyValue == NULL) { |
533 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_operations_per_nf_instance]"); |
534 | 0 | goto end; |
535 | 0 | } |
536 | 0 | if (localKeyValue->key == NULL) { |
537 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_operations_per_nf_instance]"); |
538 | 0 | goto end; |
539 | 0 | } |
540 | 0 | } |
541 | 0 | } |
542 | 0 | } |
543 | | |
544 | 0 | if (nf_service->is_allowed_operations_per_nf_instance_overrides) { |
545 | 0 | if (cJSON_AddBoolToObject(item, "allowedOperationsPerNfInstanceOverrides", nf_service->allowed_operations_per_nf_instance_overrides) == NULL) { |
546 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_operations_per_nf_instance_overrides]"); |
547 | 0 | goto end; |
548 | 0 | } |
549 | 0 | } |
550 | | |
551 | 0 | if (nf_service->allowed_scopes_rule_set) { |
552 | 0 | cJSON *allowed_scopes_rule_set = cJSON_AddObjectToObject(item, "allowedScopesRuleSet"); |
553 | 0 | if (allowed_scopes_rule_set == NULL) { |
554 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_scopes_rule_set]"); |
555 | 0 | goto end; |
556 | 0 | } |
557 | 0 | cJSON *localMapObject = allowed_scopes_rule_set; |
558 | 0 | if (nf_service->allowed_scopes_rule_set) { |
559 | 0 | OpenAPI_list_for_each(nf_service->allowed_scopes_rule_set, node) { |
560 | 0 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
561 | 0 | if (localKeyValue == NULL) { |
562 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_scopes_rule_set]"); |
563 | 0 | goto end; |
564 | 0 | } |
565 | 0 | if (localKeyValue->key == NULL) { |
566 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [allowed_scopes_rule_set]"); |
567 | 0 | goto end; |
568 | 0 | } |
569 | 0 | cJSON *itemLocal = localKeyValue->value ? |
570 | 0 | OpenAPI_rule_set_convertToJSON(localKeyValue->value) : |
571 | 0 | cJSON_CreateNull(); |
572 | 0 | if (itemLocal == NULL) { |
573 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [inner]"); |
574 | 0 | goto end; |
575 | 0 | } |
576 | 0 | cJSON_AddItemToObject(localMapObject, localKeyValue->key, itemLocal); |
577 | 0 | } |
578 | 0 | } |
579 | 0 | } |
580 | | |
581 | 0 | if (nf_service->is_priority) { |
582 | 0 | if (cJSON_AddNumberToObject(item, "priority", nf_service->priority) == NULL) { |
583 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [priority]"); |
584 | 0 | goto end; |
585 | 0 | } |
586 | 0 | } |
587 | | |
588 | 0 | if (nf_service->is_capacity) { |
589 | 0 | if (cJSON_AddNumberToObject(item, "capacity", nf_service->capacity) == NULL) { |
590 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [capacity]"); |
591 | 0 | goto end; |
592 | 0 | } |
593 | 0 | } |
594 | | |
595 | 0 | if (nf_service->is_load) { |
596 | 0 | if (cJSON_AddNumberToObject(item, "load", nf_service->load) == NULL) { |
597 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [load]"); |
598 | 0 | goto end; |
599 | 0 | } |
600 | 0 | } |
601 | | |
602 | 0 | if (nf_service->load_time_stamp) { |
603 | 0 | if (cJSON_AddStringToObject(item, "loadTimeStamp", nf_service->load_time_stamp) == NULL) { |
604 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [load_time_stamp]"); |
605 | 0 | goto end; |
606 | 0 | } |
607 | 0 | } |
608 | | |
609 | 0 | if (nf_service->recovery_time) { |
610 | 0 | if (cJSON_AddStringToObject(item, "recoveryTime", nf_service->recovery_time) == NULL) { |
611 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [recovery_time]"); |
612 | 0 | goto end; |
613 | 0 | } |
614 | 0 | } |
615 | | |
616 | 0 | if (nf_service->supported_features) { |
617 | 0 | if (cJSON_AddStringToObject(item, "supportedFeatures", nf_service->supported_features) == NULL) { |
618 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [supported_features]"); |
619 | 0 | goto end; |
620 | 0 | } |
621 | 0 | } |
622 | | |
623 | 0 | if (nf_service->nf_service_set_id_list) { |
624 | 0 | cJSON *nf_service_set_id_listList = cJSON_AddArrayToObject(item, "nfServiceSetIdList"); |
625 | 0 | if (nf_service_set_id_listList == NULL) { |
626 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [nf_service_set_id_list]"); |
627 | 0 | goto end; |
628 | 0 | } |
629 | 0 | OpenAPI_list_for_each(nf_service->nf_service_set_id_list, node) { |
630 | 0 | if (cJSON_AddStringToObject(nf_service_set_id_listList, "", (char*)node->data) == NULL) { |
631 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [nf_service_set_id_list]"); |
632 | 0 | goto end; |
633 | 0 | } |
634 | 0 | } |
635 | 0 | } |
636 | | |
637 | 0 | if (nf_service->s_nssais) { |
638 | 0 | cJSON *s_nssaisList = cJSON_AddArrayToObject(item, "sNssais"); |
639 | 0 | if (s_nssaisList == NULL) { |
640 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [s_nssais]"); |
641 | 0 | goto end; |
642 | 0 | } |
643 | 0 | OpenAPI_list_for_each(nf_service->s_nssais, node) { |
644 | 0 | cJSON *itemLocal = OpenAPI_ext_snssai_convertToJSON(node->data); |
645 | 0 | if (itemLocal == NULL) { |
646 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [s_nssais]"); |
647 | 0 | goto end; |
648 | 0 | } |
649 | 0 | cJSON_AddItemToArray(s_nssaisList, itemLocal); |
650 | 0 | } |
651 | 0 | } |
652 | | |
653 | 0 | if (nf_service->per_plmn_snssai_list) { |
654 | 0 | cJSON *per_plmn_snssai_listList = cJSON_AddArrayToObject(item, "perPlmnSnssaiList"); |
655 | 0 | if (per_plmn_snssai_listList == NULL) { |
656 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [per_plmn_snssai_list]"); |
657 | 0 | goto end; |
658 | 0 | } |
659 | 0 | OpenAPI_list_for_each(nf_service->per_plmn_snssai_list, node) { |
660 | 0 | cJSON *itemLocal = OpenAPI_plmn_snssai_convertToJSON(node->data); |
661 | 0 | if (itemLocal == NULL) { |
662 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [per_plmn_snssai_list]"); |
663 | 0 | goto end; |
664 | 0 | } |
665 | 0 | cJSON_AddItemToArray(per_plmn_snssai_listList, itemLocal); |
666 | 0 | } |
667 | 0 | } |
668 | | |
669 | 0 | if (nf_service->vendor_id) { |
670 | 0 | if (cJSON_AddStringToObject(item, "vendorId", nf_service->vendor_id) == NULL) { |
671 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [vendor_id]"); |
672 | 0 | goto end; |
673 | 0 | } |
674 | 0 | } |
675 | | |
676 | 0 | if (nf_service->supported_vendor_specific_features) { |
677 | 0 | cJSON *supported_vendor_specific_features = cJSON_AddObjectToObject(item, "supportedVendorSpecificFeatures"); |
678 | 0 | if (supported_vendor_specific_features == NULL) { |
679 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [supported_vendor_specific_features]"); |
680 | 0 | goto end; |
681 | 0 | } |
682 | 0 | cJSON *localMapObject = supported_vendor_specific_features; |
683 | 0 | if (nf_service->supported_vendor_specific_features) { |
684 | 0 | OpenAPI_list_for_each(nf_service->supported_vendor_specific_features, node) { |
685 | 0 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
686 | 0 | if (localKeyValue == NULL) { |
687 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [supported_vendor_specific_features]"); |
688 | 0 | goto end; |
689 | 0 | } |
690 | 0 | if (localKeyValue->key == NULL) { |
691 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [supported_vendor_specific_features]"); |
692 | 0 | goto end; |
693 | 0 | } |
694 | 0 | cJSON *itemLocal = localKeyValue->value ? |
695 | 0 | OpenAPI_vendor_specific_feature_convertToJSON(localKeyValue->value) : |
696 | 0 | cJSON_CreateNull(); |
697 | 0 | if (itemLocal == NULL) { |
698 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [inner]"); |
699 | 0 | goto end; |
700 | 0 | } |
701 | 0 | cJSON_AddItemToObject(localMapObject, localKeyValue->key, itemLocal); |
702 | 0 | } |
703 | 0 | } |
704 | 0 | } |
705 | | |
706 | 0 | if (nf_service->is_oauth2_required) { |
707 | 0 | if (cJSON_AddBoolToObject(item, "oauth2Required", nf_service->oauth2_required) == NULL) { |
708 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [oauth2_required]"); |
709 | 0 | goto end; |
710 | 0 | } |
711 | 0 | } |
712 | | |
713 | 0 | if (nf_service->per_plmn_oauth2_req_list) { |
714 | 0 | cJSON *per_plmn_oauth2_req_list_local_JSON = OpenAPI_plmn_oauth2_convertToJSON(nf_service->per_plmn_oauth2_req_list); |
715 | 0 | if (per_plmn_oauth2_req_list_local_JSON == NULL) { |
716 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [per_plmn_oauth2_req_list]"); |
717 | 0 | goto end; |
718 | 0 | } |
719 | 0 | cJSON_AddItemToObject(item, "perPlmnOauth2ReqList", per_plmn_oauth2_req_list_local_JSON); |
720 | 0 | if (item->child == NULL) { |
721 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [per_plmn_oauth2_req_list]"); |
722 | 0 | goto end; |
723 | 0 | } |
724 | 0 | } |
725 | | |
726 | 0 | if (nf_service->selection_conditions) { |
727 | 0 | cJSON *selection_conditions_local_JSON = OpenAPI_selection_conditions_convertToJSON(nf_service->selection_conditions); |
728 | 0 | if (selection_conditions_local_JSON == NULL) { |
729 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [selection_conditions]"); |
730 | 0 | goto end; |
731 | 0 | } |
732 | 0 | cJSON_AddItemToObject(item, "selectionConditions", selection_conditions_local_JSON); |
733 | 0 | if (item->child == NULL) { |
734 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [selection_conditions]"); |
735 | 0 | goto end; |
736 | 0 | } |
737 | 0 | } |
738 | | |
739 | 0 | if (nf_service->is_canary_release) { |
740 | 0 | if (cJSON_AddBoolToObject(item, "canaryRelease", nf_service->canary_release) == NULL) { |
741 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [canary_release]"); |
742 | 0 | goto end; |
743 | 0 | } |
744 | 0 | } |
745 | | |
746 | 0 | if (nf_service->is_exclusive_canary_release_selection) { |
747 | 0 | if (cJSON_AddBoolToObject(item, "exclusiveCanaryReleaseSelection", nf_service->exclusive_canary_release_selection) == NULL) { |
748 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [exclusive_canary_release_selection]"); |
749 | 0 | goto end; |
750 | 0 | } |
751 | 0 | } |
752 | | |
753 | 0 | if (nf_service->shared_service_data_id) { |
754 | 0 | if (cJSON_AddStringToObject(item, "sharedServiceDataId", nf_service->shared_service_data_id) == NULL) { |
755 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [shared_service_data_id]"); |
756 | 0 | goto end; |
757 | 0 | } |
758 | 0 | } |
759 | | |
760 | 0 | if (nf_service->shutdown_time) { |
761 | 0 | if (cJSON_AddStringToObject(item, "shutdownTime", nf_service->shutdown_time) == NULL) { |
762 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [shutdown_time]"); |
763 | 0 | goto end; |
764 | 0 | } |
765 | 0 | } |
766 | | |
767 | 0 | if (nf_service->is_canary_precedence_over_preferred) { |
768 | 0 | if (cJSON_AddBoolToObject(item, "canaryPrecedenceOverPreferred", nf_service->canary_precedence_over_preferred) == NULL) { |
769 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed [canary_precedence_over_preferred]"); |
770 | 0 | goto end; |
771 | 0 | } |
772 | 0 | } |
773 | | |
774 | 0 | end: |
775 | 0 | return item; |
776 | 0 | } |
777 | | |
778 | | OpenAPI_nf_service_t *OpenAPI_nf_service_parseFromJSON(cJSON *nf_serviceJSON) |
779 | 4.57k | { |
780 | 4.57k | OpenAPI_nf_service_t *nf_service_local_var = NULL; |
781 | 4.57k | OpenAPI_lnode_t *node = NULL; |
782 | 4.57k | cJSON *service_instance_id = NULL; |
783 | 4.57k | cJSON *service_name = NULL; |
784 | 4.57k | OpenAPI_service_name_e service_nameVariable = 0; |
785 | 4.57k | cJSON *versions = NULL; |
786 | 4.57k | OpenAPI_list_t *versionsList = NULL; |
787 | 4.57k | cJSON *scheme = NULL; |
788 | 4.57k | OpenAPI_uri_scheme_e schemeVariable = 0; |
789 | 4.57k | cJSON *nf_service_status = NULL; |
790 | 4.57k | OpenAPI_nf_service_status_e nf_service_statusVariable = 0; |
791 | 4.57k | cJSON *fqdn = NULL; |
792 | 4.57k | cJSON *inter_plmn_fqdn = NULL; |
793 | 4.57k | cJSON *ip_end_points = NULL; |
794 | 4.57k | OpenAPI_list_t *ip_end_pointsList = NULL; |
795 | 4.57k | cJSON *api_prefix = NULL; |
796 | 4.57k | cJSON *callback_uri_prefix_list = NULL; |
797 | 4.57k | OpenAPI_list_t *callback_uri_prefix_listList = NULL; |
798 | 4.57k | cJSON *default_notification_subscriptions = NULL; |
799 | 4.57k | OpenAPI_list_t *default_notification_subscriptionsList = NULL; |
800 | 4.57k | cJSON *allowed_plmns = NULL; |
801 | 4.57k | OpenAPI_list_t *allowed_plmnsList = NULL; |
802 | 4.57k | cJSON *allowed_snpns = NULL; |
803 | 4.57k | OpenAPI_list_t *allowed_snpnsList = NULL; |
804 | 4.57k | cJSON *allowed_nf_types = NULL; |
805 | 4.57k | OpenAPI_list_t *allowed_nf_typesList = NULL; |
806 | 4.57k | cJSON *allowed_nf_domains = NULL; |
807 | 4.57k | OpenAPI_list_t *allowed_nf_domainsList = NULL; |
808 | 4.57k | cJSON *allowed_nssais = NULL; |
809 | 4.57k | OpenAPI_list_t *allowed_nssaisList = NULL; |
810 | 4.57k | cJSON *allowed_operations_per_nf_type = NULL; |
811 | 4.57k | OpenAPI_list_t *allowed_operations_per_nf_typeList = NULL; |
812 | 4.57k | cJSON *allowed_operations_per_nf_instance = NULL; |
813 | 4.57k | OpenAPI_list_t *allowed_operations_per_nf_instanceList = NULL; |
814 | 4.57k | cJSON *allowed_operations_per_nf_instance_overrides = NULL; |
815 | 4.57k | cJSON *allowed_scopes_rule_set = NULL; |
816 | 4.57k | OpenAPI_list_t *allowed_scopes_rule_setList = NULL; |
817 | 4.57k | cJSON *priority = NULL; |
818 | 4.57k | cJSON *capacity = NULL; |
819 | 4.57k | cJSON *load = NULL; |
820 | 4.57k | cJSON *load_time_stamp = NULL; |
821 | 4.57k | cJSON *recovery_time = NULL; |
822 | 4.57k | cJSON *supported_features = NULL; |
823 | 4.57k | cJSON *nf_service_set_id_list = NULL; |
824 | 4.57k | OpenAPI_list_t *nf_service_set_id_listList = NULL; |
825 | 4.57k | cJSON *s_nssais = NULL; |
826 | 4.57k | OpenAPI_list_t *s_nssaisList = NULL; |
827 | 4.57k | cJSON *per_plmn_snssai_list = NULL; |
828 | 4.57k | OpenAPI_list_t *per_plmn_snssai_listList = NULL; |
829 | 4.57k | cJSON *vendor_id = NULL; |
830 | 4.57k | cJSON *supported_vendor_specific_features = NULL; |
831 | 4.57k | OpenAPI_list_t *supported_vendor_specific_featuresList = NULL; |
832 | 4.57k | cJSON *oauth2_required = NULL; |
833 | 4.57k | cJSON *per_plmn_oauth2_req_list = NULL; |
834 | 4.57k | OpenAPI_plmn_oauth2_t *per_plmn_oauth2_req_list_local_nonprim = NULL; |
835 | 4.57k | cJSON *selection_conditions = NULL; |
836 | 4.57k | OpenAPI_selection_conditions_t *selection_conditions_local_nonprim = NULL; |
837 | 4.57k | cJSON *canary_release = NULL; |
838 | 4.57k | cJSON *exclusive_canary_release_selection = NULL; |
839 | 4.57k | cJSON *shared_service_data_id = NULL; |
840 | 4.57k | cJSON *shutdown_time = NULL; |
841 | 4.57k | cJSON *canary_precedence_over_preferred = NULL; |
842 | 4.57k | service_instance_id = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "serviceInstanceId"); |
843 | 4.57k | if (!service_instance_id) { |
844 | 734 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [service_instance_id]"); |
845 | 734 | goto end; |
846 | 734 | } |
847 | 3.83k | if (!cJSON_IsString(service_instance_id)) { |
848 | 194 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [service_instance_id]"); |
849 | 194 | goto end; |
850 | 194 | } |
851 | | |
852 | 3.64k | service_name = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "serviceName"); |
853 | 3.64k | if (!service_name) { |
854 | 104 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [service_name]"); |
855 | 104 | goto end; |
856 | 104 | } |
857 | 3.54k | if (!cJSON_IsString(service_name)) { |
858 | 66 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [service_name]"); |
859 | 66 | goto end; |
860 | 66 | } |
861 | 3.47k | service_nameVariable = OpenAPI_service_name_FromString(service_name->valuestring); |
862 | | |
863 | 3.47k | versions = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "versions"); |
864 | 3.47k | if (!versions) { |
865 | 186 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [versions]"); |
866 | 186 | goto end; |
867 | 186 | } |
868 | 3.28k | cJSON *versions_local = NULL; |
869 | 3.28k | if (!cJSON_IsArray(versions)) { |
870 | 68 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [versions]"); |
871 | 68 | goto end; |
872 | 68 | } |
873 | | |
874 | 3.22k | versionsList = OpenAPI_list_create(); |
875 | | |
876 | 3.22k | cJSON_ArrayForEach(versions_local, versions) { |
877 | 127 | if (!cJSON_IsObject(versions_local)) { |
878 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [versions]"); |
879 | 1 | goto end; |
880 | 1 | } |
881 | 126 | OpenAPI_nf_service_version_t *versionsItem = OpenAPI_nf_service_version_parseFromJSON(versions_local); |
882 | 126 | if (!versionsItem) { |
883 | 10 | ogs_error("No versionsItem"); |
884 | 10 | goto end; |
885 | 10 | } |
886 | 116 | OpenAPI_list_add(versionsList, versionsItem); |
887 | 116 | } |
888 | | |
889 | 3.21k | scheme = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "scheme"); |
890 | 3.21k | if (!scheme) { |
891 | 8 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [scheme]"); |
892 | 8 | goto end; |
893 | 8 | } |
894 | 3.20k | if (!cJSON_IsString(scheme)) { |
895 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [scheme]"); |
896 | 1 | goto end; |
897 | 1 | } |
898 | 3.20k | schemeVariable = OpenAPI_uri_scheme_FromString(scheme->valuestring); |
899 | | |
900 | 3.20k | nf_service_status = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "nfServiceStatus"); |
901 | 3.20k | if (!nf_service_status) { |
902 | 16 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [nf_service_status]"); |
903 | 16 | goto end; |
904 | 16 | } |
905 | 3.18k | if (!cJSON_IsString(nf_service_status)) { |
906 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [nf_service_status]"); |
907 | 1 | goto end; |
908 | 1 | } |
909 | 3.18k | nf_service_statusVariable = OpenAPI_nf_service_status_FromString(nf_service_status->valuestring); |
910 | | |
911 | 3.18k | fqdn = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "fqdn"); |
912 | 3.18k | if (fqdn) { |
913 | 3 | if (!cJSON_IsString(fqdn) && !cJSON_IsNull(fqdn)) { |
914 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [fqdn]"); |
915 | 1 | goto end; |
916 | 1 | } |
917 | 3 | } |
918 | | |
919 | 3.18k | inter_plmn_fqdn = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "interPlmnFqdn"); |
920 | 3.18k | if (inter_plmn_fqdn) { |
921 | 68 | if (!cJSON_IsString(inter_plmn_fqdn) && !cJSON_IsNull(inter_plmn_fqdn)) { |
922 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [inter_plmn_fqdn]"); |
923 | 1 | goto end; |
924 | 1 | } |
925 | 68 | } |
926 | | |
927 | 3.18k | ip_end_points = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "ipEndPoints"); |
928 | 3.18k | if (ip_end_points) { |
929 | 189 | cJSON *ip_end_points_local = NULL; |
930 | 189 | if (!cJSON_IsArray(ip_end_points)) { |
931 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [ip_end_points]"); |
932 | 1 | goto end; |
933 | 1 | } |
934 | | |
935 | 188 | ip_end_pointsList = OpenAPI_list_create(); |
936 | | |
937 | 2.20k | cJSON_ArrayForEach(ip_end_points_local, ip_end_points) { |
938 | 2.20k | if (!cJSON_IsObject(ip_end_points_local)) { |
939 | 11 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [ip_end_points]"); |
940 | 11 | goto end; |
941 | 11 | } |
942 | 2.19k | OpenAPI_ip_end_point_t *ip_end_pointsItem = OpenAPI_ip_end_point_parseFromJSON(ip_end_points_local); |
943 | 2.19k | if (!ip_end_pointsItem) { |
944 | 1 | ogs_error("No ip_end_pointsItem"); |
945 | 1 | goto end; |
946 | 1 | } |
947 | 2.19k | OpenAPI_list_add(ip_end_pointsList, ip_end_pointsItem); |
948 | 2.19k | } |
949 | 188 | } |
950 | | |
951 | 3.16k | api_prefix = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "apiPrefix"); |
952 | 3.16k | if (api_prefix) { |
953 | 3 | if (!cJSON_IsString(api_prefix) && !cJSON_IsNull(api_prefix)) { |
954 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [api_prefix]"); |
955 | 1 | goto end; |
956 | 1 | } |
957 | 3 | } |
958 | | |
959 | 3.16k | callback_uri_prefix_list = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "callbackUriPrefixList"); |
960 | 3.16k | if (callback_uri_prefix_list) { |
961 | 4 | cJSON *callback_uri_prefix_list_local = NULL; |
962 | 4 | if (!cJSON_IsArray(callback_uri_prefix_list)) { |
963 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [callback_uri_prefix_list]"); |
964 | 1 | goto end; |
965 | 1 | } |
966 | | |
967 | 3 | callback_uri_prefix_listList = OpenAPI_list_create(); |
968 | | |
969 | 3 | cJSON_ArrayForEach(callback_uri_prefix_list_local, callback_uri_prefix_list) { |
970 | 2 | if (!cJSON_IsObject(callback_uri_prefix_list_local)) { |
971 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [callback_uri_prefix_list]"); |
972 | 1 | goto end; |
973 | 1 | } |
974 | 1 | OpenAPI_callback_uri_prefix_item_t *callback_uri_prefix_listItem = OpenAPI_callback_uri_prefix_item_parseFromJSON(callback_uri_prefix_list_local); |
975 | 1 | if (!callback_uri_prefix_listItem) { |
976 | 1 | ogs_error("No callback_uri_prefix_listItem"); |
977 | 1 | goto end; |
978 | 1 | } |
979 | 0 | OpenAPI_list_add(callback_uri_prefix_listList, callback_uri_prefix_listItem); |
980 | 0 | } |
981 | 3 | } |
982 | | |
983 | 3.16k | default_notification_subscriptions = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "defaultNotificationSubscriptions"); |
984 | 3.16k | if (default_notification_subscriptions) { |
985 | 4 | cJSON *default_notification_subscriptions_local = NULL; |
986 | 4 | if (!cJSON_IsArray(default_notification_subscriptions)) { |
987 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [default_notification_subscriptions]"); |
988 | 1 | goto end; |
989 | 1 | } |
990 | | |
991 | 3 | default_notification_subscriptionsList = OpenAPI_list_create(); |
992 | | |
993 | 3 | cJSON_ArrayForEach(default_notification_subscriptions_local, default_notification_subscriptions) { |
994 | 2 | if (!cJSON_IsObject(default_notification_subscriptions_local)) { |
995 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [default_notification_subscriptions]"); |
996 | 1 | goto end; |
997 | 1 | } |
998 | 1 | OpenAPI_default_notification_subscription_t *default_notification_subscriptionsItem = OpenAPI_default_notification_subscription_parseFromJSON(default_notification_subscriptions_local); |
999 | 1 | if (!default_notification_subscriptionsItem) { |
1000 | 1 | ogs_error("No default_notification_subscriptionsItem"); |
1001 | 1 | goto end; |
1002 | 1 | } |
1003 | 0 | OpenAPI_list_add(default_notification_subscriptionsList, default_notification_subscriptionsItem); |
1004 | 0 | } |
1005 | 3 | } |
1006 | | |
1007 | 3.16k | allowed_plmns = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "allowedPlmns"); |
1008 | 3.16k | if (allowed_plmns) { |
1009 | 22 | cJSON *allowed_plmns_local = NULL; |
1010 | 22 | if (!cJSON_IsArray(allowed_plmns)) { |
1011 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_plmns]"); |
1012 | 1 | goto end; |
1013 | 1 | } |
1014 | | |
1015 | 21 | allowed_plmnsList = OpenAPI_list_create(); |
1016 | | |
1017 | 198 | cJSON_ArrayForEach(allowed_plmns_local, allowed_plmns) { |
1018 | 198 | if (!cJSON_IsObject(allowed_plmns_local)) { |
1019 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_plmns]"); |
1020 | 1 | goto end; |
1021 | 1 | } |
1022 | 197 | OpenAPI_plmn_id_t *allowed_plmnsItem = OpenAPI_plmn_id_parseFromJSON(allowed_plmns_local); |
1023 | 197 | if (!allowed_plmnsItem) { |
1024 | 9 | ogs_error("No allowed_plmnsItem"); |
1025 | 9 | goto end; |
1026 | 9 | } |
1027 | 188 | OpenAPI_list_add(allowed_plmnsList, allowed_plmnsItem); |
1028 | 188 | } |
1029 | 21 | } |
1030 | | |
1031 | 3.15k | allowed_snpns = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "allowedSnpns"); |
1032 | 3.15k | if (allowed_snpns) { |
1033 | 21 | cJSON *allowed_snpns_local = NULL; |
1034 | 21 | if (!cJSON_IsArray(allowed_snpns)) { |
1035 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_snpns]"); |
1036 | 1 | goto end; |
1037 | 1 | } |
1038 | | |
1039 | 20 | allowed_snpnsList = OpenAPI_list_create(); |
1040 | | |
1041 | 167 | cJSON_ArrayForEach(allowed_snpns_local, allowed_snpns) { |
1042 | 167 | if (!cJSON_IsObject(allowed_snpns_local)) { |
1043 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_snpns]"); |
1044 | 1 | goto end; |
1045 | 1 | } |
1046 | 166 | OpenAPI_plmn_id_nid_t *allowed_snpnsItem = OpenAPI_plmn_id_nid_parseFromJSON(allowed_snpns_local); |
1047 | 166 | if (!allowed_snpnsItem) { |
1048 | 10 | ogs_error("No allowed_snpnsItem"); |
1049 | 10 | goto end; |
1050 | 10 | } |
1051 | 156 | OpenAPI_list_add(allowed_snpnsList, allowed_snpnsItem); |
1052 | 156 | } |
1053 | 20 | } |
1054 | | |
1055 | 3.13k | allowed_nf_types = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "allowedNfTypes"); |
1056 | 3.13k | if (allowed_nf_types) { |
1057 | 54 | cJSON *allowed_nf_types_local = NULL; |
1058 | 54 | if (!cJSON_IsArray(allowed_nf_types)) { |
1059 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_nf_types]"); |
1060 | 1 | goto end; |
1061 | 1 | } |
1062 | | |
1063 | 53 | allowed_nf_typesList = OpenAPI_list_create(); |
1064 | | |
1065 | 689 | cJSON_ArrayForEach(allowed_nf_types_local, allowed_nf_types) { |
1066 | 689 | OpenAPI_nf_type_e localEnum = OpenAPI_nf_type_NULL; |
1067 | 689 | if (!cJSON_IsString(allowed_nf_types_local)) { |
1068 | 2 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_nf_types]"); |
1069 | 2 | goto end; |
1070 | 2 | } |
1071 | 687 | localEnum = OpenAPI_nf_type_FromString(allowed_nf_types_local->valuestring); |
1072 | 687 | if (!localEnum) { |
1073 | 456 | ogs_info("Enum value \"%s\" for field \"allowed_nf_types\" is not supported. Ignoring it ...", |
1074 | 456 | allowed_nf_types_local->valuestring); |
1075 | 456 | } else { |
1076 | 231 | OpenAPI_list_add(allowed_nf_typesList, (void *)localEnum); |
1077 | 231 | } |
1078 | 687 | } |
1079 | 51 | if (allowed_nf_typesList->count == 0) { |
1080 | 7 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed: Expected allowed_nf_typesList to not be empty (after ignoring unsupported enum values)."); |
1081 | 7 | goto end; |
1082 | 7 | } |
1083 | 51 | } |
1084 | | |
1085 | 3.12k | allowed_nf_domains = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "allowedNfDomains"); |
1086 | 3.12k | if (allowed_nf_domains) { |
1087 | 153 | cJSON *allowed_nf_domains_local = NULL; |
1088 | 153 | if (!cJSON_IsArray(allowed_nf_domains)) { |
1089 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_nf_domains]"); |
1090 | 1 | goto end; |
1091 | 1 | } |
1092 | | |
1093 | 152 | allowed_nf_domainsList = OpenAPI_list_create(); |
1094 | | |
1095 | 649 | cJSON_ArrayForEach(allowed_nf_domains_local, allowed_nf_domains) { |
1096 | 649 | double *localDouble = NULL; |
1097 | 649 | int *localInt = NULL; |
1098 | 649 | if (!cJSON_IsString(allowed_nf_domains_local)) { |
1099 | 10 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_nf_domains]"); |
1100 | 10 | goto end; |
1101 | 10 | } |
1102 | 639 | OpenAPI_list_add(allowed_nf_domainsList, ogs_strdup(allowed_nf_domains_local->valuestring)); |
1103 | 639 | } |
1104 | 152 | } |
1105 | | |
1106 | 3.11k | allowed_nssais = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "allowedNssais"); |
1107 | 3.11k | if (allowed_nssais) { |
1108 | 158 | cJSON *allowed_nssais_local = NULL; |
1109 | 158 | if (!cJSON_IsArray(allowed_nssais)) { |
1110 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_nssais]"); |
1111 | 1 | goto end; |
1112 | 1 | } |
1113 | | |
1114 | 157 | allowed_nssaisList = OpenAPI_list_create(); |
1115 | | |
1116 | 406 | cJSON_ArrayForEach(allowed_nssais_local, allowed_nssais) { |
1117 | 406 | if (!cJSON_IsObject(allowed_nssais_local)) { |
1118 | 2 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_nssais]"); |
1119 | 2 | goto end; |
1120 | 2 | } |
1121 | 404 | OpenAPI_ext_snssai_t *allowed_nssaisItem = OpenAPI_ext_snssai_parseFromJSON(allowed_nssais_local); |
1122 | 404 | if (!allowed_nssaisItem) { |
1123 | 7 | ogs_error("No allowed_nssaisItem"); |
1124 | 7 | goto end; |
1125 | 7 | } |
1126 | 397 | OpenAPI_list_add(allowed_nssaisList, allowed_nssaisItem); |
1127 | 397 | } |
1128 | 157 | } |
1129 | | |
1130 | 3.10k | allowed_operations_per_nf_type = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "allowedOperationsPerNfType"); |
1131 | 3.10k | if (allowed_operations_per_nf_type) { |
1132 | 4 | cJSON *allowed_operations_per_nf_type_local_map = NULL; |
1133 | 4 | if (!cJSON_IsObject(allowed_operations_per_nf_type) && !cJSON_IsNull(allowed_operations_per_nf_type)) { |
1134 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_operations_per_nf_type]"); |
1135 | 1 | goto end; |
1136 | 1 | } |
1137 | 3 | if (cJSON_IsObject(allowed_operations_per_nf_type)) { |
1138 | 2 | allowed_operations_per_nf_typeList = OpenAPI_list_create(); |
1139 | 2 | OpenAPI_map_t *localMapKeyPair = NULL; |
1140 | 2 | cJSON_ArrayForEach(allowed_operations_per_nf_type_local_map, allowed_operations_per_nf_type) { |
1141 | 0 | cJSON *localMapObject = allowed_operations_per_nf_type_local_map; |
1142 | 0 | double *localDouble = NULL; |
1143 | 0 | int *localInt = NULL; |
1144 | 0 | if (localMapKeyPair == NULL) { |
1145 | 0 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_operations_per_nf_type]"); |
1146 | 0 | goto end; |
1147 | 0 | } |
1148 | 0 | OpenAPI_list_add(allowed_operations_per_nf_typeList, localMapKeyPair); |
1149 | 0 | } |
1150 | 2 | } |
1151 | 3 | } |
1152 | | |
1153 | 3.10k | allowed_operations_per_nf_instance = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "allowedOperationsPerNfInstance"); |
1154 | 3.10k | if (allowed_operations_per_nf_instance) { |
1155 | 4 | cJSON *allowed_operations_per_nf_instance_local_map = NULL; |
1156 | 4 | if (!cJSON_IsObject(allowed_operations_per_nf_instance) && !cJSON_IsNull(allowed_operations_per_nf_instance)) { |
1157 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_operations_per_nf_instance]"); |
1158 | 1 | goto end; |
1159 | 1 | } |
1160 | 3 | if (cJSON_IsObject(allowed_operations_per_nf_instance)) { |
1161 | 2 | allowed_operations_per_nf_instanceList = OpenAPI_list_create(); |
1162 | 2 | OpenAPI_map_t *localMapKeyPair = NULL; |
1163 | 2 | cJSON_ArrayForEach(allowed_operations_per_nf_instance_local_map, allowed_operations_per_nf_instance) { |
1164 | 1 | cJSON *localMapObject = allowed_operations_per_nf_instance_local_map; |
1165 | 1 | double *localDouble = NULL; |
1166 | 1 | int *localInt = NULL; |
1167 | 1 | if (localMapKeyPair == NULL) { |
1168 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_operations_per_nf_instance]"); |
1169 | 1 | goto end; |
1170 | 1 | } |
1171 | 0 | OpenAPI_list_add(allowed_operations_per_nf_instanceList, localMapKeyPair); |
1172 | 0 | } |
1173 | 2 | } |
1174 | 3 | } |
1175 | | |
1176 | 3.10k | allowed_operations_per_nf_instance_overrides = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "allowedOperationsPerNfInstanceOverrides"); |
1177 | 3.10k | if (allowed_operations_per_nf_instance_overrides) { |
1178 | 2 | if (!cJSON_IsBool(allowed_operations_per_nf_instance_overrides)) { |
1179 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_operations_per_nf_instance_overrides]"); |
1180 | 1 | goto end; |
1181 | 1 | } |
1182 | 2 | } |
1183 | | |
1184 | 3.10k | allowed_scopes_rule_set = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "allowedScopesRuleSet"); |
1185 | 3.10k | if (allowed_scopes_rule_set) { |
1186 | 188 | cJSON *allowed_scopes_rule_set_local_map = NULL; |
1187 | 188 | if (!cJSON_IsObject(allowed_scopes_rule_set) && !cJSON_IsNull(allowed_scopes_rule_set)) { |
1188 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_scopes_rule_set]"); |
1189 | 1 | goto end; |
1190 | 1 | } |
1191 | 187 | if (cJSON_IsObject(allowed_scopes_rule_set)) { |
1192 | 186 | allowed_scopes_rule_setList = OpenAPI_list_create(); |
1193 | 186 | OpenAPI_map_t *localMapKeyPair = NULL; |
1194 | 817 | cJSON_ArrayForEach(allowed_scopes_rule_set_local_map, allowed_scopes_rule_set) { |
1195 | 817 | cJSON *localMapObject = allowed_scopes_rule_set_local_map; |
1196 | 817 | if (cJSON_IsObject(localMapObject)) { |
1197 | 403 | localMapKeyPair = OpenAPI_map_create( |
1198 | 403 | ogs_strdup(localMapObject->string), OpenAPI_rule_set_parseFromJSON(localMapObject)); |
1199 | 414 | } else if (cJSON_IsNull(localMapObject)) { |
1200 | 404 | localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), NULL); |
1201 | 404 | } else { |
1202 | 10 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [inner]"); |
1203 | 10 | goto end; |
1204 | 10 | } |
1205 | 807 | if (localMapKeyPair == NULL) { |
1206 | 0 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [allowed_scopes_rule_set]"); |
1207 | 0 | goto end; |
1208 | 0 | } |
1209 | 807 | OpenAPI_list_add(allowed_scopes_rule_setList, localMapKeyPair); |
1210 | 807 | } |
1211 | 186 | } |
1212 | 187 | } |
1213 | | |
1214 | 3.09k | priority = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "priority"); |
1215 | 3.09k | if (priority) { |
1216 | 67 | if (!cJSON_IsNumber(priority)) { |
1217 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [priority]"); |
1218 | 1 | goto end; |
1219 | 1 | } |
1220 | 67 | } |
1221 | | |
1222 | 3.09k | capacity = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "capacity"); |
1223 | 3.09k | if (capacity) { |
1224 | 68 | if (!cJSON_IsNumber(capacity)) { |
1225 | 2 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [capacity]"); |
1226 | 2 | goto end; |
1227 | 2 | } |
1228 | 68 | } |
1229 | | |
1230 | 3.09k | load = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "load"); |
1231 | 3.09k | if (load) { |
1232 | 2 | if (!cJSON_IsNumber(load)) { |
1233 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [load]"); |
1234 | 1 | goto end; |
1235 | 1 | } |
1236 | 2 | } |
1237 | | |
1238 | 3.08k | load_time_stamp = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "loadTimeStamp"); |
1239 | 3.08k | if (load_time_stamp) { |
1240 | 133 | if (!cJSON_IsString(load_time_stamp) && !cJSON_IsNull(load_time_stamp)) { |
1241 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [load_time_stamp]"); |
1242 | 1 | goto end; |
1243 | 1 | } |
1244 | 133 | } |
1245 | | |
1246 | 3.08k | recovery_time = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "recoveryTime"); |
1247 | 3.08k | if (recovery_time) { |
1248 | 133 | if (!cJSON_IsString(recovery_time) && !cJSON_IsNull(recovery_time)) { |
1249 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [recovery_time]"); |
1250 | 1 | goto end; |
1251 | 1 | } |
1252 | 133 | } |
1253 | | |
1254 | 3.08k | supported_features = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "supportedFeatures"); |
1255 | 3.08k | if (supported_features) { |
1256 | 134 | if (!cJSON_IsString(supported_features) && !cJSON_IsNull(supported_features)) { |
1257 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [supported_features]"); |
1258 | 1 | goto end; |
1259 | 1 | } |
1260 | 134 | } |
1261 | | |
1262 | 3.08k | nf_service_set_id_list = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "nfServiceSetIdList"); |
1263 | 3.08k | if (nf_service_set_id_list) { |
1264 | 177 | cJSON *nf_service_set_id_list_local = NULL; |
1265 | 177 | if (!cJSON_IsArray(nf_service_set_id_list)) { |
1266 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [nf_service_set_id_list]"); |
1267 | 1 | goto end; |
1268 | 1 | } |
1269 | | |
1270 | 176 | nf_service_set_id_listList = OpenAPI_list_create(); |
1271 | | |
1272 | 504 | cJSON_ArrayForEach(nf_service_set_id_list_local, nf_service_set_id_list) { |
1273 | 504 | double *localDouble = NULL; |
1274 | 504 | int *localInt = NULL; |
1275 | 504 | if (!cJSON_IsString(nf_service_set_id_list_local)) { |
1276 | 7 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [nf_service_set_id_list]"); |
1277 | 7 | goto end; |
1278 | 7 | } |
1279 | 497 | OpenAPI_list_add(nf_service_set_id_listList, ogs_strdup(nf_service_set_id_list_local->valuestring)); |
1280 | 497 | } |
1281 | 176 | } |
1282 | | |
1283 | 3.07k | s_nssais = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "sNssais"); |
1284 | 3.07k | if (s_nssais) { |
1285 | 119 | cJSON *s_nssais_local = NULL; |
1286 | 119 | if (!cJSON_IsArray(s_nssais)) { |
1287 | 2 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [s_nssais]"); |
1288 | 2 | goto end; |
1289 | 2 | } |
1290 | | |
1291 | 117 | s_nssaisList = OpenAPI_list_create(); |
1292 | | |
1293 | 544 | cJSON_ArrayForEach(s_nssais_local, s_nssais) { |
1294 | 544 | if (!cJSON_IsObject(s_nssais_local)) { |
1295 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [s_nssais]"); |
1296 | 1 | goto end; |
1297 | 1 | } |
1298 | 543 | OpenAPI_ext_snssai_t *s_nssaisItem = OpenAPI_ext_snssai_parseFromJSON(s_nssais_local); |
1299 | 543 | if (!s_nssaisItem) { |
1300 | 9 | ogs_error("No s_nssaisItem"); |
1301 | 9 | goto end; |
1302 | 9 | } |
1303 | 534 | OpenAPI_list_add(s_nssaisList, s_nssaisItem); |
1304 | 534 | } |
1305 | 117 | } |
1306 | | |
1307 | 3.06k | per_plmn_snssai_list = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "perPlmnSnssaiList"); |
1308 | 3.06k | if (per_plmn_snssai_list) { |
1309 | 4 | cJSON *per_plmn_snssai_list_local = NULL; |
1310 | 4 | if (!cJSON_IsArray(per_plmn_snssai_list)) { |
1311 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [per_plmn_snssai_list]"); |
1312 | 1 | goto end; |
1313 | 1 | } |
1314 | | |
1315 | 3 | per_plmn_snssai_listList = OpenAPI_list_create(); |
1316 | | |
1317 | 3 | cJSON_ArrayForEach(per_plmn_snssai_list_local, per_plmn_snssai_list) { |
1318 | 2 | if (!cJSON_IsObject(per_plmn_snssai_list_local)) { |
1319 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [per_plmn_snssai_list]"); |
1320 | 1 | goto end; |
1321 | 1 | } |
1322 | 1 | OpenAPI_plmn_snssai_t *per_plmn_snssai_listItem = OpenAPI_plmn_snssai_parseFromJSON(per_plmn_snssai_list_local); |
1323 | 1 | if (!per_plmn_snssai_listItem) { |
1324 | 1 | ogs_error("No per_plmn_snssai_listItem"); |
1325 | 1 | goto end; |
1326 | 1 | } |
1327 | 0 | OpenAPI_list_add(per_plmn_snssai_listList, per_plmn_snssai_listItem); |
1328 | 0 | } |
1329 | 3 | } |
1330 | | |
1331 | 3.06k | vendor_id = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "vendorId"); |
1332 | 3.06k | if (vendor_id) { |
1333 | 104 | if (!cJSON_IsString(vendor_id) && !cJSON_IsNull(vendor_id)) { |
1334 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [vendor_id]"); |
1335 | 1 | goto end; |
1336 | 1 | } |
1337 | 104 | } |
1338 | | |
1339 | 3.06k | supported_vendor_specific_features = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "supportedVendorSpecificFeatures"); |
1340 | 3.06k | if (supported_vendor_specific_features) { |
1341 | 99 | cJSON *supported_vendor_specific_features_local_map = NULL; |
1342 | 99 | if (!cJSON_IsObject(supported_vendor_specific_features) && !cJSON_IsNull(supported_vendor_specific_features)) { |
1343 | 3 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [supported_vendor_specific_features]"); |
1344 | 3 | goto end; |
1345 | 3 | } |
1346 | 96 | if (cJSON_IsObject(supported_vendor_specific_features)) { |
1347 | 30 | supported_vendor_specific_featuresList = OpenAPI_list_create(); |
1348 | 30 | OpenAPI_map_t *localMapKeyPair = NULL; |
1349 | 880 | cJSON_ArrayForEach(supported_vendor_specific_features_local_map, supported_vendor_specific_features) { |
1350 | 880 | cJSON *localMapObject = supported_vendor_specific_features_local_map; |
1351 | 880 | if (cJSON_IsObject(localMapObject)) { |
1352 | 434 | localMapKeyPair = OpenAPI_map_create( |
1353 | 434 | ogs_strdup(localMapObject->string), OpenAPI_vendor_specific_feature_parseFromJSON(localMapObject)); |
1354 | 446 | } else if (cJSON_IsNull(localMapObject)) { |
1355 | 436 | localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), NULL); |
1356 | 436 | } else { |
1357 | 10 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [inner]"); |
1358 | 10 | goto end; |
1359 | 10 | } |
1360 | 870 | if (localMapKeyPair == NULL) { |
1361 | 0 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [supported_vendor_specific_features]"); |
1362 | 0 | goto end; |
1363 | 0 | } |
1364 | 870 | OpenAPI_list_add(supported_vendor_specific_featuresList, localMapKeyPair); |
1365 | 870 | } |
1366 | 30 | } |
1367 | 96 | } |
1368 | | |
1369 | 3.04k | oauth2_required = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "oauth2Required"); |
1370 | 3.04k | if (oauth2_required) { |
1371 | 1 | if (!cJSON_IsBool(oauth2_required)) { |
1372 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [oauth2_required]"); |
1373 | 1 | goto end; |
1374 | 1 | } |
1375 | 1 | } |
1376 | | |
1377 | 3.04k | per_plmn_oauth2_req_list = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "perPlmnOauth2ReqList"); |
1378 | 3.04k | if (per_plmn_oauth2_req_list) { |
1379 | 67 | per_plmn_oauth2_req_list_local_nonprim = OpenAPI_plmn_oauth2_parseFromJSON(per_plmn_oauth2_req_list); |
1380 | 67 | if (!per_plmn_oauth2_req_list_local_nonprim) { |
1381 | 0 | ogs_error("OpenAPI_plmn_oauth2_parseFromJSON failed [per_plmn_oauth2_req_list]"); |
1382 | 0 | goto end; |
1383 | 0 | } |
1384 | 67 | } |
1385 | | |
1386 | 3.04k | selection_conditions = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "selectionConditions"); |
1387 | 3.04k | if (selection_conditions) { |
1388 | 69 | selection_conditions_local_nonprim = OpenAPI_selection_conditions_parseFromJSON(selection_conditions); |
1389 | 69 | if (!selection_conditions_local_nonprim) { |
1390 | 2 | ogs_error("OpenAPI_selection_conditions_parseFromJSON failed [selection_conditions]"); |
1391 | 2 | goto end; |
1392 | 2 | } |
1393 | 69 | } |
1394 | | |
1395 | 3.04k | canary_release = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "canaryRelease"); |
1396 | 3.04k | if (canary_release) { |
1397 | 1 | if (!cJSON_IsBool(canary_release)) { |
1398 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [canary_release]"); |
1399 | 1 | goto end; |
1400 | 1 | } |
1401 | 1 | } |
1402 | | |
1403 | 3.04k | exclusive_canary_release_selection = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "exclusiveCanaryReleaseSelection"); |
1404 | 3.04k | if (exclusive_canary_release_selection) { |
1405 | 1 | if (!cJSON_IsBool(exclusive_canary_release_selection)) { |
1406 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [exclusive_canary_release_selection]"); |
1407 | 1 | goto end; |
1408 | 1 | } |
1409 | 1 | } |
1410 | | |
1411 | 3.04k | shared_service_data_id = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "sharedServiceDataId"); |
1412 | 3.04k | if (shared_service_data_id) { |
1413 | 69 | if (!cJSON_IsString(shared_service_data_id) && !cJSON_IsNull(shared_service_data_id)) { |
1414 | 2 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [shared_service_data_id]"); |
1415 | 2 | goto end; |
1416 | 2 | } |
1417 | 69 | } |
1418 | | |
1419 | 3.04k | shutdown_time = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "shutdownTime"); |
1420 | 3.04k | if (shutdown_time) { |
1421 | 153 | if (!cJSON_IsString(shutdown_time) && !cJSON_IsNull(shutdown_time)) { |
1422 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [shutdown_time]"); |
1423 | 1 | goto end; |
1424 | 1 | } |
1425 | 153 | } |
1426 | | |
1427 | 3.04k | canary_precedence_over_preferred = cJSON_GetObjectItemCaseSensitive(nf_serviceJSON, "canaryPrecedenceOverPreferred"); |
1428 | 3.04k | if (canary_precedence_over_preferred) { |
1429 | 1 | if (!cJSON_IsBool(canary_precedence_over_preferred)) { |
1430 | 1 | ogs_error("OpenAPI_nf_service_parseFromJSON() failed [canary_precedence_over_preferred]"); |
1431 | 1 | goto end; |
1432 | 1 | } |
1433 | 1 | } |
1434 | | |
1435 | 3.04k | nf_service_local_var = OpenAPI_nf_service_create ( |
1436 | 3.04k | ogs_strdup(service_instance_id->valuestring), |
1437 | 3.04k | service_nameVariable, |
1438 | 3.04k | versionsList, |
1439 | 3.04k | schemeVariable, |
1440 | 3.04k | nf_service_statusVariable, |
1441 | 3.04k | fqdn && !cJSON_IsNull(fqdn) ? ogs_strdup(fqdn->valuestring) : NULL, |
1442 | 3.04k | inter_plmn_fqdn && !cJSON_IsNull(inter_plmn_fqdn) ? ogs_strdup(inter_plmn_fqdn->valuestring) : NULL, |
1443 | 3.04k | ip_end_points ? ip_end_pointsList : NULL, |
1444 | 3.04k | api_prefix && !cJSON_IsNull(api_prefix) ? ogs_strdup(api_prefix->valuestring) : NULL, |
1445 | 3.04k | callback_uri_prefix_list ? callback_uri_prefix_listList : NULL, |
1446 | 3.04k | default_notification_subscriptions ? default_notification_subscriptionsList : NULL, |
1447 | 3.04k | allowed_plmns ? allowed_plmnsList : NULL, |
1448 | 3.04k | allowed_snpns ? allowed_snpnsList : NULL, |
1449 | 3.04k | allowed_nf_types ? allowed_nf_typesList : NULL, |
1450 | 3.04k | allowed_nf_domains ? allowed_nf_domainsList : NULL, |
1451 | 3.04k | allowed_nssais ? allowed_nssaisList : NULL, |
1452 | 3.04k | allowed_operations_per_nf_type ? allowed_operations_per_nf_typeList : NULL, |
1453 | 3.04k | allowed_operations_per_nf_instance ? allowed_operations_per_nf_instanceList : NULL, |
1454 | 3.04k | allowed_operations_per_nf_instance_overrides ? true : false, |
1455 | 3.04k | allowed_operations_per_nf_instance_overrides ? allowed_operations_per_nf_instance_overrides->valueint : 0, |
1456 | 3.04k | allowed_scopes_rule_set ? allowed_scopes_rule_setList : NULL, |
1457 | 3.04k | priority ? true : false, |
1458 | 3.04k | priority ? priority->valuedouble : 0, |
1459 | 3.04k | capacity ? true : false, |
1460 | 3.04k | capacity ? capacity->valuedouble : 0, |
1461 | 3.04k | load ? true : false, |
1462 | 3.04k | load ? load->valuedouble : 0, |
1463 | 3.04k | load_time_stamp && !cJSON_IsNull(load_time_stamp) ? ogs_strdup(load_time_stamp->valuestring) : NULL, |
1464 | 3.04k | recovery_time && !cJSON_IsNull(recovery_time) ? ogs_strdup(recovery_time->valuestring) : NULL, |
1465 | 3.04k | supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL, |
1466 | 3.04k | nf_service_set_id_list ? nf_service_set_id_listList : NULL, |
1467 | 3.04k | s_nssais ? s_nssaisList : NULL, |
1468 | 3.04k | per_plmn_snssai_list ? per_plmn_snssai_listList : NULL, |
1469 | 3.04k | vendor_id && !cJSON_IsNull(vendor_id) ? ogs_strdup(vendor_id->valuestring) : NULL, |
1470 | 3.04k | supported_vendor_specific_features ? supported_vendor_specific_featuresList : NULL, |
1471 | 3.04k | oauth2_required ? true : false, |
1472 | 3.04k | oauth2_required ? oauth2_required->valueint : 0, |
1473 | 3.04k | per_plmn_oauth2_req_list ? per_plmn_oauth2_req_list_local_nonprim : NULL, |
1474 | 3.04k | selection_conditions ? selection_conditions_local_nonprim : NULL, |
1475 | 3.04k | canary_release ? true : false, |
1476 | 3.04k | canary_release ? canary_release->valueint : 0, |
1477 | 3.04k | exclusive_canary_release_selection ? true : false, |
1478 | 3.04k | exclusive_canary_release_selection ? exclusive_canary_release_selection->valueint : 0, |
1479 | 3.04k | shared_service_data_id && !cJSON_IsNull(shared_service_data_id) ? ogs_strdup(shared_service_data_id->valuestring) : NULL, |
1480 | 3.04k | shutdown_time && !cJSON_IsNull(shutdown_time) ? ogs_strdup(shutdown_time->valuestring) : NULL, |
1481 | 3.04k | canary_precedence_over_preferred ? true : false, |
1482 | 3.04k | canary_precedence_over_preferred ? canary_precedence_over_preferred->valueint : 0 |
1483 | 3.04k | ); |
1484 | | |
1485 | 3.04k | return nf_service_local_var; |
1486 | 1.53k | end: |
1487 | 1.53k | if (versionsList) { |
1488 | 181 | OpenAPI_list_for_each(versionsList, node) { |
1489 | 16 | OpenAPI_nf_service_version_free(node->data); |
1490 | 16 | } |
1491 | 181 | OpenAPI_list_free(versionsList); |
1492 | 181 | versionsList = NULL; |
1493 | 181 | } |
1494 | 1.53k | if (ip_end_pointsList) { |
1495 | 357 | OpenAPI_list_for_each(ip_end_pointsList, node) { |
1496 | 357 | OpenAPI_ip_end_point_free(node->data); |
1497 | 357 | } |
1498 | 12 | OpenAPI_list_free(ip_end_pointsList); |
1499 | 12 | ip_end_pointsList = NULL; |
1500 | 12 | } |
1501 | 1.53k | if (callback_uri_prefix_listList) { |
1502 | 2 | OpenAPI_list_for_each(callback_uri_prefix_listList, node) { |
1503 | 0 | OpenAPI_callback_uri_prefix_item_free(node->data); |
1504 | 0 | } |
1505 | 2 | OpenAPI_list_free(callback_uri_prefix_listList); |
1506 | 2 | callback_uri_prefix_listList = NULL; |
1507 | 2 | } |
1508 | 1.53k | if (default_notification_subscriptionsList) { |
1509 | 2 | OpenAPI_list_for_each(default_notification_subscriptionsList, node) { |
1510 | 0 | OpenAPI_default_notification_subscription_free(node->data); |
1511 | 0 | } |
1512 | 2 | OpenAPI_list_free(default_notification_subscriptionsList); |
1513 | 2 | default_notification_subscriptionsList = NULL; |
1514 | 2 | } |
1515 | 1.53k | if (allowed_plmnsList) { |
1516 | 74 | OpenAPI_list_for_each(allowed_plmnsList, node) { |
1517 | 74 | OpenAPI_plmn_id_free(node->data); |
1518 | 74 | } |
1519 | 10 | OpenAPI_list_free(allowed_plmnsList); |
1520 | 10 | allowed_plmnsList = NULL; |
1521 | 10 | } |
1522 | 1.53k | if (allowed_snpnsList) { |
1523 | 82 | OpenAPI_list_for_each(allowed_snpnsList, node) { |
1524 | 82 | OpenAPI_plmn_id_nid_free(node->data); |
1525 | 82 | } |
1526 | 11 | OpenAPI_list_free(allowed_snpnsList); |
1527 | 11 | allowed_snpnsList = NULL; |
1528 | 11 | } |
1529 | 1.53k | if (allowed_nf_typesList) { |
1530 | 9 | OpenAPI_list_free(allowed_nf_typesList); |
1531 | 9 | allowed_nf_typesList = NULL; |
1532 | 9 | } |
1533 | 1.53k | if (allowed_nf_domainsList) { |
1534 | 203 | OpenAPI_list_for_each(allowed_nf_domainsList, node) { |
1535 | 203 | ogs_free(node->data); |
1536 | 203 | } |
1537 | 10 | OpenAPI_list_free(allowed_nf_domainsList); |
1538 | 10 | allowed_nf_domainsList = NULL; |
1539 | 10 | } |
1540 | 1.53k | if (allowed_nssaisList) { |
1541 | 73 | OpenAPI_list_for_each(allowed_nssaisList, node) { |
1542 | 73 | OpenAPI_ext_snssai_free(node->data); |
1543 | 73 | } |
1544 | 9 | OpenAPI_list_free(allowed_nssaisList); |
1545 | 9 | allowed_nssaisList = NULL; |
1546 | 9 | } |
1547 | 1.53k | if (allowed_operations_per_nf_typeList) { |
1548 | 1 | OpenAPI_list_for_each(allowed_operations_per_nf_typeList, node) { |
1549 | 0 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
1550 | 0 | ogs_free(localKeyValue->key); |
1551 | 0 | ogs_free(localKeyValue->value); |
1552 | 0 | OpenAPI_map_free(localKeyValue); |
1553 | 0 | } |
1554 | 1 | OpenAPI_list_free(allowed_operations_per_nf_typeList); |
1555 | 1 | allowed_operations_per_nf_typeList = NULL; |
1556 | 1 | } |
1557 | 1.53k | if (allowed_operations_per_nf_instanceList) { |
1558 | 1 | OpenAPI_list_for_each(allowed_operations_per_nf_instanceList, node) { |
1559 | 0 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
1560 | 0 | ogs_free(localKeyValue->key); |
1561 | 0 | ogs_free(localKeyValue->value); |
1562 | 0 | OpenAPI_map_free(localKeyValue); |
1563 | 0 | } |
1564 | 1 | OpenAPI_list_free(allowed_operations_per_nf_instanceList); |
1565 | 1 | allowed_operations_per_nf_instanceList = NULL; |
1566 | 1 | } |
1567 | 1.53k | if (allowed_scopes_rule_setList) { |
1568 | 335 | OpenAPI_list_for_each(allowed_scopes_rule_setList, node) { |
1569 | 335 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
1570 | 335 | ogs_free(localKeyValue->key); |
1571 | 335 | OpenAPI_rule_set_free(localKeyValue->value); |
1572 | 335 | OpenAPI_map_free(localKeyValue); |
1573 | 335 | } |
1574 | 10 | OpenAPI_list_free(allowed_scopes_rule_setList); |
1575 | 10 | allowed_scopes_rule_setList = NULL; |
1576 | 10 | } |
1577 | 1.53k | if (nf_service_set_id_listList) { |
1578 | 203 | OpenAPI_list_for_each(nf_service_set_id_listList, node) { |
1579 | 203 | ogs_free(node->data); |
1580 | 203 | } |
1581 | 10 | OpenAPI_list_free(nf_service_set_id_listList); |
1582 | 10 | nf_service_set_id_listList = NULL; |
1583 | 10 | } |
1584 | 1.53k | if (s_nssaisList) { |
1585 | 203 | OpenAPI_list_for_each(s_nssaisList, node) { |
1586 | 203 | OpenAPI_ext_snssai_free(node->data); |
1587 | 203 | } |
1588 | 10 | OpenAPI_list_free(s_nssaisList); |
1589 | 10 | s_nssaisList = NULL; |
1590 | 10 | } |
1591 | 1.53k | if (per_plmn_snssai_listList) { |
1592 | 2 | OpenAPI_list_for_each(per_plmn_snssai_listList, node) { |
1593 | 0 | OpenAPI_plmn_snssai_free(node->data); |
1594 | 0 | } |
1595 | 2 | OpenAPI_list_free(per_plmn_snssai_listList); |
1596 | 2 | per_plmn_snssai_listList = NULL; |
1597 | 2 | } |
1598 | 1.53k | if (supported_vendor_specific_featuresList) { |
1599 | 203 | OpenAPI_list_for_each(supported_vendor_specific_featuresList, node) { |
1600 | 203 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
1601 | 203 | ogs_free(localKeyValue->key); |
1602 | 203 | OpenAPI_vendor_specific_feature_free(localKeyValue->value); |
1603 | 203 | OpenAPI_map_free(localKeyValue); |
1604 | 203 | } |
1605 | 10 | OpenAPI_list_free(supported_vendor_specific_featuresList); |
1606 | 10 | supported_vendor_specific_featuresList = NULL; |
1607 | 10 | } |
1608 | 1.53k | if (per_plmn_oauth2_req_list_local_nonprim) { |
1609 | 1 | OpenAPI_plmn_oauth2_free(per_plmn_oauth2_req_list_local_nonprim); |
1610 | 1 | per_plmn_oauth2_req_list_local_nonprim = NULL; |
1611 | 1 | } |
1612 | 1.53k | if (selection_conditions_local_nonprim) { |
1613 | 1 | OpenAPI_selection_conditions_free(selection_conditions_local_nonprim); |
1614 | 1 | selection_conditions_local_nonprim = NULL; |
1615 | 1 | } |
1616 | 1.53k | return NULL; |
1617 | 3.04k | } |
1618 | | |
1619 | | OpenAPI_nf_service_t *OpenAPI_nf_service_copy(OpenAPI_nf_service_t *dst, OpenAPI_nf_service_t *src) |
1620 | 0 | { |
1621 | 0 | cJSON *item = NULL; |
1622 | 0 | char *content = NULL; |
1623 | |
|
1624 | 0 | ogs_assert(src); |
1625 | 0 | item = OpenAPI_nf_service_convertToJSON(src); |
1626 | 0 | if (!item) { |
1627 | 0 | ogs_error("OpenAPI_nf_service_convertToJSON() failed"); |
1628 | 0 | return NULL; |
1629 | 0 | } |
1630 | | |
1631 | 0 | content = cJSON_Print(item); |
1632 | 0 | cJSON_Delete(item); |
1633 | |
|
1634 | 0 | if (!content) { |
1635 | 0 | ogs_error("cJSON_Print() failed"); |
1636 | 0 | return NULL; |
1637 | 0 | } |
1638 | | |
1639 | 0 | item = cJSON_Parse(content); |
1640 | 0 | ogs_free(content); |
1641 | 0 | if (!item) { |
1642 | 0 | ogs_error("cJSON_Parse() failed"); |
1643 | 0 | return NULL; |
1644 | 0 | } |
1645 | | |
1646 | 0 | OpenAPI_nf_service_free(dst); |
1647 | 0 | dst = OpenAPI_nf_service_parseFromJSON(item); |
1648 | 0 | cJSON_Delete(item); |
1649 | |
|
1650 | 0 | return dst; |
1651 | 0 | } |
1652 | | |