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/n3ga_location.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "n3ga_location.h"
6
7
OpenAPI_n3ga_location_t *OpenAPI_n3ga_location_create(
8
    OpenAPI_tai_t *n3gpp_tai,
9
    char *n3_iwf_id,
10
    char *ue_ipv4_addr,
11
    char *ue_ipv6_addr,
12
    bool is_port_number,
13
    int port_number,
14
    OpenAPI_transport_protocol_e protocol,
15
    OpenAPI_tnap_id_t *tnap_id,
16
    OpenAPI_twap_id_t *twap_id,
17
    OpenAPI_hfc_node_id_t *hfc_node_id,
18
    char *gli,
19
    OpenAPI_line_type_e w5gban_line_type,
20
    char *gci
21
)
22
0
{
23
0
    OpenAPI_n3ga_location_t *n3ga_location_local_var = ogs_malloc(sizeof(OpenAPI_n3ga_location_t));
24
0
    ogs_assert(n3ga_location_local_var);
25
26
0
    n3ga_location_local_var->n3gpp_tai = n3gpp_tai;
27
0
    n3ga_location_local_var->n3_iwf_id = n3_iwf_id;
28
0
    n3ga_location_local_var->ue_ipv4_addr = ue_ipv4_addr;
29
0
    n3ga_location_local_var->ue_ipv6_addr = ue_ipv6_addr;
30
0
    n3ga_location_local_var->is_port_number = is_port_number;
31
0
    n3ga_location_local_var->port_number = port_number;
32
0
    n3ga_location_local_var->protocol = protocol;
33
0
    n3ga_location_local_var->tnap_id = tnap_id;
34
0
    n3ga_location_local_var->twap_id = twap_id;
35
0
    n3ga_location_local_var->hfc_node_id = hfc_node_id;
36
0
    n3ga_location_local_var->gli = gli;
37
0
    n3ga_location_local_var->w5gban_line_type = w5gban_line_type;
38
0
    n3ga_location_local_var->gci = gci;
39
40
0
    return n3ga_location_local_var;
41
0
}
42
43
void OpenAPI_n3ga_location_free(OpenAPI_n3ga_location_t *n3ga_location)
44
0
{
45
0
    OpenAPI_lnode_t *node = NULL;
46
47
0
    if (NULL == n3ga_location) {
48
0
        return;
49
0
    }
50
0
    if (n3ga_location->n3gpp_tai) {
51
0
        OpenAPI_tai_free(n3ga_location->n3gpp_tai);
52
0
        n3ga_location->n3gpp_tai = NULL;
53
0
    }
54
0
    if (n3ga_location->n3_iwf_id) {
55
0
        ogs_free(n3ga_location->n3_iwf_id);
56
0
        n3ga_location->n3_iwf_id = NULL;
57
0
    }
58
0
    if (n3ga_location->ue_ipv4_addr) {
59
0
        ogs_free(n3ga_location->ue_ipv4_addr);
60
0
        n3ga_location->ue_ipv4_addr = NULL;
61
0
    }
62
0
    if (n3ga_location->ue_ipv6_addr) {
63
0
        ogs_free(n3ga_location->ue_ipv6_addr);
64
0
        n3ga_location->ue_ipv6_addr = NULL;
65
0
    }
66
0
    if (n3ga_location->tnap_id) {
67
0
        OpenAPI_tnap_id_free(n3ga_location->tnap_id);
68
0
        n3ga_location->tnap_id = NULL;
69
0
    }
70
0
    if (n3ga_location->twap_id) {
71
0
        OpenAPI_twap_id_free(n3ga_location->twap_id);
72
0
        n3ga_location->twap_id = NULL;
73
0
    }
74
0
    if (n3ga_location->hfc_node_id) {
75
0
        OpenAPI_hfc_node_id_free(n3ga_location->hfc_node_id);
76
0
        n3ga_location->hfc_node_id = NULL;
77
0
    }
78
0
    if (n3ga_location->gli) {
79
0
        ogs_free(n3ga_location->gli);
80
0
        n3ga_location->gli = NULL;
81
0
    }
82
0
    if (n3ga_location->gci) {
83
0
        ogs_free(n3ga_location->gci);
84
0
        n3ga_location->gci = NULL;
85
0
    }
86
0
    ogs_free(n3ga_location);
87
0
}
88
89
cJSON *OpenAPI_n3ga_location_convertToJSON(OpenAPI_n3ga_location_t *n3ga_location)
90
0
{
91
0
    cJSON *item = NULL;
92
0
    OpenAPI_lnode_t *node = NULL;
93
94
0
    if (n3ga_location == NULL) {
95
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [N3gaLocation]");
96
0
        return NULL;
97
0
    }
98
99
0
    item = cJSON_CreateObject();
100
0
    if (n3ga_location->n3gpp_tai) {
101
0
    cJSON *n3gpp_tai_local_JSON = OpenAPI_tai_convertToJSON(n3ga_location->n3gpp_tai);
102
0
    if (n3gpp_tai_local_JSON == NULL) {
103
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [n3gpp_tai]");
104
0
        goto end;
105
0
    }
106
0
    cJSON_AddItemToObject(item, "n3gppTai", n3gpp_tai_local_JSON);
107
0
    if (item->child == NULL) {
108
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [n3gpp_tai]");
109
0
        goto end;
110
0
    }
111
0
    }
112
113
0
    if (n3ga_location->n3_iwf_id) {
114
0
    if (cJSON_AddStringToObject(item, "n3IwfId", n3ga_location->n3_iwf_id) == NULL) {
115
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [n3_iwf_id]");
116
0
        goto end;
117
0
    }
118
0
    }
119
120
0
    if (n3ga_location->ue_ipv4_addr) {
121
0
    if (cJSON_AddStringToObject(item, "ueIpv4Addr", n3ga_location->ue_ipv4_addr) == NULL) {
122
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [ue_ipv4_addr]");
123
0
        goto end;
124
0
    }
125
0
    }
126
127
0
    if (n3ga_location->ue_ipv6_addr) {
128
0
    if (cJSON_AddStringToObject(item, "ueIpv6Addr", n3ga_location->ue_ipv6_addr) == NULL) {
129
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [ue_ipv6_addr]");
130
0
        goto end;
131
0
    }
132
0
    }
133
134
0
    if (n3ga_location->is_port_number) {
135
0
    if (cJSON_AddNumberToObject(item, "portNumber", n3ga_location->port_number) == NULL) {
136
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [port_number]");
137
0
        goto end;
138
0
    }
139
0
    }
140
141
0
    if (n3ga_location->protocol != OpenAPI_transport_protocol_NULL) {
142
0
    if (cJSON_AddStringToObject(item, "protocol", OpenAPI_transport_protocol_ToString(n3ga_location->protocol)) == NULL) {
143
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [protocol]");
144
0
        goto end;
145
0
    }
146
0
    }
147
148
0
    if (n3ga_location->tnap_id) {
149
0
    cJSON *tnap_id_local_JSON = OpenAPI_tnap_id_convertToJSON(n3ga_location->tnap_id);
150
0
    if (tnap_id_local_JSON == NULL) {
151
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [tnap_id]");
152
0
        goto end;
153
0
    }
154
0
    cJSON_AddItemToObject(item, "tnapId", tnap_id_local_JSON);
155
0
    if (item->child == NULL) {
156
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [tnap_id]");
157
0
        goto end;
158
0
    }
159
0
    }
160
161
0
    if (n3ga_location->twap_id) {
162
0
    cJSON *twap_id_local_JSON = OpenAPI_twap_id_convertToJSON(n3ga_location->twap_id);
163
0
    if (twap_id_local_JSON == NULL) {
164
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [twap_id]");
165
0
        goto end;
166
0
    }
167
0
    cJSON_AddItemToObject(item, "twapId", twap_id_local_JSON);
168
0
    if (item->child == NULL) {
169
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [twap_id]");
170
0
        goto end;
171
0
    }
172
0
    }
173
174
0
    if (n3ga_location->hfc_node_id) {
175
0
    cJSON *hfc_node_id_local_JSON = OpenAPI_hfc_node_id_convertToJSON(n3ga_location->hfc_node_id);
176
0
    if (hfc_node_id_local_JSON == NULL) {
177
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [hfc_node_id]");
178
0
        goto end;
179
0
    }
180
0
    cJSON_AddItemToObject(item, "hfcNodeId", hfc_node_id_local_JSON);
181
0
    if (item->child == NULL) {
182
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [hfc_node_id]");
183
0
        goto end;
184
0
    }
185
0
    }
186
187
0
    if (n3ga_location->gli) {
188
0
    if (cJSON_AddStringToObject(item, "gli", n3ga_location->gli) == NULL) {
189
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [gli]");
190
0
        goto end;
191
0
    }
192
0
    }
193
194
0
    if (n3ga_location->w5gban_line_type != OpenAPI_line_type_NULL) {
195
0
    if (cJSON_AddStringToObject(item, "w5gbanLineType", OpenAPI_line_type_ToString(n3ga_location->w5gban_line_type)) == NULL) {
196
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [w5gban_line_type]");
197
0
        goto end;
198
0
    }
199
0
    }
200
201
0
    if (n3ga_location->gci) {
202
0
    if (cJSON_AddStringToObject(item, "gci", n3ga_location->gci) == NULL) {
203
0
        ogs_error("OpenAPI_n3ga_location_convertToJSON() failed [gci]");
204
0
        goto end;
205
0
    }
206
0
    }
207
208
0
end:
209
0
    return item;
210
0
}
211
212
OpenAPI_n3ga_location_t *OpenAPI_n3ga_location_parseFromJSON(cJSON *n3ga_locationJSON)
213
0
{
214
0
    OpenAPI_n3ga_location_t *n3ga_location_local_var = NULL;
215
0
    OpenAPI_lnode_t *node = NULL;
216
0
    cJSON *n3gpp_tai = NULL;
217
0
    OpenAPI_tai_t *n3gpp_tai_local_nonprim = NULL;
218
0
    cJSON *n3_iwf_id = NULL;
219
0
    cJSON *ue_ipv4_addr = NULL;
220
0
    cJSON *ue_ipv6_addr = NULL;
221
0
    cJSON *port_number = NULL;
222
0
    cJSON *protocol = NULL;
223
0
    OpenAPI_transport_protocol_e protocolVariable = 0;
224
0
    cJSON *tnap_id = NULL;
225
0
    OpenAPI_tnap_id_t *tnap_id_local_nonprim = NULL;
226
0
    cJSON *twap_id = NULL;
227
0
    OpenAPI_twap_id_t *twap_id_local_nonprim = NULL;
228
0
    cJSON *hfc_node_id = NULL;
229
0
    OpenAPI_hfc_node_id_t *hfc_node_id_local_nonprim = NULL;
230
0
    cJSON *gli = NULL;
231
0
    cJSON *w5gban_line_type = NULL;
232
0
    OpenAPI_line_type_e w5gban_line_typeVariable = 0;
233
0
    cJSON *gci = NULL;
234
0
    n3gpp_tai = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "n3gppTai");
235
0
    if (n3gpp_tai) {
236
0
    n3gpp_tai_local_nonprim = OpenAPI_tai_parseFromJSON(n3gpp_tai);
237
0
    if (!n3gpp_tai_local_nonprim) {
238
0
        ogs_error("OpenAPI_tai_parseFromJSON failed [n3gpp_tai]");
239
0
        goto end;
240
0
    }
241
0
    }
242
243
0
    n3_iwf_id = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "n3IwfId");
244
0
    if (n3_iwf_id) {
245
0
    if (!cJSON_IsString(n3_iwf_id) && !cJSON_IsNull(n3_iwf_id)) {
246
0
        ogs_error("OpenAPI_n3ga_location_parseFromJSON() failed [n3_iwf_id]");
247
0
        goto end;
248
0
    }
249
0
    }
250
251
0
    ue_ipv4_addr = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "ueIpv4Addr");
252
0
    if (ue_ipv4_addr) {
253
0
    if (!cJSON_IsString(ue_ipv4_addr) && !cJSON_IsNull(ue_ipv4_addr)) {
254
0
        ogs_error("OpenAPI_n3ga_location_parseFromJSON() failed [ue_ipv4_addr]");
255
0
        goto end;
256
0
    }
257
0
    }
258
259
0
    ue_ipv6_addr = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "ueIpv6Addr");
260
0
    if (ue_ipv6_addr) {
261
0
    if (!cJSON_IsString(ue_ipv6_addr) && !cJSON_IsNull(ue_ipv6_addr)) {
262
0
        ogs_error("OpenAPI_n3ga_location_parseFromJSON() failed [ue_ipv6_addr]");
263
0
        goto end;
264
0
    }
265
0
    }
266
267
0
    port_number = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "portNumber");
268
0
    if (port_number) {
269
0
    if (!cJSON_IsNumber(port_number)) {
270
0
        ogs_error("OpenAPI_n3ga_location_parseFromJSON() failed [port_number]");
271
0
        goto end;
272
0
    }
273
0
    }
274
275
0
    protocol = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "protocol");
276
0
    if (protocol) {
277
0
    if (!cJSON_IsString(protocol)) {
278
0
        ogs_error("OpenAPI_n3ga_location_parseFromJSON() failed [protocol]");
279
0
        goto end;
280
0
    }
281
0
    protocolVariable = OpenAPI_transport_protocol_FromString(protocol->valuestring);
282
0
    }
283
284
0
    tnap_id = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "tnapId");
285
0
    if (tnap_id) {
286
0
    tnap_id_local_nonprim = OpenAPI_tnap_id_parseFromJSON(tnap_id);
287
0
    if (!tnap_id_local_nonprim) {
288
0
        ogs_error("OpenAPI_tnap_id_parseFromJSON failed [tnap_id]");
289
0
        goto end;
290
0
    }
291
0
    }
292
293
0
    twap_id = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "twapId");
294
0
    if (twap_id) {
295
0
    twap_id_local_nonprim = OpenAPI_twap_id_parseFromJSON(twap_id);
296
0
    if (!twap_id_local_nonprim) {
297
0
        ogs_error("OpenAPI_twap_id_parseFromJSON failed [twap_id]");
298
0
        goto end;
299
0
    }
300
0
    }
301
302
0
    hfc_node_id = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "hfcNodeId");
303
0
    if (hfc_node_id) {
304
0
    hfc_node_id_local_nonprim = OpenAPI_hfc_node_id_parseFromJSON(hfc_node_id);
305
0
    if (!hfc_node_id_local_nonprim) {
306
0
        ogs_error("OpenAPI_hfc_node_id_parseFromJSON failed [hfc_node_id]");
307
0
        goto end;
308
0
    }
309
0
    }
310
311
0
    gli = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "gli");
312
0
    if (gli) {
313
0
    if (!cJSON_IsString(gli) && !cJSON_IsNull(gli)) {
314
0
        ogs_error("OpenAPI_n3ga_location_parseFromJSON() failed [gli]");
315
0
        goto end;
316
0
    }
317
0
    }
318
319
0
    w5gban_line_type = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "w5gbanLineType");
320
0
    if (w5gban_line_type) {
321
0
    if (!cJSON_IsString(w5gban_line_type)) {
322
0
        ogs_error("OpenAPI_n3ga_location_parseFromJSON() failed [w5gban_line_type]");
323
0
        goto end;
324
0
    }
325
0
    w5gban_line_typeVariable = OpenAPI_line_type_FromString(w5gban_line_type->valuestring);
326
0
    }
327
328
0
    gci = cJSON_GetObjectItemCaseSensitive(n3ga_locationJSON, "gci");
329
0
    if (gci) {
330
0
    if (!cJSON_IsString(gci) && !cJSON_IsNull(gci)) {
331
0
        ogs_error("OpenAPI_n3ga_location_parseFromJSON() failed [gci]");
332
0
        goto end;
333
0
    }
334
0
    }
335
336
0
    n3ga_location_local_var = OpenAPI_n3ga_location_create (
337
0
        n3gpp_tai ? n3gpp_tai_local_nonprim : NULL,
338
0
        n3_iwf_id && !cJSON_IsNull(n3_iwf_id) ? ogs_strdup(n3_iwf_id->valuestring) : NULL,
339
0
        ue_ipv4_addr && !cJSON_IsNull(ue_ipv4_addr) ? ogs_strdup(ue_ipv4_addr->valuestring) : NULL,
340
0
        ue_ipv6_addr && !cJSON_IsNull(ue_ipv6_addr) ? ogs_strdup(ue_ipv6_addr->valuestring) : NULL,
341
0
        port_number ? true : false,
342
0
        port_number ? port_number->valuedouble : 0,
343
0
        protocol ? protocolVariable : 0,
344
0
        tnap_id ? tnap_id_local_nonprim : NULL,
345
0
        twap_id ? twap_id_local_nonprim : NULL,
346
0
        hfc_node_id ? hfc_node_id_local_nonprim : NULL,
347
0
        gli && !cJSON_IsNull(gli) ? ogs_strdup(gli->valuestring) : NULL,
348
0
        w5gban_line_type ? w5gban_line_typeVariable : 0,
349
0
        gci && !cJSON_IsNull(gci) ? ogs_strdup(gci->valuestring) : NULL
350
0
    );
351
352
0
    return n3ga_location_local_var;
353
0
end:
354
0
    if (n3gpp_tai_local_nonprim) {
355
0
        OpenAPI_tai_free(n3gpp_tai_local_nonprim);
356
0
        n3gpp_tai_local_nonprim = NULL;
357
0
    }
358
0
    if (tnap_id_local_nonprim) {
359
0
        OpenAPI_tnap_id_free(tnap_id_local_nonprim);
360
0
        tnap_id_local_nonprim = NULL;
361
0
    }
362
0
    if (twap_id_local_nonprim) {
363
0
        OpenAPI_twap_id_free(twap_id_local_nonprim);
364
0
        twap_id_local_nonprim = NULL;
365
0
    }
366
0
    if (hfc_node_id_local_nonprim) {
367
0
        OpenAPI_hfc_node_id_free(hfc_node_id_local_nonprim);
368
0
        hfc_node_id_local_nonprim = NULL;
369
0
    }
370
0
    return NULL;
371
0
}
372
373
OpenAPI_n3ga_location_t *OpenAPI_n3ga_location_copy(OpenAPI_n3ga_location_t *dst, OpenAPI_n3ga_location_t *src)
374
0
{
375
0
    cJSON *item = NULL;
376
0
    char *content = NULL;
377
378
0
    ogs_assert(src);
379
0
    item = OpenAPI_n3ga_location_convertToJSON(src);
380
0
    if (!item) {
381
0
        ogs_error("OpenAPI_n3ga_location_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_n3ga_location_free(dst);
401
0
    dst = OpenAPI_n3ga_location_parseFromJSON(item);
402
0
    cJSON_Delete(item);
403
404
0
    return dst;
405
0
}
406