Commit 4954e0d1 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

Merge branch 'dsTest' into pre_release

parents 3e410047 ce381e8b
......@@ -19,8 +19,6 @@ openair-cn5g-smf
├── common: Common header files
│   ├── msg: ITTI messages definitions.
│   └── utils: Common utilities.
├── gtpv1u: Generic GTPV1-U stack implementation.
├── gtpv2c: Generic GTPV2-C stack implementation.
├── itti: Inter task interface.
├── nas: NAS protocol implememtation.
├── ngap: NGAP protocol implememtation.
......
......@@ -220,10 +220,13 @@ void IndividualSMContextApiImpl::update_sm_context(
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY)));
} else {
} else if (json_data.size() > 0 ){
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType("application/json"));
body = json_data.dump().c_str();
} else {
response.send(Pistache::Http::Code(sm_context_response.get_http_code()));
return;
}
response.send(Pistache::Http::Code(sm_context_response.get_http_code()),
......
......@@ -38,8 +38,7 @@
#include <stdint.h>
#include <string>
extern const char *interface_type2char[];
//extern const char *interface_type2char[];
namespace gtpv2c {
struct gtpc_exception : public std::exception {
......@@ -1337,6 +1336,49 @@ struct interface_type_s {
//------------------------------------------------------------------------------
std::string toString() const {
const char* interface_type2char[40] = {
"S1_U_ENODEB_GTP_U",
"S1_U_SGW_GTP_U",
"S12_RNC_GTP_U",
"S12_SGW_GTP_U",
"S5_S8_SGW_GTP_U",
"S5_S8_PGW_GTP_U",
"S5_S8_SGW_GTP_C",
"S5_S8_PGW_GTP_C",
"S5_S8_SGW_PMIPv6",
"S5_S8_PGW_PMIPv6",
"S11_MME_GTP_C",
"S11_S4_SGW_GTP_C",
"S10_MME_GTP_C",
"S3_MME_GTP_C",
"S3_SGSN_GTP_C",
"S4_SGSN_GTP_U",
"S4_SGW_GTP_U",
"S4_SGSN_GTP_C",
"S16_SGSN_GTP_C",
"ENODEB_GTP_U_DL_DATA_FORWARDING",
"ENODEB_GTP_U_UL_DATA_FORWARDING",
"RNC_GTP_U_DATA_FORWARDING",
"SGSN_GTP_U_DATA_FORWARDING",
"SGW_UPF_GTP_U_DL_DATA_FORWARDING",
"SM_MBMS_GW_GTP_C",
"SN_MBMS_GW_GTP_C",
"SM_MME_GTP_C",
"SN_SGSN_GTP_C",
"SGW_GTP_U_UL_DATA_FORWARDING",
"SN_SGSN_GTP_U",
"S2B_EPDG_GTP_C",
"S2B_U_EPDG_GTP_U",
"S2B_PGW_GTP_C",
"S2B_U_PGW_GTP_U",
"S2A_TWAN_GTP_U",
"S2A_TWAN_GTP_C",
"S2A_PGW_GTP_C",
"S2A_PGW_GTP_U",
"S11_MME_GTP_U",
"S11_SGW_GTP_U"};
if ((interface_type >= INTERFACE_TYPE_MIN)
&& (interface_type <= INTERFACE_TYPE_MAX)) {
return std::string(interface_type2char[interface_type]);
......
......@@ -56,8 +56,6 @@ void Logger::_init(const char *app, const bool log_stdout,
ss << "[%Y-%m-%dT%H:%M:%S.%f] [" << app << "] [%n] [%l] %v";
m_async_cmd = new _Logger("async_c ", m_sinks, ss.str().c_str());
m_gtpv1_u = new _Logger("gtpv1_u ", m_sinks, ss.str().c_str());
m_gtpv2_c = new _Logger("gtpv2_c ", m_sinks, ss.str().c_str());
m_itti = new _Logger("itti ", m_sinks, ss.str().c_str());
m_smf_app = new _Logger("smf_app ", m_sinks, ss.str().c_str());
m_system = new _Logger("system ", m_sinks, ss.str().c_str());
......
......@@ -89,12 +89,6 @@ class Logger {
static _Logger& async_cmd() {
return *singleton().m_async_cmd;
}
static _Logger& gtpv1_u() {
return *singleton().m_gtpv1_u;
}
static _Logger& gtpv2_c() {
return *singleton().m_gtpv2_c;
}
static _Logger& itti() {
return *singleton().m_itti;
}
......@@ -146,8 +140,6 @@ class Logger {
std::string m_pattern;
_Logger *m_async_cmd;
_Logger *m_gtpv1_u;
_Logger *m_gtpv2_c;
_Logger *m_itti;
_Logger *m_smf_app;
_Logger *m_system;
......
This diff is collapsed.
This diff is collapsed.
################################################################################
# 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
################################################################################
add_library(GTPV2C STATIC
3gpp_29.274.cpp
gtpv2c.cpp
)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/gtpv2c)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
This diff is collapsed.
/*
* 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 gtpv2c.hpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_GTPV2C_HPP_SEEN
#define FILE_GTPV2C_HPP_SEEN
#include "3gpp_29.274.hpp"
#include "endpoint.hpp"
#include "itti.hpp"
#include "udp.hpp"
#include "uint_generator.hpp"
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "msg_gtpv2c.hpp"
namespace gtpv2c {
static const uint16_t default_port = 2123;
class gtpv2c_procedure {
public:
std::shared_ptr<gtpv2c_msg> retry_msg;
endpoint remote_endpoint;
teid_t local_teid; // for peer not responding
timer_id_t retry_timer_id;
timer_id_t proc_cleanup_timer_id;
uint64_t gtpc_tx_id;
uint8_t initial_msg_type; // sent or received
uint8_t triggered_msg_type; // sent or received
uint8_t retry_count;
// Could add customized N3, and customized T3:
// T3-RESPONSE timer and N3-REQUESTS counter setting is implementation
// dependent. That is, the timers and counters may be configurable per procedure. Multileg communications (e.g. Create
// Session Requests and Responses) however require longer timer values and possibly a higher number of retransmission
// attempts compared to single leg communication.
gtpv2c_procedure() :
retry_msg(),
remote_endpoint(),
local_teid(0),
retry_timer_id(0),
proc_cleanup_timer_id(0),
gtpc_tx_id(0),
initial_msg_type(0),
triggered_msg_type(0),
retry_count(0) {}
gtpv2c_procedure(const gtpv2c_procedure& p) :
retry_msg(p.retry_msg),
remote_endpoint(p.remote_endpoint),
local_teid(p.local_teid),
retry_timer_id(p.retry_timer_id),
proc_cleanup_timer_id(p.proc_cleanup_timer_id),
gtpc_tx_id(p.gtpc_tx_id),
initial_msg_type(p.initial_msg_type),
triggered_msg_type(p.triggered_msg_type),
retry_count(p.retry_count) {}
};
enum gtpv2c_transaction_action {
DELETE_TX = 0,
CONTINUE_TX
};
class gtpv2c_stack : public udp_application {
#define GTPV2C_T3_RESPONSE_MS 1000
#define GTPV2C_N3_REQUESTS 3
#define GTPV2C_PROC_TIME_OUT_MS ((GTPV2C_T3_RESPONSE_MS) * (GTPV2C_N3_REQUESTS + 1) + 1000)
protected:
uint32_t id;
udp_server udp_s;
udp_server udp_s_allocated;
// seems no need for atomic
uint32_t seq_num;
std::mutex m_seq_num;
uint32_t restart_counter;
std::map<uint64_t, uint32_t> gtpc_tx_id2seq_num;
std::map<timer_id_t, uint32_t> proc_cleanup_timers;
std::map<timer_id_t, uint32_t> msg_out_retry_timers;
std::map<uint32_t , gtpv2c_procedure> pending_procedures;
static const char* msg_type2cstr[256];
uint32_t get_next_seq_num();
static uint64_t generate_gtpc_tx_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
static bool check_initial_message_type(const uint8_t initial);
static bool check_triggered_message_type(const uint8_t initial, const uint8_t triggered);
void start_proc_cleanup_timer(gtpv2c_procedure& p, uint32_t time_out_milli_seconds, const task_id_t& task_id, const uint32_t& seq_num);
void start_msg_retry_timer(gtpv2c_procedure& p, uint32_t time_out_milli_seconds, const task_id_t& task_id, const uint32_t& seq_num);
void stop_msg_retry_timer(gtpv2c_procedure& p);
void stop_msg_retry_timer(timer_id_t& t);
void stop_proc_cleanup_timer(gtpv2c_procedure& p);
void notify_ul_error(const gtpv2c_procedure& p, const cause_value_e cause);
public:
static const uint8_t version = 2;
gtpv2c_stack(const std::string& ip_address, const unsigned short port_num, const util::thread_sched_params& sched_param);
virtual void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& r_endpoint);
virtual void notify_ul_error(const endpoint& r_endpoint, const teid_t l_teid, const cause_value_e cause, const uint64_t gtpc_tx_id);
void handle_receive_message_cb(const gtpv2c_msg& msg, const endpoint& r_endpoint, const task_id_t& task_id, bool& error, uint64_t& gtpc_tx_id);
// Path mangement messages
virtual uint32_t send_initial_message(const endpoint& r_endpoint, const gtpv2c_echo_request& gtp_ies, const task_id_t& task_id, const uint64_t gtp_tx_id);
virtual void send_triggered_message(const endpoint& r_endpoint, const gtpv2c_echo_response& gtp_ies, const uint64_t gtp_tx_id, const gtpv2c_transaction_action& a = DELETE_TX);
// Tunnel management messages
virtual uint32_t send_initial_message(const endpoint& r_endpoint, const teid_t r_teid, const teid_t l_teid, const gtpv2c_create_session_request& gtp_ies, const task_id_t& task_id, const uint64_t gtp_tx_id);
virtual uint32_t send_initial_message(const endpoint& r_endpoint, const teid_t r_teid, const teid_t l_teid, const gtpv2c_delete_session_request& gtp_ies, const task_id_t& task_id, const uint64_t gtp_tx_id);
virtual uint32_t send_initial_message(const endpoint& r_endpoint, const teid_t r_teid, const teid_t l_teid, const gtpv2c_modify_bearer_request& gtp_ies, const task_id_t& task_id, const uint64_t gtp_tx_id);
virtual uint32_t send_initial_message(const endpoint& r_endpoint, const teid_t r_teid, const teid_t l_teid, const gtpv2c_release_access_bearers_request& gtp_ies, const task_id_t& task_id, const uint64_t gtp_tx_id);
virtual uint32_t send_initial_message(const endpoint& r_endpoint, const teid_t r_teid, const teid_t l_teid, const gtpv2c_downlink_data_notification& gtp_ies, const task_id_t& task_id, const uint64_t gtp_tx_id);
virtual void send_triggered_message(const endpoint& r_endpoint, const teid_t teid, const gtpv2c_create_session_response& gtp_ies, const uint64_t gtp_tx_id, const gtpv2c_transaction_action& a = DELETE_TX);
virtual void send_triggered_message(const endpoint& r_endpoint, const teid_t teid, const gtpv2c_delete_session_response& gtp_ies, const uint64_t gtp_tx_id, const gtpv2c_transaction_action& a = DELETE_TX);
virtual void send_triggered_message(const endpoint& r_endpoint, const teid_t teid, const gtpv2c_modify_bearer_response& gtp_ies, const uint64_t gtp_tx_id, const gtpv2c_transaction_action& a = DELETE_TX);
virtual void send_triggered_message(const endpoint& r_endpoint, const teid_t teid, const gtpv2c_release_access_bearers_response& gtp_ies, const uint64_t gtp_tx_id, const gtpv2c_transaction_action& a = DELETE_TX);
virtual void send_triggered_message(const endpoint& r_endpoint, const teid_t teid, const gtpv2c_downlink_data_notification_acknowledge& gtp_ies, const uint64_t gtp_tx_id, const gtpv2c_transaction_action& a = DELETE_TX);
void time_out_event(const uint32_t timer_id, const task_id_t& task_id, bool &error);
};
} // namespace gtpv2c
#endif /* FILE_GTPV2C_HPP_SEEN */
This diff is collapsed.
......@@ -34,8 +34,6 @@ typedef enum {
TASK_FIRST = 0,
TASK_ITTI_TIMER = TASK_FIRST,
TASK_ASYNC_SHELL_CMD,
TASK_GTPV1_U,
TASK_GTPV2_C,
TASK_SMF_APP,
TASK_SMF_N4,
TASK_SMF_N10,
......
......@@ -266,7 +266,6 @@ endif(STATIC_LINKING)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/common ${CMAKE_CURRENT_BINARY_DIR}/common)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/utils ${CMAKE_CURRENT_BINARY_DIR}/utils)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/gtpv2c ${CMAKE_CURRENT_BINARY_DIR}/gtpv2c)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/pfcp ${CMAKE_CURRENT_BINARY_DIR}/pfcp)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/udp ${CMAKE_CURRENT_BINARY_DIR}/udp)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/api-server ${CMAKE_CURRENT_BINARY_DIR}/api-server)
......@@ -287,7 +286,6 @@ include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/common/ngap)
include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/gtpv2c)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
......@@ -323,5 +321,5 @@ IF(STATIC_LINKING)
ENDIF(STATIC_LINKING)
target_link_libraries (smf ${ASAN}
-Wl,--start-group CN_UTILS SMF UDP GTPV2C PFCP 3GPP_COMMON_TYPES SMF_API -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system pistache curl)
-Wl,--start-group CN_UTILS SMF UDP PFCP 3GPP_COMMON_TYPES SMF_API -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system pistache curl)
\ No newline at end of file
......@@ -36,7 +36,6 @@
#include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
using namespace gtpv2c;
using namespace smf;
using namespace util;
using namespace std;
......
......@@ -19,7 +19,7 @@
* contact@openairinterface.org
*/
/*! \file gtpv2c.cpp
/*! \file pfcp.cpp
\brief
\author Lionel Gauthier
\company Eurecom
......
......@@ -24,7 +24,6 @@ include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/ngap)
include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/gtpv2c)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/smf)
include_directories(${SRC_TOP_DIR}/ngap)
......
......@@ -503,7 +503,12 @@ void smf_app::handle_itti_msg(itti_n11_create_sm_context_response &m) {
Logger::smf_app().debug(
"PDU Session Create SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_create_sm_context_response sm_context_response = { };
sm_context_create_promises[m.pid]->set_value(m.res);
std::shared_lock lock(m_sm_context_create_promises);
if (sm_context_create_promises.count(m.pid) > 0 ){
sm_context_create_promises[m.pid]->set_value(m.res);
//Remove this promise from list
sm_context_create_promises.erase(m.pid);
}
}
//------------------------------------------------------------------------------
......@@ -511,7 +516,12 @@ void smf_app::handle_itti_msg(itti_n11_update_sm_context_response &m) {
Logger::smf_app().debug(
"PDU Session Update SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_update_sm_context_response sm_context_response = { };
sm_context_update_promises[m.pid]->set_value(m.res);
std::shared_lock lock(m_sm_context_update_promises);
if (sm_context_update_promises.count(m.pid) > 0 ){
sm_context_update_promises[m.pid]->set_value(m.res);
//Remove this promise from list
sm_context_update_promises.erase(m.pid);
}
}
//------------------------------------------------------------------------------
......@@ -519,7 +529,12 @@ void smf_app::handle_itti_msg(itti_n11_release_sm_context_response &m) {
Logger::smf_app().debug(
"PDU Session Release SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_release_sm_context_response sm_context_response = { };
sm_context_release_promises[m.pid]->set_value(m.res);
std::shared_lock lock(m_sm_context_release_promises);
if (sm_context_release_promises.count(m.pid) > 0 ){
sm_context_release_promises[m.pid]->set_value(m.res);
//Remove this promise from list
sm_context_release_promises.erase(m.pid);
}
}
//------------------------------------------------------------------------------
......@@ -762,6 +777,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
//Step 4. Verify the session is already existed
if (is_scid_2_smf_context(supi64, dnn, snssai, pdu_session_id)) {
//TODO: should delete the local context (including and any associated resources in the UPF and PCF) and create a new one
Logger::smf_app().warn(
"PDU Session already existed (SUPI " SUPI_64_FMT ", DNN %s, NSSAI (sst %d, sd %s), PDU Session ID %d)",
supi64, dnn.c_str(), snssai.sST, snssai.sD.c_str(), pdu_session_id);
......
......@@ -45,7 +45,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include "3gpp_29.274.hpp"
//#include "3gpp_29.274.hpp"
#include "common_defs.h"
#include "epc.h"
#include "if.hpp"
......
......@@ -41,7 +41,6 @@
#include "3gpp_29.244.h"
#include "3gpp_29.274.h"
#include "gtpv2c.hpp"
#include "pfcp.hpp"
#include "smf.h"
......
......@@ -1220,14 +1220,14 @@ void smf_context::handle_pdu_session_create_sm_context_request(
bool find_pdu = sd.get()->find_pdu_session(pdu_session_id, sp);
if (nullptr == sp.get()) {
Logger::smf_app().debug("Create a new PDN connection");
Logger::smf_app().debug("Create a new PDU session");
sp = std::shared_ptr<smf_pdu_session>(new smf_pdu_session());
sp.get()->pdn_type.pdn_type = smreq->req.get_pdu_session_type();
sp.get()->pdu_session_id = pdu_session_id;
sp.get()->amf_id = smreq->req.get_serving_nf_id(); //amf id
sd->insert_pdu_session(sp);
} else {
Logger::smf_app().debug("PDN connection is already existed!");
Logger::smf_app().debug("PDU session is already existed!");
//trigger to send reply to AMF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_406_NOT_ACCEPTABLE, smreq->pid,
......@@ -2317,6 +2317,9 @@ void smf_context::handle_pdu_session_update_sm_context_request(
sm_context_resp_pending->session_procedure_type = procedure_type;
//don't need to create a procedure to update UPF
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_200_OK,
smreq->pid, N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE);
}
break;
......
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