Coverage Report

Created: 2026-08-14 06:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/sac_info.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "sac_info.h"
6
7
OpenAPI_sac_info_t *OpenAPI_sac_info_create(
8
    bool is_numeric_val_num_ues,
9
    int numeric_val_num_ues,
10
    bool is_numeric_val_num_pdu_sess,
11
    int numeric_val_num_pdu_sess,
12
    bool is_perc_value_num_ues,
13
    int perc_value_num_ues,
14
    bool is_perc_value_num_pdu_sess,
15
    int perc_value_num_pdu_sess,
16
    bool is_ues_with_pdu_session_ind,
17
    int ues_with_pdu_session_ind
18
)
19
0
{
20
0
    OpenAPI_sac_info_t *sac_info_local_var = ogs_malloc(sizeof(OpenAPI_sac_info_t));
21
0
    ogs_assert(sac_info_local_var);
22
23
0
    sac_info_local_var->is_numeric_val_num_ues = is_numeric_val_num_ues;
24
0
    sac_info_local_var->numeric_val_num_ues = numeric_val_num_ues;
25
0
    sac_info_local_var->is_numeric_val_num_pdu_sess = is_numeric_val_num_pdu_sess;
26
0
    sac_info_local_var->numeric_val_num_pdu_sess = numeric_val_num_pdu_sess;
27
0
    sac_info_local_var->is_perc_value_num_ues = is_perc_value_num_ues;
28
0
    sac_info_local_var->perc_value_num_ues = perc_value_num_ues;
29
0
    sac_info_local_var->is_perc_value_num_pdu_sess = is_perc_value_num_pdu_sess;
30
0
    sac_info_local_var->perc_value_num_pdu_sess = perc_value_num_pdu_sess;
31
0
    sac_info_local_var->is_ues_with_pdu_session_ind = is_ues_with_pdu_session_ind;
32
0
    sac_info_local_var->ues_with_pdu_session_ind = ues_with_pdu_session_ind;
33
34
0
    return sac_info_local_var;
35
0
}
36
37
void OpenAPI_sac_info_free(OpenAPI_sac_info_t *sac_info)
38
0
{
39
0
    OpenAPI_lnode_t *node = NULL;
40
41
0
    if (NULL == sac_info) {
42
0
        return;
43
0
    }
44
0
    ogs_free(sac_info);
45
0
}
46
47
cJSON *OpenAPI_sac_info_convertToJSON(OpenAPI_sac_info_t *sac_info)
48
0
{
49
0
    cJSON *item = NULL;
50
0
    OpenAPI_lnode_t *node = NULL;
51
52
0
    if (sac_info == NULL) {
53
0
        ogs_error("OpenAPI_sac_info_convertToJSON() failed [SACInfo]");
54
0
        return NULL;
55
0
    }
56
57
0
    item = cJSON_CreateObject();
58
0
    if (sac_info->is_numeric_val_num_ues) {
59
0
    if (cJSON_AddNumberToObject(item, "numericValNumUes", sac_info->numeric_val_num_ues) == NULL) {
60
0
        ogs_error("OpenAPI_sac_info_convertToJSON() failed [numeric_val_num_ues]");
61
0
        goto end;
62
0
    }
63
0
    }
64
65
0
    if (sac_info->is_numeric_val_num_pdu_sess) {
66
0
    if (cJSON_AddNumberToObject(item, "numericValNumPduSess", sac_info->numeric_val_num_pdu_sess) == NULL) {
67
0
        ogs_error("OpenAPI_sac_info_convertToJSON() failed [numeric_val_num_pdu_sess]");
68
0
        goto end;
69
0
    }
70
0
    }
71
72
0
    if (sac_info->is_perc_value_num_ues) {
73
0
    if (cJSON_AddNumberToObject(item, "percValueNumUes", sac_info->perc_value_num_ues) == NULL) {
74
0
        ogs_error("OpenAPI_sac_info_convertToJSON() failed [perc_value_num_ues]");
75
0
        goto end;
76
0
    }
77
0
    }
78
79
0
    if (sac_info->is_perc_value_num_pdu_sess) {
80
0
    if (cJSON_AddNumberToObject(item, "percValueNumPduSess", sac_info->perc_value_num_pdu_sess) == NULL) {
81
0
        ogs_error("OpenAPI_sac_info_convertToJSON() failed [perc_value_num_pdu_sess]");
82
0
        goto end;
83
0
    }
84
0
    }
85
86
0
    if (sac_info->is_ues_with_pdu_session_ind) {
87
0
    if (cJSON_AddBoolToObject(item, "uesWithPduSessionInd", sac_info->ues_with_pdu_session_ind) == NULL) {
88
0
        ogs_error("OpenAPI_sac_info_convertToJSON() failed [ues_with_pdu_session_ind]");
89
0
        goto end;
90
0
    }
91
0
    }
92
93
0
end:
94
0
    return item;
95
0
}
96
97
OpenAPI_sac_info_t *OpenAPI_sac_info_parseFromJSON(cJSON *sac_infoJSON)
98
0
{
99
0
    OpenAPI_sac_info_t *sac_info_local_var = NULL;
100
0
    OpenAPI_lnode_t *node = NULL;
101
0
    cJSON *numeric_val_num_ues = NULL;
102
0
    cJSON *numeric_val_num_pdu_sess = NULL;
103
0
    cJSON *perc_value_num_ues = NULL;
104
0
    cJSON *perc_value_num_pdu_sess = NULL;
105
0
    cJSON *ues_with_pdu_session_ind = NULL;
106
0
    numeric_val_num_ues = cJSON_GetObjectItemCaseSensitive(sac_infoJSON, "numericValNumUes");
107
0
    if (numeric_val_num_ues) {
108
0
    if (!cJSON_IsNumber(numeric_val_num_ues)) {
109
0
        ogs_error("OpenAPI_sac_info_parseFromJSON() failed [numeric_val_num_ues]");
110
0
        goto end;
111
0
    }
112
0
    }
113
114
0
    numeric_val_num_pdu_sess = cJSON_GetObjectItemCaseSensitive(sac_infoJSON, "numericValNumPduSess");
115
0
    if (numeric_val_num_pdu_sess) {
116
0
    if (!cJSON_IsNumber(numeric_val_num_pdu_sess)) {
117
0
        ogs_error("OpenAPI_sac_info_parseFromJSON() failed [numeric_val_num_pdu_sess]");
118
0
        goto end;
119
0
    }
120
0
    }
121
122
0
    perc_value_num_ues = cJSON_GetObjectItemCaseSensitive(sac_infoJSON, "percValueNumUes");
123
0
    if (perc_value_num_ues) {
124
0
    if (!cJSON_IsNumber(perc_value_num_ues)) {
125
0
        ogs_error("OpenAPI_sac_info_parseFromJSON() failed [perc_value_num_ues]");
126
0
        goto end;
127
0
    }
128
0
    }
129
130
0
    perc_value_num_pdu_sess = cJSON_GetObjectItemCaseSensitive(sac_infoJSON, "percValueNumPduSess");
131
0
    if (perc_value_num_pdu_sess) {
132
0
    if (!cJSON_IsNumber(perc_value_num_pdu_sess)) {
133
0
        ogs_error("OpenAPI_sac_info_parseFromJSON() failed [perc_value_num_pdu_sess]");
134
0
        goto end;
135
0
    }
136
0
    }
137
138
0
    ues_with_pdu_session_ind = cJSON_GetObjectItemCaseSensitive(sac_infoJSON, "uesWithPduSessionInd");
139
0
    if (ues_with_pdu_session_ind) {
140
0
    if (!cJSON_IsBool(ues_with_pdu_session_ind)) {
141
0
        ogs_error("OpenAPI_sac_info_parseFromJSON() failed [ues_with_pdu_session_ind]");
142
0
        goto end;
143
0
    }
144
0
    }
145
146
0
    sac_info_local_var = OpenAPI_sac_info_create (
147
0
        numeric_val_num_ues ? true : false,
148
0
        numeric_val_num_ues ? numeric_val_num_ues->valuedouble : 0,
149
0
        numeric_val_num_pdu_sess ? true : false,
150
0
        numeric_val_num_pdu_sess ? numeric_val_num_pdu_sess->valuedouble : 0,
151
0
        perc_value_num_ues ? true : false,
152
0
        perc_value_num_ues ? perc_value_num_ues->valuedouble : 0,
153
0
        perc_value_num_pdu_sess ? true : false,
154
0
        perc_value_num_pdu_sess ? perc_value_num_pdu_sess->valuedouble : 0,
155
0
        ues_with_pdu_session_ind ? true : false,
156
0
        ues_with_pdu_session_ind ? ues_with_pdu_session_ind->valueint : 0
157
0
    );
158
159
0
    return sac_info_local_var;
160
0
end:
161
0
    return NULL;
162
0
}
163
164
OpenAPI_sac_info_t *OpenAPI_sac_info_copy(OpenAPI_sac_info_t *dst, OpenAPI_sac_info_t *src)
165
0
{
166
0
    cJSON *item = NULL;
167
0
    char *content = NULL;
168
169
0
    ogs_assert(src);
170
0
    item = OpenAPI_sac_info_convertToJSON(src);
171
0
    if (!item) {
172
0
        ogs_error("OpenAPI_sac_info_convertToJSON() failed");
173
0
        return NULL;
174
0
    }
175
176
0
    content = cJSON_Print(item);
177
0
    cJSON_Delete(item);
178
179
0
    if (!content) {
180
0
        ogs_error("cJSON_Print() failed");
181
0
        return NULL;
182
0
    }
183
184
0
    item = cJSON_Parse(content);
185
0
    ogs_free(content);
186
0
    if (!item) {
187
0
        ogs_error("cJSON_Parse() failed");
188
0
        return NULL;
189
0
    }
190
191
0
    OpenAPI_sac_info_free(dst);
192
0
    dst = OpenAPI_sac_info_parseFromJSON(item);
193
0
    cJSON_Delete(item);
194
195
0
    return dst;
196
0
}
197