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