forked from acouzens/open5gs
[SBI] Conforms standard in Subscription API(#2152)
POST requests to {apiRoot}/nnrf-nfm/v1/subscriptions return a HTTP Location header in 201 respose in the form {apiRoot}/nnrf-nfm/v1/subscriptions/{subscriptionID}
This commit is contained in:
parent
ad9e5b28cf
commit
dd2c85b1b0
|
@ -535,12 +535,44 @@ void ogs_nnrf_nfm_handle_nf_status_subscribe(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SubscriptionData->subscription_id) {
|
if (recvmsg->http.location) {
|
||||||
ogs_error("No SubscriptionId");
|
int rv;
|
||||||
|
ogs_sbi_message_t message;
|
||||||
|
ogs_sbi_header_t header;
|
||||||
|
|
||||||
|
memset(&header, 0, sizeof(header));
|
||||||
|
header.uri = recvmsg->http.location;
|
||||||
|
|
||||||
|
rv = ogs_sbi_parse_header(&message, &header);
|
||||||
|
if (rv != OGS_OK) {
|
||||||
|
ogs_error("Cannot parse http.location [%s]",
|
||||||
|
recvmsg->http.location);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!message.h.resource.component[1]) {
|
||||||
|
ogs_error("No Subscription ID [%s]", recvmsg->http.location);
|
||||||
|
ogs_sbi_header_free(&header);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ogs_sbi_subscription_data_set_id(
|
||||||
|
subscription_data, message.h.resource.component[1]);
|
||||||
|
|
||||||
|
ogs_sbi_header_free(&header);
|
||||||
|
|
||||||
|
} else if (SubscriptionData->subscription_id) {
|
||||||
|
/*
|
||||||
|
* For compatibility with v2.5.x and lower versions
|
||||||
|
*
|
||||||
|
* Deprecated : It will be removed soon.
|
||||||
|
*/
|
||||||
|
ogs_sbi_subscription_data_set_id(
|
||||||
|
subscription_data, SubscriptionData->subscription_id);
|
||||||
|
} else {
|
||||||
|
ogs_error("No Subscription ID");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ogs_sbi_subscription_data_set_id(
|
|
||||||
subscription_data, SubscriptionData->subscription_id);
|
|
||||||
|
|
||||||
/* SBI Features */
|
/* SBI Features */
|
||||||
if (SubscriptionData->nrf_supported_features) {
|
if (SubscriptionData->nrf_supported_features) {
|
||||||
|
|
|
@ -188,6 +188,9 @@ bool nrf_nnrf_handle_nf_status_subscribe(
|
||||||
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
|
OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
|
||||||
ogs_sockaddr_t *addr = NULL;
|
ogs_sockaddr_t *addr = NULL;
|
||||||
|
|
||||||
|
ogs_sbi_server_t *server = NULL;
|
||||||
|
ogs_sbi_header_t header;
|
||||||
|
|
||||||
ogs_uuid_t uuid;
|
ogs_uuid_t uuid;
|
||||||
char id[OGS_UUID_FORMATTED_LENGTH + 1];
|
char id[OGS_UUID_FORMATTED_LENGTH + 1];
|
||||||
|
|
||||||
|
@ -321,13 +324,28 @@ bool nrf_nnrf_handle_nf_status_subscribe(
|
||||||
SubscriptionData->validity_time,
|
SubscriptionData->validity_time,
|
||||||
subscription_data->time.validity_duration);
|
subscription_data->time.validity_duration);
|
||||||
|
|
||||||
recvmsg->http.location = recvmsg->h.uri;
|
/* Location */
|
||||||
|
server = ogs_sbi_server_from_stream(stream);
|
||||||
|
ogs_assert(server);
|
||||||
|
|
||||||
|
memset(&header, 0, sizeof(header));
|
||||||
|
header.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM;
|
||||||
|
header.api.version = (char *)OGS_SBI_API_V1;
|
||||||
|
header.resource.component[0] =
|
||||||
|
(char *)OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS;
|
||||||
|
header.resource.component[1] = subscription_data->id;
|
||||||
|
|
||||||
|
recvmsg->http.location = ogs_sbi_server_uri(server, &header);
|
||||||
|
|
||||||
status = OGS_SBI_HTTP_STATUS_CREATED;
|
status = OGS_SBI_HTTP_STATUS_CREATED;
|
||||||
|
|
||||||
response = ogs_sbi_build_response(recvmsg, status);
|
response = ogs_sbi_build_response(recvmsg, status);
|
||||||
ogs_assert(response);
|
ogs_assert(response);
|
||||||
ogs_assert(true == ogs_sbi_server_send_response(stream, response));
|
ogs_assert(true == ogs_sbi_server_send_response(stream, response));
|
||||||
|
|
||||||
|
if (recvmsg->http.location)
|
||||||
|
ogs_free(recvmsg->http.location);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue