Coverage Report

Created: 2026-11-06 06:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/easdf_info.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "easdf_info.h"
6
7
OpenAPI_easdf_info_t *OpenAPI_easdf_info_create(
8
    OpenAPI_list_t *s_nssai_easdf_info_list,
9
    OpenAPI_list_t *easdf_n6_ip_address_list,
10
    OpenAPI_list_t *upf_n6_ip_address_list,
11
    OpenAPI_list_t* n6_tunnel_info_list,
12
    OpenAPI_list_t *dns_security_protocols
13
)
14
4.98k
{
15
4.98k
    OpenAPI_easdf_info_t *easdf_info_local_var = ogs_malloc(sizeof(OpenAPI_easdf_info_t));
16
4.98k
    ogs_assert(easdf_info_local_var);
17
18
4.98k
    easdf_info_local_var->s_nssai_easdf_info_list = s_nssai_easdf_info_list;
19
4.98k
    easdf_info_local_var->easdf_n6_ip_address_list = easdf_n6_ip_address_list;
20
4.98k
    easdf_info_local_var->upf_n6_ip_address_list = upf_n6_ip_address_list;
21
4.98k
    easdf_info_local_var->n6_tunnel_info_list = n6_tunnel_info_list;
22
4.98k
    easdf_info_local_var->dns_security_protocols = dns_security_protocols;
23
24
4.98k
    return easdf_info_local_var;
25
4.98k
}
26
27
void OpenAPI_easdf_info_free(OpenAPI_easdf_info_t *easdf_info)
28
9.10k
{
29
9.10k
    OpenAPI_lnode_t *node = NULL;
30
31
9.10k
    if (NULL == easdf_info) {
32
4.12k
        return;
33
4.12k
    }
34
4.98k
    if (easdf_info->s_nssai_easdf_info_list) {
35
194
        OpenAPI_list_for_each(easdf_info->s_nssai_easdf_info_list, node) {
36
0
            OpenAPI_snssai_easdf_info_item_free(node->data);
37
0
        }
38
194
        OpenAPI_list_free(easdf_info->s_nssai_easdf_info_list);
39
194
        easdf_info->s_nssai_easdf_info_list = NULL;
40
194
    }
41
4.98k
    if (easdf_info->easdf_n6_ip_address_list) {
42
442
        OpenAPI_list_for_each(easdf_info->easdf_n6_ip_address_list, node) {
43
442
            OpenAPI_ip_addr_free(node->data);
44
442
        }
45
399
        OpenAPI_list_free(easdf_info->easdf_n6_ip_address_list);
46
399
        easdf_info->easdf_n6_ip_address_list = NULL;
47
399
    }
48
4.98k
    if (easdf_info->upf_n6_ip_address_list) {
49
1.18k
        OpenAPI_list_for_each(easdf_info->upf_n6_ip_address_list, node) {
50
1.18k
            OpenAPI_ip_addr_free(node->data);
51
1.18k
        }
52
874
        OpenAPI_list_free(easdf_info->upf_n6_ip_address_list);
53
874
        easdf_info->upf_n6_ip_address_list = NULL;
54
874
    }
55
4.98k
    if (easdf_info->n6_tunnel_info_list) {
56
4.43k
        OpenAPI_list_for_each(easdf_info->n6_tunnel_info_list, node) {
57
4.43k
            OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data;
58
4.43k
            ogs_free(localKeyValue->key);
59
4.43k
            OpenAPI_interface_upf_info_item_free(localKeyValue->value);
60
4.43k
            OpenAPI_map_free(localKeyValue);
61
4.43k
        }
62
766
        OpenAPI_list_free(easdf_info->n6_tunnel_info_list);
63
766
        easdf_info->n6_tunnel_info_list = NULL;
64
766
    }
65
4.98k
    if (easdf_info->dns_security_protocols) {
66
210
        OpenAPI_list_free(easdf_info->dns_security_protocols);
67
210
        easdf_info->dns_security_protocols = NULL;
68
210
    }
69
4.98k
    ogs_free(easdf_info);
70
4.98k
}
71
72
cJSON *OpenAPI_easdf_info_convertToJSON(OpenAPI_easdf_info_t *easdf_info)
73
0
{
74
0
    cJSON *item = NULL;
75
0
    OpenAPI_lnode_t *node = NULL;
76
77
0
    if (easdf_info == NULL) {
78
0
        ogs_error("OpenAPI_easdf_info_convertToJSON() failed [EasdfInfo]");
79
0
        return NULL;
80
0
    }
81
82
0
    item = cJSON_CreateObject();
83
0
    if (easdf_info->s_nssai_easdf_info_list) {
84
0
    cJSON *s_nssai_easdf_info_listList = cJSON_AddArrayToObject(item, "sNssaiEasdfInfoList");
85
0
    if (s_nssai_easdf_info_listList == NULL) {
86
0
        ogs_error("OpenAPI_easdf_info_convertToJSON() failed [s_nssai_easdf_info_list]");
87
0
        goto end;
88
0
    }
89
0
    OpenAPI_list_for_each(easdf_info->s_nssai_easdf_info_list, node) {
90
0
        cJSON *itemLocal = OpenAPI_snssai_easdf_info_item_convertToJSON(node->data);
91
0
        if (itemLocal == NULL) {
92
0
            ogs_error("OpenAPI_easdf_info_convertToJSON() failed [s_nssai_easdf_info_list]");
93
0
            goto end;
94
0
        }
95
0
        cJSON_AddItemToArray(s_nssai_easdf_info_listList, itemLocal);
96
0
    }
97
0
    }
98
99
0
    if (easdf_info->easdf_n6_ip_address_list) {
100
0
    cJSON *easdf_n6_ip_address_listList = cJSON_AddArrayToObject(item, "easdfN6IpAddressList");
101
0
    if (easdf_n6_ip_address_listList == NULL) {
102
0
        ogs_error("OpenAPI_easdf_info_convertToJSON() failed [easdf_n6_ip_address_list]");
103
0
        goto end;
104
0
    }
105
0
    OpenAPI_list_for_each(easdf_info->easdf_n6_ip_address_list, node) {
106
0
        cJSON *itemLocal = OpenAPI_ip_addr_convertToJSON(node->data);
107
0
        if (itemLocal == NULL) {
108
0
            ogs_error("OpenAPI_easdf_info_convertToJSON() failed [easdf_n6_ip_address_list]");
109
0
            goto end;
110
0
        }
111
0
        cJSON_AddItemToArray(easdf_n6_ip_address_listList, itemLocal);
112
0
    }
113
0
    }
114
115
0
    if (easdf_info->upf_n6_ip_address_list) {
116
0
    cJSON *upf_n6_ip_address_listList = cJSON_AddArrayToObject(item, "upfN6IpAddressList");
117
0
    if (upf_n6_ip_address_listList == NULL) {
118
0
        ogs_error("OpenAPI_easdf_info_convertToJSON() failed [upf_n6_ip_address_list]");
119
0
        goto end;
120
0
    }
121
0
    OpenAPI_list_for_each(easdf_info->upf_n6_ip_address_list, node) {
122
0
        cJSON *itemLocal = OpenAPI_ip_addr_convertToJSON(node->data);
123
0
        if (itemLocal == NULL) {
124
0
            ogs_error("OpenAPI_easdf_info_convertToJSON() failed [upf_n6_ip_address_list]");
125
0
            goto end;
126
0
        }
127
0
        cJSON_AddItemToArray(upf_n6_ip_address_listList, itemLocal);
128
0
    }
129
0
    }
130
131
0
    if (easdf_info->n6_tunnel_info_list) {
132
0
    cJSON *n6_tunnel_info_list = cJSON_AddObjectToObject(item, "n6TunnelInfoList");
133
0
    if (n6_tunnel_info_list == NULL) {
134
0
        ogs_error("OpenAPI_easdf_info_convertToJSON() failed [n6_tunnel_info_list]");
135
0
        goto end;
136
0
    }
137
0
    cJSON *localMapObject = n6_tunnel_info_list;
138
0
    if (easdf_info->n6_tunnel_info_list) {
139
0
        OpenAPI_list_for_each(easdf_info->n6_tunnel_info_list, node) {
140
0
            OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data;
141
0
            if (localKeyValue == NULL) {
142
0
                ogs_error("OpenAPI_easdf_info_convertToJSON() failed [n6_tunnel_info_list]");
143
0
                goto end;
144
0
            }
145
0
            if (localKeyValue->key == NULL) {
146
0
                ogs_error("OpenAPI_easdf_info_convertToJSON() failed [n6_tunnel_info_list]");
147
0
                goto end;
148
0
            }
149
0
            cJSON *itemLocal = localKeyValue->value ?
150
0
                OpenAPI_interface_upf_info_item_convertToJSON(localKeyValue->value) :
151
0
                cJSON_CreateNull();
152
0
            if (itemLocal == NULL) {
153
0
                ogs_error("OpenAPI_easdf_info_convertToJSON() failed [inner]");
154
0
                goto end;
155
0
            }
156
0
            cJSON_AddItemToObject(localMapObject, localKeyValue->key, itemLocal);
157
0
        }
158
0
    }
159
0
    }
160
161
0
    if (easdf_info->dns_security_protocols != OpenAPI_dns_security_protocol_NULL) {
162
0
    cJSON *dns_security_protocolsList = cJSON_AddArrayToObject(item, "dnsSecurityProtocols");
163
0
    if (dns_security_protocolsList == NULL) {
164
0
        ogs_error("OpenAPI_easdf_info_convertToJSON() failed [dns_security_protocols]");
165
0
        goto end;
166
0
    }
167
0
    OpenAPI_list_for_each(easdf_info->dns_security_protocols, node) {
168
0
        if (cJSON_AddStringToObject(dns_security_protocolsList, "", OpenAPI_dns_security_protocol_ToString((intptr_t)node->data)) == NULL) {
169
0
            ogs_error("OpenAPI_easdf_info_convertToJSON() failed [dns_security_protocols]");
170
0
            goto end;
171
0
        }
172
0
    }
173
0
    }
174
175
0
end:
176
0
    return item;
177
0
}
178
179
OpenAPI_easdf_info_t *OpenAPI_easdf_info_parseFromJSON(cJSON *easdf_infoJSON)
180
8.43k
{
181
8.43k
    OpenAPI_easdf_info_t *easdf_info_local_var = NULL;
182
8.43k
    OpenAPI_lnode_t *node = NULL;
183
8.43k
    cJSON *s_nssai_easdf_info_list = NULL;
184
8.43k
    OpenAPI_list_t *s_nssai_easdf_info_listList = NULL;
185
8.43k
    cJSON *easdf_n6_ip_address_list = NULL;
186
8.43k
    OpenAPI_list_t *easdf_n6_ip_address_listList = NULL;
187
8.43k
    cJSON *upf_n6_ip_address_list = NULL;
188
8.43k
    OpenAPI_list_t *upf_n6_ip_address_listList = NULL;
189
8.43k
    cJSON *n6_tunnel_info_list = NULL;
190
8.43k
    OpenAPI_list_t *n6_tunnel_info_listList = NULL;
191
8.43k
    cJSON *dns_security_protocols = NULL;
192
8.43k
    OpenAPI_list_t *dns_security_protocolsList = NULL;
193
8.43k
    s_nssai_easdf_info_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "sNssaiEasdfInfoList");
194
8.43k
    if (s_nssai_easdf_info_list) {
195
977
        cJSON *s_nssai_easdf_info_list_local = NULL;
196
977
        if (!cJSON_IsArray(s_nssai_easdf_info_list)) {
197
194
            ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [s_nssai_easdf_info_list]");
198
194
            goto end;
199
194
        }
200
201
783
        s_nssai_easdf_info_listList = OpenAPI_list_create();
202
203
783
        cJSON_ArrayForEach(s_nssai_easdf_info_list_local, s_nssai_easdf_info_list) {
204
589
            if (!cJSON_IsObject(s_nssai_easdf_info_list_local)) {
205
194
                ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [s_nssai_easdf_info_list]");
206
194
                goto end;
207
194
            }
208
395
            OpenAPI_snssai_easdf_info_item_t *s_nssai_easdf_info_listItem = OpenAPI_snssai_easdf_info_item_parseFromJSON(s_nssai_easdf_info_list_local);
209
395
            if (!s_nssai_easdf_info_listItem) {
210
395
                ogs_error("No s_nssai_easdf_info_listItem");
211
395
                goto end;
212
395
            }
213
0
            OpenAPI_list_add(s_nssai_easdf_info_listList, s_nssai_easdf_info_listItem);
214
0
        }
215
783
    }
216
217
7.64k
    easdf_n6_ip_address_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "easdfN6IpAddressList");
218
7.64k
    if (easdf_n6_ip_address_list) {
219
1.07k
        cJSON *easdf_n6_ip_address_list_local = NULL;
220
1.07k
        if (!cJSON_IsArray(easdf_n6_ip_address_list)) {
221
202
            ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [easdf_n6_ip_address_list]");
222
202
            goto end;
223
202
        }
224
225
872
        easdf_n6_ip_address_listList = OpenAPI_list_create();
226
227
1.33k
        cJSON_ArrayForEach(easdf_n6_ip_address_list_local, easdf_n6_ip_address_list) {
228
1.33k
            if (!cJSON_IsObject(easdf_n6_ip_address_list_local)) {
229
397
                ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [easdf_n6_ip_address_list]");
230
397
                goto end;
231
397
            }
232
934
            OpenAPI_ip_addr_t *easdf_n6_ip_address_listItem = OpenAPI_ip_addr_parseFromJSON(easdf_n6_ip_address_list_local);
233
934
            if (!easdf_n6_ip_address_listItem) {
234
76
                ogs_error("No easdf_n6_ip_address_listItem");
235
76
                goto end;
236
76
            }
237
858
            OpenAPI_list_add(easdf_n6_ip_address_listList, easdf_n6_ip_address_listItem);
238
858
        }
239
872
    }
240
241
6.97k
    upf_n6_ip_address_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "upfN6IpAddressList");
242
6.97k
    if (upf_n6_ip_address_list) {
243
1.64k
        cJSON *upf_n6_ip_address_list_local = NULL;
244
1.64k
        if (!cJSON_IsArray(upf_n6_ip_address_list)) {
245
194
            ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [upf_n6_ip_address_list]");
246
194
            goto end;
247
194
        }
248
249
1.45k
        upf_n6_ip_address_listList = OpenAPI_list_create();
250
251
3.10k
        cJSON_ArrayForEach(upf_n6_ip_address_list_local, upf_n6_ip_address_list) {
252
3.10k
            if (!cJSON_IsObject(upf_n6_ip_address_list_local)) {
253
447
                ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [upf_n6_ip_address_list]");
254
447
                goto end;
255
447
            }
256
2.65k
            OpenAPI_ip_addr_t *upf_n6_ip_address_listItem = OpenAPI_ip_addr_parseFromJSON(upf_n6_ip_address_list_local);
257
2.65k
            if (!upf_n6_ip_address_listItem) {
258
130
                ogs_error("No upf_n6_ip_address_listItem");
259
130
                goto end;
260
130
            }
261
2.52k
            OpenAPI_list_add(upf_n6_ip_address_listList, upf_n6_ip_address_listItem);
262
2.52k
        }
263
1.45k
    }
264
265
6.20k
    n6_tunnel_info_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "n6TunnelInfoList");
266
6.20k
    if (n6_tunnel_info_list) {
267
1.53k
        cJSON *n6_tunnel_info_list_local_map = NULL;
268
1.53k
        if (!cJSON_IsObject(n6_tunnel_info_list) && !cJSON_IsNull(n6_tunnel_info_list)) {
269
213
            ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [n6_tunnel_info_list]");
270
213
            goto end;
271
213
        }
272
1.32k
        if (cJSON_IsObject(n6_tunnel_info_list)) {
273
1.13k
            n6_tunnel_info_listList = OpenAPI_list_create();
274
1.13k
            OpenAPI_map_t *localMapKeyPair = NULL;
275
7.22k
            cJSON_ArrayForEach(n6_tunnel_info_list_local_map, n6_tunnel_info_list) {
276
7.22k
                cJSON *localMapObject = n6_tunnel_info_list_local_map;
277
7.22k
                if (cJSON_IsObject(localMapObject)) {
278
6.54k
                    localMapKeyPair = OpenAPI_map_create(
279
6.54k
                        ogs_strdup(localMapObject->string), OpenAPI_interface_upf_info_item_parseFromJSON(localMapObject));
280
6.54k
                } else if (cJSON_IsNull(localMapObject)) {
281
323
                    localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), NULL);
282
366
                } else {
283
366
                    ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [inner]");
284
366
                    goto end;
285
366
                }
286
6.86k
                if (localMapKeyPair == NULL) {
287
0
                    ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [n6_tunnel_info_list]");
288
0
                    goto end;
289
0
                }
290
6.86k
                OpenAPI_list_add(n6_tunnel_info_listList, localMapKeyPair);
291
6.86k
            }
292
1.13k
        }
293
1.32k
    }
294
295
5.62k
    dns_security_protocols = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "dnsSecurityProtocols");
296
5.62k
    if (dns_security_protocols) {
297
851
        cJSON *dns_security_protocols_local = NULL;
298
851
        if (!cJSON_IsArray(dns_security_protocols)) {
299
195
            ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [dns_security_protocols]");
300
195
            goto end;
301
195
        }
302
303
656
        dns_security_protocolsList = OpenAPI_list_create();
304
305
4.37k
        cJSON_ArrayForEach(dns_security_protocols_local, dns_security_protocols) {
306
4.37k
            OpenAPI_dns_security_protocol_e localEnum = OpenAPI_dns_security_protocol_NULL;
307
4.37k
            if (!cJSON_IsString(dns_security_protocols_local)) {
308
205
                ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [dns_security_protocols]");
309
205
                goto end;
310
205
            }
311
4.17k
            localEnum = OpenAPI_dns_security_protocol_FromString(dns_security_protocols_local->valuestring);
312
4.17k
            if (!localEnum) {
313
1.75k
                ogs_info("Enum value \"%s\" for field \"dns_security_protocols\" is not supported. Ignoring it ...",
314
1.75k
                         dns_security_protocols_local->valuestring);
315
2.42k
            } else {
316
2.42k
                OpenAPI_list_add(dns_security_protocolsList, (void *)localEnum);
317
2.42k
            }
318
4.17k
        }
319
451
        if (dns_security_protocolsList->count == 0) {
320
241
            ogs_error("OpenAPI_easdf_info_parseFromJSON() failed: Expected dns_security_protocolsList to not be empty (after ignoring unsupported enum values).");
321
241
            goto end;
322
241
        }
323
451
    }
324
325
4.98k
    easdf_info_local_var = OpenAPI_easdf_info_create (
326
4.98k
        s_nssai_easdf_info_list ? s_nssai_easdf_info_listList : NULL,
327
4.98k
        easdf_n6_ip_address_list ? easdf_n6_ip_address_listList : NULL,
328
4.98k
        upf_n6_ip_address_list ? upf_n6_ip_address_listList : NULL,
329
4.98k
        n6_tunnel_info_list ? n6_tunnel_info_listList : NULL,
330
4.98k
        dns_security_protocols ? dns_security_protocolsList : NULL
331
4.98k
    );
332
333
4.98k
    return easdf_info_local_var;
334
3.44k
end:
335
3.44k
    if (s_nssai_easdf_info_listList) {
336
589
        OpenAPI_list_for_each(s_nssai_easdf_info_listList, node) {
337
0
            OpenAPI_snssai_easdf_info_item_free(node->data);
338
0
        }
339
589
        OpenAPI_list_free(s_nssai_easdf_info_listList);
340
589
        s_nssai_easdf_info_listList = NULL;
341
589
    }
342
3.44k
    if (easdf_n6_ip_address_listList) {
343
473
        OpenAPI_list_for_each(easdf_n6_ip_address_listList, node) {
344
416
            OpenAPI_ip_addr_free(node->data);
345
416
        }
346
473
        OpenAPI_list_free(easdf_n6_ip_address_listList);
347
473
        easdf_n6_ip_address_listList = NULL;
348
473
    }
349
3.44k
    if (upf_n6_ip_address_listList) {
350
1.33k
        OpenAPI_list_for_each(upf_n6_ip_address_listList, node) {
351
1.33k
            OpenAPI_ip_addr_free(node->data);
352
1.33k
        }
353
577
        OpenAPI_list_free(upf_n6_ip_address_listList);
354
577
        upf_n6_ip_address_listList = NULL;
355
577
    }
356
3.44k
    if (n6_tunnel_info_listList) {
357
2.42k
        OpenAPI_list_for_each(n6_tunnel_info_listList, node) {
358
2.42k
            OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data;
359
2.42k
            ogs_free(localKeyValue->key);
360
2.42k
            OpenAPI_interface_upf_info_item_free(localKeyValue->value);
361
2.42k
            OpenAPI_map_free(localKeyValue);
362
2.42k
        }
363
366
        OpenAPI_list_free(n6_tunnel_info_listList);
364
366
        n6_tunnel_info_listList = NULL;
365
366
    }
366
3.44k
    if (dns_security_protocolsList) {
367
446
        OpenAPI_list_free(dns_security_protocolsList);
368
446
        dns_security_protocolsList = NULL;
369
446
    }
370
3.44k
    return NULL;
371
5.62k
}
372
373
OpenAPI_easdf_info_t *OpenAPI_easdf_info_copy(OpenAPI_easdf_info_t *dst, OpenAPI_easdf_info_t *src)
374
0
{
375
0
    cJSON *item = NULL;
376
0
    char *content = NULL;
377
378
0
    ogs_assert(src);
379
0
    item = OpenAPI_easdf_info_convertToJSON(src);
380
0
    if (!item) {
381
0
        ogs_error("OpenAPI_easdf_info_convertToJSON() failed");
382
0
        return NULL;
383
0
    }
384
385
0
    content = cJSON_Print(item);
386
0
    cJSON_Delete(item);
387
388
0
    if (!content) {
389
0
        ogs_error("cJSON_Print() failed");
390
0
        return NULL;
391
0
    }
392
393
0
    item = cJSON_Parse(content);
394
0
    ogs_free(content);
395
0
    if (!item) {
396
0
        ogs_error("cJSON_Parse() failed");
397
0
        return NULL;
398
0
    }
399
400
0
    OpenAPI_easdf_info_free(dst);
401
0
    dst = OpenAPI_easdf_info_parseFromJSON(item);
402
0
    cJSON_Delete(item);
403
404
0
    return dst;
405
0
}
406