Commit e4f2b911 authored by Niuhaiwen's avatar Niuhaiwen

this is some format correct

parent 2754a665
#ifndef _NGAPIESSTRUCT_H_
#define _NGAPIESSTRUCT_H_
#include <vector>
#include <string>
extern "C"{
#include <OCTET_STRING.h>
#include "Ngap_DelayCritical.h"
#include "Ngap_Pre-emptionCapability.h"
#include "Ngap_Pre-emptionVulnerability.h"
#include "Ngap_NotificationControl.h"
#include "Ngap_ReflectiveQosAttribute.h"
#include "Ngap_AdditionalQosFlowInformation.h"
#include "Ngap_AssociatedQosFlowItem.h"
#include <vector>
extern "C" {
#include "Ngap_AdditionalQosFlowInformation.h"
#include "Ngap_AssociatedQosFlowItem.h"
#include "Ngap_DelayCritical.h"
#include "Ngap_NotificationControl.h"
#include "Ngap_Pre-emptionCapability.h"
#include "Ngap_Pre-emptionVulnerability.h"
#include "Ngap_ReflectiveQosAttribute.h"
#include <OCTET_STRING.h>
}
namespace ngap{
typedef struct SliceSupportItem_s{
std::string sst;
std::string sd;
}SliceSupportItem_t;
typedef struct PlmnSliceSupport_s{
std::string mcc;
std::string mnc;
std::vector<SliceSupportItem_t> slice_list;
}PlmnSliceSupport_t;
typedef struct SupportedItem_s{
uint32_t tac;
std::vector<PlmnSliceSupport_t> b_plmn_list;
}SupportedItem_t;
typedef struct GuamiItem_s{
std::string mcc;
std::string mnc;
std::string regionID;
std::string AmfSetID;
std::string AmfPointer;
std::string backupAMFName;//optional
}GuamiItem_t;
typedef struct NrCgi_s{
std::string mcc;
std::string mnc;
unsigned long nrCellID;
}NrCgi_t;
typedef struct Tai_s{
std::string mcc;
std::string mnc;
uint32_t tac:24;
}Tai_t;
typedef struct Guami_s{
std::string mcc;
std::string mnc;
std::string regionID;
std::string AmfSetID;
std::string AmfPointer;
}Guami_t;
typedef struct{
std::string sst;
std::string sd;//可选
}S_Nssai;
typedef struct{
uint8_t pduSessionId;
uint8_t *pduSessionNAS_PDU;
size_t sizeofpduSessionNAS_PDU;
S_Nssai s_nssai;
OCTET_STRING_t pduSessionResourceSetupRequestTransfer;
}PDUSessionResourceSetupRequestItem_t;
typedef struct{
std::string ip_address;
uint32_t gtp_teid;
}GtpTunnel_t;
typedef struct{
long _5QI;
long *priorityLevelQos;
long *averagingWindow;
long *maximumDataBurstVolume;
}NonDynamic5QI_t;
typedef struct{
long pERScalar;
long pERExponent;
}PacketErrorRate_t;
typedef struct{
long priorityLevelQos;
long packetDelayBudget;
PacketErrorRate_t packetErrorRate;
long *_5QI;
e_Ngap_DelayCritical *delayCritical;
long *averagingWindow;
long *maximumDataBurstVolume;
}Dynamic5QI_t;
typedef struct{
NonDynamic5QI_t *nonDy;
Dynamic5QI_t *dy;
}QosCharacteristics_t;
typedef struct{
long priorityLevelARP;
e_Ngap_Pre_emptionCapability pre_emptionCapability;
e_Ngap_Pre_emptionVulnerability pre_emptionVulnerability;
}AllocationAndRetentionPriority_t;
typedef struct{
long maximumFlowBitRateDL;
long maximumFlowBitRateUL;
long guaranteedFlowBitRateDL;
long guaranteedFlowBitRateUL;
e_Ngap_NotificationControl *notificationControl;
long *maximumPacketLossRateDL;
long *maximumPacketLossRateUL;
}GBR_QosInformation_t;
typedef struct{
QosCharacteristics_t qosc;
AllocationAndRetentionPriority_t arp;
GBR_QosInformation_t *gbr_qos_info;
e_Ngap_ReflectiveQosAttribute *reflectiveQosAttribute;
e_Ngap_AdditionalQosFlowInformation *additionalQosFlowInformation;
}QosFlowLevelQosParameters_t;
typedef struct{
long qos_flow_id;
QosFlowLevelQosParameters_t qflqp;
}QosFlowSetupReq_t;
typedef struct{
long qosFlowIdentifier;
e_Ngap_AssociatedQosFlowItem__qosFlowMappingIndication *qosFlowMappingIndication;
}AssociatedQosFlow_t;
typedef struct{
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupResponseTransfer;
}PDUSessionResourceSetupResponseItem_t;
typedef struct{
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupUnsuccessfulTransfer;
}PDUSessionResourceFailedToSetupItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceReleaseCommandTransfer;
}PDUSessionResourceReleaseCommandItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t HandoverRequiredTransfer;
}PDUSessionResourceItem_t;
typedef struct {
uint8_t pduSessionId;
S_Nssai s_nssai;
OCTET_STRING_t pduSessionResourceSetupRequestTransfer;
}PDUSessionResourceSetupItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t handoverRequestAcknowledgeTransfer;
}PDUSessionResourceAdmittedItem_t;
}
namespace ngap {
typedef struct SliceSupportItem_s {
std::string sst;
std::string sd;
} SliceSupportItem_t;
typedef struct PlmnSliceSupport_s {
std::string mcc;
std::string mnc;
std::vector<SliceSupportItem_t> slice_list;
} PlmnSliceSupport_t;
typedef struct SupportedItem_s {
uint32_t tac;
std::vector<PlmnSliceSupport_t> b_plmn_list;
} SupportedItem_t;
typedef struct GuamiItem_s {
std::string mcc;
std::string mnc;
std::string regionID;
std::string AmfSetID;
std::string AmfPointer;
std::string backupAMFName; // optional
} GuamiItem_t;
typedef struct NrCgi_s {
std::string mcc;
std::string mnc;
unsigned long nrCellID;
} NrCgi_t;
typedef struct Tai_s {
std::string mcc;
std::string mnc;
uint32_t tac : 24;
} Tai_t;
typedef struct Guami_s {
std::string mcc;
std::string mnc;
std::string regionID;
std::string AmfSetID;
std::string AmfPointer;
} Guami_t;
typedef struct {
std::string sst;
std::string sd; //可选
} S_Nssai;
typedef struct {
uint8_t pduSessionId;
uint8_t *pduSessionNAS_PDU;
size_t sizeofpduSessionNAS_PDU;
S_Nssai s_nssai;
OCTET_STRING_t pduSessionResourceSetupRequestTransfer;
} PDUSessionResourceSetupRequestItem_t;
typedef struct {
std::string ip_address;
uint32_t gtp_teid;
} GtpTunnel_t;
typedef struct {
long _5QI;
long *priorityLevelQos;
long *averagingWindow;
long *maximumDataBurstVolume;
} NonDynamic5QI_t;
typedef struct {
long pERScalar;
long pERExponent;
} PacketErrorRate_t;
typedef struct {
long priorityLevelQos;
long packetDelayBudget;
PacketErrorRate_t packetErrorRate;
long *_5QI;
e_Ngap_DelayCritical *delayCritical;
long *averagingWindow;
long *maximumDataBurstVolume;
} Dynamic5QI_t;
typedef struct {
NonDynamic5QI_t *nonDy;
Dynamic5QI_t *dy;
} QosCharacteristics_t;
typedef struct {
long priorityLevelARP;
e_Ngap_Pre_emptionCapability pre_emptionCapability;
e_Ngap_Pre_emptionVulnerability pre_emptionVulnerability;
} AllocationAndRetentionPriority_t;
typedef struct {
long maximumFlowBitRateDL;
long maximumFlowBitRateUL;
long guaranteedFlowBitRateDL;
long guaranteedFlowBitRateUL;
e_Ngap_NotificationControl *notificationControl;
long *maximumPacketLossRateDL;
long *maximumPacketLossRateUL;
} GBR_QosInformation_t;
typedef struct {
QosCharacteristics_t qosc;
AllocationAndRetentionPriority_t arp;
GBR_QosInformation_t *gbr_qos_info;
e_Ngap_ReflectiveQosAttribute *reflectiveQosAttribute;
e_Ngap_AdditionalQosFlowInformation *additionalQosFlowInformation;
} QosFlowLevelQosParameters_t;
typedef struct {
long qos_flow_id;
QosFlowLevelQosParameters_t qflqp;
} QosFlowSetupReq_t;
typedef struct {
long qosFlowIdentifier;
e_Ngap_AssociatedQosFlowItem__qosFlowMappingIndication
*qosFlowMappingIndication;
} AssociatedQosFlow_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupResponseTransfer;
} PDUSessionResourceSetupResponseItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupUnsuccessfulTransfer;
} PDUSessionResourceFailedToSetupItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceReleaseCommandTransfer;
} PDUSessionResourceReleaseCommandItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t HandoverRequiredTransfer;
} PDUSessionResourceItem_t;
typedef struct {
uint8_t pduSessionId;
S_Nssai s_nssai;
OCTET_STRING_t pduSessionResourceSetupRequestTransfer;
} PDUSessionResourceSetupItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t handoverRequestAcknowledgeTransfer;
} PDUSessionResourceAdmittedItem_t;
typedef struct {
Ngap_QosFlowIdentifier_t qosFlowIdentifier;
} QosFlowLItemWithDataForwarding_t;
} // namespace ngap
#endif
......@@ -2,33 +2,35 @@
#define _PDUSESSIONRESOURCEADMITTEDITEM_H_
#include "PDUSessionID.hpp"
extern "C"{
#include "Ngap_PDUSessionResourceAdmittedItem.h"
#include "PDUSessionResourceHandoverRequestAckTransfer.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceAdmittedItem.h"
}
namespace ngap{
class PDUSessionResourceAdmittedItem {
public:
PDUSessionResourceAdmittedItem();
virtual ~PDUSessionResourceAdmittedItem();
void setPDUSessionResourceAdmittedItem(PDUSessionID *m_pDUSessionID, OCTET_STRING_t m_handoverrequestAcktransfer);
void getPDUSessionResourceAdmittedItem(PDUSessionID *&m_pDUSessionID, OCTET_STRING_t &m_handoverrequestAcktransfer);
bool encode2PDUSessionResourceAdmittedItem(Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem);
bool decodefromPDUSessionResourceAdmittedItem(Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem);
private:
PDUSessionID *pDUSessionID;
OCTET_STRING_t handoverrequestAcktransfer;
};
namespace ngap {
}
#endif
class PDUSessionResourceAdmittedItem {
public:
PDUSessionResourceAdmittedItem();
virtual ~PDUSessionResourceAdmittedItem();
void setPDUSessionResourceAdmittedItem(
PDUSessionID *m_pDUSessionID,
OCTET_STRING_t m_handoverrequestAcktransfer);
void getPDUSessionResourceAdmittedItem(
PDUSessionID *&m_pDUSessionID,
OCTET_STRING_t &m_handoverrequestAcktransfer);
bool encode2PDUSessionResourceAdmittedItem(
Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem);
bool decodefromPDUSessionResourceAdmittedItem(
Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem);
private:
PDUSessionID *pDUSessionID;
OCTET_STRING_t handoverrequestAcktransfer;
};
} // namespace ngap
#endif
#include "PDUSessionResourceItemHORqd.hpp"
#include <iostream>
using namespace std;
namespace ngap{
PDUSessionResourceItemHORqd::PDUSessionResourceItemHORqd()
{
pDUSessionID = NULL;
}
PDUSessionResourceItemHORqd::~PDUSessionResourceItemHORqd(){}
void PDUSessionResourceItemHORqd::setPDUSessionResourceItemHORqd(PDUSessionID *m_pDUSessionID, OCTET_STRING_t m_handoverrequiredtransfer)
{
pDUSessionID = m_pDUSessionID;
handoverrequiredtransfer = m_handoverrequiredtransfer;
}
bool PDUSessionResourceItemHORqd::encode2PDUSessionResourceItemHORqd(Ngap_PDUSessionResourceItemHORqd_t *pdUSessionResourceItemHORqd)
{
if(!pDUSessionID) return false;
if(!pDUSessionID->encode2PDUSessionID(pdUSessionResourceItemHORqd->pDUSessionID)) return false;
pdUSessionResourceItemHORqd->handoverRequiredTransfer = handoverrequiredtransfer;
return true;
}
bool PDUSessionResourceItemHORqd::decodefromPDUSessionResourceItemHORqd(Ngap_PDUSessionResourceItemHORqd_t *pdUSessionResourceItemHORqd)
{
pDUSessionID = new PDUSessionID();
if(!pDUSessionID->decodefromPDUSessionID(pdUSessionResourceItemHORqd->pDUSessionID)) return false;
handoverrequiredtransfer = pdUSessionResourceItemHORqd->handoverRequiredTransfer;
return true;
}
void PDUSessionResourceItemHORqd::getPDUSessionResourceItemHORqd(PDUSessionID *&m_pDUSessionID, OCTET_STRING_t &m_handoverrequiredtransfer)
{
m_pDUSessionID = pDUSessionID;
m_handoverrequiredtransfer = handoverrequiredtransfer;
}
}
#include <iostream>
using namespace std;
namespace ngap {
PDUSessionResourceItemHORqd::PDUSessionResourceItemHORqd() {
pDUSessionID = NULL;
}
PDUSessionResourceItemHORqd::~PDUSessionResourceItemHORqd() {}
void PDUSessionResourceItemHORqd::setPDUSessionResourceItemHORqd(
PDUSessionID *m_pDUSessionID, OCTET_STRING_t m_handoverrequiredtransfer) {
pDUSessionID = m_pDUSessionID;
handoverrequiredtransfer = m_handoverrequiredtransfer;
}
bool PDUSessionResourceItemHORqd::encode2PDUSessionResourceItemHORqd(
Ngap_PDUSessionResourceItemHORqd_t *pdUSessionResourceItemHORqd) {
if (!pDUSessionID)
return false;
if (!pDUSessionID->encode2PDUSessionID(
pdUSessionResourceItemHORqd->pDUSessionID))
return false;
pdUSessionResourceItemHORqd->handoverRequiredTransfer =
handoverrequiredtransfer;
return true;
}
bool PDUSessionResourceItemHORqd::decodefromPDUSessionResourceItemHORqd(
Ngap_PDUSessionResourceItemHORqd_t *pdUSessionResourceItemHORqd) {
pDUSessionID = new PDUSessionID();
if (!pDUSessionID->decodefromPDUSessionID(
pdUSessionResourceItemHORqd->pDUSessionID))
return false;
handoverrequiredtransfer =
pdUSessionResourceItemHORqd->handoverRequiredTransfer;
return true;
}
void PDUSessionResourceItemHORqd::getPDUSessionResourceItemHORqd(
PDUSessionID *&m_pDUSessionID, OCTET_STRING_t &m_handoverrequiredtransfer) {
m_pDUSessionID = pDUSessionID;
m_handoverrequiredtransfer = handoverrequiredtransfer;
}
} // namespace ngap
......@@ -2,33 +2,35 @@
#define _PDUSESSIONRESOURCEITEMHQRQD_H_
#include "PDUSessionID.hpp"
extern "C"{
#include "Ngap_PDUSessionResourceItemHORqd.h"
#include "PDUSessionResourceHandoverRequestAckTransfer.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceItemHORqd.h"
}
namespace ngap{
class PDUSessionResourceItemHORqd{
public:
PDUSessionResourceItemHORqd();
virtual ~PDUSessionResourceItemHORqd();
void setPDUSessionResourceItemHORqd(PDUSessionID *m_pDUSessionID, OCTET_STRING_t m_handoverrequiredtransfer);
void getPDUSessionResourceItemHORqd(PDUSessionID *&m_pDUSessionID, OCTET_STRING_t &m_handoverrequiredtransfer);
bool encode2PDUSessionResourceItemHORqd(Ngap_PDUSessionResourceItemHORqd_t *pdUSessionResourceItemHORqd);
bool decodefromPDUSessionResourceItemHORqd(Ngap_PDUSessionResourceItemHORqd_t *pdUSessionResourceItemHORqd);
private:
PDUSessionID *pDUSessionID;
OCTET_STRING_t handoverrequiredtransfer;
};
namespace ngap {
}
#endif
class PDUSessionResourceItemHORqd {
public:
PDUSessionResourceItemHORqd();
virtual ~PDUSessionResourceItemHORqd();
void
setPDUSessionResourceItemHORqd(PDUSessionID *m_pDUSessionID,
OCTET_STRING_t m_handoverrequiredtransfer);
void
getPDUSessionResourceItemHORqd(PDUSessionID *&m_pDUSessionID,
OCTET_STRING_t &m_handoverrequiredtransfer);
bool encode2PDUSessionResourceItemHORqd(
Ngap_PDUSessionResourceItemHORqd_t *pdUSessionResourceItemHORqd);
bool decodefromPDUSessionResourceItemHORqd(
Ngap_PDUSessionResourceItemHORqd_t *pdUSessionResourceItemHORqd);
private:
PDUSessionID *pDUSessionID;
OCTET_STRING_t handoverrequiredtransfer;
};
} // 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 ngap_message_callback.cpp
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _HANDOVERNOTIFYMSG_H_
#define _HANDOVERNOTIFYMSG_H_
......
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -26,15 +26,15 @@
\email: contact@openairinterface.org
*/
#include "sctp_server.hpp"
#include "ngap_app.hpp"
#include "logger.hpp"
#include "amf_module_from_config.hpp"
#include "logger.hpp"
#include "ngap_message_callback.hpp"
#include "sctp_server.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_InitiatingMessage.h"
#include "Ngap_NGAP-PDU.h"
}
using namespace sctp;
......@@ -43,47 +43,66 @@ using namespace ngap;
//------------------------------------------------------------------------------
ngap_app::ngap_app(const std::string &address, const uint16_t port_num)
:
ppid_(60),
sctp_s_38412(address.c_str(), port_num) {
: ppid_(60), sctp_s_38412(address.c_str(), port_num) {
sctp_s_38412.start_receive(this);
Logger::ngap().info("Set N2 AMF IPv4 Addr, port: %s, %d", address.c_str(), port_num);
Logger::ngap().info("Set N2 AMF IPv4 Addr, port: %s, %d", address.c_str(),
port_num);
}
//------------------------------------------------------------------------------
ngap_app::~ngap_app() {
}
ngap_app::~ngap_app() {}
//------------------------------------------------------------------------------
// received sctp payload and decode it to NGAP message and send itti message to TASK_AMF_N2
void ngap_app::handle_receive(bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream, sctp_stream_id_t instreams, sctp_stream_id_t outstreams) {
Logger::ngap().debug("Handling SCTP payload from sctp_server on assoc_id (%d), stream_id (%d), instreams (%d), outstreams (%d)", assoc_id, stream, instreams, outstreams);
Ngap_NGAP_PDU_t *ngap_msg_pdu = (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
asn_dec_rval_t rc = asn_decode(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_Ngap_NGAP_PDU, (void**) &ngap_msg_pdu, bdata(payload), blength(payload));
Logger::ngap().debug("Decoded NGAP message, procedure code %d, present %d", ngap_msg_pdu->choice.initiatingMessage->procedureCode, ngap_msg_pdu->present);
(*messages_callback[ngap_msg_pdu->choice.initiatingMessage->procedureCode][ngap_msg_pdu->present - 1])(assoc_id, stream, ngap_msg_pdu);
// received sctp payload and decode it to NGAP message and send itti message to
// TASK_AMF_N2
void ngap_app::handle_receive(bstring payload, sctp_assoc_id_t assoc_id,
sctp_stream_id_t stream,
sctp_stream_id_t instreams,
sctp_stream_id_t outstreams) {
Logger::ngap().debug("Handling SCTP payload from sctp_server on assoc_id "
"(%d), stream_id (%d), instreams (%d), outstreams (%d)",
assoc_id, stream, instreams, outstreams);
Ngap_NGAP_PDU_t *ngap_msg_pdu =
(Ngap_NGAP_PDU_t *)calloc(1, sizeof(Ngap_NGAP_PDU_t));
asn_dec_rval_t rc =
asn_decode(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_Ngap_NGAP_PDU,
(void **)&ngap_msg_pdu, bdata(payload), blength(payload));
Logger::ngap().debug("Decoded NGAP message, procedure code %d, present %d",
ngap_msg_pdu->choice.initiatingMessage->procedureCode,
ngap_msg_pdu->present);
(*messages_callback[ngap_msg_pdu->choice.initiatingMessage->procedureCode]
[ngap_msg_pdu->present - 1])(assoc_id, stream,
ngap_msg_pdu);
}
//------------------------------------------------------------------------------
//handle new sctp association
// handle new sctp association
// TNL association(clause 8.7.1.1, 3gpp ts38.413)
void ngap_app::handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream_id_t instreams, sctp_stream_id_t outstreams) {
Logger::ngap().debug("Ready to handle new NGAP SCTP association (id: %d) request", assoc_id);
void ngap_app::handle_sctp_new_association(sctp_assoc_id_t assoc_id,
sctp_stream_id_t instreams,
sctp_stream_id_t outstreams) {
Logger::ngap().debug(
"Ready to handle new NGAP SCTP association (id: %d) request", assoc_id);
std::shared_ptr<gnb_context> gc;
if (!is_assoc_id_2_gnb_context(assoc_id)) {
Logger::ngap().debug("Create a new gNB context with assoc_id (%d)", assoc_id);
gc = std::shared_ptr < gnb_context > (new gnb_context());
Logger::ngap().debug("Create a new gNB context with assoc_id (%d)",
assoc_id);
gc = std::shared_ptr<gnb_context>(new gnb_context());
set_assoc_id_2_gnb_context(assoc_id, gc);
} else {
gc = assoc_id_2_gnb_context(assoc_id);
if (gc.get()->ng_state == NGAP_RESETING || gc.get()->ng_state == NGAP_SHUTDOWN) {
Logger::ngap().warn("Received new association request on an association that is being %s, ignoring", ng_gnb_state_str[gc.get()->ng_state]);
if (gc.get()->ng_state == NGAP_RESETING ||
gc.get()->ng_state == NGAP_SHUTDOWN) {
Logger::ngap().warn("Received new association request on an association "
"that is being %s, ignoring",
ng_gnb_state_str[gc.get()->ng_state]);
} else {
Logger::ngap().debug("Update gNB context with assoc id (%d)", assoc_id);
}
}
if (gc.get() == nullptr) {
Logger::ngap().error("Failed to create gNB context for assoc_id(%d)", assoc_id);
Logger::ngap().error("Failed to create gNB context for assoc_id(%d)",
assoc_id);
} else {
gc.get()->sctp_assoc_id = assoc_id;
gc.get()->instreams = instreams;
......@@ -94,25 +113,43 @@ void ngap_app::handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream
}
//------------------------------------------------------------------------------
uint32_t ngap_app::getPpid() {
return ppid_;
}
uint32_t ngap_app::getPpid() { return ppid_; }
//gnb context management
// gnb context management
//------------------------------------------------------------------------------
bool ngap_app::is_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const {
bool ngap_app::is_assoc_id_2_gnb_context(
const sctp_assoc_id_t &assoc_id) const {
std::shared_lock lock(m_assoc2gnbContext);
return bool { assoc2gnbContext.count(assoc_id) > 0 };
return bool{assoc2gnbContext.count(assoc_id) > 0};
}
//------------------------------------------------------------------------------
std::shared_ptr<gnb_context> ngap_app::assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const {
std::shared_ptr<gnb_context>
ngap_app::assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const {
std::shared_lock lock(m_assoc2gnbContext);
return assoc2gnbContext.at(assoc_id);
}
//------------------------------------------------------------------------------
void ngap_app::set_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id, std::shared_ptr<gnb_context> gc) {
void ngap_app::set_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id,
std::shared_ptr<gnb_context> gc) {
std::shared_lock lock(m_assoc2gnbContext);
assoc2gnbContext[assoc_id] = gc;
}
bool ngap_app::is_gnb_id_2_gnb_context(const long &gnb_id) const {
std::shared_lock lock(m_gnbid2gnbContext);
return bool{gnbid2gnbContext.count(gnb_id) > 0};
}
std::shared_ptr<gnb_context>
ngap_app::gnb_id_2_gnb_context(const long &gnb_id) const {
std::shared_lock lock(m_gnbid2gnbContext);
return gnbid2gnbContext.at(gnb_id);
}
void ngap_app::set_gnb_id_2_gnb_context(const long &gnb_id,
std::shared_ptr<gnb_context> gc) {
std::shared_lock lock(m_gnbid2gnbContext);
gnbid2gnbContext[gnb_id] = gc;
}
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -29,8 +29,8 @@
#ifndef _NGAP_APPLICATION_H_
#define _NGAP_APPLICATION_H_
#include "sctp_server.hpp"
#include "gNB_context.hpp"
#include "sctp_server.hpp"
#include <map>
#include <set>
#include <shared_mutex>
......@@ -41,29 +41,41 @@ using namespace sctp;
namespace ngap {
static const char *const ng_gnb_state_str[] = { "NGAP_INIT", "NGAP_RESETTING", "NGAP_READY", "NGAP_SHUTDOWN" };
static const char *const ng_gnb_state_str[] = {"NGAP_INIT", "NGAP_RESETTING",
"NGAP_READY", "NGAP_SHUTDOWN"};
class ngap_app : public sctp_application {
public:
public:
ngap_app(const std::string &address, const uint16_t port_num);
~ngap_app();
uint32_t getPpid();
void handle_receive(bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream, sctp_stream_id_t instreams, sctp_stream_id_t outstreams);
void handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream_id_t instreams, sctp_stream_id_t outstreams);
void handle_receive(bstring payload, sctp_assoc_id_t assoc_id,
sctp_stream_id_t stream, sctp_stream_id_t instreams,
sctp_stream_id_t outstreams);
void handle_sctp_new_association(sctp_assoc_id_t assoc_id,
sctp_stream_id_t instreams,
sctp_stream_id_t outstreams);
bool is_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const;
void set_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id, std::shared_ptr<gnb_context> gc);
std::shared_ptr<gnb_context> assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const;
void set_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id,
std::shared_ptr<gnb_context> gc);
std::shared_ptr<gnb_context>
assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const;
bool is_gnb_id_2_gnb_context(const long &gnb_id) const;
void set_gnb_id_2_gnb_context(const long &gnb_id,
std::shared_ptr<gnb_context> gc);
std::shared_ptr<gnb_context> gnb_id_2_gnb_context(const long &gnb_id) const;
protected:
protected:
sctp_server sctp_s_38412;
uint32_t ppid_;
std::map<sctp_assoc_id_t, std::shared_ptr<gnb_context>> assoc2gnbContext;
mutable std::shared_mutex m_assoc2gnbContext;
std::map<long, std::shared_ptr<gnb_context>> gnbid2gnbContext;
mutable std::shared_mutex m_gnbid2gnbContext;
};
}
} // namespace ngap
#endif
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