/src/open5gs/lib/sbi/openapi/model/nef_info.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "nef_info.h" |
6 | | |
7 | | OpenAPI_nef_info_t *OpenAPI_nef_info_create( |
8 | | char *nef_id, |
9 | | OpenAPI_pfd_data_t *pfd_data, |
10 | | OpenAPI_af_event_exposure_data_t *af_ee_data, |
11 | | OpenAPI_list_t *gpsi_ranges, |
12 | | OpenAPI_list_t *external_group_identifiers_ranges, |
13 | | OpenAPI_list_t *served_fqdn_list, |
14 | | OpenAPI_list_t *tai_list, |
15 | | OpenAPI_list_t *tai_range_list, |
16 | | OpenAPI_list_t *dnai_list, |
17 | | OpenAPI_list_t *un_trust_af_info_list, |
18 | | bool is_uas_nf_functionality_ind, |
19 | | int uas_nf_functionality_ind, |
20 | | bool is_multi_mem_af_sess_qos_ind, |
21 | | int multi_mem_af_sess_qos_ind, |
22 | | bool is_member_ue_sel_assist_ind, |
23 | | int member_ue_sel_assist_ind |
24 | | ) |
25 | 44 | { |
26 | 44 | OpenAPI_nef_info_t *nef_info_local_var = ogs_malloc(sizeof(OpenAPI_nef_info_t)); |
27 | 44 | ogs_assert(nef_info_local_var); |
28 | | |
29 | 44 | nef_info_local_var->nef_id = nef_id; |
30 | 44 | nef_info_local_var->pfd_data = pfd_data; |
31 | 44 | nef_info_local_var->af_ee_data = af_ee_data; |
32 | 44 | nef_info_local_var->gpsi_ranges = gpsi_ranges; |
33 | 44 | nef_info_local_var->external_group_identifiers_ranges = external_group_identifiers_ranges; |
34 | 44 | nef_info_local_var->served_fqdn_list = served_fqdn_list; |
35 | 44 | nef_info_local_var->tai_list = tai_list; |
36 | 44 | nef_info_local_var->tai_range_list = tai_range_list; |
37 | 44 | nef_info_local_var->dnai_list = dnai_list; |
38 | 44 | nef_info_local_var->un_trust_af_info_list = un_trust_af_info_list; |
39 | 44 | nef_info_local_var->is_uas_nf_functionality_ind = is_uas_nf_functionality_ind; |
40 | 44 | nef_info_local_var->uas_nf_functionality_ind = uas_nf_functionality_ind; |
41 | 44 | nef_info_local_var->is_multi_mem_af_sess_qos_ind = is_multi_mem_af_sess_qos_ind; |
42 | 44 | nef_info_local_var->multi_mem_af_sess_qos_ind = multi_mem_af_sess_qos_ind; |
43 | 44 | nef_info_local_var->is_member_ue_sel_assist_ind = is_member_ue_sel_assist_ind; |
44 | 44 | nef_info_local_var->member_ue_sel_assist_ind = member_ue_sel_assist_ind; |
45 | | |
46 | 44 | return nef_info_local_var; |
47 | 44 | } |
48 | | |
49 | | void OpenAPI_nef_info_free(OpenAPI_nef_info_t *nef_info) |
50 | 44 | { |
51 | 44 | OpenAPI_lnode_t *node = NULL; |
52 | | |
53 | 44 | if (NULL == nef_info) { |
54 | 0 | return; |
55 | 0 | } |
56 | 44 | if (nef_info->nef_id) { |
57 | 1 | ogs_free(nef_info->nef_id); |
58 | 1 | nef_info->nef_id = NULL; |
59 | 1 | } |
60 | 44 | if (nef_info->pfd_data) { |
61 | 1 | OpenAPI_pfd_data_free(nef_info->pfd_data); |
62 | 1 | nef_info->pfd_data = NULL; |
63 | 1 | } |
64 | 44 | if (nef_info->af_ee_data) { |
65 | 0 | OpenAPI_af_event_exposure_data_free(nef_info->af_ee_data); |
66 | 0 | nef_info->af_ee_data = NULL; |
67 | 0 | } |
68 | 44 | if (nef_info->gpsi_ranges) { |
69 | 211 | OpenAPI_list_for_each(nef_info->gpsi_ranges, node) { |
70 | 211 | OpenAPI_identity_range_free(node->data); |
71 | 211 | } |
72 | 12 | OpenAPI_list_free(nef_info->gpsi_ranges); |
73 | 12 | nef_info->gpsi_ranges = NULL; |
74 | 12 | } |
75 | 44 | if (nef_info->external_group_identifiers_ranges) { |
76 | 227 | OpenAPI_list_for_each(nef_info->external_group_identifiers_ranges, node) { |
77 | 227 | OpenAPI_identity_range_free(node->data); |
78 | 227 | } |
79 | 12 | OpenAPI_list_free(nef_info->external_group_identifiers_ranges); |
80 | 12 | nef_info->external_group_identifiers_ranges = NULL; |
81 | 12 | } |
82 | 44 | if (nef_info->served_fqdn_list) { |
83 | 260 | OpenAPI_list_for_each(nef_info->served_fqdn_list, node) { |
84 | 260 | ogs_free(node->data); |
85 | 260 | } |
86 | 13 | OpenAPI_list_free(nef_info->served_fqdn_list); |
87 | 13 | nef_info->served_fqdn_list = NULL; |
88 | 13 | } |
89 | 44 | if (nef_info->tai_list) { |
90 | 1 | OpenAPI_list_for_each(nef_info->tai_list, node) { |
91 | 0 | OpenAPI_tai_free(node->data); |
92 | 0 | } |
93 | 1 | OpenAPI_list_free(nef_info->tai_list); |
94 | 1 | nef_info->tai_list = NULL; |
95 | 1 | } |
96 | 44 | if (nef_info->tai_range_list) { |
97 | 1 | OpenAPI_list_for_each(nef_info->tai_range_list, node) { |
98 | 0 | OpenAPI_tai_range_free(node->data); |
99 | 0 | } |
100 | 1 | OpenAPI_list_free(nef_info->tai_range_list); |
101 | 1 | nef_info->tai_range_list = NULL; |
102 | 1 | } |
103 | 44 | if (nef_info->dnai_list) { |
104 | 0 | OpenAPI_list_for_each(nef_info->dnai_list, node) { |
105 | 0 | ogs_free(node->data); |
106 | 0 | } |
107 | 0 | OpenAPI_list_free(nef_info->dnai_list); |
108 | 0 | nef_info->dnai_list = NULL; |
109 | 0 | } |
110 | 44 | if (nef_info->un_trust_af_info_list) { |
111 | 0 | OpenAPI_list_for_each(nef_info->un_trust_af_info_list, node) { |
112 | 0 | OpenAPI_un_trust_af_info_free(node->data); |
113 | 0 | } |
114 | 0 | OpenAPI_list_free(nef_info->un_trust_af_info_list); |
115 | 0 | nef_info->un_trust_af_info_list = NULL; |
116 | 0 | } |
117 | 44 | ogs_free(nef_info); |
118 | 44 | } |
119 | | |
120 | | cJSON *OpenAPI_nef_info_convertToJSON(OpenAPI_nef_info_t *nef_info) |
121 | 0 | { |
122 | 0 | cJSON *item = NULL; |
123 | 0 | OpenAPI_lnode_t *node = NULL; |
124 | |
|
125 | 0 | if (nef_info == NULL) { |
126 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [NefInfo]"); |
127 | 0 | return NULL; |
128 | 0 | } |
129 | | |
130 | 0 | item = cJSON_CreateObject(); |
131 | 0 | if (nef_info->nef_id) { |
132 | 0 | if (cJSON_AddStringToObject(item, "nefId", nef_info->nef_id) == NULL) { |
133 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [nef_id]"); |
134 | 0 | goto end; |
135 | 0 | } |
136 | 0 | } |
137 | | |
138 | 0 | if (nef_info->pfd_data) { |
139 | 0 | cJSON *pfd_data_local_JSON = OpenAPI_pfd_data_convertToJSON(nef_info->pfd_data); |
140 | 0 | if (pfd_data_local_JSON == NULL) { |
141 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [pfd_data]"); |
142 | 0 | goto end; |
143 | 0 | } |
144 | 0 | cJSON_AddItemToObject(item, "pfdData", pfd_data_local_JSON); |
145 | 0 | if (item->child == NULL) { |
146 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [pfd_data]"); |
147 | 0 | goto end; |
148 | 0 | } |
149 | 0 | } |
150 | | |
151 | 0 | if (nef_info->af_ee_data) { |
152 | 0 | cJSON *af_ee_data_local_JSON = OpenAPI_af_event_exposure_data_convertToJSON(nef_info->af_ee_data); |
153 | 0 | if (af_ee_data_local_JSON == NULL) { |
154 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [af_ee_data]"); |
155 | 0 | goto end; |
156 | 0 | } |
157 | 0 | cJSON_AddItemToObject(item, "afEeData", af_ee_data_local_JSON); |
158 | 0 | if (item->child == NULL) { |
159 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [af_ee_data]"); |
160 | 0 | goto end; |
161 | 0 | } |
162 | 0 | } |
163 | | |
164 | 0 | if (nef_info->gpsi_ranges) { |
165 | 0 | cJSON *gpsi_rangesList = cJSON_AddArrayToObject(item, "gpsiRanges"); |
166 | 0 | if (gpsi_rangesList == NULL) { |
167 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [gpsi_ranges]"); |
168 | 0 | goto end; |
169 | 0 | } |
170 | 0 | OpenAPI_list_for_each(nef_info->gpsi_ranges, node) { |
171 | 0 | cJSON *itemLocal = OpenAPI_identity_range_convertToJSON(node->data); |
172 | 0 | if (itemLocal == NULL) { |
173 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [gpsi_ranges]"); |
174 | 0 | goto end; |
175 | 0 | } |
176 | 0 | cJSON_AddItemToArray(gpsi_rangesList, itemLocal); |
177 | 0 | } |
178 | 0 | } |
179 | | |
180 | 0 | if (nef_info->external_group_identifiers_ranges) { |
181 | 0 | cJSON *external_group_identifiers_rangesList = cJSON_AddArrayToObject(item, "externalGroupIdentifiersRanges"); |
182 | 0 | if (external_group_identifiers_rangesList == NULL) { |
183 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [external_group_identifiers_ranges]"); |
184 | 0 | goto end; |
185 | 0 | } |
186 | 0 | OpenAPI_list_for_each(nef_info->external_group_identifiers_ranges, node) { |
187 | 0 | cJSON *itemLocal = OpenAPI_identity_range_convertToJSON(node->data); |
188 | 0 | if (itemLocal == NULL) { |
189 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [external_group_identifiers_ranges]"); |
190 | 0 | goto end; |
191 | 0 | } |
192 | 0 | cJSON_AddItemToArray(external_group_identifiers_rangesList, itemLocal); |
193 | 0 | } |
194 | 0 | } |
195 | | |
196 | 0 | if (nef_info->served_fqdn_list) { |
197 | 0 | cJSON *served_fqdn_listList = cJSON_AddArrayToObject(item, "servedFqdnList"); |
198 | 0 | if (served_fqdn_listList == NULL) { |
199 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [served_fqdn_list]"); |
200 | 0 | goto end; |
201 | 0 | } |
202 | 0 | OpenAPI_list_for_each(nef_info->served_fqdn_list, node) { |
203 | 0 | if (cJSON_AddStringToObject(served_fqdn_listList, "", (char*)node->data) == NULL) { |
204 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [served_fqdn_list]"); |
205 | 0 | goto end; |
206 | 0 | } |
207 | 0 | } |
208 | 0 | } |
209 | | |
210 | 0 | if (nef_info->tai_list) { |
211 | 0 | cJSON *tai_listList = cJSON_AddArrayToObject(item, "taiList"); |
212 | 0 | if (tai_listList == NULL) { |
213 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [tai_list]"); |
214 | 0 | goto end; |
215 | 0 | } |
216 | 0 | OpenAPI_list_for_each(nef_info->tai_list, node) { |
217 | 0 | cJSON *itemLocal = OpenAPI_tai_convertToJSON(node->data); |
218 | 0 | if (itemLocal == NULL) { |
219 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [tai_list]"); |
220 | 0 | goto end; |
221 | 0 | } |
222 | 0 | cJSON_AddItemToArray(tai_listList, itemLocal); |
223 | 0 | } |
224 | 0 | } |
225 | | |
226 | 0 | if (nef_info->tai_range_list) { |
227 | 0 | cJSON *tai_range_listList = cJSON_AddArrayToObject(item, "taiRangeList"); |
228 | 0 | if (tai_range_listList == NULL) { |
229 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [tai_range_list]"); |
230 | 0 | goto end; |
231 | 0 | } |
232 | 0 | OpenAPI_list_for_each(nef_info->tai_range_list, node) { |
233 | 0 | cJSON *itemLocal = OpenAPI_tai_range_convertToJSON(node->data); |
234 | 0 | if (itemLocal == NULL) { |
235 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [tai_range_list]"); |
236 | 0 | goto end; |
237 | 0 | } |
238 | 0 | cJSON_AddItemToArray(tai_range_listList, itemLocal); |
239 | 0 | } |
240 | 0 | } |
241 | | |
242 | 0 | if (nef_info->dnai_list) { |
243 | 0 | cJSON *dnai_listList = cJSON_AddArrayToObject(item, "dnaiList"); |
244 | 0 | if (dnai_listList == NULL) { |
245 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [dnai_list]"); |
246 | 0 | goto end; |
247 | 0 | } |
248 | 0 | OpenAPI_list_for_each(nef_info->dnai_list, node) { |
249 | 0 | if (cJSON_AddStringToObject(dnai_listList, "", (char*)node->data) == NULL) { |
250 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [dnai_list]"); |
251 | 0 | goto end; |
252 | 0 | } |
253 | 0 | } |
254 | 0 | } |
255 | | |
256 | 0 | if (nef_info->un_trust_af_info_list) { |
257 | 0 | cJSON *un_trust_af_info_listList = cJSON_AddArrayToObject(item, "unTrustAfInfoList"); |
258 | 0 | if (un_trust_af_info_listList == NULL) { |
259 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [un_trust_af_info_list]"); |
260 | 0 | goto end; |
261 | 0 | } |
262 | 0 | OpenAPI_list_for_each(nef_info->un_trust_af_info_list, node) { |
263 | 0 | cJSON *itemLocal = OpenAPI_un_trust_af_info_convertToJSON(node->data); |
264 | 0 | if (itemLocal == NULL) { |
265 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [un_trust_af_info_list]"); |
266 | 0 | goto end; |
267 | 0 | } |
268 | 0 | cJSON_AddItemToArray(un_trust_af_info_listList, itemLocal); |
269 | 0 | } |
270 | 0 | } |
271 | | |
272 | 0 | if (nef_info->is_uas_nf_functionality_ind) { |
273 | 0 | if (cJSON_AddBoolToObject(item, "uasNfFunctionalityInd", nef_info->uas_nf_functionality_ind) == NULL) { |
274 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [uas_nf_functionality_ind]"); |
275 | 0 | goto end; |
276 | 0 | } |
277 | 0 | } |
278 | | |
279 | 0 | if (nef_info->is_multi_mem_af_sess_qos_ind) { |
280 | 0 | if (cJSON_AddBoolToObject(item, "multiMemAfSessQosInd", nef_info->multi_mem_af_sess_qos_ind) == NULL) { |
281 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [multi_mem_af_sess_qos_ind]"); |
282 | 0 | goto end; |
283 | 0 | } |
284 | 0 | } |
285 | | |
286 | 0 | if (nef_info->is_member_ue_sel_assist_ind) { |
287 | 0 | if (cJSON_AddBoolToObject(item, "memberUESelAssistInd", nef_info->member_ue_sel_assist_ind) == NULL) { |
288 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed [member_ue_sel_assist_ind]"); |
289 | 0 | goto end; |
290 | 0 | } |
291 | 0 | } |
292 | | |
293 | 0 | end: |
294 | 0 | return item; |
295 | 0 | } |
296 | | |
297 | | OpenAPI_nef_info_t *OpenAPI_nef_info_parseFromJSON(cJSON *nef_infoJSON) |
298 | 92 | { |
299 | 92 | OpenAPI_nef_info_t *nef_info_local_var = NULL; |
300 | 92 | OpenAPI_lnode_t *node = NULL; |
301 | 92 | cJSON *nef_id = NULL; |
302 | 92 | cJSON *pfd_data = NULL; |
303 | 92 | OpenAPI_pfd_data_t *pfd_data_local_nonprim = NULL; |
304 | 92 | cJSON *af_ee_data = NULL; |
305 | 92 | OpenAPI_af_event_exposure_data_t *af_ee_data_local_nonprim = NULL; |
306 | 92 | cJSON *gpsi_ranges = NULL; |
307 | 92 | OpenAPI_list_t *gpsi_rangesList = NULL; |
308 | 92 | cJSON *external_group_identifiers_ranges = NULL; |
309 | 92 | OpenAPI_list_t *external_group_identifiers_rangesList = NULL; |
310 | 92 | cJSON *served_fqdn_list = NULL; |
311 | 92 | OpenAPI_list_t *served_fqdn_listList = NULL; |
312 | 92 | cJSON *tai_list = NULL; |
313 | 92 | OpenAPI_list_t *tai_listList = NULL; |
314 | 92 | cJSON *tai_range_list = NULL; |
315 | 92 | OpenAPI_list_t *tai_range_listList = NULL; |
316 | 92 | cJSON *dnai_list = NULL; |
317 | 92 | OpenAPI_list_t *dnai_listList = NULL; |
318 | 92 | cJSON *un_trust_af_info_list = NULL; |
319 | 92 | OpenAPI_list_t *un_trust_af_info_listList = NULL; |
320 | 92 | cJSON *uas_nf_functionality_ind = NULL; |
321 | 92 | cJSON *multi_mem_af_sess_qos_ind = NULL; |
322 | 92 | cJSON *member_ue_sel_assist_ind = NULL; |
323 | 92 | nef_id = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "nefId"); |
324 | 92 | if (nef_id) { |
325 | 3 | if (!cJSON_IsString(nef_id) && !cJSON_IsNull(nef_id)) { |
326 | 1 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [nef_id]"); |
327 | 1 | goto end; |
328 | 1 | } |
329 | 3 | } |
330 | | |
331 | 91 | pfd_data = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "pfdData"); |
332 | 91 | if (pfd_data) { |
333 | 2 | pfd_data_local_nonprim = OpenAPI_pfd_data_parseFromJSON(pfd_data); |
334 | 2 | if (!pfd_data_local_nonprim) { |
335 | 0 | ogs_error("OpenAPI_pfd_data_parseFromJSON failed [pfd_data]"); |
336 | 0 | goto end; |
337 | 0 | } |
338 | 2 | } |
339 | | |
340 | 91 | af_ee_data = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "afEeData"); |
341 | 91 | if (af_ee_data) { |
342 | 1 | af_ee_data_local_nonprim = OpenAPI_af_event_exposure_data_parseFromJSON(af_ee_data); |
343 | 1 | if (!af_ee_data_local_nonprim) { |
344 | 1 | ogs_error("OpenAPI_af_event_exposure_data_parseFromJSON failed [af_ee_data]"); |
345 | 1 | goto end; |
346 | 1 | } |
347 | 1 | } |
348 | | |
349 | 90 | gpsi_ranges = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "gpsiRanges"); |
350 | 90 | if (gpsi_ranges) { |
351 | 29 | cJSON *gpsi_ranges_local = NULL; |
352 | 29 | if (!cJSON_IsArray(gpsi_ranges)) { |
353 | 1 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [gpsi_ranges]"); |
354 | 1 | goto end; |
355 | 1 | } |
356 | | |
357 | 28 | gpsi_rangesList = OpenAPI_list_create(); |
358 | | |
359 | 656 | cJSON_ArrayForEach(gpsi_ranges_local, gpsi_ranges) { |
360 | 656 | if (!cJSON_IsObject(gpsi_ranges_local)) { |
361 | 15 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [gpsi_ranges]"); |
362 | 15 | goto end; |
363 | 15 | } |
364 | 641 | OpenAPI_identity_range_t *gpsi_rangesItem = OpenAPI_identity_range_parseFromJSON(gpsi_ranges_local); |
365 | 641 | if (!gpsi_rangesItem) { |
366 | 1 | ogs_error("No gpsi_rangesItem"); |
367 | 1 | goto end; |
368 | 1 | } |
369 | 640 | OpenAPI_list_add(gpsi_rangesList, gpsi_rangesItem); |
370 | 640 | } |
371 | 28 | } |
372 | | |
373 | 73 | external_group_identifiers_ranges = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "externalGroupIdentifiersRanges"); |
374 | 73 | if (external_group_identifiers_ranges) { |
375 | 24 | cJSON *external_group_identifiers_ranges_local = NULL; |
376 | 24 | if (!cJSON_IsArray(external_group_identifiers_ranges)) { |
377 | 1 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [external_group_identifiers_ranges]"); |
378 | 1 | goto end; |
379 | 1 | } |
380 | | |
381 | 23 | external_group_identifiers_rangesList = OpenAPI_list_create(); |
382 | | |
383 | 441 | cJSON_ArrayForEach(external_group_identifiers_ranges_local, external_group_identifiers_ranges) { |
384 | 441 | if (!cJSON_IsObject(external_group_identifiers_ranges_local)) { |
385 | 10 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [external_group_identifiers_ranges]"); |
386 | 10 | goto end; |
387 | 10 | } |
388 | 431 | OpenAPI_identity_range_t *external_group_identifiers_rangesItem = OpenAPI_identity_range_parseFromJSON(external_group_identifiers_ranges_local); |
389 | 431 | if (!external_group_identifiers_rangesItem) { |
390 | 1 | ogs_error("No external_group_identifiers_rangesItem"); |
391 | 1 | goto end; |
392 | 1 | } |
393 | 430 | OpenAPI_list_add(external_group_identifiers_rangesList, external_group_identifiers_rangesItem); |
394 | 430 | } |
395 | 23 | } |
396 | | |
397 | 61 | served_fqdn_list = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "servedFqdnList"); |
398 | 61 | if (served_fqdn_list) { |
399 | 24 | cJSON *served_fqdn_list_local = NULL; |
400 | 24 | if (!cJSON_IsArray(served_fqdn_list)) { |
401 | 1 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [served_fqdn_list]"); |
402 | 1 | goto end; |
403 | 1 | } |
404 | | |
405 | 23 | served_fqdn_listList = OpenAPI_list_create(); |
406 | | |
407 | 473 | cJSON_ArrayForEach(served_fqdn_list_local, served_fqdn_list) { |
408 | 473 | double *localDouble = NULL; |
409 | 473 | int *localInt = NULL; |
410 | 473 | if (!cJSON_IsString(served_fqdn_list_local)) { |
411 | 10 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [served_fqdn_list]"); |
412 | 10 | goto end; |
413 | 10 | } |
414 | 463 | OpenAPI_list_add(served_fqdn_listList, ogs_strdup(served_fqdn_list_local->valuestring)); |
415 | 463 | } |
416 | 23 | } |
417 | | |
418 | 50 | tai_list = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "taiList"); |
419 | 50 | if (tai_list) { |
420 | 4 | cJSON *tai_list_local = NULL; |
421 | 4 | if (!cJSON_IsArray(tai_list)) { |
422 | 1 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [tai_list]"); |
423 | 1 | goto end; |
424 | 1 | } |
425 | | |
426 | 3 | tai_listList = OpenAPI_list_create(); |
427 | | |
428 | 3 | cJSON_ArrayForEach(tai_list_local, tai_list) { |
429 | 2 | if (!cJSON_IsObject(tai_list_local)) { |
430 | 1 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [tai_list]"); |
431 | 1 | goto end; |
432 | 1 | } |
433 | 1 | OpenAPI_tai_t *tai_listItem = OpenAPI_tai_parseFromJSON(tai_list_local); |
434 | 1 | if (!tai_listItem) { |
435 | 1 | ogs_error("No tai_listItem"); |
436 | 1 | goto end; |
437 | 1 | } |
438 | 0 | OpenAPI_list_add(tai_listList, tai_listItem); |
439 | 0 | } |
440 | 3 | } |
441 | | |
442 | 47 | tai_range_list = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "taiRangeList"); |
443 | 47 | if (tai_range_list) { |
444 | 4 | cJSON *tai_range_list_local = NULL; |
445 | 4 | if (!cJSON_IsArray(tai_range_list)) { |
446 | 1 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [tai_range_list]"); |
447 | 1 | goto end; |
448 | 1 | } |
449 | | |
450 | 3 | tai_range_listList = OpenAPI_list_create(); |
451 | | |
452 | 3 | cJSON_ArrayForEach(tai_range_list_local, tai_range_list) { |
453 | 2 | if (!cJSON_IsObject(tai_range_list_local)) { |
454 | 1 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [tai_range_list]"); |
455 | 1 | goto end; |
456 | 1 | } |
457 | 1 | OpenAPI_tai_range_t *tai_range_listItem = OpenAPI_tai_range_parseFromJSON(tai_range_list_local); |
458 | 1 | if (!tai_range_listItem) { |
459 | 1 | ogs_error("No tai_range_listItem"); |
460 | 1 | goto end; |
461 | 1 | } |
462 | 0 | OpenAPI_list_add(tai_range_listList, tai_range_listItem); |
463 | 0 | } |
464 | 3 | } |
465 | | |
466 | 44 | dnai_list = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "dnaiList"); |
467 | 44 | if (dnai_list) { |
468 | 0 | cJSON *dnai_list_local = NULL; |
469 | 0 | if (!cJSON_IsArray(dnai_list)) { |
470 | 0 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [dnai_list]"); |
471 | 0 | goto end; |
472 | 0 | } |
473 | | |
474 | 0 | dnai_listList = OpenAPI_list_create(); |
475 | |
|
476 | 0 | cJSON_ArrayForEach(dnai_list_local, dnai_list) { |
477 | 0 | double *localDouble = NULL; |
478 | 0 | int *localInt = NULL; |
479 | 0 | if (!cJSON_IsString(dnai_list_local)) { |
480 | 0 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [dnai_list]"); |
481 | 0 | goto end; |
482 | 0 | } |
483 | 0 | OpenAPI_list_add(dnai_listList, ogs_strdup(dnai_list_local->valuestring)); |
484 | 0 | } |
485 | 0 | } |
486 | | |
487 | 44 | un_trust_af_info_list = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "unTrustAfInfoList"); |
488 | 44 | if (un_trust_af_info_list) { |
489 | 0 | cJSON *un_trust_af_info_list_local = NULL; |
490 | 0 | if (!cJSON_IsArray(un_trust_af_info_list)) { |
491 | 0 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [un_trust_af_info_list]"); |
492 | 0 | goto end; |
493 | 0 | } |
494 | | |
495 | 0 | un_trust_af_info_listList = OpenAPI_list_create(); |
496 | |
|
497 | 0 | cJSON_ArrayForEach(un_trust_af_info_list_local, un_trust_af_info_list) { |
498 | 0 | if (!cJSON_IsObject(un_trust_af_info_list_local)) { |
499 | 0 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [un_trust_af_info_list]"); |
500 | 0 | goto end; |
501 | 0 | } |
502 | 0 | OpenAPI_un_trust_af_info_t *un_trust_af_info_listItem = OpenAPI_un_trust_af_info_parseFromJSON(un_trust_af_info_list_local); |
503 | 0 | if (!un_trust_af_info_listItem) { |
504 | 0 | ogs_error("No un_trust_af_info_listItem"); |
505 | 0 | goto end; |
506 | 0 | } |
507 | 0 | OpenAPI_list_add(un_trust_af_info_listList, un_trust_af_info_listItem); |
508 | 0 | } |
509 | 0 | } |
510 | | |
511 | 44 | uas_nf_functionality_ind = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "uasNfFunctionalityInd"); |
512 | 44 | if (uas_nf_functionality_ind) { |
513 | 0 | if (!cJSON_IsBool(uas_nf_functionality_ind)) { |
514 | 0 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [uas_nf_functionality_ind]"); |
515 | 0 | goto end; |
516 | 0 | } |
517 | 0 | } |
518 | | |
519 | 44 | multi_mem_af_sess_qos_ind = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "multiMemAfSessQosInd"); |
520 | 44 | if (multi_mem_af_sess_qos_ind) { |
521 | 0 | if (!cJSON_IsBool(multi_mem_af_sess_qos_ind)) { |
522 | 0 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [multi_mem_af_sess_qos_ind]"); |
523 | 0 | goto end; |
524 | 0 | } |
525 | 0 | } |
526 | | |
527 | 44 | member_ue_sel_assist_ind = cJSON_GetObjectItemCaseSensitive(nef_infoJSON, "memberUESelAssistInd"); |
528 | 44 | if (member_ue_sel_assist_ind) { |
529 | 0 | if (!cJSON_IsBool(member_ue_sel_assist_ind)) { |
530 | 0 | ogs_error("OpenAPI_nef_info_parseFromJSON() failed [member_ue_sel_assist_ind]"); |
531 | 0 | goto end; |
532 | 0 | } |
533 | 0 | } |
534 | | |
535 | 44 | nef_info_local_var = OpenAPI_nef_info_create ( |
536 | 44 | nef_id && !cJSON_IsNull(nef_id) ? ogs_strdup(nef_id->valuestring) : NULL, |
537 | 44 | pfd_data ? pfd_data_local_nonprim : NULL, |
538 | 44 | af_ee_data ? af_ee_data_local_nonprim : NULL, |
539 | 44 | gpsi_ranges ? gpsi_rangesList : NULL, |
540 | 44 | external_group_identifiers_ranges ? external_group_identifiers_rangesList : NULL, |
541 | 44 | served_fqdn_list ? served_fqdn_listList : NULL, |
542 | 44 | tai_list ? tai_listList : NULL, |
543 | 44 | tai_range_list ? tai_range_listList : NULL, |
544 | 44 | dnai_list ? dnai_listList : NULL, |
545 | 44 | un_trust_af_info_list ? un_trust_af_info_listList : NULL, |
546 | 44 | uas_nf_functionality_ind ? true : false, |
547 | 44 | uas_nf_functionality_ind ? uas_nf_functionality_ind->valueint : 0, |
548 | 44 | multi_mem_af_sess_qos_ind ? true : false, |
549 | 44 | multi_mem_af_sess_qos_ind ? multi_mem_af_sess_qos_ind->valueint : 0, |
550 | 44 | member_ue_sel_assist_ind ? true : false, |
551 | 44 | member_ue_sel_assist_ind ? member_ue_sel_assist_ind->valueint : 0 |
552 | 44 | ); |
553 | | |
554 | 44 | return nef_info_local_var; |
555 | 48 | end: |
556 | 48 | if (pfd_data_local_nonprim) { |
557 | 1 | OpenAPI_pfd_data_free(pfd_data_local_nonprim); |
558 | 1 | pfd_data_local_nonprim = NULL; |
559 | 1 | } |
560 | 48 | if (af_ee_data_local_nonprim) { |
561 | 0 | OpenAPI_af_event_exposure_data_free(af_ee_data_local_nonprim); |
562 | 0 | af_ee_data_local_nonprim = NULL; |
563 | 0 | } |
564 | 48 | if (gpsi_rangesList) { |
565 | 429 | OpenAPI_list_for_each(gpsi_rangesList, node) { |
566 | 429 | OpenAPI_identity_range_free(node->data); |
567 | 429 | } |
568 | 16 | OpenAPI_list_free(gpsi_rangesList); |
569 | 16 | gpsi_rangesList = NULL; |
570 | 16 | } |
571 | 48 | if (external_group_identifiers_rangesList) { |
572 | 203 | OpenAPI_list_for_each(external_group_identifiers_rangesList, node) { |
573 | 203 | OpenAPI_identity_range_free(node->data); |
574 | 203 | } |
575 | 11 | OpenAPI_list_free(external_group_identifiers_rangesList); |
576 | 11 | external_group_identifiers_rangesList = NULL; |
577 | 11 | } |
578 | 48 | if (served_fqdn_listList) { |
579 | 203 | OpenAPI_list_for_each(served_fqdn_listList, node) { |
580 | 203 | ogs_free(node->data); |
581 | 203 | } |
582 | 10 | OpenAPI_list_free(served_fqdn_listList); |
583 | 10 | served_fqdn_listList = NULL; |
584 | 10 | } |
585 | 48 | if (tai_listList) { |
586 | 2 | OpenAPI_list_for_each(tai_listList, node) { |
587 | 0 | OpenAPI_tai_free(node->data); |
588 | 0 | } |
589 | 2 | OpenAPI_list_free(tai_listList); |
590 | 2 | tai_listList = NULL; |
591 | 2 | } |
592 | 48 | if (tai_range_listList) { |
593 | 2 | OpenAPI_list_for_each(tai_range_listList, node) { |
594 | 0 | OpenAPI_tai_range_free(node->data); |
595 | 0 | } |
596 | 2 | OpenAPI_list_free(tai_range_listList); |
597 | 2 | tai_range_listList = NULL; |
598 | 2 | } |
599 | 48 | if (dnai_listList) { |
600 | 0 | OpenAPI_list_for_each(dnai_listList, node) { |
601 | 0 | ogs_free(node->data); |
602 | 0 | } |
603 | 0 | OpenAPI_list_free(dnai_listList); |
604 | 0 | dnai_listList = NULL; |
605 | 0 | } |
606 | 48 | if (un_trust_af_info_listList) { |
607 | 0 | OpenAPI_list_for_each(un_trust_af_info_listList, node) { |
608 | 0 | OpenAPI_un_trust_af_info_free(node->data); |
609 | 0 | } |
610 | 0 | OpenAPI_list_free(un_trust_af_info_listList); |
611 | 0 | un_trust_af_info_listList = NULL; |
612 | 0 | } |
613 | 48 | return NULL; |
614 | 44 | } |
615 | | |
616 | | OpenAPI_nef_info_t *OpenAPI_nef_info_copy(OpenAPI_nef_info_t *dst, OpenAPI_nef_info_t *src) |
617 | 0 | { |
618 | 0 | cJSON *item = NULL; |
619 | 0 | char *content = NULL; |
620 | |
|
621 | 0 | ogs_assert(src); |
622 | 0 | item = OpenAPI_nef_info_convertToJSON(src); |
623 | 0 | if (!item) { |
624 | 0 | ogs_error("OpenAPI_nef_info_convertToJSON() failed"); |
625 | 0 | return NULL; |
626 | 0 | } |
627 | | |
628 | 0 | content = cJSON_Print(item); |
629 | 0 | cJSON_Delete(item); |
630 | |
|
631 | 0 | if (!content) { |
632 | 0 | ogs_error("cJSON_Print() failed"); |
633 | 0 | return NULL; |
634 | 0 | } |
635 | | |
636 | 0 | item = cJSON_Parse(content); |
637 | 0 | ogs_free(content); |
638 | 0 | if (!item) { |
639 | 0 | ogs_error("cJSON_Parse() failed"); |
640 | 0 | return NULL; |
641 | 0 | } |
642 | | |
643 | 0 | OpenAPI_nef_info_free(dst); |
644 | 0 | dst = OpenAPI_nef_info_parseFromJSON(item); |
645 | 0 | cJSON_Delete(item); |
646 | |
|
647 | 0 | return dst; |
648 | 0 | } |
649 | | |