Coverage Report

Created: 2026-09-27 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/eutra_location.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "eutra_location.h"
6
7
OpenAPI_eutra_location_t *OpenAPI_eutra_location_create(
8
    OpenAPI_tai_t *tai,
9
    bool is_ignore_tai,
10
    int ignore_tai,
11
    OpenAPI_ecgi_t *ecgi,
12
    bool is_ignore_ecgi,
13
    int ignore_ecgi,
14
    bool is_age_of_location_information,
15
    int age_of_location_information,
16
    char *ue_location_timestamp,
17
    char *geographical_information,
18
    char *geodetic_information,
19
    OpenAPI_global_ran_node_id_t *global_ngenb_id,
20
    OpenAPI_global_ran_node_id_t *global_enb_id
21
)
22
0
{
23
0
    OpenAPI_eutra_location_t *eutra_location_local_var = ogs_malloc(sizeof(OpenAPI_eutra_location_t));
24
0
    ogs_assert(eutra_location_local_var);
25
26
0
    eutra_location_local_var->tai = tai;
27
0
    eutra_location_local_var->is_ignore_tai = is_ignore_tai;
28
0
    eutra_location_local_var->ignore_tai = ignore_tai;
29
0
    eutra_location_local_var->ecgi = ecgi;
30
0
    eutra_location_local_var->is_ignore_ecgi = is_ignore_ecgi;
31
0
    eutra_location_local_var->ignore_ecgi = ignore_ecgi;
32
0
    eutra_location_local_var->is_age_of_location_information = is_age_of_location_information;
33
0
    eutra_location_local_var->age_of_location_information = age_of_location_information;
34
0
    eutra_location_local_var->ue_location_timestamp = ue_location_timestamp;
35
0
    eutra_location_local_var->geographical_information = geographical_information;
36
0
    eutra_location_local_var->geodetic_information = geodetic_information;
37
0
    eutra_location_local_var->global_ngenb_id = global_ngenb_id;
38
0
    eutra_location_local_var->global_enb_id = global_enb_id;
39
40
0
    return eutra_location_local_var;
41
0
}
42
43
void OpenAPI_eutra_location_free(OpenAPI_eutra_location_t *eutra_location)
44
0
{
45
0
    OpenAPI_lnode_t *node = NULL;
46
47
0
    if (NULL == eutra_location) {
48
0
        return;
49
0
    }
50
0
    if (eutra_location->tai) {
51
0
        OpenAPI_tai_free(eutra_location->tai);
52
0
        eutra_location->tai = NULL;
53
0
    }
54
0
    if (eutra_location->ecgi) {
55
0
        OpenAPI_ecgi_free(eutra_location->ecgi);
56
0
        eutra_location->ecgi = NULL;
57
0
    }
58
0
    if (eutra_location->ue_location_timestamp) {
59
0
        ogs_free(eutra_location->ue_location_timestamp);
60
0
        eutra_location->ue_location_timestamp = NULL;
61
0
    }
62
0
    if (eutra_location->geographical_information) {
63
0
        ogs_free(eutra_location->geographical_information);
64
0
        eutra_location->geographical_information = NULL;
65
0
    }
66
0
    if (eutra_location->geodetic_information) {
67
0
        ogs_free(eutra_location->geodetic_information);
68
0
        eutra_location->geodetic_information = NULL;
69
0
    }
70
0
    if (eutra_location->global_ngenb_id) {
71
0
        OpenAPI_global_ran_node_id_free(eutra_location->global_ngenb_id);
72
0
        eutra_location->global_ngenb_id = NULL;
73
0
    }
74
0
    if (eutra_location->global_enb_id) {
75
0
        OpenAPI_global_ran_node_id_free(eutra_location->global_enb_id);
76
0
        eutra_location->global_enb_id = NULL;
77
0
    }
78
0
    ogs_free(eutra_location);
79
0
}
80
81
cJSON *OpenAPI_eutra_location_convertToJSON(OpenAPI_eutra_location_t *eutra_location)
82
0
{
83
0
    cJSON *item = NULL;
84
0
    OpenAPI_lnode_t *node = NULL;
85
86
0
    if (eutra_location == NULL) {
87
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [EutraLocation]");
88
0
        return NULL;
89
0
    }
90
91
0
    item = cJSON_CreateObject();
92
0
    if (!eutra_location->tai) {
93
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [tai]");
94
0
        return NULL;
95
0
    }
96
0
    cJSON *tai_local_JSON = OpenAPI_tai_convertToJSON(eutra_location->tai);
97
0
    if (tai_local_JSON == NULL) {
98
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [tai]");
99
0
        goto end;
100
0
    }
101
0
    cJSON_AddItemToObject(item, "tai", tai_local_JSON);
102
0
    if (item->child == NULL) {
103
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [tai]");
104
0
        goto end;
105
0
    }
106
107
0
    if (eutra_location->is_ignore_tai) {
108
0
    if (cJSON_AddBoolToObject(item, "ignoreTai", eutra_location->ignore_tai) == NULL) {
109
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [ignore_tai]");
110
0
        goto end;
111
0
    }
112
0
    }
113
114
0
    if (!eutra_location->ecgi) {
115
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [ecgi]");
116
0
        return NULL;
117
0
    }
118
0
    cJSON *ecgi_local_JSON = OpenAPI_ecgi_convertToJSON(eutra_location->ecgi);
119
0
    if (ecgi_local_JSON == NULL) {
120
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [ecgi]");
121
0
        goto end;
122
0
    }
123
0
    cJSON_AddItemToObject(item, "ecgi", ecgi_local_JSON);
124
0
    if (item->child == NULL) {
125
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [ecgi]");
126
0
        goto end;
127
0
    }
128
129
0
    if (eutra_location->is_ignore_ecgi) {
130
0
    if (cJSON_AddBoolToObject(item, "ignoreEcgi", eutra_location->ignore_ecgi) == NULL) {
131
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [ignore_ecgi]");
132
0
        goto end;
133
0
    }
134
0
    }
135
136
0
    if (eutra_location->is_age_of_location_information) {
137
0
    if (cJSON_AddNumberToObject(item, "ageOfLocationInformation", eutra_location->age_of_location_information) == NULL) {
138
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [age_of_location_information]");
139
0
        goto end;
140
0
    }
141
0
    }
142
143
0
    if (eutra_location->ue_location_timestamp) {
144
0
    if (cJSON_AddStringToObject(item, "ueLocationTimestamp", eutra_location->ue_location_timestamp) == NULL) {
145
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [ue_location_timestamp]");
146
0
        goto end;
147
0
    }
148
0
    }
149
150
0
    if (eutra_location->geographical_information) {
151
0
    if (cJSON_AddStringToObject(item, "geographicalInformation", eutra_location->geographical_information) == NULL) {
152
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [geographical_information]");
153
0
        goto end;
154
0
    }
155
0
    }
156
157
0
    if (eutra_location->geodetic_information) {
158
0
    if (cJSON_AddStringToObject(item, "geodeticInformation", eutra_location->geodetic_information) == NULL) {
159
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [geodetic_information]");
160
0
        goto end;
161
0
    }
162
0
    }
163
164
0
    if (eutra_location->global_ngenb_id) {
165
0
    cJSON *global_ngenb_id_local_JSON = OpenAPI_global_ran_node_id_convertToJSON(eutra_location->global_ngenb_id);
166
0
    if (global_ngenb_id_local_JSON == NULL) {
167
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [global_ngenb_id]");
168
0
        goto end;
169
0
    }
170
0
    cJSON_AddItemToObject(item, "globalNgenbId", global_ngenb_id_local_JSON);
171
0
    if (item->child == NULL) {
172
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [global_ngenb_id]");
173
0
        goto end;
174
0
    }
175
0
    }
176
177
0
    if (eutra_location->global_enb_id) {
178
0
    cJSON *global_enb_id_local_JSON = OpenAPI_global_ran_node_id_convertToJSON(eutra_location->global_enb_id);
179
0
    if (global_enb_id_local_JSON == NULL) {
180
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [global_enb_id]");
181
0
        goto end;
182
0
    }
183
0
    cJSON_AddItemToObject(item, "globalENbId", global_enb_id_local_JSON);
184
0
    if (item->child == NULL) {
185
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed [global_enb_id]");
186
0
        goto end;
187
0
    }
188
0
    }
189
190
0
end:
191
0
    return item;
192
0
}
193
194
OpenAPI_eutra_location_t *OpenAPI_eutra_location_parseFromJSON(cJSON *eutra_locationJSON)
195
0
{
196
0
    OpenAPI_eutra_location_t *eutra_location_local_var = NULL;
197
0
    OpenAPI_lnode_t *node = NULL;
198
0
    cJSON *tai = NULL;
199
0
    OpenAPI_tai_t *tai_local_nonprim = NULL;
200
0
    cJSON *ignore_tai = NULL;
201
0
    cJSON *ecgi = NULL;
202
0
    OpenAPI_ecgi_t *ecgi_local_nonprim = NULL;
203
0
    cJSON *ignore_ecgi = NULL;
204
0
    cJSON *age_of_location_information = NULL;
205
0
    cJSON *ue_location_timestamp = NULL;
206
0
    cJSON *geographical_information = NULL;
207
0
    cJSON *geodetic_information = NULL;
208
0
    cJSON *global_ngenb_id = NULL;
209
0
    OpenAPI_global_ran_node_id_t *global_ngenb_id_local_nonprim = NULL;
210
0
    cJSON *global_enb_id = NULL;
211
0
    OpenAPI_global_ran_node_id_t *global_enb_id_local_nonprim = NULL;
212
0
    tai = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "tai");
213
0
    if (!tai) {
214
0
        ogs_error("OpenAPI_eutra_location_parseFromJSON() failed [tai]");
215
0
        goto end;
216
0
    }
217
0
    tai_local_nonprim = OpenAPI_tai_parseFromJSON(tai);
218
0
    if (!tai_local_nonprim) {
219
0
        ogs_error("OpenAPI_tai_parseFromJSON failed [tai]");
220
0
        goto end;
221
0
    }
222
223
0
    ignore_tai = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "ignoreTai");
224
0
    if (ignore_tai) {
225
0
    if (!cJSON_IsBool(ignore_tai)) {
226
0
        ogs_error("OpenAPI_eutra_location_parseFromJSON() failed [ignore_tai]");
227
0
        goto end;
228
0
    }
229
0
    }
230
231
0
    ecgi = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "ecgi");
232
0
    if (!ecgi) {
233
0
        ogs_error("OpenAPI_eutra_location_parseFromJSON() failed [ecgi]");
234
0
        goto end;
235
0
    }
236
0
    ecgi_local_nonprim = OpenAPI_ecgi_parseFromJSON(ecgi);
237
0
    if (!ecgi_local_nonprim) {
238
0
        ogs_error("OpenAPI_ecgi_parseFromJSON failed [ecgi]");
239
0
        goto end;
240
0
    }
241
242
0
    ignore_ecgi = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "ignoreEcgi");
243
0
    if (ignore_ecgi) {
244
0
    if (!cJSON_IsBool(ignore_ecgi)) {
245
0
        ogs_error("OpenAPI_eutra_location_parseFromJSON() failed [ignore_ecgi]");
246
0
        goto end;
247
0
    }
248
0
    }
249
250
0
    age_of_location_information = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "ageOfLocationInformation");
251
0
    if (age_of_location_information) {
252
0
    if (!cJSON_IsNumber(age_of_location_information)) {
253
0
        ogs_error("OpenAPI_eutra_location_parseFromJSON() failed [age_of_location_information]");
254
0
        goto end;
255
0
    }
256
0
    }
257
258
0
    ue_location_timestamp = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "ueLocationTimestamp");
259
0
    if (ue_location_timestamp) {
260
0
    if (!cJSON_IsString(ue_location_timestamp) && !cJSON_IsNull(ue_location_timestamp)) {
261
0
        ogs_error("OpenAPI_eutra_location_parseFromJSON() failed [ue_location_timestamp]");
262
0
        goto end;
263
0
    }
264
0
    }
265
266
0
    geographical_information = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "geographicalInformation");
267
0
    if (geographical_information) {
268
0
    if (!cJSON_IsString(geographical_information) && !cJSON_IsNull(geographical_information)) {
269
0
        ogs_error("OpenAPI_eutra_location_parseFromJSON() failed [geographical_information]");
270
0
        goto end;
271
0
    }
272
0
    }
273
274
0
    geodetic_information = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "geodeticInformation");
275
0
    if (geodetic_information) {
276
0
    if (!cJSON_IsString(geodetic_information) && !cJSON_IsNull(geodetic_information)) {
277
0
        ogs_error("OpenAPI_eutra_location_parseFromJSON() failed [geodetic_information]");
278
0
        goto end;
279
0
    }
280
0
    }
281
282
0
    global_ngenb_id = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "globalNgenbId");
283
0
    if (global_ngenb_id) {
284
0
    global_ngenb_id_local_nonprim = OpenAPI_global_ran_node_id_parseFromJSON(global_ngenb_id);
285
0
    if (!global_ngenb_id_local_nonprim) {
286
0
        ogs_error("OpenAPI_global_ran_node_id_parseFromJSON failed [global_ngenb_id]");
287
0
        goto end;
288
0
    }
289
0
    }
290
291
0
    global_enb_id = cJSON_GetObjectItemCaseSensitive(eutra_locationJSON, "globalENbId");
292
0
    if (global_enb_id) {
293
0
    global_enb_id_local_nonprim = OpenAPI_global_ran_node_id_parseFromJSON(global_enb_id);
294
0
    if (!global_enb_id_local_nonprim) {
295
0
        ogs_error("OpenAPI_global_ran_node_id_parseFromJSON failed [global_enb_id]");
296
0
        goto end;
297
0
    }
298
0
    }
299
300
0
    eutra_location_local_var = OpenAPI_eutra_location_create (
301
0
        tai_local_nonprim,
302
0
        ignore_tai ? true : false,
303
0
        ignore_tai ? ignore_tai->valueint : 0,
304
0
        ecgi_local_nonprim,
305
0
        ignore_ecgi ? true : false,
306
0
        ignore_ecgi ? ignore_ecgi->valueint : 0,
307
0
        age_of_location_information ? true : false,
308
0
        age_of_location_information ? age_of_location_information->valuedouble : 0,
309
0
        ue_location_timestamp && !cJSON_IsNull(ue_location_timestamp) ? ogs_strdup(ue_location_timestamp->valuestring) : NULL,
310
0
        geographical_information && !cJSON_IsNull(geographical_information) ? ogs_strdup(geographical_information->valuestring) : NULL,
311
0
        geodetic_information && !cJSON_IsNull(geodetic_information) ? ogs_strdup(geodetic_information->valuestring) : NULL,
312
0
        global_ngenb_id ? global_ngenb_id_local_nonprim : NULL,
313
0
        global_enb_id ? global_enb_id_local_nonprim : NULL
314
0
    );
315
316
0
    return eutra_location_local_var;
317
0
end:
318
0
    if (tai_local_nonprim) {
319
0
        OpenAPI_tai_free(tai_local_nonprim);
320
0
        tai_local_nonprim = NULL;
321
0
    }
322
0
    if (ecgi_local_nonprim) {
323
0
        OpenAPI_ecgi_free(ecgi_local_nonprim);
324
0
        ecgi_local_nonprim = NULL;
325
0
    }
326
0
    if (global_ngenb_id_local_nonprim) {
327
0
        OpenAPI_global_ran_node_id_free(global_ngenb_id_local_nonprim);
328
0
        global_ngenb_id_local_nonprim = NULL;
329
0
    }
330
0
    if (global_enb_id_local_nonprim) {
331
0
        OpenAPI_global_ran_node_id_free(global_enb_id_local_nonprim);
332
0
        global_enb_id_local_nonprim = NULL;
333
0
    }
334
0
    return NULL;
335
0
}
336
337
OpenAPI_eutra_location_t *OpenAPI_eutra_location_copy(OpenAPI_eutra_location_t *dst, OpenAPI_eutra_location_t *src)
338
0
{
339
0
    cJSON *item = NULL;
340
0
    char *content = NULL;
341
342
0
    ogs_assert(src);
343
0
    item = OpenAPI_eutra_location_convertToJSON(src);
344
0
    if (!item) {
345
0
        ogs_error("OpenAPI_eutra_location_convertToJSON() failed");
346
0
        return NULL;
347
0
    }
348
349
0
    content = cJSON_Print(item);
350
0
    cJSON_Delete(item);
351
352
0
    if (!content) {
353
0
        ogs_error("cJSON_Print() failed");
354
0
        return NULL;
355
0
    }
356
357
0
    item = cJSON_Parse(content);
358
0
    ogs_free(content);
359
0
    if (!item) {
360
0
        ogs_error("cJSON_Parse() failed");
361
0
        return NULL;
362
0
    }
363
364
0
    OpenAPI_eutra_location_free(dst);
365
0
    dst = OpenAPI_eutra_location_parseFromJSON(item);
366
0
    cJSON_Delete(item);
367
368
0
    return dst;
369
0
}
370