fix: NRF notification send all information (#737)

This commit is contained in:
Sukchan Lee 2020-12-28 23:36:02 -05:00
parent efd1780745
commit 4115799c2a
5 changed files with 39 additions and 30 deletions

View File

@ -516,6 +516,9 @@ void ogs_sbi_nf_instance_remove(ogs_sbi_nf_instance_t *nf_instance)
if (nf_instance->client)
ogs_sbi_client_remove(nf_instance->client);
if (nf_instance->nf_profile)
OpenAPI_nf_profile_free(nf_instance->nf_profile);
ogs_pool_free(&nf_instance_pool, nf_instance);
}

View File

@ -94,6 +94,8 @@ typedef struct ogs_sbi_nf_instance_s {
void *client; /* only used in CLIENT */
unsigned int reference_count; /* reference count for memory free */
OpenAPI_nf_profile_t *nf_profile; /* stored NF Profile */
} ogs_sbi_nf_instance_t;
#define OGS_SBI_NF_INSTANCE_GET(__aRRAY, __nFType) \

View File

@ -786,6 +786,7 @@ static int on_stream_close(nghttp2_session *session, int32_t stream_id,
session, NGHTTP2_FLAG_NONE, stream_id, error_code);
}
ogs_debug("STREAM closed [%d]", stream_id);
stream_remove(stream);
return 0;
}
@ -849,6 +850,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
ogs_assert(request->h.uri == NULL);
request->h.uri = ogs_sbi_parse_uri(valuestr, "?", &saveptr);
ogs_assert(request->h.uri);
ogs_debug("path: %s", request->h.uri);
memset(params, 0, sizeof(params));
@ -876,6 +878,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
ogs_assert(request->h.method == NULL);
request->h.method = ogs_strdup(valuestr);
ogs_debug("method: %s", request->h.method);
} else {
@ -909,7 +912,14 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
ogs_assert(data);
ogs_assert(len);
ogs_assert(request->http.content == NULL);
if (request->http.content) {
ogs_fatal("Content-Length [%d]", (int)request->http.content_length);
ogs_log_hexdump(OGS_LOG_FATAL,
(uint8_t *)request->http.content, request->http.content_length);
ogs_fatal("Data Size [%d]", (int)len);
ogs_log_hexdump(OGS_LOG_FATAL, data, len);
ogs_assert_if_reached();
}
request->http.content_length = len;
request->http.content = (char*)ogs_malloc(request->http.content_length + 1);
@ -917,6 +927,10 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
memcpy(request->http.content, data, len);
request->http.content[request->http.content_length] = '\0';
ogs_debug("RECEIVED");
ogs_debug("content-length: %d", (int)request->http.content_length);
ogs_debug("%s", request->http.content);
return 0;
}
@ -1030,6 +1044,7 @@ static int on_begin_headers(nghttp2_session *session,
stream = stream_add(sbi_sess, frame->hd.stream_id);
ogs_assert(stream);
ogs_debug("STREAM added [%d]", frame->hd.stream_id);
nghttp2_session_set_stream_user_data(session, frame->hd.stream_id, stream);
@ -1090,6 +1105,10 @@ static int on_send_data(nghttp2_session *session, nghttp2_frame *frame,
ogs_assert(framehd);
ogs_assert(length);
ogs_debug("SENDING...");
ogs_debug("content-length: %d", (int)response->http.content_length);
ogs_debug("%s", response->http.content);
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
ogs_assert(pkbuf);
ogs_pkbuf_put_data(pkbuf, framehd, 9);
@ -1204,6 +1223,8 @@ static void session_write_callback(short when, ogs_socket_t fd, void *data)
ogs_list_remove(&sbi_sess->write_queue, pkbuf);
ogs_send(fd, pkbuf->data, pkbuf->len, 0);
ogs_log_hexdump(OGS_LOG_DEBUG, pkbuf->data, pkbuf->len);
ogs_pkbuf_free(pkbuf);
}

View File

@ -31,7 +31,6 @@ ogs_sbi_request_t *nrf_nnrf_nfm_build_nf_status_notify(
ogs_sbi_server_t *server = NULL;
OpenAPI_notification_data_t *NotificationData = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
ogs_assert(client);
ogs_assert(subscription);
@ -62,10 +61,8 @@ ogs_sbi_request_t *nrf_nnrf_nfm_build_nf_status_notify(
ogs_assert(NotificationData->nf_instance_uri);
if (event != OpenAPI_notification_event_type_NF_DEREGISTERED) {
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
ogs_assert(NFProfile);
NotificationData->nf_profile = NFProfile;
ogs_assert(nf_instance->nf_profile);
NotificationData->nf_profile = nf_instance->nf_profile;
}
message.NotificationData = NotificationData;
@ -73,9 +70,6 @@ ogs_sbi_request_t *nrf_nnrf_nfm_build_nf_status_notify(
request = ogs_sbi_build_request(&message);
ogs_assert(request);
if (NotificationData->nf_profile)
ogs_sbi_nnrf_free_nf_profile(NotificationData->nf_profile);
ogs_free(NotificationData->nf_instance_uri);
ogs_free(NotificationData);

View File

@ -53,6 +53,10 @@ bool nrf_nnrf_handle_nf_register(ogs_sbi_nf_instance_t *nf_instance,
} else
ogs_assert_if_reached();
/* Store NFProfile */
nf_instance->nf_profile = OpenAPI_nf_profile_copy(
nf_instance->nf_profile, NFProfile);
response = ogs_sbi_build_response(recvmsg, status);
ogs_assert(response);
ogs_sbi_server_send_response(stream, response);
@ -300,8 +304,6 @@ bool nrf_nnrf_handle_nf_profile_retrieval(
ogs_sbi_response_t *response = NULL;
ogs_sbi_nf_instance_t *nf_instance = NULL;
OpenAPI_nf_profile_t *NFProfile = NULL;
ogs_assert(stream);
ogs_assert(recvmsg);
@ -315,18 +317,15 @@ bool nrf_nnrf_handle_nf_profile_retrieval(
return false;
}
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
ogs_assert(NFProfile);
memset(&sendmsg, 0, sizeof(sendmsg));
sendmsg.NFProfile = NFProfile;
ogs_assert(nf_instance->nf_profile);
sendmsg.NFProfile = nf_instance->nf_profile;
response = ogs_sbi_build_response(&sendmsg, OGS_SBI_HTTP_STATUS_OK);
ogs_assert(response);
ogs_sbi_server_send_response(stream, response);
ogs_sbi_nnrf_free_nf_profile(NFProfile);
return true;
}
@ -338,7 +337,6 @@ bool nrf_nnrf_handle_nf_discover(
ogs_sbi_nf_instance_t *nf_instance = NULL;
OpenAPI_search_result_t *SearchResult = NULL;
OpenAPI_lnode_t *node = NULL;
int i;
ogs_assert(stream);
@ -373,8 +371,6 @@ bool nrf_nnrf_handle_nf_discover(
i = 0;
ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) {
OpenAPI_nf_profile_t *NFProfile = NULL;
if (nf_instance->nf_type != recvmsg->param.target_nf_type)
continue;
if (nf_instance->nf_type == recvmsg->param.requester_nf_type)
@ -389,10 +385,9 @@ bool nrf_nnrf_handle_nf_discover(
OpenAPI_nf_status_ToString(nf_instance->nf_status),
nf_instance->num_of_ipv4, nf_instance->num_of_ipv6);
NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance);
ogs_assert(NFProfile);
OpenAPI_list_add(SearchResult->nf_instances, NFProfile);
ogs_assert(nf_instance->nf_profile);
OpenAPI_list_add(SearchResult->nf_instances,
nf_instance->nf_profile);
i++;
}
@ -409,12 +404,6 @@ bool nrf_nnrf_handle_nf_discover(
ogs_assert(response);
ogs_sbi_server_send_response(stream, response);
OpenAPI_list_for_each(SearchResult->nf_instances, node) {
OpenAPI_nf_profile_t *NFProfile = NULL;
if (!node->data) continue;
NFProfile = node->data;
ogs_sbi_nnrf_free_nf_profile(NFProfile);
}
OpenAPI_list_free(SearchResult->nf_instances);
if (sendmsg.http.cache_control)