diff --git a/srsenb/hdr/stack/ngap/ngap.h b/srsenb/hdr/stack/ngap/ngap.h index 9ee160629..8556be68f 100644 --- a/srsenb/hdr/stack/ngap/ngap.h +++ b/srsenb/hdr/stack/ngap/ngap.h @@ -12,6 +12,7 @@ #ifndef SRSENB_NGAP_H #define SRSENB_NGAP_H +#include "ngap_metrics.h" #include "srsenb/hdr/common/common_enb.h" #include "srsran/adt/circular_map.h" #include "srsran/adt/optional.h" @@ -66,6 +67,7 @@ public: // Stack interface bool handle_amf_rx_msg(srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags); + void get_metrics(ngap_metrics_t& m); private: static const int AMF_PORT = 38412; diff --git a/srsenb/hdr/stack/ngap/ngap_metrics.h b/srsenb/hdr/stack/ngap/ngap_metrics.h new file mode 100644 index 000000000..fb3dc843a --- /dev/null +++ b/srsenb/hdr/stack/ngap/ngap_metrics.h @@ -0,0 +1,30 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSENB_NGAP_METRICS_H +#define SRSENB_NGAP_METRICS_H + +namespace srsenb { + +typedef enum { + ngap_attaching = 0, // Attempting to create NG connection + ngap_connected, // NG connected + ngap_error // Failure +} ngap_status_t; + +struct ngap_metrics_t { + ngap_status_t status; +}; + +} // namespace srsenb + +#endif // SRSENB_NGAP_METRICS_H diff --git a/srsenb/src/stack/ngap/ngap.cc b/srsenb/src/stack/ngap/ngap.cc index 8cbca6fee..7aa2390a8 100644 --- a/srsenb/src/stack/ngap/ngap.cc +++ b/srsenb/src/stack/ngap/ngap.cc @@ -143,6 +143,19 @@ void ngap::stop() amf_socket.close(); } +void ngap::get_metrics(ngap_metrics_t& m) +{ + if (!running) { + m.status = ngap_error; + return; + } + if (amf_connected) { + m.status = ngap_connected; + } else { + m.status = ngap_attaching; + } +} + bool ngap::is_amf_connected() { return amf_connected;