/src/open5gs/lib/sbi/openapi/model/pcf_info.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "pcf_info.h" |
6 | | |
7 | | OpenAPI_pcf_info_t *OpenAPI_pcf_info_create( |
8 | | char *group_id, |
9 | | OpenAPI_list_t *dnn_list, |
10 | | OpenAPI_list_t *supi_ranges, |
11 | | OpenAPI_list_t *gpsi_ranges, |
12 | | char *rx_diam_host, |
13 | | char *rx_diam_realm, |
14 | | bool is_v2x_support_ind, |
15 | | int v2x_support_ind, |
16 | | bool is_prose_support_ind, |
17 | | int prose_support_ind, |
18 | | OpenAPI_pro_se_capability_t *prose_capability, |
19 | | OpenAPI_v2x_capability_t *v2x_capability, |
20 | | bool is_a2x_support_ind, |
21 | | int a2x_support_ind, |
22 | | OpenAPI_a2x_capability_t *a2x_capability, |
23 | | bool is_ranging_sl_pos_support_ind, |
24 | | int ranging_sl_pos_support_ind, |
25 | | bool is_ursp_eps_support, |
26 | | int ursp_eps_support |
27 | | ) |
28 | 6.31k | { |
29 | 6.31k | OpenAPI_pcf_info_t *pcf_info_local_var = ogs_malloc(sizeof(OpenAPI_pcf_info_t)); |
30 | 6.31k | ogs_assert(pcf_info_local_var); |
31 | | |
32 | 6.31k | pcf_info_local_var->group_id = group_id; |
33 | 6.31k | pcf_info_local_var->dnn_list = dnn_list; |
34 | 6.31k | pcf_info_local_var->supi_ranges = supi_ranges; |
35 | 6.31k | pcf_info_local_var->gpsi_ranges = gpsi_ranges; |
36 | 6.31k | pcf_info_local_var->rx_diam_host = rx_diam_host; |
37 | 6.31k | pcf_info_local_var->rx_diam_realm = rx_diam_realm; |
38 | 6.31k | pcf_info_local_var->is_v2x_support_ind = is_v2x_support_ind; |
39 | 6.31k | pcf_info_local_var->v2x_support_ind = v2x_support_ind; |
40 | 6.31k | pcf_info_local_var->is_prose_support_ind = is_prose_support_ind; |
41 | 6.31k | pcf_info_local_var->prose_support_ind = prose_support_ind; |
42 | 6.31k | pcf_info_local_var->prose_capability = prose_capability; |
43 | 6.31k | pcf_info_local_var->v2x_capability = v2x_capability; |
44 | 6.31k | pcf_info_local_var->is_a2x_support_ind = is_a2x_support_ind; |
45 | 6.31k | pcf_info_local_var->a2x_support_ind = a2x_support_ind; |
46 | 6.31k | pcf_info_local_var->a2x_capability = a2x_capability; |
47 | 6.31k | pcf_info_local_var->is_ranging_sl_pos_support_ind = is_ranging_sl_pos_support_ind; |
48 | 6.31k | pcf_info_local_var->ranging_sl_pos_support_ind = ranging_sl_pos_support_ind; |
49 | 6.31k | pcf_info_local_var->is_ursp_eps_support = is_ursp_eps_support; |
50 | 6.31k | pcf_info_local_var->ursp_eps_support = ursp_eps_support; |
51 | | |
52 | 6.31k | return pcf_info_local_var; |
53 | 6.31k | } |
54 | | |
55 | | void OpenAPI_pcf_info_free(OpenAPI_pcf_info_t *pcf_info) |
56 | 11.8k | { |
57 | 11.8k | OpenAPI_lnode_t *node = NULL; |
58 | | |
59 | 11.8k | if (NULL == pcf_info) { |
60 | 5.49k | return; |
61 | 5.49k | } |
62 | 6.31k | if (pcf_info->group_id) { |
63 | 205 | ogs_free(pcf_info->group_id); |
64 | 205 | pcf_info->group_id = NULL; |
65 | 205 | } |
66 | 6.31k | if (pcf_info->dnn_list) { |
67 | 395 | OpenAPI_list_for_each(pcf_info->dnn_list, node) { |
68 | 395 | ogs_free(node->data); |
69 | 395 | } |
70 | 267 | OpenAPI_list_free(pcf_info->dnn_list); |
71 | 267 | pcf_info->dnn_list = NULL; |
72 | 267 | } |
73 | 6.31k | if (pcf_info->supi_ranges) { |
74 | 796 | OpenAPI_list_for_each(pcf_info->supi_ranges, node) { |
75 | 796 | OpenAPI_supi_range_free(node->data); |
76 | 796 | } |
77 | 409 | OpenAPI_list_free(pcf_info->supi_ranges); |
78 | 409 | pcf_info->supi_ranges = NULL; |
79 | 409 | } |
80 | 6.31k | if (pcf_info->gpsi_ranges) { |
81 | 648 | OpenAPI_list_for_each(pcf_info->gpsi_ranges, node) { |
82 | 648 | OpenAPI_identity_range_free(node->data); |
83 | 648 | } |
84 | 467 | OpenAPI_list_free(pcf_info->gpsi_ranges); |
85 | 467 | pcf_info->gpsi_ranges = NULL; |
86 | 467 | } |
87 | 6.31k | if (pcf_info->rx_diam_host) { |
88 | 285 | ogs_free(pcf_info->rx_diam_host); |
89 | 285 | pcf_info->rx_diam_host = NULL; |
90 | 285 | } |
91 | 6.31k | if (pcf_info->rx_diam_realm) { |
92 | 194 | ogs_free(pcf_info->rx_diam_realm); |
93 | 194 | pcf_info->rx_diam_realm = NULL; |
94 | 194 | } |
95 | 6.31k | if (pcf_info->prose_capability) { |
96 | 266 | OpenAPI_pro_se_capability_free(pcf_info->prose_capability); |
97 | 266 | pcf_info->prose_capability = NULL; |
98 | 266 | } |
99 | 6.31k | if (pcf_info->v2x_capability) { |
100 | 200 | OpenAPI_v2x_capability_free(pcf_info->v2x_capability); |
101 | 200 | pcf_info->v2x_capability = NULL; |
102 | 200 | } |
103 | 6.31k | if (pcf_info->a2x_capability) { |
104 | 207 | OpenAPI_a2x_capability_free(pcf_info->a2x_capability); |
105 | 207 | pcf_info->a2x_capability = NULL; |
106 | 207 | } |
107 | 6.31k | ogs_free(pcf_info); |
108 | 6.31k | } |
109 | | |
110 | | cJSON *OpenAPI_pcf_info_convertToJSON(OpenAPI_pcf_info_t *pcf_info) |
111 | 0 | { |
112 | 0 | cJSON *item = NULL; |
113 | 0 | OpenAPI_lnode_t *node = NULL; |
114 | |
|
115 | 0 | if (pcf_info == NULL) { |
116 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [PcfInfo]"); |
117 | 0 | return NULL; |
118 | 0 | } |
119 | | |
120 | 0 | item = cJSON_CreateObject(); |
121 | 0 | if (pcf_info->group_id) { |
122 | 0 | if (cJSON_AddStringToObject(item, "groupId", pcf_info->group_id) == NULL) { |
123 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [group_id]"); |
124 | 0 | goto end; |
125 | 0 | } |
126 | 0 | } |
127 | | |
128 | 0 | if (pcf_info->dnn_list) { |
129 | 0 | cJSON *dnn_listList = cJSON_AddArrayToObject(item, "dnnList"); |
130 | 0 | if (dnn_listList == NULL) { |
131 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [dnn_list]"); |
132 | 0 | goto end; |
133 | 0 | } |
134 | 0 | OpenAPI_list_for_each(pcf_info->dnn_list, node) { |
135 | 0 | if (cJSON_AddStringToObject(dnn_listList, "", (char*)node->data) == NULL) { |
136 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [dnn_list]"); |
137 | 0 | goto end; |
138 | 0 | } |
139 | 0 | } |
140 | 0 | } |
141 | | |
142 | 0 | if (pcf_info->supi_ranges) { |
143 | 0 | cJSON *supi_rangesList = cJSON_AddArrayToObject(item, "supiRanges"); |
144 | 0 | if (supi_rangesList == NULL) { |
145 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [supi_ranges]"); |
146 | 0 | goto end; |
147 | 0 | } |
148 | 0 | OpenAPI_list_for_each(pcf_info->supi_ranges, node) { |
149 | 0 | cJSON *itemLocal = OpenAPI_supi_range_convertToJSON(node->data); |
150 | 0 | if (itemLocal == NULL) { |
151 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [supi_ranges]"); |
152 | 0 | goto end; |
153 | 0 | } |
154 | 0 | cJSON_AddItemToArray(supi_rangesList, itemLocal); |
155 | 0 | } |
156 | 0 | } |
157 | | |
158 | 0 | if (pcf_info->gpsi_ranges) { |
159 | 0 | cJSON *gpsi_rangesList = cJSON_AddArrayToObject(item, "gpsiRanges"); |
160 | 0 | if (gpsi_rangesList == NULL) { |
161 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [gpsi_ranges]"); |
162 | 0 | goto end; |
163 | 0 | } |
164 | 0 | OpenAPI_list_for_each(pcf_info->gpsi_ranges, node) { |
165 | 0 | cJSON *itemLocal = OpenAPI_identity_range_convertToJSON(node->data); |
166 | 0 | if (itemLocal == NULL) { |
167 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [gpsi_ranges]"); |
168 | 0 | goto end; |
169 | 0 | } |
170 | 0 | cJSON_AddItemToArray(gpsi_rangesList, itemLocal); |
171 | 0 | } |
172 | 0 | } |
173 | | |
174 | 0 | if (pcf_info->rx_diam_host) { |
175 | 0 | if (cJSON_AddStringToObject(item, "rxDiamHost", pcf_info->rx_diam_host) == NULL) { |
176 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [rx_diam_host]"); |
177 | 0 | goto end; |
178 | 0 | } |
179 | 0 | } |
180 | | |
181 | 0 | if (pcf_info->rx_diam_realm) { |
182 | 0 | if (cJSON_AddStringToObject(item, "rxDiamRealm", pcf_info->rx_diam_realm) == NULL) { |
183 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [rx_diam_realm]"); |
184 | 0 | goto end; |
185 | 0 | } |
186 | 0 | } |
187 | | |
188 | 0 | if (pcf_info->is_v2x_support_ind) { |
189 | 0 | if (cJSON_AddBoolToObject(item, "v2xSupportInd", pcf_info->v2x_support_ind) == NULL) { |
190 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [v2x_support_ind]"); |
191 | 0 | goto end; |
192 | 0 | } |
193 | 0 | } |
194 | | |
195 | 0 | if (pcf_info->is_prose_support_ind) { |
196 | 0 | if (cJSON_AddBoolToObject(item, "proseSupportInd", pcf_info->prose_support_ind) == NULL) { |
197 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [prose_support_ind]"); |
198 | 0 | goto end; |
199 | 0 | } |
200 | 0 | } |
201 | | |
202 | 0 | if (pcf_info->prose_capability) { |
203 | 0 | cJSON *prose_capability_local_JSON = OpenAPI_pro_se_capability_convertToJSON(pcf_info->prose_capability); |
204 | 0 | if (prose_capability_local_JSON == NULL) { |
205 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [prose_capability]"); |
206 | 0 | goto end; |
207 | 0 | } |
208 | 0 | cJSON_AddItemToObject(item, "proseCapability", prose_capability_local_JSON); |
209 | 0 | if (item->child == NULL) { |
210 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [prose_capability]"); |
211 | 0 | goto end; |
212 | 0 | } |
213 | 0 | } |
214 | | |
215 | 0 | if (pcf_info->v2x_capability) { |
216 | 0 | cJSON *v2x_capability_local_JSON = OpenAPI_v2x_capability_convertToJSON(pcf_info->v2x_capability); |
217 | 0 | if (v2x_capability_local_JSON == NULL) { |
218 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [v2x_capability]"); |
219 | 0 | goto end; |
220 | 0 | } |
221 | 0 | cJSON_AddItemToObject(item, "v2xCapability", v2x_capability_local_JSON); |
222 | 0 | if (item->child == NULL) { |
223 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [v2x_capability]"); |
224 | 0 | goto end; |
225 | 0 | } |
226 | 0 | } |
227 | | |
228 | 0 | if (pcf_info->is_a2x_support_ind) { |
229 | 0 | if (cJSON_AddBoolToObject(item, "a2xSupportInd", pcf_info->a2x_support_ind) == NULL) { |
230 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [a2x_support_ind]"); |
231 | 0 | goto end; |
232 | 0 | } |
233 | 0 | } |
234 | | |
235 | 0 | if (pcf_info->a2x_capability) { |
236 | 0 | cJSON *a2x_capability_local_JSON = OpenAPI_a2x_capability_convertToJSON(pcf_info->a2x_capability); |
237 | 0 | if (a2x_capability_local_JSON == NULL) { |
238 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [a2x_capability]"); |
239 | 0 | goto end; |
240 | 0 | } |
241 | 0 | cJSON_AddItemToObject(item, "a2xCapability", a2x_capability_local_JSON); |
242 | 0 | if (item->child == NULL) { |
243 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [a2x_capability]"); |
244 | 0 | goto end; |
245 | 0 | } |
246 | 0 | } |
247 | | |
248 | 0 | if (pcf_info->is_ranging_sl_pos_support_ind) { |
249 | 0 | if (cJSON_AddBoolToObject(item, "rangingSlPosSupportInd", pcf_info->ranging_sl_pos_support_ind) == NULL) { |
250 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [ranging_sl_pos_support_ind]"); |
251 | 0 | goto end; |
252 | 0 | } |
253 | 0 | } |
254 | | |
255 | 0 | if (pcf_info->is_ursp_eps_support) { |
256 | 0 | if (cJSON_AddBoolToObject(item, "urspEpsSupport", pcf_info->ursp_eps_support) == NULL) { |
257 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed [ursp_eps_support]"); |
258 | 0 | goto end; |
259 | 0 | } |
260 | 0 | } |
261 | | |
262 | 0 | end: |
263 | 0 | return item; |
264 | 0 | } |
265 | | |
266 | | OpenAPI_pcf_info_t *OpenAPI_pcf_info_parseFromJSON(cJSON *pcf_infoJSON) |
267 | 11.2k | { |
268 | 11.2k | OpenAPI_pcf_info_t *pcf_info_local_var = NULL; |
269 | 11.2k | OpenAPI_lnode_t *node = NULL; |
270 | 11.2k | cJSON *group_id = NULL; |
271 | 11.2k | cJSON *dnn_list = NULL; |
272 | 11.2k | OpenAPI_list_t *dnn_listList = NULL; |
273 | 11.2k | cJSON *supi_ranges = NULL; |
274 | 11.2k | OpenAPI_list_t *supi_rangesList = NULL; |
275 | 11.2k | cJSON *gpsi_ranges = NULL; |
276 | 11.2k | OpenAPI_list_t *gpsi_rangesList = NULL; |
277 | 11.2k | cJSON *rx_diam_host = NULL; |
278 | 11.2k | cJSON *rx_diam_realm = NULL; |
279 | 11.2k | cJSON *v2x_support_ind = NULL; |
280 | 11.2k | cJSON *prose_support_ind = NULL; |
281 | 11.2k | cJSON *prose_capability = NULL; |
282 | 11.2k | OpenAPI_pro_se_capability_t *prose_capability_local_nonprim = NULL; |
283 | 11.2k | cJSON *v2x_capability = NULL; |
284 | 11.2k | OpenAPI_v2x_capability_t *v2x_capability_local_nonprim = NULL; |
285 | 11.2k | cJSON *a2x_support_ind = NULL; |
286 | 11.2k | cJSON *a2x_capability = NULL; |
287 | 11.2k | OpenAPI_a2x_capability_t *a2x_capability_local_nonprim = NULL; |
288 | 11.2k | cJSON *ranging_sl_pos_support_ind = NULL; |
289 | 11.2k | cJSON *ursp_eps_support = NULL; |
290 | 11.2k | group_id = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "groupId"); |
291 | 11.2k | if (group_id) { |
292 | 737 | if (!cJSON_IsString(group_id) && !cJSON_IsNull(group_id)) { |
293 | 194 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [group_id]"); |
294 | 194 | goto end; |
295 | 194 | } |
296 | 737 | } |
297 | | |
298 | 11.0k | dnn_list = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "dnnList"); |
299 | 11.0k | if (dnn_list) { |
300 | 1.02k | cJSON *dnn_list_local = NULL; |
301 | 1.02k | if (!cJSON_IsArray(dnn_list)) { |
302 | 281 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [dnn_list]"); |
303 | 281 | goto end; |
304 | 281 | } |
305 | | |
306 | 745 | dnn_listList = OpenAPI_list_create(); |
307 | | |
308 | 1.42k | cJSON_ArrayForEach(dnn_list_local, dnn_list) { |
309 | 1.42k | double *localDouble = NULL; |
310 | 1.42k | int *localInt = NULL; |
311 | 1.42k | if (!cJSON_IsString(dnn_list_local)) { |
312 | 478 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [dnn_list]"); |
313 | 478 | goto end; |
314 | 478 | } |
315 | 943 | OpenAPI_list_add(dnn_listList, ogs_strdup(dnn_list_local->valuestring)); |
316 | 943 | } |
317 | 745 | } |
318 | | |
319 | 10.3k | supi_ranges = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "supiRanges"); |
320 | 10.3k | if (supi_ranges) { |
321 | 1.41k | cJSON *supi_ranges_local = NULL; |
322 | 1.41k | if (!cJSON_IsArray(supi_ranges)) { |
323 | 215 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [supi_ranges]"); |
324 | 215 | goto end; |
325 | 215 | } |
326 | | |
327 | 1.19k | supi_rangesList = OpenAPI_list_create(); |
328 | | |
329 | 2.25k | cJSON_ArrayForEach(supi_ranges_local, supi_ranges) { |
330 | 2.25k | if (!cJSON_IsObject(supi_ranges_local)) { |
331 | 466 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [supi_ranges]"); |
332 | 466 | goto end; |
333 | 466 | } |
334 | 1.79k | OpenAPI_supi_range_t *supi_rangesItem = OpenAPI_supi_range_parseFromJSON(supi_ranges_local); |
335 | 1.79k | if (!supi_rangesItem) { |
336 | 322 | ogs_error("No supi_rangesItem"); |
337 | 322 | goto end; |
338 | 322 | } |
339 | 1.46k | OpenAPI_list_add(supi_rangesList, supi_rangesItem); |
340 | 1.46k | } |
341 | 1.19k | } |
342 | | |
343 | 9.33k | gpsi_ranges = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "gpsiRanges"); |
344 | 9.33k | if (gpsi_ranges) { |
345 | 1.45k | cJSON *gpsi_ranges_local = NULL; |
346 | 1.45k | if (!cJSON_IsArray(gpsi_ranges)) { |
347 | 194 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [gpsi_ranges]"); |
348 | 194 | goto end; |
349 | 194 | } |
350 | | |
351 | 1.26k | gpsi_rangesList = OpenAPI_list_create(); |
352 | | |
353 | 2.01k | cJSON_ArrayForEach(gpsi_ranges_local, gpsi_ranges) { |
354 | 2.01k | if (!cJSON_IsObject(gpsi_ranges_local)) { |
355 | 461 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [gpsi_ranges]"); |
356 | 461 | goto end; |
357 | 461 | } |
358 | 1.55k | OpenAPI_identity_range_t *gpsi_rangesItem = OpenAPI_identity_range_parseFromJSON(gpsi_ranges_local); |
359 | 1.55k | if (!gpsi_rangesItem) { |
360 | 332 | ogs_error("No gpsi_rangesItem"); |
361 | 332 | goto end; |
362 | 332 | } |
363 | 1.21k | OpenAPI_list_add(gpsi_rangesList, gpsi_rangesItem); |
364 | 1.21k | } |
365 | 1.26k | } |
366 | | |
367 | 8.34k | rx_diam_host = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "rxDiamHost"); |
368 | 8.34k | if (rx_diam_host) { |
369 | 681 | if (!cJSON_IsString(rx_diam_host) && !cJSON_IsNull(rx_diam_host)) { |
370 | 202 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [rx_diam_host]"); |
371 | 202 | goto end; |
372 | 202 | } |
373 | 681 | } |
374 | | |
375 | 8.14k | rx_diam_realm = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "rxDiamRealm"); |
376 | 8.14k | if (rx_diam_realm) { |
377 | 582 | if (!cJSON_IsString(rx_diam_realm) && !cJSON_IsNull(rx_diam_realm)) { |
378 | 194 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [rx_diam_realm]"); |
379 | 194 | goto end; |
380 | 194 | } |
381 | 582 | } |
382 | | |
383 | 7.95k | v2x_support_ind = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "v2xSupportInd"); |
384 | 7.95k | if (v2x_support_ind) { |
385 | 389 | if (!cJSON_IsBool(v2x_support_ind)) { |
386 | 195 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [v2x_support_ind]"); |
387 | 195 | goto end; |
388 | 195 | } |
389 | 389 | } |
390 | | |
391 | 7.75k | prose_support_ind = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "proseSupportInd"); |
392 | 7.75k | if (prose_support_ind) { |
393 | 408 | if (!cJSON_IsBool(prose_support_ind)) { |
394 | 214 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [prose_support_ind]"); |
395 | 214 | goto end; |
396 | 214 | } |
397 | 408 | } |
398 | | |
399 | 7.54k | prose_capability = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "proseCapability"); |
400 | 7.54k | if (prose_capability) { |
401 | 539 | prose_capability_local_nonprim = OpenAPI_pro_se_capability_parseFromJSON(prose_capability); |
402 | 539 | if (!prose_capability_local_nonprim) { |
403 | 13 | ogs_error("OpenAPI_pro_se_capability_parseFromJSON failed [prose_capability]"); |
404 | 13 | goto end; |
405 | 13 | } |
406 | 539 | } |
407 | | |
408 | 7.52k | v2x_capability = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "v2xCapability"); |
409 | 7.52k | if (v2x_capability) { |
410 | 394 | v2x_capability_local_nonprim = OpenAPI_v2x_capability_parseFromJSON(v2x_capability); |
411 | 394 | if (!v2x_capability_local_nonprim) { |
412 | 0 | ogs_error("OpenAPI_v2x_capability_parseFromJSON failed [v2x_capability]"); |
413 | 0 | goto end; |
414 | 0 | } |
415 | 394 | } |
416 | | |
417 | 7.52k | a2x_support_ind = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "a2xSupportInd"); |
418 | 7.52k | if (a2x_support_ind) { |
419 | 264 | if (!cJSON_IsBool(a2x_support_ind)) { |
420 | 198 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [a2x_support_ind]"); |
421 | 198 | goto end; |
422 | 198 | } |
423 | 264 | } |
424 | | |
425 | 7.33k | a2x_capability = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "a2xCapability"); |
426 | 7.33k | if (a2x_capability) { |
427 | 440 | a2x_capability_local_nonprim = OpenAPI_a2x_capability_parseFromJSON(a2x_capability); |
428 | 440 | if (!a2x_capability_local_nonprim) { |
429 | 0 | ogs_error("OpenAPI_a2x_capability_parseFromJSON failed [a2x_capability]"); |
430 | 0 | goto end; |
431 | 0 | } |
432 | 440 | } |
433 | | |
434 | 7.33k | ranging_sl_pos_support_ind = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "rangingSlPosSupportInd"); |
435 | 7.33k | if (ranging_sl_pos_support_ind) { |
436 | 663 | if (!cJSON_IsBool(ranging_sl_pos_support_ind)) { |
437 | 597 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [ranging_sl_pos_support_ind]"); |
438 | 597 | goto end; |
439 | 597 | } |
440 | 663 | } |
441 | | |
442 | 6.73k | ursp_eps_support = cJSON_GetObjectItemCaseSensitive(pcf_infoJSON, "urspEpsSupport"); |
443 | 6.73k | if (ursp_eps_support) { |
444 | 615 | if (!cJSON_IsBool(ursp_eps_support)) { |
445 | 421 | ogs_error("OpenAPI_pcf_info_parseFromJSON() failed [ursp_eps_support]"); |
446 | 421 | goto end; |
447 | 421 | } |
448 | 615 | } |
449 | | |
450 | 6.31k | pcf_info_local_var = OpenAPI_pcf_info_create ( |
451 | 6.31k | group_id && !cJSON_IsNull(group_id) ? ogs_strdup(group_id->valuestring) : NULL, |
452 | 6.31k | dnn_list ? dnn_listList : NULL, |
453 | 6.31k | supi_ranges ? supi_rangesList : NULL, |
454 | 6.31k | gpsi_ranges ? gpsi_rangesList : NULL, |
455 | 6.31k | rx_diam_host && !cJSON_IsNull(rx_diam_host) ? ogs_strdup(rx_diam_host->valuestring) : NULL, |
456 | 6.31k | rx_diam_realm && !cJSON_IsNull(rx_diam_realm) ? ogs_strdup(rx_diam_realm->valuestring) : NULL, |
457 | 6.31k | v2x_support_ind ? true : false, |
458 | 6.31k | v2x_support_ind ? v2x_support_ind->valueint : 0, |
459 | 6.31k | prose_support_ind ? true : false, |
460 | 6.31k | prose_support_ind ? prose_support_ind->valueint : 0, |
461 | 6.31k | prose_capability ? prose_capability_local_nonprim : NULL, |
462 | 6.31k | v2x_capability ? v2x_capability_local_nonprim : NULL, |
463 | 6.31k | a2x_support_ind ? true : false, |
464 | 6.31k | a2x_support_ind ? a2x_support_ind->valueint : 0, |
465 | 6.31k | a2x_capability ? a2x_capability_local_nonprim : NULL, |
466 | 6.31k | ranging_sl_pos_support_ind ? true : false, |
467 | 6.31k | ranging_sl_pos_support_ind ? ranging_sl_pos_support_ind->valueint : 0, |
468 | 6.31k | ursp_eps_support ? true : false, |
469 | 6.31k | ursp_eps_support ? ursp_eps_support->valueint : 0 |
470 | 6.31k | ); |
471 | | |
472 | 6.31k | return pcf_info_local_var; |
473 | 4.97k | end: |
474 | 4.97k | if (dnn_listList) { |
475 | 548 | OpenAPI_list_for_each(dnn_listList, node) { |
476 | 548 | ogs_free(node->data); |
477 | 548 | } |
478 | 478 | OpenAPI_list_free(dnn_listList); |
479 | 478 | dnn_listList = NULL; |
480 | 478 | } |
481 | 4.97k | if (supi_rangesList) { |
482 | 788 | OpenAPI_list_for_each(supi_rangesList, node) { |
483 | 672 | OpenAPI_supi_range_free(node->data); |
484 | 672 | } |
485 | 788 | OpenAPI_list_free(supi_rangesList); |
486 | 788 | supi_rangesList = NULL; |
487 | 788 | } |
488 | 4.97k | if (gpsi_rangesList) { |
489 | 793 | OpenAPI_list_for_each(gpsi_rangesList, node) { |
490 | 570 | OpenAPI_identity_range_free(node->data); |
491 | 570 | } |
492 | 793 | OpenAPI_list_free(gpsi_rangesList); |
493 | 793 | gpsi_rangesList = NULL; |
494 | 793 | } |
495 | 4.97k | if (prose_capability_local_nonprim) { |
496 | 260 | OpenAPI_pro_se_capability_free(prose_capability_local_nonprim); |
497 | 260 | prose_capability_local_nonprim = NULL; |
498 | 260 | } |
499 | 4.97k | if (v2x_capability_local_nonprim) { |
500 | 194 | OpenAPI_v2x_capability_free(v2x_capability_local_nonprim); |
501 | 194 | v2x_capability_local_nonprim = NULL; |
502 | 194 | } |
503 | 4.97k | if (a2x_capability_local_nonprim) { |
504 | 233 | OpenAPI_a2x_capability_free(a2x_capability_local_nonprim); |
505 | 233 | a2x_capability_local_nonprim = NULL; |
506 | 233 | } |
507 | 4.97k | return NULL; |
508 | 6.73k | } |
509 | | |
510 | | OpenAPI_pcf_info_t *OpenAPI_pcf_info_copy(OpenAPI_pcf_info_t *dst, OpenAPI_pcf_info_t *src) |
511 | 0 | { |
512 | 0 | cJSON *item = NULL; |
513 | 0 | char *content = NULL; |
514 | |
|
515 | 0 | ogs_assert(src); |
516 | 0 | item = OpenAPI_pcf_info_convertToJSON(src); |
517 | 0 | if (!item) { |
518 | 0 | ogs_error("OpenAPI_pcf_info_convertToJSON() failed"); |
519 | 0 | return NULL; |
520 | 0 | } |
521 | | |
522 | 0 | content = cJSON_Print(item); |
523 | 0 | cJSON_Delete(item); |
524 | |
|
525 | 0 | if (!content) { |
526 | 0 | ogs_error("cJSON_Print() failed"); |
527 | 0 | return NULL; |
528 | 0 | } |
529 | | |
530 | 0 | item = cJSON_Parse(content); |
531 | 0 | ogs_free(content); |
532 | 0 | if (!item) { |
533 | 0 | ogs_error("cJSON_Parse() failed"); |
534 | 0 | return NULL; |
535 | 0 | } |
536 | | |
537 | 0 | OpenAPI_pcf_info_free(dst); |
538 | 0 | dst = OpenAPI_pcf_info_parseFromJSON(item); |
539 | 0 | cJSON_Delete(item); |
540 | |
|
541 | 0 | return dst; |
542 | 0 | } |
543 | | |