Commit 0c306b02 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Merge branch 'develop' into cu_du_testing

parents 6cb56ba6 ee09cb41
...@@ -131,13 +131,12 @@ check_supported_distribution() { ...@@ -131,13 +131,12 @@ check_supported_distribution() {
"ubuntu20.04") return 0 ;; "ubuntu20.04") return 0 ;;
"ubuntu22.04") return 0 ;; "ubuntu22.04") return 0 ;;
"rhel8") return 0 ;; "rhel8") return 0 ;;
"rhel8.2") return 0 ;; "rhel8.2") return 0 ;;
"rhel8.3") return 0 ;; "rhel8.3") return 0 ;;
"rhel8.4") return 0 ;; "rhel8.4") return 0 ;;
"rhel8.5") return 0 ;; "rhel8.5") return 0 ;;
"rhel8.6") return 0 ;; "rhel8.6") return 0 ;;
"rhel8.7") return 0 ;; "rhel8.7") return 0 ;;
#"centos7") return 0 ;;
esac esac
return 1 return 1
} }
...@@ -297,7 +296,10 @@ check_enable_epel_repos() { ...@@ -297,7 +296,10 @@ check_enable_epel_repos() {
echo "EPEL repos already present. Good." echo "EPEL repos already present. Good."
else else
echo "EPEL repos not present. Installing them." echo "EPEL repos not present. Installing them."
$SUDO $INSTALLER install $OPTION https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm wget --tries=4 --retry-connrefused --wait=8 \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$SUDO $INSTALLER install $OPTION epel-release-latest-7.noarch.rpm
rm -f epel-release-latest-7.noarch.rpm
fi fi
fi fi
} }
......
...@@ -51,6 +51,7 @@ RUN rm -f /etc/rhsm-host && \ ...@@ -51,6 +51,7 @@ RUN rm -f /etc/rhsm-host && \
boost-devel \ boost-devel \
openssl-devel \ openssl-devel \
openssl \ openssl \
wget \
libasan && \ libasan && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \
echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf
......
...@@ -19,15 +19,9 @@ ...@@ -19,15 +19,9 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file 5GMMCapability.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "5GMMCapability.hpp" #include "5GMMCapability.hpp"
#include "common_defs.h"
#include "logger.hpp" #include "logger.hpp"
using namespace nas; using namespace nas;
...@@ -35,8 +29,8 @@ using namespace nas; ...@@ -35,8 +29,8 @@ using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
_5GMMCapability::_5GMMCapability(const uint8_t iei, uint8_t value) { _5GMMCapability::_5GMMCapability(const uint8_t iei, uint8_t value) {
m_iei = iei; m_iei = iei;
m_value = value; octet3_ = value;
length = 3; length = k5gmmCapabilityMinimumLength;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -48,51 +42,62 @@ _5GMMCapability::~_5GMMCapability() {} ...@@ -48,51 +42,62 @@ _5GMMCapability::~_5GMMCapability() {}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void _5GMMCapability::setValue(uint8_t iei, uint8_t value) { void _5GMMCapability::setValue(uint8_t iei, uint8_t value) {
m_iei = iei; m_iei = iei;
m_value = value; octet3_ = value;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t _5GMMCapability::getValue() { uint8_t _5GMMCapability::getValue() {
return m_value; return octet3_;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int _5GMMCapability::encode2buffer(uint8_t* buf, int len) { int _5GMMCapability::encode2buffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("encoding _5GMMCapability iei(0x%x)", m_iei); Logger::nas_mm().debug("Encoding _5GMMCapability IEI (0x%x)", m_iei);
if (len < length) { if (len < length) {
Logger::nas_mm().error("len is less than %d", length); Logger::nas_mm().error("Len is less than %d", length);
return 0; return 0;
} }
int encoded_size = 0; int encoded_size = 0;
if (m_iei) { if (m_iei) {
*(buf + encoded_size) = m_iei; ENCODE_U8(buf + encoded_size, m_iei, encoded_size);
encoded_size++; ENCODE_U8(buf + encoded_size, length - 2, encoded_size);
*(buf + encoded_size) = length - 2;
encoded_size++;
*(buf + encoded_size) = m_value;
encoded_size++;
} else { } else {
*(buf + encoded_size) = length - 1; ENCODE_U8(buf + encoded_size, length - 1, encoded_size);
encoded_size++;
*(buf + encoded_size) = m_value;
encoded_size++;
} }
Logger::nas_mm().debug("encoded _5GMMCapability len(%d)", encoded_size);
ENCODE_U8(buf + encoded_size, octet3_, encoded_size);
// TODO: Encode spare for the rest
uint8_t spare = 0;
for (int i = 0; i < (length - encoded_size); i++) {
ENCODE_U8(buf + encoded_size, spare, encoded_size);
}
Logger::nas_mm().debug("Encoded _5GMMCapability len (%d)", encoded_size);
return encoded_size; return encoded_size;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int _5GMMCapability::decodefrombuffer(uint8_t* buf, int len, bool is_option) { int _5GMMCapability::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding _5GMMCapability iei(0x%x)", *buf); uint8_t decoded_size = 0;
int decoded_size = 0;
Logger::nas_mm().debug("Decoding _5GMMCapability IEI (0x%x)", *buf);
if (is_option) { if (is_option) {
decoded_size++; decoded_size++;
} }
length = *(buf + decoded_size);
decoded_size++; uint8_t ie_len = 0;
m_value = *(buf + decoded_size); DECODE_U8(buf + decoded_size, ie_len, decoded_size);
decoded_size++; length = ie_len + decoded_size;
Logger::nas_mm().debug("decoded _5GMMCapability value(0x%x)", m_value);
Logger::nas_mm().debug("decoded _5GMMCapability len(%d)", decoded_size); DECODE_U8(buf + decoded_size, octet3_, decoded_size);
// TODO: decode the rest as spare for now
uint8_t spare = 0;
for (int i = 0; i < (ie_len - 1); i++) {
ENCODE_U8(buf + decoded_size, spare, decoded_size);
}
Logger::nas_mm().debug("Decoded _5GMMCapability value(0x%x)", octet3_);
Logger::nas_mm().debug("Decoded _5GMMCapability len(%d)", decoded_size);
return decoded_size; return decoded_size;
} }
...@@ -19,18 +19,14 @@ ...@@ -19,18 +19,14 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file 5GMMCapability.hpp #ifndef _5GMM_CAPABILITY_H_
\brief #define _5GMM_CAPABILITY_H_
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef __5GMMCapability_H_
#define __5GMMCapability_H_
#include <stdint.h> #include <stdint.h>
constexpr uint8_t k5gmmCapabilityMinimumLength = 3;
constexpr uint8_t k5gmmCapabilityMaximumLength = 15;
namespace nas { namespace nas {
class _5GMMCapability { class _5GMMCapability {
...@@ -38,15 +34,17 @@ class _5GMMCapability { ...@@ -38,15 +34,17 @@ class _5GMMCapability {
_5GMMCapability(); _5GMMCapability();
_5GMMCapability(const uint8_t iei, uint8_t value); _5GMMCapability(const uint8_t iei, uint8_t value);
~_5GMMCapability(); ~_5GMMCapability();
void setValue(uint8_t iei, uint8_t value); void setValue(uint8_t iei, uint8_t value);
int encode2buffer(uint8_t* buf, int len);
int decodefrombuffer(uint8_t* buf, int len, bool is_option);
uint8_t getValue(); uint8_t getValue();
int encode2buffer(uint8_t* buf, int len);
int decodefrombuffer(uint8_t* buf, int len, bool is_option = true);
private: private:
uint8_t m_iei; uint8_t m_iei;
uint8_t m_value; uint8_t octet3_; // minimum length of 3 octets
int length; uint8_t length;
}; };
} // namespace nas } // namespace nas
......
...@@ -19,20 +19,12 @@ ...@@ -19,20 +19,12 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "UENetworkCapability.hpp" #include "UENetworkCapability.hpp"
#include <iostream> #include "common_defs.h"
#include "logger.hpp" #include "logger.hpp"
using namespace nas; using namespace nas;
using namespace std;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
UENetworkCapability::UENetworkCapability(uint8_t iei) { UENetworkCapability::UENetworkCapability(uint8_t iei) {
...@@ -59,7 +51,7 @@ UENetworkCapability::UENetworkCapability( ...@@ -59,7 +51,7 @@ UENetworkCapability::UENetworkCapability(
_iei = iei; _iei = iei;
_5g_EEASel = _5gg_EEASel; _5g_EEASel = _5gg_EEASel;
_5g_EIASel = _5gg_EIASel; _5g_EIASel = _5gg_EIASel;
length = 4; // Minimum length length = kUeNetworkCapabilityMinimumLength;
Logger::nas_mm().debug( Logger::nas_mm().debug(
"decoded UENetworkCapability EA(0x%d),IA(0x%d)", _5g_EEASel, _5g_EIASel); "decoded UENetworkCapability EA(0x%d),IA(0x%d)", _5g_EEASel, _5g_EIASel);
} }
...@@ -93,22 +85,21 @@ int UENetworkCapability::encode2buffer(uint8_t* buf, int len) { ...@@ -93,22 +85,21 @@ int UENetworkCapability::encode2buffer(uint8_t* buf, int len) {
} }
int encoded_size = 0; int encoded_size = 0;
if (_iei) { if (_iei) {
*(buf + encoded_size) = _iei; ENCODE_U8(buf + encoded_size, _iei, encoded_size);
encoded_size++; ENCODE_U8(buf + encoded_size, length - 2, encoded_size);
*(buf + encoded_size) = length - 2;
encoded_size++;
*(buf + encoded_size) = _5g_EEASel;
encoded_size++;
*(buf + encoded_size) = _5g_EIASel;
encoded_size++;
} else { } else {
*(buf + encoded_size) = length - 1; ENCODE_U8(buf + encoded_size, length - 1, encoded_size);
encoded_size++; }
*(buf + encoded_size) = _5g_EEASel;
encoded_size++; ENCODE_U8(buf + encoded_size, _5g_EEASel, encoded_size);
*(buf + encoded_size) = _5g_EIASel; ENCODE_U8(buf + encoded_size, _5g_EIASel, encoded_size);
encoded_size++;
// TODO: Encode the rest as spare for now
uint8_t spare = 0;
for (int i = 0; i < (length - encoded_size); i++) {
ENCODE_U8(buf + encoded_size, spare, encoded_size);
} }
Logger::nas_mm().debug("Encoded UENetworkCapability len (%d)", encoded_size); Logger::nas_mm().debug("Encoded UENetworkCapability len (%d)", encoded_size);
return encoded_size; return encoded_size;
} }
...@@ -118,25 +109,28 @@ int UENetworkCapability::decodefrombuffer( ...@@ -118,25 +109,28 @@ int UENetworkCapability::decodefrombuffer(
uint8_t* buf, int len, bool is_option) { uint8_t* buf, int len, bool is_option) {
Logger::nas_mm().debug("Decoding UENetworkCapability IEI"); Logger::nas_mm().debug("Decoding UENetworkCapability IEI");
int decoded_size = 0; int decoded_size = 0;
int ie_length = 0;
if (is_option) { if (is_option) {
_iei = *(buf + decoded_size); DECODE_U8(buf + decoded_size, _iei, decoded_size);
decoded_size++; }
uint8_t ie_len = 0;
DECODE_U8(buf + decoded_size, ie_len, decoded_size);
length = ie_len + decoded_size;
DECODE_U8(buf + decoded_size, _5g_EEASel, decoded_size);
DECODE_U8(buf + decoded_size, _5g_EIASel, decoded_size);
// TODO: decode the rest as spare for now
uint8_t spare = 0;
for (int i = 0; i < (ie_len - 2); i++) {
ENCODE_U8(buf + decoded_size, spare, decoded_size);
} }
length = *(buf + decoded_size);
decoded_size++;
ie_length = length + decoded_size;
_5g_EEASel = *(buf + decoded_size);
decoded_size++;
_5g_EIASel = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug( Logger::nas_mm().debug(
"Decoded UENetworkCapability EA (0x%d), IA (0x%d)", _5g_EEASel, "Decoded UENetworkCapability EA (0x%d), IA (0x%d)", _5g_EEASel,
_5g_EIASel); _5g_EIASel);
Logger::nas_mm().debug( Logger::nas_mm().debug(
"Decoded UENetworkCapability len 0x%d, actual length 0x%d", decoded_size, "Decoded UENetworkCapability IE len 0x%d, actual length 0x%d", ie_len,
ie_length); decoded_size);
return ie_length; return decoded_size;
} }
...@@ -19,18 +19,14 @@ ...@@ -19,18 +19,14 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _UENetworkCapability_H #ifndef _UENetworkCapability_H
#define _UENetworkCapability_H #define _UENetworkCapability_H
#include <stdint.h> #include <stdint.h>
constexpr uint8_t kUeNetworkCapabilityMinimumLength = 4;
constexpr uint8_t kUeNetworkCapabilityMaximumLength = 15;
namespace nas { namespace nas {
class UENetworkCapability { class UENetworkCapability {
...@@ -45,7 +41,7 @@ class UENetworkCapability { ...@@ -45,7 +41,7 @@ class UENetworkCapability {
uint8_t getEEASel(); uint8_t getEEASel();
uint8_t getEIASel(); uint8_t getEIASel();
int encode2buffer(uint8_t* buf, int len); int encode2buffer(uint8_t* buf, int len);
int decodefrombuffer(uint8_t* buf, int len, bool is_option); int decodefrombuffer(uint8_t* buf, int len, bool is_option = true);
private: private:
uint8_t _iei; uint8_t _iei;
......
...@@ -32,6 +32,9 @@ namespace ngap { ...@@ -32,6 +32,9 @@ namespace ngap {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
HandoverNotifyMsg::HandoverNotifyMsg() : NgapUEMessage() { HandoverNotifyMsg::HandoverNotifyMsg() : NgapUEMessage() {
handoverNotifyIEs = nullptr; handoverNotifyIEs = nullptr;
setMessageType(NgapMessageType::HANDOVER_NOTIFY);
initialize();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -36,7 +36,7 @@ InitialUEMessageMsg::InitialUEMessageMsg() : NgapMessage() { ...@@ -36,7 +36,7 @@ InitialUEMessageMsg::InitialUEMessageMsg() : NgapMessage() {
amfSetId = std::nullopt; amfSetId = std::nullopt;
allowedNssai = std::nullopt; allowedNssai = std::nullopt;
NgapMessage::setMessageType(NgapMessageType::NG_SETUP_RESPONSE); NgapMessage::setMessageType(NgapMessageType::INITIAL_UE_MESSAGE);
initialize(); initialize();
} }
......
...@@ -33,6 +33,7 @@ UEContextReleaseCompleteMsg::UEContextReleaseCompleteMsg() : NgapUEMessage() { ...@@ -33,6 +33,7 @@ UEContextReleaseCompleteMsg::UEContextReleaseCompleteMsg() : NgapUEMessage() {
ies = nullptr; ies = nullptr;
userLocationInformation = nullptr; userLocationInformation = nullptr;
pduSessionResourceListCxtRelCpl = std::nullopt; pduSessionResourceListCxtRelCpl = std::nullopt;
setMessageType(NgapMessageType::UE_CONTEXT_RELEASE_COMPLETE); setMessageType(NgapMessageType::UE_CONTEXT_RELEASE_COMPLETE);
initialize(); initialize();
} }
......
...@@ -35,6 +35,7 @@ UeRadioCapabilityInfoIndicationMsg::UeRadioCapabilityInfoIndicationMsg() ...@@ -35,6 +35,7 @@ UeRadioCapabilityInfoIndicationMsg::UeRadioCapabilityInfoIndicationMsg()
: NgapUEMessage() { : NgapUEMessage() {
ueRadioCapabilityInfoIndicationIEs = nullptr; ueRadioCapabilityInfoIndicationIEs = nullptr;
ueRadioCapabilityForPaging = std::nullopt; ueRadioCapabilityForPaging = std::nullopt;
setMessageType(NgapMessageType::UE_RADIO_CAPABILITY_INFO_INDICATION); setMessageType(NgapMessageType::UE_RADIO_CAPABILITY_INFO_INDICATION);
initialize(); initialize();
} }
......
...@@ -32,6 +32,7 @@ namespace ngap { ...@@ -32,6 +32,7 @@ namespace ngap {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
UplinkNASTransportMsg::UplinkNASTransportMsg() : NgapUEMessage() { UplinkNASTransportMsg::UplinkNASTransportMsg() : NgapUEMessage() {
uplinkNASTransportIEs = nullptr; uplinkNASTransportIEs = nullptr;
setMessageType(NgapMessageType::UPLINK_NAS_TRANSPORT); setMessageType(NgapMessageType::UPLINK_NAS_TRANSPORT);
initialize(); initialize();
} }
......
...@@ -31,6 +31,8 @@ namespace ngap { ...@@ -31,6 +31,8 @@ namespace ngap {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
UplinkNonUEAssociatedNRPPaTransportMsg::UplinkNonUEAssociatedNRPPaTransportMsg() UplinkNonUEAssociatedNRPPaTransportMsg::UplinkNonUEAssociatedNRPPaTransportMsg()
: NgapMessage() { : NgapMessage() {
uplinkNonUEAssociatedNRPPaTransportIEs = nullptr;
setMessageType(NgapMessageType::UPLINK_NON_UE_ASSOCIATED_NRPPA_TRANSPORT); setMessageType(NgapMessageType::UPLINK_NON_UE_ASSOCIATED_NRPPA_TRANSPORT);
initialize(); initialize();
} }
......
...@@ -32,6 +32,8 @@ namespace ngap { ...@@ -32,6 +32,8 @@ namespace ngap {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
UplinkUEAssociatedNRPPaTransportMsg::UplinkUEAssociatedNRPPaTransportMsg() UplinkUEAssociatedNRPPaTransportMsg::UplinkUEAssociatedNRPPaTransportMsg()
: NgapUEMessage() { : NgapUEMessage() {
uplinkUEAssociatedNRPPaTransportIEs = nullptr;
setMessageType(NgapMessageType::UPLINK_UE_ASSOCIATED_NRPPA_TRANSPORT); setMessageType(NgapMessageType::UPLINK_UE_ASSOCIATED_NRPPA_TRANSPORT);
initialize(); initialize();
} }
......
...@@ -20,43 +20,54 @@ ...@@ -20,43 +20,54 @@
*/ */
#include "fqdn.hpp" #include "fqdn.hpp"
#include "logger.hpp"
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <iostream> #include <iostream>
#include <chrono>
#include <thread>
#include "logger.hpp" #define MAX_NB_RESOLVE_TRIES 4
#define TIME_BETWEEN_TRIES 2
bool fqdn::resolve( bool fqdn::resolve(
const std::string& host_name, std::string& address, uint32_t& port, const std::string& host_name, std::string& address, uint32_t& port,
uint8_t& addr_type, const std::string& protocol) { uint8_t& addr_type, const std::string& protocol) {
try { int tries = 0;
Logger::amf_app().debug("Resolving DNS:- %s", host_name.c_str()); Logger::amf_app().debug("Resolving a DNS (name %s)", host_name.c_str());
boost::asio::io_context io_context = {}; while (tries < MAX_NB_RESOLVE_TRIES) {
try {
boost::asio::io_context io_context = {};
Logger::amf_app().debug("Resolving DNS Try #%u", tries);
boost::asio::ip::tcp::resolver resolver{io_context}; boost::asio::ip::tcp::resolver resolver{io_context};
boost::asio::ip::tcp::resolver::results_type endpoints = boost::asio::ip::tcp::resolver::results_type endpoints =
resolver.resolve(host_name, protocol); resolver.resolve(host_name, protocol);
addr_type = 0; // IPv4 by default addr_type = 0; // IPv4 by default
for (auto it = endpoints.cbegin(); it != endpoints.cend(); it++) { for (auto it = endpoints.cbegin(); it != endpoints.cend(); it++) {
// get the first Endpoint // get the first Endpoint
boost::asio::ip::tcp::endpoint endpoint = *it; boost::asio::ip::tcp::endpoint endpoint = *it;
address = endpoint.address().to_string(); address = endpoint.address().to_string();
port = endpoint.port(); port = endpoint.port();
Logger::amf_app().debug( Logger::amf_app().debug(
"Resolve a DNS (name %s, protocol %s): Ip Addr %s, port %u", "Resolved a DNS (name %s, protocol %s): Ip Addr %s, port %u",
host_name.c_str(), protocol.c_str(), address.c_str(), port); host_name.c_str(), protocol.c_str(), address.c_str(), port);
if (endpoint.address().is_v4()) if (endpoint.address().is_v4())
addr_type = 0; addr_type = 0;
else else
addr_type = 1; addr_type = 1;
return true; return true;
}
} catch (std::exception& e) {
tries++;
if (tries == MAX_NB_RESOLVE_TRIES) {
throw std::runtime_error(
"Cannot resolve a DNS name " + std::string(e.what()) + " after " +
std::to_string(tries) + " tries");
return false;
}
std::this_thread::sleep_for(std::chrono::seconds(TIME_BETWEEN_TRIES));
} }
} catch (std::exception& e) {
// TODO: Remove this line so that AMF can re-try several times
throw std::runtime_error(
"Cannot resolve a DNS name " + std::string(e.what()));
return false;
} }
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment