Commit 66998970 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Fix default SD value from UE

parent 236c2eb1
......@@ -32,6 +32,12 @@
#include <string>
const uint32_t SD_NO_VALUE = 0xFFFFFF;
const uint8_t SST_MAX_STANDARDIZED_VALUE = 127;
const uint8_t SST_LENGTH = 1;
const uint8_t SD_LENGTH = 3;
typedef struct s_nssai // section 28.4, TS23.003
{
uint8_t sST;
......
......@@ -69,9 +69,6 @@ constexpr uint64_t SECONDS_SINCE_FIRST_EPOCH = 2208988800;
#define NAS_MESSAGE_DOWNLINK 1
#define NAS_MESSAGE_UPLINK 0
const uint32_t SD_NO_VALUE = 0xFFFFFF;
const uint8_t SST_MAX_STANDARDIZED_VALUE = 127;
typedef enum {
PlainNasMsg = 0x0,
IntegrityProtected = 0x1,
......
#NAS Library - CODEOWNERS
Philippe MOREL
Sebastien ROUX
Lionel GAUTHIER
Keliang DU, BUPT
Tien Thinh NGUYEN, Eurecom
......@@ -19,13 +19,6 @@
* contact@openairinterface.org
*/
/*! \file 3gpp_ts24501.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _3GPP_TS_24501_H_
#define _3GPP_TS_24501_H_
......@@ -188,4 +181,6 @@ static const std::vector<std::string> nas_ciphering_algorithm_list_e2str = {
#define PDU_SESSION_RELEASE_COMMAND 0b11010011
#define PDU_SESSION_RELEASE_COMPLETE 0b11010100
#define DEREGISTRATION_TYPE_MASK 0b00001000
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#pragma once
constexpr uint8_t kIeIsOptional = true;
constexpr uint8_t kIeIsNotOptional = false;
constexpr uint8_t kIei5gmmCause = 0x58;
constexpr uint8_t kIei5gsmCapability = 0x28;
constexpr uint8_t kIei5gsDrxParameters = 0x51;
constexpr uint8_t kIei5gsmCongestionReAttemptIndicator = 0x61;
constexpr uint8_t kIei5gsmNetworkFeatureSupport = 0x17;
constexpr uint8_t kIei5gsMobileIdentityImeiSv = 0x77;
constexpr uint8_t kIei5gsMobileIdentityNonImeiSvPei = 0x78;
constexpr uint8_t kIei5gsRegistrationResult = 0x44;
constexpr uint8_t kIei5gsTrackingAreaIdentity = 0x52;
constexpr uint8_t kIei5gsTrackingAreaIdentityList = 0x54;
constexpr uint8_t kIei5gsUpdateType = 0x53;
constexpr uint8_t kIeiAdditionalInformation = 0x24;
constexpr uint8_t kIeiAllowedSscMode = 0x0f;
constexpr uint8_t kIeiAlwaysOnPduSessionIndication = 0x08;
constexpr uint8_t kIeiAlwaysOnPduSessionRequested = 0x0b;
constexpr uint8_t kIeiAtsssContainer = 0x77;
constexpr uint8_t kIeiAuthorizedQosFlowDescriptions = 0x79;
constexpr uint8_t kIeiAuthorizedQosRules = 0x7a;
constexpr uint8_t kIeiBackOffTimerValue = 0x37;
constexpr uint8_t kIeiControlPlaneOnlyIndication = 0x0c;
constexpr uint8_t kIeiDnn = 0x25;
constexpr uint8_t kIeiDsTtEthernetPortMacAddress = 0x6e;
constexpr uint8_t kIeiEapMessage = 0x78;
constexpr uint8_t kIeiEthernetHeaderCompressionConfiguration = 0x1f;
constexpr uint8_t kIeiExtendedDrxParameters = 0x6e;
constexpr uint8_t kIeiExtendedProtocolConfigurationOptions = 0x7b;
constexpr uint8_t kIeiIntegrityProtectionMaximumDataRate = 0x13;
constexpr uint8_t kIeiIpHeaderCompressionConfiguration = 0x66;
constexpr uint8_t kIeiMaPduSessionInformation = 0xa0;
constexpr uint8_t kIeiMappedEpsBearerContexts = 0x75;
constexpr uint8_t kIeiMaximumNumberOfSupportedPacketFilters = 0x55;
constexpr uint8_t kIeiNbN1ModeDrxParameters = 0x29;
constexpr uint8_t kIeiNSSAIAllowed = 0x15;
constexpr uint8_t kIeiNSSAIConfigured = 0x31;
constexpr uint8_t kIeiNSSAIPending = 0x39;
constexpr uint8_t kIeiOldPduSessionId = 0x59;
constexpr uint8_t kIeiPduAddress = 0x29;
constexpr uint8_t kIeiPduSessionId = 0x12;
constexpr uint8_t kIeiPduSessionType = 0x09;
constexpr uint8_t kIeiPortManagementInformationContainer = 0x74;
constexpr uint8_t kIeiReAttemptIndicator = 0x1d;
constexpr uint8_t kIeiRejectedNssaiRa = 0x11;
constexpr uint8_t kIeiRejectedNssaiRr = 0x69;
constexpr uint8_t kIeiRejectedNssaiDr = 0x6D;
constexpr uint8_t kIeiRejectedNssaiCuc = 0x11;
constexpr uint8_t kIeiReleaseAssistanceIndication = 0xf0;
constexpr uint8_t kIeiRequestedQosFlowDescriptions = 0x79;
constexpr uint8_t kIeiRequestedQosRules = 0x7a;
constexpr uint8_t kIeiRequestType = 0x80;
constexpr uint8_t kIeiRqTimerValue = 0x56;
constexpr uint8_t kIeiServingPlmnRateControlPsea = 0x18;
constexpr uint8_t kIeiServingPlmnRateControlPsmc = 0x1e;
constexpr uint8_t kIeiSessionAmbr = 0x2a;
constexpr uint8_t kIeiSmPduDnRequestContainer = 0x39;
constexpr uint8_t kIeiSNssai = 0x22;
constexpr uint8_t kIeiSscMode = 0x0a;
constexpr uint8_t kIeiSuggestedInterfaceIdentifier = 0x29;
constexpr uint8_t kIeiUeDsTtResidenceTime = 0x6f;
......@@ -19,13 +19,6 @@
* contact@openairinterface.org
*/
/*! \file nas_ie_header.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "5GMMCapability.hpp"
#include "5GSMobilityIdentity.hpp"
#include "5GSRegistrationType.hpp"
......@@ -87,3 +80,4 @@
#include "_5GS_Update_Type.hpp"
#include "nas_mm_plain_header.hpp"
#include "struct.hpp"
#include "Ie_Const.hpp"
......@@ -19,13 +19,6 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "NSSAI.hpp"
#include <vector>
......@@ -37,16 +30,15 @@ using namespace nas;
//------------------------------------------------------------------------------
NSSAI::NSSAI(uint8_t iei) {
_iei = iei;
length = 0;
S_NSSAI = {};
_iei = iei;
length = 0;
}
//------------------------------------------------------------------------------
NSSAI::NSSAI(const uint8_t iei, std::vector<struct SNSSAI_s> nssai) {
_iei = iei;
length = 0;
S_NSSAI.assign(nssai.begin(), nssai.end());
S_NSSAIs.assign(nssai.begin(), nssai.end());
for (int i = 0; i < nssai.size(); i++) {
length += 2; // 1 for IEI and 1 for sst
if (nssai[i].sd != SD_NO_VALUE) length += SD_LENGTH;
......@@ -56,7 +48,7 @@ NSSAI::NSSAI(const uint8_t iei, std::vector<struct SNSSAI_s> nssai) {
}
//------------------------------------------------------------------------------
NSSAI::NSSAI() : _iei(), length(), S_NSSAI() {}
NSSAI::NSSAI() : _iei(), length(), S_NSSAIs() {}
//------------------------------------------------------------------------------
NSSAI::~NSSAI() {}
......@@ -66,7 +58,7 @@ void NSSAI::setS_NAASI(uint8_t SST) {}
//------------------------------------------------------------------------------
void NSSAI::getValue(std::vector<struct SNSSAI_s>& nssai) {
nssai.assign(S_NSSAI.begin(), S_NSSAI.end());
nssai.assign(S_NSSAIs.begin(), S_NSSAIs.end());
}
//------------------------------------------------------------------------------
......@@ -78,51 +70,48 @@ int NSSAI::encode2buffer(uint8_t* buf, int len) {
}
int encoded_size = 0;
if (_iei) {
*(buf + encoded_size) = _iei;
ENCODE_U8(buf + encoded_size, _iei, encoded_size);
}
ENCODE_U8(buf + encoded_size, length, encoded_size);
for (int i = 0; i < S_NSSAIs.size(); i++) {
int len_s_nssai = SST_LENGTH;
encoded_size++;
*(buf + encoded_size) = length;
*(buf + encoded_size) = S_NSSAIs.at(i).sst;
encoded_size++;
for (int i = 0; i < S_NSSAI.size(); i++) {
int len_s_nssai = SST_LENGTH;
if (S_NSSAIs.at(i).sd != SD_NO_VALUE) {
len_s_nssai += SD_LENGTH;
*(buf + encoded_size) = (S_NSSAIs.at(i).sd & 0x00ff0000) >> 16;
encoded_size++;
*(buf + encoded_size) = S_NSSAI.at(i).sst;
Logger::nas_mm().debug(
"Encoded NSSAI SD first octet (%x)", *(buf + encoded_size - 1));
*(buf + encoded_size) = (S_NSSAIs.at(i).sd & 0x0000ff00) >> 8;
encoded_size++;
Logger::nas_mm().debug(
"Encoded NSSAI SD second octet (%x)", *(buf + encoded_size - 1));
*(buf + encoded_size) = S_NSSAIs.at(i).sd & 0x000000ff;
encoded_size++;
Logger::nas_mm().debug(
"Encoded NSSAI SD third octet (%x)", *(buf + encoded_size - 1));
}
if (S_NSSAIs.at(i).mHplmnSst != -1) {
len_s_nssai += SST_LENGTH;
*(buf + encoded_size) = S_NSSAIs.at(i).mHplmnSst;
encoded_size++;
}
if (S_NSSAIs.at(i).mHplmnSd != SD_NO_VALUE) {
len_s_nssai += SD_LENGTH;
*(buf + encoded_size) = (S_NSSAIs.at(i).mHplmnSd & 0x00ff0000) >> 16;
encoded_size++;
*(buf + encoded_size) = (S_NSSAIs.at(i).mHplmnSd & 0x0000ff00) >> 8;
encoded_size++;
*(buf + encoded_size) = S_NSSAIs.at(i).mHplmnSd & 0x000000ff;
encoded_size++;
if (S_NSSAI.at(i).sd != SD_NO_VALUE) {
len_s_nssai += SD_LENGTH;
*(buf + encoded_size) = (S_NSSAI.at(i).sd & 0x00ff0000) >> 16;
encoded_size++;
Logger::nas_mm().debug(
"Encoded NSSAI SD first octet (%x)", *(buf + encoded_size - 1));
*(buf + encoded_size) = (S_NSSAI.at(i).sd & 0x0000ff00) >> 8;
encoded_size++;
Logger::nas_mm().debug(
"Encoded NSSAI SD second octet (%x)", *(buf + encoded_size - 1));
*(buf + encoded_size) = S_NSSAI.at(i).sd & 0x000000ff;
encoded_size++;
Logger::nas_mm().debug(
"Encoded NSSAI SD third octet (%x)", *(buf + encoded_size - 1));
}
if (S_NSSAI.at(i).mHplmnSst != -1) {
len_s_nssai += SST_LENGTH;
*(buf + encoded_size) = S_NSSAI.at(i).mHplmnSst;
encoded_size++;
}
if (S_NSSAI.at(i).mHplmnSd != SD_NO_VALUE) {
len_s_nssai += SD_LENGTH;
*(buf + encoded_size) = (S_NSSAI.at(i).mHplmnSd & 0x00ff0000) >> 16;
encoded_size++;
*(buf + encoded_size) = (S_NSSAI.at(i).mHplmnSd & 0x0000ff00) >> 8;
encoded_size++;
*(buf + encoded_size) = S_NSSAI.at(i).mHplmnSd & 0x000000ff;
encoded_size++;
}
*(buf + encoded_size - len_s_nssai - 1) = len_s_nssai;
}
} else {
// *(buf + encoded_size) = length - 1; encoded_size++;
// *(buf + encoded_size) = _value; encoded_size++; encoded_size++;
*(buf + encoded_size - len_s_nssai - 1) = len_s_nssai;
}
Logger::nas_mm().debug("Encoded NSSAI len (%d)", encoded_size);
return encoded_size;
}
......@@ -227,15 +216,15 @@ int NSSAI::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
} break;
}
S_NSSAI.insert(S_NSSAI.end(), a);
S_NSSAIs.insert(S_NSSAIs.end(), a);
a = {0, 0, 0, 0};
}
for (int i = 0; i < S_NSSAI.size(); i++) {
for (int i = 0; i < S_NSSAIs.size(); i++) {
Logger::nas_mm().debug(
"Decoded NSSAI SST (0x%x) SD (0x%x) hplmnSST (0x%x) hplmnSD (%d)",
S_NSSAI.at(i).sst, S_NSSAI.at(i).sd, S_NSSAI.at(i).mHplmnSst,
S_NSSAI.at(i).mHplmnSd);
S_NSSAIs.at(i).sst, S_NSSAIs.at(i).sd, S_NSSAIs.at(i).mHplmnSst,
S_NSSAIs.at(i).mHplmnSd);
}
Logger::nas_mm().debug("Decoded NSSAI len (%d)", decoded_size);
return decoded_size;
......
......@@ -34,8 +34,6 @@
#include "nas_ie_header.hpp"
#define SST_LENGTH 1
#define SD_LENGTH 3
namespace nas {
class NSSAI {
......@@ -52,7 +50,7 @@ class NSSAI {
private:
uint8_t _iei;
uint8_t length;
std::vector<struct SNSSAI_s> S_NSSAI;
std::vector<struct SNSSAI_s> S_NSSAIs;
};
} // namespace nas
......
This diff is collapsed.
......@@ -32,23 +32,36 @@
#include <stdint.h>
#include "nas_ie_header.hpp"
#include <optional>
namespace nas {
class S_NSSAI {
public:
S_NSSAI();
S_NSSAI(uint8_t iei);
S_NSSAI(const uint8_t iei, SNSSAI_s snssai);
// S_NSSAI(uint8_t iei);
S_NSSAI(std::optional<uint8_t> iei, SNSSAI_s snssai);
~S_NSSAI();
void setS_NSSAI(SNSSAI_s snssai);
// void setS_NSSAI(SNSSAI_s snssai);
int encode2buffer(uint8_t* buf, int len);
int decodefrombuffer(uint8_t* buf, int len, bool is_option);
void getValue(SNSSAI_s& snssai);
int decodefrombuffer(uint8_t* buf, int len, const bool is_option = true);
void getValue(SNSSAI_t& snssai);
void SetSNSSAI(
std::optional<int8_t> iei, uint8_t sst, std::optional<int32_t> sd,
std::optional<int8_t> mapped_hplmn_sst,
std::optional<int32_t> mapped_hplmn_sd);
uint8_t GetLength();
std::string ToString();
private:
uint8_t _iei;
// uint8_t _iei;
std::optional<int8_t> iei_;
uint8_t length;
SNSSAI_s SNSSAI;
// SNSSAI_s SNSSAI;
uint8_t sst_;
std::optional<int32_t> sd_;
std::optional<int8_t> mapped_hplmn_sst_;
std::optional<int32_t> mapped_hplmn_sd_;
};
} // namespace nas
......
......@@ -32,6 +32,10 @@
#include <iostream>
#include <vector>
#include "spdlog/fmt/fmt.h"
#include "3gpp_23.003.h"
extern "C" {
#include "TLVDecoder.h"
#include "TLVEncoder.h"
......@@ -55,6 +59,26 @@ typedef struct SNSSAI_s {
length = s.length;
return *this;
}
std::string ToString() {
std::string s;
s.append(fmt::format("SST {:#x}", sst));
if (length >= (SST_LENGTH + SD_LENGTH)) {
s.append(fmt::format(" SD {:#x}", sd));
}
if ((length == (SST_LENGTH + SST_LENGTH)) ||
(length >= (SST_LENGTH + SD_LENGTH + SST_LENGTH))) {
s.append(fmt::format(" M-HPLMN SST {:#x}", mHplmnSst));
}
if (length == (SST_LENGTH + SD_LENGTH + SST_LENGTH + SD_LENGTH)) {
s.append(fmt::format(" M-HPLMN SD {:#x}", mHplmnSd));
}
return s;
}
} SNSSAI_t;
typedef struct {
......@@ -62,15 +86,18 @@ typedef struct {
uint8_t ie_len;
bstring ie_value;
} IE_t;
typedef struct {
uint8_t ie_type;
uint16_t ie_len;
bstring ie_value;
} IE_t_E;
typedef struct {
uint8_t payloadContainerType : 4;
std::vector<IE_t> optionalIE;
} PayloadContainerEntry;
typedef struct IMEISV_s {
bstring identity;
} IMEISV_t;
......
......@@ -19,13 +19,6 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "ULNASTransport.hpp"
#include "3gpp_ts24501.hpp"
......@@ -137,7 +130,7 @@ uint8_t ULNASTransport::getRequestType() {
//------------------------------------------------------------------------------
void ULNASTransport::setS_NSSAI(SNSSAI_s snssai) {
ie_s_nssai = new S_NSSAI(0x22, snssai);
ie_s_nssai = new S_NSSAI(std::optional<uint8_t>{kIeiSNssai}, snssai);
}
//------------------------------------------------------------------------------
......@@ -378,7 +371,7 @@ int ULNASTransport::decodefrombuffer(
Logger::nas_mm().debug("Decoding IEI (0x22)");
ie_s_nssai = new S_NSSAI();
decoded_size += ie_s_nssai->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
buf + decoded_size, len - decoded_size, kIeIsOptional);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
} break;
......
......@@ -29,9 +29,7 @@
#define FILE_TLV_DECODER_SEEN
#include "bstrlib.h"
//#include "log.h"
#include "common_defs.h"
//#include "log.h"
#define IES_DECODE_U8(bUFFER, dECODED, vALUE) \
DECODE_U8(bUFFER + dECODED, vALUE, dECODED)
......
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