Commit 705d7a6d authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue for decoding ResetType

parent 552f041c
/*
* 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
*/
/*! \file
\brief
\author
\date 2021
\email: contact@openairinterface.org
*/
#include "ResetType.hpp"
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
ResetType::ResetType() {
present = Ngap_ResetType_PR_NOTHING;
nG_Interface = 0;
partOfNG_Interface = nullptr;
ueAssociationLogicalNGConnectionItem = nullptr;
}
//------------------------------------------------------------------------------
ResetType::~ResetType() {}
//------------------------------------------------------------------------------
void ResetType::setResetType(long) {}
//------------------------------------------------------------------------------
bool ResetType::encode(Ngap_ResetType_t* type) {}
//------------------------------------------------------------------------------
bool ResetType::decode(Ngap_ResetType_t* type) {
if (type->present == Ngap_ResetType_PR_nG_Interface) {
nG_Interface = (long) type->choice.nG_Interface;
return true;
} else if (type->present == Ngap_ResetType_PR_partOfNG_Interface) {
int num_item = type->choice.partOfNG_Interface->list.count;
partOfNG_Interface = new Ngap_UE_associatedLogicalNG_connectionList();
UEAssociationLogicalNGConnectionItem* item =
new UEAssociationLogicalNGConnectionItem[num_item]();
for (int i = 0; i < num_item; i++) {
if (!item[i].decode(type->choice.partOfNG_Interface->list.array[i]))
return false;
}
} else {
return false;
}
}
//------------------------------------------------------------------------------
void ResetType::getResetType(long& resetType) {}
//------------------------------------------------------------------------------
void ResetType::getResetType(
struct Ngap_UE_associatedLogicalNG_connectionList*& list) {}
//------------------------------------------------------------------------------
void ResetType::setUE_associatedLogicalNG_connectionList(
const std::vector<UEAssociationLogicalNGConnectionItem> list) {}
} // namespace ngap
/*
* 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
*/
/*! \file
\brief
\author
\date 2021
\email: contact@openairinterface.org
*/
#ifndef _RESET_TYPE_H_
#define _RESET_TYPE_H_
#include "UEAssociationLogicalNGConnectionItem.hpp"
extern "C" {
#include "Ngap_ResetType.h"
}
#include <vector>
namespace ngap {
class ResetType {
public:
ResetType();
virtual ~ResetType();
void setResetType(long);
bool encode(Ngap_ResetType_t* type);
bool decode(Ngap_ResetType_t* type);
void getResetType(long&);
void getResetType(struct Ngap_UE_associatedLogicalNG_connectionList*&);
void setUE_associatedLogicalNG_connectionList(
const std::vector<UEAssociationLogicalNGConnectionItem> list);
private:
Ngap_ResetType_PR present;
long nG_Interface;
struct Ngap_UE_associatedLogicalNG_connectionList* partOfNG_Interface;
UEAssociationLogicalNGConnectionItem* ueAssociationLogicalNGConnectionItem;
// struct Ngap_ProtocolIE_SingleContainer *choice_Extensions;
};
} // namespace ngap
#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
*/
/*! \file
\brief
\author
\date 2021
\email: contact@openairinterface.org
*/
#include "UEAssociationLogicalNGConnectionItem.hpp"
extern "C" {
#include "dynamic_memory_check.h"
}
#include <iostream>
using namespace std;
namespace ngap {
UEAssociationLogicalNGConnectionItem::UEAssociationLogicalNGConnectionItem() {
amfUeNgapId = nullptr;
ranUeNgapId = nullptr;
}
//------------------------------------------------------------------------------
void UEAssociationLogicalNGConnectionItem::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_DownlinkNASTransport_IEs_t* ie =
(Ngap_DownlinkNASTransport_IEs_t*) calloc(
1, sizeof(Ngap_DownlinkNASTransport_IEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_DownlinkNASTransport_IEs__value_PR_AMF_UE_NGAP_ID;
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
free_wrapper((void**) &ie);
return;
}
}
//------------------------------------------------------------------------------
void UEAssociationLogicalNGConnectionItem::setRanUeNgapId(
uint32_t ran_ue_ngap_id) {
if (!ranUeNgapId) ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(ran_ue_ngap_id);
Ngap_DownlinkNASTransport_IEs_t* ie =
(Ngap_DownlinkNASTransport_IEs_t*) calloc(
1, sizeof(Ngap_DownlinkNASTransport_IEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_DownlinkNASTransport_IEs__value_PR_RAN_UE_NGAP_ID;
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) {
cout << "Encode RAN_UE_NGAP_ID IE error" << endl;
free_wrapper((void**) &ie);
return;
}
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::encode(
Ngap_UE_associatedLogicalNG_connectionItem_t& item) {}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::decode(
Ngap_UE_associatedLogicalNG_connectionItem_t* item) {
amfUeNgapId = new AMF_UE_NGAP_ID();
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(*item->aMF_UE_NGAP_ID)) {
cout << "Decoded NGAP AMF_UE_NGAP_ID IE error" << endl;
return false;
}
ranUeNgapId = new RAN_UE_NGAP_ID();
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(*item->rAN_UE_NGAP_ID)) {
cout << "Decoded NGAP RAN_UE_NGAP_ID IE error" << endl;
return false;
}
return true;
}
} // namespace ngap
/*
* 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
*/
/*! \file
\brief
\author
\date 2021
\email: contact@openairinterface.org
*/
#ifndef _UE_ASSOCIATION_LOGICAL_NG_CONNECTION_ITEM_H_
#define _UE_ASSOCIATION_LOGICAL_NG_CONNECTION_ITEM_H_
#include "AMF-UE-NGAP-ID.hpp"
#include "RAN-UE-NGAP-ID.hpp"
extern "C" {
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_UE-associatedLogicalNG-connectionItem.h"
}
namespace ngap {
class UEAssociationLogicalNGConnectionItem {
public:
UEAssociationLogicalNGConnectionItem();
virtual ~UEAssociationLogicalNGConnectionItem(){};
void setAmfUeNgapId(unsigned long id);
void setRanUeNgapId(uint32_t id);
bool encode(Ngap_UE_associatedLogicalNG_connectionItem_t& item);
bool decode(Ngap_UE_associatedLogicalNG_connectionItem_t* item);
private:
AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId;
};
} // namespace ngap
#endif
......@@ -51,7 +51,7 @@ NGResetMsg::NGResetMsg() {
ngResetIEs = nullptr;
// cause = {};
cause = nullptr;
resetType = {};
resetType = nullptr;
}
//------------------------------------------------------------------------------
NGResetMsg::~NGResetMsg() {}
......@@ -87,7 +87,7 @@ void NGResetMsg::setCause(Ngap_Cause_t cause) {
//------------------------------------------------------------------------------
void NGResetMsg::setResetType(Ngap_ResetType_t resetType) {
this->resetType = resetType;
// is->resetType = resetType;
}
void NGResetMsg::getCause(Ngap_Cause_t& cause) {
......@@ -95,7 +95,7 @@ void NGResetMsg::getCause(Ngap_Cause_t& cause) {
}
void NGResetMsg::getResetType(Ngap_ResetType_t& resetType) {
resetType = this->resetType;
// resetType = this->resetType;
}
//------------------------------------------------------------------------------
......@@ -131,11 +131,9 @@ bool NGResetMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!cause->decodefromCause(
&ngResetIEs->protocolIEs.list.array[i]
->value.choice.Cause)) {
cout << "decoded ngap Cause IE error" << endl;
cout << "Decoded NGAP Cause IE error" << endl;
return false;
}
// cause =
// ngResetIEs->protocolIEs.list.array[i]->value.choice.Cause;
} else {
cout << "Decoded NGAP Cause IE error" << endl;
return false;
......@@ -146,8 +144,13 @@ bool NGResetMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
Ngap_Criticality_ignore &&
ngResetIEs->protocolIEs.list.array[i]->value.present ==
Ngap_NGResetIEs__value_PR_ResetType) {
resetType =
ngResetIEs->protocolIEs.list.array[i]->value.choice.ResetType;
resetType = new ResetType();
if (!resetType->decode(&ngResetIEs->protocolIEs.list.array[i]
->value.choice.ResetType)) {
cout << "Decoded NGAP ResetType IE error" << endl;
return false;
}
} else {
cout << "Decoded NGAP ResetType IE error" << endl;
return false;
......
......@@ -33,6 +33,7 @@
#include "MessageType.hpp"
#include "Cause.hpp"
#include "ResetType.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
......@@ -60,9 +61,10 @@ class NGResetMsg {
Ngap_NGAP_PDU_t* ngResetPdu;
Ngap_NGReset_t* ngResetIEs;
// Ngap_Cause_t cause;
Ngap_ResetType_t resetType;
// Ngap_ResetType_t resetType;
Cause* cause;
// ResetType resetType;
ResetType* resetType;
};
} // namespace ngap
......
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