/src/open5gs/lib/sbi/openapi/model/authentication_subscription.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "authentication_subscription.h" |
6 | | |
7 | | OpenAPI_authentication_subscription_t *OpenAPI_authentication_subscription_create( |
8 | | OpenAPI_auth_method_e authentication_method, |
9 | | char *enc_permanent_key, |
10 | | char *protection_parameter_id, |
11 | | OpenAPI_sequence_number_t *sequence_number, |
12 | | char *authentication_management_field, |
13 | | char *algorithm_id, |
14 | | char *enc_opc_key, |
15 | | char *enc_topc_key, |
16 | | bool is_vector_generation_in_hss, |
17 | | int vector_generation_in_hss, |
18 | | char *hss_group_id, |
19 | | OpenAPI_auth_method_e n5gc_auth_method, |
20 | | bool is_rg_authentication_ind, |
21 | | int rg_authentication_ind, |
22 | | char *supi, |
23 | | bool is_akma_allowed, |
24 | | int akma_allowed, |
25 | | char *routing_id, |
26 | | bool is_nswo_allowed, |
27 | | int nswo_allowed, |
28 | | bool is__5g_key_hierar_supp, |
29 | | int _5g_key_hierar_supp |
30 | | ) |
31 | 0 | { |
32 | 0 | OpenAPI_authentication_subscription_t *authentication_subscription_local_var = ogs_malloc(sizeof(OpenAPI_authentication_subscription_t)); |
33 | 0 | ogs_assert(authentication_subscription_local_var); |
34 | | |
35 | 0 | authentication_subscription_local_var->authentication_method = authentication_method; |
36 | 0 | authentication_subscription_local_var->enc_permanent_key = enc_permanent_key; |
37 | 0 | authentication_subscription_local_var->protection_parameter_id = protection_parameter_id; |
38 | 0 | authentication_subscription_local_var->sequence_number = sequence_number; |
39 | 0 | authentication_subscription_local_var->authentication_management_field = authentication_management_field; |
40 | 0 | authentication_subscription_local_var->algorithm_id = algorithm_id; |
41 | 0 | authentication_subscription_local_var->enc_opc_key = enc_opc_key; |
42 | 0 | authentication_subscription_local_var->enc_topc_key = enc_topc_key; |
43 | 0 | authentication_subscription_local_var->is_vector_generation_in_hss = is_vector_generation_in_hss; |
44 | 0 | authentication_subscription_local_var->vector_generation_in_hss = vector_generation_in_hss; |
45 | 0 | authentication_subscription_local_var->hss_group_id = hss_group_id; |
46 | 0 | authentication_subscription_local_var->n5gc_auth_method = n5gc_auth_method; |
47 | 0 | authentication_subscription_local_var->is_rg_authentication_ind = is_rg_authentication_ind; |
48 | 0 | authentication_subscription_local_var->rg_authentication_ind = rg_authentication_ind; |
49 | 0 | authentication_subscription_local_var->supi = supi; |
50 | 0 | authentication_subscription_local_var->is_akma_allowed = is_akma_allowed; |
51 | 0 | authentication_subscription_local_var->akma_allowed = akma_allowed; |
52 | 0 | authentication_subscription_local_var->routing_id = routing_id; |
53 | 0 | authentication_subscription_local_var->is_nswo_allowed = is_nswo_allowed; |
54 | 0 | authentication_subscription_local_var->nswo_allowed = nswo_allowed; |
55 | 0 | authentication_subscription_local_var->is__5g_key_hierar_supp = is__5g_key_hierar_supp; |
56 | 0 | authentication_subscription_local_var->_5g_key_hierar_supp = _5g_key_hierar_supp; |
57 | |
|
58 | 0 | return authentication_subscription_local_var; |
59 | 0 | } |
60 | | |
61 | | void OpenAPI_authentication_subscription_free(OpenAPI_authentication_subscription_t *authentication_subscription) |
62 | 0 | { |
63 | 0 | OpenAPI_lnode_t *node = NULL; |
64 | |
|
65 | 0 | if (NULL == authentication_subscription) { |
66 | 0 | return; |
67 | 0 | } |
68 | 0 | if (authentication_subscription->enc_permanent_key) { |
69 | 0 | ogs_free(authentication_subscription->enc_permanent_key); |
70 | 0 | authentication_subscription->enc_permanent_key = NULL; |
71 | 0 | } |
72 | 0 | if (authentication_subscription->protection_parameter_id) { |
73 | 0 | ogs_free(authentication_subscription->protection_parameter_id); |
74 | 0 | authentication_subscription->protection_parameter_id = NULL; |
75 | 0 | } |
76 | 0 | if (authentication_subscription->sequence_number) { |
77 | 0 | OpenAPI_sequence_number_free(authentication_subscription->sequence_number); |
78 | 0 | authentication_subscription->sequence_number = NULL; |
79 | 0 | } |
80 | 0 | if (authentication_subscription->authentication_management_field) { |
81 | 0 | ogs_free(authentication_subscription->authentication_management_field); |
82 | 0 | authentication_subscription->authentication_management_field = NULL; |
83 | 0 | } |
84 | 0 | if (authentication_subscription->algorithm_id) { |
85 | 0 | ogs_free(authentication_subscription->algorithm_id); |
86 | 0 | authentication_subscription->algorithm_id = NULL; |
87 | 0 | } |
88 | 0 | if (authentication_subscription->enc_opc_key) { |
89 | 0 | ogs_free(authentication_subscription->enc_opc_key); |
90 | 0 | authentication_subscription->enc_opc_key = NULL; |
91 | 0 | } |
92 | 0 | if (authentication_subscription->enc_topc_key) { |
93 | 0 | ogs_free(authentication_subscription->enc_topc_key); |
94 | 0 | authentication_subscription->enc_topc_key = NULL; |
95 | 0 | } |
96 | 0 | if (authentication_subscription->hss_group_id) { |
97 | 0 | ogs_free(authentication_subscription->hss_group_id); |
98 | 0 | authentication_subscription->hss_group_id = NULL; |
99 | 0 | } |
100 | 0 | if (authentication_subscription->supi) { |
101 | 0 | ogs_free(authentication_subscription->supi); |
102 | 0 | authentication_subscription->supi = NULL; |
103 | 0 | } |
104 | 0 | if (authentication_subscription->routing_id) { |
105 | 0 | ogs_free(authentication_subscription->routing_id); |
106 | 0 | authentication_subscription->routing_id = NULL; |
107 | 0 | } |
108 | 0 | ogs_free(authentication_subscription); |
109 | 0 | } |
110 | | |
111 | | cJSON *OpenAPI_authentication_subscription_convertToJSON(OpenAPI_authentication_subscription_t *authentication_subscription) |
112 | 0 | { |
113 | 0 | cJSON *item = NULL; |
114 | 0 | OpenAPI_lnode_t *node = NULL; |
115 | |
|
116 | 0 | if (authentication_subscription == NULL) { |
117 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [AuthenticationSubscription]"); |
118 | 0 | return NULL; |
119 | 0 | } |
120 | | |
121 | 0 | item = cJSON_CreateObject(); |
122 | 0 | if (authentication_subscription->authentication_method == OpenAPI_auth_method_NULL) { |
123 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [authentication_method]"); |
124 | 0 | return NULL; |
125 | 0 | } |
126 | 0 | if (cJSON_AddStringToObject(item, "authenticationMethod", OpenAPI_auth_method_ToString(authentication_subscription->authentication_method)) == NULL) { |
127 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [authentication_method]"); |
128 | 0 | goto end; |
129 | 0 | } |
130 | | |
131 | 0 | if (authentication_subscription->enc_permanent_key) { |
132 | 0 | if (cJSON_AddStringToObject(item, "encPermanentKey", authentication_subscription->enc_permanent_key) == NULL) { |
133 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [enc_permanent_key]"); |
134 | 0 | goto end; |
135 | 0 | } |
136 | 0 | } |
137 | | |
138 | 0 | if (authentication_subscription->protection_parameter_id) { |
139 | 0 | if (cJSON_AddStringToObject(item, "protectionParameterId", authentication_subscription->protection_parameter_id) == NULL) { |
140 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [protection_parameter_id]"); |
141 | 0 | goto end; |
142 | 0 | } |
143 | 0 | } |
144 | | |
145 | 0 | if (authentication_subscription->sequence_number) { |
146 | 0 | cJSON *sequence_number_local_JSON = OpenAPI_sequence_number_convertToJSON(authentication_subscription->sequence_number); |
147 | 0 | if (sequence_number_local_JSON == NULL) { |
148 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [sequence_number]"); |
149 | 0 | goto end; |
150 | 0 | } |
151 | 0 | cJSON_AddItemToObject(item, "sequenceNumber", sequence_number_local_JSON); |
152 | 0 | if (item->child == NULL) { |
153 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [sequence_number]"); |
154 | 0 | goto end; |
155 | 0 | } |
156 | 0 | } |
157 | | |
158 | 0 | if (authentication_subscription->authentication_management_field) { |
159 | 0 | if (cJSON_AddStringToObject(item, "authenticationManagementField", authentication_subscription->authentication_management_field) == NULL) { |
160 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [authentication_management_field]"); |
161 | 0 | goto end; |
162 | 0 | } |
163 | 0 | } |
164 | | |
165 | 0 | if (authentication_subscription->algorithm_id) { |
166 | 0 | if (cJSON_AddStringToObject(item, "algorithmId", authentication_subscription->algorithm_id) == NULL) { |
167 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [algorithm_id]"); |
168 | 0 | goto end; |
169 | 0 | } |
170 | 0 | } |
171 | | |
172 | 0 | if (authentication_subscription->enc_opc_key) { |
173 | 0 | if (cJSON_AddStringToObject(item, "encOpcKey", authentication_subscription->enc_opc_key) == NULL) { |
174 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [enc_opc_key]"); |
175 | 0 | goto end; |
176 | 0 | } |
177 | 0 | } |
178 | | |
179 | 0 | if (authentication_subscription->enc_topc_key) { |
180 | 0 | if (cJSON_AddStringToObject(item, "encTopcKey", authentication_subscription->enc_topc_key) == NULL) { |
181 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [enc_topc_key]"); |
182 | 0 | goto end; |
183 | 0 | } |
184 | 0 | } |
185 | | |
186 | 0 | if (authentication_subscription->is_vector_generation_in_hss) { |
187 | 0 | if (cJSON_AddBoolToObject(item, "vectorGenerationInHss", authentication_subscription->vector_generation_in_hss) == NULL) { |
188 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [vector_generation_in_hss]"); |
189 | 0 | goto end; |
190 | 0 | } |
191 | 0 | } |
192 | | |
193 | 0 | if (authentication_subscription->hss_group_id) { |
194 | 0 | if (cJSON_AddStringToObject(item, "hssGroupId", authentication_subscription->hss_group_id) == NULL) { |
195 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [hss_group_id]"); |
196 | 0 | goto end; |
197 | 0 | } |
198 | 0 | } |
199 | | |
200 | 0 | if (authentication_subscription->n5gc_auth_method != OpenAPI_auth_method_NULL) { |
201 | 0 | if (cJSON_AddStringToObject(item, "n5gcAuthMethod", OpenAPI_auth_method_ToString(authentication_subscription->n5gc_auth_method)) == NULL) { |
202 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [n5gc_auth_method]"); |
203 | 0 | goto end; |
204 | 0 | } |
205 | 0 | } |
206 | | |
207 | 0 | if (authentication_subscription->is_rg_authentication_ind) { |
208 | 0 | if (cJSON_AddBoolToObject(item, "rgAuthenticationInd", authentication_subscription->rg_authentication_ind) == NULL) { |
209 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [rg_authentication_ind]"); |
210 | 0 | goto end; |
211 | 0 | } |
212 | 0 | } |
213 | | |
214 | 0 | if (authentication_subscription->supi) { |
215 | 0 | if (cJSON_AddStringToObject(item, "supi", authentication_subscription->supi) == NULL) { |
216 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [supi]"); |
217 | 0 | goto end; |
218 | 0 | } |
219 | 0 | } |
220 | | |
221 | 0 | if (authentication_subscription->is_akma_allowed) { |
222 | 0 | if (cJSON_AddBoolToObject(item, "akmaAllowed", authentication_subscription->akma_allowed) == NULL) { |
223 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [akma_allowed]"); |
224 | 0 | goto end; |
225 | 0 | } |
226 | 0 | } |
227 | | |
228 | 0 | if (authentication_subscription->routing_id) { |
229 | 0 | if (cJSON_AddStringToObject(item, "routingId", authentication_subscription->routing_id) == NULL) { |
230 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [routing_id]"); |
231 | 0 | goto end; |
232 | 0 | } |
233 | 0 | } |
234 | | |
235 | 0 | if (authentication_subscription->is_nswo_allowed) { |
236 | 0 | if (cJSON_AddBoolToObject(item, "nswoAllowed", authentication_subscription->nswo_allowed) == NULL) { |
237 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [nswo_allowed]"); |
238 | 0 | goto end; |
239 | 0 | } |
240 | 0 | } |
241 | | |
242 | 0 | if (authentication_subscription->is__5g_key_hierar_supp) { |
243 | 0 | if (cJSON_AddBoolToObject(item, "5gKeyHierarSupp", authentication_subscription->_5g_key_hierar_supp) == NULL) { |
244 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed [_5g_key_hierar_supp]"); |
245 | 0 | goto end; |
246 | 0 | } |
247 | 0 | } |
248 | | |
249 | 0 | end: |
250 | 0 | return item; |
251 | 0 | } |
252 | | |
253 | | OpenAPI_authentication_subscription_t *OpenAPI_authentication_subscription_parseFromJSON(cJSON *authentication_subscriptionJSON) |
254 | 0 | { |
255 | 0 | OpenAPI_authentication_subscription_t *authentication_subscription_local_var = NULL; |
256 | 0 | OpenAPI_lnode_t *node = NULL; |
257 | 0 | cJSON *authentication_method = NULL; |
258 | 0 | OpenAPI_auth_method_e authentication_methodVariable = 0; |
259 | 0 | cJSON *enc_permanent_key = NULL; |
260 | 0 | cJSON *protection_parameter_id = NULL; |
261 | 0 | cJSON *sequence_number = NULL; |
262 | 0 | OpenAPI_sequence_number_t *sequence_number_local_nonprim = NULL; |
263 | 0 | cJSON *authentication_management_field = NULL; |
264 | 0 | cJSON *algorithm_id = NULL; |
265 | 0 | cJSON *enc_opc_key = NULL; |
266 | 0 | cJSON *enc_topc_key = NULL; |
267 | 0 | cJSON *vector_generation_in_hss = NULL; |
268 | 0 | cJSON *hss_group_id = NULL; |
269 | 0 | cJSON *n5gc_auth_method = NULL; |
270 | 0 | OpenAPI_auth_method_e n5gc_auth_methodVariable = 0; |
271 | 0 | cJSON *rg_authentication_ind = NULL; |
272 | 0 | cJSON *supi = NULL; |
273 | 0 | cJSON *akma_allowed = NULL; |
274 | 0 | cJSON *routing_id = NULL; |
275 | 0 | cJSON *nswo_allowed = NULL; |
276 | 0 | cJSON *_5g_key_hierar_supp = NULL; |
277 | 0 | authentication_method = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "authenticationMethod"); |
278 | 0 | if (!authentication_method) { |
279 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [authentication_method]"); |
280 | 0 | goto end; |
281 | 0 | } |
282 | 0 | if (!cJSON_IsString(authentication_method)) { |
283 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [authentication_method]"); |
284 | 0 | goto end; |
285 | 0 | } |
286 | 0 | authentication_methodVariable = OpenAPI_auth_method_FromString(authentication_method->valuestring); |
287 | |
|
288 | 0 | enc_permanent_key = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "encPermanentKey"); |
289 | 0 | if (enc_permanent_key) { |
290 | 0 | if (!cJSON_IsString(enc_permanent_key) && !cJSON_IsNull(enc_permanent_key)) { |
291 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [enc_permanent_key]"); |
292 | 0 | goto end; |
293 | 0 | } |
294 | 0 | } |
295 | | |
296 | 0 | protection_parameter_id = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "protectionParameterId"); |
297 | 0 | if (protection_parameter_id) { |
298 | 0 | if (!cJSON_IsString(protection_parameter_id) && !cJSON_IsNull(protection_parameter_id)) { |
299 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [protection_parameter_id]"); |
300 | 0 | goto end; |
301 | 0 | } |
302 | 0 | } |
303 | | |
304 | 0 | sequence_number = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "sequenceNumber"); |
305 | 0 | if (sequence_number) { |
306 | 0 | sequence_number_local_nonprim = OpenAPI_sequence_number_parseFromJSON(sequence_number); |
307 | 0 | if (!sequence_number_local_nonprim) { |
308 | 0 | ogs_error("OpenAPI_sequence_number_parseFromJSON failed [sequence_number]"); |
309 | 0 | goto end; |
310 | 0 | } |
311 | 0 | } |
312 | | |
313 | 0 | authentication_management_field = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "authenticationManagementField"); |
314 | 0 | if (authentication_management_field) { |
315 | 0 | if (!cJSON_IsString(authentication_management_field) && !cJSON_IsNull(authentication_management_field)) { |
316 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [authentication_management_field]"); |
317 | 0 | goto end; |
318 | 0 | } |
319 | 0 | } |
320 | | |
321 | 0 | algorithm_id = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "algorithmId"); |
322 | 0 | if (algorithm_id) { |
323 | 0 | if (!cJSON_IsString(algorithm_id) && !cJSON_IsNull(algorithm_id)) { |
324 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [algorithm_id]"); |
325 | 0 | goto end; |
326 | 0 | } |
327 | 0 | } |
328 | | |
329 | 0 | enc_opc_key = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "encOpcKey"); |
330 | 0 | if (enc_opc_key) { |
331 | 0 | if (!cJSON_IsString(enc_opc_key) && !cJSON_IsNull(enc_opc_key)) { |
332 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [enc_opc_key]"); |
333 | 0 | goto end; |
334 | 0 | } |
335 | 0 | } |
336 | | |
337 | 0 | enc_topc_key = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "encTopcKey"); |
338 | 0 | if (enc_topc_key) { |
339 | 0 | if (!cJSON_IsString(enc_topc_key) && !cJSON_IsNull(enc_topc_key)) { |
340 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [enc_topc_key]"); |
341 | 0 | goto end; |
342 | 0 | } |
343 | 0 | } |
344 | | |
345 | 0 | vector_generation_in_hss = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "vectorGenerationInHss"); |
346 | 0 | if (vector_generation_in_hss) { |
347 | 0 | if (!cJSON_IsBool(vector_generation_in_hss)) { |
348 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [vector_generation_in_hss]"); |
349 | 0 | goto end; |
350 | 0 | } |
351 | 0 | } |
352 | | |
353 | 0 | hss_group_id = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "hssGroupId"); |
354 | 0 | if (hss_group_id) { |
355 | 0 | if (!cJSON_IsString(hss_group_id) && !cJSON_IsNull(hss_group_id)) { |
356 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [hss_group_id]"); |
357 | 0 | goto end; |
358 | 0 | } |
359 | 0 | } |
360 | | |
361 | 0 | n5gc_auth_method = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "n5gcAuthMethod"); |
362 | 0 | if (n5gc_auth_method) { |
363 | 0 | if (!cJSON_IsString(n5gc_auth_method)) { |
364 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [n5gc_auth_method]"); |
365 | 0 | goto end; |
366 | 0 | } |
367 | 0 | n5gc_auth_methodVariable = OpenAPI_auth_method_FromString(n5gc_auth_method->valuestring); |
368 | 0 | } |
369 | | |
370 | 0 | rg_authentication_ind = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "rgAuthenticationInd"); |
371 | 0 | if (rg_authentication_ind) { |
372 | 0 | if (!cJSON_IsBool(rg_authentication_ind)) { |
373 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [rg_authentication_ind]"); |
374 | 0 | goto end; |
375 | 0 | } |
376 | 0 | } |
377 | | |
378 | 0 | supi = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "supi"); |
379 | 0 | if (supi) { |
380 | 0 | if (!cJSON_IsString(supi) && !cJSON_IsNull(supi)) { |
381 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [supi]"); |
382 | 0 | goto end; |
383 | 0 | } |
384 | 0 | } |
385 | | |
386 | 0 | akma_allowed = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "akmaAllowed"); |
387 | 0 | if (akma_allowed) { |
388 | 0 | if (!cJSON_IsBool(akma_allowed)) { |
389 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [akma_allowed]"); |
390 | 0 | goto end; |
391 | 0 | } |
392 | 0 | } |
393 | | |
394 | 0 | routing_id = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "routingId"); |
395 | 0 | if (routing_id) { |
396 | 0 | if (!cJSON_IsString(routing_id) && !cJSON_IsNull(routing_id)) { |
397 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [routing_id]"); |
398 | 0 | goto end; |
399 | 0 | } |
400 | 0 | } |
401 | | |
402 | 0 | nswo_allowed = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "nswoAllowed"); |
403 | 0 | if (nswo_allowed) { |
404 | 0 | if (!cJSON_IsBool(nswo_allowed)) { |
405 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [nswo_allowed]"); |
406 | 0 | goto end; |
407 | 0 | } |
408 | 0 | } |
409 | | |
410 | 0 | _5g_key_hierar_supp = cJSON_GetObjectItemCaseSensitive(authentication_subscriptionJSON, "5gKeyHierarSupp"); |
411 | 0 | if (_5g_key_hierar_supp) { |
412 | 0 | if (!cJSON_IsBool(_5g_key_hierar_supp)) { |
413 | 0 | ogs_error("OpenAPI_authentication_subscription_parseFromJSON() failed [_5g_key_hierar_supp]"); |
414 | 0 | goto end; |
415 | 0 | } |
416 | 0 | } |
417 | | |
418 | 0 | authentication_subscription_local_var = OpenAPI_authentication_subscription_create ( |
419 | 0 | authentication_methodVariable, |
420 | 0 | enc_permanent_key && !cJSON_IsNull(enc_permanent_key) ? ogs_strdup(enc_permanent_key->valuestring) : NULL, |
421 | 0 | protection_parameter_id && !cJSON_IsNull(protection_parameter_id) ? ogs_strdup(protection_parameter_id->valuestring) : NULL, |
422 | 0 | sequence_number ? sequence_number_local_nonprim : NULL, |
423 | 0 | authentication_management_field && !cJSON_IsNull(authentication_management_field) ? ogs_strdup(authentication_management_field->valuestring) : NULL, |
424 | 0 | algorithm_id && !cJSON_IsNull(algorithm_id) ? ogs_strdup(algorithm_id->valuestring) : NULL, |
425 | 0 | enc_opc_key && !cJSON_IsNull(enc_opc_key) ? ogs_strdup(enc_opc_key->valuestring) : NULL, |
426 | 0 | enc_topc_key && !cJSON_IsNull(enc_topc_key) ? ogs_strdup(enc_topc_key->valuestring) : NULL, |
427 | 0 | vector_generation_in_hss ? true : false, |
428 | 0 | vector_generation_in_hss ? vector_generation_in_hss->valueint : 0, |
429 | 0 | hss_group_id && !cJSON_IsNull(hss_group_id) ? ogs_strdup(hss_group_id->valuestring) : NULL, |
430 | 0 | n5gc_auth_method ? n5gc_auth_methodVariable : 0, |
431 | 0 | rg_authentication_ind ? true : false, |
432 | 0 | rg_authentication_ind ? rg_authentication_ind->valueint : 0, |
433 | 0 | supi && !cJSON_IsNull(supi) ? ogs_strdup(supi->valuestring) : NULL, |
434 | 0 | akma_allowed ? true : false, |
435 | 0 | akma_allowed ? akma_allowed->valueint : 0, |
436 | 0 | routing_id && !cJSON_IsNull(routing_id) ? ogs_strdup(routing_id->valuestring) : NULL, |
437 | 0 | nswo_allowed ? true : false, |
438 | 0 | nswo_allowed ? nswo_allowed->valueint : 0, |
439 | 0 | _5g_key_hierar_supp ? true : false, |
440 | 0 | _5g_key_hierar_supp ? _5g_key_hierar_supp->valueint : 0 |
441 | 0 | ); |
442 | |
|
443 | 0 | return authentication_subscription_local_var; |
444 | 0 | end: |
445 | 0 | if (sequence_number_local_nonprim) { |
446 | 0 | OpenAPI_sequence_number_free(sequence_number_local_nonprim); |
447 | 0 | sequence_number_local_nonprim = NULL; |
448 | 0 | } |
449 | 0 | return NULL; |
450 | 0 | } |
451 | | |
452 | | OpenAPI_authentication_subscription_t *OpenAPI_authentication_subscription_copy(OpenAPI_authentication_subscription_t *dst, OpenAPI_authentication_subscription_t *src) |
453 | 0 | { |
454 | 0 | cJSON *item = NULL; |
455 | 0 | char *content = NULL; |
456 | |
|
457 | 0 | ogs_assert(src); |
458 | 0 | item = OpenAPI_authentication_subscription_convertToJSON(src); |
459 | 0 | if (!item) { |
460 | 0 | ogs_error("OpenAPI_authentication_subscription_convertToJSON() failed"); |
461 | 0 | return NULL; |
462 | 0 | } |
463 | | |
464 | 0 | content = cJSON_Print(item); |
465 | 0 | cJSON_Delete(item); |
466 | |
|
467 | 0 | if (!content) { |
468 | 0 | ogs_error("cJSON_Print() failed"); |
469 | 0 | return NULL; |
470 | 0 | } |
471 | | |
472 | 0 | item = cJSON_Parse(content); |
473 | 0 | ogs_free(content); |
474 | 0 | if (!item) { |
475 | 0 | ogs_error("cJSON_Parse() failed"); |
476 | 0 | return NULL; |
477 | 0 | } |
478 | | |
479 | 0 | OpenAPI_authentication_subscription_free(dst); |
480 | 0 | dst = OpenAPI_authentication_subscription_parseFromJSON(item); |
481 | 0 | cJSON_Delete(item); |
482 | |
|
483 | 0 | return dst; |
484 | 0 | } |
485 | | |