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

Fix NG Reset

parent bf753e40
......@@ -56,6 +56,7 @@
#include "logger.hpp"
#include "sctp_server.hpp"
#include "3gpp_24.501.h"
#include "NGResetAck.hpp"
#include <boost/chrono.hpp>
#include <boost/chrono/chrono.hpp>
......@@ -452,8 +453,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) {
Logger::amf_n2().debug(
"gNB with gNB_id 0x%x, assoc_id %d has been attached to AMF",
gc.get()->globalRanNodeId, itti_msg.assoc_id);
stacs.gNB_connected += 1;
stacs.gnbs.insert(std::pair<uint32_t, gnb_infos>(gnbItem.gnb_id, gnbItem));
stacs.add_gnb(gnbItem.gnb_id, gnbItem);
return;
}
......@@ -483,6 +483,8 @@ void amf_n2::handle_itti_message(itti_ng_reset& itti_msg) {
// UE association(s) indicated explicitly or implicitly in the NG RESET
// message and remove the NGAP ID for the indicated UE associations.
ResetType reset_type = {};
std::vector<UEAssociationLogicalNGConnectionItem>
ueAssociationLogicalNGConnectionList;
itti_msg.ngReset->getResetType(reset_type);
if (reset_type.getResetType() == Ngap_ResetType_PR_nG_Interface) {
// Reset all
......@@ -508,8 +510,41 @@ void amf_n2::handle_itti_message(itti_ng_reset& itti_msg) {
} else if (
reset_type.getResetType() == Ngap_ResetType_PR_partOfNG_Interface) {
// TODO:
reset_type.getUE_associatedLogicalNG_connectionList(
ueAssociationLogicalNGConnectionList);
for (auto ue : ueAssociationLogicalNGConnectionList) {
unsigned long amf_ue_ngap_id = {0};
ue.getAmfUeNgapId(amf_ue_ngap_id);
uint32_t ran_ue_ngap_id = {0};
ue.getRanUeNgapId(ran_ue_ngap_id);
// get NAS context
std::shared_ptr<nas_context> nc;
if (amf_n1_inst->is_amf_ue_id_2_nas_context(amf_ue_ngap_id)) {
nc = amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
} else {
Logger::amf_n2().warn(
"No existed nas_context with amf_ue_ngap_id(" AMF_UE_NGAP_ID_FMT
")",
amf_ue_ngap_id);
}
}
}
// TODO: create NGResetAck and reply to gNB
std::unique_ptr<NGResetAckMsg> ng_reset_ack =
std::make_unique<NGResetAckMsg>();
ng_reset_ack->setMessageType();
// UEAssociationLogicalNGConnectionList
if (ueAssociationLogicalNGConnectionList.size() > 0) {
ng_reset_ack->setUE_associatedLogicalNG_connectionList(
ueAssociationLogicalNGConnectionList);
}
uint8_t buffer[BUFFER_SIZE_512];
int encoded_size = ng_reset_ack->encode2buffer(buffer, BUFFER_SIZE_512);
bstring b = blk2bstr(buffer, encoded_size);
sctp_s_38412.sctp_send_msg(gc.get()->sctp_assoc_id, itti_msg.stream, &b);
return;
}
......@@ -558,11 +593,10 @@ void amf_n2::handle_itti_message(itti_ng_shutdown& itti_msg) {
// Delete gNB context
remove_gnb_context(itti_msg.assoc_id);
stacs.gnbs.erase(gc.get()->globalRanNodeId);
stacs.remove_gnb(gc.get()->globalRanNodeId);
Logger::amf_n2().debug(
"Remove gNB with association id %d, globalRanNodeId 0x%x",
itti_msg.assoc_id, gc.get()->globalRanNodeId);
stacs.gNB_connected -= 1;
stacs.display();
return;
}
......@@ -2164,6 +2198,39 @@ void amf_n2::set_ran_ue_ngap_id_2_ue_ngap_context(
ranid2uecontext[ran_ue_ngap_id] = unc;
}
/*
//------------------------------------------------------------------------------
bool amf_n2::get_ue_ngap_context_from_ran_ue_id(const uint32_t ran_ue_ngap_id,
std::shared_ptr<ue_ngap_context>& ue_context){ std::shared_lock
lock(m_ranid2uecontext); if (ranid2uecontext.count(ran_ue_ngap_id) > 0) { if
(ranid2uecontext.at(ran_ue_ngap_id).get() != nullptr) { ue_context =
ranid2uecontext.at(ran_ue_ngap_id); return true;
}
}
return false;
}
*/
//------------------------------------------------------------------------------
void amf_n2::get_ue_ngap_contexts(
std::vector<uint32_t> ran_ue_ngap_ids,
std::vector<std::shared_ptr<ue_ngap_context>>& ue_contexts) {
std::shared_lock lock(m_ranid2uecontext);
for (auto ran_ue_ngap_id : ran_ue_ngap_ids) {
ue_contexts.push_back(ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id));
}
}
//------------------------------------------------------------------------------
void amf_n2::get_all_ue_ngap_contexts(
std::vector<std::shared_ptr<ue_ngap_context>>& ue_contexts) {
std::shared_lock lock(m_ranid2uecontext);
for (auto ue : ranid2uecontext) {
ue_contexts.push_back(ue.second);
}
}
//------------------------------------------------------------------------------
std::shared_ptr<ue_ngap_context> amf_n2::amf_ue_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id) const {
......
......@@ -220,6 +220,12 @@ class amf_n2 : public ngap::ngap_app {
const unsigned long& amf_ue_ngap_id,
std::shared_ptr<ue_ngap_context> unc);
void get_ue_ngap_contexts(
std::vector<uint32_t> ran_ue_ngap_ids,
std::vector<std::shared_ptr<ue_ngap_context>>& ue_contexts);
void get_all_ue_ngap_contexts(
std::vector<std::shared_ptr<ue_ngap_context>>& ue_contexts);
private:
std::map<uint32_t, std::shared_ptr<ue_ngap_context>>
ranid2uecontext; // ran ue ngap id
......
......@@ -30,6 +30,16 @@
#include "logger.hpp"
//------------------------------------------------------------------------------
statistics::statistics() : m_ue_infos(), m_gnbs() {
gNB_connected = 0;
UE_connected = 0;
UE_registred = 0;
}
//------------------------------------------------------------------------------
statistics::~statistics() {}
//------------------------------------------------------------------------------
void statistics::display() {
Logger::amf_app().info("");
......@@ -92,19 +102,14 @@ void statistics::display() {
Logger::amf_app().info("");
}
//------------------------------------------------------------------------------
statistics::statistics() {
gNB_connected = 0;
UE_connected = 0;
UE_registred = 0;
}
//------------------------------------------------------------------------------
void statistics::update_ue_info(const ue_info_t& ue_info) {
if (!(ue_info.imsi.size() > 0)) {
Logger::amf_app().warn("Update UE Info with invalid IMSI");
return;
}
std::unique_lock lock(m_ue_infos);
if (ue_infos.count(ue_info.imsi) > 0) {
ue_infos.erase(ue_info.imsi);
ue_infos.insert(std::pair<std::string, ue_info_t>(ue_info.imsi, ue_info));
......@@ -120,6 +125,7 @@ void statistics::update_ue_info(const ue_info_t& ue_info) {
//------------------------------------------------------------------------------
void statistics::update_5gmm_state(
const std::string& imsi, const std::string& state) {
std::unique_lock lock(m_ue_infos);
if (ue_infos.count(imsi) > 0) {
ue_info_t ue_info = ue_infos.at(imsi);
ue_info.registerStatus = state;
......@@ -134,6 +140,26 @@ void statistics::update_5gmm_state(
}
}
void statistics::remove_gnb(const uint32_t gnb_id) {}
//------------------------------------------------------------------------------
statistics::~statistics() {}
void statistics::remove_gnb(const uint32_t gnb_id) {
std::unique_lock lock(m_gnbs);
if (gnbs.count(gnb_id) > 0) {
gnbs.erase(gnb_id);
gNB_connected -= 1;
}
}
//------------------------------------------------------------------------------
void statistics::add_gnb(const uint32_t& gnb_id, const gnb_infos& gnb) {
std::unique_lock lock(m_gnbs);
gnbs.insert(std::pair<uint32_t, gnb_infos>(gnb_id, gnb));
gNB_connected += 1;
}
//------------------------------------------------------------------------------
void statistics::update_gnb(const uint32_t& gnb_id, const gnb_infos& gnb) {
std::unique_lock lock(m_gnbs);
if (gnbs.count(gnb_id) > 0) {
gnbs[gnb_id] = gnb;
}
}
......@@ -82,14 +82,17 @@ class statistics {
void update_ue_info(const ue_info_t& ue_info);
void update_5gmm_state(const std::string& imsi, const std::string& state);
void remove_gnb(const uint32_t gnb_id);
void add_gnb(const uint32_t& gnb_id, const gnb_infos& gnb);
void update_gnb(const uint32_t& gnb_id, const gnb_infos& gnb);
public:
uint32_t gNB_connected;
uint32_t UE_connected;
uint32_t UE_registred;
// uint32_t system_pdu_sessions;
std::map<uint32_t, gnb_infos> gnbs;
mutable std::shared_mutex m_gnbs;
std::map<std::string, ue_info_t> ue_infos;
mutable std::shared_mutex m_ue_infos;
};
#endif
......@@ -53,16 +53,25 @@ void ResetType::setResetType(long nG_Interface) {
this->nG_Interface = nG_Interface;
}
//------------------------------------------------------------------------------
void ResetType::setResetType(
std::vector<UEAssociationLogicalNGConnectionItem> list) {
this->present = Ngap_ResetType_PR_partOfNG_Interface;
UEAssociationLogicalNGConnectionItem* item =
new UEAssociationLogicalNGConnectionItem[list.size()]();
for (int i = 0; i < list.size(); i++) {
item[i].encode(list[i]);
if (!partOfNG_Interface) {
partOfNG_Interface = (UEAssociationLogicalNGConnectionList*) calloc(
1, sizeof(UEAssociationLogicalNGConnectionList));
}
free_wrapper((void**) &item);
partOfNG_Interface->setUEAssociationLogicalNGConnectionItem(list);
}
//------------------------------------------------------------------------------
void ResetType::getResetType(
struct Ngap_UE_associatedLogicalNG_connectionList*&) {
// TODO:
return;
}
//------------------------------------------------------------------------------
bool ResetType::encode(Ngap_ResetType_t* type) {
// TODO:
......@@ -77,15 +86,8 @@ bool ResetType::decode(Ngap_ResetType_t* type) {
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;
}
partOfNG_Interface = new UEAssociationLogicalNGConnectionList();
partOfNG_Interface->decode(type->choice.partOfNG_Interface);
} else {
return false;
}
......@@ -102,15 +104,26 @@ uint8_t ResetType::getResetType() {
}
//------------------------------------------------------------------------------
void ResetType::getResetType(
void ResetType::getUE_associatedLogicalNG_connectionList(
struct Ngap_UE_associatedLogicalNG_connectionList*& list) {
// TODO:
}
//------------------------------------------------------------------------------
void ResetType::setUE_associatedLogicalNG_connectionList(
const std::vector<UEAssociationLogicalNGConnectionItem> list) {
// TODO:
std::vector<UEAssociationLogicalNGConnectionItem> list) {
if (!partOfNG_Interface) {
partOfNG_Interface = new UEAssociationLogicalNGConnectionList();
}
partOfNG_Interface->setUEAssociationLogicalNGConnectionItem(list);
}
//------------------------------------------------------------------------------
void ResetType::getUE_associatedLogicalNG_connectionList(
std::vector<UEAssociationLogicalNGConnectionItem>& list) {
if (partOfNG_Interface) {
partOfNG_Interface->getUEAssociationLogicalNGConnectionItem(list);
}
}
} // namespace ngap
......@@ -30,6 +30,7 @@
#define _RESET_TYPE_H_
#include "UEAssociationLogicalNGConnectionItem.hpp"
#include "UEAssociationLogicalNGConnectionList.hpp"
extern "C" {
#include "Ngap_ResetType.h"
......@@ -44,20 +45,25 @@ class ResetType {
void setResetType(long);
void setResetType(std::vector<UEAssociationLogicalNGConnectionItem> list);
void getResetType(struct Ngap_UE_associatedLogicalNG_connectionList*&);
bool encode(Ngap_ResetType_t* type);
bool decode(Ngap_ResetType_t* type);
void getResetType(long&);
uint8_t getResetType();
void getResetType(struct Ngap_UE_associatedLogicalNG_connectionList*&);
void setUE_associatedLogicalNG_connectionList(
const std::vector<UEAssociationLogicalNGConnectionItem> list);
std::vector<UEAssociationLogicalNGConnectionItem> list);
void getUE_associatedLogicalNG_connectionList(
std::vector<UEAssociationLogicalNGConnectionItem>& list);
void getUE_associatedLogicalNG_connectionList(
struct Ngap_UE_associatedLogicalNG_connectionList*&);
private:
Ngap_ResetType_PR present;
long nG_Interface;
struct Ngap_UE_associatedLogicalNG_connectionList* partOfNG_Interface;
UEAssociationLogicalNGConnectionList* partOfNG_Interface;
UEAssociationLogicalNGConnectionItem* ueAssociationLogicalNGConnectionItem;
// struct Ngap_ProtocolIE_SingleContainer *choice_Extensions;
};
......
......@@ -41,6 +41,7 @@ UEAssociationLogicalNGConnectionItem::UEAssociationLogicalNGConnectionItem() {
amfUeNgapId = nullptr;
ranUeNgapId = nullptr;
}
//------------------------------------------------------------------------------
void UEAssociationLogicalNGConnectionItem::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID();
......@@ -61,6 +62,15 @@ void UEAssociationLogicalNGConnectionItem::setAmfUeNgapId(unsigned long id) {
return;
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::getAmfUeNgapId(unsigned long& id) {
if (amfUeNgapId) {
id = amfUeNgapId->getAMF_UE_NGAP_ID();
return true;
}
return false;
}
//------------------------------------------------------------------------------
void UEAssociationLogicalNGConnectionItem::setRanUeNgapId(
uint32_t ran_ue_ngap_id) {
......@@ -82,6 +92,16 @@ void UEAssociationLogicalNGConnectionItem::setRanUeNgapId(
return;
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::getRanUeNgapId(
uint32_t& ran_ue_ngap_id) {
if (ranUeNgapId) {
ran_ue_ngap_id = ranUeNgapId->getRanUeNgapId();
return true;
}
return false;
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::encode(
Ngap_UE_associatedLogicalNG_connectionItem_t& item) {
......@@ -92,6 +112,16 @@ bool UEAssociationLogicalNGConnectionItem::encode(
return true;
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::encode(
Ngap_UE_associatedLogicalNG_connectionItem_t* item) {
item->aMF_UE_NGAP_ID = new Ngap_AMF_UE_NGAP_ID_t();
amfUeNgapId->encode2AMF_UE_NGAP_ID(*item->aMF_UE_NGAP_ID);
item->rAN_UE_NGAP_ID = new Ngap_RAN_UE_NGAP_ID_t();
ranUeNgapId->encode2RAN_UE_NGAP_ID(*item->rAN_UE_NGAP_ID);
return true;
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::encode(
UEAssociationLogicalNGConnectionItem& item) {
......@@ -102,6 +132,16 @@ bool UEAssociationLogicalNGConnectionItem::encode(
return true;
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::decode(
UEAssociationLogicalNGConnectionItem& item) {
if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(item.amfUeNgapId->getAMF_UE_NGAP_ID());
if (!ranUeNgapId) ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(item.ranUeNgapId->getRanUeNgapId());
return true;
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::decode(
Ngap_UE_associatedLogicalNG_connectionItem_t* item) {
......
......@@ -45,11 +45,15 @@ class UEAssociationLogicalNGConnectionItem {
virtual ~UEAssociationLogicalNGConnectionItem(){};
void setAmfUeNgapId(unsigned long id);
bool getAmfUeNgapId(unsigned long& id);
void setRanUeNgapId(uint32_t id);
bool getRanUeNgapId(uint32_t& id);
bool encode(Ngap_UE_associatedLogicalNG_connectionItem_t& item);
bool encode(Ngap_UE_associatedLogicalNG_connectionItem_t* item);
bool encode(UEAssociationLogicalNGConnectionItem& item);
bool decode(Ngap_UE_associatedLogicalNG_connectionItem_t* item);
bool decode(UEAssociationLogicalNGConnectionItem& item);
private:
AMF_UE_NGAP_ID* amfUeNgapId;
......
/*
* 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 "UEAssociationLogicalNGConnectionList.hpp"
extern "C" {
#include "dynamic_memory_check.h"
}
#include <iostream>
using namespace std;
namespace ngap {
UEAssociationLogicalNGConnectionList::UEAssociationLogicalNGConnectionList() {
ueAssociationLogicalNGConnectionItem = nullptr;
number_of_items = 0;
}
//------------------------------------------------------------------------------
void UEAssociationLogicalNGConnectionList::
setUEAssociationLogicalNGConnectionItem(
UEAssociationLogicalNGConnectionItem*
m_UEAssociationLogicalNGConnectionItem,
int num) {
ueAssociationLogicalNGConnectionItem = m_UEAssociationLogicalNGConnectionItem;
number_of_items = num;
}
//------------------------------------------------------------------------------
void UEAssociationLogicalNGConnectionList::
getUEAssociationLogicalNGConnectionItem(
UEAssociationLogicalNGConnectionItem*&
m_UEAssociationLogicalNGConnectionItem,
int& num) {
m_UEAssociationLogicalNGConnectionItem = ueAssociationLogicalNGConnectionItem;
num = number_of_items;
}
//------------------------------------------------------------------------------
void UEAssociationLogicalNGConnectionList::
setUEAssociationLogicalNGConnectionItem(
std::vector<UEAssociationLogicalNGConnectionItem>& list) {
number_of_items = list.size();
ueAssociationLogicalNGConnectionItem =
new UEAssociationLogicalNGConnectionItem[number_of_items]();
for (int i = 0; i < number_of_items; i++) {
if (!ueAssociationLogicalNGConnectionItem[i].decode(list[i])) return;
}
return;
}
//------------------------------------------------------------------------------
void UEAssociationLogicalNGConnectionList::
getUEAssociationLogicalNGConnectionItem(
std::vector<UEAssociationLogicalNGConnectionItem>& list) {
for (int i = 0; i < number_of_items; i++) {
list.push_back(ueAssociationLogicalNGConnectionItem[i]);
}
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionList::encode(
Ngap_UE_associatedLogicalNG_connectionList_t*
ue_associatedLogicalNG_connectionList) {
for (int i = 0; i < number_of_items; i++) {
Ngap_UE_associatedLogicalNG_connectionItem_t* item =
(Ngap_UE_associatedLogicalNG_connectionItem_t*) calloc(
1, sizeof(Ngap_UE_associatedLogicalNG_connectionItem_t));
if (!item) return false;
if (!ueAssociationLogicalNGConnectionItem[i].encode(*item)) return false;
if (ASN_SEQUENCE_ADD(&ue_associatedLogicalNG_connectionList->list, item) !=
0)
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionList::decode(
Ngap_UE_associatedLogicalNG_connectionList_t*
ue_associatedLogicalNG_connectionList) {
number_of_items = ue_associatedLogicalNG_connectionList->list.count;
ueAssociationLogicalNGConnectionItem =
new UEAssociationLogicalNGConnectionItem[number_of_items]();
for (int i = 0; i < number_of_items; i++) {
if (!ueAssociationLogicalNGConnectionItem[i].decode(
ue_associatedLogicalNG_connectionList->list.array[i]))
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_LIST_H_
#define _UE_ASSOCIATION_LOGICAL_NG_CONNECTION_LIST_H_
#include "UEAssociationLogicalNGConnectionItem.hpp"
#include <vector>
extern "C" {
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_UE-associatedLogicalNG-connectionItem.h"
#include "Ngap_UE-associatedLogicalNG-connectionList.h"
}
namespace ngap {
class UEAssociationLogicalNGConnectionList {
public:
UEAssociationLogicalNGConnectionList();
virtual ~UEAssociationLogicalNGConnectionList(){};
void setUEAssociationLogicalNGConnectionItem(
UEAssociationLogicalNGConnectionItem*
m_UEAssociationLogicalNGConnectionItem,
int num);
void getUEAssociationLogicalNGConnectionItem(
UEAssociationLogicalNGConnectionItem*&
m_UEAssociationLogicalNGConnectionItem,
int& num);
void setUEAssociationLogicalNGConnectionItem(
std::vector<UEAssociationLogicalNGConnectionItem>& list);
void getUEAssociationLogicalNGConnectionItem(
std::vector<UEAssociationLogicalNGConnectionItem>& list);
bool encode(Ngap_UE_associatedLogicalNG_connectionList_t*
ue_associatedLogicalNG_connectionList);
bool decode(Ngap_UE_associatedLogicalNG_connectionList_t*
ue_associatedLogicalNG_connectionList);
private:
UEAssociationLogicalNGConnectionItem* ueAssociationLogicalNGConnectionItem;
int number_of_items;
};
} // 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 2022
\email: contact@openairinterface.org
*/
#include "NGResetAck.hpp"
#include "logger.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
#include "constr_TYPE.h"
#include "constraints.h"
#include "dynamic_memory_check.h"
#include "per_decoder.h"
#include "per_encoder.h"
}
#include <iostream>
#include <vector>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
NGResetAckMsg::NGResetAckMsg() {
ngResetAckPdu = nullptr;
ngResetAckIEs = nullptr;
ueAssociationLogicalNGConnectionList = nullptr;
CriticalityDiagnostics = nullptr;
}
//------------------------------------------------------------------------------
NGResetAckMsg::~NGResetAckMsg() {}
//------------------------------------------------------------------------------
void NGResetAckMsg::setMessageType() {
if (!ngResetAckPdu) {
ngResetAckPdu = (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
}
MessageType NgResetMessageTypeIE;
NgResetMessageTypeIE.setProcedureCode(Ngap_ProcedureCode_id_NGReset);
NgResetMessageTypeIE.setTypeOfMessage(Ngap_NGAP_PDU_PR_successfulOutcome);
NgResetMessageTypeIE.setValuePresent(
Ngap_SuccessfulOutcome__value_PR_NGResetAcknowledge);
if (NgResetMessageTypeIE.getProcedureCode() ==
Ngap_ProcedureCode_id_NGReset &&
NgResetMessageTypeIE.getTypeOfMessage() ==
Ngap_NGAP_PDU_PR_successfulOutcome) {
NgResetMessageTypeIE.encode2pdu(ngResetAckPdu);
ngResetAckIEs = &(ngResetAckPdu->choice.successfulOutcome->value.choice
.NGResetAcknowledge);
} else {
Logger::ngap().warn(
"This information doesn't refer to NGResetAck message!");
}
}
//------------------------------------------------------------------------------
void NGResetAckMsg::setUE_associatedLogicalNG_connectionList(
std::vector<UEAssociationLogicalNGConnectionItem>& list) {
if (!ueAssociationLogicalNGConnectionList) {
ueAssociationLogicalNGConnectionList =
(UEAssociationLogicalNGConnectionList*) calloc(
1, sizeof(UEAssociationLogicalNGConnectionList));
}
ueAssociationLogicalNGConnectionList->setUEAssociationLogicalNGConnectionItem(
list);
addUE_associatedLogicalNG_connectionList();
}
//------------------------------------------------------------------------------
void NGResetAckMsg::getUE_associatedLogicalNG_connectionList(
std::vector<UEAssociationLogicalNGConnectionItem>& list) {
if (ueAssociationLogicalNGConnectionList) {
ueAssociationLogicalNGConnectionList
->getUEAssociationLogicalNGConnectionItem(list);
}
}
//------------------------------------------------------------------------------
void NGResetAckMsg::addUE_associatedLogicalNG_connectionList() {
Ngap_NGResetAcknowledgeIEs_t* ie = (Ngap_NGResetAcknowledgeIEs_t*) calloc(
1, sizeof(Ngap_NGResetAcknowledgeIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_UE_associatedLogicalNG_connectionList;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present =
Ngap_NGResetAcknowledgeIEs__value_PR_UE_associatedLogicalNG_connectionList;
ueAssociationLogicalNGConnectionList->encode(
&ie->value.choice.UE_associatedLogicalNG_connectionList);
int ret = ASN_SEQUENCE_ADD(&ngResetAckIEs->protocolIEs.list, ie);
if (ret != 0)
Logger::ngap().error(
"Encode NGAP UE_associatedLogicalNG_connectionList IE error");
}
//------------------------------------------------------------------------------
int NGResetAckMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, ngResetAckPdu);
asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, ngResetAckPdu, buf, buf_size);
Logger::ngap().debug("er.encoded( %d )", er.encoded);
return er.encoded;
}
//------------------------------------------------------------------------------
bool NGResetAckMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
ngResetAckPdu = ngap_msg_pdu;
if (ngResetAckPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
if (ngResetAckPdu->choice.successfulOutcome &&
ngResetAckPdu->choice.successfulOutcome->procedureCode ==
Ngap_ProcedureCode_id_NGReset &&
ngResetAckPdu->choice.successfulOutcome->criticality ==
Ngap_Criticality_reject &&
ngResetAckPdu->choice.successfulOutcome->value.present ==
Ngap_SuccessfulOutcome__value_PR_NGResetAcknowledge) {
ngResetAckIEs = &ngResetAckPdu->choice.successfulOutcome->value.choice
.NGResetAcknowledge;
for (int i = 0; i < ngResetAckIEs->protocolIEs.list.count; i++) {
switch (ngResetAckIEs->protocolIEs.list.array[i]->id) {
case Ngap_ProtocolIE_ID_id_UE_associatedLogicalNG_connectionList: {
if (ngResetAckIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
ngResetAckIEs->protocolIEs.list.array[i]->value.present ==
Ngap_NGResetAcknowledgeIEs__value_PR_UE_associatedLogicalNG_connectionList) {
ueAssociationLogicalNGConnectionList =
new UEAssociationLogicalNGConnectionList();
if (!ueAssociationLogicalNGConnectionList->decode(
&ngResetAckIEs->protocolIEs.list.array[i]
->value.choice
.UE_associatedLogicalNG_connectionList)) {
Logger::ngap().error(
"Decoded NGAP UE_associatedLogicalNG_connectionList IE "
"error");
return false;
}
} else {
Logger::ngap().error(
"Decoded NGAP UE_associatedLogicalNG_connectionList IE "
"error");
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_CriticalityDiagnostics: {
// TODO:
} break;
default: {
Logger::ngap().error(
"Decoded NGAP NGResetAck message PDU IE error");
return false;
}
}
}
} else {
Logger::ngap().error("Check NGResetAck message error!");
return false;
}
} else {
Logger::ngap().error("Check NGResetAck message error!");
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 _NG_RESET_ACK_H_
#define _NG_RESET_ACK_H_
#include "MessageType.hpp"
#include "NgapIEsStruct.hpp"
#include "UEAssociationLogicalNGConnectionItem.hpp"
#include "UEAssociationLogicalNGConnectionList.hpp"
#include <memory>
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_NGResetAcknowledge.h"
#include "Ngap_UE-associatedLogicalNG-connectionList.h"
#include "Ngap_ProtocolIE-Field.h"
}
namespace ngap {
class NGResetAckMsg {
public:
NGResetAckMsg();
virtual ~NGResetAckMsg();
void setMessageType(); // Initialize the PDU and populate the MessageType;
void setUE_associatedLogicalNG_connectionList(
std::vector<UEAssociationLogicalNGConnectionItem>& list);
void getUE_associatedLogicalNG_connectionList(
std::vector<UEAssociationLogicalNGConnectionItem>& list);
void addUE_associatedLogicalNG_connectionList();
int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
// TODO: CriticalityDiagnostics
private:
Ngap_NGAP_PDU_t* ngResetAckPdu;
Ngap_NGResetAcknowledge_t* ngResetAckIEs;
UEAssociationLogicalNGConnectionList* ueAssociationLogicalNGConnectionList;
std::unique_ptr<Ngap_CriticalityDiagnostics_t> CriticalityDiagnostics;
};
} // namespace ngap
#endif
......@@ -31,6 +31,7 @@
#include "InitialContextSetupResponse.hpp"
#include "NGReset.hpp"
#include "NGResetAck.hpp"
#include "NGSetupRequest.hpp"
#include "PDUSessionResourceSetupUnsuccessfulTransfer.hpp"
#include "PduSessionResourceReleaseResponse.hpp"
......
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