mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-02 05:10:10 +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
|
|
@ -52,20 +52,34 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_create(
|
|||
|
||||
void OpenAPI_charging_data_free(OpenAPI_charging_data_t *charging_data)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == charging_data) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(charging_data->chg_id);
|
||||
ogs_free(charging_data->sponsor_id);
|
||||
ogs_free(charging_data->app_svc_prov_id);
|
||||
ogs_free(charging_data->af_charg_id);
|
||||
if (charging_data->chg_id) {
|
||||
ogs_free(charging_data->chg_id);
|
||||
charging_data->chg_id = NULL;
|
||||
}
|
||||
if (charging_data->sponsor_id) {
|
||||
ogs_free(charging_data->sponsor_id);
|
||||
charging_data->sponsor_id = NULL;
|
||||
}
|
||||
if (charging_data->app_svc_prov_id) {
|
||||
ogs_free(charging_data->app_svc_prov_id);
|
||||
charging_data->app_svc_prov_id = NULL;
|
||||
}
|
||||
if (charging_data->af_charg_id) {
|
||||
ogs_free(charging_data->af_charg_id);
|
||||
charging_data->af_charg_id = NULL;
|
||||
}
|
||||
ogs_free(charging_data);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_charging_data_convertToJSON(OpenAPI_charging_data_t *charging_data)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (charging_data == NULL) {
|
||||
ogs_error("OpenAPI_charging_data_convertToJSON() failed [ChargingData]");
|
||||
|
|
@ -73,12 +87,16 @@ cJSON *OpenAPI_charging_data_convertToJSON(OpenAPI_charging_data_t *charging_dat
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (!charging_data->chg_id) {
|
||||
ogs_error("OpenAPI_charging_data_convertToJSON() failed [chg_id]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "chgId", charging_data->chg_id) == NULL) {
|
||||
ogs_error("OpenAPI_charging_data_convertToJSON() failed [chg_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (charging_data->metering_method) {
|
||||
if (charging_data->metering_method != OpenAPI_metering_method_NULL) {
|
||||
if (cJSON_AddStringToObject(item, "meteringMethod", OpenAPI_metering_method_ToString(charging_data->metering_method)) == NULL) {
|
||||
ogs_error("OpenAPI_charging_data_convertToJSON() failed [metering_method]");
|
||||
goto end;
|
||||
|
|
@ -113,7 +131,7 @@ cJSON *OpenAPI_charging_data_convertToJSON(OpenAPI_charging_data_t *charging_dat
|
|||
}
|
||||
}
|
||||
|
||||
if (charging_data->reporting_level) {
|
||||
if (charging_data->reporting_level != OpenAPI_reporting_level_NULL) {
|
||||
if (cJSON_AddStringToObject(item, "reportingLevel", OpenAPI_reporting_level_ToString(charging_data->reporting_level)) == NULL) {
|
||||
ogs_error("OpenAPI_charging_data_convertToJSON() failed [reporting_level]");
|
||||
goto end;
|
||||
|
|
@ -162,20 +180,32 @@ end:
|
|||
OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dataJSON)
|
||||
{
|
||||
OpenAPI_charging_data_t *charging_data_local_var = NULL;
|
||||
cJSON *chg_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "chgId");
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *chg_id = NULL;
|
||||
cJSON *metering_method = NULL;
|
||||
OpenAPI_metering_method_e metering_methodVariable = 0;
|
||||
cJSON *offline = NULL;
|
||||
cJSON *online = NULL;
|
||||
cJSON *sdf_handl = NULL;
|
||||
cJSON *rating_group = NULL;
|
||||
cJSON *reporting_level = NULL;
|
||||
OpenAPI_reporting_level_e reporting_levelVariable = 0;
|
||||
cJSON *service_id = NULL;
|
||||
cJSON *sponsor_id = NULL;
|
||||
cJSON *app_svc_prov_id = NULL;
|
||||
cJSON *af_charging_identifier = NULL;
|
||||
cJSON *af_charg_id = NULL;
|
||||
chg_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "chgId");
|
||||
if (!chg_id) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [chg_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(chg_id)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [chg_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *metering_method = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "meteringMethod");
|
||||
|
||||
OpenAPI_metering_method_e metering_methodVariable;
|
||||
metering_method = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "meteringMethod");
|
||||
if (metering_method) {
|
||||
if (!cJSON_IsString(metering_method)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [metering_method]");
|
||||
|
|
@ -184,8 +214,7 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dat
|
|||
metering_methodVariable = OpenAPI_metering_method_FromString(metering_method->valuestring);
|
||||
}
|
||||
|
||||
cJSON *offline = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "offline");
|
||||
|
||||
offline = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "offline");
|
||||
if (offline) {
|
||||
if (!cJSON_IsBool(offline)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [offline]");
|
||||
|
|
@ -193,8 +222,7 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dat
|
|||
}
|
||||
}
|
||||
|
||||
cJSON *online = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "online");
|
||||
|
||||
online = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "online");
|
||||
if (online) {
|
||||
if (!cJSON_IsBool(online)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [online]");
|
||||
|
|
@ -202,8 +230,7 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dat
|
|||
}
|
||||
}
|
||||
|
||||
cJSON *sdf_handl = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "sdfHandl");
|
||||
|
||||
sdf_handl = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "sdfHandl");
|
||||
if (sdf_handl) {
|
||||
if (!cJSON_IsBool(sdf_handl)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [sdf_handl]");
|
||||
|
|
@ -211,8 +238,7 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dat
|
|||
}
|
||||
}
|
||||
|
||||
cJSON *rating_group = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "ratingGroup");
|
||||
|
||||
rating_group = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "ratingGroup");
|
||||
if (rating_group) {
|
||||
if (!cJSON_IsNumber(rating_group)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [rating_group]");
|
||||
|
|
@ -220,9 +246,7 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dat
|
|||
}
|
||||
}
|
||||
|
||||
cJSON *reporting_level = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "reportingLevel");
|
||||
|
||||
OpenAPI_reporting_level_e reporting_levelVariable;
|
||||
reporting_level = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "reportingLevel");
|
||||
if (reporting_level) {
|
||||
if (!cJSON_IsString(reporting_level)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [reporting_level]");
|
||||
|
|
@ -231,8 +255,7 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dat
|
|||
reporting_levelVariable = OpenAPI_reporting_level_FromString(reporting_level->valuestring);
|
||||
}
|
||||
|
||||
cJSON *service_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "serviceId");
|
||||
|
||||
service_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "serviceId");
|
||||
if (service_id) {
|
||||
if (!cJSON_IsNumber(service_id)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [service_id]");
|
||||
|
|
@ -240,26 +263,23 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dat
|
|||
}
|
||||
}
|
||||
|
||||
cJSON *sponsor_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "sponsorId");
|
||||
|
||||
sponsor_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "sponsorId");
|
||||
if (sponsor_id) {
|
||||
if (!cJSON_IsString(sponsor_id)) {
|
||||
if (!cJSON_IsString(sponsor_id) && !cJSON_IsNull(sponsor_id)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [sponsor_id]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *app_svc_prov_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "appSvcProvId");
|
||||
|
||||
app_svc_prov_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "appSvcProvId");
|
||||
if (app_svc_prov_id) {
|
||||
if (!cJSON_IsString(app_svc_prov_id)) {
|
||||
if (!cJSON_IsString(app_svc_prov_id) && !cJSON_IsNull(app_svc_prov_id)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [app_svc_prov_id]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *af_charging_identifier = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "afChargingIdentifier");
|
||||
|
||||
af_charging_identifier = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "afChargingIdentifier");
|
||||
if (af_charging_identifier) {
|
||||
if (!cJSON_IsNumber(af_charging_identifier)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [af_charging_identifier]");
|
||||
|
|
@ -267,10 +287,9 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dat
|
|||
}
|
||||
}
|
||||
|
||||
cJSON *af_charg_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "afChargId");
|
||||
|
||||
af_charg_id = cJSON_GetObjectItemCaseSensitive(charging_dataJSON, "afChargId");
|
||||
if (af_charg_id) {
|
||||
if (!cJSON_IsString(af_charg_id)) {
|
||||
if (!cJSON_IsString(af_charg_id) && !cJSON_IsNull(af_charg_id)) {
|
||||
ogs_error("OpenAPI_charging_data_parseFromJSON() failed [af_charg_id]");
|
||||
goto end;
|
||||
}
|
||||
|
|
@ -290,11 +309,11 @@ OpenAPI_charging_data_t *OpenAPI_charging_data_parseFromJSON(cJSON *charging_dat
|
|||
reporting_level ? reporting_levelVariable : 0,
|
||||
service_id ? true : false,
|
||||
service_id ? service_id->valuedouble : 0,
|
||||
sponsor_id ? ogs_strdup(sponsor_id->valuestring) : NULL,
|
||||
app_svc_prov_id ? ogs_strdup(app_svc_prov_id->valuestring) : NULL,
|
||||
sponsor_id && !cJSON_IsNull(sponsor_id) ? ogs_strdup(sponsor_id->valuestring) : NULL,
|
||||
app_svc_prov_id && !cJSON_IsNull(app_svc_prov_id) ? ogs_strdup(app_svc_prov_id->valuestring) : NULL,
|
||||
af_charging_identifier ? true : false,
|
||||
af_charging_identifier ? af_charging_identifier->valuedouble : 0,
|
||||
af_charg_id ? ogs_strdup(af_charg_id->valuestring) : NULL
|
||||
af_charg_id && !cJSON_IsNull(af_charg_id) ? ogs_strdup(af_charg_id->valuestring) : NULL
|
||||
);
|
||||
|
||||
return charging_data_local_var;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue