mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-04 22:30:09 +00:00
Add AUSF, UDM, and UDR
This commit is contained in:
parent
0c0241d5e5
commit
72370ff0b2
1151 changed files with 140173 additions and 24799 deletions
148
lib/sbi/openapi/model/privacy_parameter.c
Normal file
148
lib/sbi/openapi/model/privacy_parameter.c
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "privacy_parameter.h"
|
||||
|
||||
OpenAPI_privacy_parameter_t *OpenAPI_privacy_parameter_create(
|
||||
OpenAPI_list_t *ser_ids,
|
||||
char *geographical_area,
|
||||
int timer
|
||||
)
|
||||
{
|
||||
OpenAPI_privacy_parameter_t *privacy_parameter_local_var = OpenAPI_malloc(sizeof(OpenAPI_privacy_parameter_t));
|
||||
if (!privacy_parameter_local_var) {
|
||||
return NULL;
|
||||
}
|
||||
privacy_parameter_local_var->ser_ids = ser_ids;
|
||||
privacy_parameter_local_var->geographical_area = geographical_area;
|
||||
privacy_parameter_local_var->timer = timer;
|
||||
|
||||
return privacy_parameter_local_var;
|
||||
}
|
||||
|
||||
void OpenAPI_privacy_parameter_free(OpenAPI_privacy_parameter_t *privacy_parameter)
|
||||
{
|
||||
if (NULL == privacy_parameter) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
OpenAPI_list_for_each(privacy_parameter->ser_ids, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(privacy_parameter->ser_ids);
|
||||
ogs_free(privacy_parameter->geographical_area);
|
||||
ogs_free(privacy_parameter);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_privacy_parameter_convertToJSON(OpenAPI_privacy_parameter_t *privacy_parameter)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
|
||||
if (privacy_parameter == NULL) {
|
||||
ogs_error("OpenAPI_privacy_parameter_convertToJSON() failed [PrivacyParameter]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (!privacy_parameter->ser_ids) {
|
||||
ogs_error("OpenAPI_privacy_parameter_convertToJSON() failed [ser_ids]");
|
||||
goto end;
|
||||
}
|
||||
cJSON *ser_ids = cJSON_AddArrayToObject(item, "serIds");
|
||||
if (ser_ids == NULL) {
|
||||
ogs_error("OpenAPI_privacy_parameter_convertToJSON() failed [ser_ids]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *ser_ids_node;
|
||||
OpenAPI_list_for_each(privacy_parameter->ser_ids, ser_ids_node) {
|
||||
if (cJSON_AddStringToObject(ser_ids, "", (char*)ser_ids_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_privacy_parameter_convertToJSON() failed [ser_ids]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (!privacy_parameter->geographical_area) {
|
||||
ogs_error("OpenAPI_privacy_parameter_convertToJSON() failed [geographical_area]");
|
||||
goto end;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "geographicalArea", privacy_parameter->geographical_area) == NULL) {
|
||||
ogs_error("OpenAPI_privacy_parameter_convertToJSON() failed [geographical_area]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!privacy_parameter->timer) {
|
||||
ogs_error("OpenAPI_privacy_parameter_convertToJSON() failed [timer]");
|
||||
goto end;
|
||||
}
|
||||
if (cJSON_AddNumberToObject(item, "timer", privacy_parameter->timer) == NULL) {
|
||||
ogs_error("OpenAPI_privacy_parameter_convertToJSON() failed [timer]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
end:
|
||||
return item;
|
||||
}
|
||||
|
||||
OpenAPI_privacy_parameter_t *OpenAPI_privacy_parameter_parseFromJSON(cJSON *privacy_parameterJSON)
|
||||
{
|
||||
OpenAPI_privacy_parameter_t *privacy_parameter_local_var = NULL;
|
||||
cJSON *ser_ids = cJSON_GetObjectItemCaseSensitive(privacy_parameterJSON, "serIds");
|
||||
if (!ser_ids) {
|
||||
ogs_error("OpenAPI_privacy_parameter_parseFromJSON() failed [ser_ids]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_list_t *ser_idsList;
|
||||
|
||||
cJSON *ser_ids_local;
|
||||
if (!cJSON_IsArray(ser_ids)) {
|
||||
ogs_error("OpenAPI_privacy_parameter_parseFromJSON() failed [ser_ids]");
|
||||
goto end;
|
||||
}
|
||||
ser_idsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(ser_ids_local, ser_ids) {
|
||||
if (!cJSON_IsString(ser_ids_local)) {
|
||||
ogs_error("OpenAPI_privacy_parameter_parseFromJSON() failed [ser_ids]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(ser_idsList, ogs_strdup(ser_ids_local->valuestring));
|
||||
}
|
||||
|
||||
cJSON *geographical_area = cJSON_GetObjectItemCaseSensitive(privacy_parameterJSON, "geographicalArea");
|
||||
if (!geographical_area) {
|
||||
ogs_error("OpenAPI_privacy_parameter_parseFromJSON() failed [geographical_area]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (!cJSON_IsString(geographical_area)) {
|
||||
ogs_error("OpenAPI_privacy_parameter_parseFromJSON() failed [geographical_area]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *timer = cJSON_GetObjectItemCaseSensitive(privacy_parameterJSON, "timer");
|
||||
if (!timer) {
|
||||
ogs_error("OpenAPI_privacy_parameter_parseFromJSON() failed [timer]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (!cJSON_IsNumber(timer)) {
|
||||
ogs_error("OpenAPI_privacy_parameter_parseFromJSON() failed [timer]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
privacy_parameter_local_var = OpenAPI_privacy_parameter_create (
|
||||
ser_idsList,
|
||||
ogs_strdup(geographical_area->valuestring),
|
||||
timer->valuedouble
|
||||
);
|
||||
|
||||
return privacy_parameter_local_var;
|
||||
end:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue