mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-05 07:08:11 +00:00
[SBI] Crash occurs when ENUM in the MAP (#2103)
This commit is contained in:
parent
ce668c556c
commit
969c116e77
1097 changed files with 266728 additions and 42047 deletions
|
|
@ -22,22 +22,33 @@ OpenAPI_traffic_descriptor_t *OpenAPI_traffic_descriptor_create(
|
|||
|
||||
void OpenAPI_traffic_descriptor_free(OpenAPI_traffic_descriptor_t *traffic_descriptor)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == traffic_descriptor) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(traffic_descriptor->dnn);
|
||||
OpenAPI_snssai_free(traffic_descriptor->s_nssai);
|
||||
OpenAPI_list_for_each(traffic_descriptor->ddd_traffic_descriptor_list, node) {
|
||||
OpenAPI_ddd_traffic_descriptor_free(node->data);
|
||||
if (traffic_descriptor->dnn) {
|
||||
ogs_free(traffic_descriptor->dnn);
|
||||
traffic_descriptor->dnn = NULL;
|
||||
}
|
||||
if (traffic_descriptor->s_nssai) {
|
||||
OpenAPI_snssai_free(traffic_descriptor->s_nssai);
|
||||
traffic_descriptor->s_nssai = NULL;
|
||||
}
|
||||
if (traffic_descriptor->ddd_traffic_descriptor_list) {
|
||||
OpenAPI_list_for_each(traffic_descriptor->ddd_traffic_descriptor_list, node) {
|
||||
OpenAPI_ddd_traffic_descriptor_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(traffic_descriptor->ddd_traffic_descriptor_list);
|
||||
traffic_descriptor->ddd_traffic_descriptor_list = NULL;
|
||||
}
|
||||
OpenAPI_list_free(traffic_descriptor->ddd_traffic_descriptor_list);
|
||||
ogs_free(traffic_descriptor);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_traffic_descriptor_convertToJSON(OpenAPI_traffic_descriptor_t *traffic_descriptor)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (traffic_descriptor == NULL) {
|
||||
ogs_error("OpenAPI_traffic_descriptor_convertToJSON() failed [TrafficDescriptor]");
|
||||
|
|
@ -71,17 +82,13 @@ cJSON *OpenAPI_traffic_descriptor_convertToJSON(OpenAPI_traffic_descriptor_t *tr
|
|||
ogs_error("OpenAPI_traffic_descriptor_convertToJSON() failed [ddd_traffic_descriptor_list]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *ddd_traffic_descriptor_list_node;
|
||||
if (traffic_descriptor->ddd_traffic_descriptor_list) {
|
||||
OpenAPI_list_for_each(traffic_descriptor->ddd_traffic_descriptor_list, ddd_traffic_descriptor_list_node) {
|
||||
cJSON *itemLocal = OpenAPI_ddd_traffic_descriptor_convertToJSON(ddd_traffic_descriptor_list_node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_traffic_descriptor_convertToJSON() failed [ddd_traffic_descriptor_list]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(ddd_traffic_descriptor_listList, itemLocal);
|
||||
OpenAPI_list_for_each(traffic_descriptor->ddd_traffic_descriptor_list, node) {
|
||||
cJSON *itemLocal = OpenAPI_ddd_traffic_descriptor_convertToJSON(node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_traffic_descriptor_convertToJSON() failed [ddd_traffic_descriptor_list]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(ddd_traffic_descriptor_listList, itemLocal);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,59 +99,69 @@ end:
|
|||
OpenAPI_traffic_descriptor_t *OpenAPI_traffic_descriptor_parseFromJSON(cJSON *traffic_descriptorJSON)
|
||||
{
|
||||
OpenAPI_traffic_descriptor_t *traffic_descriptor_local_var = NULL;
|
||||
cJSON *dnn = cJSON_GetObjectItemCaseSensitive(traffic_descriptorJSON, "dnn");
|
||||
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *dnn = NULL;
|
||||
cJSON *s_nssai = NULL;
|
||||
OpenAPI_snssai_t *s_nssai_local_nonprim = NULL;
|
||||
cJSON *ddd_traffic_descriptor_list = NULL;
|
||||
OpenAPI_list_t *ddd_traffic_descriptor_listList = NULL;
|
||||
dnn = cJSON_GetObjectItemCaseSensitive(traffic_descriptorJSON, "dnn");
|
||||
if (dnn) {
|
||||
if (!cJSON_IsString(dnn)) {
|
||||
if (!cJSON_IsString(dnn) && !cJSON_IsNull(dnn)) {
|
||||
ogs_error("OpenAPI_traffic_descriptor_parseFromJSON() failed [dnn]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *s_nssai = cJSON_GetObjectItemCaseSensitive(traffic_descriptorJSON, "sNssai");
|
||||
|
||||
OpenAPI_snssai_t *s_nssai_local_nonprim = NULL;
|
||||
s_nssai = cJSON_GetObjectItemCaseSensitive(traffic_descriptorJSON, "sNssai");
|
||||
if (s_nssai) {
|
||||
s_nssai_local_nonprim = OpenAPI_snssai_parseFromJSON(s_nssai);
|
||||
}
|
||||
|
||||
cJSON *ddd_traffic_descriptor_list = cJSON_GetObjectItemCaseSensitive(traffic_descriptorJSON, "dddTrafficDescriptorList");
|
||||
|
||||
OpenAPI_list_t *ddd_traffic_descriptor_listList;
|
||||
ddd_traffic_descriptor_list = cJSON_GetObjectItemCaseSensitive(traffic_descriptorJSON, "dddTrafficDescriptorList");
|
||||
if (ddd_traffic_descriptor_list) {
|
||||
cJSON *ddd_traffic_descriptor_list_local_nonprimitive;
|
||||
if (!cJSON_IsArray(ddd_traffic_descriptor_list)){
|
||||
ogs_error("OpenAPI_traffic_descriptor_parseFromJSON() failed [ddd_traffic_descriptor_list]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ddd_traffic_descriptor_listList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(ddd_traffic_descriptor_list_local_nonprimitive, ddd_traffic_descriptor_list ) {
|
||||
if (!cJSON_IsObject(ddd_traffic_descriptor_list_local_nonprimitive)) {
|
||||
cJSON *ddd_traffic_descriptor_list_local = NULL;
|
||||
if (!cJSON_IsArray(ddd_traffic_descriptor_list)) {
|
||||
ogs_error("OpenAPI_traffic_descriptor_parseFromJSON() failed [ddd_traffic_descriptor_list]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_ddd_traffic_descriptor_t *ddd_traffic_descriptor_listItem = OpenAPI_ddd_traffic_descriptor_parseFromJSON(ddd_traffic_descriptor_list_local_nonprimitive);
|
||||
|
||||
if (!ddd_traffic_descriptor_listItem) {
|
||||
ogs_error("No ddd_traffic_descriptor_listItem");
|
||||
OpenAPI_list_free(ddd_traffic_descriptor_listList);
|
||||
goto end;
|
||||
ddd_traffic_descriptor_listList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(ddd_traffic_descriptor_list_local, ddd_traffic_descriptor_list) {
|
||||
if (!cJSON_IsObject(ddd_traffic_descriptor_list_local)) {
|
||||
ogs_error("OpenAPI_traffic_descriptor_parseFromJSON() failed [ddd_traffic_descriptor_list]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_ddd_traffic_descriptor_t *ddd_traffic_descriptor_listItem = OpenAPI_ddd_traffic_descriptor_parseFromJSON(ddd_traffic_descriptor_list_local);
|
||||
if (!ddd_traffic_descriptor_listItem) {
|
||||
ogs_error("No ddd_traffic_descriptor_listItem");
|
||||
OpenAPI_list_free(ddd_traffic_descriptor_listList);
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(ddd_traffic_descriptor_listList, ddd_traffic_descriptor_listItem);
|
||||
}
|
||||
|
||||
OpenAPI_list_add(ddd_traffic_descriptor_listList, ddd_traffic_descriptor_listItem);
|
||||
}
|
||||
}
|
||||
|
||||
traffic_descriptor_local_var = OpenAPI_traffic_descriptor_create (
|
||||
dnn ? ogs_strdup(dnn->valuestring) : NULL,
|
||||
dnn && !cJSON_IsNull(dnn) ? ogs_strdup(dnn->valuestring) : NULL,
|
||||
s_nssai ? s_nssai_local_nonprim : NULL,
|
||||
ddd_traffic_descriptor_list ? ddd_traffic_descriptor_listList : NULL
|
||||
);
|
||||
|
||||
return traffic_descriptor_local_var;
|
||||
end:
|
||||
if (s_nssai_local_nonprim) {
|
||||
OpenAPI_snssai_free(s_nssai_local_nonprim);
|
||||
s_nssai_local_nonprim = NULL;
|
||||
}
|
||||
if (ddd_traffic_descriptor_listList) {
|
||||
OpenAPI_list_for_each(ddd_traffic_descriptor_listList, node) {
|
||||
OpenAPI_ddd_traffic_descriptor_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(ddd_traffic_descriptor_listList);
|
||||
ddd_traffic_descriptor_listList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue