|
|
@ -66,8 +66,12 @@ void ric_client::stop()
|
|
|
|
void ric_client::run_thread()
|
|
|
|
void ric_client::run_thread()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (running) {
|
|
|
|
while (running) {
|
|
|
|
|
|
|
|
if (!e2ap_.has_setup_response()) {
|
|
|
|
send_e2_setup_request();
|
|
|
|
send_e2_setup_request();
|
|
|
|
printf("e2 setup request sent\n");
|
|
|
|
printf("e2 setup request sent\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
task_sched.run_next_task();
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -103,14 +107,97 @@ bool ric_client::send_e2_setup_request()
|
|
|
|
|
|
|
|
|
|
|
|
asn1::bit_ref bref(buf->msg, buf->get_tailroom());
|
|
|
|
asn1::bit_ref bref(buf->msg, buf->get_tailroom());
|
|
|
|
if (setup_req_pdu.pack(bref) != asn1::SRSASN_SUCCESS) {
|
|
|
|
if (setup_req_pdu.pack(bref) != asn1::SRSASN_SUCCESS) {
|
|
|
|
printf("Failed to pack TX E2 PDU\n");
|
|
|
|
logger.error("Failed to pack TX E2 PDU");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buf->N_bytes = bref.distance_bytes();
|
|
|
|
buf->N_bytes = bref.distance_bytes();
|
|
|
|
printf("try to send %d bytes to addr %s \n", buf->N_bytes, inet_ntoa(ric_addr.sin_addr));
|
|
|
|
printf("try to send %d bytes to addr %s \n", buf->N_bytes, inet_ntoa(ric_addr.sin_addr));
|
|
|
|
if (!send_sctp(buf)) {
|
|
|
|
if (!send_sctp(buf)) {
|
|
|
|
printf("failed to send e2 setup request\n");
|
|
|
|
logger.error("failed to send e2 setup request");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ric_client::handle_e2_rx_msg(srsran::unique_byte_buffer_t pdu,
|
|
|
|
|
|
|
|
const sockaddr_in& from,
|
|
|
|
|
|
|
|
const sctp_sndrcvinfo& sri,
|
|
|
|
|
|
|
|
int flags)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("RIC_CLIENT: Received %d bytes from %s\n", pdu->N_bytes, inet_ntoa(from.sin_addr));
|
|
|
|
|
|
|
|
e2_ap_pdu_c pdu_c;
|
|
|
|
|
|
|
|
asn1::cbit_ref bref(pdu->msg, pdu->N_bytes);
|
|
|
|
|
|
|
|
if (pdu_c.unpack(bref) != asn1::SRSASN_SUCCESS) {
|
|
|
|
|
|
|
|
logger.error("Failed to unpack RX E2 PDU");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pdu_c.type().value == e2_ap_pdu_c::types_opts::init_msg) {
|
|
|
|
|
|
|
|
logger.info("Received E2AP Init Message");
|
|
|
|
|
|
|
|
handle_e2_init_msg(pdu_c.init_msg());
|
|
|
|
|
|
|
|
} else if (pdu_c.type().value == e2_ap_pdu_c::types_opts::successful_outcome) {
|
|
|
|
|
|
|
|
logger.info("Received E2AP Successful Outcome");
|
|
|
|
|
|
|
|
// handle_e2_successful_outcome(pdu_c.successful_outcome());
|
|
|
|
|
|
|
|
} else if (pdu_c.type().value == e2_ap_pdu_c::types_opts::unsuccessful_outcome) {
|
|
|
|
|
|
|
|
logger.info("Received E2AP Unsuccessful Outcome ");
|
|
|
|
|
|
|
|
// handle_e2_unsuccessful_outcome(pdu_c.unsuccessful_outcome());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
logger.warning("Received E2AP Unknown Message ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ric_client::handle_e2_init_msg(asn1::e2ap::init_msg_s& init_msg)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using namespace asn1::e2ap;
|
|
|
|
|
|
|
|
// TODO check for different type of RIC generated init messages
|
|
|
|
|
|
|
|
// eg. RIC subscription request, RIC Reset request, RIC control request, RIC subscription delete request
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ric_client::handle_e2_successful_outcome(asn1::e2ap::successful_outcome_s& successful_outcome)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using namespace asn1::e2ap;
|
|
|
|
|
|
|
|
if (successful_outcome.value.type() == e2_ap_elem_procs_o::successful_outcome_c::types_opts::e2setup_resp) {
|
|
|
|
|
|
|
|
logger.info("Received E2AP E2 Setup Successful Outcome");
|
|
|
|
|
|
|
|
handle_e2_setup_response(successful_outcome.value.e2setup_resp());
|
|
|
|
|
|
|
|
} else if (successful_outcome.value.type() ==
|
|
|
|
|
|
|
|
e2_ap_elem_procs_o::successful_outcome_c::types_opts::ricsubscription_resp) {
|
|
|
|
|
|
|
|
logger.info("Received E2AP RIC Subscription Response");
|
|
|
|
|
|
|
|
// handle_ric_subscription_response(successful_outcome.value.ric_subscription());
|
|
|
|
|
|
|
|
} else if (successful_outcome.value.type() == e2_ap_elem_procs_o::successful_outcome_c::types_opts::ri_cctrl_ack) {
|
|
|
|
|
|
|
|
logger.info("Received E2AP RIC Control acknowlegement \n");
|
|
|
|
|
|
|
|
// handle_ric_control_response(successful_outcome.value.ric_control());
|
|
|
|
|
|
|
|
} else if (successful_outcome.value.type() ==
|
|
|
|
|
|
|
|
e2_ap_elem_procs_o::successful_outcome_c::types_opts::ricservice_upd_ack) {
|
|
|
|
|
|
|
|
logger.info("Received E2AP RIC Service Update acknowlegement \n");
|
|
|
|
|
|
|
|
// handle_ric_service_update_ack(successful_outcome.value.ric_service_update());
|
|
|
|
|
|
|
|
} else if (successful_outcome.value.type() ==
|
|
|
|
|
|
|
|
e2_ap_elem_procs_o::successful_outcome_c::types_opts::ricsubscription_delete_resp) {
|
|
|
|
|
|
|
|
logger.info("Received E2AP RIC Subscription Delete Response \n");
|
|
|
|
|
|
|
|
// handle_ric_subscription_delete_response(successful_outcome.value.ric_subscription_delete());
|
|
|
|
|
|
|
|
} else if (successful_outcome.value.type() == e2_ap_elem_procs_o::successful_outcome_c::types_opts::e2_removal_resp) {
|
|
|
|
|
|
|
|
logger.info("Received E2AP RIC Service Status Successful Outcome \n");
|
|
|
|
|
|
|
|
// handle_e2_removal_response(successful_outcome.value.e2_removal());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
logger.info("Received E2AP Unknown Successful Outcome \n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ric_client::handle_e2_setup_response(e2setup_resp_s setup_response)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Received E2AP E2 Setup Response \n");
|
|
|
|
|
|
|
|
if (e2ap_.process_setup_response(setup_response)) {
|
|
|
|
|
|
|
|
logger.error("Failed to process E2 Setup Response");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ric_client::handle_e2_unsuccessful_outcome(asn1::e2ap::unsuccessful_outcome_s& unsuccessful_outcome)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using namespace asn1::e2ap;
|
|
|
|
|
|
|
|
// TODO check for different type of RIC generated unsuccessful outcomes
|
|
|
|
|
|
|
|
// eg. RIC subscription failure, RIC Reset failure, RIC control failure, RIC subscription delete failure
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|