Coverage Report

Created: 2026-07-14 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/authentication_info.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "authentication_info.h"
6
7
OpenAPI_authentication_info_t *OpenAPI_authentication_info_create(
8
    char *supi_or_suci,
9
    char *serving_network_name,
10
    OpenAPI_resynchronization_info_t *resynchronization_info,
11
    char *pei,
12
    bool is_trace_data_null,
13
    OpenAPI_trace_data_t *trace_data,
14
    char *udm_group_id,
15
    char *routing_indicator,
16
    OpenAPI_list_t *cell_cag_info,
17
    bool is_n5gc_ind,
18
    int n5gc_ind,
19
    char *supported_features,
20
    bool is_nswo_ind,
21
    int nswo_ind,
22
    bool is_disaster_roaming_ind,
23
    int disaster_roaming_ind,
24
    bool is_onboarding_ind,
25
    int onboarding_ind,
26
    bool is_aun3_ind,
27
    int aun3_ind
28
)
29
0
{
30
0
    OpenAPI_authentication_info_t *authentication_info_local_var = ogs_malloc(sizeof(OpenAPI_authentication_info_t));
31
0
    ogs_assert(authentication_info_local_var);
32
33
0
    authentication_info_local_var->supi_or_suci = supi_or_suci;
34
0
    authentication_info_local_var->serving_network_name = serving_network_name;
35
0
    authentication_info_local_var->resynchronization_info = resynchronization_info;
36
0
    authentication_info_local_var->pei = pei;
37
0
    authentication_info_local_var->is_trace_data_null = is_trace_data_null;
38
0
    authentication_info_local_var->trace_data = trace_data;
39
0
    authentication_info_local_var->udm_group_id = udm_group_id;
40
0
    authentication_info_local_var->routing_indicator = routing_indicator;
41
0
    authentication_info_local_var->cell_cag_info = cell_cag_info;
42
0
    authentication_info_local_var->is_n5gc_ind = is_n5gc_ind;
43
0
    authentication_info_local_var->n5gc_ind = n5gc_ind;
44
0
    authentication_info_local_var->supported_features = supported_features;
45
0
    authentication_info_local_var->is_nswo_ind = is_nswo_ind;
46
0
    authentication_info_local_var->nswo_ind = nswo_ind;
47
0
    authentication_info_local_var->is_disaster_roaming_ind = is_disaster_roaming_ind;
48
0
    authentication_info_local_var->disaster_roaming_ind = disaster_roaming_ind;
49
0
    authentication_info_local_var->is_onboarding_ind = is_onboarding_ind;
50
0
    authentication_info_local_var->onboarding_ind = onboarding_ind;
51
0
    authentication_info_local_var->is_aun3_ind = is_aun3_ind;
52
0
    authentication_info_local_var->aun3_ind = aun3_ind;
53
54
0
    return authentication_info_local_var;
55
0
}
56
57
void OpenAPI_authentication_info_free(OpenAPI_authentication_info_t *authentication_info)
58
0
{
59
0
    OpenAPI_lnode_t *node = NULL;
60
61
0
    if (NULL == authentication_info) {
62
0
        return;
63
0
    }
64
0
    if (authentication_info->supi_or_suci) {
65
0
        ogs_free(authentication_info->supi_or_suci);
66
0
        authentication_info->supi_or_suci = NULL;
67
0
    }
68
0
    if (authentication_info->serving_network_name) {
69
0
        ogs_free(authentication_info->serving_network_name);
70
0
        authentication_info->serving_network_name = NULL;
71
0
    }
72
0
    if (authentication_info->resynchronization_info) {
73
0
        OpenAPI_resynchronization_info_free(authentication_info->resynchronization_info);
74
0
        authentication_info->resynchronization_info = NULL;
75
0
    }
76
0
    if (authentication_info->pei) {
77
0
        ogs_free(authentication_info->pei);
78
0
        authentication_info->pei = NULL;
79
0
    }
80
0
    if (authentication_info->trace_data) {
81
0
        OpenAPI_trace_data_free(authentication_info->trace_data);
82
0
        authentication_info->trace_data = NULL;
83
0
    }
84
0
    if (authentication_info->udm_group_id) {
85
0
        ogs_free(authentication_info->udm_group_id);
86
0
        authentication_info->udm_group_id = NULL;
87
0
    }
88
0
    if (authentication_info->routing_indicator) {
89
0
        ogs_free(authentication_info->routing_indicator);
90
0
        authentication_info->routing_indicator = NULL;
91
0
    }
92
0
    if (authentication_info->cell_cag_info) {
93
0
        OpenAPI_list_for_each(authentication_info->cell_cag_info, node) {
94
0
            ogs_free(node->data);
95
0
        }
96
0
        OpenAPI_list_free(authentication_info->cell_cag_info);
97
0
        authentication_info->cell_cag_info = NULL;
98
0
    }
99
0
    if (authentication_info->supported_features) {
100
0
        ogs_free(authentication_info->supported_features);
101
0
        authentication_info->supported_features = NULL;
102
0
    }
103
0
    ogs_free(authentication_info);
104
0
}
105
106
cJSON *OpenAPI_authentication_info_convertToJSON(OpenAPI_authentication_info_t *authentication_info)
107
0
{
108
0
    cJSON *item = NULL;
109
0
    OpenAPI_lnode_t *node = NULL;
110
111
0
    if (authentication_info == NULL) {
112
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [AuthenticationInfo]");
113
0
        return NULL;
114
0
    }
115
116
0
    item = cJSON_CreateObject();
117
0
    if (!authentication_info->supi_or_suci) {
118
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [supi_or_suci]");
119
0
        return NULL;
120
0
    }
121
0
    if (cJSON_AddStringToObject(item, "supiOrSuci", authentication_info->supi_or_suci) == NULL) {
122
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [supi_or_suci]");
123
0
        goto end;
124
0
    }
125
126
0
    if (!authentication_info->serving_network_name) {
127
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [serving_network_name]");
128
0
        return NULL;
129
0
    }
130
0
    if (cJSON_AddStringToObject(item, "servingNetworkName", authentication_info->serving_network_name) == NULL) {
131
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [serving_network_name]");
132
0
        goto end;
133
0
    }
134
135
0
    if (authentication_info->resynchronization_info) {
136
0
    cJSON *resynchronization_info_local_JSON = OpenAPI_resynchronization_info_convertToJSON(authentication_info->resynchronization_info);
137
0
    if (resynchronization_info_local_JSON == NULL) {
138
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [resynchronization_info]");
139
0
        goto end;
140
0
    }
141
0
    cJSON_AddItemToObject(item, "resynchronizationInfo", resynchronization_info_local_JSON);
142
0
    if (item->child == NULL) {
143
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [resynchronization_info]");
144
0
        goto end;
145
0
    }
146
0
    }
147
148
0
    if (authentication_info->pei) {
149
0
    if (cJSON_AddStringToObject(item, "pei", authentication_info->pei) == NULL) {
150
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [pei]");
151
0
        goto end;
152
0
    }
153
0
    }
154
155
0
    if (authentication_info->trace_data) {
156
0
    cJSON *trace_data_local_JSON = OpenAPI_trace_data_convertToJSON(authentication_info->trace_data);
157
0
    if (trace_data_local_JSON == NULL) {
158
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [trace_data]");
159
0
        goto end;
160
0
    }
161
0
    cJSON_AddItemToObject(item, "traceData", trace_data_local_JSON);
162
0
    if (item->child == NULL) {
163
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [trace_data]");
164
0
        goto end;
165
0
    }
166
0
    } else if (authentication_info->is_trace_data_null) {
167
0
        if (cJSON_AddNullToObject(item, "traceData") == NULL) {
168
0
            ogs_error("OpenAPI_authentication_info_convertToJSON() failed [trace_data]");
169
0
            goto end;
170
0
        }
171
0
    }
172
173
0
    if (authentication_info->udm_group_id) {
174
0
    if (cJSON_AddStringToObject(item, "udmGroupId", authentication_info->udm_group_id) == NULL) {
175
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [udm_group_id]");
176
0
        goto end;
177
0
    }
178
0
    }
179
180
0
    if (authentication_info->routing_indicator) {
181
0
    if (cJSON_AddStringToObject(item, "routingIndicator", authentication_info->routing_indicator) == NULL) {
182
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [routing_indicator]");
183
0
        goto end;
184
0
    }
185
0
    }
186
187
0
    if (authentication_info->cell_cag_info) {
188
0
    cJSON *cell_cag_infoList = cJSON_AddArrayToObject(item, "cellCagInfo");
189
0
    if (cell_cag_infoList == NULL) {
190
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [cell_cag_info]");
191
0
        goto end;
192
0
    }
193
0
    OpenAPI_list_for_each(authentication_info->cell_cag_info, node) {
194
0
        if (cJSON_AddStringToObject(cell_cag_infoList, "", (char*)node->data) == NULL) {
195
0
            ogs_error("OpenAPI_authentication_info_convertToJSON() failed [cell_cag_info]");
196
0
            goto end;
197
0
        }
198
0
    }
199
0
    }
200
201
0
    if (authentication_info->is_n5gc_ind) {
202
0
    if (cJSON_AddBoolToObject(item, "n5gcInd", authentication_info->n5gc_ind) == NULL) {
203
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [n5gc_ind]");
204
0
        goto end;
205
0
    }
206
0
    }
207
208
0
    if (authentication_info->supported_features) {
209
0
    if (cJSON_AddStringToObject(item, "supportedFeatures", authentication_info->supported_features) == NULL) {
210
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [supported_features]");
211
0
        goto end;
212
0
    }
213
0
    }
214
215
0
    if (authentication_info->is_nswo_ind) {
216
0
    if (cJSON_AddBoolToObject(item, "nswoInd", authentication_info->nswo_ind) == NULL) {
217
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [nswo_ind]");
218
0
        goto end;
219
0
    }
220
0
    }
221
222
0
    if (authentication_info->is_disaster_roaming_ind) {
223
0
    if (cJSON_AddBoolToObject(item, "disasterRoamingInd", authentication_info->disaster_roaming_ind) == NULL) {
224
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [disaster_roaming_ind]");
225
0
        goto end;
226
0
    }
227
0
    }
228
229
0
    if (authentication_info->is_onboarding_ind) {
230
0
    if (cJSON_AddBoolToObject(item, "onboardingInd", authentication_info->onboarding_ind) == NULL) {
231
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [onboarding_ind]");
232
0
        goto end;
233
0
    }
234
0
    }
235
236
0
    if (authentication_info->is_aun3_ind) {
237
0
    if (cJSON_AddBoolToObject(item, "aun3Ind", authentication_info->aun3_ind) == NULL) {
238
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed [aun3_ind]");
239
0
        goto end;
240
0
    }
241
0
    }
242
243
0
end:
244
0
    return item;
245
0
}
246
247
OpenAPI_authentication_info_t *OpenAPI_authentication_info_parseFromJSON(cJSON *authentication_infoJSON)
248
0
{
249
0
    OpenAPI_authentication_info_t *authentication_info_local_var = NULL;
250
0
    OpenAPI_lnode_t *node = NULL;
251
0
    cJSON *supi_or_suci = NULL;
252
0
    cJSON *serving_network_name = NULL;
253
0
    cJSON *resynchronization_info = NULL;
254
0
    OpenAPI_resynchronization_info_t *resynchronization_info_local_nonprim = NULL;
255
0
    cJSON *pei = NULL;
256
0
    cJSON *trace_data = NULL;
257
0
    OpenAPI_trace_data_t *trace_data_local_nonprim = NULL;
258
0
    cJSON *udm_group_id = NULL;
259
0
    cJSON *routing_indicator = NULL;
260
0
    cJSON *cell_cag_info = NULL;
261
0
    OpenAPI_list_t *cell_cag_infoList = NULL;
262
0
    cJSON *n5gc_ind = NULL;
263
0
    cJSON *supported_features = NULL;
264
0
    cJSON *nswo_ind = NULL;
265
0
    cJSON *disaster_roaming_ind = NULL;
266
0
    cJSON *onboarding_ind = NULL;
267
0
    cJSON *aun3_ind = NULL;
268
0
    supi_or_suci = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "supiOrSuci");
269
0
    if (!supi_or_suci) {
270
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [supi_or_suci]");
271
0
        goto end;
272
0
    }
273
0
    if (!cJSON_IsString(supi_or_suci)) {
274
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [supi_or_suci]");
275
0
        goto end;
276
0
    }
277
278
0
    serving_network_name = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "servingNetworkName");
279
0
    if (!serving_network_name) {
280
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [serving_network_name]");
281
0
        goto end;
282
0
    }
283
0
    if (!cJSON_IsString(serving_network_name)) {
284
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [serving_network_name]");
285
0
        goto end;
286
0
    }
287
288
0
    resynchronization_info = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "resynchronizationInfo");
289
0
    if (resynchronization_info) {
290
0
    resynchronization_info_local_nonprim = OpenAPI_resynchronization_info_parseFromJSON(resynchronization_info);
291
0
    if (!resynchronization_info_local_nonprim) {
292
0
        ogs_error("OpenAPI_resynchronization_info_parseFromJSON failed [resynchronization_info]");
293
0
        goto end;
294
0
    }
295
0
    }
296
297
0
    pei = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "pei");
298
0
    if (pei) {
299
0
    if (!cJSON_IsString(pei) && !cJSON_IsNull(pei)) {
300
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [pei]");
301
0
        goto end;
302
0
    }
303
0
    }
304
305
0
    trace_data = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "traceData");
306
0
    if (trace_data) {
307
0
    if (!cJSON_IsNull(trace_data)) {
308
0
    trace_data_local_nonprim = OpenAPI_trace_data_parseFromJSON(trace_data);
309
0
    if (!trace_data_local_nonprim) {
310
0
        ogs_error("OpenAPI_trace_data_parseFromJSON failed [trace_data]");
311
0
        goto end;
312
0
    }
313
0
    }
314
0
    }
315
316
0
    udm_group_id = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "udmGroupId");
317
0
    if (udm_group_id) {
318
0
    if (!cJSON_IsString(udm_group_id) && !cJSON_IsNull(udm_group_id)) {
319
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [udm_group_id]");
320
0
        goto end;
321
0
    }
322
0
    }
323
324
0
    routing_indicator = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "routingIndicator");
325
0
    if (routing_indicator) {
326
0
    if (!cJSON_IsString(routing_indicator) && !cJSON_IsNull(routing_indicator)) {
327
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [routing_indicator]");
328
0
        goto end;
329
0
    }
330
0
    }
331
332
0
    cell_cag_info = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "cellCagInfo");
333
0
    if (cell_cag_info) {
334
0
        cJSON *cell_cag_info_local = NULL;
335
0
        if (!cJSON_IsArray(cell_cag_info)) {
336
0
            ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [cell_cag_info]");
337
0
            goto end;
338
0
        }
339
340
0
        cell_cag_infoList = OpenAPI_list_create();
341
342
0
        cJSON_ArrayForEach(cell_cag_info_local, cell_cag_info) {
343
0
            double *localDouble = NULL;
344
0
            int *localInt = NULL;
345
0
            if (!cJSON_IsString(cell_cag_info_local)) {
346
0
                ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [cell_cag_info]");
347
0
                goto end;
348
0
            }
349
0
            OpenAPI_list_add(cell_cag_infoList, ogs_strdup(cell_cag_info_local->valuestring));
350
0
        }
351
0
    }
352
353
0
    n5gc_ind = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "n5gcInd");
354
0
    if (n5gc_ind) {
355
0
    if (!cJSON_IsBool(n5gc_ind)) {
356
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [n5gc_ind]");
357
0
        goto end;
358
0
    }
359
0
    }
360
361
0
    supported_features = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "supportedFeatures");
362
0
    if (supported_features) {
363
0
    if (!cJSON_IsString(supported_features) && !cJSON_IsNull(supported_features)) {
364
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [supported_features]");
365
0
        goto end;
366
0
    }
367
0
    }
368
369
0
    nswo_ind = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "nswoInd");
370
0
    if (nswo_ind) {
371
0
    if (!cJSON_IsBool(nswo_ind)) {
372
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [nswo_ind]");
373
0
        goto end;
374
0
    }
375
0
    }
376
377
0
    disaster_roaming_ind = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "disasterRoamingInd");
378
0
    if (disaster_roaming_ind) {
379
0
    if (!cJSON_IsBool(disaster_roaming_ind)) {
380
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [disaster_roaming_ind]");
381
0
        goto end;
382
0
    }
383
0
    }
384
385
0
    onboarding_ind = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "onboardingInd");
386
0
    if (onboarding_ind) {
387
0
    if (!cJSON_IsBool(onboarding_ind)) {
388
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [onboarding_ind]");
389
0
        goto end;
390
0
    }
391
0
    }
392
393
0
    aun3_ind = cJSON_GetObjectItemCaseSensitive(authentication_infoJSON, "aun3Ind");
394
0
    if (aun3_ind) {
395
0
    if (!cJSON_IsBool(aun3_ind)) {
396
0
        ogs_error("OpenAPI_authentication_info_parseFromJSON() failed [aun3_ind]");
397
0
        goto end;
398
0
    }
399
0
    }
400
401
0
    authentication_info_local_var = OpenAPI_authentication_info_create (
402
0
        ogs_strdup(supi_or_suci->valuestring),
403
0
        ogs_strdup(serving_network_name->valuestring),
404
0
        resynchronization_info ? resynchronization_info_local_nonprim : NULL,
405
0
        pei && !cJSON_IsNull(pei) ? ogs_strdup(pei->valuestring) : NULL,
406
0
        trace_data && cJSON_IsNull(trace_data) ? true : false,
407
0
        trace_data ? trace_data_local_nonprim : NULL,
408
0
        udm_group_id && !cJSON_IsNull(udm_group_id) ? ogs_strdup(udm_group_id->valuestring) : NULL,
409
0
        routing_indicator && !cJSON_IsNull(routing_indicator) ? ogs_strdup(routing_indicator->valuestring) : NULL,
410
0
        cell_cag_info ? cell_cag_infoList : NULL,
411
0
        n5gc_ind ? true : false,
412
0
        n5gc_ind ? n5gc_ind->valueint : 0,
413
0
        supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL,
414
0
        nswo_ind ? true : false,
415
0
        nswo_ind ? nswo_ind->valueint : 0,
416
0
        disaster_roaming_ind ? true : false,
417
0
        disaster_roaming_ind ? disaster_roaming_ind->valueint : 0,
418
0
        onboarding_ind ? true : false,
419
0
        onboarding_ind ? onboarding_ind->valueint : 0,
420
0
        aun3_ind ? true : false,
421
0
        aun3_ind ? aun3_ind->valueint : 0
422
0
    );
423
424
0
    return authentication_info_local_var;
425
0
end:
426
0
    if (resynchronization_info_local_nonprim) {
427
0
        OpenAPI_resynchronization_info_free(resynchronization_info_local_nonprim);
428
0
        resynchronization_info_local_nonprim = NULL;
429
0
    }
430
0
    if (trace_data_local_nonprim) {
431
0
        OpenAPI_trace_data_free(trace_data_local_nonprim);
432
0
        trace_data_local_nonprim = NULL;
433
0
    }
434
0
    if (cell_cag_infoList) {
435
0
        OpenAPI_list_for_each(cell_cag_infoList, node) {
436
0
            ogs_free(node->data);
437
0
        }
438
0
        OpenAPI_list_free(cell_cag_infoList);
439
0
        cell_cag_infoList = NULL;
440
0
    }
441
0
    return NULL;
442
0
}
443
444
OpenAPI_authentication_info_t *OpenAPI_authentication_info_copy(OpenAPI_authentication_info_t *dst, OpenAPI_authentication_info_t *src)
445
0
{
446
0
    cJSON *item = NULL;
447
0
    char *content = NULL;
448
449
0
    ogs_assert(src);
450
0
    item = OpenAPI_authentication_info_convertToJSON(src);
451
0
    if (!item) {
452
0
        ogs_error("OpenAPI_authentication_info_convertToJSON() failed");
453
0
        return NULL;
454
0
    }
455
456
0
    content = cJSON_Print(item);
457
0
    cJSON_Delete(item);
458
459
0
    if (!content) {
460
0
        ogs_error("cJSON_Print() failed");
461
0
        return NULL;
462
0
    }
463
464
0
    item = cJSON_Parse(content);
465
0
    ogs_free(content);
466
0
    if (!item) {
467
0
        ogs_error("cJSON_Parse() failed");
468
0
        return NULL;
469
0
    }
470
471
0
    OpenAPI_authentication_info_free(dst);
472
0
    dst = OpenAPI_authentication_info_parseFromJSON(item);
473
0
    cJSON_Delete(item);
474
475
0
    return dst;
476
0
}
477