Skip to content

Commit c0136f8

Browse files
stojkovicvdavidjwbbc
authored andcommitted
Removed unnecessary session lookups, added OPTIONS request, fixed update function, resolved indents
1 parent 9983469 commit c0136f8

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/5gmsaf/metrics-reporting-configuration.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,16 @@ program. If this file is missing then the license can be retrieved from
125125
ogs_error("Null pointers passed");
126126
return -1;
127127
}
128+
if (existing_metrics_config->config->metrics_reporting_configuration_id) {
129+
if (updated_config->metrics_reporting_configuration_id) {
130+
ogs_free(updated_config->metrics_reporting_configuration_id);
131+
}
132+
updated_config->metrics_reporting_configuration_id = msaf_strdup(existing_metrics_config->config->metrics_reporting_configuration_id);
133+
}
128134

129135
msaf_api_metrics_reporting_configuration_free(existing_metrics_config->config);
130-
131136
existing_metrics_config->config = updated_config;
137+
132138
if (existing_metrics_config->etag) {
133139
ogs_free(existing_metrics_config->etag);
134140
}

src/5gmsaf/msaf-m1-sm.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,6 @@ void msaf_m1_state_functional(ogs_fsm_t *s, msaf_event_t *e)
943943

944944
ogs_debug("GET metrics-reporting-configuration");
945945

946-
msaf_provisioning_session_t *msaf_provisioning_session;
947-
msaf_provisioning_session = msaf_provisioning_session_find_by_provisioningSessionId(message->h.resource.component[1]);
948-
949946
msaf_metrics_reporting_configuration_t *metricsReportingConfiguration;
950947
metricsReportingConfiguration = msaf_metrics_reporting_configuration_retrieve(msaf_provisioning_session, message->h.resource.component[3]);
951948

@@ -958,7 +955,6 @@ void msaf_m1_state_functional(ogs_fsm_t *s, msaf_event_t *e)
958955
else {
959956
cJSON *mrc_json_data = msaf_api_metrics_reporting_configuration_convertResponseToJSON(metricsReportingConfiguration->config);
960957
if (mrc_json_data) {
961-
962958
char *metrics_response_body = cJSON_Print(mrc_json_data);
963959
if(metrics_response_body) {
964960
ogs_debug("Retrieved Metrics Reporting Configuration:\n%s", metrics_response_body);
@@ -971,7 +967,6 @@ void msaf_m1_state_functional(ogs_fsm_t *s, msaf_event_t *e)
971967
nf_server_populate_response(response, strlen(metrics_response_body), metrics_response_body, 200);
972968
ogs_assert(true == ogs_sbi_server_send_response(stream, response));
973969
response= NULL;
974-
cJSON_free(metrics_response_body);
975970
cJSON_Delete(mrc_json_data);
976971
}
977972
else {
@@ -1613,9 +1608,6 @@ void msaf_m1_state_functional(ogs_fsm_t *s, msaf_event_t *e)
16131608
} else if(api == m1_metricsreportingprovisioning_api) {
16141609
if (message->h.resource.component[3] && !message->h.resource.component[4]) {
16151610

1616-
msaf_provisioning_session_t *provisioning_session = NULL;
1617-
provisioning_session = msaf_provisioning_session_find_by_provisioningSessionId(message->h.resource.component[1]);
1618-
16191611
if (msaf_delete_metrics_configuration(provisioning_session, message->h.resource.component[3]) == 0) {
16201612
ogs_sbi_response_t *response;
16211613
response = nf_server_new_response(NULL, "application/json", 0, NULL, 0, NULL, m1_metricsreportingprovisioning_api, app_meta);
@@ -1777,6 +1769,12 @@ void msaf_m1_state_functional(ogs_fsm_t *s, msaf_event_t *e)
17771769
nf_server_populate_response(response, 0, NULL, 204);
17781770
ogs_assert(response);
17791771
ogs_assert(true == ogs_sbi_server_send_response(stream, response));
1772+
} else if (!strcmp(message->h.resource.component[2], "metrics-reporting-configurations")){
1773+
methods = ogs_msprintf("%s, %s, %s, %s, %s", OGS_SBI_HTTP_METHOD_POST, OGS_SBI_HTTP_METHOD_GET, OGS_SBI_HTTP_METHOD_PUT, OGS_SBI_HTTP_METHOD_DELETE, OGS_SBI_HTTP_METHOD_OPTIONS);
1774+
response = nf_server_new_response(request->h.uri, NULL, 0, NULL, 0, methods, m1_metricsreportingprovisioning_api, app_meta);
1775+
nf_server_populate_response(response, 0, NULL, 204);
1776+
ogs_assert(response);
1777+
ogs_assert(true == ogs_sbi_server_send_response(stream, response));
17801778
} else if (!strcmp(message->h.resource.component[2],"protocols")) {
17811779
methods = ogs_msprintf("%s, %s", OGS_SBI_HTTP_METHOD_GET, OGS_SBI_HTTP_METHOD_OPTIONS);
17821780
response = nf_server_new_response(request->h.uri, NULL, 0, NULL, 0, methods, m1_contentprotocolsdiscovery_api, app_meta);

0 commit comments

Comments
 (0)