Coverage Report

Created: 2026-11-12 06:28

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
5.14k
{
15
5.14k
    OpenAPI_easdf_info_t *easdf_info_local_var = ogs_malloc(sizeof(OpenAPI_easdf_info_t));
16
5.14k
    ogs_assert(easdf_info_local_var);
17
18
5.14k
    easdf_info_local_var->s_nssai_easdf_info_list = s_nssai_easdf_info_list;
19
5.14k
    easdf_info_local_var->easdf_n6_ip_address_list = easdf_n6_ip_address_list;
20
5.14k
    easdf_info_local_var->upf_n6_ip_address_list = upf_n6_ip_address_list;
21
5.14k
    easdf_info_local_var->n6_tunnel_info_list = n6_tunnel_info_list;
22
5.14k
    easdf_info_local_var->dns_security_protocols = dns_security_protocols;
23
24
5.14k
    return easdf_info_local_var;
25
5.14k
}
26
27
void OpenAPI_easdf_info_free(OpenAPI_easdf_info_t *easdf_info)
28
8.89k
{
29
8.89k
    OpenAPI_lnode_t *node = NULL;
30
31
8.89k
    if (NULL == easdf_info) {
32
3.74k
        return;
33
3.74k
    }
34
5.14k
    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
5.14k
    if (easdf_info->easdf_n6_ip_address_list) {
42
461
        OpenAPI_list_for_each(easdf_info->easdf_n6_ip_address_list, node) {
43
461
            OpenAPI_ip_addr_free(node->data);
44
461
        }
45
408
        OpenAPI_list_free(easdf_info->easdf_n6_ip_address_list);
46
408
        easdf_info->easdf_n6_ip_address_list = NULL;
47
408
    }
48
5.14k
    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
875
        OpenAPI_list_free(easdf_info->upf_n6_ip_address_list);
53
875
        easdf_info->upf_n6_ip_address_list = NULL;
54
875
    }
55
5.14k
    if (easdf_info->n6_tunnel_info_list) {
56
4.12k
        OpenAPI_list_for_each(easdf_info->n6_tunnel_info_list, node) {
57
4.12k
            OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data;
58
4.12k
            ogs_free(localKeyValue->key);
59
4.12k
            OpenAPI_interface_upf_info_item_free(localKeyValue->value);
60
4.12k
            OpenAPI_map_free(localKeyValue);
61
4.12k
        }
62
776
        OpenAPI_list_free(easdf_info->n6_tunnel_info_list);
63
776
        easdf_info->n6_tunnel_info_list = NULL;
64
776
    }
65
5.14k
    if (easdf_info->dns_security_protocols) {
66
240
        OpenAPI_list_free(easdf_info->dns_security_protocols);
67
240
        easdf_info->dns_security_protocols = NULL;
68
240
    }
69
5.14k
    ogs_free(easdf_info);
70
5.14k
}
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.27k
{
181
8.27k
    OpenAPI_easdf_info_t *easdf_info_local_var = NULL;
182
8.27k
    OpenAPI_lnode_t *node = NULL;
183
8.27k
    cJSON *s_nssai_easdf_info_list = NULL;
184
8.27k
    OpenAPI_list_t *s_nssai_easdf_info_listList = NULL;
185
8.27k
    cJSON *easdf_n6_ip_address_list = NULL;
186
8.27k
    OpenAPI_list_t *easdf_n6_ip_address_listList = NULL;
187
8.27k
    cJSON *upf_n6_ip_address_list = NULL;
188
8.27k
    OpenAPI_list_t *upf_n6_ip_address_listList = NULL;
189
8.27k
    cJSON *n6_tunnel_info_list = NULL;
190
8.27k
    OpenAPI_list_t *n6_tunnel_info_listList = NULL;
191
8.27k
    cJSON *dns_security_protocols = NULL;
192
8.27k
    OpenAPI_list_t *dns_security_protocolsList = NULL;
193
8.27k
    s_nssai_easdf_info_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "sNssaiEasdfInfoList");
194
8.27k
    if (s_nssai_easdf_info_list) {
195
848
        cJSON *s_nssai_easdf_info_list_local = NULL;
196
848
        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
654
        s_nssai_easdf_info_listList = OpenAPI_list_create();
202
203
654
        cJSON_ArrayForEach(s_nssai_easdf_info_list_local, s_nssai_easdf_info_list) {
204
460
            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
266
            OpenAPI_snssai_easdf_info_item_t *s_nssai_easdf_info_listItem = OpenAPI_snssai_easdf_info_item_parseFromJSON(s_nssai_easdf_info_list_local);
209
266
            if (!s_nssai_easdf_info_listItem) {
210
266
                ogs_error("No s_nssai_easdf_info_listItem");
211
266
                goto end;
212
266
            }
213
0
            OpenAPI_list_add(s_nssai_easdf_info_listList, s_nssai_easdf_info_listItem);
214
0
        }
215
654
    }
216
217
7.62k
    easdf_n6_ip_address_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "easdfN6IpAddressList");
218
7.62k
    if (easdf_n6_ip_address_list) {
219
1.06k
        cJSON *easdf_n6_ip_address_list_local = NULL;
220
1.06k
        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
860
        easdf_n6_ip_address_listList = OpenAPI_list_create();
226
227
1.32k
        cJSON_ArrayForEach(easdf_n6_ip_address_list_local, easdf_n6_ip_address_list) {
228
1.32k
            if (!cJSON_IsObject(easdf_n6_ip_address_list_local)) {
229
378
                ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [easdf_n6_ip_address_list]");
230
378
                goto end;
231
378
            }
232
942
            OpenAPI_ip_addr_t *easdf_n6_ip_address_listItem = OpenAPI_ip_addr_parseFromJSON(easdf_n6_ip_address_list_local);
233
942
            if (!easdf_n6_ip_address_listItem) {
234
74
                ogs_error("No easdf_n6_ip_address_listItem");
235
74
                goto end;
236
74
            }
237
868
            OpenAPI_list_add(easdf_n6_ip_address_listList, easdf_n6_ip_address_listItem);
238
868
        }
239
860
    }
240
241
6.96k
    upf_n6_ip_address_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "upfN6IpAddressList");
242
6.96k
    if (upf_n6_ip_address_list) {
243
1.60k
        cJSON *upf_n6_ip_address_list_local = NULL;
244
1.60k
        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.41k
        upf_n6_ip_address_listList = OpenAPI_list_create();
250
251
2.95k
        cJSON_ArrayForEach(upf_n6_ip_address_list_local, upf_n6_ip_address_list) {
252
2.95k
            if (!cJSON_IsObject(upf_n6_ip_address_list_local)) {
253
406
                ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [upf_n6_ip_address_list]");
254
406
                goto end;
255
406
            }
256
2.54k
            OpenAPI_ip_addr_t *upf_n6_ip_address_listItem = OpenAPI_ip_addr_parseFromJSON(upf_n6_ip_address_list_local);
257
2.54k
            if (!upf_n6_ip_address_listItem) {
258
130
                ogs_error("No upf_n6_ip_address_listItem");
259
130
                goto end;
260
130
            }
261
2.41k
            OpenAPI_list_add(upf_n6_ip_address_listList, upf_n6_ip_address_listItem);
262
2.41k
        }
263
1.41k
    }
264
265
6.23k
    n6_tunnel_info_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "n6TunnelInfoList");
266
6.23k
    if (n6_tunnel_info_list) {
267
1.42k
        cJSON *n6_tunnel_info_list_local_map = NULL;
268
1.42k
        if (!cJSON_IsObject(n6_tunnel_info_list) && !cJSON_IsNull(n6_tunnel_info_list)) {
269
212
            ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [n6_tunnel_info_list]");
270
212
            goto end;
271
212
        }
272
1.20k
        if (cJSON_IsObject(n6_tunnel_info_list)) {
273
1.01k
            n6_tunnel_info_listList = OpenAPI_list_create();
274
1.01k
            OpenAPI_map_t *localMapKeyPair = NULL;
275
6.42k
            cJSON_ArrayForEach(n6_tunnel_info_list_local_map, n6_tunnel_info_list) {
276
6.42k
                cJSON *localMapObject = n6_tunnel_info_list_local_map;
277
6.42k
                if (cJSON_IsObject(localMapObject)) {
278
5.82k
                    localMapKeyPair = OpenAPI_map_create(
279
5.82k
                        ogs_strdup(localMapObject->string), OpenAPI_interface_upf_info_item_parseFromJSON(localMapObject));
280
5.82k
                } else if (cJSON_IsNull(localMapObject)) {
281
363
                    localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), NULL);
282
363
                } else {
283
238
                    ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [inner]");
284
238
                    goto end;
285
238
                }
286
6.19k
                if (localMapKeyPair == NULL) {
287
0
                    ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [n6_tunnel_info_list]");
288
0
                    goto end;
289
0
                }
290
6.19k
                OpenAPI_list_add(n6_tunnel_info_listList, localMapKeyPair);
291
6.19k
            }
292
1.01k
        }
293
1.20k
    }
294
295
5.78k
    dns_security_protocols = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "dnsSecurityProtocols");
296
5.78k
    if (dns_security_protocols) {
297
883
        cJSON *dns_security_protocols_local = NULL;
298
883
        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
688
        dns_security_protocolsList = OpenAPI_list_create();
304
305
1.44k
        cJSON_ArrayForEach(dns_security_protocols_local, dns_security_protocols) {
306
1.44k
            OpenAPI_dns_security_protocol_e localEnum = OpenAPI_dns_security_protocol_NULL;
307
1.44k
            if (!cJSON_IsString(dns_security_protocols_local)) {
308
194
                ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [dns_security_protocols]");
309
194
                goto end;
310
194
            }
311
1.25k
            localEnum = OpenAPI_dns_security_protocol_FromString(dns_security_protocols_local->valuestring);
312
1.25k
            if (!localEnum) {
313
827
                ogs_info("Enum value \"%s\" for field \"dns_security_protocols\" is not supported. Ignoring it ...",
314
827
                         dns_security_protocols_local->valuestring);
315
827
            } else {
316
427
                OpenAPI_list_add(dns_security_protocolsList, (void *)localEnum);
317
427
            }
318
1.25k
        }
319
494
        if (dns_security_protocolsList->count == 0) {
320
254
            ogs_error("OpenAPI_easdf_info_parseFromJSON() failed: Expected dns_security_protocolsList to not be empty (after ignoring unsupported enum values).");
321
254
            goto end;
322
254
        }
323
494
    }
324
325
5.14k
    easdf_info_local_var = OpenAPI_easdf_info_create (
326
5.14k
        s_nssai_easdf_info_list ? s_nssai_easdf_info_listList : NULL,
327
5.14k
        easdf_n6_ip_address_list ? easdf_n6_ip_address_listList : NULL,
328
5.14k
        upf_n6_ip_address_list ? upf_n6_ip_address_listList : NULL,
329
5.14k
        n6_tunnel_info_list ? n6_tunnel_info_listList : NULL,
330
5.14k
        dns_security_protocols ? dns_security_protocolsList : NULL
331
5.14k
    );
332
333
5.14k
    return easdf_info_local_var;
334
3.13k
end:
335
3.13k
    if (s_nssai_easdf_info_listList) {
336
460
        OpenAPI_list_for_each(s_nssai_easdf_info_listList, node) {
337
0
            OpenAPI_snssai_easdf_info_item_free(node->data);
338
0
        }
339
460
        OpenAPI_list_free(s_nssai_easdf_info_listList);
340
460
        s_nssai_easdf_info_listList = NULL;
341
460
    }
342
3.13k
    if (easdf_n6_ip_address_listList) {
343
452
        OpenAPI_list_for_each(easdf_n6_ip_address_listList, node) {
344
407
            OpenAPI_ip_addr_free(node->data);
345
407
        }
346
452
        OpenAPI_list_free(easdf_n6_ip_address_listList);
347
452
        easdf_n6_ip_address_listList = NULL;
348
452
    }
349
3.13k
    if (upf_n6_ip_address_listList) {
350
1.23k
        OpenAPI_list_for_each(upf_n6_ip_address_listList, node) {
351
1.23k
            OpenAPI_ip_addr_free(node->data);
352
1.23k
        }
353
536
        OpenAPI_list_free(upf_n6_ip_address_listList);
354
536
        upf_n6_ip_address_listList = NULL;
355
536
    }
356
3.13k
    if (n6_tunnel_info_listList) {
357
2.06k
        OpenAPI_list_for_each(n6_tunnel_info_listList, node) {
358
2.06k
            OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data;
359
2.06k
            ogs_free(localKeyValue->key);
360
2.06k
            OpenAPI_interface_upf_info_item_free(localKeyValue->value);
361
2.06k
            OpenAPI_map_free(localKeyValue);
362
2.06k
        }
363
238
        OpenAPI_list_free(n6_tunnel_info_listList);
364
238
        n6_tunnel_info_listList = NULL;
365
238
    }
366
3.13k
    if (dns_security_protocolsList) {
367
448
        OpenAPI_list_free(dns_security_protocolsList);
368
448
        dns_security_protocolsList = NULL;
369
448
    }
370
3.13k
    return NULL;
371
5.78k
}
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