Commit a08ddf86 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'develop' into 'n1_message_notify_api'

# Conflicts:
#   src/amf-app/amf_n11.cpp
#   src/amf-app/amf_n11.hpp
parents d4884676 03612dde
# RELEASE NOTES: #
## v1.3.0 -- January 2022 ##
* Periodic Registration Update
* Support for Event Exposure (Registration State Report)
* Implicit Deregistration Timer
* Mobile Reachable Timer
* Mobility Registration Update
* NRF Selection (via NSSF)
* Fix for validation of SMF Info
* Fix RAN UE NGAP Id
* Fix SMF Selection SD
* Fix NSSAI mismatch
* Fix Service Request
* Fix HTTP2
* Fix MCC such as 001
* Docker optimization
## v1.2.1 -- October 2021 ##
* Fix build issue
......
......@@ -243,9 +243,10 @@ pipeline {
}
myShCmd('sudo podman image prune --force', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
// Copy the RHEL Host certificates for building
myShCmd('mkdir -p tmp/ca tmp/entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('cp /etc/pki/entitlement/*pem tmp/entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo cp /etc/rhsm/ca/redhat-uep.pem tmp/ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('mkdir -p ./etc-pki-entitlement ./rhsm-conf ./rhsm-ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('cp /etc/pki/entitlement/*pem ./etc-pki-entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo cp /etc/rhsm/rhsm.conf ./rhsm-conf', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo cp /etc/rhsm/ca/*.pem ./rhsm-ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman build --no-cache --target oai-amf --tag oai-amf:' + amf_tag + ' --file docker/Dockerfile.amf.rhel8 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/amf_podman_image_build.log 2>&1', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman image ls >> archives/amf_podman_image_build.log', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
if ("MERGE".equals(env.gitlabActionType)) {
......@@ -439,6 +440,36 @@ pipeline {
}
}
}
stage ('Testing the tutorials') {
steps {
script {
gitlabCommitStatus(name: "Test tutorials") {
localStatus = build job: 'OAI-CN5G-Tutorials-Check',
parameters: [
string(name: 'AMF_TAG', value: String.valueOf(amf_tag)),
string(name: 'AMF_BRANCH', value: String.valueOf(amf_branch))
], propagate: false
localResult = localStatus.getResult()
if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
echo "Tutorials Test Job is OK"
} else {
echo "Tutorials Test Job is KO"
sh "ci-scripts/fail.sh"
}
}
}
}
post {
always {
script {
copyArtifacts(projectName: 'OAI-CN5G-Tutorials-Check',
filter: '*_results_oai_cn5g*.html',
selector: lastCompleted())
}
}
}
}
}
}
// For the moment it is Docker-Hub, but we might have a new one internally.
......
......@@ -32,8 +32,12 @@ FROM registry.access.redhat.com/ubi8/ubi:latest AS oai-amf-builder
ARG NEEDED_GIT_PROXY
COPY tmp/ca/redhat-uep.pem /etc/rhsm/ca
COPY tmp/entitlement/*.pem /etc/pki/entitlement
# Copy the entitlements
COPY ./etc-pki-entitlement /etc/pki/entitlement
# Copy the subscription manager configurations
COPY ./rhsm-conf /etc/rhsm
COPY ./rhsm-ca /etc/rhsm/ca
RUN rm -f /etc/rhsm-host && \
yum repolist --disablerepo=* && \
......
......@@ -126,7 +126,7 @@ AMF =
EXTERNAL_UDM = "@EXTERNAL_UDM@"; # Set to yes if AMF works with an external UDM
EXTERNAL_NSSF = "@EXTERNAL_NSSF"; # Set to yes if AMF works with an external NSSF
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AMF relies on a DNS to resolve NRF/SMF/UDM/AUSF's FQDN
USE_HTTP2 = "no"; # Set to yes to enable HTTP2 for AMF server
USE_HTTP2 = "@USE_HTTP2@"; # Set to yes to enable HTTP2 for AMF server
}
AUTHENTICATION:
......
......@@ -16,6 +16,7 @@ NSSF_API_VERSION=${NSSF_API_VERSION:-v2}
NSSF_FQDN=${NSSF_FQDN:-oai-nssf}
INT_ALGO_LIST=${INT_ALGO_LIST:-'[ "NIA0" , "NIA1" , "NIA2" ]'}
CIPH_ALGO_LIST=${CIPH_ALGO_LIST:-'[ "NEA0" , "NEA1" , "NEA2" ]'}
USE_HTTP2=${USE_HTTP2:-no}
if [[ ${USE_FQDN_DNS} == "yes" ]];then
NSSF_IPV4_ADDR=${NSSF_IPV4_ADDR_0:-0.0.0.0}
......
......@@ -491,6 +491,11 @@ int amf_config::load(const std::string& config_file) {
util::trim(address).c_str(), ausf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR AUSF !");
ausf_addr.ipv4_addr = ausf_ipv4_addr;
// We hardcode nrf port from config for the moment
if (!(ausf_cfg.lookupValue(AMF_CONFIG_STRING_PORT, ausf_port))) {
Logger::amf_app().error(AMF_CONFIG_STRING_PORT "failed");
throw(AMF_CONFIG_STRING_PORT "failed");
}
ausf_addr.port = ausf_port;
ausf_addr.api_version = "v1"; // TODO: get API version
}
......
......@@ -226,12 +226,14 @@ void amf_n11::handle_itti_message(
}
std::string smf_addr = {};
std::string smf_port = {};
std::string smf_api_version = {};
if (!psc.get()->smf_available) {
Logger::amf_n11().error("No SMF is available for this PDU session");
} else {
smf_addr = psc->smf_addr;
smf_port = psc->smf_port;
smf_api_version = psc->smf_api_version;
}
......@@ -249,7 +251,8 @@ void amf_n11::handle_itti_message(
if (found != std::string::npos)
remote_uri = psc.get()->smf_context_location + "/modify";
else
remote_uri = smf_addr + psc.get()->smf_context_location + "/modify";
remote_uri =
smf_addr + ":" + smf_port + psc.get()->smf_context_location + "/modify";
Logger::amf_n11().debug("SMF URI: %s", remote_uri.c_str());
......@@ -274,7 +277,7 @@ void amf_n11::handle_itti_message(
std::string json_part = pdu_session_update_request.dump();
uint8_t http_version = 1;
// if (amf_cfg.support_features.use_http2) http_version = 2;
if (amf_cfg.support_features.use_http2) http_version = 2;
curl_http_client(
remote_uri, json_part, "", n2sm_msg, supi, itti_msg.pdu_session_id,
......@@ -354,6 +357,7 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
std::string smf_addr = {};
std::string smf_api_version = {};
std::string smf_port = "80"; // Set to default port number
if (!psc.get()->smf_available) {
if (amf_cfg.support_features.enable_smf_selection) {
// Get NRF URI
......@@ -381,6 +385,7 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
// store smf info to be used with this PDU session
psc.get()->smf_available = true;
psc->smf_addr = smf_addr;
psc->smf_port = smf_port;
psc->smf_api_version = smf_api_version;
} else {
smf_addr = psc->smf_addr;
......@@ -396,7 +401,7 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
"Decoded PTI for PDUSessionEstablishmentRequest(0x%x)", pti);
psc.get()->isn2sm_avaliable = false;
handle_pdu_session_initial_request(
supi, psc, smf_addr, smf_api_version, smf.sm_msg, dnn);
supi, psc, smf_addr, smf_api_version, smf_port, smf.sm_msg, dnn);
} break;
case EXISTING_PDU_SESSION: {
// TODO:
......@@ -419,8 +424,8 @@ void amf_n11::send_pdu_session_update_sm_context_request(
std::string smf_addr, bstring sm_msg, std::string dnn) {
Logger::amf_n11().debug(
"Send PDU Session Update SM Context Request to SMF (SUPI %s, PDU Session "
"ID %d)",
supi.c_str(), psc.get()->pdu_session_id);
"ID %d, %s)",
supi.c_str(), psc.get()->pdu_session_id, smf_addr.c_str());
std::string smf_ip_addr = {};
std::string remote_uri = {};
......@@ -448,7 +453,7 @@ void amf_n11::send_pdu_session_update_sm_context_request(
(uint8_t*) bdata(sm_msg), blength(sm_msg), n1sm_msg);
uint8_t http_version = 1;
if (amf_cfg.support_features.use_http2) http_version = 2;
// if (amf_cfg.support_features.use_http2) http_version = 2;
curl_http_client(
remote_uri, json_part, n1sm_msg, "", supi, psc.get()->pdu_session_id,
......@@ -458,15 +463,27 @@ void amf_n11::send_pdu_session_update_sm_context_request(
//------------------------------------------------------------------------------
void amf_n11::handle_pdu_session_initial_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, std::string smf_api_version, bstring sm_msg,
std::string dnn) {
std::string smf_addr, std::string smf_api_version, std::string smf_port,
bstring sm_msg, std::string dnn) {
Logger::amf_n11().debug(
"Handle PDU Session Establishment Request (SUPI %s, PDU Session ID %d)",
supi.c_str(), psc.get()->pdu_session_id);
// remove http port from the URI if existed
std::string smf_ip_addr = {};
std::size_t found_port = smf_addr.find(":");
if (found_port != std::string::npos)
smf_ip_addr = smf_addr.substr(0, found_port);
else
smf_ip_addr = smf_addr;
// provide http2 port if enabled
std::string amf_port = to_string(amf_cfg.n11.port);
if (amf_cfg.support_features.use_http2)
amf_port = to_string(amf_cfg.sbi_http2_port);
// TODO: Remove hardcoded values
std::string remote_uri =
smf_addr + "/nsmf-pdusession/" + smf_api_version + "/sm-contexts";
std::string remote_uri = smf_ip_addr + ":" + smf_port + "/nsmf-pdusession/" +
smf_api_version + "/sm-contexts";
nlohmann::json pdu_session_establishment_request;
pdu_session_establishment_request["supi"] = supi.c_str();
pdu_session_establishment_request["pei"] = "imei-200000000000001";
......@@ -486,8 +503,8 @@ void amf_n11::handle_pdu_session_initial_request(
pdu_session_establishment_request["anType"] = "3GPP_ACCESS"; // TODO
pdu_session_establishment_request["smContextStatusUri"] =
"http://" +
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.n11.addr4))) +
"/nsmf-pdusession/callback/" + supi + "/" +
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.n11.addr4))) + ":" +
amf_port + "/nsmf-pdusession/callback/" + supi + "/" +
std::to_string(psc.get()->pdu_session_id);
pdu_session_establishment_request["n1MessageContainer"]["n1MessageClass"] =
......@@ -504,7 +521,7 @@ void amf_n11::handle_pdu_session_initial_request(
(uint8_t*) bdata(sm_msg), blength(sm_msg), n1sm_msg);
uint8_t http_version = 1;
// if (amf_cfg.support_features.use_http2) http_version = 2;
if (amf_cfg.support_features.use_http2) http_version = 2;
curl_http_client(
remote_uri, json_part, n1sm_msg, "", supi, psc.get()->pdu_session_id,
......@@ -1292,6 +1309,20 @@ void amf_n11::curl_http_client(
curl_global_cleanup();
free_wrapper((void**) &body_data);
}
<<<<<<< src/amf-app/amf_n11.cpp
=======
//-----------------------------------------------------------------------------------------------------
bool amf_n11::discover_smf_from_nsi_info(
std::string& smf_addr, std::string& smf_api_version, std::string& smf_port,
const snssai_t snssai, const plmn_t plmn, const std::string dnn) {
Logger::amf_n11().debug(
"Send NS Selection to NSSF to discover the appropriate NRF");
bool result = true;
std::string nrf_addr = {};
std::string nrf_port = {};
std::string nrf_api_version = {};
>>>>>>> src/amf-app/amf_n11.cpp
//------------------------------------------------------------------------------
void amf_n11::curl_http_client(
......@@ -1324,7 +1355,27 @@ void amf_n11::curl_http_client(
body = json_data;
is_multipart = false;
}
<<<<<<< src/amf-app/amf_n11.cpp
=======
curl_global_cleanup();
if (!result) return result;
Logger::amf_n11().debug("NSI Inforation is successfully retrieved from NSSF");
if (!discover_smf(
smf_addr, smf_api_version, smf_port, snssai, plmn, dnn, nrf_addr,
nrf_port, nrf_api_version))
return false;
return true;
}
//-----------------------------------------------------------------------------------------------------
bool amf_n11::discover_smf(
std::string& smf_addr, std::string& smf_api_version, std::string& smf_port,
const snssai_t snssai, const plmn_t plmn, const std::string dnn,
const std::string& nrf_addr, const std::string& nrf_port,
const std::string& nrf_api_version) {
>>>>>>> src/amf-app/amf_n11.cpp
Logger::amf_n11().debug(
"Send HTTP message to SMF with body %s", body.c_str());
......@@ -1339,10 +1390,123 @@ void amf_n11::curl_http_client(
if (curl) {
CURLcode res = {};
struct curl_slist* headers = nullptr;
<<<<<<< src/amf-app/amf_n11.cpp
std::string content_type = {};
if (is_multipart) {
content_type = "content-type: multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY);
=======
// headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
if (http_version == 2) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
}
// Response information
long httpCode = {0};
std::unique_ptr<std::string> httpData(new std::string());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
// curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, body.length());
// curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
Logger::amf_n11().debug(
"NFDiscovery, response from NRF, HTTP Code: %d", httpCode);
if (httpCode == 200) {
Logger::amf_n11().debug("NFDiscovery, got successful response from NRF");
nlohmann::json response_data = {};
try {
response_data = nlohmann::json::parse(*httpData.get());
} catch (nlohmann::json::exception& e) {
Logger::amf_n11().warn(
"NFDiscovery, could not parse json from the NRF "
"response");
}
Logger::amf_n11().debug(
"NFDiscovery, response from NRF, json data: \n %s",
response_data.dump().c_str());
// Process data to obtain SMF info
if (response_data.find("nfInstances") != response_data.end()) {
for (auto& it : response_data["nfInstances"].items()) {
nlohmann::json instance_json = it.value();
// TODO: convert instance_json to SMF profile
// TODO: add SMF to the list of available SMF
// check with sNSSAI
if (instance_json.find("sNssais") != instance_json.end()) {
for (auto& s : instance_json["sNssais"].items()) {
nlohmann::json Snssai = s.value();
if (Snssai["sst"].get<int>() == snssai.sST) {
// Match SD (optional) only if it is provided
if (Snssai["sd"].empty() or
(snssai.sD.compare(Snssai["sd"].get<std::string>()) == 0)) {
Logger::amf_n11().debug(
"S-NSSAI [SST- %d, SD -%s] is matched for SMF profile",
snssai.sST, snssai.sD.c_str());
result = true;
break; // NSSAI is included in the list of supported slices
// from SMF
}
}
}
}
if (!result) {
Logger::amf_n11().debug("S-NSSAI is not matched for SMF profile");
// continue;
}
// TODO: check DNN
// TODO: PLMN (need to add plmnList into NRF profile, SMF profile)
// for now, just IP addr of SMF of the first NF instance
if (instance_json.find("ipv4Addresses") != instance_json.end()) {
if (instance_json["ipv4Addresses"].size() > 0)
smf_addr =
instance_json["ipv4Addresses"].at(0).get<std::string>();
}
if (instance_json.find("nfServices") != instance_json.end()) {
if (instance_json["nfServices"].size() > 0) {
nlohmann::json nf_service = instance_json["nfServices"].at(0);
if (nf_service.find("versions") != nf_service.end()) {
nlohmann::json nf_version = nf_service["versions"].at(0);
if (nf_version.find("apiVersionInUri") != nf_version.end()) {
smf_api_version =
nf_version["apiVersionInUri"].get<std::string>();
}
}
if (nf_service.find("ipEndPoints") != nf_service.end()) {
nlohmann::json nf_ip_end = nf_service["ipEndPoints"].at(0);
if (nf_ip_end.find("port") != nf_ip_end.end()) {
smf_port = to_string(nf_ip_end["port"].get<int>()).c_str();
}
}
}
}
// Break after first matching SMF instance for requested S-NSSAI
if (result) break;
}
}
Logger::amf_n11().debug(
"NFDiscovery, SMF Addr: %s, SMF Api Version: %s, SMF Port: %s",
smf_addr.c_str(), smf_api_version.c_str(), smf_port.c_str());
>>>>>>> src/amf-app/amf_n11.cpp
} else {
content_type = "content-type: application/json";
}
......
......@@ -53,8 +53,8 @@ class amf_n11 {
void handle_itti_message(itti_nsmf_pdusession_create_sm_context&);
void handle_pdu_session_initial_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, std::string smf_api_version, bstring sm_msg,
std::string dnn);
std::string smf_addr, std::string smf_api_version, std::string smf_port,
bstring sm_msg, std::string dnn);
void handle_itti_message(itti_nsmf_pdusession_update_sm_context& itti_msg);
void handle_itti_message(itti_nsmf_pdusession_release_sm_context& itti_msg);
void handle_itti_message(itti_pdu_session_resource_setup_response& itti_msg);
......@@ -93,7 +93,8 @@ class amf_n11 {
bool discover_smf_from_nsi_info(
std::string& smf_addr, std::string& smf_api_version,
const snssai_t snssai, const plmn_t plmn, const std::string dnn);
std::string& smf_port, const snssai_t snssai, const plmn_t plmn,
const std::string dnn);
bool discover_smf(
std::string& smf_addr, std::string& smf_api_version,
......
......@@ -49,6 +49,7 @@ class pdu_session_context {
bool isn1sm_avaliable;
std::string dnn;
std::string smf_addr;
std::string smf_port;
std::string smf_api_version;
bool smf_available;
std::string location;
......
......@@ -57,7 +57,6 @@ LADN_Indication::~LADN_Indication() {}
//------------------------------------------------------------------------------
void LADN_Indication::setValue(uint8_t iei, uint8_t value) {
_iei = iei;
//_value = value;
}
//------------------------------------------------------------------------------
......@@ -68,19 +67,15 @@ bool LADN_Indication::getValue(std::vector<bstring>& ladn) {
//------------------------------------------------------------------------------
int LADN_Indication::encode2buffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding LADN_Indication iei (0x%x)", _iei);
Logger::nas_mm().debug("Encoding LADN_Indication IEI (0x%x)", _iei);
if (len < length) {
Logger::nas_mm().error("Len is less than %d", length);
return 0;
}
int encoded_size = 0;
if (_iei) {
*(buf + encoded_size) = _iei;
encoded_size++;
*(buf + encoded_size) = (length - 3) & 0x00ff;
encoded_size++;
*(buf + encoded_size) = ((length - 3) & 0xff00) >> 8;
encoded_size++;
ENCODE_U8(buf + encoded_size, _iei, encoded_size);
ENCODE_U16(buf + encoded_size, length - 3, encoded_size);
for (int i = 0; i < LADN.size(); i++) {
*(buf + encoded_size) = blength(LADN.at(i));
encoded_size++;
......@@ -88,6 +83,7 @@ int LADN_Indication::encode2buffer(uint8_t* buf, int len) {
encode_bstring(LADN.at(i), (buf + encoded_size), len - encoded_size);
}
} else {
// TODO:
// *(buf + encoded_size) = length - 1; encoded_size++;
// *(buf + encoded_size) = _value; encoded_size++; encoded_size++;
}
......@@ -97,29 +93,26 @@ int LADN_Indication::encode2buffer(uint8_t* buf, int len) {
//------------------------------------------------------------------------------
int LADN_Indication::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
Logger::nas_mm().debug("Decoding LADN_Indication iei (0x%x)", *buf);
Logger::nas_mm().debug("Decoding LADN_Indication IEI (0x%x)", *buf);
int decoded_size = 0;
if (is_option) {
decoded_size++;
}
length = 0;
length |= *(buf + decoded_size);
decoded_size++;
length |= (*(buf + decoded_size)) << 8;
decoded_size++;
DECODE_U16(buf + decoded_size, length, decoded_size);
Logger::nas_mm().debug("Decoded LADN_Indication len (%d)", length);
int LEAGTH = length;
uint8_t len_dnn;
int len_ie = length;
uint8_t len_dnn = 0;
bstring dnn;
while (LEAGTH) {
len_dnn = *(buf + decoded_size);
decoded_size++;
LEAGTH--;
while (len_ie) {
DECODE_U8(buf + decoded_size, len_dnn, decoded_size);
len_ie--;
decode_bstring(&dnn, len_dnn, (buf + decoded_size), len - decoded_size);
decoded_size += len_dnn;
LEAGTH -= len_dnn;
len_ie -= len_dnn;
LADN.insert(LADN.end(), dnn);
}
for (int i = 0; i < LADN.size(); i++) {
for (int j = 0; j < blength(LADN.at(i)); j++) {
Logger::nas_mm().debug(
......@@ -127,6 +120,7 @@ int LADN_Indication::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
(uint8_t) LADN.at(i)->data[j]);
}
}
Logger::nas_mm().debug("Decoded LADN_Indication len (%d)", decoded_size);
return decoded_size;
}
......@@ -59,7 +59,7 @@ UENetworkCapability::UENetworkCapability(
_iei = iei;
_5g_EEASel = _5gg_EEASel;
_5g_EIASel = _5gg_EIASel;
length = 4;
length = 4; // Minimum length
Logger::nas_mm().debug(
"decoded UENetworkCapability EA(0x%d),IA(0x%d)", _5g_EEASel, _5g_EIASel);
}
......@@ -86,9 +86,9 @@ uint8_t UENetworkCapability::getEIASel() {
//------------------------------------------------------------------------------
int UENetworkCapability::encode2buffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("encoding UENetworkCapability iei(0x%x)", _iei);
Logger::nas_mm().debug("encoding UENetworkCapability IEI (0x%x)", _iei);
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;
}
int encoded_size = 0;
......@@ -102,29 +102,41 @@ int UENetworkCapability::encode2buffer(uint8_t* buf, int len) {
*(buf + encoded_size) = _5g_EIASel;
encoded_size++;
} else {
//*(buf + encoded_size) = length - 1; encoded_size++;
//*(buf + encoded_size) = _value; encoded_size++; encoded_size++;
*(buf + encoded_size) = length - 1;
encoded_size++;
*(buf + encoded_size) = _5g_EEASel;
encoded_size++;
*(buf + encoded_size) = _5g_EIASel;
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;
}
//------------------------------------------------------------------------------
int UENetworkCapability::decodefrombuffer(
uint8_t* buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding UENetworkCapability iei(0x%x)", *buf);
Logger::nas_mm().debug("Decoding UENetworkCapability IEI");
int decoded_size = 0;
int ie_length = 0;
if (is_option) {
_iei = *(buf + decoded_size);
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(
"decoded UENetworkCapability EA(0x%d),IA(0x%d)", _5g_EEASel, _5g_EIASel);
Logger::nas_mm().debug("decoded UENetworkCapability len(%d)", decoded_size);
return decoded_size;
"Decoded UENetworkCapability EA (0x%d), IA (0x%d)", _5g_EEASel,
_5g_EIASel);
Logger::nas_mm().debug(
"Decoded UENetworkCapability len 0x%d, actual length 0x%d", decoded_size,
ie_length);
return ie_length;
}
......@@ -52,6 +52,11 @@ class UENetworkCapability {
uint8_t length;
uint8_t _5g_EEASel;
uint8_t _5g_EIASel;
// TODO: uint8_t uEASel;
// TODO: uint8_t uIASel;
// TODO: uint8_t octet_7;
// TODO: uint8_t octet_8;
// TODO: uint8_t octet_9;
};
} // namespace nas
......
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