gnb,ngap: added logging for Rx NGAP messages.

master
Pedro Alvarez 3 years ago
parent 5759d396d4
commit 3e61448a41

@ -78,6 +78,10 @@ public:
// PCAP // PCAP
void start_pcap(srsran::ngap_pcap* pcap_); void start_pcap(srsran::ngap_pcap* pcap_);
// Logging
typedef enum { Rx = 0, Tx } direction_t;
void log_ngap_message(const asn1::ngap_nr::ngap_pdu_c& msg, const direction_t dir, srsran::const_byte_span pdu);
private: private:
static const int AMF_PORT = 38412; static const int AMF_PORT = 38412;
static const int ADDR_FAMILY = AF_INET; static const int ADDR_FAMILY = AF_INET;

@ -376,6 +376,7 @@ bool ngap::handle_ngap_rx_pdu(srsran::byte_buffer_t* pdu)
pcap->write_ngap(pdu->msg, pdu->N_bytes); pcap->write_ngap(pdu->msg, pdu->N_bytes);
} }
// Unpack
ngap_pdu_c rx_pdu; ngap_pdu_c rx_pdu;
asn1::cbit_ref bref(pdu->msg, pdu->N_bytes); asn1::cbit_ref bref(pdu->msg, pdu->N_bytes);
@ -387,6 +388,10 @@ bool ngap::handle_ngap_rx_pdu(srsran::byte_buffer_t* pdu)
return false; return false;
} }
// Logging
log_ngap_message(rx_pdu, Rx, srsran::make_span(*pdu));
// Handle the NGAP message
switch (rx_pdu.type().value) { switch (rx_pdu.type().value) {
case ngap_pdu_c::types_opts::init_msg: case ngap_pdu_c::types_opts::init_msg:
return handle_initiating_message(rx_pdu.init_msg()); return handle_initiating_message(rx_pdu.init_msg());
@ -805,4 +810,30 @@ void ngap::start_pcap(srsran::ngap_pcap* pcap_)
{ {
pcap = pcap_; pcap = pcap_;
} }
void ngap::log_ngap_message(const ngap_pdu_c& msg, const direction_t dir, srsran::const_byte_span pdu)
{
std::string msg_type = {};
switch (msg.type().value) {
case ngap_pdu_c::types_opts::init_msg:
msg_type = msg.init_msg().value.type().to_string();
break;
case ngap_pdu_c::types_opts::successful_outcome:
msg_type = msg.successful_outcome().value.type().to_string();
break;
case ngap_pdu_c::types_opts::unsuccessful_outcome:
msg_type = msg.unsuccessful_outcome().value.type().to_string();
break;
default:
return;
}
if (logger.debug.enabled()) {
asn1::json_writer json_writer;
msg.to_json(json_writer);
logger.debug(pdu.data(), pdu.size(), "%s - %s (%d B)", (dir == Rx) ? "Rx" : "Tx", msg_type, pdu.size());
logger.debug("Content:%s", json_writer.to_string().c_str());
} else if (logger.info.enabled()) {
logger.info(pdu.data(), pdu.size(), "%s - %s (%d B)", (dir == Rx) ? "Rx" : "Tx", msg_type, pdu.size());
}
}
} // namespace srsenb } // namespace srsenb

Loading…
Cancel
Save