Commit 585d36de authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Fix issue for PayloadContainerType

parent 2e76d726
...@@ -27,14 +27,21 @@ ...@@ -27,14 +27,21 @@
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
PayloadContainerType::PayloadContainerType(const uint8_t iei, uint8_t value) PayloadContainerType::PayloadContainerType() : Type1NasIeFormatTv() {
: Type1NasIeFormatTv(iei) { SetIeName(kPayloadContainerTypeIeName);
}
//------------------------------------------------------------------------------
PayloadContainerType::PayloadContainerType(uint8_t value)
: Type1NasIeFormatTv() {
SetValue(value & 0x0f); SetValue(value & 0x0f);
SetIeName(kPayloadContainerTypeIeName); SetIeName(kPayloadContainerTypeIeName);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
PayloadContainerType::PayloadContainerType() : Type1NasIeFormatTv() { PayloadContainerType::PayloadContainerType(const uint8_t iei, uint8_t value)
: Type1NasIeFormatTv(iei) {
SetValue(value & 0x0f);
SetIeName(kPayloadContainerTypeIeName); SetIeName(kPayloadContainerTypeIeName);
} }
......
...@@ -34,6 +34,7 @@ namespace nas { ...@@ -34,6 +34,7 @@ namespace nas {
class PayloadContainerType : public Type1NasIeFormatTv { class PayloadContainerType : public Type1NasIeFormatTv {
public: public:
PayloadContainerType(); PayloadContainerType();
PayloadContainerType(uint8_t value);
PayloadContainerType(const uint8_t iei, uint8_t value); PayloadContainerType(const uint8_t iei, uint8_t value);
~PayloadContainerType(); ~PayloadContainerType();
......
...@@ -57,7 +57,7 @@ void DLNASTransport::setHeader(uint8_t security_header_type) { ...@@ -57,7 +57,7 @@ void DLNASTransport::setHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void DLNASTransport::setPayload_Container_Type(uint8_t value) { void DLNASTransport::setPayload_Container_Type(uint8_t value) {
ie_payload_container_type = new PayloadContainerType(0x00, value); ie_payload_container_type = new PayloadContainerType(value);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -105,13 +105,15 @@ int DLNASTransport::Encode(uint8_t* buf, int len) { ...@@ -105,13 +105,15 @@ int DLNASTransport::Encode(uint8_t* buf, int len) {
if (!ie_payload_container_type) { if (!ie_payload_container_type) {
Logger::nas_mm().warn("IE ie_payload_container_type is not available"); Logger::nas_mm().warn("IE ie_payload_container_type is not available");
} else { } else {
if (int size = ie_payload_container_type->Encode( int size = ie_payload_container_type->Encode(
buf + encoded_size, len - encoded_size)) { buf + encoded_size, len - encoded_size);
encoded_size += size; if (size == KEncodeDecodeError) {
} else {
Logger::nas_mm().error("Encoding ie_payload_container_type error"); Logger::nas_mm().error("Encoding ie_payload_container_type error");
return 0; return 0;
} }
if (size == 0)
size++; // 1/2 octet for ie_payload_container_type, 1/2 octet for spare
encoded_size += size;
} }
if (!ie_payload_container or !ie_payload_container_type) { if (!ie_payload_container or !ie_payload_container_type) {
Logger::nas_mm().warn("IE ie_payload_container is not available"); Logger::nas_mm().warn("IE ie_payload_container is not available");
...@@ -181,8 +183,8 @@ int DLNASTransport::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) { ...@@ -181,8 +183,8 @@ int DLNASTransport::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
ie_payload_container_type = new PayloadContainerType(); ie_payload_container_type = new PayloadContainerType();
decoded_size += ie_payload_container_type->Decode( decoded_size += ie_payload_container_type->Decode(
buf + decoded_size, len - decoded_size, false); buf + decoded_size, len - decoded_size, false);
ie_payload_container = new Payload_Container();
decoded_size++; // 1/2 octet for PayloadContainerType, 1/2 octet for spare decoded_size++; // 1/2 octet for PayloadContainerType, 1/2 octet for spare
ie_payload_container = new Payload_Container();
decoded_size += ie_payload_container->Decode( decoded_size += ie_payload_container->Decode(
buf + decoded_size, len - decoded_size, false, buf + decoded_size, len - decoded_size, false,
N1_SM_INFORMATION); // TODO: verified Typeb of Payload Container N1_SM_INFORMATION); // TODO: verified Typeb of Payload Container
......
...@@ -53,7 +53,7 @@ void ULNASTransport::setHeader(uint8_t security_header_type) { ...@@ -53,7 +53,7 @@ void ULNASTransport::setHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ULNASTransport::setPayload_Container_Type(uint8_t value) { void ULNASTransport::setPayload_Container_Type(uint8_t value) {
ie_payload_container_type = new PayloadContainerType(0x00, value); ie_payload_container_type = new PayloadContainerType(value);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -187,13 +187,15 @@ int ULNASTransport::Encode(uint8_t* buf, int len) { ...@@ -187,13 +187,15 @@ int ULNASTransport::Encode(uint8_t* buf, int len) {
if (!ie_payload_container_type) { if (!ie_payload_container_type) {
Logger::nas_mm().warn("IE ie_payload_container_type is not available"); Logger::nas_mm().warn("IE ie_payload_container_type is not available");
} else { } else {
if (int size = ie_payload_container_type->Encode( int size = ie_payload_container_type->Encode(
buf + encoded_size, len - encoded_size)) { buf + encoded_size, len - encoded_size);
encoded_size += size; if (size == KEncodeDecodeError) {
} else { Logger::nas_mm().error("Encoding ie_payload_container_type error");
Logger::nas_mm().error("encoding ie_payload_container_type error");
return 0; return 0;
} }
if (size == 0)
size++; // 1/2 octet for ie_payload_container_type, 1/2 octet for spare
encoded_size += size;
} }
if (!ie_payload_container or !ie_payload_container_type) { if (!ie_payload_container or !ie_payload_container_type) {
Logger::nas_mm().warn("IE ie_payload_container is not available"); Logger::nas_mm().warn("IE ie_payload_container is not available");
......
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