Commit 85ebcd38 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_ladn_indication' into 'develop'

Fix issue for LADN Indication

See merge request oai/cn5g/oai-cn5g-amf!87
parents 0be97cec 887cdf9e
......@@ -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, _iei, encoded_size);
ENCODE_U16(buf, 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, 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, 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;
}
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