[SBI] Crash occurs when ENUM in the MAP (#2103)

This commit is contained in:
Sukchan Lee 2023-03-01 17:50:25 +09:00
parent ce668c556c
commit 969c116e77
1097 changed files with 266728 additions and 42047 deletions

View file

@ -48,30 +48,65 @@ OpenAPI_sm_context_created_data_t *OpenAPI_sm_context_created_data_create(
void OpenAPI_sm_context_created_data_free(OpenAPI_sm_context_created_data_t *sm_context_created_data)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == sm_context_created_data) {
return;
}
OpenAPI_lnode_t *node;
ogs_free(sm_context_created_data->h_smf_uri);
ogs_free(sm_context_created_data->smf_uri);
OpenAPI_snssai_free(sm_context_created_data->s_nssai);
OpenAPI_ref_to_binary_data_free(sm_context_created_data->n2_sm_info);
OpenAPI_list_for_each(sm_context_created_data->allocated_ebi_list, node) {
OpenAPI_ebi_arp_mapping_free(node->data);
if (sm_context_created_data->h_smf_uri) {
ogs_free(sm_context_created_data->h_smf_uri);
sm_context_created_data->h_smf_uri = NULL;
}
if (sm_context_created_data->smf_uri) {
ogs_free(sm_context_created_data->smf_uri);
sm_context_created_data->smf_uri = NULL;
}
if (sm_context_created_data->s_nssai) {
OpenAPI_snssai_free(sm_context_created_data->s_nssai);
sm_context_created_data->s_nssai = NULL;
}
if (sm_context_created_data->n2_sm_info) {
OpenAPI_ref_to_binary_data_free(sm_context_created_data->n2_sm_info);
sm_context_created_data->n2_sm_info = NULL;
}
if (sm_context_created_data->allocated_ebi_list) {
OpenAPI_list_for_each(sm_context_created_data->allocated_ebi_list, node) {
OpenAPI_ebi_arp_mapping_free(node->data);
}
OpenAPI_list_free(sm_context_created_data->allocated_ebi_list);
sm_context_created_data->allocated_ebi_list = NULL;
}
if (sm_context_created_data->gpsi) {
ogs_free(sm_context_created_data->gpsi);
sm_context_created_data->gpsi = NULL;
}
if (sm_context_created_data->smf_service_instance_id) {
ogs_free(sm_context_created_data->smf_service_instance_id);
sm_context_created_data->smf_service_instance_id = NULL;
}
if (sm_context_created_data->recovery_time) {
ogs_free(sm_context_created_data->recovery_time);
sm_context_created_data->recovery_time = NULL;
}
if (sm_context_created_data->supported_features) {
ogs_free(sm_context_created_data->supported_features);
sm_context_created_data->supported_features = NULL;
}
if (sm_context_created_data->selected_smf_id) {
ogs_free(sm_context_created_data->selected_smf_id);
sm_context_created_data->selected_smf_id = NULL;
}
if (sm_context_created_data->selected_old_smf_id) {
ogs_free(sm_context_created_data->selected_old_smf_id);
sm_context_created_data->selected_old_smf_id = NULL;
}
OpenAPI_list_free(sm_context_created_data->allocated_ebi_list);
ogs_free(sm_context_created_data->gpsi);
ogs_free(sm_context_created_data->smf_service_instance_id);
ogs_free(sm_context_created_data->recovery_time);
ogs_free(sm_context_created_data->supported_features);
ogs_free(sm_context_created_data->selected_smf_id);
ogs_free(sm_context_created_data->selected_old_smf_id);
ogs_free(sm_context_created_data);
}
cJSON *OpenAPI_sm_context_created_data_convertToJSON(OpenAPI_sm_context_created_data_t *sm_context_created_data)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (sm_context_created_data == NULL) {
ogs_error("OpenAPI_sm_context_created_data_convertToJSON() failed [SmContextCreatedData]");
@ -113,7 +148,7 @@ cJSON *OpenAPI_sm_context_created_data_convertToJSON(OpenAPI_sm_context_created_
}
}
if (sm_context_created_data->up_cnx_state) {
if (sm_context_created_data->up_cnx_state != OpenAPI_up_cnx_state_NULL) {
if (cJSON_AddStringToObject(item, "upCnxState", OpenAPI_up_cnx_state_ToString(sm_context_created_data->up_cnx_state)) == NULL) {
ogs_error("OpenAPI_sm_context_created_data_convertToJSON() failed [up_cnx_state]");
goto end;
@ -133,7 +168,7 @@ cJSON *OpenAPI_sm_context_created_data_convertToJSON(OpenAPI_sm_context_created_
}
}
if (sm_context_created_data->n2_sm_info_type) {
if (sm_context_created_data->n2_sm_info_type != OpenAPI_n2_sm_info_type_NULL) {
if (cJSON_AddStringToObject(item, "n2SmInfoType", OpenAPI_n2_sm_info_type_ToString(sm_context_created_data->n2_sm_info_type)) == NULL) {
ogs_error("OpenAPI_sm_context_created_data_convertToJSON() failed [n2_sm_info_type]");
goto end;
@ -146,21 +181,17 @@ cJSON *OpenAPI_sm_context_created_data_convertToJSON(OpenAPI_sm_context_created_
ogs_error("OpenAPI_sm_context_created_data_convertToJSON() failed [allocated_ebi_list]");
goto end;
}
OpenAPI_lnode_t *allocated_ebi_list_node;
if (sm_context_created_data->allocated_ebi_list) {
OpenAPI_list_for_each(sm_context_created_data->allocated_ebi_list, allocated_ebi_list_node) {
cJSON *itemLocal = OpenAPI_ebi_arp_mapping_convertToJSON(allocated_ebi_list_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sm_context_created_data_convertToJSON() failed [allocated_ebi_list]");
goto end;
}
cJSON_AddItemToArray(allocated_ebi_listList, itemLocal);
OpenAPI_list_for_each(sm_context_created_data->allocated_ebi_list, node) {
cJSON *itemLocal = OpenAPI_ebi_arp_mapping_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sm_context_created_data_convertToJSON() failed [allocated_ebi_list]");
goto end;
}
cJSON_AddItemToArray(allocated_ebi_listList, itemLocal);
}
}
if (sm_context_created_data->ho_state) {
if (sm_context_created_data->ho_state != OpenAPI_ho_state_NULL) {
if (cJSON_AddStringToObject(item, "hoState", OpenAPI_ho_state_ToString(sm_context_created_data->ho_state)) == NULL) {
ogs_error("OpenAPI_sm_context_created_data_convertToJSON() failed [ho_state]");
goto end;
@ -216,26 +247,45 @@ end:
OpenAPI_sm_context_created_data_t *OpenAPI_sm_context_created_data_parseFromJSON(cJSON *sm_context_created_dataJSON)
{
OpenAPI_sm_context_created_data_t *sm_context_created_data_local_var = NULL;
cJSON *h_smf_uri = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "hSmfUri");
OpenAPI_lnode_t *node = NULL;
cJSON *h_smf_uri = NULL;
cJSON *smf_uri = NULL;
cJSON *pdu_session_id = NULL;
cJSON *s_nssai = NULL;
OpenAPI_snssai_t *s_nssai_local_nonprim = NULL;
cJSON *up_cnx_state = NULL;
OpenAPI_up_cnx_state_e up_cnx_stateVariable = 0;
cJSON *n2_sm_info = NULL;
OpenAPI_ref_to_binary_data_t *n2_sm_info_local_nonprim = NULL;
cJSON *n2_sm_info_type = NULL;
OpenAPI_n2_sm_info_type_e n2_sm_info_typeVariable = 0;
cJSON *allocated_ebi_list = NULL;
OpenAPI_list_t *allocated_ebi_listList = NULL;
cJSON *ho_state = NULL;
OpenAPI_ho_state_e ho_stateVariable = 0;
cJSON *gpsi = NULL;
cJSON *smf_service_instance_id = NULL;
cJSON *recovery_time = NULL;
cJSON *supported_features = NULL;
cJSON *selected_smf_id = NULL;
cJSON *selected_old_smf_id = NULL;
h_smf_uri = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "hSmfUri");
if (h_smf_uri) {
if (!cJSON_IsString(h_smf_uri)) {
if (!cJSON_IsString(h_smf_uri) && !cJSON_IsNull(h_smf_uri)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [h_smf_uri]");
goto end;
}
}
cJSON *smf_uri = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "smfUri");
smf_uri = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "smfUri");
if (smf_uri) {
if (!cJSON_IsString(smf_uri)) {
if (!cJSON_IsString(smf_uri) && !cJSON_IsNull(smf_uri)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [smf_uri]");
goto end;
}
}
cJSON *pdu_session_id = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "pduSessionId");
pdu_session_id = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "pduSessionId");
if (pdu_session_id) {
if (!cJSON_IsNumber(pdu_session_id)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [pdu_session_id]");
@ -243,16 +293,12 @@ OpenAPI_sm_context_created_data_t *OpenAPI_sm_context_created_data_parseFromJSON
}
}
cJSON *s_nssai = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "sNssai");
OpenAPI_snssai_t *s_nssai_local_nonprim = NULL;
s_nssai = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "sNssai");
if (s_nssai) {
s_nssai_local_nonprim = OpenAPI_snssai_parseFromJSON(s_nssai);
}
cJSON *up_cnx_state = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "upCnxState");
OpenAPI_up_cnx_state_e up_cnx_stateVariable;
up_cnx_state = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "upCnxState");
if (up_cnx_state) {
if (!cJSON_IsString(up_cnx_state)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [up_cnx_state]");
@ -261,16 +307,12 @@ OpenAPI_sm_context_created_data_t *OpenAPI_sm_context_created_data_parseFromJSON
up_cnx_stateVariable = OpenAPI_up_cnx_state_FromString(up_cnx_state->valuestring);
}
cJSON *n2_sm_info = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "n2SmInfo");
OpenAPI_ref_to_binary_data_t *n2_sm_info_local_nonprim = NULL;
n2_sm_info = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "n2SmInfo");
if (n2_sm_info) {
n2_sm_info_local_nonprim = OpenAPI_ref_to_binary_data_parseFromJSON(n2_sm_info);
}
cJSON *n2_sm_info_type = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "n2SmInfoType");
OpenAPI_n2_sm_info_type_e n2_sm_info_typeVariable;
n2_sm_info_type = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "n2SmInfoType");
if (n2_sm_info_type) {
if (!cJSON_IsString(n2_sm_info_type)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [n2_sm_info_type]");
@ -279,38 +321,32 @@ OpenAPI_sm_context_created_data_t *OpenAPI_sm_context_created_data_parseFromJSON
n2_sm_info_typeVariable = OpenAPI_n2_sm_info_type_FromString(n2_sm_info_type->valuestring);
}
cJSON *allocated_ebi_list = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "allocatedEbiList");
OpenAPI_list_t *allocated_ebi_listList;
allocated_ebi_list = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "allocatedEbiList");
if (allocated_ebi_list) {
cJSON *allocated_ebi_list_local_nonprimitive;
if (!cJSON_IsArray(allocated_ebi_list)){
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [allocated_ebi_list]");
goto end;
}
allocated_ebi_listList = OpenAPI_list_create();
cJSON_ArrayForEach(allocated_ebi_list_local_nonprimitive, allocated_ebi_list ) {
if (!cJSON_IsObject(allocated_ebi_list_local_nonprimitive)) {
cJSON *allocated_ebi_list_local = NULL;
if (!cJSON_IsArray(allocated_ebi_list)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [allocated_ebi_list]");
goto end;
}
OpenAPI_ebi_arp_mapping_t *allocated_ebi_listItem = OpenAPI_ebi_arp_mapping_parseFromJSON(allocated_ebi_list_local_nonprimitive);
if (!allocated_ebi_listItem) {
ogs_error("No allocated_ebi_listItem");
OpenAPI_list_free(allocated_ebi_listList);
goto end;
allocated_ebi_listList = OpenAPI_list_create();
cJSON_ArrayForEach(allocated_ebi_list_local, allocated_ebi_list) {
if (!cJSON_IsObject(allocated_ebi_list_local)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [allocated_ebi_list]");
goto end;
}
OpenAPI_ebi_arp_mapping_t *allocated_ebi_listItem = OpenAPI_ebi_arp_mapping_parseFromJSON(allocated_ebi_list_local);
if (!allocated_ebi_listItem) {
ogs_error("No allocated_ebi_listItem");
OpenAPI_list_free(allocated_ebi_listList);
goto end;
}
OpenAPI_list_add(allocated_ebi_listList, allocated_ebi_listItem);
}
OpenAPI_list_add(allocated_ebi_listList, allocated_ebi_listItem);
}
}
cJSON *ho_state = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "hoState");
OpenAPI_ho_state_e ho_stateVariable;
ho_state = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "hoState");
if (ho_state) {
if (!cJSON_IsString(ho_state)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [ho_state]");
@ -319,63 +355,57 @@ OpenAPI_sm_context_created_data_t *OpenAPI_sm_context_created_data_parseFromJSON
ho_stateVariable = OpenAPI_ho_state_FromString(ho_state->valuestring);
}
cJSON *gpsi = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "gpsi");
gpsi = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "gpsi");
if (gpsi) {
if (!cJSON_IsString(gpsi)) {
if (!cJSON_IsString(gpsi) && !cJSON_IsNull(gpsi)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [gpsi]");
goto end;
}
}
cJSON *smf_service_instance_id = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "smfServiceInstanceId");
smf_service_instance_id = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "smfServiceInstanceId");
if (smf_service_instance_id) {
if (!cJSON_IsString(smf_service_instance_id)) {
if (!cJSON_IsString(smf_service_instance_id) && !cJSON_IsNull(smf_service_instance_id)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [smf_service_instance_id]");
goto end;
}
}
cJSON *recovery_time = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "recoveryTime");
recovery_time = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "recoveryTime");
if (recovery_time) {
if (!cJSON_IsString(recovery_time)) {
if (!cJSON_IsString(recovery_time) && !cJSON_IsNull(recovery_time)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [recovery_time]");
goto end;
}
}
cJSON *supported_features = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "supportedFeatures");
supported_features = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "supportedFeatures");
if (supported_features) {
if (!cJSON_IsString(supported_features)) {
if (!cJSON_IsString(supported_features) && !cJSON_IsNull(supported_features)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [supported_features]");
goto end;
}
}
cJSON *selected_smf_id = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "selectedSmfId");
selected_smf_id = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "selectedSmfId");
if (selected_smf_id) {
if (!cJSON_IsString(selected_smf_id)) {
if (!cJSON_IsString(selected_smf_id) && !cJSON_IsNull(selected_smf_id)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [selected_smf_id]");
goto end;
}
}
cJSON *selected_old_smf_id = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "selectedOldSmfId");
selected_old_smf_id = cJSON_GetObjectItemCaseSensitive(sm_context_created_dataJSON, "selectedOldSmfId");
if (selected_old_smf_id) {
if (!cJSON_IsString(selected_old_smf_id)) {
if (!cJSON_IsString(selected_old_smf_id) && !cJSON_IsNull(selected_old_smf_id)) {
ogs_error("OpenAPI_sm_context_created_data_parseFromJSON() failed [selected_old_smf_id]");
goto end;
}
}
sm_context_created_data_local_var = OpenAPI_sm_context_created_data_create (
h_smf_uri ? ogs_strdup(h_smf_uri->valuestring) : NULL,
smf_uri ? ogs_strdup(smf_uri->valuestring) : NULL,
h_smf_uri && !cJSON_IsNull(h_smf_uri) ? ogs_strdup(h_smf_uri->valuestring) : NULL,
smf_uri && !cJSON_IsNull(smf_uri) ? ogs_strdup(smf_uri->valuestring) : NULL,
pdu_session_id ? true : false,
pdu_session_id ? pdu_session_id->valuedouble : 0,
s_nssai ? s_nssai_local_nonprim : NULL,
@ -384,16 +414,31 @@ OpenAPI_sm_context_created_data_t *OpenAPI_sm_context_created_data_parseFromJSON
n2_sm_info_type ? n2_sm_info_typeVariable : 0,
allocated_ebi_list ? allocated_ebi_listList : NULL,
ho_state ? ho_stateVariable : 0,
gpsi ? ogs_strdup(gpsi->valuestring) : NULL,
smf_service_instance_id ? ogs_strdup(smf_service_instance_id->valuestring) : NULL,
recovery_time ? ogs_strdup(recovery_time->valuestring) : NULL,
supported_features ? ogs_strdup(supported_features->valuestring) : NULL,
selected_smf_id ? ogs_strdup(selected_smf_id->valuestring) : NULL,
selected_old_smf_id ? ogs_strdup(selected_old_smf_id->valuestring) : NULL
gpsi && !cJSON_IsNull(gpsi) ? ogs_strdup(gpsi->valuestring) : NULL,
smf_service_instance_id && !cJSON_IsNull(smf_service_instance_id) ? ogs_strdup(smf_service_instance_id->valuestring) : NULL,
recovery_time && !cJSON_IsNull(recovery_time) ? ogs_strdup(recovery_time->valuestring) : NULL,
supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL,
selected_smf_id && !cJSON_IsNull(selected_smf_id) ? ogs_strdup(selected_smf_id->valuestring) : NULL,
selected_old_smf_id && !cJSON_IsNull(selected_old_smf_id) ? ogs_strdup(selected_old_smf_id->valuestring) : NULL
);
return sm_context_created_data_local_var;
end:
if (s_nssai_local_nonprim) {
OpenAPI_snssai_free(s_nssai_local_nonprim);
s_nssai_local_nonprim = NULL;
}
if (n2_sm_info_local_nonprim) {
OpenAPI_ref_to_binary_data_free(n2_sm_info_local_nonprim);
n2_sm_info_local_nonprim = NULL;
}
if (allocated_ebi_listList) {
OpenAPI_list_for_each(allocated_ebi_listList, node) {
OpenAPI_ebi_arp_mapping_free(node->data);
}
OpenAPI_list_free(allocated_ebi_listList);
allocated_ebi_listList = NULL;
}
return NULL;
}