Coverage Report

Created: 2026-06-30 06:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/selection_conditions.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "selection_conditions.h"
6
7
OpenAPI_selection_conditions_t *OpenAPI_selection_conditions_create(
8
    OpenAPI_list_t *consumer_nf_types,
9
    bool is_service_feature,
10
    int service_feature,
11
    bool is_vs_service_feature,
12
    int vs_service_feature,
13
    OpenAPI_list_t *supi_range_list,
14
    OpenAPI_list_t *gpsi_range_list,
15
    OpenAPI_list_t *impu_range_list,
16
    OpenAPI_list_t *impi_range_list,
17
    OpenAPI_list_t *pei_list,
18
    OpenAPI_list_t *tai_range_list,
19
    OpenAPI_list_t *dnn_list,
20
    OpenAPI_list_t *_and,
21
    OpenAPI_list_t *_or
22
)
23
2
{
24
2
    OpenAPI_selection_conditions_t *selection_conditions_local_var = ogs_malloc(sizeof(OpenAPI_selection_conditions_t));
25
2
    ogs_assert(selection_conditions_local_var);
26
27
2
    selection_conditions_local_var->consumer_nf_types = consumer_nf_types;
28
2
    selection_conditions_local_var->is_service_feature = is_service_feature;
29
2
    selection_conditions_local_var->service_feature = service_feature;
30
2
    selection_conditions_local_var->is_vs_service_feature = is_vs_service_feature;
31
2
    selection_conditions_local_var->vs_service_feature = vs_service_feature;
32
2
    selection_conditions_local_var->supi_range_list = supi_range_list;
33
2
    selection_conditions_local_var->gpsi_range_list = gpsi_range_list;
34
2
    selection_conditions_local_var->impu_range_list = impu_range_list;
35
2
    selection_conditions_local_var->impi_range_list = impi_range_list;
36
2
    selection_conditions_local_var->pei_list = pei_list;
37
2
    selection_conditions_local_var->tai_range_list = tai_range_list;
38
2
    selection_conditions_local_var->dnn_list = dnn_list;
39
2
    selection_conditions_local_var->_and = _and;
40
2
    selection_conditions_local_var->_or = _or;
41
42
2
    return selection_conditions_local_var;
43
2
}
44
45
void OpenAPI_selection_conditions_free(OpenAPI_selection_conditions_t *selection_conditions)
46
2
{
47
2
    OpenAPI_lnode_t *node = NULL;
48
49
2
    if (NULL == selection_conditions) {
50
0
        return;
51
0
    }
52
2
    if (selection_conditions->consumer_nf_types) {
53
0
        OpenAPI_list_free(selection_conditions->consumer_nf_types);
54
0
        selection_conditions->consumer_nf_types = NULL;
55
0
    }
56
2
    if (selection_conditions->supi_range_list) {
57
0
        OpenAPI_list_for_each(selection_conditions->supi_range_list, node) {
58
0
            OpenAPI_supi_range_free(node->data);
59
0
        }
60
0
        OpenAPI_list_free(selection_conditions->supi_range_list);
61
0
        selection_conditions->supi_range_list = NULL;
62
0
    }
63
2
    if (selection_conditions->gpsi_range_list) {
64
0
        OpenAPI_list_for_each(selection_conditions->gpsi_range_list, node) {
65
0
            OpenAPI_identity_range_free(node->data);
66
0
        }
67
0
        OpenAPI_list_free(selection_conditions->gpsi_range_list);
68
0
        selection_conditions->gpsi_range_list = NULL;
69
0
    }
70
2
    if (selection_conditions->impu_range_list) {
71
0
        OpenAPI_list_for_each(selection_conditions->impu_range_list, node) {
72
0
            OpenAPI_identity_range_free(node->data);
73
0
        }
74
0
        OpenAPI_list_free(selection_conditions->impu_range_list);
75
0
        selection_conditions->impu_range_list = NULL;
76
0
    }
77
2
    if (selection_conditions->impi_range_list) {
78
0
        OpenAPI_list_for_each(selection_conditions->impi_range_list, node) {
79
0
            OpenAPI_identity_range_free(node->data);
80
0
        }
81
0
        OpenAPI_list_free(selection_conditions->impi_range_list);
82
0
        selection_conditions->impi_range_list = NULL;
83
0
    }
84
2
    if (selection_conditions->pei_list) {
85
0
        OpenAPI_list_for_each(selection_conditions->pei_list, node) {
86
0
            ogs_free(node->data);
87
0
        }
88
0
        OpenAPI_list_free(selection_conditions->pei_list);
89
0
        selection_conditions->pei_list = NULL;
90
0
    }
91
2
    if (selection_conditions->tai_range_list) {
92
0
        OpenAPI_list_for_each(selection_conditions->tai_range_list, node) {
93
0
            OpenAPI_tai_range_free(node->data);
94
0
        }
95
0
        OpenAPI_list_free(selection_conditions->tai_range_list);
96
0
        selection_conditions->tai_range_list = NULL;
97
0
    }
98
2
    if (selection_conditions->dnn_list) {
99
0
        OpenAPI_list_for_each(selection_conditions->dnn_list, node) {
100
0
            ogs_free(node->data);
101
0
        }
102
0
        OpenAPI_list_free(selection_conditions->dnn_list);
103
0
        selection_conditions->dnn_list = NULL;
104
0
    }
105
2
    if (selection_conditions->_and) {
106
0
        OpenAPI_list_for_each(selection_conditions->_and, node) {
107
0
            OpenAPI_selection_conditions_free(node->data);
108
0
        }
109
0
        OpenAPI_list_free(selection_conditions->_and);
110
0
        selection_conditions->_and = NULL;
111
0
    }
112
2
    if (selection_conditions->_or) {
113
0
        OpenAPI_list_for_each(selection_conditions->_or, node) {
114
0
            OpenAPI_selection_conditions_free(node->data);
115
0
        }
116
0
        OpenAPI_list_free(selection_conditions->_or);
117
0
        selection_conditions->_or = NULL;
118
0
    }
119
2
    ogs_free(selection_conditions);
120
2
}
121
122
cJSON *OpenAPI_selection_conditions_convertToJSON(OpenAPI_selection_conditions_t *selection_conditions)
123
0
{
124
0
    cJSON *item = NULL;
125
0
    OpenAPI_lnode_t *node = NULL;
126
127
0
    if (selection_conditions == NULL) {
128
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [SelectionConditions]");
129
0
        return NULL;
130
0
    }
131
132
0
    item = cJSON_CreateObject();
133
0
    if (selection_conditions->consumer_nf_types != OpenAPI_nf_type_NULL) {
134
0
    cJSON *consumer_nf_typesList = cJSON_AddArrayToObject(item, "consumerNfTypes");
135
0
    if (consumer_nf_typesList == NULL) {
136
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [consumer_nf_types]");
137
0
        goto end;
138
0
    }
139
0
    OpenAPI_list_for_each(selection_conditions->consumer_nf_types, node) {
140
0
        if (cJSON_AddStringToObject(consumer_nf_typesList, "", OpenAPI_nf_type_ToString((intptr_t)node->data)) == NULL) {
141
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [consumer_nf_types]");
142
0
            goto end;
143
0
        }
144
0
    }
145
0
    }
146
147
0
    if (selection_conditions->is_service_feature) {
148
0
    if (cJSON_AddNumberToObject(item, "serviceFeature", selection_conditions->service_feature) == NULL) {
149
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [service_feature]");
150
0
        goto end;
151
0
    }
152
0
    }
153
154
0
    if (selection_conditions->is_vs_service_feature) {
155
0
    if (cJSON_AddNumberToObject(item, "vsServiceFeature", selection_conditions->vs_service_feature) == NULL) {
156
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [vs_service_feature]");
157
0
        goto end;
158
0
    }
159
0
    }
160
161
0
    if (selection_conditions->supi_range_list) {
162
0
    cJSON *supi_range_listList = cJSON_AddArrayToObject(item, "supiRangeList");
163
0
    if (supi_range_listList == NULL) {
164
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [supi_range_list]");
165
0
        goto end;
166
0
    }
167
0
    OpenAPI_list_for_each(selection_conditions->supi_range_list, node) {
168
0
        cJSON *itemLocal = OpenAPI_supi_range_convertToJSON(node->data);
169
0
        if (itemLocal == NULL) {
170
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [supi_range_list]");
171
0
            goto end;
172
0
        }
173
0
        cJSON_AddItemToArray(supi_range_listList, itemLocal);
174
0
    }
175
0
    }
176
177
0
    if (selection_conditions->gpsi_range_list) {
178
0
    cJSON *gpsi_range_listList = cJSON_AddArrayToObject(item, "gpsiRangeList");
179
0
    if (gpsi_range_listList == NULL) {
180
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [gpsi_range_list]");
181
0
        goto end;
182
0
    }
183
0
    OpenAPI_list_for_each(selection_conditions->gpsi_range_list, node) {
184
0
        cJSON *itemLocal = OpenAPI_identity_range_convertToJSON(node->data);
185
0
        if (itemLocal == NULL) {
186
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [gpsi_range_list]");
187
0
            goto end;
188
0
        }
189
0
        cJSON_AddItemToArray(gpsi_range_listList, itemLocal);
190
0
    }
191
0
    }
192
193
0
    if (selection_conditions->impu_range_list) {
194
0
    cJSON *impu_range_listList = cJSON_AddArrayToObject(item, "impuRangeList");
195
0
    if (impu_range_listList == NULL) {
196
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [impu_range_list]");
197
0
        goto end;
198
0
    }
199
0
    OpenAPI_list_for_each(selection_conditions->impu_range_list, node) {
200
0
        cJSON *itemLocal = OpenAPI_identity_range_convertToJSON(node->data);
201
0
        if (itemLocal == NULL) {
202
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [impu_range_list]");
203
0
            goto end;
204
0
        }
205
0
        cJSON_AddItemToArray(impu_range_listList, itemLocal);
206
0
    }
207
0
    }
208
209
0
    if (selection_conditions->impi_range_list) {
210
0
    cJSON *impi_range_listList = cJSON_AddArrayToObject(item, "impiRangeList");
211
0
    if (impi_range_listList == NULL) {
212
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [impi_range_list]");
213
0
        goto end;
214
0
    }
215
0
    OpenAPI_list_for_each(selection_conditions->impi_range_list, node) {
216
0
        cJSON *itemLocal = OpenAPI_identity_range_convertToJSON(node->data);
217
0
        if (itemLocal == NULL) {
218
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [impi_range_list]");
219
0
            goto end;
220
0
        }
221
0
        cJSON_AddItemToArray(impi_range_listList, itemLocal);
222
0
    }
223
0
    }
224
225
0
    if (selection_conditions->pei_list) {
226
0
    cJSON *pei_listList = cJSON_AddArrayToObject(item, "peiList");
227
0
    if (pei_listList == NULL) {
228
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [pei_list]");
229
0
        goto end;
230
0
    }
231
0
    OpenAPI_list_for_each(selection_conditions->pei_list, node) {
232
0
        if (cJSON_AddStringToObject(pei_listList, "", (char*)node->data) == NULL) {
233
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [pei_list]");
234
0
            goto end;
235
0
        }
236
0
    }
237
0
    }
238
239
0
    if (selection_conditions->tai_range_list) {
240
0
    cJSON *tai_range_listList = cJSON_AddArrayToObject(item, "taiRangeList");
241
0
    if (tai_range_listList == NULL) {
242
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [tai_range_list]");
243
0
        goto end;
244
0
    }
245
0
    OpenAPI_list_for_each(selection_conditions->tai_range_list, node) {
246
0
        cJSON *itemLocal = OpenAPI_tai_range_convertToJSON(node->data);
247
0
        if (itemLocal == NULL) {
248
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [tai_range_list]");
249
0
            goto end;
250
0
        }
251
0
        cJSON_AddItemToArray(tai_range_listList, itemLocal);
252
0
    }
253
0
    }
254
255
0
    if (selection_conditions->dnn_list) {
256
0
    cJSON *dnn_listList = cJSON_AddArrayToObject(item, "dnnList");
257
0
    if (dnn_listList == NULL) {
258
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [dnn_list]");
259
0
        goto end;
260
0
    }
261
0
    OpenAPI_list_for_each(selection_conditions->dnn_list, node) {
262
0
        if (cJSON_AddStringToObject(dnn_listList, "", (char*)node->data) == NULL) {
263
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [dnn_list]");
264
0
            goto end;
265
0
        }
266
0
    }
267
0
    }
268
269
0
    if (selection_conditions->_and) {
270
0
    cJSON *_andList = cJSON_AddArrayToObject(item, "and");
271
0
    if (_andList == NULL) {
272
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [_and]");
273
0
        goto end;
274
0
    }
275
0
    OpenAPI_list_for_each(selection_conditions->_and, node) {
276
0
        cJSON *itemLocal = OpenAPI_selection_conditions_convertToJSON(node->data);
277
0
        if (itemLocal == NULL) {
278
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [_and]");
279
0
            goto end;
280
0
        }
281
0
        cJSON_AddItemToArray(_andList, itemLocal);
282
0
    }
283
0
    }
284
285
0
    if (selection_conditions->_or) {
286
0
    cJSON *_orList = cJSON_AddArrayToObject(item, "or");
287
0
    if (_orList == NULL) {
288
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [_or]");
289
0
        goto end;
290
0
    }
291
0
    OpenAPI_list_for_each(selection_conditions->_or, node) {
292
0
        cJSON *itemLocal = OpenAPI_selection_conditions_convertToJSON(node->data);
293
0
        if (itemLocal == NULL) {
294
0
            ogs_error("OpenAPI_selection_conditions_convertToJSON() failed [_or]");
295
0
            goto end;
296
0
        }
297
0
        cJSON_AddItemToArray(_orList, itemLocal);
298
0
    }
299
0
    }
300
301
0
end:
302
0
    return item;
303
0
}
304
305
OpenAPI_selection_conditions_t *OpenAPI_selection_conditions_parseFromJSON(cJSON *selection_conditionsJSON)
306
2
{
307
2
    OpenAPI_selection_conditions_t *selection_conditions_local_var = NULL;
308
2
    OpenAPI_lnode_t *node = NULL;
309
2
    cJSON *consumer_nf_types = NULL;
310
2
    OpenAPI_list_t *consumer_nf_typesList = NULL;
311
2
    cJSON *service_feature = NULL;
312
2
    cJSON *vs_service_feature = NULL;
313
2
    cJSON *supi_range_list = NULL;
314
2
    OpenAPI_list_t *supi_range_listList = NULL;
315
2
    cJSON *gpsi_range_list = NULL;
316
2
    OpenAPI_list_t *gpsi_range_listList = NULL;
317
2
    cJSON *impu_range_list = NULL;
318
2
    OpenAPI_list_t *impu_range_listList = NULL;
319
2
    cJSON *impi_range_list = NULL;
320
2
    OpenAPI_list_t *impi_range_listList = NULL;
321
2
    cJSON *pei_list = NULL;
322
2
    OpenAPI_list_t *pei_listList = NULL;
323
2
    cJSON *tai_range_list = NULL;
324
2
    OpenAPI_list_t *tai_range_listList = NULL;
325
2
    cJSON *dnn_list = NULL;
326
2
    OpenAPI_list_t *dnn_listList = NULL;
327
2
    cJSON *_and = NULL;
328
2
    OpenAPI_list_t *_andList = NULL;
329
2
    cJSON *_or = NULL;
330
2
    OpenAPI_list_t *_orList = NULL;
331
2
    consumer_nf_types = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "consumerNfTypes");
332
2
    if (consumer_nf_types) {
333
0
        cJSON *consumer_nf_types_local = NULL;
334
0
        if (!cJSON_IsArray(consumer_nf_types)) {
335
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [consumer_nf_types]");
336
0
            goto end;
337
0
        }
338
339
0
        consumer_nf_typesList = OpenAPI_list_create();
340
341
0
        cJSON_ArrayForEach(consumer_nf_types_local, consumer_nf_types) {
342
0
            OpenAPI_nf_type_e localEnum = OpenAPI_nf_type_NULL;
343
0
            if (!cJSON_IsString(consumer_nf_types_local)) {
344
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [consumer_nf_types]");
345
0
                goto end;
346
0
            }
347
0
            localEnum = OpenAPI_nf_type_FromString(consumer_nf_types_local->valuestring);
348
0
            if (!localEnum) {
349
0
                ogs_info("Enum value \"%s\" for field \"consumer_nf_types\" is not supported. Ignoring it ...",
350
0
                         consumer_nf_types_local->valuestring);
351
0
            } else {
352
0
                OpenAPI_list_add(consumer_nf_typesList, (void *)localEnum);
353
0
            }
354
0
        }
355
0
        if (consumer_nf_typesList->count == 0) {
356
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed: Expected consumer_nf_typesList to not be empty (after ignoring unsupported enum values).");
357
0
            goto end;
358
0
        }
359
0
    }
360
361
2
    service_feature = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "serviceFeature");
362
2
    if (service_feature) {
363
0
    if (!cJSON_IsNumber(service_feature)) {
364
0
        ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [service_feature]");
365
0
        goto end;
366
0
    }
367
0
    }
368
369
2
    vs_service_feature = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "vsServiceFeature");
370
2
    if (vs_service_feature) {
371
0
    if (!cJSON_IsNumber(vs_service_feature)) {
372
0
        ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [vs_service_feature]");
373
0
        goto end;
374
0
    }
375
0
    }
376
377
2
    supi_range_list = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "supiRangeList");
378
2
    if (supi_range_list) {
379
0
        cJSON *supi_range_list_local = NULL;
380
0
        if (!cJSON_IsArray(supi_range_list)) {
381
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [supi_range_list]");
382
0
            goto end;
383
0
        }
384
385
0
        supi_range_listList = OpenAPI_list_create();
386
387
0
        cJSON_ArrayForEach(supi_range_list_local, supi_range_list) {
388
0
            if (!cJSON_IsObject(supi_range_list_local)) {
389
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [supi_range_list]");
390
0
                goto end;
391
0
            }
392
0
            OpenAPI_supi_range_t *supi_range_listItem = OpenAPI_supi_range_parseFromJSON(supi_range_list_local);
393
0
            if (!supi_range_listItem) {
394
0
                ogs_error("No supi_range_listItem");
395
0
                goto end;
396
0
            }
397
0
            OpenAPI_list_add(supi_range_listList, supi_range_listItem);
398
0
        }
399
0
    }
400
401
2
    gpsi_range_list = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "gpsiRangeList");
402
2
    if (gpsi_range_list) {
403
0
        cJSON *gpsi_range_list_local = NULL;
404
0
        if (!cJSON_IsArray(gpsi_range_list)) {
405
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [gpsi_range_list]");
406
0
            goto end;
407
0
        }
408
409
0
        gpsi_range_listList = OpenAPI_list_create();
410
411
0
        cJSON_ArrayForEach(gpsi_range_list_local, gpsi_range_list) {
412
0
            if (!cJSON_IsObject(gpsi_range_list_local)) {
413
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [gpsi_range_list]");
414
0
                goto end;
415
0
            }
416
0
            OpenAPI_identity_range_t *gpsi_range_listItem = OpenAPI_identity_range_parseFromJSON(gpsi_range_list_local);
417
0
            if (!gpsi_range_listItem) {
418
0
                ogs_error("No gpsi_range_listItem");
419
0
                goto end;
420
0
            }
421
0
            OpenAPI_list_add(gpsi_range_listList, gpsi_range_listItem);
422
0
        }
423
0
    }
424
425
2
    impu_range_list = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "impuRangeList");
426
2
    if (impu_range_list) {
427
0
        cJSON *impu_range_list_local = NULL;
428
0
        if (!cJSON_IsArray(impu_range_list)) {
429
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [impu_range_list]");
430
0
            goto end;
431
0
        }
432
433
0
        impu_range_listList = OpenAPI_list_create();
434
435
0
        cJSON_ArrayForEach(impu_range_list_local, impu_range_list) {
436
0
            if (!cJSON_IsObject(impu_range_list_local)) {
437
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [impu_range_list]");
438
0
                goto end;
439
0
            }
440
0
            OpenAPI_identity_range_t *impu_range_listItem = OpenAPI_identity_range_parseFromJSON(impu_range_list_local);
441
0
            if (!impu_range_listItem) {
442
0
                ogs_error("No impu_range_listItem");
443
0
                goto end;
444
0
            }
445
0
            OpenAPI_list_add(impu_range_listList, impu_range_listItem);
446
0
        }
447
0
    }
448
449
2
    impi_range_list = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "impiRangeList");
450
2
    if (impi_range_list) {
451
0
        cJSON *impi_range_list_local = NULL;
452
0
        if (!cJSON_IsArray(impi_range_list)) {
453
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [impi_range_list]");
454
0
            goto end;
455
0
        }
456
457
0
        impi_range_listList = OpenAPI_list_create();
458
459
0
        cJSON_ArrayForEach(impi_range_list_local, impi_range_list) {
460
0
            if (!cJSON_IsObject(impi_range_list_local)) {
461
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [impi_range_list]");
462
0
                goto end;
463
0
            }
464
0
            OpenAPI_identity_range_t *impi_range_listItem = OpenAPI_identity_range_parseFromJSON(impi_range_list_local);
465
0
            if (!impi_range_listItem) {
466
0
                ogs_error("No impi_range_listItem");
467
0
                goto end;
468
0
            }
469
0
            OpenAPI_list_add(impi_range_listList, impi_range_listItem);
470
0
        }
471
0
    }
472
473
2
    pei_list = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "peiList");
474
2
    if (pei_list) {
475
0
        cJSON *pei_list_local = NULL;
476
0
        if (!cJSON_IsArray(pei_list)) {
477
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [pei_list]");
478
0
            goto end;
479
0
        }
480
481
0
        pei_listList = OpenAPI_list_create();
482
483
0
        cJSON_ArrayForEach(pei_list_local, pei_list) {
484
0
            double *localDouble = NULL;
485
0
            int *localInt = NULL;
486
0
            if (!cJSON_IsString(pei_list_local)) {
487
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [pei_list]");
488
0
                goto end;
489
0
            }
490
0
            OpenAPI_list_add(pei_listList, ogs_strdup(pei_list_local->valuestring));
491
0
        }
492
0
    }
493
494
2
    tai_range_list = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "taiRangeList");
495
2
    if (tai_range_list) {
496
0
        cJSON *tai_range_list_local = NULL;
497
0
        if (!cJSON_IsArray(tai_range_list)) {
498
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [tai_range_list]");
499
0
            goto end;
500
0
        }
501
502
0
        tai_range_listList = OpenAPI_list_create();
503
504
0
        cJSON_ArrayForEach(tai_range_list_local, tai_range_list) {
505
0
            if (!cJSON_IsObject(tai_range_list_local)) {
506
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [tai_range_list]");
507
0
                goto end;
508
0
            }
509
0
            OpenAPI_tai_range_t *tai_range_listItem = OpenAPI_tai_range_parseFromJSON(tai_range_list_local);
510
0
            if (!tai_range_listItem) {
511
0
                ogs_error("No tai_range_listItem");
512
0
                goto end;
513
0
            }
514
0
            OpenAPI_list_add(tai_range_listList, tai_range_listItem);
515
0
        }
516
0
    }
517
518
2
    dnn_list = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "dnnList");
519
2
    if (dnn_list) {
520
0
        cJSON *dnn_list_local = NULL;
521
0
        if (!cJSON_IsArray(dnn_list)) {
522
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [dnn_list]");
523
0
            goto end;
524
0
        }
525
526
0
        dnn_listList = OpenAPI_list_create();
527
528
0
        cJSON_ArrayForEach(dnn_list_local, dnn_list) {
529
0
            double *localDouble = NULL;
530
0
            int *localInt = NULL;
531
0
            if (!cJSON_IsString(dnn_list_local)) {
532
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [dnn_list]");
533
0
                goto end;
534
0
            }
535
0
            OpenAPI_list_add(dnn_listList, ogs_strdup(dnn_list_local->valuestring));
536
0
        }
537
0
    }
538
539
2
    _and = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "and");
540
2
    if (_and) {
541
0
        cJSON *_and_local = NULL;
542
0
        if (!cJSON_IsArray(_and)) {
543
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [_and]");
544
0
            goto end;
545
0
        }
546
547
0
        _andList = OpenAPI_list_create();
548
549
0
        cJSON_ArrayForEach(_and_local, _and) {
550
0
            if (!cJSON_IsObject(_and_local)) {
551
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [_and]");
552
0
                goto end;
553
0
            }
554
0
            OpenAPI_selection_conditions_t *_andItem = OpenAPI_selection_conditions_parseFromJSON(_and_local);
555
0
            if (!_andItem) {
556
0
                ogs_error("No _andItem");
557
0
                goto end;
558
0
            }
559
0
            OpenAPI_list_add(_andList, _andItem);
560
0
        }
561
0
    }
562
563
2
    _or = cJSON_GetObjectItemCaseSensitive(selection_conditionsJSON, "or");
564
2
    if (_or) {
565
0
        cJSON *_or_local = NULL;
566
0
        if (!cJSON_IsArray(_or)) {
567
0
            ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [_or]");
568
0
            goto end;
569
0
        }
570
571
0
        _orList = OpenAPI_list_create();
572
573
0
        cJSON_ArrayForEach(_or_local, _or) {
574
0
            if (!cJSON_IsObject(_or_local)) {
575
0
                ogs_error("OpenAPI_selection_conditions_parseFromJSON() failed [_or]");
576
0
                goto end;
577
0
            }
578
0
            OpenAPI_selection_conditions_t *_orItem = OpenAPI_selection_conditions_parseFromJSON(_or_local);
579
0
            if (!_orItem) {
580
0
                ogs_error("No _orItem");
581
0
                goto end;
582
0
            }
583
0
            OpenAPI_list_add(_orList, _orItem);
584
0
        }
585
0
    }
586
587
2
    selection_conditions_local_var = OpenAPI_selection_conditions_create (
588
2
        consumer_nf_types ? consumer_nf_typesList : NULL,
589
2
        service_feature ? true : false,
590
2
        service_feature ? service_feature->valuedouble : 0,
591
2
        vs_service_feature ? true : false,
592
2
        vs_service_feature ? vs_service_feature->valuedouble : 0,
593
2
        supi_range_list ? supi_range_listList : NULL,
594
2
        gpsi_range_list ? gpsi_range_listList : NULL,
595
2
        impu_range_list ? impu_range_listList : NULL,
596
2
        impi_range_list ? impi_range_listList : NULL,
597
2
        pei_list ? pei_listList : NULL,
598
2
        tai_range_list ? tai_range_listList : NULL,
599
2
        dnn_list ? dnn_listList : NULL,
600
2
        _and ? _andList : NULL,
601
2
        _or ? _orList : NULL
602
2
    );
603
604
2
    return selection_conditions_local_var;
605
0
end:
606
0
    if (consumer_nf_typesList) {
607
0
        OpenAPI_list_free(consumer_nf_typesList);
608
0
        consumer_nf_typesList = NULL;
609
0
    }
610
0
    if (supi_range_listList) {
611
0
        OpenAPI_list_for_each(supi_range_listList, node) {
612
0
            OpenAPI_supi_range_free(node->data);
613
0
        }
614
0
        OpenAPI_list_free(supi_range_listList);
615
0
        supi_range_listList = NULL;
616
0
    }
617
0
    if (gpsi_range_listList) {
618
0
        OpenAPI_list_for_each(gpsi_range_listList, node) {
619
0
            OpenAPI_identity_range_free(node->data);
620
0
        }
621
0
        OpenAPI_list_free(gpsi_range_listList);
622
0
        gpsi_range_listList = NULL;
623
0
    }
624
0
    if (impu_range_listList) {
625
0
        OpenAPI_list_for_each(impu_range_listList, node) {
626
0
            OpenAPI_identity_range_free(node->data);
627
0
        }
628
0
        OpenAPI_list_free(impu_range_listList);
629
0
        impu_range_listList = NULL;
630
0
    }
631
0
    if (impi_range_listList) {
632
0
        OpenAPI_list_for_each(impi_range_listList, node) {
633
0
            OpenAPI_identity_range_free(node->data);
634
0
        }
635
0
        OpenAPI_list_free(impi_range_listList);
636
0
        impi_range_listList = NULL;
637
0
    }
638
0
    if (pei_listList) {
639
0
        OpenAPI_list_for_each(pei_listList, node) {
640
0
            ogs_free(node->data);
641
0
        }
642
0
        OpenAPI_list_free(pei_listList);
643
0
        pei_listList = NULL;
644
0
    }
645
0
    if (tai_range_listList) {
646
0
        OpenAPI_list_for_each(tai_range_listList, node) {
647
0
            OpenAPI_tai_range_free(node->data);
648
0
        }
649
0
        OpenAPI_list_free(tai_range_listList);
650
0
        tai_range_listList = NULL;
651
0
    }
652
0
    if (dnn_listList) {
653
0
        OpenAPI_list_for_each(dnn_listList, node) {
654
0
            ogs_free(node->data);
655
0
        }
656
0
        OpenAPI_list_free(dnn_listList);
657
0
        dnn_listList = NULL;
658
0
    }
659
0
    if (_andList) {
660
0
        OpenAPI_list_for_each(_andList, node) {
661
0
            OpenAPI_selection_conditions_free(node->data);
662
0
        }
663
0
        OpenAPI_list_free(_andList);
664
0
        _andList = NULL;
665
0
    }
666
0
    if (_orList) {
667
0
        OpenAPI_list_for_each(_orList, node) {
668
0
            OpenAPI_selection_conditions_free(node->data);
669
0
        }
670
0
        OpenAPI_list_free(_orList);
671
0
        _orList = NULL;
672
0
    }
673
0
    return NULL;
674
2
}
675
676
OpenAPI_selection_conditions_t *OpenAPI_selection_conditions_copy(OpenAPI_selection_conditions_t *dst, OpenAPI_selection_conditions_t *src)
677
0
{
678
0
    cJSON *item = NULL;
679
0
    char *content = NULL;
680
681
0
    ogs_assert(src);
682
0
    item = OpenAPI_selection_conditions_convertToJSON(src);
683
0
    if (!item) {
684
0
        ogs_error("OpenAPI_selection_conditions_convertToJSON() failed");
685
0
        return NULL;
686
0
    }
687
688
0
    content = cJSON_Print(item);
689
0
    cJSON_Delete(item);
690
691
0
    if (!content) {
692
0
        ogs_error("cJSON_Print() failed");
693
0
        return NULL;
694
0
    }
695
696
0
    item = cJSON_Parse(content);
697
0
    ogs_free(content);
698
0
    if (!item) {
699
0
        ogs_error("cJSON_Parse() failed");
700
0
        return NULL;
701
0
    }
702
703
0
    OpenAPI_selection_conditions_free(dst);
704
0
    dst = OpenAPI_selection_conditions_parseFromJSON(item);
705
0
    cJSON_Delete(item);
706
707
0
    return dst;
708
0
}
709