mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-05 15:24:14 +00:00
Add only one 5GC scenario (call-flow)
This commit is contained in:
parent
20008b6a13
commit
dbee687a75
1415 changed files with 86635 additions and 5877 deletions
183
lib/sbi/openapi/model/status_info.c
Normal file
183
lib/sbi/openapi/model/status_info.c
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "status_info.h"
|
||||
|
||||
OpenAPI_status_info_t *OpenAPI_status_info_create(
|
||||
OpenAPI_resource_status_t *resource_status,
|
||||
OpenAPI_cause_t *cause,
|
||||
OpenAPI_cn_assisted_ran_para_t *cn_assisted_ran_para,
|
||||
OpenAPI_access_type_e an_type
|
||||
)
|
||||
{
|
||||
OpenAPI_status_info_t *status_info_local_var = OpenAPI_malloc(sizeof(OpenAPI_status_info_t));
|
||||
if (!status_info_local_var) {
|
||||
return NULL;
|
||||
}
|
||||
status_info_local_var->resource_status = resource_status;
|
||||
status_info_local_var->cause = cause;
|
||||
status_info_local_var->cn_assisted_ran_para = cn_assisted_ran_para;
|
||||
status_info_local_var->an_type = an_type;
|
||||
|
||||
return status_info_local_var;
|
||||
}
|
||||
|
||||
void OpenAPI_status_info_free(OpenAPI_status_info_t *status_info)
|
||||
{
|
||||
if (NULL == status_info) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
OpenAPI_resource_status_free(status_info->resource_status);
|
||||
OpenAPI_cause_free(status_info->cause);
|
||||
OpenAPI_cn_assisted_ran_para_free(status_info->cn_assisted_ran_para);
|
||||
ogs_free(status_info);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_status_info_convertToJSON(OpenAPI_status_info_t *status_info)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
|
||||
if (status_info == NULL) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed [StatusInfo]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (!status_info->resource_status) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed [resource_status]");
|
||||
goto end;
|
||||
}
|
||||
cJSON *resource_status_local_JSON = OpenAPI_resource_status_convertToJSON(status_info->resource_status);
|
||||
if (resource_status_local_JSON == NULL) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed [resource_status]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToObject(item, "resourceStatus", resource_status_local_JSON);
|
||||
if (item->child == NULL) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed [resource_status]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (status_info->cause) {
|
||||
cJSON *cause_local_JSON = OpenAPI_cause_convertToJSON(status_info->cause);
|
||||
if (cause_local_JSON == NULL) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed [cause]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToObject(item, "cause", cause_local_JSON);
|
||||
if (item->child == NULL) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed [cause]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (status_info->cn_assisted_ran_para) {
|
||||
cJSON *cn_assisted_ran_para_local_JSON = OpenAPI_cn_assisted_ran_para_convertToJSON(status_info->cn_assisted_ran_para);
|
||||
if (cn_assisted_ran_para_local_JSON == NULL) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed [cn_assisted_ran_para]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToObject(item, "cnAssistedRanPara", cn_assisted_ran_para_local_JSON);
|
||||
if (item->child == NULL) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed [cn_assisted_ran_para]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (status_info->an_type) {
|
||||
if (cJSON_AddStringToObject(item, "anType", OpenAPI_access_type_ToString(status_info->an_type)) == NULL) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed [an_type]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
return item;
|
||||
}
|
||||
|
||||
OpenAPI_status_info_t *OpenAPI_status_info_parseFromJSON(cJSON *status_infoJSON)
|
||||
{
|
||||
OpenAPI_status_info_t *status_info_local_var = NULL;
|
||||
cJSON *resource_status = cJSON_GetObjectItemCaseSensitive(status_infoJSON, "resourceStatus");
|
||||
if (!resource_status) {
|
||||
ogs_error("OpenAPI_status_info_parseFromJSON() failed [resource_status]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_resource_status_t *resource_status_local_nonprim = NULL;
|
||||
|
||||
resource_status_local_nonprim = OpenAPI_resource_status_parseFromJSON(resource_status);
|
||||
|
||||
cJSON *cause = cJSON_GetObjectItemCaseSensitive(status_infoJSON, "cause");
|
||||
|
||||
OpenAPI_cause_t *cause_local_nonprim = NULL;
|
||||
if (cause) {
|
||||
cause_local_nonprim = OpenAPI_cause_parseFromJSON(cause);
|
||||
}
|
||||
|
||||
cJSON *cn_assisted_ran_para = cJSON_GetObjectItemCaseSensitive(status_infoJSON, "cnAssistedRanPara");
|
||||
|
||||
OpenAPI_cn_assisted_ran_para_t *cn_assisted_ran_para_local_nonprim = NULL;
|
||||
if (cn_assisted_ran_para) {
|
||||
cn_assisted_ran_para_local_nonprim = OpenAPI_cn_assisted_ran_para_parseFromJSON(cn_assisted_ran_para);
|
||||
}
|
||||
|
||||
cJSON *an_type = cJSON_GetObjectItemCaseSensitive(status_infoJSON, "anType");
|
||||
|
||||
OpenAPI_access_type_e an_typeVariable;
|
||||
if (an_type) {
|
||||
if (!cJSON_IsString(an_type)) {
|
||||
ogs_error("OpenAPI_status_info_parseFromJSON() failed [an_type]");
|
||||
goto end;
|
||||
}
|
||||
an_typeVariable = OpenAPI_access_type_FromString(an_type->valuestring);
|
||||
}
|
||||
|
||||
status_info_local_var = OpenAPI_status_info_create (
|
||||
resource_status_local_nonprim,
|
||||
cause ? cause_local_nonprim : NULL,
|
||||
cn_assisted_ran_para ? cn_assisted_ran_para_local_nonprim : NULL,
|
||||
an_type ? an_typeVariable : 0
|
||||
);
|
||||
|
||||
return status_info_local_var;
|
||||
end:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OpenAPI_status_info_t *OpenAPI_status_info_copy(OpenAPI_status_info_t *dst, OpenAPI_status_info_t *src)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
char *content = NULL;
|
||||
|
||||
ogs_assert(src);
|
||||
item = OpenAPI_status_info_convertToJSON(src);
|
||||
if (!item) {
|
||||
ogs_error("OpenAPI_status_info_convertToJSON() failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
content = cJSON_Print(item);
|
||||
cJSON_Delete(item);
|
||||
|
||||
if (!content) {
|
||||
ogs_error("cJSON_Print() failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = cJSON_Parse(content);
|
||||
ogs_free(content);
|
||||
if (!item) {
|
||||
ogs_error("cJSON_Parse() failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OpenAPI_status_info_free(dst);
|
||||
dst = OpenAPI_status_info_parseFromJSON(item);
|
||||
cJSON_Delete(item);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue