Commit e4f2b911 authored by Niuhaiwen's avatar Niuhaiwen

this is some format correct

parent 2754a665
#ifndef _NGAPIESSTRUCT_H_ #ifndef _NGAPIESSTRUCT_H_
#define _NGAPIESSTRUCT_H_ #define _NGAPIESSTRUCT_H_
#include <vector>
#include <string> #include <string>
#include <vector>
extern "C"{ extern "C" {
#include <OCTET_STRING.h> #include "Ngap_AdditionalQosFlowInformation.h"
#include "Ngap_DelayCritical.h" #include "Ngap_AssociatedQosFlowItem.h"
#include "Ngap_Pre-emptionCapability.h" #include "Ngap_DelayCritical.h"
#include "Ngap_Pre-emptionVulnerability.h" #include "Ngap_NotificationControl.h"
#include "Ngap_NotificationControl.h" #include "Ngap_Pre-emptionCapability.h"
#include "Ngap_ReflectiveQosAttribute.h" #include "Ngap_Pre-emptionVulnerability.h"
#include "Ngap_AdditionalQosFlowInformation.h" #include "Ngap_ReflectiveQosAttribute.h"
#include "Ngap_AssociatedQosFlowItem.h" #include <OCTET_STRING.h>
} }
namespace ngap{ namespace ngap {
typedef struct SliceSupportItem_s{ typedef struct SliceSupportItem_s {
std::string sst; std::string sst;
std::string sd; std::string sd;
}SliceSupportItem_t; } SliceSupportItem_t;
typedef struct PlmnSliceSupport_s{ typedef struct PlmnSliceSupport_s {
std::string mcc; std::string mcc;
std::string mnc; std::string mnc;
std::vector<SliceSupportItem_t> slice_list; std::vector<SliceSupportItem_t> slice_list;
}PlmnSliceSupport_t; } PlmnSliceSupport_t;
typedef struct SupportedItem_s{ typedef struct SupportedItem_s {
uint32_t tac; uint32_t tac;
std::vector<PlmnSliceSupport_t> b_plmn_list; std::vector<PlmnSliceSupport_t> b_plmn_list;
}SupportedItem_t; } SupportedItem_t;
typedef struct GuamiItem_s{ typedef struct GuamiItem_s {
std::string mcc; std::string mcc;
std::string mnc; std::string mnc;
std::string regionID; std::string regionID;
std::string AmfSetID; std::string AmfSetID;
std::string AmfPointer; std::string AmfPointer;
std::string backupAMFName;//optional std::string backupAMFName; // optional
}GuamiItem_t; } GuamiItem_t;
typedef struct NrCgi_s{ typedef struct NrCgi_s {
std::string mcc; std::string mcc;
std::string mnc; std::string mnc;
unsigned long nrCellID; unsigned long nrCellID;
}NrCgi_t; } NrCgi_t;
typedef struct Tai_s{ typedef struct Tai_s {
std::string mcc; std::string mcc;
std::string mnc; std::string mnc;
uint32_t tac:24; uint32_t tac : 24;
}Tai_t; } Tai_t;
typedef struct Guami_s{ typedef struct Guami_s {
std::string mcc; std::string mcc;
std::string mnc; std::string mnc;
std::string regionID; std::string regionID;
std::string AmfSetID; std::string AmfSetID;
std::string AmfPointer; std::string AmfPointer;
}Guami_t; } Guami_t;
typedef struct{ typedef struct {
std::string sst; std::string sst;
std::string sd;//可选 std::string sd; //可选
}S_Nssai; } S_Nssai;
typedef struct{ typedef struct {
uint8_t pduSessionId; uint8_t pduSessionId;
uint8_t *pduSessionNAS_PDU; uint8_t *pduSessionNAS_PDU;
size_t sizeofpduSessionNAS_PDU; size_t sizeofpduSessionNAS_PDU;
S_Nssai s_nssai; S_Nssai s_nssai;
OCTET_STRING_t pduSessionResourceSetupRequestTransfer; OCTET_STRING_t pduSessionResourceSetupRequestTransfer;
}PDUSessionResourceSetupRequestItem_t; } PDUSessionResourceSetupRequestItem_t;
typedef struct{ typedef struct {
std::string ip_address; std::string ip_address;
uint32_t gtp_teid; uint32_t gtp_teid;
}GtpTunnel_t; } GtpTunnel_t;
typedef struct{ typedef struct {
long _5QI; long _5QI;
long *priorityLevelQos; long *priorityLevelQos;
long *averagingWindow; long *averagingWindow;
long *maximumDataBurstVolume; long *maximumDataBurstVolume;
}NonDynamic5QI_t; } NonDynamic5QI_t;
typedef struct{ typedef struct {
long pERScalar; long pERScalar;
long pERExponent; long pERExponent;
}PacketErrorRate_t; } PacketErrorRate_t;
typedef struct{ typedef struct {
long priorityLevelQos; long priorityLevelQos;
long packetDelayBudget; long packetDelayBudget;
PacketErrorRate_t packetErrorRate; PacketErrorRate_t packetErrorRate;
long *_5QI; long *_5QI;
e_Ngap_DelayCritical *delayCritical; e_Ngap_DelayCritical *delayCritical;
long *averagingWindow; long *averagingWindow;
long *maximumDataBurstVolume; long *maximumDataBurstVolume;
}Dynamic5QI_t; } Dynamic5QI_t;
typedef struct{ typedef struct {
NonDynamic5QI_t *nonDy; NonDynamic5QI_t *nonDy;
Dynamic5QI_t *dy; Dynamic5QI_t *dy;
}QosCharacteristics_t; } QosCharacteristics_t;
typedef struct{ typedef struct {
long priorityLevelARP; long priorityLevelARP;
e_Ngap_Pre_emptionCapability pre_emptionCapability; e_Ngap_Pre_emptionCapability pre_emptionCapability;
e_Ngap_Pre_emptionVulnerability pre_emptionVulnerability; e_Ngap_Pre_emptionVulnerability pre_emptionVulnerability;
}AllocationAndRetentionPriority_t; } AllocationAndRetentionPriority_t;
typedef struct{ typedef struct {
long maximumFlowBitRateDL; long maximumFlowBitRateDL;
long maximumFlowBitRateUL; long maximumFlowBitRateUL;
long guaranteedFlowBitRateDL; long guaranteedFlowBitRateDL;
long guaranteedFlowBitRateUL; long guaranteedFlowBitRateUL;
e_Ngap_NotificationControl *notificationControl; e_Ngap_NotificationControl *notificationControl;
long *maximumPacketLossRateDL; long *maximumPacketLossRateDL;
long *maximumPacketLossRateUL; long *maximumPacketLossRateUL;
}GBR_QosInformation_t; } GBR_QosInformation_t;
typedef struct{ typedef struct {
QosCharacteristics_t qosc; QosCharacteristics_t qosc;
AllocationAndRetentionPriority_t arp; AllocationAndRetentionPriority_t arp;
GBR_QosInformation_t *gbr_qos_info; GBR_QosInformation_t *gbr_qos_info;
e_Ngap_ReflectiveQosAttribute *reflectiveQosAttribute; e_Ngap_ReflectiveQosAttribute *reflectiveQosAttribute;
e_Ngap_AdditionalQosFlowInformation *additionalQosFlowInformation; e_Ngap_AdditionalQosFlowInformation *additionalQosFlowInformation;
}QosFlowLevelQosParameters_t; } QosFlowLevelQosParameters_t;
typedef struct{ typedef struct {
long qos_flow_id; long qos_flow_id;
QosFlowLevelQosParameters_t qflqp; QosFlowLevelQosParameters_t qflqp;
}QosFlowSetupReq_t; } QosFlowSetupReq_t;
typedef struct{ typedef struct {
long qosFlowIdentifier; long qosFlowIdentifier;
e_Ngap_AssociatedQosFlowItem__qosFlowMappingIndication *qosFlowMappingIndication; e_Ngap_AssociatedQosFlowItem__qosFlowMappingIndication
}AssociatedQosFlow_t; *qosFlowMappingIndication;
} AssociatedQosFlow_t;
typedef struct{ typedef struct {
uint8_t pduSessionId; uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupResponseTransfer; OCTET_STRING_t pduSessionResourceSetupResponseTransfer;
}PDUSessionResourceSetupResponseItem_t; } PDUSessionResourceSetupResponseItem_t;
typedef struct{ typedef struct {
uint8_t pduSessionId; uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupUnsuccessfulTransfer; OCTET_STRING_t pduSessionResourceSetupUnsuccessfulTransfer;
}PDUSessionResourceFailedToSetupItem_t; } PDUSessionResourceFailedToSetupItem_t;
typedef struct { typedef struct {
uint8_t pduSessionId; uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceReleaseCommandTransfer; OCTET_STRING_t pduSessionResourceReleaseCommandTransfer;
}PDUSessionResourceReleaseCommandItem_t; } PDUSessionResourceReleaseCommandItem_t;
typedef struct { typedef struct {
uint8_t pduSessionId; uint8_t pduSessionId;
OCTET_STRING_t HandoverRequiredTransfer; OCTET_STRING_t HandoverRequiredTransfer;
}PDUSessionResourceItem_t; } PDUSessionResourceItem_t;
typedef struct { typedef struct {
uint8_t pduSessionId; uint8_t pduSessionId;
S_Nssai s_nssai; S_Nssai s_nssai;
OCTET_STRING_t pduSessionResourceSetupRequestTransfer; OCTET_STRING_t pduSessionResourceSetupRequestTransfer;
}PDUSessionResourceSetupItem_t; } PDUSessionResourceSetupItem_t;
typedef struct {
typedef struct { uint8_t pduSessionId;
uint8_t pduSessionId; OCTET_STRING_t handoverRequestAcknowledgeTransfer;
OCTET_STRING_t handoverRequestAcknowledgeTransfer; } PDUSessionResourceAdmittedItem_t;
}PDUSessionResourceAdmittedItem_t;
} typedef struct {
Ngap_QosFlowIdentifier_t qosFlowIdentifier;
} QosFlowLItemWithDataForwarding_t;
} // namespace ngap
#endif #endif
...@@ -2,33 +2,35 @@ ...@@ -2,33 +2,35 @@
#define _PDUSESSIONRESOURCEADMITTEDITEM_H_ #define _PDUSESSIONRESOURCEADMITTEDITEM_H_
#include "PDUSessionID.hpp" #include "PDUSessionID.hpp"
#include "PDUSessionResourceHandoverRequestAckTransfer.hpp"
extern "C"{ extern "C" {
#include "Ngap_PDUSessionResourceAdmittedItem.h" #include "Ngap_PDUSessionResourceAdmittedItem.h"
} }
namespace ngap{ 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;
};
} class PDUSessionResourceAdmittedItem {
public:
#endif 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 "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 @@ ...@@ -2,33 +2,35 @@
#define _PDUSESSIONRESOURCEITEMHQRQD_H_ #define _PDUSESSIONRESOURCEITEMHQRQD_H_
#include "PDUSessionID.hpp" #include "PDUSessionID.hpp"
#include "PDUSessionResourceHandoverRequestAckTransfer.hpp"
extern "C"{ extern "C" {
#include "Ngap_PDUSessionResourceItemHORqd.h" #include "Ngap_PDUSessionResourceItemHORqd.h"
} }
namespace ngap{ 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;
};
} class PDUSessionResourceItemHORqd {
public:
#endif 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_ #ifndef _HANDOVERNOTIFYMSG_H_
#define _HANDOVERNOTIFYMSG_H_ #define _HANDOVERNOTIFYMSG_H_
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. *file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at *License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -26,15 +26,15 @@ ...@@ -26,15 +26,15 @@
\email: contact@openairinterface.org \email: contact@openairinterface.org
*/ */
#include "sctp_server.hpp"
#include "ngap_app.hpp" #include "ngap_app.hpp"
#include "logger.hpp"
#include "amf_module_from_config.hpp" #include "amf_module_from_config.hpp"
#include "logger.hpp"
#include "ngap_message_callback.hpp" #include "ngap_message_callback.hpp"
#include "sctp_server.hpp"
extern "C" { extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_InitiatingMessage.h" #include "Ngap_InitiatingMessage.h"
#include "Ngap_NGAP-PDU.h"
} }
using namespace sctp; using namespace sctp;
...@@ -43,47 +43,66 @@ using namespace ngap; ...@@ -43,47 +43,66 @@ using namespace ngap;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
ngap_app::ngap_app(const std::string &address, const uint16_t port_num) 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); 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 // received sctp payload and decode it to NGAP message and send itti message to
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) { // TASK_AMF_N2
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); void ngap_app::handle_receive(bstring payload, sctp_assoc_id_t assoc_id,
Ngap_NGAP_PDU_t *ngap_msg_pdu = (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t)); sctp_stream_id_t stream,
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)); sctp_stream_id_t instreams,
Logger::ngap().debug("Decoded NGAP message, procedure code %d, present %d", ngap_msg_pdu->choice.initiatingMessage->procedureCode, ngap_msg_pdu->present); sctp_stream_id_t outstreams) {
(*messages_callback[ngap_msg_pdu->choice.initiatingMessage->procedureCode][ngap_msg_pdu->present - 1])(assoc_id, stream, ngap_msg_pdu); 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) // 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) { void ngap_app::handle_sctp_new_association(sctp_assoc_id_t assoc_id,
Logger::ngap().debug("Ready to handle new NGAP SCTP association (id: %d) request", 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; std::shared_ptr<gnb_context> gc;
if (!is_assoc_id_2_gnb_context(assoc_id)) { if (!is_assoc_id_2_gnb_context(assoc_id)) {
Logger::ngap().debug("Create a new gNB context with assoc_id (%d)", assoc_id); Logger::ngap().debug("Create a new gNB context with assoc_id (%d)",
gc = std::shared_ptr < gnb_context > (new gnb_context()); assoc_id);
gc = std::shared_ptr<gnb_context>(new gnb_context());
set_assoc_id_2_gnb_context(assoc_id, gc); set_assoc_id_2_gnb_context(assoc_id, gc);
} else { } else {
gc = assoc_id_2_gnb_context(assoc_id); gc = assoc_id_2_gnb_context(assoc_id);
if (gc.get()->ng_state == NGAP_RESETING || gc.get()->ng_state == NGAP_SHUTDOWN) { if (gc.get()->ng_state == NGAP_RESETING ||
Logger::ngap().warn("Received new association request on an association that is being %s, ignoring", ng_gnb_state_str[gc.get()->ng_state]); 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 { } else {
Logger::ngap().debug("Update gNB context with assoc id (%d)", assoc_id); Logger::ngap().debug("Update gNB context with assoc id (%d)", assoc_id);
} }
} }
if (gc.get() == nullptr) { 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 { } else {
gc.get()->sctp_assoc_id = assoc_id; gc.get()->sctp_assoc_id = assoc_id;
gc.get()->instreams = instreams; gc.get()->instreams = instreams;
...@@ -94,25 +113,43 @@ void ngap_app::handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream ...@@ -94,25 +113,43 @@ void ngap_app::handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint32_t ngap_app::getPpid() { uint32_t ngap_app::getPpid() { return ppid_; }
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); 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); std::shared_lock lock(m_assoc2gnbContext);
return assoc2gnbContext.at(assoc_id); 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); std::shared_lock lock(m_assoc2gnbContext);
assoc2gnbContext[assoc_id] = gc; 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 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. *file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at *License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#ifndef _NGAP_APPLICATION_H_ #ifndef _NGAP_APPLICATION_H_
#define _NGAP_APPLICATION_H_ #define _NGAP_APPLICATION_H_
#include "sctp_server.hpp"
#include "gNB_context.hpp" #include "gNB_context.hpp"
#include "sctp_server.hpp"
#include <map> #include <map>
#include <set> #include <set>
#include <shared_mutex> #include <shared_mutex>
...@@ -41,29 +41,41 @@ using namespace sctp; ...@@ -41,29 +41,41 @@ using namespace sctp;
namespace ngap { 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 { class ngap_app : public sctp_application {
public: public:
ngap_app(const std::string &address, const uint16_t port_num); ngap_app(const std::string &address, const uint16_t port_num);
~ngap_app(); ~ngap_app();
uint32_t getPpid(); 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_receive(bstring payload, sctp_assoc_id_t assoc_id,
void handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream_id_t instreams, sctp_stream_id_t outstreams); 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; 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); void set_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id,
std::shared_ptr<gnb_context> assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const; 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; sctp_server sctp_s_38412;
uint32_t ppid_; uint32_t ppid_;
std::map<sctp_assoc_id_t, std::shared_ptr<gnb_context>> assoc2gnbContext; std::map<sctp_assoc_id_t, std::shared_ptr<gnb_context>> assoc2gnbContext;
mutable std::shared_mutex m_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 #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