/src/open5gs/lib/sbi/openapi/model/plmn_restriction.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "plmn_restriction.h" |
6 | | |
7 | | OpenAPI_plmn_restriction_t *OpenAPI_plmn_restriction_create( |
8 | | OpenAPI_list_t *rat_restrictions, |
9 | | OpenAPI_list_t *forbidden_areas, |
10 | | OpenAPI_service_area_restriction_t *service_area_restriction, |
11 | | OpenAPI_list_t *core_network_type_restrictions, |
12 | | OpenAPI_list_t *access_type_restrictions, |
13 | | OpenAPI_list_t *primary_rat_restrictions, |
14 | | OpenAPI_list_t *secondary_rat_restrictions |
15 | | ) |
16 | 0 | { |
17 | 0 | OpenAPI_plmn_restriction_t *plmn_restriction_local_var = ogs_malloc(sizeof(OpenAPI_plmn_restriction_t)); |
18 | 0 | ogs_assert(plmn_restriction_local_var); |
19 | | |
20 | 0 | plmn_restriction_local_var->rat_restrictions = rat_restrictions; |
21 | 0 | plmn_restriction_local_var->forbidden_areas = forbidden_areas; |
22 | 0 | plmn_restriction_local_var->service_area_restriction = service_area_restriction; |
23 | 0 | plmn_restriction_local_var->core_network_type_restrictions = core_network_type_restrictions; |
24 | 0 | plmn_restriction_local_var->access_type_restrictions = access_type_restrictions; |
25 | 0 | plmn_restriction_local_var->primary_rat_restrictions = primary_rat_restrictions; |
26 | 0 | plmn_restriction_local_var->secondary_rat_restrictions = secondary_rat_restrictions; |
27 | |
|
28 | 0 | return plmn_restriction_local_var; |
29 | 0 | } |
30 | | |
31 | | void OpenAPI_plmn_restriction_free(OpenAPI_plmn_restriction_t *plmn_restriction) |
32 | 0 | { |
33 | 0 | OpenAPI_lnode_t *node = NULL; |
34 | |
|
35 | 0 | if (NULL == plmn_restriction) { |
36 | 0 | return; |
37 | 0 | } |
38 | 0 | if (plmn_restriction->rat_restrictions) { |
39 | 0 | OpenAPI_list_free(plmn_restriction->rat_restrictions); |
40 | 0 | plmn_restriction->rat_restrictions = NULL; |
41 | 0 | } |
42 | 0 | if (plmn_restriction->forbidden_areas) { |
43 | 0 | OpenAPI_list_for_each(plmn_restriction->forbidden_areas, node) { |
44 | 0 | OpenAPI_area_free(node->data); |
45 | 0 | } |
46 | 0 | OpenAPI_list_free(plmn_restriction->forbidden_areas); |
47 | 0 | plmn_restriction->forbidden_areas = NULL; |
48 | 0 | } |
49 | 0 | if (plmn_restriction->service_area_restriction) { |
50 | 0 | OpenAPI_service_area_restriction_free(plmn_restriction->service_area_restriction); |
51 | 0 | plmn_restriction->service_area_restriction = NULL; |
52 | 0 | } |
53 | 0 | if (plmn_restriction->core_network_type_restrictions) { |
54 | 0 | OpenAPI_list_free(plmn_restriction->core_network_type_restrictions); |
55 | 0 | plmn_restriction->core_network_type_restrictions = NULL; |
56 | 0 | } |
57 | 0 | if (plmn_restriction->access_type_restrictions) { |
58 | 0 | OpenAPI_list_free(plmn_restriction->access_type_restrictions); |
59 | 0 | plmn_restriction->access_type_restrictions = NULL; |
60 | 0 | } |
61 | 0 | if (plmn_restriction->primary_rat_restrictions) { |
62 | 0 | OpenAPI_list_free(plmn_restriction->primary_rat_restrictions); |
63 | 0 | plmn_restriction->primary_rat_restrictions = NULL; |
64 | 0 | } |
65 | 0 | if (plmn_restriction->secondary_rat_restrictions) { |
66 | 0 | OpenAPI_list_free(plmn_restriction->secondary_rat_restrictions); |
67 | 0 | plmn_restriction->secondary_rat_restrictions = NULL; |
68 | 0 | } |
69 | 0 | ogs_free(plmn_restriction); |
70 | 0 | } |
71 | | |
72 | | cJSON *OpenAPI_plmn_restriction_convertToJSON(OpenAPI_plmn_restriction_t *plmn_restriction) |
73 | 0 | { |
74 | 0 | cJSON *item = NULL; |
75 | 0 | OpenAPI_lnode_t *node = NULL; |
76 | |
|
77 | 0 | if (plmn_restriction == NULL) { |
78 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [PlmnRestriction]"); |
79 | 0 | return NULL; |
80 | 0 | } |
81 | | |
82 | 0 | item = cJSON_CreateObject(); |
83 | 0 | if (plmn_restriction->rat_restrictions != OpenAPI_rat_type_NULL) { |
84 | 0 | cJSON *rat_restrictionsList = cJSON_AddArrayToObject(item, "ratRestrictions"); |
85 | 0 | if (rat_restrictionsList == NULL) { |
86 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [rat_restrictions]"); |
87 | 0 | goto end; |
88 | 0 | } |
89 | 0 | OpenAPI_list_for_each(plmn_restriction->rat_restrictions, node) { |
90 | 0 | if (cJSON_AddStringToObject(rat_restrictionsList, "", OpenAPI_rat_type_ToString((intptr_t)node->data)) == NULL) { |
91 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [rat_restrictions]"); |
92 | 0 | goto end; |
93 | 0 | } |
94 | 0 | } |
95 | 0 | } |
96 | | |
97 | 0 | if (plmn_restriction->forbidden_areas) { |
98 | 0 | cJSON *forbidden_areasList = cJSON_AddArrayToObject(item, "forbiddenAreas"); |
99 | 0 | if (forbidden_areasList == NULL) { |
100 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [forbidden_areas]"); |
101 | 0 | goto end; |
102 | 0 | } |
103 | 0 | OpenAPI_list_for_each(plmn_restriction->forbidden_areas, node) { |
104 | 0 | cJSON *itemLocal = OpenAPI_area_convertToJSON(node->data); |
105 | 0 | if (itemLocal == NULL) { |
106 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [forbidden_areas]"); |
107 | 0 | goto end; |
108 | 0 | } |
109 | 0 | cJSON_AddItemToArray(forbidden_areasList, itemLocal); |
110 | 0 | } |
111 | 0 | } |
112 | | |
113 | 0 | if (plmn_restriction->service_area_restriction) { |
114 | 0 | cJSON *service_area_restriction_local_JSON = OpenAPI_service_area_restriction_convertToJSON(plmn_restriction->service_area_restriction); |
115 | 0 | if (service_area_restriction_local_JSON == NULL) { |
116 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [service_area_restriction]"); |
117 | 0 | goto end; |
118 | 0 | } |
119 | 0 | cJSON_AddItemToObject(item, "serviceAreaRestriction", service_area_restriction_local_JSON); |
120 | 0 | if (item->child == NULL) { |
121 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [service_area_restriction]"); |
122 | 0 | goto end; |
123 | 0 | } |
124 | 0 | } |
125 | | |
126 | 0 | if (plmn_restriction->core_network_type_restrictions != OpenAPI_core_network_type_NULL) { |
127 | 0 | cJSON *core_network_type_restrictionsList = cJSON_AddArrayToObject(item, "coreNetworkTypeRestrictions"); |
128 | 0 | if (core_network_type_restrictionsList == NULL) { |
129 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [core_network_type_restrictions]"); |
130 | 0 | goto end; |
131 | 0 | } |
132 | 0 | OpenAPI_list_for_each(plmn_restriction->core_network_type_restrictions, node) { |
133 | 0 | if (cJSON_AddStringToObject(core_network_type_restrictionsList, "", OpenAPI_core_network_type_ToString((intptr_t)node->data)) == NULL) { |
134 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [core_network_type_restrictions]"); |
135 | 0 | goto end; |
136 | 0 | } |
137 | 0 | } |
138 | 0 | } |
139 | | |
140 | 0 | if (plmn_restriction->access_type_restrictions != OpenAPI_access_type_NULL) { |
141 | 0 | cJSON *access_type_restrictionsList = cJSON_AddArrayToObject(item, "accessTypeRestrictions"); |
142 | 0 | if (access_type_restrictionsList == NULL) { |
143 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [access_type_restrictions]"); |
144 | 0 | goto end; |
145 | 0 | } |
146 | 0 | OpenAPI_list_for_each(plmn_restriction->access_type_restrictions, node) { |
147 | 0 | if (cJSON_AddStringToObject(access_type_restrictionsList, "", OpenAPI_access_type_ToString((intptr_t)node->data)) == NULL) { |
148 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [access_type_restrictions]"); |
149 | 0 | goto end; |
150 | 0 | } |
151 | 0 | } |
152 | 0 | } |
153 | | |
154 | 0 | if (plmn_restriction->primary_rat_restrictions != OpenAPI_rat_type_NULL) { |
155 | 0 | cJSON *primary_rat_restrictionsList = cJSON_AddArrayToObject(item, "primaryRatRestrictions"); |
156 | 0 | if (primary_rat_restrictionsList == NULL) { |
157 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [primary_rat_restrictions]"); |
158 | 0 | goto end; |
159 | 0 | } |
160 | 0 | OpenAPI_list_for_each(plmn_restriction->primary_rat_restrictions, node) { |
161 | 0 | if (cJSON_AddStringToObject(primary_rat_restrictionsList, "", OpenAPI_rat_type_ToString((intptr_t)node->data)) == NULL) { |
162 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [primary_rat_restrictions]"); |
163 | 0 | goto end; |
164 | 0 | } |
165 | 0 | } |
166 | 0 | } |
167 | | |
168 | 0 | if (plmn_restriction->secondary_rat_restrictions != OpenAPI_rat_type_NULL) { |
169 | 0 | cJSON *secondary_rat_restrictionsList = cJSON_AddArrayToObject(item, "secondaryRatRestrictions"); |
170 | 0 | if (secondary_rat_restrictionsList == NULL) { |
171 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [secondary_rat_restrictions]"); |
172 | 0 | goto end; |
173 | 0 | } |
174 | 0 | OpenAPI_list_for_each(plmn_restriction->secondary_rat_restrictions, node) { |
175 | 0 | if (cJSON_AddStringToObject(secondary_rat_restrictionsList, "", OpenAPI_rat_type_ToString((intptr_t)node->data)) == NULL) { |
176 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed [secondary_rat_restrictions]"); |
177 | 0 | goto end; |
178 | 0 | } |
179 | 0 | } |
180 | 0 | } |
181 | | |
182 | 0 | end: |
183 | 0 | return item; |
184 | 0 | } |
185 | | |
186 | | OpenAPI_plmn_restriction_t *OpenAPI_plmn_restriction_parseFromJSON(cJSON *plmn_restrictionJSON) |
187 | 0 | { |
188 | 0 | OpenAPI_plmn_restriction_t *plmn_restriction_local_var = NULL; |
189 | 0 | OpenAPI_lnode_t *node = NULL; |
190 | 0 | cJSON *rat_restrictions = NULL; |
191 | 0 | OpenAPI_list_t *rat_restrictionsList = NULL; |
192 | 0 | cJSON *forbidden_areas = NULL; |
193 | 0 | OpenAPI_list_t *forbidden_areasList = NULL; |
194 | 0 | cJSON *service_area_restriction = NULL; |
195 | 0 | OpenAPI_service_area_restriction_t *service_area_restriction_local_nonprim = NULL; |
196 | 0 | cJSON *core_network_type_restrictions = NULL; |
197 | 0 | OpenAPI_list_t *core_network_type_restrictionsList = NULL; |
198 | 0 | cJSON *access_type_restrictions = NULL; |
199 | 0 | OpenAPI_list_t *access_type_restrictionsList = NULL; |
200 | 0 | cJSON *primary_rat_restrictions = NULL; |
201 | 0 | OpenAPI_list_t *primary_rat_restrictionsList = NULL; |
202 | 0 | cJSON *secondary_rat_restrictions = NULL; |
203 | 0 | OpenAPI_list_t *secondary_rat_restrictionsList = NULL; |
204 | 0 | rat_restrictions = cJSON_GetObjectItemCaseSensitive(plmn_restrictionJSON, "ratRestrictions"); |
205 | 0 | if (rat_restrictions) { |
206 | 0 | cJSON *rat_restrictions_local = NULL; |
207 | 0 | if (!cJSON_IsArray(rat_restrictions)) { |
208 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [rat_restrictions]"); |
209 | 0 | goto end; |
210 | 0 | } |
211 | | |
212 | 0 | rat_restrictionsList = OpenAPI_list_create(); |
213 | |
|
214 | 0 | cJSON_ArrayForEach(rat_restrictions_local, rat_restrictions) { |
215 | 0 | OpenAPI_rat_type_e localEnum = OpenAPI_rat_type_NULL; |
216 | 0 | if (!cJSON_IsString(rat_restrictions_local)) { |
217 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [rat_restrictions]"); |
218 | 0 | goto end; |
219 | 0 | } |
220 | 0 | localEnum = OpenAPI_rat_type_FromString(rat_restrictions_local->valuestring); |
221 | 0 | if (!localEnum) { |
222 | 0 | ogs_info("Enum value \"%s\" for field \"rat_restrictions\" is not supported. Ignoring it ...", |
223 | 0 | rat_restrictions_local->valuestring); |
224 | 0 | } else { |
225 | 0 | OpenAPI_list_add(rat_restrictionsList, (void *)localEnum); |
226 | 0 | } |
227 | 0 | } |
228 | 0 | if (rat_restrictionsList->count == 0) { |
229 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed: Expected rat_restrictionsList to not be empty (after ignoring unsupported enum values)."); |
230 | 0 | goto end; |
231 | 0 | } |
232 | 0 | } |
233 | | |
234 | 0 | forbidden_areas = cJSON_GetObjectItemCaseSensitive(plmn_restrictionJSON, "forbiddenAreas"); |
235 | 0 | if (forbidden_areas) { |
236 | 0 | cJSON *forbidden_areas_local = NULL; |
237 | 0 | if (!cJSON_IsArray(forbidden_areas)) { |
238 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [forbidden_areas]"); |
239 | 0 | goto end; |
240 | 0 | } |
241 | | |
242 | 0 | forbidden_areasList = OpenAPI_list_create(); |
243 | |
|
244 | 0 | cJSON_ArrayForEach(forbidden_areas_local, forbidden_areas) { |
245 | 0 | if (!cJSON_IsObject(forbidden_areas_local)) { |
246 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [forbidden_areas]"); |
247 | 0 | goto end; |
248 | 0 | } |
249 | 0 | OpenAPI_area_t *forbidden_areasItem = OpenAPI_area_parseFromJSON(forbidden_areas_local); |
250 | 0 | if (!forbidden_areasItem) { |
251 | 0 | ogs_error("No forbidden_areasItem"); |
252 | 0 | goto end; |
253 | 0 | } |
254 | 0 | OpenAPI_list_add(forbidden_areasList, forbidden_areasItem); |
255 | 0 | } |
256 | 0 | } |
257 | | |
258 | 0 | service_area_restriction = cJSON_GetObjectItemCaseSensitive(plmn_restrictionJSON, "serviceAreaRestriction"); |
259 | 0 | if (service_area_restriction) { |
260 | 0 | service_area_restriction_local_nonprim = OpenAPI_service_area_restriction_parseFromJSON(service_area_restriction); |
261 | 0 | if (!service_area_restriction_local_nonprim) { |
262 | 0 | ogs_error("OpenAPI_service_area_restriction_parseFromJSON failed [service_area_restriction]"); |
263 | 0 | goto end; |
264 | 0 | } |
265 | 0 | } |
266 | | |
267 | 0 | core_network_type_restrictions = cJSON_GetObjectItemCaseSensitive(plmn_restrictionJSON, "coreNetworkTypeRestrictions"); |
268 | 0 | if (core_network_type_restrictions) { |
269 | 0 | cJSON *core_network_type_restrictions_local = NULL; |
270 | 0 | if (!cJSON_IsArray(core_network_type_restrictions)) { |
271 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [core_network_type_restrictions]"); |
272 | 0 | goto end; |
273 | 0 | } |
274 | | |
275 | 0 | core_network_type_restrictionsList = OpenAPI_list_create(); |
276 | |
|
277 | 0 | cJSON_ArrayForEach(core_network_type_restrictions_local, core_network_type_restrictions) { |
278 | 0 | OpenAPI_core_network_type_e localEnum = OpenAPI_core_network_type_NULL; |
279 | 0 | if (!cJSON_IsString(core_network_type_restrictions_local)) { |
280 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [core_network_type_restrictions]"); |
281 | 0 | goto end; |
282 | 0 | } |
283 | 0 | localEnum = OpenAPI_core_network_type_FromString(core_network_type_restrictions_local->valuestring); |
284 | 0 | if (!localEnum) { |
285 | 0 | ogs_info("Enum value \"%s\" for field \"core_network_type_restrictions\" is not supported. Ignoring it ...", |
286 | 0 | core_network_type_restrictions_local->valuestring); |
287 | 0 | } else { |
288 | 0 | OpenAPI_list_add(core_network_type_restrictionsList, (void *)localEnum); |
289 | 0 | } |
290 | 0 | } |
291 | 0 | if (core_network_type_restrictionsList->count == 0) { |
292 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed: Expected core_network_type_restrictionsList to not be empty (after ignoring unsupported enum values)."); |
293 | 0 | goto end; |
294 | 0 | } |
295 | 0 | } |
296 | | |
297 | 0 | access_type_restrictions = cJSON_GetObjectItemCaseSensitive(plmn_restrictionJSON, "accessTypeRestrictions"); |
298 | 0 | if (access_type_restrictions) { |
299 | 0 | cJSON *access_type_restrictions_local = NULL; |
300 | 0 | if (!cJSON_IsArray(access_type_restrictions)) { |
301 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [access_type_restrictions]"); |
302 | 0 | goto end; |
303 | 0 | } |
304 | | |
305 | 0 | access_type_restrictionsList = OpenAPI_list_create(); |
306 | |
|
307 | 0 | cJSON_ArrayForEach(access_type_restrictions_local, access_type_restrictions) { |
308 | 0 | OpenAPI_access_type_e localEnum = OpenAPI_access_type_NULL; |
309 | 0 | if (!cJSON_IsString(access_type_restrictions_local)) { |
310 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [access_type_restrictions]"); |
311 | 0 | goto end; |
312 | 0 | } |
313 | 0 | localEnum = OpenAPI_access_type_FromString(access_type_restrictions_local->valuestring); |
314 | 0 | if (!localEnum) { |
315 | 0 | ogs_info("Enum value \"%s\" for field \"access_type_restrictions\" is not supported. Ignoring it ...", |
316 | 0 | access_type_restrictions_local->valuestring); |
317 | 0 | } else { |
318 | 0 | OpenAPI_list_add(access_type_restrictionsList, (void *)localEnum); |
319 | 0 | } |
320 | 0 | } |
321 | 0 | if (access_type_restrictionsList->count == 0) { |
322 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed: Expected access_type_restrictionsList to not be empty (after ignoring unsupported enum values)."); |
323 | 0 | goto end; |
324 | 0 | } |
325 | 0 | } |
326 | | |
327 | 0 | primary_rat_restrictions = cJSON_GetObjectItemCaseSensitive(plmn_restrictionJSON, "primaryRatRestrictions"); |
328 | 0 | if (primary_rat_restrictions) { |
329 | 0 | cJSON *primary_rat_restrictions_local = NULL; |
330 | 0 | if (!cJSON_IsArray(primary_rat_restrictions)) { |
331 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [primary_rat_restrictions]"); |
332 | 0 | goto end; |
333 | 0 | } |
334 | | |
335 | 0 | primary_rat_restrictionsList = OpenAPI_list_create(); |
336 | |
|
337 | 0 | cJSON_ArrayForEach(primary_rat_restrictions_local, primary_rat_restrictions) { |
338 | 0 | OpenAPI_rat_type_e localEnum = OpenAPI_rat_type_NULL; |
339 | 0 | if (!cJSON_IsString(primary_rat_restrictions_local)) { |
340 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [primary_rat_restrictions]"); |
341 | 0 | goto end; |
342 | 0 | } |
343 | 0 | localEnum = OpenAPI_rat_type_FromString(primary_rat_restrictions_local->valuestring); |
344 | 0 | if (!localEnum) { |
345 | 0 | ogs_info("Enum value \"%s\" for field \"primary_rat_restrictions\" is not supported. Ignoring it ...", |
346 | 0 | primary_rat_restrictions_local->valuestring); |
347 | 0 | } else { |
348 | 0 | OpenAPI_list_add(primary_rat_restrictionsList, (void *)localEnum); |
349 | 0 | } |
350 | 0 | } |
351 | 0 | if (primary_rat_restrictionsList->count == 0) { |
352 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed: Expected primary_rat_restrictionsList to not be empty (after ignoring unsupported enum values)."); |
353 | 0 | goto end; |
354 | 0 | } |
355 | 0 | } |
356 | | |
357 | 0 | secondary_rat_restrictions = cJSON_GetObjectItemCaseSensitive(plmn_restrictionJSON, "secondaryRatRestrictions"); |
358 | 0 | if (secondary_rat_restrictions) { |
359 | 0 | cJSON *secondary_rat_restrictions_local = NULL; |
360 | 0 | if (!cJSON_IsArray(secondary_rat_restrictions)) { |
361 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [secondary_rat_restrictions]"); |
362 | 0 | goto end; |
363 | 0 | } |
364 | | |
365 | 0 | secondary_rat_restrictionsList = OpenAPI_list_create(); |
366 | |
|
367 | 0 | cJSON_ArrayForEach(secondary_rat_restrictions_local, secondary_rat_restrictions) { |
368 | 0 | OpenAPI_rat_type_e localEnum = OpenAPI_rat_type_NULL; |
369 | 0 | if (!cJSON_IsString(secondary_rat_restrictions_local)) { |
370 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed [secondary_rat_restrictions]"); |
371 | 0 | goto end; |
372 | 0 | } |
373 | 0 | localEnum = OpenAPI_rat_type_FromString(secondary_rat_restrictions_local->valuestring); |
374 | 0 | if (!localEnum) { |
375 | 0 | ogs_info("Enum value \"%s\" for field \"secondary_rat_restrictions\" is not supported. Ignoring it ...", |
376 | 0 | secondary_rat_restrictions_local->valuestring); |
377 | 0 | } else { |
378 | 0 | OpenAPI_list_add(secondary_rat_restrictionsList, (void *)localEnum); |
379 | 0 | } |
380 | 0 | } |
381 | 0 | if (secondary_rat_restrictionsList->count == 0) { |
382 | 0 | ogs_error("OpenAPI_plmn_restriction_parseFromJSON() failed: Expected secondary_rat_restrictionsList to not be empty (after ignoring unsupported enum values)."); |
383 | 0 | goto end; |
384 | 0 | } |
385 | 0 | } |
386 | | |
387 | 0 | plmn_restriction_local_var = OpenAPI_plmn_restriction_create ( |
388 | 0 | rat_restrictions ? rat_restrictionsList : NULL, |
389 | 0 | forbidden_areas ? forbidden_areasList : NULL, |
390 | 0 | service_area_restriction ? service_area_restriction_local_nonprim : NULL, |
391 | 0 | core_network_type_restrictions ? core_network_type_restrictionsList : NULL, |
392 | 0 | access_type_restrictions ? access_type_restrictionsList : NULL, |
393 | 0 | primary_rat_restrictions ? primary_rat_restrictionsList : NULL, |
394 | 0 | secondary_rat_restrictions ? secondary_rat_restrictionsList : NULL |
395 | 0 | ); |
396 | |
|
397 | 0 | return plmn_restriction_local_var; |
398 | 0 | end: |
399 | 0 | if (rat_restrictionsList) { |
400 | 0 | OpenAPI_list_free(rat_restrictionsList); |
401 | 0 | rat_restrictionsList = NULL; |
402 | 0 | } |
403 | 0 | if (forbidden_areasList) { |
404 | 0 | OpenAPI_list_for_each(forbidden_areasList, node) { |
405 | 0 | OpenAPI_area_free(node->data); |
406 | 0 | } |
407 | 0 | OpenAPI_list_free(forbidden_areasList); |
408 | 0 | forbidden_areasList = NULL; |
409 | 0 | } |
410 | 0 | if (service_area_restriction_local_nonprim) { |
411 | 0 | OpenAPI_service_area_restriction_free(service_area_restriction_local_nonprim); |
412 | 0 | service_area_restriction_local_nonprim = NULL; |
413 | 0 | } |
414 | 0 | if (core_network_type_restrictionsList) { |
415 | 0 | OpenAPI_list_free(core_network_type_restrictionsList); |
416 | 0 | core_network_type_restrictionsList = NULL; |
417 | 0 | } |
418 | 0 | if (access_type_restrictionsList) { |
419 | 0 | OpenAPI_list_free(access_type_restrictionsList); |
420 | 0 | access_type_restrictionsList = NULL; |
421 | 0 | } |
422 | 0 | if (primary_rat_restrictionsList) { |
423 | 0 | OpenAPI_list_free(primary_rat_restrictionsList); |
424 | 0 | primary_rat_restrictionsList = NULL; |
425 | 0 | } |
426 | 0 | if (secondary_rat_restrictionsList) { |
427 | 0 | OpenAPI_list_free(secondary_rat_restrictionsList); |
428 | 0 | secondary_rat_restrictionsList = NULL; |
429 | 0 | } |
430 | 0 | return NULL; |
431 | 0 | } |
432 | | |
433 | | OpenAPI_plmn_restriction_t *OpenAPI_plmn_restriction_copy(OpenAPI_plmn_restriction_t *dst, OpenAPI_plmn_restriction_t *src) |
434 | 0 | { |
435 | 0 | cJSON *item = NULL; |
436 | 0 | char *content = NULL; |
437 | |
|
438 | 0 | ogs_assert(src); |
439 | 0 | item = OpenAPI_plmn_restriction_convertToJSON(src); |
440 | 0 | if (!item) { |
441 | 0 | ogs_error("OpenAPI_plmn_restriction_convertToJSON() failed"); |
442 | 0 | return NULL; |
443 | 0 | } |
444 | | |
445 | 0 | content = cJSON_Print(item); |
446 | 0 | cJSON_Delete(item); |
447 | |
|
448 | 0 | if (!content) { |
449 | 0 | ogs_error("cJSON_Print() failed"); |
450 | 0 | return NULL; |
451 | 0 | } |
452 | | |
453 | 0 | item = cJSON_Parse(content); |
454 | 0 | ogs_free(content); |
455 | 0 | if (!item) { |
456 | 0 | ogs_error("cJSON_Parse() failed"); |
457 | 0 | return NULL; |
458 | 0 | } |
459 | | |
460 | 0 | OpenAPI_plmn_restriction_free(dst); |
461 | 0 | dst = OpenAPI_plmn_restriction_parseFromJSON(item); |
462 | 0 | cJSON_Delete(item); |
463 | |
|
464 | 0 | return dst; |
465 | 0 | } |
466 | | |