mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-05 15:24:14 +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
|
|
@ -48,31 +48,69 @@ OpenAPI_sdm_subscription_t *OpenAPI_sdm_subscription_create(
|
|||
|
||||
void OpenAPI_sdm_subscription_free(OpenAPI_sdm_subscription_t *sdm_subscription)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == sdm_subscription) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(sdm_subscription->nf_instance_id);
|
||||
ogs_free(sdm_subscription->expires);
|
||||
ogs_free(sdm_subscription->callback_reference);
|
||||
ogs_free(sdm_subscription->amf_service_name);
|
||||
OpenAPI_list_for_each(sdm_subscription->monitored_resource_uris, node) {
|
||||
ogs_free(node->data);
|
||||
if (sdm_subscription->nf_instance_id) {
|
||||
ogs_free(sdm_subscription->nf_instance_id);
|
||||
sdm_subscription->nf_instance_id = NULL;
|
||||
}
|
||||
if (sdm_subscription->expires) {
|
||||
ogs_free(sdm_subscription->expires);
|
||||
sdm_subscription->expires = NULL;
|
||||
}
|
||||
if (sdm_subscription->callback_reference) {
|
||||
ogs_free(sdm_subscription->callback_reference);
|
||||
sdm_subscription->callback_reference = NULL;
|
||||
}
|
||||
if (sdm_subscription->amf_service_name) {
|
||||
ogs_free(sdm_subscription->amf_service_name);
|
||||
sdm_subscription->amf_service_name = NULL;
|
||||
}
|
||||
if (sdm_subscription->monitored_resource_uris) {
|
||||
OpenAPI_list_for_each(sdm_subscription->monitored_resource_uris, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(sdm_subscription->monitored_resource_uris);
|
||||
sdm_subscription->monitored_resource_uris = NULL;
|
||||
}
|
||||
if (sdm_subscription->single_nssai) {
|
||||
OpenAPI_snssai_free(sdm_subscription->single_nssai);
|
||||
sdm_subscription->single_nssai = NULL;
|
||||
}
|
||||
if (sdm_subscription->dnn) {
|
||||
ogs_free(sdm_subscription->dnn);
|
||||
sdm_subscription->dnn = NULL;
|
||||
}
|
||||
if (sdm_subscription->subscription_id) {
|
||||
ogs_free(sdm_subscription->subscription_id);
|
||||
sdm_subscription->subscription_id = NULL;
|
||||
}
|
||||
if (sdm_subscription->plmn_id) {
|
||||
OpenAPI_plmn_id_free(sdm_subscription->plmn_id);
|
||||
sdm_subscription->plmn_id = NULL;
|
||||
}
|
||||
if (sdm_subscription->report) {
|
||||
OpenAPI_subscription_data_sets_free(sdm_subscription->report);
|
||||
sdm_subscription->report = NULL;
|
||||
}
|
||||
if (sdm_subscription->supported_features) {
|
||||
ogs_free(sdm_subscription->supported_features);
|
||||
sdm_subscription->supported_features = NULL;
|
||||
}
|
||||
if (sdm_subscription->context_info) {
|
||||
OpenAPI_context_info_free(sdm_subscription->context_info);
|
||||
sdm_subscription->context_info = NULL;
|
||||
}
|
||||
OpenAPI_list_free(sdm_subscription->monitored_resource_uris);
|
||||
OpenAPI_snssai_free(sdm_subscription->single_nssai);
|
||||
ogs_free(sdm_subscription->dnn);
|
||||
ogs_free(sdm_subscription->subscription_id);
|
||||
OpenAPI_plmn_id_free(sdm_subscription->plmn_id);
|
||||
OpenAPI_subscription_data_sets_free(sdm_subscription->report);
|
||||
ogs_free(sdm_subscription->supported_features);
|
||||
OpenAPI_context_info_free(sdm_subscription->context_info);
|
||||
ogs_free(sdm_subscription);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_sdm_subscription_convertToJSON(OpenAPI_sdm_subscription_t *sdm_subscription)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (sdm_subscription == NULL) {
|
||||
ogs_error("OpenAPI_sdm_subscription_convertToJSON() failed [SdmSubscription]");
|
||||
|
|
@ -80,6 +118,10 @@ cJSON *OpenAPI_sdm_subscription_convertToJSON(OpenAPI_sdm_subscription_t *sdm_su
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (!sdm_subscription->nf_instance_id) {
|
||||
ogs_error("OpenAPI_sdm_subscription_convertToJSON() failed [nf_instance_id]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "nfInstanceId", sdm_subscription->nf_instance_id) == NULL) {
|
||||
ogs_error("OpenAPI_sdm_subscription_convertToJSON() failed [nf_instance_id]");
|
||||
goto end;
|
||||
|
|
@ -99,6 +141,10 @@ cJSON *OpenAPI_sdm_subscription_convertToJSON(OpenAPI_sdm_subscription_t *sdm_su
|
|||
}
|
||||
}
|
||||
|
||||
if (!sdm_subscription->callback_reference) {
|
||||
ogs_error("OpenAPI_sdm_subscription_convertToJSON() failed [callback_reference]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "callbackReference", sdm_subscription->callback_reference) == NULL) {
|
||||
ogs_error("OpenAPI_sdm_subscription_convertToJSON() failed [callback_reference]");
|
||||
goto end;
|
||||
|
|
@ -111,19 +157,21 @@ cJSON *OpenAPI_sdm_subscription_convertToJSON(OpenAPI_sdm_subscription_t *sdm_su
|
|||
}
|
||||
}
|
||||
|
||||
cJSON *monitored_resource_uris = cJSON_AddArrayToObject(item, "monitoredResourceUris");
|
||||
if (monitored_resource_uris == NULL) {
|
||||
if (!sdm_subscription->monitored_resource_uris) {
|
||||
ogs_error("OpenAPI_sdm_subscription_convertToJSON() failed [monitored_resource_uris]");
|
||||
return NULL;
|
||||
}
|
||||
cJSON *monitored_resource_urisList = cJSON_AddArrayToObject(item, "monitoredResourceUris");
|
||||
if (monitored_resource_urisList == NULL) {
|
||||
ogs_error("OpenAPI_sdm_subscription_convertToJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *monitored_resource_uris_node;
|
||||
OpenAPI_list_for_each(sdm_subscription->monitored_resource_uris, monitored_resource_uris_node) {
|
||||
if (cJSON_AddStringToObject(monitored_resource_uris, "", (char*)monitored_resource_uris_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_sdm_subscription_convertToJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
OpenAPI_list_for_each(sdm_subscription->monitored_resource_uris, node) {
|
||||
if (cJSON_AddStringToObject(monitored_resource_urisList, "", (char*)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_sdm_subscription_convertToJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sdm_subscription->single_nssai) {
|
||||
cJSON *single_nssai_local_JSON = OpenAPI_snssai_convertToJSON(sdm_subscription->single_nssai);
|
||||
|
|
@ -212,19 +260,37 @@ end:
|
|||
OpenAPI_sdm_subscription_t *OpenAPI_sdm_subscription_parseFromJSON(cJSON *sdm_subscriptionJSON)
|
||||
{
|
||||
OpenAPI_sdm_subscription_t *sdm_subscription_local_var = NULL;
|
||||
cJSON *nf_instance_id = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "nfInstanceId");
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *nf_instance_id = NULL;
|
||||
cJSON *implicit_unsubscribe = NULL;
|
||||
cJSON *expires = NULL;
|
||||
cJSON *callback_reference = NULL;
|
||||
cJSON *amf_service_name = NULL;
|
||||
cJSON *monitored_resource_uris = NULL;
|
||||
OpenAPI_list_t *monitored_resource_urisList = NULL;
|
||||
cJSON *single_nssai = NULL;
|
||||
OpenAPI_snssai_t *single_nssai_local_nonprim = NULL;
|
||||
cJSON *dnn = NULL;
|
||||
cJSON *subscription_id = NULL;
|
||||
cJSON *plmn_id = NULL;
|
||||
OpenAPI_plmn_id_t *plmn_id_local_nonprim = NULL;
|
||||
cJSON *immediate_report = NULL;
|
||||
cJSON *report = NULL;
|
||||
OpenAPI_subscription_data_sets_t *report_local_nonprim = NULL;
|
||||
cJSON *supported_features = NULL;
|
||||
cJSON *context_info = NULL;
|
||||
OpenAPI_context_info_t *context_info_local_nonprim = NULL;
|
||||
nf_instance_id = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "nfInstanceId");
|
||||
if (!nf_instance_id) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [nf_instance_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(nf_instance_id)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [nf_instance_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *implicit_unsubscribe = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "implicitUnsubscribe");
|
||||
|
||||
implicit_unsubscribe = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "implicitUnsubscribe");
|
||||
if (implicit_unsubscribe) {
|
||||
if (!cJSON_IsBool(implicit_unsubscribe)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [implicit_unsubscribe]");
|
||||
|
|
@ -232,91 +298,82 @@ OpenAPI_sdm_subscription_t *OpenAPI_sdm_subscription_parseFromJSON(cJSON *sdm_su
|
|||
}
|
||||
}
|
||||
|
||||
cJSON *expires = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "expires");
|
||||
|
||||
expires = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "expires");
|
||||
if (expires) {
|
||||
if (!cJSON_IsString(expires)) {
|
||||
if (!cJSON_IsString(expires) && !cJSON_IsNull(expires)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [expires]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *callback_reference = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "callbackReference");
|
||||
callback_reference = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "callbackReference");
|
||||
if (!callback_reference) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [callback_reference]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(callback_reference)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [callback_reference]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *amf_service_name = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "amfServiceName");
|
||||
|
||||
amf_service_name = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "amfServiceName");
|
||||
if (amf_service_name) {
|
||||
if (!cJSON_IsString(amf_service_name)) {
|
||||
if (!cJSON_IsString(amf_service_name) && !cJSON_IsNull(amf_service_name)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [amf_service_name]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *monitored_resource_uris = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "monitoredResourceUris");
|
||||
monitored_resource_uris = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "monitoredResourceUris");
|
||||
if (!monitored_resource_uris) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
cJSON *monitored_resource_uris_local = NULL;
|
||||
if (!cJSON_IsArray(monitored_resource_uris)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_list_t *monitored_resource_urisList;
|
||||
cJSON *monitored_resource_uris_local;
|
||||
if (!cJSON_IsArray(monitored_resource_uris)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
monitored_resource_urisList = OpenAPI_list_create();
|
||||
monitored_resource_urisList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(monitored_resource_uris_local, monitored_resource_uris) {
|
||||
if (!cJSON_IsString(monitored_resource_uris_local)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(monitored_resource_urisList, ogs_strdup(monitored_resource_uris_local->valuestring));
|
||||
}
|
||||
cJSON_ArrayForEach(monitored_resource_uris_local, monitored_resource_uris) {
|
||||
double *localDouble = NULL;
|
||||
int *localInt = NULL;
|
||||
if (!cJSON_IsString(monitored_resource_uris_local)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(monitored_resource_urisList, ogs_strdup(monitored_resource_uris_local->valuestring));
|
||||
}
|
||||
|
||||
cJSON *single_nssai = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "singleNssai");
|
||||
|
||||
OpenAPI_snssai_t *single_nssai_local_nonprim = NULL;
|
||||
single_nssai = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "singleNssai");
|
||||
if (single_nssai) {
|
||||
single_nssai_local_nonprim = OpenAPI_snssai_parseFromJSON(single_nssai);
|
||||
}
|
||||
|
||||
cJSON *dnn = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "dnn");
|
||||
|
||||
dnn = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "dnn");
|
||||
if (dnn) {
|
||||
if (!cJSON_IsString(dnn)) {
|
||||
if (!cJSON_IsString(dnn) && !cJSON_IsNull(dnn)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [dnn]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *subscription_id = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "subscriptionId");
|
||||
|
||||
subscription_id = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "subscriptionId");
|
||||
if (subscription_id) {
|
||||
if (!cJSON_IsString(subscription_id)) {
|
||||
if (!cJSON_IsString(subscription_id) && !cJSON_IsNull(subscription_id)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [subscription_id]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *plmn_id = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "plmnId");
|
||||
|
||||
OpenAPI_plmn_id_t *plmn_id_local_nonprim = NULL;
|
||||
plmn_id = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "plmnId");
|
||||
if (plmn_id) {
|
||||
plmn_id_local_nonprim = OpenAPI_plmn_id_parseFromJSON(plmn_id);
|
||||
}
|
||||
|
||||
cJSON *immediate_report = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "immediateReport");
|
||||
|
||||
immediate_report = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "immediateReport");
|
||||
if (immediate_report) {
|
||||
if (!cJSON_IsBool(immediate_report)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [immediate_report]");
|
||||
|
|
@ -324,25 +381,20 @@ OpenAPI_sdm_subscription_t *OpenAPI_sdm_subscription_parseFromJSON(cJSON *sdm_su
|
|||
}
|
||||
}
|
||||
|
||||
cJSON *report = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "report");
|
||||
|
||||
OpenAPI_subscription_data_sets_t *report_local_nonprim = NULL;
|
||||
report = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "report");
|
||||
if (report) {
|
||||
report_local_nonprim = OpenAPI_subscription_data_sets_parseFromJSON(report);
|
||||
}
|
||||
|
||||
cJSON *supported_features = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "supportedFeatures");
|
||||
|
||||
supported_features = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "supportedFeatures");
|
||||
if (supported_features) {
|
||||
if (!cJSON_IsString(supported_features)) {
|
||||
if (!cJSON_IsString(supported_features) && !cJSON_IsNull(supported_features)) {
|
||||
ogs_error("OpenAPI_sdm_subscription_parseFromJSON() failed [supported_features]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *context_info = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "contextInfo");
|
||||
|
||||
OpenAPI_context_info_t *context_info_local_nonprim = NULL;
|
||||
context_info = cJSON_GetObjectItemCaseSensitive(sdm_subscriptionJSON, "contextInfo");
|
||||
if (context_info) {
|
||||
context_info_local_nonprim = OpenAPI_context_info_parseFromJSON(context_info);
|
||||
}
|
||||
|
|
@ -351,23 +403,46 @@ OpenAPI_sdm_subscription_t *OpenAPI_sdm_subscription_parseFromJSON(cJSON *sdm_su
|
|||
ogs_strdup(nf_instance_id->valuestring),
|
||||
implicit_unsubscribe ? true : false,
|
||||
implicit_unsubscribe ? implicit_unsubscribe->valueint : 0,
|
||||
expires ? ogs_strdup(expires->valuestring) : NULL,
|
||||
expires && !cJSON_IsNull(expires) ? ogs_strdup(expires->valuestring) : NULL,
|
||||
ogs_strdup(callback_reference->valuestring),
|
||||
amf_service_name ? ogs_strdup(amf_service_name->valuestring) : NULL,
|
||||
amf_service_name && !cJSON_IsNull(amf_service_name) ? ogs_strdup(amf_service_name->valuestring) : NULL,
|
||||
monitored_resource_urisList,
|
||||
single_nssai ? single_nssai_local_nonprim : NULL,
|
||||
dnn ? ogs_strdup(dnn->valuestring) : NULL,
|
||||
subscription_id ? ogs_strdup(subscription_id->valuestring) : NULL,
|
||||
dnn && !cJSON_IsNull(dnn) ? ogs_strdup(dnn->valuestring) : NULL,
|
||||
subscription_id && !cJSON_IsNull(subscription_id) ? ogs_strdup(subscription_id->valuestring) : NULL,
|
||||
plmn_id ? plmn_id_local_nonprim : NULL,
|
||||
immediate_report ? true : false,
|
||||
immediate_report ? immediate_report->valueint : 0,
|
||||
report ? report_local_nonprim : NULL,
|
||||
supported_features ? ogs_strdup(supported_features->valuestring) : NULL,
|
||||
supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL,
|
||||
context_info ? context_info_local_nonprim : NULL
|
||||
);
|
||||
|
||||
return sdm_subscription_local_var;
|
||||
end:
|
||||
if (monitored_resource_urisList) {
|
||||
OpenAPI_list_for_each(monitored_resource_urisList, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(monitored_resource_urisList);
|
||||
monitored_resource_urisList = NULL;
|
||||
}
|
||||
if (single_nssai_local_nonprim) {
|
||||
OpenAPI_snssai_free(single_nssai_local_nonprim);
|
||||
single_nssai_local_nonprim = NULL;
|
||||
}
|
||||
if (plmn_id_local_nonprim) {
|
||||
OpenAPI_plmn_id_free(plmn_id_local_nonprim);
|
||||
plmn_id_local_nonprim = NULL;
|
||||
}
|
||||
if (report_local_nonprim) {
|
||||
OpenAPI_subscription_data_sets_free(report_local_nonprim);
|
||||
report_local_nonprim = NULL;
|
||||
}
|
||||
if (context_info_local_nonprim) {
|
||||
OpenAPI_context_info_free(context_info_local_nonprim);
|
||||
context_info_local_nonprim = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue