/src/open5gs/lib/sbi/openapi/model/amf_info.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "amf_info.h" |
6 | | |
7 | | OpenAPI_amf_info_t *OpenAPI_amf_info_create( |
8 | | char *amf_set_id, |
9 | | char *amf_region_id, |
10 | | OpenAPI_list_t *guami_list, |
11 | | OpenAPI_list_t *tai_list, |
12 | | OpenAPI_list_t *tai_range_list, |
13 | | OpenAPI_list_t *backup_info_amf_failure, |
14 | | OpenAPI_list_t *backup_info_amf_removal, |
15 | | bool is_n2_interface_amf_info_null, |
16 | | OpenAPI_n2_interface_amf_info_t *n2_interface_amf_info, |
17 | | bool is_amf_onboarding_capability, |
18 | | int amf_onboarding_capability, |
19 | | bool is_high_latency_com, |
20 | | int high_latency_com, |
21 | | OpenAPI_list_t *amf_events, |
22 | | OpenAPI_list_t *pra_id_list, |
23 | | bool is_mobile_iab_ind_null, |
24 | | bool is_mobile_iab_ind, |
25 | | int mobile_iab_ind |
26 | | ) |
27 | 1.28k | { |
28 | 1.28k | OpenAPI_amf_info_t *amf_info_local_var = ogs_malloc(sizeof(OpenAPI_amf_info_t)); |
29 | 1.28k | ogs_assert(amf_info_local_var); |
30 | | |
31 | 1.28k | amf_info_local_var->amf_set_id = amf_set_id; |
32 | 1.28k | amf_info_local_var->amf_region_id = amf_region_id; |
33 | 1.28k | amf_info_local_var->guami_list = guami_list; |
34 | 1.28k | amf_info_local_var->tai_list = tai_list; |
35 | 1.28k | amf_info_local_var->tai_range_list = tai_range_list; |
36 | 1.28k | amf_info_local_var->backup_info_amf_failure = backup_info_amf_failure; |
37 | 1.28k | amf_info_local_var->backup_info_amf_removal = backup_info_amf_removal; |
38 | 1.28k | amf_info_local_var->is_n2_interface_amf_info_null = is_n2_interface_amf_info_null; |
39 | 1.28k | amf_info_local_var->n2_interface_amf_info = n2_interface_amf_info; |
40 | 1.28k | amf_info_local_var->is_amf_onboarding_capability = is_amf_onboarding_capability; |
41 | 1.28k | amf_info_local_var->amf_onboarding_capability = amf_onboarding_capability; |
42 | 1.28k | amf_info_local_var->is_high_latency_com = is_high_latency_com; |
43 | 1.28k | amf_info_local_var->high_latency_com = high_latency_com; |
44 | 1.28k | amf_info_local_var->amf_events = amf_events; |
45 | 1.28k | amf_info_local_var->pra_id_list = pra_id_list; |
46 | 1.28k | amf_info_local_var->is_mobile_iab_ind_null = is_mobile_iab_ind_null; |
47 | 1.28k | amf_info_local_var->is_mobile_iab_ind = is_mobile_iab_ind; |
48 | 1.28k | amf_info_local_var->mobile_iab_ind = mobile_iab_ind; |
49 | | |
50 | 1.28k | return amf_info_local_var; |
51 | 1.28k | } |
52 | | |
53 | | void OpenAPI_amf_info_free(OpenAPI_amf_info_t *amf_info) |
54 | 7.21k | { |
55 | 7.21k | OpenAPI_lnode_t *node = NULL; |
56 | | |
57 | 7.21k | if (NULL == amf_info) { |
58 | 5.92k | return; |
59 | 5.92k | } |
60 | 1.28k | if (amf_info->amf_set_id) { |
61 | 1.28k | ogs_free(amf_info->amf_set_id); |
62 | 1.28k | amf_info->amf_set_id = NULL; |
63 | 1.28k | } |
64 | 1.28k | if (amf_info->amf_region_id) { |
65 | 1.28k | ogs_free(amf_info->amf_region_id); |
66 | 1.28k | amf_info->amf_region_id = NULL; |
67 | 1.28k | } |
68 | 1.28k | if (amf_info->guami_list) { |
69 | 1.28k | OpenAPI_list_for_each(amf_info->guami_list, node) { |
70 | 46 | OpenAPI_guami_free(node->data); |
71 | 46 | } |
72 | 1.28k | OpenAPI_list_free(amf_info->guami_list); |
73 | 1.28k | amf_info->guami_list = NULL; |
74 | 1.28k | } |
75 | 1.28k | if (amf_info->tai_list) { |
76 | 237 | OpenAPI_list_for_each(amf_info->tai_list, node) { |
77 | 37 | OpenAPI_tai_free(node->data); |
78 | 37 | } |
79 | 237 | OpenAPI_list_free(amf_info->tai_list); |
80 | 237 | amf_info->tai_list = NULL; |
81 | 237 | } |
82 | 1.28k | if (amf_info->tai_range_list) { |
83 | 87 | OpenAPI_list_for_each(amf_info->tai_range_list, node) { |
84 | 19 | OpenAPI_tai_range_free(node->data); |
85 | 19 | } |
86 | 87 | OpenAPI_list_free(amf_info->tai_range_list); |
87 | 87 | amf_info->tai_range_list = NULL; |
88 | 87 | } |
89 | 1.28k | if (amf_info->backup_info_amf_failure) { |
90 | 66 | OpenAPI_list_for_each(amf_info->backup_info_amf_failure, node) { |
91 | 0 | OpenAPI_guami_free(node->data); |
92 | 0 | } |
93 | 66 | OpenAPI_list_free(amf_info->backup_info_amf_failure); |
94 | 66 | amf_info->backup_info_amf_failure = NULL; |
95 | 66 | } |
96 | 1.28k | if (amf_info->backup_info_amf_removal) { |
97 | 66 | OpenAPI_list_for_each(amf_info->backup_info_amf_removal, node) { |
98 | 0 | OpenAPI_guami_free(node->data); |
99 | 0 | } |
100 | 66 | OpenAPI_list_free(amf_info->backup_info_amf_removal); |
101 | 66 | amf_info->backup_info_amf_removal = NULL; |
102 | 66 | } |
103 | 1.28k | if (amf_info->n2_interface_amf_info) { |
104 | 66 | OpenAPI_n2_interface_amf_info_free(amf_info->n2_interface_amf_info); |
105 | 66 | amf_info->n2_interface_amf_info = NULL; |
106 | 66 | } |
107 | 1.28k | if (amf_info->amf_events) { |
108 | 79 | OpenAPI_list_free(amf_info->amf_events); |
109 | 79 | amf_info->amf_events = NULL; |
110 | 79 | } |
111 | 1.28k | if (amf_info->pra_id_list) { |
112 | 268 | OpenAPI_list_for_each(amf_info->pra_id_list, node) { |
113 | 268 | ogs_free(node->data); |
114 | 268 | } |
115 | 140 | OpenAPI_list_free(amf_info->pra_id_list); |
116 | 140 | amf_info->pra_id_list = NULL; |
117 | 140 | } |
118 | 1.28k | ogs_free(amf_info); |
119 | 1.28k | } |
120 | | |
121 | | cJSON *OpenAPI_amf_info_convertToJSON(OpenAPI_amf_info_t *amf_info) |
122 | 0 | { |
123 | 0 | cJSON *item = NULL; |
124 | 0 | OpenAPI_lnode_t *node = NULL; |
125 | |
|
126 | 0 | if (amf_info == NULL) { |
127 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [AmfInfo]"); |
128 | 0 | return NULL; |
129 | 0 | } |
130 | | |
131 | 0 | item = cJSON_CreateObject(); |
132 | 0 | if (!amf_info->amf_set_id) { |
133 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [amf_set_id]"); |
134 | 0 | return NULL; |
135 | 0 | } |
136 | 0 | if (cJSON_AddStringToObject(item, "amfSetId", amf_info->amf_set_id) == NULL) { |
137 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [amf_set_id]"); |
138 | 0 | goto end; |
139 | 0 | } |
140 | | |
141 | 0 | if (!amf_info->amf_region_id) { |
142 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [amf_region_id]"); |
143 | 0 | return NULL; |
144 | 0 | } |
145 | 0 | if (cJSON_AddStringToObject(item, "amfRegionId", amf_info->amf_region_id) == NULL) { |
146 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [amf_region_id]"); |
147 | 0 | goto end; |
148 | 0 | } |
149 | | |
150 | 0 | if (!amf_info->guami_list) { |
151 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [guami_list]"); |
152 | 0 | return NULL; |
153 | 0 | } |
154 | 0 | cJSON *guami_listList = cJSON_AddArrayToObject(item, "guamiList"); |
155 | 0 | if (guami_listList == NULL) { |
156 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [guami_list]"); |
157 | 0 | goto end; |
158 | 0 | } |
159 | 0 | OpenAPI_list_for_each(amf_info->guami_list, node) { |
160 | 0 | cJSON *itemLocal = OpenAPI_guami_convertToJSON(node->data); |
161 | 0 | if (itemLocal == NULL) { |
162 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [guami_list]"); |
163 | 0 | goto end; |
164 | 0 | } |
165 | 0 | cJSON_AddItemToArray(guami_listList, itemLocal); |
166 | 0 | } |
167 | | |
168 | 0 | if (amf_info->tai_list) { |
169 | 0 | cJSON *tai_listList = cJSON_AddArrayToObject(item, "taiList"); |
170 | 0 | if (tai_listList == NULL) { |
171 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [tai_list]"); |
172 | 0 | goto end; |
173 | 0 | } |
174 | 0 | OpenAPI_list_for_each(amf_info->tai_list, node) { |
175 | 0 | cJSON *itemLocal = OpenAPI_tai_convertToJSON(node->data); |
176 | 0 | if (itemLocal == NULL) { |
177 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [tai_list]"); |
178 | 0 | goto end; |
179 | 0 | } |
180 | 0 | cJSON_AddItemToArray(tai_listList, itemLocal); |
181 | 0 | } |
182 | 0 | } |
183 | | |
184 | 0 | if (amf_info->tai_range_list) { |
185 | 0 | cJSON *tai_range_listList = cJSON_AddArrayToObject(item, "taiRangeList"); |
186 | 0 | if (tai_range_listList == NULL) { |
187 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [tai_range_list]"); |
188 | 0 | goto end; |
189 | 0 | } |
190 | 0 | OpenAPI_list_for_each(amf_info->tai_range_list, node) { |
191 | 0 | cJSON *itemLocal = OpenAPI_tai_range_convertToJSON(node->data); |
192 | 0 | if (itemLocal == NULL) { |
193 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [tai_range_list]"); |
194 | 0 | goto end; |
195 | 0 | } |
196 | 0 | cJSON_AddItemToArray(tai_range_listList, itemLocal); |
197 | 0 | } |
198 | 0 | } |
199 | | |
200 | 0 | if (amf_info->backup_info_amf_failure) { |
201 | 0 | cJSON *backup_info_amf_failureList = cJSON_AddArrayToObject(item, "backupInfoAmfFailure"); |
202 | 0 | if (backup_info_amf_failureList == NULL) { |
203 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [backup_info_amf_failure]"); |
204 | 0 | goto end; |
205 | 0 | } |
206 | 0 | OpenAPI_list_for_each(amf_info->backup_info_amf_failure, node) { |
207 | 0 | cJSON *itemLocal = OpenAPI_guami_convertToJSON(node->data); |
208 | 0 | if (itemLocal == NULL) { |
209 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [backup_info_amf_failure]"); |
210 | 0 | goto end; |
211 | 0 | } |
212 | 0 | cJSON_AddItemToArray(backup_info_amf_failureList, itemLocal); |
213 | 0 | } |
214 | 0 | } |
215 | | |
216 | 0 | if (amf_info->backup_info_amf_removal) { |
217 | 0 | cJSON *backup_info_amf_removalList = cJSON_AddArrayToObject(item, "backupInfoAmfRemoval"); |
218 | 0 | if (backup_info_amf_removalList == NULL) { |
219 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [backup_info_amf_removal]"); |
220 | 0 | goto end; |
221 | 0 | } |
222 | 0 | OpenAPI_list_for_each(amf_info->backup_info_amf_removal, node) { |
223 | 0 | cJSON *itemLocal = OpenAPI_guami_convertToJSON(node->data); |
224 | 0 | if (itemLocal == NULL) { |
225 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [backup_info_amf_removal]"); |
226 | 0 | goto end; |
227 | 0 | } |
228 | 0 | cJSON_AddItemToArray(backup_info_amf_removalList, itemLocal); |
229 | 0 | } |
230 | 0 | } |
231 | | |
232 | 0 | if (amf_info->n2_interface_amf_info) { |
233 | 0 | cJSON *n2_interface_amf_info_local_JSON = OpenAPI_n2_interface_amf_info_convertToJSON(amf_info->n2_interface_amf_info); |
234 | 0 | if (n2_interface_amf_info_local_JSON == NULL) { |
235 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [n2_interface_amf_info]"); |
236 | 0 | goto end; |
237 | 0 | } |
238 | 0 | cJSON_AddItemToObject(item, "n2InterfaceAmfInfo", n2_interface_amf_info_local_JSON); |
239 | 0 | if (item->child == NULL) { |
240 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [n2_interface_amf_info]"); |
241 | 0 | goto end; |
242 | 0 | } |
243 | 0 | } else if (amf_info->is_n2_interface_amf_info_null) { |
244 | 0 | if (cJSON_AddNullToObject(item, "n2InterfaceAmfInfo") == NULL) { |
245 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [n2_interface_amf_info]"); |
246 | 0 | goto end; |
247 | 0 | } |
248 | 0 | } |
249 | | |
250 | 0 | if (amf_info->is_amf_onboarding_capability) { |
251 | 0 | if (cJSON_AddBoolToObject(item, "amfOnboardingCapability", amf_info->amf_onboarding_capability) == NULL) { |
252 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [amf_onboarding_capability]"); |
253 | 0 | goto end; |
254 | 0 | } |
255 | 0 | } |
256 | | |
257 | 0 | if (amf_info->is_high_latency_com) { |
258 | 0 | if (cJSON_AddBoolToObject(item, "highLatencyCom", amf_info->high_latency_com) == NULL) { |
259 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [high_latency_com]"); |
260 | 0 | goto end; |
261 | 0 | } |
262 | 0 | } |
263 | | |
264 | 0 | if (amf_info->amf_events != OpenAPI_amf_event_type_NULL) { |
265 | 0 | cJSON *amf_eventsList = cJSON_AddArrayToObject(item, "amfEvents"); |
266 | 0 | if (amf_eventsList == NULL) { |
267 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [amf_events]"); |
268 | 0 | goto end; |
269 | 0 | } |
270 | 0 | OpenAPI_list_for_each(amf_info->amf_events, node) { |
271 | 0 | if (cJSON_AddStringToObject(amf_eventsList, "", OpenAPI_amf_event_type_ToString((intptr_t)node->data)) == NULL) { |
272 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [amf_events]"); |
273 | 0 | goto end; |
274 | 0 | } |
275 | 0 | } |
276 | 0 | } |
277 | | |
278 | 0 | if (amf_info->pra_id_list) { |
279 | 0 | cJSON *pra_id_listList = cJSON_AddArrayToObject(item, "praIdList"); |
280 | 0 | if (pra_id_listList == NULL) { |
281 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [pra_id_list]"); |
282 | 0 | goto end; |
283 | 0 | } |
284 | 0 | OpenAPI_list_for_each(amf_info->pra_id_list, node) { |
285 | 0 | if (cJSON_AddStringToObject(pra_id_listList, "", (char*)node->data) == NULL) { |
286 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [pra_id_list]"); |
287 | 0 | goto end; |
288 | 0 | } |
289 | 0 | } |
290 | 0 | } |
291 | | |
292 | 0 | if (amf_info->is_mobile_iab_ind) { |
293 | 0 | if (cJSON_AddBoolToObject(item, "mobileIabInd", amf_info->mobile_iab_ind) == NULL) { |
294 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [mobile_iab_ind]"); |
295 | 0 | goto end; |
296 | 0 | } |
297 | 0 | } else if (amf_info->is_mobile_iab_ind_null) { |
298 | 0 | if (cJSON_AddNullToObject(item, "mobileIabInd") == NULL) { |
299 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed [mobile_iab_ind]"); |
300 | 0 | goto end; |
301 | 0 | } |
302 | 0 | } |
303 | | |
304 | 0 | end: |
305 | 0 | return item; |
306 | 0 | } |
307 | | |
308 | | OpenAPI_amf_info_t *OpenAPI_amf_info_parseFromJSON(cJSON *amf_infoJSON) |
309 | 6.76k | { |
310 | 6.76k | OpenAPI_amf_info_t *amf_info_local_var = NULL; |
311 | 6.76k | OpenAPI_lnode_t *node = NULL; |
312 | 6.76k | cJSON *amf_set_id = NULL; |
313 | 6.76k | cJSON *amf_region_id = NULL; |
314 | 6.76k | cJSON *guami_list = NULL; |
315 | 6.76k | OpenAPI_list_t *guami_listList = NULL; |
316 | 6.76k | cJSON *tai_list = NULL; |
317 | 6.76k | OpenAPI_list_t *tai_listList = NULL; |
318 | 6.76k | cJSON *tai_range_list = NULL; |
319 | 6.76k | OpenAPI_list_t *tai_range_listList = NULL; |
320 | 6.76k | cJSON *backup_info_amf_failure = NULL; |
321 | 6.76k | OpenAPI_list_t *backup_info_amf_failureList = NULL; |
322 | 6.76k | cJSON *backup_info_amf_removal = NULL; |
323 | 6.76k | OpenAPI_list_t *backup_info_amf_removalList = NULL; |
324 | 6.76k | cJSON *n2_interface_amf_info = NULL; |
325 | 6.76k | OpenAPI_n2_interface_amf_info_t *n2_interface_amf_info_local_nonprim = NULL; |
326 | 6.76k | cJSON *amf_onboarding_capability = NULL; |
327 | 6.76k | cJSON *high_latency_com = NULL; |
328 | 6.76k | cJSON *amf_events = NULL; |
329 | 6.76k | OpenAPI_list_t *amf_eventsList = NULL; |
330 | 6.76k | cJSON *pra_id_list = NULL; |
331 | 6.76k | OpenAPI_list_t *pra_id_listList = NULL; |
332 | 6.76k | cJSON *mobile_iab_ind = NULL; |
333 | 6.76k | amf_set_id = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "amfSetId"); |
334 | 6.76k | if (!amf_set_id) { |
335 | 1.50k | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [amf_set_id]"); |
336 | 1.50k | goto end; |
337 | 1.50k | } |
338 | 5.25k | if (!cJSON_IsString(amf_set_id)) { |
339 | 195 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [amf_set_id]"); |
340 | 195 | goto end; |
341 | 195 | } |
342 | | |
343 | 5.05k | amf_region_id = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "amfRegionId"); |
344 | 5.05k | if (!amf_region_id) { |
345 | 311 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [amf_region_id]"); |
346 | 311 | goto end; |
347 | 311 | } |
348 | 4.74k | if (!cJSON_IsString(amf_region_id)) { |
349 | 200 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [amf_region_id]"); |
350 | 200 | goto end; |
351 | 200 | } |
352 | | |
353 | 4.54k | guami_list = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "guamiList"); |
354 | 4.54k | if (!guami_list) { |
355 | 209 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [guami_list]"); |
356 | 209 | goto end; |
357 | 209 | } |
358 | 4.33k | cJSON *guami_list_local = NULL; |
359 | 4.33k | if (!cJSON_IsArray(guami_list)) { |
360 | 202 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [guami_list]"); |
361 | 202 | goto end; |
362 | 202 | } |
363 | | |
364 | 4.13k | guami_listList = OpenAPI_list_create(); |
365 | | |
366 | 4.13k | cJSON_ArrayForEach(guami_list_local, guami_list) { |
367 | 511 | if (!cJSON_IsObject(guami_list_local)) { |
368 | 195 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [guami_list]"); |
369 | 195 | goto end; |
370 | 195 | } |
371 | 316 | OpenAPI_guami_t *guami_listItem = OpenAPI_guami_parseFromJSON(guami_list_local); |
372 | 316 | if (!guami_listItem) { |
373 | 263 | ogs_error("No guami_listItem"); |
374 | 263 | goto end; |
375 | 263 | } |
376 | 53 | OpenAPI_list_add(guami_listList, guami_listItem); |
377 | 53 | } |
378 | | |
379 | 3.67k | tai_list = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "taiList"); |
380 | 3.67k | if (tai_list) { |
381 | 695 | cJSON *tai_list_local = NULL; |
382 | 695 | if (!cJSON_IsArray(tai_list)) { |
383 | 195 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [tai_list]"); |
384 | 195 | goto end; |
385 | 195 | } |
386 | | |
387 | 500 | tai_listList = OpenAPI_list_create(); |
388 | | |
389 | 500 | cJSON_ArrayForEach(tai_list_local, tai_list) { |
390 | 300 | if (!cJSON_IsObject(tai_list_local)) { |
391 | 195 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [tai_list]"); |
392 | 195 | goto end; |
393 | 195 | } |
394 | 105 | OpenAPI_tai_t *tai_listItem = OpenAPI_tai_parseFromJSON(tai_list_local); |
395 | 105 | if (!tai_listItem) { |
396 | 68 | ogs_error("No tai_listItem"); |
397 | 68 | goto end; |
398 | 68 | } |
399 | 37 | OpenAPI_list_add(tai_listList, tai_listItem); |
400 | 37 | } |
401 | 500 | } |
402 | | |
403 | 3.22k | tai_range_list = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "taiRangeList"); |
404 | 3.22k | if (tai_range_list) { |
405 | 288 | cJSON *tai_range_list_local = NULL; |
406 | 288 | if (!cJSON_IsArray(tai_range_list)) { |
407 | 66 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [tai_range_list]"); |
408 | 66 | goto end; |
409 | 66 | } |
410 | | |
411 | 222 | tai_range_listList = OpenAPI_list_create(); |
412 | | |
413 | 222 | cJSON_ArrayForEach(tai_range_list_local, tai_range_list) { |
414 | 154 | if (!cJSON_IsObject(tai_range_list_local)) { |
415 | 66 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [tai_range_list]"); |
416 | 66 | goto end; |
417 | 66 | } |
418 | 88 | OpenAPI_tai_range_t *tai_range_listItem = OpenAPI_tai_range_parseFromJSON(tai_range_list_local); |
419 | 88 | if (!tai_range_listItem) { |
420 | 69 | ogs_error("No tai_range_listItem"); |
421 | 69 | goto end; |
422 | 69 | } |
423 | 19 | OpenAPI_list_add(tai_range_listList, tai_range_listItem); |
424 | 19 | } |
425 | 222 | } |
426 | | |
427 | 3.02k | backup_info_amf_failure = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "backupInfoAmfFailure"); |
428 | 3.02k | if (backup_info_amf_failure) { |
429 | 264 | cJSON *backup_info_amf_failure_local = NULL; |
430 | 264 | if (!cJSON_IsArray(backup_info_amf_failure)) { |
431 | 66 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [backup_info_amf_failure]"); |
432 | 66 | goto end; |
433 | 66 | } |
434 | | |
435 | 198 | backup_info_amf_failureList = OpenAPI_list_create(); |
436 | | |
437 | 198 | cJSON_ArrayForEach(backup_info_amf_failure_local, backup_info_amf_failure) { |
438 | 132 | if (!cJSON_IsObject(backup_info_amf_failure_local)) { |
439 | 66 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [backup_info_amf_failure]"); |
440 | 66 | goto end; |
441 | 66 | } |
442 | 66 | OpenAPI_guami_t *backup_info_amf_failureItem = OpenAPI_guami_parseFromJSON(backup_info_amf_failure_local); |
443 | 66 | if (!backup_info_amf_failureItem) { |
444 | 66 | ogs_error("No backup_info_amf_failureItem"); |
445 | 66 | goto end; |
446 | 66 | } |
447 | 0 | OpenAPI_list_add(backup_info_amf_failureList, backup_info_amf_failureItem); |
448 | 0 | } |
449 | 198 | } |
450 | | |
451 | 2.82k | backup_info_amf_removal = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "backupInfoAmfRemoval"); |
452 | 2.82k | if (backup_info_amf_removal) { |
453 | 264 | cJSON *backup_info_amf_removal_local = NULL; |
454 | 264 | if (!cJSON_IsArray(backup_info_amf_removal)) { |
455 | 66 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [backup_info_amf_removal]"); |
456 | 66 | goto end; |
457 | 66 | } |
458 | | |
459 | 198 | backup_info_amf_removalList = OpenAPI_list_create(); |
460 | | |
461 | 198 | cJSON_ArrayForEach(backup_info_amf_removal_local, backup_info_amf_removal) { |
462 | 132 | if (!cJSON_IsObject(backup_info_amf_removal_local)) { |
463 | 66 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [backup_info_amf_removal]"); |
464 | 66 | goto end; |
465 | 66 | } |
466 | 66 | OpenAPI_guami_t *backup_info_amf_removalItem = OpenAPI_guami_parseFromJSON(backup_info_amf_removal_local); |
467 | 66 | if (!backup_info_amf_removalItem) { |
468 | 66 | ogs_error("No backup_info_amf_removalItem"); |
469 | 66 | goto end; |
470 | 66 | } |
471 | 0 | OpenAPI_list_add(backup_info_amf_removalList, backup_info_amf_removalItem); |
472 | 0 | } |
473 | 198 | } |
474 | | |
475 | 2.62k | n2_interface_amf_info = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "n2InterfaceAmfInfo"); |
476 | 2.62k | if (n2_interface_amf_info) { |
477 | 198 | if (!cJSON_IsNull(n2_interface_amf_info)) { |
478 | 132 | n2_interface_amf_info_local_nonprim = OpenAPI_n2_interface_amf_info_parseFromJSON(n2_interface_amf_info); |
479 | 132 | if (!n2_interface_amf_info_local_nonprim) { |
480 | 0 | ogs_error("OpenAPI_n2_interface_amf_info_parseFromJSON failed [n2_interface_amf_info]"); |
481 | 0 | goto end; |
482 | 0 | } |
483 | 132 | } |
484 | 198 | } |
485 | | |
486 | 2.62k | amf_onboarding_capability = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "amfOnboardingCapability"); |
487 | 2.62k | if (amf_onboarding_capability) { |
488 | 132 | if (!cJSON_IsBool(amf_onboarding_capability)) { |
489 | 66 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [amf_onboarding_capability]"); |
490 | 66 | goto end; |
491 | 66 | } |
492 | 132 | } |
493 | | |
494 | 2.55k | high_latency_com = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "highLatencyCom"); |
495 | 2.55k | if (high_latency_com) { |
496 | 260 | if (!cJSON_IsBool(high_latency_com)) { |
497 | 194 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [high_latency_com]"); |
498 | 194 | goto end; |
499 | 194 | } |
500 | 260 | } |
501 | | |
502 | 2.36k | amf_events = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "amfEvents"); |
503 | 2.36k | if (amf_events) { |
504 | 692 | cJSON *amf_events_local = NULL; |
505 | 692 | if (!cJSON_IsArray(amf_events)) { |
506 | 214 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [amf_events]"); |
507 | 214 | goto end; |
508 | 214 | } |
509 | | |
510 | 478 | amf_eventsList = OpenAPI_list_create(); |
511 | | |
512 | 1.01k | cJSON_ArrayForEach(amf_events_local, amf_events) { |
513 | 1.01k | OpenAPI_amf_event_type_e localEnum = OpenAPI_amf_event_type_NULL; |
514 | 1.01k | if (!cJSON_IsString(amf_events_local)) { |
515 | 66 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [amf_events]"); |
516 | 66 | goto end; |
517 | 66 | } |
518 | 948 | localEnum = OpenAPI_amf_event_type_FromString(amf_events_local->valuestring); |
519 | 948 | if (!localEnum) { |
520 | 683 | ogs_info("Enum value \"%s\" for field \"amf_events\" is not supported. Ignoring it ...", |
521 | 683 | amf_events_local->valuestring); |
522 | 683 | } else { |
523 | 265 | OpenAPI_list_add(amf_eventsList, (void *)localEnum); |
524 | 265 | } |
525 | 948 | } |
526 | 412 | if (amf_eventsList->count == 0) { |
527 | 333 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed: Expected amf_eventsList to not be empty (after ignoring unsupported enum values)."); |
528 | 333 | goto end; |
529 | 333 | } |
530 | 412 | } |
531 | | |
532 | 1.75k | pra_id_list = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "praIdList"); |
533 | 1.75k | if (pra_id_list) { |
534 | 540 | cJSON *pra_id_list_local = NULL; |
535 | 540 | if (!cJSON_IsArray(pra_id_list)) { |
536 | 201 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [pra_id_list]"); |
537 | 201 | goto end; |
538 | 201 | } |
539 | | |
540 | 339 | pra_id_listList = OpenAPI_list_create(); |
541 | | |
542 | 670 | cJSON_ArrayForEach(pra_id_list_local, pra_id_list) { |
543 | 670 | double *localDouble = NULL; |
544 | 670 | int *localInt = NULL; |
545 | 670 | if (!cJSON_IsString(pra_id_list_local)) { |
546 | 134 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [pra_id_list]"); |
547 | 134 | goto end; |
548 | 134 | } |
549 | 536 | OpenAPI_list_add(pra_id_listList, ogs_strdup(pra_id_list_local->valuestring)); |
550 | 536 | } |
551 | 339 | } |
552 | | |
553 | 1.41k | mobile_iab_ind = cJSON_GetObjectItemCaseSensitive(amf_infoJSON, "mobileIabInd"); |
554 | 1.41k | if (mobile_iab_ind) { |
555 | 263 | if (!cJSON_IsNull(mobile_iab_ind)) { |
556 | 197 | if (!cJSON_IsBool(mobile_iab_ind)) { |
557 | 131 | ogs_error("OpenAPI_amf_info_parseFromJSON() failed [mobile_iab_ind]"); |
558 | 131 | goto end; |
559 | 131 | } |
560 | 197 | } |
561 | 263 | } |
562 | | |
563 | 1.28k | amf_info_local_var = OpenAPI_amf_info_create ( |
564 | 1.28k | ogs_strdup(amf_set_id->valuestring), |
565 | 1.28k | ogs_strdup(amf_region_id->valuestring), |
566 | 1.28k | guami_listList, |
567 | 1.28k | tai_list ? tai_listList : NULL, |
568 | 1.28k | tai_range_list ? tai_range_listList : NULL, |
569 | 1.28k | backup_info_amf_failure ? backup_info_amf_failureList : NULL, |
570 | 1.28k | backup_info_amf_removal ? backup_info_amf_removalList : NULL, |
571 | 1.28k | n2_interface_amf_info && cJSON_IsNull(n2_interface_amf_info) ? true : false, |
572 | 1.28k | n2_interface_amf_info ? n2_interface_amf_info_local_nonprim : NULL, |
573 | 1.28k | amf_onboarding_capability ? true : false, |
574 | 1.28k | amf_onboarding_capability ? amf_onboarding_capability->valueint : 0, |
575 | 1.28k | high_latency_com ? true : false, |
576 | 1.28k | high_latency_com ? high_latency_com->valueint : 0, |
577 | 1.28k | amf_events ? amf_eventsList : NULL, |
578 | 1.28k | pra_id_list ? pra_id_listList : NULL, |
579 | 1.28k | mobile_iab_ind && cJSON_IsNull(mobile_iab_ind) ? true : false, |
580 | 1.28k | mobile_iab_ind ? true : false, |
581 | 1.28k | mobile_iab_ind ? mobile_iab_ind->valueint : 0 |
582 | 1.28k | ); |
583 | | |
584 | 1.28k | return amf_info_local_var; |
585 | 5.47k | end: |
586 | 5.47k | if (guami_listList) { |
587 | 2.85k | OpenAPI_list_for_each(guami_listList, node) { |
588 | 7 | OpenAPI_guami_free(node->data); |
589 | 7 | } |
590 | 2.85k | OpenAPI_list_free(guami_listList); |
591 | 2.85k | guami_listList = NULL; |
592 | 2.85k | } |
593 | 5.47k | if (tai_listList) { |
594 | 263 | OpenAPI_list_for_each(tai_listList, node) { |
595 | 0 | OpenAPI_tai_free(node->data); |
596 | 0 | } |
597 | 263 | OpenAPI_list_free(tai_listList); |
598 | 263 | tai_listList = NULL; |
599 | 263 | } |
600 | 5.47k | if (tai_range_listList) { |
601 | 135 | OpenAPI_list_for_each(tai_range_listList, node) { |
602 | 0 | OpenAPI_tai_range_free(node->data); |
603 | 0 | } |
604 | 135 | OpenAPI_list_free(tai_range_listList); |
605 | 135 | tai_range_listList = NULL; |
606 | 135 | } |
607 | 5.47k | if (backup_info_amf_failureList) { |
608 | 132 | OpenAPI_list_for_each(backup_info_amf_failureList, node) { |
609 | 0 | OpenAPI_guami_free(node->data); |
610 | 0 | } |
611 | 132 | OpenAPI_list_free(backup_info_amf_failureList); |
612 | 132 | backup_info_amf_failureList = NULL; |
613 | 132 | } |
614 | 5.47k | if (backup_info_amf_removalList) { |
615 | 132 | OpenAPI_list_for_each(backup_info_amf_removalList, node) { |
616 | 0 | OpenAPI_guami_free(node->data); |
617 | 0 | } |
618 | 132 | OpenAPI_list_free(backup_info_amf_removalList); |
619 | 132 | backup_info_amf_removalList = NULL; |
620 | 132 | } |
621 | 5.47k | if (n2_interface_amf_info_local_nonprim) { |
622 | 66 | OpenAPI_n2_interface_amf_info_free(n2_interface_amf_info_local_nonprim); |
623 | 66 | n2_interface_amf_info_local_nonprim = NULL; |
624 | 66 | } |
625 | 5.47k | if (amf_eventsList) { |
626 | 399 | OpenAPI_list_free(amf_eventsList); |
627 | 399 | amf_eventsList = NULL; |
628 | 399 | } |
629 | 5.47k | if (pra_id_listList) { |
630 | 268 | OpenAPI_list_for_each(pra_id_listList, node) { |
631 | 268 | ogs_free(node->data); |
632 | 268 | } |
633 | 199 | OpenAPI_list_free(pra_id_listList); |
634 | 199 | pra_id_listList = NULL; |
635 | 199 | } |
636 | 5.47k | return NULL; |
637 | 1.41k | } |
638 | | |
639 | | OpenAPI_amf_info_t *OpenAPI_amf_info_copy(OpenAPI_amf_info_t *dst, OpenAPI_amf_info_t *src) |
640 | 0 | { |
641 | 0 | cJSON *item = NULL; |
642 | 0 | char *content = NULL; |
643 | |
|
644 | 0 | ogs_assert(src); |
645 | 0 | item = OpenAPI_amf_info_convertToJSON(src); |
646 | 0 | if (!item) { |
647 | 0 | ogs_error("OpenAPI_amf_info_convertToJSON() failed"); |
648 | 0 | return NULL; |
649 | 0 | } |
650 | | |
651 | 0 | content = cJSON_Print(item); |
652 | 0 | cJSON_Delete(item); |
653 | |
|
654 | 0 | if (!content) { |
655 | 0 | ogs_error("cJSON_Print() failed"); |
656 | 0 | return NULL; |
657 | 0 | } |
658 | | |
659 | 0 | item = cJSON_Parse(content); |
660 | 0 | ogs_free(content); |
661 | 0 | if (!item) { |
662 | 0 | ogs_error("cJSON_Parse() failed"); |
663 | 0 | return NULL; |
664 | 0 | } |
665 | | |
666 | 0 | OpenAPI_amf_info_free(dst); |
667 | 0 | dst = OpenAPI_amf_info_parseFromJSON(item); |
668 | 0 | cJSON_Delete(item); |
669 | |
|
670 | 0 | return dst; |
671 | 0 | } |
672 | | |