Coverage Report

Created: 2026-06-30 06:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/a2x_context.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "a2x_context.h"
6
7
OpenAPI_a2x_context_t *OpenAPI_a2x_context_create(
8
    OpenAPI_nr_a2x_auth_t *nr_a2x_services_auth,
9
    OpenAPI_lte_a2x_auth_t *lte_a2x_services_auth,
10
    char *nr_ue_sidelink_ambr,
11
    char *lte_ue_sidelink_ambr,
12
    OpenAPI_pc5_qo_s_para_t *pc5_qo_s_para
13
)
14
0
{
15
0
    OpenAPI_a2x_context_t *a2x_context_local_var = ogs_malloc(sizeof(OpenAPI_a2x_context_t));
16
0
    ogs_assert(a2x_context_local_var);
17
18
0
    a2x_context_local_var->nr_a2x_services_auth = nr_a2x_services_auth;
19
0
    a2x_context_local_var->lte_a2x_services_auth = lte_a2x_services_auth;
20
0
    a2x_context_local_var->nr_ue_sidelink_ambr = nr_ue_sidelink_ambr;
21
0
    a2x_context_local_var->lte_ue_sidelink_ambr = lte_ue_sidelink_ambr;
22
0
    a2x_context_local_var->pc5_qo_s_para = pc5_qo_s_para;
23
24
0
    return a2x_context_local_var;
25
0
}
26
27
void OpenAPI_a2x_context_free(OpenAPI_a2x_context_t *a2x_context)
28
0
{
29
0
    OpenAPI_lnode_t *node = NULL;
30
31
0
    if (NULL == a2x_context) {
32
0
        return;
33
0
    }
34
0
    if (a2x_context->nr_a2x_services_auth) {
35
0
        OpenAPI_nr_a2x_auth_free(a2x_context->nr_a2x_services_auth);
36
0
        a2x_context->nr_a2x_services_auth = NULL;
37
0
    }
38
0
    if (a2x_context->lte_a2x_services_auth) {
39
0
        OpenAPI_lte_a2x_auth_free(a2x_context->lte_a2x_services_auth);
40
0
        a2x_context->lte_a2x_services_auth = NULL;
41
0
    }
42
0
    if (a2x_context->nr_ue_sidelink_ambr) {
43
0
        ogs_free(a2x_context->nr_ue_sidelink_ambr);
44
0
        a2x_context->nr_ue_sidelink_ambr = NULL;
45
0
    }
46
0
    if (a2x_context->lte_ue_sidelink_ambr) {
47
0
        ogs_free(a2x_context->lte_ue_sidelink_ambr);
48
0
        a2x_context->lte_ue_sidelink_ambr = NULL;
49
0
    }
50
0
    if (a2x_context->pc5_qo_s_para) {
51
0
        OpenAPI_pc5_qo_s_para_free(a2x_context->pc5_qo_s_para);
52
0
        a2x_context->pc5_qo_s_para = NULL;
53
0
    }
54
0
    ogs_free(a2x_context);
55
0
}
56
57
cJSON *OpenAPI_a2x_context_convertToJSON(OpenAPI_a2x_context_t *a2x_context)
58
0
{
59
0
    cJSON *item = NULL;
60
0
    OpenAPI_lnode_t *node = NULL;
61
62
0
    if (a2x_context == NULL) {
63
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed [A2xContext]");
64
0
        return NULL;
65
0
    }
66
67
0
    item = cJSON_CreateObject();
68
0
    if (a2x_context->nr_a2x_services_auth) {
69
0
    cJSON *nr_a2x_services_auth_local_JSON = OpenAPI_nr_a2x_auth_convertToJSON(a2x_context->nr_a2x_services_auth);
70
0
    if (nr_a2x_services_auth_local_JSON == NULL) {
71
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed [nr_a2x_services_auth]");
72
0
        goto end;
73
0
    }
74
0
    cJSON_AddItemToObject(item, "nrA2xServicesAuth", nr_a2x_services_auth_local_JSON);
75
0
    if (item->child == NULL) {
76
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed [nr_a2x_services_auth]");
77
0
        goto end;
78
0
    }
79
0
    }
80
81
0
    if (a2x_context->lte_a2x_services_auth) {
82
0
    cJSON *lte_a2x_services_auth_local_JSON = OpenAPI_lte_a2x_auth_convertToJSON(a2x_context->lte_a2x_services_auth);
83
0
    if (lte_a2x_services_auth_local_JSON == NULL) {
84
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed [lte_a2x_services_auth]");
85
0
        goto end;
86
0
    }
87
0
    cJSON_AddItemToObject(item, "lteA2xServicesAuth", lte_a2x_services_auth_local_JSON);
88
0
    if (item->child == NULL) {
89
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed [lte_a2x_services_auth]");
90
0
        goto end;
91
0
    }
92
0
    }
93
94
0
    if (a2x_context->nr_ue_sidelink_ambr) {
95
0
    if (cJSON_AddStringToObject(item, "nrUeSidelinkAmbr", a2x_context->nr_ue_sidelink_ambr) == NULL) {
96
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed [nr_ue_sidelink_ambr]");
97
0
        goto end;
98
0
    }
99
0
    }
100
101
0
    if (a2x_context->lte_ue_sidelink_ambr) {
102
0
    if (cJSON_AddStringToObject(item, "lteUeSidelinkAmbr", a2x_context->lte_ue_sidelink_ambr) == NULL) {
103
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed [lte_ue_sidelink_ambr]");
104
0
        goto end;
105
0
    }
106
0
    }
107
108
0
    if (a2x_context->pc5_qo_s_para) {
109
0
    cJSON *pc5_qo_s_para_local_JSON = OpenAPI_pc5_qo_s_para_convertToJSON(a2x_context->pc5_qo_s_para);
110
0
    if (pc5_qo_s_para_local_JSON == NULL) {
111
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed [pc5_qo_s_para]");
112
0
        goto end;
113
0
    }
114
0
    cJSON_AddItemToObject(item, "pc5QoSPara", pc5_qo_s_para_local_JSON);
115
0
    if (item->child == NULL) {
116
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed [pc5_qo_s_para]");
117
0
        goto end;
118
0
    }
119
0
    }
120
121
0
end:
122
0
    return item;
123
0
}
124
125
OpenAPI_a2x_context_t *OpenAPI_a2x_context_parseFromJSON(cJSON *a2x_contextJSON)
126
0
{
127
0
    OpenAPI_a2x_context_t *a2x_context_local_var = NULL;
128
0
    OpenAPI_lnode_t *node = NULL;
129
0
    cJSON *nr_a2x_services_auth = NULL;
130
0
    OpenAPI_nr_a2x_auth_t *nr_a2x_services_auth_local_nonprim = NULL;
131
0
    cJSON *lte_a2x_services_auth = NULL;
132
0
    OpenAPI_lte_a2x_auth_t *lte_a2x_services_auth_local_nonprim = NULL;
133
0
    cJSON *nr_ue_sidelink_ambr = NULL;
134
0
    cJSON *lte_ue_sidelink_ambr = NULL;
135
0
    cJSON *pc5_qo_s_para = NULL;
136
0
    OpenAPI_pc5_qo_s_para_t *pc5_qo_s_para_local_nonprim = NULL;
137
0
    nr_a2x_services_auth = cJSON_GetObjectItemCaseSensitive(a2x_contextJSON, "nrA2xServicesAuth");
138
0
    if (nr_a2x_services_auth) {
139
0
    nr_a2x_services_auth_local_nonprim = OpenAPI_nr_a2x_auth_parseFromJSON(nr_a2x_services_auth);
140
0
    if (!nr_a2x_services_auth_local_nonprim) {
141
0
        ogs_error("OpenAPI_nr_a2x_auth_parseFromJSON failed [nr_a2x_services_auth]");
142
0
        goto end;
143
0
    }
144
0
    }
145
146
0
    lte_a2x_services_auth = cJSON_GetObjectItemCaseSensitive(a2x_contextJSON, "lteA2xServicesAuth");
147
0
    if (lte_a2x_services_auth) {
148
0
    lte_a2x_services_auth_local_nonprim = OpenAPI_lte_a2x_auth_parseFromJSON(lte_a2x_services_auth);
149
0
    if (!lte_a2x_services_auth_local_nonprim) {
150
0
        ogs_error("OpenAPI_lte_a2x_auth_parseFromJSON failed [lte_a2x_services_auth]");
151
0
        goto end;
152
0
    }
153
0
    }
154
155
0
    nr_ue_sidelink_ambr = cJSON_GetObjectItemCaseSensitive(a2x_contextJSON, "nrUeSidelinkAmbr");
156
0
    if (nr_ue_sidelink_ambr) {
157
0
    if (!cJSON_IsString(nr_ue_sidelink_ambr) && !cJSON_IsNull(nr_ue_sidelink_ambr)) {
158
0
        ogs_error("OpenAPI_a2x_context_parseFromJSON() failed [nr_ue_sidelink_ambr]");
159
0
        goto end;
160
0
    }
161
0
    }
162
163
0
    lte_ue_sidelink_ambr = cJSON_GetObjectItemCaseSensitive(a2x_contextJSON, "lteUeSidelinkAmbr");
164
0
    if (lte_ue_sidelink_ambr) {
165
0
    if (!cJSON_IsString(lte_ue_sidelink_ambr) && !cJSON_IsNull(lte_ue_sidelink_ambr)) {
166
0
        ogs_error("OpenAPI_a2x_context_parseFromJSON() failed [lte_ue_sidelink_ambr]");
167
0
        goto end;
168
0
    }
169
0
    }
170
171
0
    pc5_qo_s_para = cJSON_GetObjectItemCaseSensitive(a2x_contextJSON, "pc5QoSPara");
172
0
    if (pc5_qo_s_para) {
173
0
    pc5_qo_s_para_local_nonprim = OpenAPI_pc5_qo_s_para_parseFromJSON(pc5_qo_s_para);
174
0
    if (!pc5_qo_s_para_local_nonprim) {
175
0
        ogs_error("OpenAPI_pc5_qo_s_para_parseFromJSON failed [pc5_qo_s_para]");
176
0
        goto end;
177
0
    }
178
0
    }
179
180
0
    a2x_context_local_var = OpenAPI_a2x_context_create (
181
0
        nr_a2x_services_auth ? nr_a2x_services_auth_local_nonprim : NULL,
182
0
        lte_a2x_services_auth ? lte_a2x_services_auth_local_nonprim : NULL,
183
0
        nr_ue_sidelink_ambr && !cJSON_IsNull(nr_ue_sidelink_ambr) ? ogs_strdup(nr_ue_sidelink_ambr->valuestring) : NULL,
184
0
        lte_ue_sidelink_ambr && !cJSON_IsNull(lte_ue_sidelink_ambr) ? ogs_strdup(lte_ue_sidelink_ambr->valuestring) : NULL,
185
0
        pc5_qo_s_para ? pc5_qo_s_para_local_nonprim : NULL
186
0
    );
187
188
0
    return a2x_context_local_var;
189
0
end:
190
0
    if (nr_a2x_services_auth_local_nonprim) {
191
0
        OpenAPI_nr_a2x_auth_free(nr_a2x_services_auth_local_nonprim);
192
0
        nr_a2x_services_auth_local_nonprim = NULL;
193
0
    }
194
0
    if (lte_a2x_services_auth_local_nonprim) {
195
0
        OpenAPI_lte_a2x_auth_free(lte_a2x_services_auth_local_nonprim);
196
0
        lte_a2x_services_auth_local_nonprim = NULL;
197
0
    }
198
0
    if (pc5_qo_s_para_local_nonprim) {
199
0
        OpenAPI_pc5_qo_s_para_free(pc5_qo_s_para_local_nonprim);
200
0
        pc5_qo_s_para_local_nonprim = NULL;
201
0
    }
202
0
    return NULL;
203
0
}
204
205
OpenAPI_a2x_context_t *OpenAPI_a2x_context_copy(OpenAPI_a2x_context_t *dst, OpenAPI_a2x_context_t *src)
206
0
{
207
0
    cJSON *item = NULL;
208
0
    char *content = NULL;
209
210
0
    ogs_assert(src);
211
0
    item = OpenAPI_a2x_context_convertToJSON(src);
212
0
    if (!item) {
213
0
        ogs_error("OpenAPI_a2x_context_convertToJSON() failed");
214
0
        return NULL;
215
0
    }
216
217
0
    content = cJSON_Print(item);
218
0
    cJSON_Delete(item);
219
220
0
    if (!content) {
221
0
        ogs_error("cJSON_Print() failed");
222
0
        return NULL;
223
0
    }
224
225
0
    item = cJSON_Parse(content);
226
0
    ogs_free(content);
227
0
    if (!item) {
228
0
        ogs_error("cJSON_Parse() failed");
229
0
        return NULL;
230
0
    }
231
232
0
    OpenAPI_a2x_context_free(dst);
233
0
    dst = OpenAPI_a2x_context_parseFromJSON(item);
234
0
    cJSON_Delete(item);
235
236
0
    return dst;
237
0
}
238