mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-04 06:10:11 +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
137
lib/sbi/openapi/model/identity_data.c
Normal file
137
lib/sbi/openapi/model/identity_data.c
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "identity_data.h"
|
||||
|
||||
OpenAPI_identity_data_t *OpenAPI_identity_data_create(
|
||||
OpenAPI_list_t *supi_list,
|
||||
OpenAPI_list_t *gpsi_list
|
||||
)
|
||||
{
|
||||
OpenAPI_identity_data_t *identity_data_local_var = OpenAPI_malloc(sizeof(OpenAPI_identity_data_t));
|
||||
if (!identity_data_local_var) {
|
||||
return NULL;
|
||||
}
|
||||
identity_data_local_var->supi_list = supi_list;
|
||||
identity_data_local_var->gpsi_list = gpsi_list;
|
||||
|
||||
return identity_data_local_var;
|
||||
}
|
||||
|
||||
void OpenAPI_identity_data_free(OpenAPI_identity_data_t *identity_data)
|
||||
{
|
||||
if (NULL == identity_data) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
OpenAPI_list_for_each(identity_data->supi_list, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(identity_data->supi_list);
|
||||
OpenAPI_list_for_each(identity_data->gpsi_list, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(identity_data->gpsi_list);
|
||||
ogs_free(identity_data);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_identity_data_convertToJSON(OpenAPI_identity_data_t *identity_data)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
|
||||
if (identity_data == NULL) {
|
||||
ogs_error("OpenAPI_identity_data_convertToJSON() failed [IdentityData]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (identity_data->supi_list) {
|
||||
cJSON *supi_list = cJSON_AddArrayToObject(item, "supiList");
|
||||
if (supi_list == NULL) {
|
||||
ogs_error("OpenAPI_identity_data_convertToJSON() failed [supi_list]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *supi_list_node;
|
||||
OpenAPI_list_for_each(identity_data->supi_list, supi_list_node) {
|
||||
if (cJSON_AddStringToObject(supi_list, "", (char*)supi_list_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_identity_data_convertToJSON() failed [supi_list]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (identity_data->gpsi_list) {
|
||||
cJSON *gpsi_list = cJSON_AddArrayToObject(item, "gpsiList");
|
||||
if (gpsi_list == NULL) {
|
||||
ogs_error("OpenAPI_identity_data_convertToJSON() failed [gpsi_list]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *gpsi_list_node;
|
||||
OpenAPI_list_for_each(identity_data->gpsi_list, gpsi_list_node) {
|
||||
if (cJSON_AddStringToObject(gpsi_list, "", (char*)gpsi_list_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_identity_data_convertToJSON() failed [gpsi_list]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
return item;
|
||||
}
|
||||
|
||||
OpenAPI_identity_data_t *OpenAPI_identity_data_parseFromJSON(cJSON *identity_dataJSON)
|
||||
{
|
||||
OpenAPI_identity_data_t *identity_data_local_var = NULL;
|
||||
cJSON *supi_list = cJSON_GetObjectItemCaseSensitive(identity_dataJSON, "supiList");
|
||||
|
||||
OpenAPI_list_t *supi_listList;
|
||||
if (supi_list) {
|
||||
cJSON *supi_list_local;
|
||||
if (!cJSON_IsArray(supi_list)) {
|
||||
ogs_error("OpenAPI_identity_data_parseFromJSON() failed [supi_list]");
|
||||
goto end;
|
||||
}
|
||||
supi_listList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(supi_list_local, supi_list) {
|
||||
if (!cJSON_IsString(supi_list_local)) {
|
||||
ogs_error("OpenAPI_identity_data_parseFromJSON() failed [supi_list]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(supi_listList, ogs_strdup(supi_list_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *gpsi_list = cJSON_GetObjectItemCaseSensitive(identity_dataJSON, "gpsiList");
|
||||
|
||||
OpenAPI_list_t *gpsi_listList;
|
||||
if (gpsi_list) {
|
||||
cJSON *gpsi_list_local;
|
||||
if (!cJSON_IsArray(gpsi_list)) {
|
||||
ogs_error("OpenAPI_identity_data_parseFromJSON() failed [gpsi_list]");
|
||||
goto end;
|
||||
}
|
||||
gpsi_listList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(gpsi_list_local, gpsi_list) {
|
||||
if (!cJSON_IsString(gpsi_list_local)) {
|
||||
ogs_error("OpenAPI_identity_data_parseFromJSON() failed [gpsi_list]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(gpsi_listList, ogs_strdup(gpsi_list_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
identity_data_local_var = OpenAPI_identity_data_create (
|
||||
supi_list ? supi_listList : NULL,
|
||||
gpsi_list ? gpsi_listList : NULL
|
||||
);
|
||||
|
||||
return identity_data_local_var;
|
||||
end:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue