Commit 496955d9 authored by gauthier's avatar gauthier

Removed boost::asio. Set configurations default values

parent f13a6ef0
This diff is collapsed.
......@@ -23,33 +23,33 @@ SPGW-U =
INSTANCE = @INSTANCE@; # 0 is the default
PID_DIRECTORY = "@PID_DIRECTORY@"; # /var/run is the default
ITTI_TASKS :
{
ITTI_TIMER_SCHED_PARAMS :
{
CPU_ID = 1;
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
SCHED_PRIORITY = 85;
};
S1U_SCHED_PARAMS :
{
CPU_ID = 1;
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
SCHED_PRIORITY = 84;
};
SX_SCHED_PARAMS :
{
CPU_ID = 1;
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
SCHED_PRIORITY = 84;
};
ASYNC_CMD_SCHED_PARAMS :
{
CPU_ID = 1;
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
SCHED_PRIORITY = 84;
};
};
#ITTI_TASKS :
#{
#ITTI_TIMER_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 85;
#};
#S1U_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#SX_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#ASYNC_CMD_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#};
INTERFACES :
{
......@@ -57,39 +57,39 @@ SPGW-U =
{
# S-GW binded interface for S1-U communication (GTPV1-U) can be ethernet interface, virtual ethernet interface, we don't advise wireless interfaces
INTERFACE_NAME = "@SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP@"; # STRING, interface name, YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read"; # STRING, CIDR or read to let app read interface configured IP address
PORT = @SGW_UDP_PORT_FOR_S1U_S12_S4_UP@; # Default is 2152
SCHED_PARAMS :
{
CPU_ID = 2;
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
SCHED_PRIORITY = 98;
};
IPV4_ADDRESS = "read"; # STRING, CIDR or "read to let app read interface configured IP address
#PORT = 2152; # Default is 2152
#SCHED_PARAMS :
#{
#CPU_ID = 2;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 98;
#};
};
SX :
{
# S/P-GW binded interface for SX communication
INTERFACE_NAME = "@SGW_INTERFACE_NAME_FOR_SX@"; # STRING, interface name
IPV4_ADDRESS = "read"; # STRING, CIDR or read to let app read interface configured IP address
PORT = 8805; # Default is 8805
SCHED_PARAMS :
{
CPU_ID = 1;
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
SCHED_PRIORITY = 95;
};
IPV4_ADDRESS = "read"; # STRING, CIDR or "read" to let app read interface configured IP address
#PORT = 8805; # Default is 8805
#SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 95;
#};
};
SGI :
{
# No config to set, the software will set the SGi interface to the interface used for the default route.
INTERFACE_NAME = "@SGW_INTERFACE_NAME_FOR_SGI@"; # STRING, interface name or "default_gateway"
IPV4_ADDRESS = "read"; # STRING, CIDR or read to let app read interface configured IP address
SCHED_PARAMS :
{
CPU_ID = 3;
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
SCHED_PRIORITY = 98;
};
IPV4_ADDRESS = "read"; # STRING, CIDR or "read" to let app read interface configured IP address
#SCHED_PARAMS :
#{
#CPU_ID = 3;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 98;
#};
};
};
......
......@@ -391,6 +391,16 @@ struct imsi_s {
} u1;
uint num_digits;
imsi_s() : num_digits(0)
{
memset(u1.b, 0, sizeof(u1.b));
}
imsi_s(const imsi_s& i) : num_digits(i.num_digits)
{
memcpy(u1.b, i.u1.b, sizeof(u1.b));
}
std::string toString() const
{
std::string s = {};
......@@ -431,6 +441,39 @@ struct imsi_s {
}
return imsi64;
}
imsi_s& operator++ () // prefix ++
{
int l_i = IMSI_BCD8_SIZE - 1;
uint8_t carry = 1;
while(l_i > 5) {
uint8_t b = u1.b[l_i];
uint8_t d0 = b & 0x0f;
uint8_t d1 = b & 0xf0;
if (d0 <= 9) {
d0 += carry;
if (d0 <= 9) {
u1.b[l_i] = d0 | d1;
return(*this);
} else {
d0 = 0;
u1.b[l_i] = d0 | d1;
}
}
if (d1 <= 9) {
d1 += carry;
if (d1 <= 9) {
u1.b[l_i] = d0 | d1;
return(*this);
} else {
d1 = 0;
u1.b[l_i] = d0 | d1;
}
}
l_i++;
}
return (*this);
}
} ;
typedef struct imsi_s imsi_t;
......@@ -578,7 +621,7 @@ typedef struct ip_address_s {
//-------------------------------------
// 8.10 Mobile Equipment Identity (MEI)
// The ME Identity field contains either the IMEI or the IMEISV as defined in subclause 6.2 of 3GPP TS 23.003
typedef struct mei_s {
struct mei_s {
#define MEI_MIN_LENGTH (15)
#define MEI_MAX_LENGTH (16)
union {
......@@ -603,10 +646,74 @@ typedef struct mei_s {
uint8_t b[MEI_MAX_LENGTH/2];
} u1;
uint num_digits;
} mei_t;
mei_s() : num_digits(0)
{
memset(u1.b, 0, sizeof(u1.b));
}
mei_s(const mei_s& i) : num_digits(i.num_digits)
{
memcpy(u1.b, i.u1.b, sizeof(u1.b));
}
std::string toString() const
{
std::string s = {};
int l_i = 0;
int l_j = 0;
while(l_i < MEI_MAX_LENGTH/2) {
if((u1.b[l_i] & 0xf) > 9)
break;
s.append(std::to_string(u1.b[l_i] & 0xf));
l_j++;
if(((u1.b[l_i] & 0xf0) >> 4) > 9)
break;
s.append(std::to_string((u1.b[l_i] & 0xf0) >> 4));
l_j++;
l_i++;
}
return s;
}
mei_s& operator++ () // prefix ++
{
int l_i = MEI_MAX_LENGTH/2 - 1 - 1; // depends if imei or imei_sv -1 again
uint8_t carry = 1;
while(l_i) {
uint8_t b = u1.b[l_i];
uint8_t d0 = b & 0x0f;
uint8_t d1 = b & 0xf0;
if (d0 <= 9) {
d0 += carry;
if (d0 <= 9) {
u1.b[l_i] = d0 | d1;
return(*this);
} else {
d0 = 0;
u1.b[l_i] = d0 | d1;
}
}
if (d1 <= 9) {
d1 += carry;
if (d1 <= 9) {
u1.b[l_i] = d0 | d1;
return(*this);
} else {
d1 = 0;
u1.b[l_i] = d0 | d1;
}
}
l_i++;
}
return (*this);
}
} ;
typedef struct mei_s mei_t;
//-------------------------------------
// 8.11 MSISDN
typedef struct msisdn_s {
struct msisdn_s {
#define MSISDN_MAX_LENGTH (15)
union {
struct {
......@@ -629,7 +736,73 @@ typedef struct msisdn_s {
uint8_t b[MSISDN_MAX_LENGTH/2+1];
} u1;
uint num_digits;
} msisdn_t;
msisdn_s() : num_digits(0)
{
memset(u1.b, 0, sizeof(u1.b));
}
msisdn_s(const msisdn_s& i) : num_digits(i.num_digits)
{
memcpy(u1.b, i.u1.b, sizeof(u1.b));
}
std::string toString() const
{
std::string s = {};
int l_i = 0;
int l_j = 0;
while(l_i < sizeof(u1.b)) {
if((u1.b[l_i] & 0xf) > 9)
break;
s.append(std::to_string(u1.b[l_i] & 0xf));
l_j++;
if(((u1.b[l_i] & 0xf0) >> 4) > 9)
break;
s.append(std::to_string((u1.b[l_i] & 0xf0) >> 4));
l_j++;
l_i++;
}
return s;
}
// Should be refined see spec
msisdn_s& operator++ () // prefix ++
{
int l_i = sizeof(u1.b) - 1;
uint8_t carry = 1;
while(l_i > 5) {
uint8_t b = u1.b[l_i];
uint8_t d0 = b & 0x0f;
uint8_t d1 = b & 0xf0;
if (d0 <= 9) {
d0 += carry;
if (d0 <= 9) {
u1.b[l_i] = d0 | d1;
return(*this);
} else {
d0 = 0;
u1.b[l_i] = d0 | d1;
}
}
if (d1 <= 9) {
d1 += carry;
if (d1 <= 9) {
u1.b[l_i] = d0 | d1;
return(*this);
} else {
d1 = 0;
u1.b[l_i] = d0 | d1;
}
}
l_i++;
}
return (*this);
}
};
typedef struct msisdn_s msisdn_t;
//-------------------------------------
// 8.12 Indication
typedef struct indication_s {
......@@ -833,9 +1006,31 @@ enum rat_type_e {
RAT_TYPE_E_LTE_M = 9,
RAT_TYPE_E_NR = 10,
};
typedef struct rat_type_s {
struct rat_type_s {
uint8_t rat_type;
} rat_type_t;
rat_type_s() : rat_type(RAT_TYPE_E_EUTRAN_WB_EUTRAN) {}
rat_type_s(const rat_type_e r) : rat_type(r) {}
rat_type_s(const rat_type_s& i) : rat_type(i.rat_type) {}
//------------------------------------------------------------------------------
std::string toString() const
{
switch(rat_type) {
case RAT_TYPE_E_EUTRAN_WB_EUTRAN: return std::string("EUTRAN_WB_EUTRAN");
case RAT_TYPE_E_EUTRAN_NB_IOT: return std::string("EUTRAN_NB_IOT");
case RAT_TYPE_E_LTE_M: return std::string("LTE_M");
case RAT_TYPE_E_NR: return std::string("NR");
case RAT_TYPE_E_VIRTUAL: return std::string("VIRTUAL");
case RAT_TYPE_E_RESERVED: return std::string("RESERVED");
case RAT_TYPE_E_UTRAN: return std::string("UTRAN");
case RAT_TYPE_E_GERAN: return std::string("GERAN");
case RAT_TYPE_E_WLAN: return std::string("WLAN");
case RAT_TYPE_E_GAN: return std::string("GAN");
case RAT_TYPE_E_HSPA_EVOLUTION: return std::string("HSPA_EVOLUTION");
default: return std::to_string(rat_type);
}
}
};
typedef struct rat_type_s rat_type_t;
//-------------------------------------
// 8.18 Serving Network
typedef struct serving_network_s {
......@@ -1936,4 +2131,29 @@ typedef struct maximum_packet_loss_rate_s {
// 8.135 APN Rate Control Status
// 8.136 Extended Trace Information
namespace std {
template<>
class hash<fteid_t> {
public:
size_t operator()(const fteid_t &k) const
{
using std::size_t;
using std::hash;
std::size_t h1 = std::hash<uint32_t>()(k.interface_type);
std::size_t h2 = std::hash<uint32_t>()(k.teid_gre_key) ^ h1;
if (k.v4) {
h2 ^= std::hash<uint32_t>()(k.ipv4_address.s_addr);
}
if (k.v6) {
h2 ^= std::hash<uint32_t>()(k.ipv6_address.s6_addr32[0]);
h2 ^= std::hash<uint32_t>()(k.ipv6_address.s6_addr32[1]);
h2 ^= std::hash<uint32_t>()(k.ipv6_address.s6_addr32[2]);
h2 ^= std::hash<uint32_t>()(k.ipv6_address.s6_addr32[3]);
}
return h2;
}
};
}
#endif /* FILE_3GPP_29_274_SEEN */
/*
* 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 endpoint.hpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_ENDPOINT_HPP_SEEN
#define FILE_ENDPOINT_HPP_SEEN
#include <arpa/inet.h>
#include <inttypes.h>
#include <sys/socket.h>
#include <string.h>
class endpoint {
public :
struct sockaddr_storage addr_storage;
socklen_t addr_storage_len;
endpoint() : addr_storage(), addr_storage_len(sizeof(struct sockaddr_storage)) {};
endpoint(const endpoint& e) : addr_storage(e.addr_storage), addr_storage_len(e.addr_storage_len) {};
endpoint(const struct sockaddr_storage& addr, const socklen_t len) : addr_storage(addr), addr_storage_len(len) {};
endpoint(const struct in_addr& addr, const uint16_t port)
{
struct sockaddr_in * addr_in = (struct sockaddr_in *)&addr_storage;
addr_in->sin_family = AF_INET;
addr_in->sin_port = htons(port);
addr_in->sin_addr.s_addr = addr.s_addr;
addr_storage_len = sizeof(struct sockaddr_in);
};
endpoint(const struct in6_addr& addr6, const uint16_t port)
{
struct sockaddr_in6 * addr_in6 = (struct sockaddr_in6 *)&addr_storage;
addr_in6->sin6_family = AF_INET6;
addr_in6->sin6_port = htons(port);
addr_in6->sin6_flowinfo = 0;
memcpy(&addr_in6->sin6_addr, &addr6, sizeof(struct in6_addr));
addr_in6->sin6_scope_id = 0;
addr_storage_len = sizeof(struct sockaddr_in6);
};
uint16_t port() const
{
return ntohs(((struct sockaddr_in *)&addr_storage)->sin_port);
}
sa_family_t family() const
{
return addr_storage.ss_family;
}
};
#endif
\ No newline at end of file
......@@ -30,9 +30,9 @@
#define ITTI_MSG_S11_HPP_INCLUDED_
#include "3gpp_29.274.hpp"
#include "endpoint.hpp"
#include "itti_msg.hpp"
#include "msg_gtpv2c.hpp"
#include <boost/asio/ip/udp.hpp>
class itti_s11_msg : public itti_msg {
public:
......@@ -54,10 +54,10 @@ public:
destination = dest;
}
boost::asio::ip::udp::endpoint l_endpoint;
boost::asio::ip::udp::endpoint r_endpoint;
teid_t teid;
uint64_t gtpc_tx_id;
endpoint l_endpoint;
endpoint r_endpoint;
teid_t teid;
uint64_t gtpc_tx_id;
};
class itti_s11_create_session_request : public itti_s11_msg {
......
......@@ -30,9 +30,9 @@
#define ITTI_MSG_S5S8_HPP_INCLUDED_
#include "3gpp_29.274.hpp"
#include "endpoint.hpp"
#include "itti_msg.hpp"
#include "msg_gtpv2c.hpp"
#include <boost/asio/ip/udp.hpp>
class itti_s5s8_msg : public itti_msg {
public:
......@@ -44,7 +44,7 @@ public:
gtpc_tx_id = 0;
}
itti_s5s8_msg(const itti_s5s8_msg& i) : itti_msg(i), l_endpoint(i.l_endpoint),
itti_s5s8_msg(const itti_s5s8_msg& i) : itti_msg(i), l_endpoint(i.l_endpoint),
r_endpoint(i.r_endpoint), teid(i.teid), gtpc_tx_id(i.gtpc_tx_id) {}
itti_s5s8_msg(const itti_s5s8_msg& i, const task_id_t orig, const task_id_t dest) :
......@@ -54,10 +54,10 @@ public:
destination = dest;
}
boost::asio::ip::udp::endpoint l_endpoint;
boost::asio::ip::udp::endpoint r_endpoint;
teid_t teid;
uint64_t gtpc_tx_id;
endpoint l_endpoint;
endpoint r_endpoint;
teid_t teid;
uint64_t gtpc_tx_id;
};
class itti_s5s8_create_session_request : public itti_s5s8_msg {
......
......@@ -29,9 +29,9 @@
#define ITTI_MSG_SXAB_HPP_INCLUDED_
#include "3gpp_29.244.hpp"
#include "endpoint.hpp"
#include "itti_msg.hpp"
#include "msg_pfcp.hpp"
#include <boost/asio/ip/udp.hpp>
class itti_sxab_msg : public itti_msg {
public:
......@@ -53,10 +53,10 @@ public:
destination = dest;
}
boost::asio::ip::udp::endpoint l_endpoint;
boost::asio::ip::udp::endpoint r_endpoint;
seid_t seid;
uint64_t trxn_id;
endpoint l_endpoint;
endpoint r_endpoint;
seid_t seid;
uint64_t trxn_id;
};
//-----------------------------------------------------------------------------
......
......@@ -134,19 +134,20 @@ void xgpp_conv::pfcp_cause_to_core_cause(const pfcp::cause_t& pc, cause_t& c)
c.cause_value = SYSTEM_FAILURE; // ? ...
}
}
//------------------------------------------------------------------------------
bool xgpp_conv::sockaddr_storage_to_gtp_u_peer_address(const struct sockaddr_storage& peer_sockaddr, gtp_u_peer_address_t& peer_address)
bool xgpp_conv::endpoint_to_gtp_u_peer_address(const endpoint& ep, gtp_u_peer_address_t& peer_address)
{
switch (peer_sockaddr.ss_family) {
switch (ep.family()) {
case AF_INET: {
const struct sockaddr_in * const sin = reinterpret_cast<const sockaddr_in* const>(&peer_sockaddr);
const struct sockaddr_in * const sin = reinterpret_cast<const sockaddr_in* const>(&ep.addr_storage);
peer_address.ipv4_address.s_addr = sin->sin_addr.s_addr;
peer_address.is_v4 = true;
return true;
}
break;
case AF_INET6: {
const struct sockaddr_in6 * const sin6 = reinterpret_cast<const sockaddr_in6* const>(&peer_sockaddr);
const struct sockaddr_in6 * const sin6 = reinterpret_cast<const sockaddr_in6* const>(&ep.addr_storage);
peer_address.ipv6_address = sin6->sin6_addr;
peer_address.is_v4 = false;
return true;
......@@ -157,4 +158,3 @@ bool xgpp_conv::sockaddr_storage_to_gtp_u_peer_address(const struct sockaddr_sto
}
}
......@@ -31,6 +31,7 @@
#include "3gpp_29.274.h"
#include "3gpp_29.244.h"
#include "3gpp_29.281.h"
#include "endpoint.hpp"
namespace xgpp_conv {
......@@ -42,8 +43,7 @@ namespace xgpp_conv {
void pfcp_to_core_fteid(const pfcp::fteid_t& pfteid, fteid_t& fteid);
void pfcp_from_core_fteid(pfcp::fteid_t& pfteid, const fteid_t& fteid);
void pfcp_cause_to_core_cause(const pfcp::cause_t& pc, cause_t& c);
bool sockaddr_storage_to_gtp_u_peer_address(const struct sockaddr_storage& peer_sockaddr, gtp_u_peer_address_t& peer_address);
bool endpoint_to_gtp_u_peer_address(const endpoint& ep, gtp_u_peer_address_t& gpa);
}
#endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
......@@ -21,6 +21,7 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
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}/itti)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
......
......@@ -167,3 +167,5 @@ std::string conv::toString(const struct in6_addr& in6addr)
}
return s;
}
......@@ -32,6 +32,7 @@
#include <string>
#include <netinet/in.h>
/* Used to format an uint32_t containing an ipv4 address */
#define IN_ADDR_FMT "%u.%u.%u.%u"
#define PRI_IN_ADDR(aDDRESS) \
......
......@@ -34,7 +34,8 @@
namespace util {
class thread_sched_params {
public:
public:
thread_sched_params() : cpu_id(0), sched_policy(SCHED_FIFO), sched_priority(84) {}
int cpu_id;
int sched_policy;
int sched_priority;
......
......@@ -28,4 +28,5 @@ include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/gtpv1u)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
......@@ -38,134 +38,7 @@ using namespace std;
extern itti_mw *itti_inst;
//------------------------------------------------------------------------------
static std::string string_to_hex(const std::string& input)
{
static const char* const lut = "0123456789ABCDEF";
size_t len = input.length();
std::string output;
output.reserve(2 * len);
for (size_t i = 0; i < len; ++i)
{
const unsigned char c = input[i];
output.push_back(lut[c >> 4]);
output.push_back(lut[c & 15]);
}
return output;
}
//------------------------------------------------------------------------------
void udp_server::udp_read_loop(const util::thread_sched_params& sched_params)
{
socklen_t r_endpoint_addr_len = 0;
struct sockaddr_storage r_endpoint = {};
size_t bytes_received = 0;
sched_params.apply(TASK_NONE, Logger::udp());
while (1) {
r_endpoint_addr_len = sizeof(struct sockaddr_storage);
if ((bytes_received = recvfrom (socket_, recv_buffer_, UDP_RECV_BUFFER_SIZE, 0, (struct sockaddr *)&r_endpoint, &r_endpoint_addr_len)) > 0) {
app_->handle_receive(recv_buffer_, bytes_received, r_endpoint, r_endpoint_addr_len);
} else {
Logger::udp().error( "Recvfrom failed %s\n", strerror (errno));
}
}
}
//------------------------------------------------------------------------------
int udp_server::create_socket (const struct in_addr &address, const uint16_t port)
{
struct sockaddr_in addr = {};
int sd = 0;
/*
* Create UDP socket
*/
if ((sd = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
/*
* Socket creation has failed...
*/
Logger::udp().error( "Socket creation failed (%s)\n", strerror (errno));
return errno;
}
addr.sin_family = AF_INET;
addr.sin_port = htons (port);
addr.sin_addr.s_addr = address.s_addr;
std::string ipv4 = conv::toString(address);
Logger::udp().debug("Creating new listen socket on address %s and port %" PRIu16 "\n", ipv4.c_str(), port);
if (bind (sd, (struct sockaddr *)&addr, sizeof (struct sockaddr_in)) < 0) {
/*
* Bind failed
*/
Logger::udp().error("Socket bind failed (%s) for address %s and port %" PRIu16 "\n", strerror (errno), ipv4.c_str(), port);
close (sd);
return errno;
}
return sd;
}
//------------------------------------------------------------------------------
int udp_server::create_socket (const struct in6_addr &address, const uint16_t port)
{
struct sockaddr_in6 addr = {};
int sd = 0;
/*
* Create UDP socket
*/
if ((sd = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
/*
* Socket creation has failed...
*/
Logger::udp().error( "Socket creation failed (%s)\n", strerror (errno));
return errno;
}
addr.sin6_family = AF_INET6;
addr.sin6_port = htons (port);
addr.sin6_addr = address;
std::string ipv6 = conv::toString(address);
Logger::udp().debug("Creating new listen socket on address %s and port %" PRIu16 "\n", ipv6.c_str(), port);
if (bind (sd, (struct sockaddr *)&addr, sizeof (struct sockaddr_in6)) < 0) {
/*
* Bind failed
*/
Logger::udp().error("Socket bind failed (%s) for address %s and port %" PRIu16 "\n", strerror (errno), ipv6.c_str(), port);
close (sd);
return errno;
}
return sd;
}
//------------------------------------------------------------------------------
int udp_server::create_socket (char * address, const uint16_t port_num)
{
unsigned char buf_in_addr[sizeof(struct in6_addr)];
if (inet_pton (AF_INET, address, buf_in_addr) == 1) {
struct in_addr addr4 = {};
memcpy (&addr4, buf_in_addr, sizeof (struct in_addr));
return create_socket(addr4, port_num);
} else if (inet_pton (AF_INET6, address, buf_in_addr) == 1) {
struct in6_addr addr6 = {};
memcpy (&addr6, buf_in_addr, sizeof (struct in6_addr));
return create_socket(addr6, port_num);
} else {
Logger::udp().error( "udp_server::create_socket(%s:%d)", address, port_num);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
throw std::system_error(socket_, std::generic_category(), "UDP socket creation failed!");
}
}
//------------------------------------------------------------------------------
void udp_server::start_receive(gtpu_l4_stack * gtp_stack, const util::thread_sched_params& sched_params)
{
app_ = gtp_stack;
Logger::udp().trace( "udp_server::start_receive");
thread_ = thread(&udp_server::udp_read_loop,this, sched_params);
thread_.detach();
}
////------------------------------------------------------------------------------
//void udp_server::handle_receive(const int& error, std::size_t bytes_transferred)
......@@ -232,7 +105,7 @@ uint32_t gtpu_l4_stack::get_next_seq_num() {
return seq_num;
}
//------------------------------------------------------------------------------
void gtpu_l4_stack::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len)
void gtpu_l4_stack::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& r_endpoint)
{
Logger::gtpv1_u().error( "TODO implement in derived class");
}
......@@ -315,20 +188,8 @@ void gtpu_l4_stack::send_response(const gtpv1u_echo_response& gtp_ies)
}
msg.dump_to(oss);
std::string bstream = oss.str();
switch (gtp_ies.r_endpoint.ss_family) {
case AF_INET: {
const struct sockaddr_in * const sin = reinterpret_cast<const sockaddr_in* const>(&gtp_ies.r_endpoint);
udp_s.async_send_to(reinterpret_cast<const char*>(bstream.c_str()), bstream.length(), *sin);
}
break;
case AF_INET6: {
const struct sockaddr_in6 * const sin6 = reinterpret_cast<const sockaddr_in6* const>(&gtp_ies.r_endpoint);
udp_s.async_send_to(reinterpret_cast<const char*>(bstream.c_str()), bstream.length(), *sin6);
}
break;
default:
Logger::gtpv1_u().debug( "gtpu_l4_stack::send_response %s, no known peer addr", gtp_ies.get_msg_name());
}
udp_s.async_send_to(reinterpret_cast<const char*>(bstream.c_str()), bstream.length(), gtp_ies.r_endpoint);
}
//------------------------------------------------------------------------------
void gtpu_l4_stack::send_indication(const gtpv1u_error_indication& gtp_ies)
......@@ -345,18 +206,6 @@ void gtpu_l4_stack::send_indication(const gtpv1u_error_indication& gtp_ies)
}
msg.dump_to(oss);
std::string bstream = oss.str();
switch (gtp_ies.r_endpoint.ss_family) {
case AF_INET: {
const struct sockaddr_in * const sin = reinterpret_cast<const sockaddr_in* const>(&gtp_ies.r_endpoint);
udp_s.async_send_to(reinterpret_cast<const char*>(bstream.c_str()), bstream.length(), *sin);
}
break;
case AF_INET6: {
const struct sockaddr_in6 * const sin6 = reinterpret_cast<const sockaddr_in6* const>(&gtp_ies.r_endpoint);
udp_s.async_send_to(reinterpret_cast<const char*>(bstream.c_str()), bstream.length(), *sin6);
}
break;
default:
Logger::gtpv1_u().debug( "gtpu_l4_stack::send_indication %s, no known peer addr", gtp_ies.get_msg_name());
}
udp_s.async_send_to(reinterpret_cast<const char*>(bstream.c_str()), bstream.length(), gtp_ies.r_endpoint);
}
......@@ -32,6 +32,7 @@
#include "itti.hpp"
#include "msg_gtpv1u.hpp"
#include "thread_sched.hpp"
#include "udp.hpp"
#include <iostream>
#include <map>
......@@ -45,101 +46,10 @@
namespace gtpv1u {
class gtpu_l4_stack;
static const uint16_t default_port = 2152;
class udp_server
{
public:
udp_server(const struct in_addr& address, const uint16_t port_num)
: app_(nullptr), port_(port_num)
{
socket_ = create_socket (address, port_);
if (socket_ > 0) {
Logger::udp().debug( "udp_server::udp_server(%s:%d)", conv::toString(address).c_str(), port_);
} else {
Logger::udp().error( "udp_server::udp_server(%s:%d)", conv::toString(address).c_str(), port_);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
throw std::system_error(socket_, std::generic_category(), "GTPV1-U socket creation failed!");
}
}
udp_server(const struct in6_addr& address, const uint16_t port_num)
: app_(nullptr), port_(port_num)
{
socket_ = create_socket (address, port_);
if (socket_ > 0) {
Logger::udp().debug( "udp_server::udp_server(%s:%d)", conv::toString(address).c_str(), port_);
} else {
Logger::udp().error( "udp_server::udp_server(%s:%d)", conv::toString(address).c_str(), port_);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
throw std::system_error(socket_, std::generic_category(), "GTPV1-U socket creation failed!");
}
}
udp_server(char * address, const uint16_t port_num)
: app_(nullptr), port_(port_num)
{
socket_ = create_socket (address, port_);
if (socket_ > 0) {
Logger::udp().debug( "udp_server::udp_server(%s:%d)", address, port_);
} else {
Logger::udp().error( "udp_server::udp_server(%s:%d)", address, port_);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
throw std::system_error(socket_, std::generic_category(), "GTPV1-U socket creation failed!");
}
}
~udp_server()
{
close(socket_);
}
void udp_read_loop(const util::thread_sched_params& thread_sched_params);
void async_send_to(const char* send_buffer, const ssize_t num_bytes, const struct sockaddr_in& peer_addr)
{
//Logger::udp().trace( "udp_server::async_send_to(%s:%d) %d bytes", toString(peer_addr.sin_addr).c_str(), peer_addr.sin_port, num_bytes);
ssize_t bytes_written = sendto (socket_, send_buffer, num_bytes, 0, (struct sockaddr *)&peer_addr, sizeof (struct sockaddr_in));
if (bytes_written != num_bytes) {
Logger::udp().error( "sendto failed(%d:%s)\n", errno, strerror (errno));
}
}
void async_send_to(const char* send_buffer, const ssize_t num_bytes, const struct sockaddr_in6& peer_addr)
{
ssize_t bytes_written = sendto (socket_, send_buffer, num_bytes, 0, (struct sockaddr *)&peer_addr, sizeof (struct sockaddr_in6));
if (bytes_written != num_bytes) {
Logger::udp().error( "sendto failed(%d:%s)\n", errno, strerror (errno));
}
}
void start_receive(gtpu_l4_stack * gtp_stack, const util::thread_sched_params& sched_params);
protected:
int create_socket (const struct in_addr& address, const uint16_t port);
int create_socket (const struct in6_addr& address, const uint16_t port);
int create_socket (char * address, const uint16_t port_num);
// void handle_receive(const int& error, std::size_t bytes_transferred);
static void handle_send(const char *, /*buffer*/
const int& /*error*/,
std::size_t /*bytes_transferred*/)
{
}
gtpu_l4_stack* app_;
std::thread thread_;
int socket_;
uint16_t port_;
#define UDP_RECV_BUFFER_SIZE 8192
char recv_buffer_[UDP_RECV_BUFFER_SIZE];
};
class gtpu_l4_stack {
class gtpu_l4_stack : public udp_application {
#define GTPV1U_T3_RESPONSE_MS 1000
#define GTPV1U_N3_REQUESTS 5
#define GTPV1U_PROC_TIME_OUT_MS ((GTPV1U_T3_RESPONSE_MS) * (GTPV1U_N3_REQUESTS + 1))
......@@ -162,7 +72,7 @@ public:
gtpu_l4_stack(const struct in_addr& address, const uint16_t port_num, const util::thread_sched_params& sched_params);
gtpu_l4_stack(const struct in6_addr& address, const uint16_t port_num, const util::thread_sched_params& sched_params);
gtpu_l4_stack(char * ip_address, const uint16_t port_num, const util::thread_sched_params& sched_params);
virtual void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len);
virtual void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& r_endpoint);
void handle_receive_message_cb(const gtpv1u_msg& msg, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const task_id_t& task_id, bool &error, uint64_t& gtpc_tx_id);
void send_g_pdu(const struct sockaddr_in& peer_addr, const teid_t teid, const char* payload, const ssize_t payload_len);
......
......@@ -32,6 +32,7 @@
#include "3gpp_29.274.h"
#include "3gpp_29.281.h"
#include "endpoint.hpp"
#include "common_defs.h"
#include <utility>
......@@ -43,16 +44,14 @@ namespace gtpv1u {
class gtpv1u_ies_container {
public:
static const uint8_t msg_id = 0;
struct sockaddr_storage r_endpoint;
socklen_t r_endpoint_addr_len;
endpoint r_endpoint;
std::pair<bool, uint32_t> teid;
std::pair<bool, uint16_t> sequence_number;
std::pair<bool, uint8_t> npdu_number;
gtpv1u_ies_container() : r_endpoint(), r_endpoint_addr_len(0), teid(), sequence_number(), npdu_number() {}
gtpv1u_ies_container() : r_endpoint(), teid(), sequence_number(), npdu_number() {}
gtpv1u_ies_container(const gtpv1u_ies_container& i) :
r_endpoint(i.r_endpoint),
r_endpoint_addr_len(i.r_endpoint_addr_len),
teid(i.teid),
sequence_number(i.sequence_number),
npdu_number(i.npdu_number) {}
......@@ -60,7 +59,6 @@ public:
gtpv1u_ies_container& operator=(gtpv1u_ies_container other)
{
std::swap(r_endpoint, other.r_endpoint);
std::swap(r_endpoint_addr_len, other.r_endpoint_addr_len);
std::swap(teid, other.teid);
std::swap(sequence_number, other.sequence_number);
std::swap(npdu_number, other.npdu_number);
......
......@@ -23,10 +23,11 @@ add_library(GTPV2C STATIC
gtpv2c.cpp
)
include_directories(${SRC_TOP_DIR}/gtpv2c)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/itti)
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}/oai_spgw_c)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
This diff is collapsed.
......@@ -29,14 +29,11 @@
#define FILE_GTPV2C_HPP_SEEN
#include "3gpp_29.274.hpp"
#include "endpoint.hpp"
#include "itti.hpp"
#include "udp.hpp"
#include "uint_generator.hpp"
#include <boost/array.hpp>
#include <boost/bind.hpp>
#include <boost/asio/ip/udp.hpp>
#include <boost/asio/ip/address.hpp>
#include <boost/asio.hpp>
#include <iostream>
#include <map>
#include <memory>
......@@ -46,11 +43,13 @@
#include "msg_gtpv2c.hpp"
namespace gtpv2c {
static const uint16_t default_port = 2123;
class gtpv2c_procedure {
public:
std::shared_ptr<gtpv2c_msg> retry_msg;
boost::asio::ip::udp::endpoint remote_endpoint;
endpoint remote_endpoint;
timer_id_t retry_timer_id;
timer_id_t proc_cleanup_timer_id;
uint64_t gtpc_tx_id;
......@@ -83,81 +82,31 @@ public:
retry_count(p.retry_count) {}
};
class gtpv2c_stack;
class udp_server
{
public:
udp_server(boost::asio::io_service& io_service, boost::asio::ip::address address, const unsigned short port_num)
: app(nullptr), local_address_(address), socket_(io_service, boost::asio::ip::udp::endpoint(address, port_num))
{
boost::asio::socket_base::reuse_address option(true);
socket_.set_option(option);
Logger::udp().debug( "udp_server::udp_server(%s:%d) for GTPv2-C", address.to_string().c_str(), port_num);
}
void async_send_to(boost::shared_ptr<std::string> message, boost::asio::ip::udp::endpoint remote_endpoint)
{
Logger::udp().trace( "udp_server::async_send_to(%s:%d) %d bytes", remote_endpoint.address().to_string().c_str(), remote_endpoint.port(), message.get()->size());
socket_.async_send_to(boost::asio::buffer(*message), remote_endpoint,
boost::bind(&udp_server::handle_send, this, message,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
void start_receive(gtpv2c_stack * gtp_stack)
{
app = gtp_stack;
socket_.async_receive_from(
boost::asio::buffer(recv_buffer_), remote_endpoint_,
boost::bind(&udp_server::handle_receive, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
protected:
void handle_receive(const boost::system::error_code& error, std::size_t bytes_transferred);
void handle_send(boost::shared_ptr<std::string> /*message*/,
const boost::system::error_code& /*error*/,
std::size_t /*bytes_transferred*/)
{
}
gtpv2c_stack* app;
boost::asio::ip::udp::socket socket_;
boost::asio::ip::udp::endpoint remote_endpoint_;
boost::asio::ip::address local_address_;
boost::array<char, 4096> recv_buffer_;
};
enum gtpv2c_transaction_action {
DELETE_TX = 0,
CONTINUE_TX
};
class gtpv2c_stack {
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;
uint32_t id;
udp_server udp_s;
udp_server udp_s_allocated;
// seems no need for std::atomic_uint32_t
uint32_t seq_num;
uint32_t restart_counter;
uint32_t 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;
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;
boost::array<char, 4096> send_buffer;
static const char* msg_type2cstr[256];
uint32_t get_next_seq_num();
......@@ -177,24 +126,24 @@ protected:
public:
static const uint8_t version = 2;
gtpv2c_stack(const std::string& ip_address, const unsigned short port_num);
virtual void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_message_cb(const gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint, const task_id_t& task_id, bool& error, uint64_t& gtpc_tx_id);
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);
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 boost::asio::ip::udp::endpoint& dest, const gtpv2c_echo_request& gtp_ies, const task_id_t& task_id, const uint64_t gtp_tx_id);
virtual void send_triggered_message(const boost::asio::ip::udp::endpoint& dest, const gtpv2c_echo_response& gtp_ies, const uint64_t gtp_tx_id, const gtpv2c_transaction_action& a = DELETE_TX);
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 boost::asio::ip::udp::endpoint& dest, const teid_t 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 boost::asio::ip::udp::endpoint& dest, const teid_t 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 boost::asio::ip::udp::endpoint& dest, const teid_t 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 boost::asio::ip::udp::endpoint& dest, const teid_t teid, const gtpv2c_release_access_bearers_request& gtp_ies, const task_id_t& task_id, const uint64_t gtp_tx_id);
virtual void send_triggered_message(const boost::asio::ip::udp::endpoint& dest, 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 boost::asio::ip::udp::endpoint& dest, 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 boost::asio::ip::udp::endpoint& dest, 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 boost::asio::ip::udp::endpoint& dest, 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 uint32_t send_initial_message(const endpoint& r_endpoint, const teid_t 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 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 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 teid, const gtpv2c_release_access_bearers_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 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);
void time_out_event(const uint32_t timer_id, const task_id_t& task_id, bool &error);
};
......
......@@ -269,6 +269,7 @@ ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/common ${CMAKE_CURRENT_BI
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)
if(${SGW_AUTOTEST})
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/gtpv1u ${CMAKE_CURRENT_BINARY_DIR}/gtpv1u)
endif(${SGW_AUTOTEST})
......@@ -290,6 +291,7 @@ include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/gtpv2c)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/sgwc)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
add_executable(spgwc
......@@ -310,5 +312,5 @@ if(${SGW_AUTOTEST})
SET(GTPV1U_LIB GTPV1U)
endif(${SGW_AUTOTEST})
target_link_libraries (spgwc ${ASAN} -Wl,--start-group CN_UTILS SGWC PGWC ${GTPV1U_LIB} GTPV2C PFCP 3GPP_COMMON_TYPES gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system )
target_link_libraries (spgwc ${ASAN} -Wl,--start-group CN_UTILS SGWC PGWC UDP ${GTPV1U_LIB} GTPV2C PFCP 3GPP_COMMON_TYPES gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system )
......@@ -25,7 +25,6 @@
#include "sgwc_app.hpp"
#include "sgwc_config.hpp"
#include <boost/asio.hpp>
#include <iostream>
#include <thread>
#include <signal.h>
......@@ -44,7 +43,6 @@ pgw_app *pgw_app_inst = nullptr;
sgwc_app *sgwc_app_inst = nullptr;
pgw_config pgw_cfg;
sgwc_config sgwc_cfg;
boost::asio::io_service io_service;
//------------------------------------------------------------------------------
void my_app_signal_handler(int s){
......@@ -119,9 +117,6 @@ int main(int argc, char **argv)
fflush(fp);
fclose(fp);
// once all udp servers initialized
io_service.run();
pause();
return 0;
}
......@@ -270,7 +270,7 @@ ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/utils ${CMAKE_CURR
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/pfcp ${CMAKE_CURRENT_BINARY_DIR}/pfcp)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/spgwu/simpleswitch ${CMAKE_CURRENT_BINARY_DIR}/simpleswitch)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/gtpv1u ${CMAKE_CURRENT_BINARY_DIR}/gtpv1u)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/gtpv2c ${CMAKE_CURRENT_BINARY_DIR}/gtpv2c)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/udp ${CMAKE_CURRENT_BINARY_DIR}/udp)
################################################################################
......@@ -287,6 +287,7 @@ include_directories(${SRC_TOP_DIR}/gtpv1u)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/spgwu)
include_directories(${SRC_TOP_DIR}/spgwu/simpleswitch)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
add_executable(spgwu
......@@ -305,6 +306,6 @@ ENDIF(STATIC_LINKING)
# folly glog dl double-conversion for FB folly library
target_link_libraries (spgwu ${ASAN} -Wl,--start-group CN_UTILS SPGWU SPGW_SWITCH GTPV2C GTPV1U PFCP 3GPP_COMMON_TYPES gflags glog dl double-conversion folly -Wl,--end-group
target_link_libraries (spgwu ${ASAN} -Wl,--start-group CN_UTILS SPGWU SPGW_SWITCH UDP GTPV1U PFCP 3GPP_COMMON_TYPES gflags glog dl double-conversion folly -Wl,--end-group
pthread m rt config++ event boost_system)
......@@ -24,6 +24,7 @@ include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/oai_spgwc)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
add_library(PFCP STATIC
......
This diff is collapsed.
This diff is collapsed.
......@@ -26,6 +26,7 @@ include_directories(${SRC_TOP_DIR}/gtpv2c)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/pgwc)
include_directories(${SRC_TOP_DIR}/sgwc)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
......
......@@ -285,7 +285,8 @@ pgw_app::pgw_app (const std::string& config_file) : m_s5s8_cp_teid_generator(),
}
//------------------------------------------------------------------------------
void pgw_app::send_delete_session_response_cause_request_accepted (const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const
void pgw_app::send_delete_session_response_cause_request_accepted (const uint64_t gtpc_tx_id, const teid_t teid,
const endpoint& r_endpoint) const
{
cause_t cause = {.cause_value = REQUEST_ACCEPTED, .pce = 0, .bce = 0, .cs = 0};
itti_s5s8_delete_session_response *s5s8 = new itti_s5s8_delete_session_response(TASK_PGWC_APP, TASK_PGWC_S5S8);
......@@ -304,7 +305,8 @@ void pgw_app::send_delete_session_response_cause_request_accepted (const uint64_
}
//------------------------------------------------------------------------------
void pgw_app::send_modify_bearer_response_cause_context_not_found (const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const
void pgw_app::send_modify_bearer_response_cause_context_not_found (const uint64_t gtpc_tx_id, const teid_t teid,
const endpoint& r_endpoint) const
{
cause_t cause = {.cause_value = CONTEXT_NOT_FOUND, .pce = 0, .bce = 0, .cs = 0};
itti_s5s8_modify_bearer_response *s5s8 = new itti_s5s8_modify_bearer_response(TASK_PGWC_APP, TASK_PGWC_S5S8);
......@@ -322,7 +324,8 @@ void pgw_app::send_modify_bearer_response_cause_context_not_found (const uint64_
}
}
//------------------------------------------------------------------------------
void pgw_app::send_delete_session_response_cause_context_not_found (const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const
void pgw_app::send_delete_session_response_cause_context_not_found (const uint64_t gtpc_tx_id, const teid_t teid,
const endpoint& r_endpoint) const
{
cause_t cause = {.cause_value = CONTEXT_NOT_FOUND, .pce = 0, .bce = 0, .cs = 0};
itti_s5s8_delete_session_response *s5s8 = new itti_s5s8_delete_session_response(TASK_PGWC_APP, TASK_PGWC_S5S8);
......@@ -340,7 +343,8 @@ void pgw_app::send_delete_session_response_cause_context_not_found (const uint64
}
}
//------------------------------------------------------------------------------
void pgw_app::send_release_access_bearers_response_cause_context_not_found(const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const
void pgw_app::send_release_access_bearers_response_cause_context_not_found(const uint64_t gtpc_tx_id, const teid_t teid,
const endpoint& r_endpoint) const
{
cause_t cause = {.cause_value = CONTEXT_NOT_FOUND, .pce = 0, .bce = 0, .cs = 0};
itti_s5s8_release_access_bearers_response *s5s8 = new itti_s5s8_release_access_bearers_response(TASK_PGWC_APP, TASK_PGWC_S5S8);
......@@ -358,7 +362,8 @@ void pgw_app::send_release_access_bearers_response_cause_context_not_found(const
}
}
//------------------------------------------------------------------------------
void pgw_app::send_release_access_bearers_response_cause_request_accepted(const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const
void pgw_app::send_release_access_bearers_response_cause_request_accepted(const uint64_t gtpc_tx_id, const teid_t teid,
const endpoint& r_endpoint) const
{
cause_t cause = {.cause_value = REQUEST_ACCEPTED, .pce = 0, .bce = 0, .cs = 0};
itti_s5s8_release_access_bearers_response *s5s8 = new itti_s5s8_release_access_bearers_response(TASK_PGWC_APP, TASK_PGWC_S5S8);
......
......@@ -92,11 +92,11 @@ public:
pgw_app(pgw_app const&) = delete;
void operator=(pgw_app const&) = delete;
void send_delete_session_response_cause_request_accepted (const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const;
void send_delete_session_response_cause_context_not_found (const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const;
void send_modify_bearer_response_cause_context_not_found (const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const;
void send_release_access_bearers_response_cause_context_not_found(const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const;
void send_release_access_bearers_response_cause_request_accepted(const uint64_t gtpc_tx_id, const teid_t teid, boost::asio::ip::udp::endpoint& r_endpoint) const;
void send_delete_session_response_cause_request_accepted (const uint64_t gtpc_tx_id, const teid_t teid, const endpoint& r_endpoint) const;
void send_delete_session_response_cause_context_not_found (const uint64_t gtpc_tx_id, const teid_t teid, const endpoint& r_endpoint) const;
void send_modify_bearer_response_cause_context_not_found (const uint64_t gtpc_tx_id, const teid_t teid, const endpoint& r_endpoint) const;
void send_release_access_bearers_response_cause_context_not_found(const uint64_t gtpc_tx_id, const teid_t teid, const endpoint& r_endpoint) const;
void send_release_access_bearers_response_cause_request_accepted(const uint64_t gtpc_tx_id, const teid_t teid, const endpoint& r_endpoint) const;
fteid_t build_s5s8_cp_fteid(const struct in_addr ipv4_address, const teid_t teid);
fteid_t generate_s5s8_cp_fteid(const struct in_addr ipv4_address);
......
This diff is collapsed.
......@@ -31,6 +31,8 @@
#include "3gpp_29.244.h"
#include "3gpp_29.274.h"
#include "gtpv2c.hpp"
#include "pfcp.hpp"
#include "thread_sched.hpp"
#include <arpa/inet.h>
......@@ -136,7 +138,6 @@ typedef struct interface_cfg_s {
typedef struct itti_cfg_s {
util::thread_sched_params itti_timer_sched_params;
util::thread_sched_params s11_sched_params;
util::thread_sched_params sx_sched_params;
util::thread_sched_params s5s8_sched_params;
util::thread_sched_params pgw_app_sched_params;
......@@ -223,6 +224,18 @@ public:
}
force_push_pco = true;
ue_mtu = 1500;
itti.itti_timer_sched_params.sched_priority = 85;
itti.sx_sched_params.sched_priority = 84;
itti.s5s8_sched_params.sched_priority = 84;
itti.pgw_app_sched_params.sched_priority = 84;
itti.async_cmd_sched_params.sched_priority = 84;
s5s8_cp.thread_rd_sched_params.sched_priority = 90;
s5s8_cp.port = gtpv2c::default_port;
sx.thread_rd_sched_params.sched_priority = 90;
sx.port = pfcp::default_port;
};
~pgw_config();
void lock() {m_rw_lock.lock();};
......
......@@ -814,13 +814,15 @@ void pgw_context::handle_itti_msg (std::shared_ptr<itti_s5s8_release_access_bear
}
} else {
Logger::pgwc_app().warn( "S5S8 RELEASE_ACCESS_BEARERS_REQUEST procedure TODO");
pgw_app_inst->send_release_access_bearers_response_cause_request_accepted (s5_trigger->gtpc_tx_id, sp->sgw_fteid_s5_s8_cp.teid_gre_key, s5_trigger->r_endpoint);
pgw_app_inst->send_release_access_bearers_response_cause_request_accepted (s5_trigger->gtpc_tx_id, sp->sgw_fteid_s5_s8_cp.teid_gre_key,
s5_trigger->r_endpoint);
}
lock_pdn.unlock();
}
} else {
Logger::pgwc_app().info( "S5S8 RELEASE_ACCESS_BEARERS_REQUEST procedure failed, context not found");
pgw_app_inst->send_release_access_bearers_response_cause_context_not_found (s5_trigger->gtpc_tx_id, sp->sgw_fteid_s5_s8_cp.teid_gre_key, s5_trigger->r_endpoint);
pgw_app_inst->send_release_access_bearers_response_cause_context_not_found (s5_trigger->gtpc_tx_id, sp->sgw_fteid_s5_s8_cp.teid_gre_key,
s5_trigger->r_endpoint);
}
}
......
......@@ -277,9 +277,7 @@ class pgw_context : public std::enable_shared_from_this<pgw_context> {
public:
pgw_context() : m_pending_procedures(), m_apns(),
imsi(), imsi_unauthenticated_indicator(false), apns(), pending_procedures() {
msisdn = {0};
}
imsi(), imsi_unauthenticated_indicator(false), apns(), pending_procedures(), msisdn() {}
pgw_context(pgw_context& b) = delete;
......
......@@ -102,7 +102,7 @@ void pgw_s5s8_task (void *args_p)
}
//------------------------------------------------------------------------------
pgw_s5s8::pgw_s5s8 () : gtpv2c_stack(string(inet_ntoa(pgw_cfg.s5s8_cp.addr4)), pgw_cfg.s5s8_cp.port)
pgw_s5s8::pgw_s5s8 () : gtpv2c_stack(string(inet_ntoa(pgw_cfg.s5s8_cp.addr4)), pgw_cfg.s5s8_cp.port, pgw_cfg.s5s8_cp.thread_rd_sched_params)
{
Logger::pgwc_s5s8().startup("Starting...");
if (itti_inst->create_task(TASK_PGWC_S5S8, pgw_s5s8_task, nullptr) ) {
......@@ -133,7 +133,7 @@ void pgw_s5s8::send_msg(itti_s5s8_release_access_bearers_response& i)
send_triggered_message(i.r_endpoint, i.teid, i.gtp_ies, i.gtpc_tx_id);
}
//------------------------------------------------------------------------------
void pgw_s5s8::handle_receive_create_session_request(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgw_s5s8::handle_receive_create_session_request(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -156,7 +156,7 @@ void pgw_s5s8::handle_receive_create_session_request(gtpv2c_msg& msg, const boos
// else ignore
}
//------------------------------------------------------------------------------
void pgw_s5s8::handle_receive_delete_session_request(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgw_s5s8::handle_receive_delete_session_request(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -179,7 +179,7 @@ void pgw_s5s8::handle_receive_delete_session_request(gtpv2c_msg& msg, const boos
// else ignore
}
//------------------------------------------------------------------------------
void pgw_s5s8::handle_receive_modify_bearer_request(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgw_s5s8::handle_receive_modify_bearer_request(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -202,7 +202,7 @@ void pgw_s5s8::handle_receive_modify_bearer_request(gtpv2c_msg& msg, const boost
// else ignore
}
//------------------------------------------------------------------------------
void pgw_s5s8::handle_receive_release_access_bearers_request(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgw_s5s8::handle_receive_release_access_bearers_request(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -225,7 +225,7 @@ void pgw_s5s8::handle_receive_release_access_bearers_request(gtpv2c_msg& msg, co
// else ignore
}
//------------------------------------------------------------------------------
void pgw_s5s8::handle_receive_gtpv2c_msg(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgw_s5s8::handle_receive_gtpv2c_msg(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
//Logger::pgwc_s5s8().trace( "handle_receive_gtpv2c_msg msg type %d length %d", msg.get_message_type(), msg.get_message_length());
switch (msg.get_message_type()) {
......@@ -334,7 +334,8 @@ void pgw_s5s8::handle_receive_gtpv2c_msg(gtpv2c_msg& msg, const boost::asio::ip:
}
}
//------------------------------------------------------------------------------
void pgw_s5s8::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint)
void pgw_s5s8::handle_receive(char* recv_buffer, const std::size_t bytes_transferred,
const endpoint& remote_endpoint)
{
//Logger::pgwc_s5s8().info( "handle_receive(%d bytes)", bytes_transferred);
//std::cout << string_to_hex(recv_buffer, bytes_transferred) << std::endl;
......
......@@ -40,18 +40,18 @@ private:
std::thread::id thread_id;
std::thread thread;
void handle_receive_gtpv2c_msg(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_create_session_request(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint );
void handle_receive_delete_session_request(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_modify_bearer_request(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_release_access_bearers_request(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_gtpv2c_msg(gtpv2c::gtpv2c_msg& msg, const endpoint& r_endpoint);
void handle_receive_create_session_request(gtpv2c::gtpv2c_msg& msg, const endpoint& r_endpoint);
void handle_receive_delete_session_request(gtpv2c::gtpv2c_msg& msg, const endpoint& r_endpoint);
void handle_receive_modify_bearer_request(gtpv2c::gtpv2c_msg& msg, const endpoint& r_endpoint);
void handle_receive_release_access_bearers_request(gtpv2c::gtpv2c_msg& msg, const endpoint& r_endpoint);
public:
pgw_s5s8();
pgw_s5s8(pgw_s5s8 const&) = delete;
void operator=(pgw_s5s8 const&) = delete;
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& r_endpoint);
void send_msg(itti_s5s8_create_session_response& m);
void send_msg(itti_s5s8_delete_session_response& m);
......
......@@ -98,7 +98,7 @@ int session_establishment_procedure::run(std::shared_ptr<itti_s5s8_create_sessio
sx_ser->seid = 0;
sx_ser->trxn_id = this->trxn_id;
//sx_ser->l_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(0xC0A8A064), 8805);
sx_ser->r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(htobe32(up_node_id.u1.ipv4_address.s_addr)), 8805);
sx_ser->r_endpoint = endpoint(up_node_id.u1.ipv4_address, pfcp::default_port);
sx_triggered = std::shared_ptr<itti_sxab_session_establishment_request>(sx_ser);
//-------------------
......@@ -309,7 +309,7 @@ int modify_bearer_procedure::run(std::shared_ptr<itti_s5s8_modify_bearer_request
itti_sxab_session_modification_request *sx_smr = new itti_sxab_session_modification_request(TASK_PGWC_APP, TASK_PGWC_SX);
sx_smr->seid = ppc->up_fseid.seid;
sx_smr->trxn_id = this->trxn_id;
sx_smr->r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(htobe32(ppc->up_fseid.ipv4_address.s_addr)), pgw_cfg.sx.port);
sx_smr->r_endpoint = endpoint(ppc->up_fseid.ipv4_address, pgw_cfg.sx.port);
sx_triggered = std::shared_ptr<itti_sxab_session_modification_request>(sx_smr);
......@@ -764,7 +764,7 @@ int release_access_bearers_procedure::run(std::shared_ptr<itti_s5s8_release_acce
itti_sxab_session_modification_request *sx_smr = new itti_sxab_session_modification_request(TASK_PGWC_APP, TASK_PGWC_SX);
sx_smr->seid = ppc->up_fseid.seid;
sx_smr->trxn_id = this->trxn_id;
sx_smr->r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(htobe32(ppc->up_fseid.ipv4_address.s_addr)), pgw_cfg.sx.port);
sx_smr->r_endpoint = endpoint(ppc->up_fseid.ipv4_address, pgw_cfg.sx.port);
sx_triggered = std::shared_ptr<itti_sxab_session_modification_request>(sx_smr);
......@@ -885,7 +885,7 @@ int delete_session_procedure::run(std::shared_ptr<itti_s5s8_delete_session_reque
itti_sxab_session_deletion_request *sx = new itti_sxab_session_deletion_request(TASK_PGWC_APP, TASK_PGWC_SX);
sx->seid = ppc->up_fseid.seid;
sx->trxn_id = this->trxn_id;
sx->r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(htobe32(ppc->up_fseid.ipv4_address.s_addr)), pgw_cfg.sx.port);
sx->r_endpoint = endpoint(ppc->up_fseid.ipv4_address, pgw_cfg.sx.port);
sx_triggered = std::shared_ptr<itti_sxab_session_deletion_request>(sx);
......
......@@ -176,7 +176,7 @@ void pgwc_sxab_task (void *args_p)
}
//------------------------------------------------------------------------------
pgwc_sxab::pgwc_sxab() : pfcp_l4_stack(string(inet_ntoa(pgw_cfg.sx.addr4)), pgw_cfg.sx.port)
pgwc_sxab::pgwc_sxab() : pfcp_l4_stack(string(inet_ntoa(pgw_cfg.sx.addr4)), pgw_cfg.sx.port, pgw_cfg.sx.thread_rd_sched_params)
{
Logger::pgwc_sx().startup("Starting...");
// TODO refine this, look at RFC5905
......@@ -204,7 +204,7 @@ pgwc_sxab::pgwc_sxab() : pfcp_l4_stack(string(inet_ntoa(pgw_cfg.sx.addr4)), pgw_
}
//------------------------------------------------------------------------------
void pgwc_sxab::handle_receive_pfcp_msg(pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgwc_sxab::handle_receive_pfcp_msg(pfcp_msg& msg, const endpoint& remote_endpoint)
{
Logger::pgwc_sx().trace( "handle_receive_pfcp_msg msg type %d length %d", msg.get_message_type(), msg.get_message_length());
switch (msg.get_message_type()) {
......@@ -251,7 +251,7 @@ void pgwc_sxab::handle_receive_pfcp_msg(pfcp_msg& msg, const boost::asio::ip::ud
}
}
//------------------------------------------------------------------------------
void pgwc_sxab::handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgwc_sxab::handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -269,7 +269,7 @@ void pgwc_sxab::handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const boos
}
}
//------------------------------------------------------------------------------
void pgwc_sxab::handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgwc_sxab::handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -287,7 +287,7 @@ void pgwc_sxab::handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const boo
}
}
//------------------------------------------------------------------------------
void pgwc_sxab::handle_receive_association_setup_request(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgwc_sxab::handle_receive_association_setup_request(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -346,7 +346,7 @@ void pgwc_sxab::handle_receive_association_setup_request(pfcp::pfcp_msg& msg, co
}
//------------------------------------------------------------------------------
void pgwc_sxab::handle_receive_session_establishment_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgwc_sxab::handle_receive_session_establishment_response(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -369,7 +369,7 @@ void pgwc_sxab::handle_receive_session_establishment_response(pfcp::pfcp_msg& ms
// else ignore
}
//------------------------------------------------------------------------------
void pgwc_sxab::handle_receive_session_modification_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgwc_sxab::handle_receive_session_modification_response(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -392,7 +392,7 @@ void pgwc_sxab::handle_receive_session_modification_response(pfcp::pfcp_msg& msg
// else ignore
}
//------------------------------------------------------------------------------
void pgwc_sxab::handle_receive_session_deletion_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void pgwc_sxab::handle_receive_session_deletion_response(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -430,7 +430,7 @@ void pgwc_sxab::send_heartbeat_request(std::shared_ptr<pfcp_association>& a)
if (node_id.node_id_type == pfcp::NODE_ID_TYPE_IPV4_ADDRESS) {
a->timer_heartbeat = itti_inst->timer_setup(5,0, TASK_PGWC_SX, TASK_PGWC_SX_TIMEOUT_HEARTBEAT_REQUEST, a->hash_node_id);
boost::asio::ip::udp::endpoint r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(htobe32(node_id.u1.ipv4_address.s_addr)), 8805);
endpoint r_endpoint = endpoint(node_id.u1.ipv4_address, pfcp::default_port);
a->trxn_id_heartbeat = generate_trxn_id();
send_request(r_endpoint, h, TASK_PGWC_SX, a->trxn_id_heartbeat);
......@@ -439,7 +439,7 @@ void pgwc_sxab::send_heartbeat_request(std::shared_ptr<pfcp_association>& a)
}
}
//------------------------------------------------------------------------------
void pgwc_sxab::send_heartbeat_response(const boost::asio::ip::udp::endpoint& r_endpoint, const uint64_t trxn_id)
void pgwc_sxab::send_heartbeat_response(const endpoint& r_endpoint, const uint64_t trxn_id)
{
pfcp::pfcp_heartbeat_response h = {};
pfcp::recovery_time_stamp_t r = {.recovery_time_stamp = (uint32_t)recovery_time_stamp};
......@@ -462,7 +462,7 @@ void pgwc_sxab::send_sx_msg(itti_sxab_session_deletion_request& i)
send_request(i.r_endpoint, i.seid, i.pfcp_ies, TASK_PGWC_SX, i.trxn_id);
}
//------------------------------------------------------------------------------
void pgwc_sxab::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint)
void pgwc_sxab::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& remote_endpoint)
{
Logger::pgwc_sx().info( "handle_receive(%d bytes)", bytes_transferred);
//std::cout << string_to_hex(recv_buffer, bytes_transferred) << std::endl;
......
......@@ -88,18 +88,18 @@ public:
void send_sx_msg (itti_sxab_session_report_response& s) {};
void send_heartbeat_request(std::shared_ptr<pfcp_association>& a);
void send_heartbeat_response(const boost::asio::ip::udp::endpoint& r_endpoint, const uint64_t trxn_id);
void send_heartbeat_response(const endpoint& r_endpoint, const uint64_t trxn_id);
void handle_receive_pfcp_msg( pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_pfcp_msg( pfcp::pfcp_msg& msg, const endpoint& r_endpoint);
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& r_endpoint);
void handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_association_setup_request(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const endpoint& r_endpoint);
void handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const endpoint& r_endpoint);
void handle_receive_association_setup_request(pfcp::pfcp_msg& msg, const endpoint& r_endpoint);
void handle_receive_session_establishment_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_session_modification_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_session_deletion_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_session_establishment_response(pfcp::pfcp_msg& msg, const endpoint& r_endpoint);
void handle_receive_session_modification_response(pfcp::pfcp_msg& msg, const endpoint& r_endpoint);
void handle_receive_session_deletion_response(pfcp::pfcp_msg& msg, const endpoint& r_endpoint);
void time_out_itti_event(const uint32_t timer_id);
};
......
......@@ -26,6 +26,7 @@ include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/pgwc)
include_directories(${SRC_TOP_DIR}/sgwc)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
add_library (SGWC STATIC
......
This diff is collapsed.
......@@ -29,6 +29,7 @@
#ifndef FILE_SGWC_CONFIG_HPP_SEEN
#define FILE_SGWC_CONFIG_HPP_SEEN
#include "gtpv2c.hpp"
#include "thread_sched.hpp"
#include <libconfig.h++>
#include <mutex>
......@@ -106,7 +107,22 @@ public:
bool local_to_eNB;
itti_cfg_t itti;
sgwc_config() : m_rw_lock(), pid_dir(), instance(0), s11_cp(), s11_up(), s5s8_cp(), local_to_eNB(false) {};
sgwc_config() : m_rw_lock(), pid_dir(), instance(0), s11_cp(), s11_up(), s5s8_cp(), local_to_eNB(false)
{
itti.itti_timer_sched_params.sched_priority = 85;
itti.s11_sched_params.sched_priority = 84;
itti.s5s8_sched_params.sched_priority = 84;
itti.sgw_app_sched_params.sched_priority = 84;
itti.async_cmd_sched_params.sched_priority = 84;
s11_cp.thread_rd_sched_params.sched_priority = 95;
s11_cp.port = gtpv2c::default_port;
s11_up.thread_rd_sched_params.sched_priority = 95;
s5s8_cp.thread_rd_sched_params.sched_priority = 95;
s5s8_cp.port = gtpv2c::default_port;
};
void lock() {m_rw_lock.lock();};
void unlock() {m_rw_lock.unlock();};
int load(const std::string& config_file);
......
......@@ -157,7 +157,7 @@ int create_session_request_procedure::run(shared_ptr<sgw_eps_bearer_context> c)
//s5s8_csr->gtp_ies = msg.gtp_ies;
//s5s8_csr->l_endpoint = {};
// TODO PGW address in HSS
s5s8_csr->r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(ntohl(pgw_cfg.s5s8_cp.addr4.s_addr)), sgwc_cfg.s5s8_cp.port);
s5s8_csr->r_endpoint = endpoint(pgw_cfg.s5s8_cp.addr4, sgwc_cfg.s5s8_cp.port);
std::shared_ptr<itti_s5s8_create_session_request> msg = std::shared_ptr<itti_s5s8_create_session_request>(s5s8_csr);
int ret = itti_inst->send_msg(msg);
......@@ -279,7 +279,7 @@ int delete_session_request_procedure::run(shared_ptr<sgw_eps_bearer_context> c)
itti_s5s8_delete_session_request *s5s8_dsr = new itti_s5s8_delete_session_request(TASK_SGWC_APP, TASK_SGWC_S5S8);
s5s8_dsr->gtpc_tx_id = get_trxn_id();
s5s8_dsr->teid = pdn_connection->pgw_fteid_s5_s8_cp.teid_gre_key;
s5s8_dsr->r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(ntohl(pgw_cfg.s5s8_cp.addr4.s_addr)), sgwc_cfg.s5s8_cp.port);
s5s8_dsr->r_endpoint = endpoint(pgw_cfg.s5s8_cp.addr4, sgwc_cfg.s5s8_cp.port);
// transfer IEs from S11 msg to S5 msg
// The SGW shall include this IE on S5/S8 if it receives the Cause from the MME/SGSN.
......@@ -499,7 +499,7 @@ int modify_bearer_request_procedure::run(shared_ptr<sgw_eps_bearer_context> c)
px->gtpc_tx_id = util::uint_uid_generator<uint64_t>::get_instance().get_uid();
s5s8_mbr->gtpc_tx_id = px->gtpc_tx_id;
s5s8_mbr->teid = px->pdn->pgw_fteid_s5_s8_cp.teid_gre_key;
s5s8_mbr->r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(ntohl(pgw_cfg.s5s8_cp.addr4.s_addr)), sgwc_cfg.s5s8_cp.port);
s5s8_mbr->r_endpoint = endpoint(pgw_cfg.s5s8_cp.addr4, sgwc_cfg.s5s8_cp.port);
mei_t mei;
if (msg.gtp_ies.get(mei)) {
......@@ -718,7 +718,7 @@ int release_access_bearers_request_procedure::run(shared_ptr<sgw_eps_bearer_cont
itti_s5s8_release_access_bearers_request *s5s8 = new itti_s5s8_release_access_bearers_request(TASK_SGWC_APP, TASK_SGWC_S5S8);
s5s8->gtpc_tx_id = breal->gtpc_tx_id;
s5s8->teid = it_pdn->second->pgw_fteid_s5_s8_cp.teid_gre_key;
s5s8->r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(ntohl(it_pdn->second->pgw_fteid_s5_s8_cp.ipv4_address.s_addr)), pgw_cfg.s5s8_cp.port);
s5s8->r_endpoint = endpoint(it_pdn->second->pgw_fteid_s5_s8_cp.ipv4_address, pgw_cfg.s5s8_cp.port);
std::shared_ptr<itti_s5s8_release_access_bearers_request> msg = std::shared_ptr<itti_s5s8_release_access_bearers_request>(s5s8);
//breal->msg = msg;
......
......@@ -117,7 +117,7 @@ void sgw_s11_task (void *args_p)
}
//------------------------------------------------------------------------------
sgw_s11::sgw_s11 () : gtpv2c_stack(string(inet_ntoa(sgwc_cfg.s11_cp.addr4)), sgwc_cfg.s11_cp.port)
sgw_s11::sgw_s11 () : gtpv2c_stack(string(inet_ntoa(sgwc_cfg.s11_cp.addr4)), sgwc_cfg.s11_cp.port, sgwc_cfg.s11_cp.thread_rd_sched_params)
{
Logger::sgwc_s11().startup("Starting...");
if (itti_inst->create_task(TASK_SGWC_S11, sgw_s11_task, nullptr) ) {
......@@ -148,7 +148,7 @@ void sgw_s11::send_msg(itti_s11_release_access_bearers_response& i)
send_triggered_message(i.r_endpoint, i.teid, i.gtp_ies, i.gtpc_tx_id);
}
//------------------------------------------------------------------------------
void sgw_s11::handle_receive_create_session_request(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s11::handle_receive_create_session_request(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -171,7 +171,7 @@ void sgw_s11::handle_receive_create_session_request(gtpv2c_msg& msg, const boost
// else ignore
}
//------------------------------------------------------------------------------
void sgw_s11::handle_receive_delete_session_request(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s11::handle_receive_delete_session_request(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -194,7 +194,7 @@ void sgw_s11::handle_receive_delete_session_request(gtpv2c_msg& msg, const boost
// else ignore
}
//------------------------------------------------------------------------------
void sgw_s11::handle_receive_modify_bearer_request(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s11::handle_receive_modify_bearer_request(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -217,7 +217,7 @@ void sgw_s11::handle_receive_modify_bearer_request(gtpv2c_msg& msg, const boost:
// else ignore
}
//------------------------------------------------------------------------------
void sgw_s11::handle_receive_release_access_bearers_request(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s11::handle_receive_release_access_bearers_request(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -240,7 +240,7 @@ void sgw_s11::handle_receive_release_access_bearers_request(gtpv2c_msg& msg, con
// else ignore
}
//------------------------------------------------------------------------------
void sgw_s11::handle_receive_echo_request(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s11::handle_receive_echo_request(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -259,7 +259,7 @@ void sgw_s11::handle_receive_echo_request(gtpv2c_msg& msg, const boost::asio::ip
}
}
//------------------------------------------------------------------------------
void sgw_s11::handle_receive_echo_response(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s11::handle_receive_echo_response(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -278,7 +278,7 @@ void sgw_s11::handle_receive_echo_response(gtpv2c_msg& msg, const boost::asio::i
}
}
//------------------------------------------------------------------------------
void sgw_s11::send_echo_response(const boost::asio::ip::udp::endpoint& r_endpoint, const uint64_t trxn_id)
void sgw_s11::send_echo_response(const endpoint& r_endpoint, const uint64_t trxn_id)
{
gtpv2c_echo_response h = {};
recovery_t r = {.restart_counter = 0};
......@@ -287,7 +287,7 @@ void sgw_s11::send_echo_response(const boost::asio::ip::udp::endpoint& r_endpoin
}
//------------------------------------------------------------------------------
void sgw_s11::handle_receive_gtpv2c_msg(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s11::handle_receive_gtpv2c_msg(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
//Logger::sgwc_s11().trace( "handle_receive_gtpv2c_msg msg type %d length %d", msg.get_message_type(), msg.get_message_length());
switch (msg.get_message_type()) {
......@@ -398,7 +398,7 @@ void sgw_s11::handle_receive_gtpv2c_msg(gtpv2c_msg& msg, const boost::asio::ip::
}
}
//------------------------------------------------------------------------------
void sgw_s11::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s11::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& remote_endpoint)
{
//Logger::sgwc_s11().info( "handle_receive(%d bytes)", bytes_transferred);
//std::cout << string_to_hex(recv_buffer, bytes_transferred) << std::endl;
......
......@@ -40,27 +40,27 @@ private:
std::thread::id thread_id;
std::thread thread;
void handle_receive_gtpv2c_msg(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_echo_request(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint );
void handle_receive_echo_response(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint );
void handle_receive_create_session_request(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint );
void handle_receive_delete_session_request(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_modify_bearer_request(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_release_access_bearers_request(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_gtpv2c_msg(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint);
void handle_receive_echo_request(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint );
void handle_receive_echo_response(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint );
void handle_receive_create_session_request(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint );
void handle_receive_delete_session_request(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint);
void handle_receive_modify_bearer_request(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint);
void handle_receive_release_access_bearers_request(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint);
public:
sgw_s11();
sgw_s11(sgw_s11 const&) = delete;
void operator=(sgw_s11 const&) = delete;
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& remote_endpoint);
void send_msg(itti_s11_create_session_response& m);
void send_msg(itti_s11_delete_session_response& m);
void send_msg(itti_s11_modify_bearer_response& m);
void send_msg(itti_s11_release_access_bearers_response& m);
void send_echo_response(const boost::asio::ip::udp::endpoint& r_endpoint, const uint64_t trxn_id);
void send_echo_response(const endpoint& r_endpoint, const uint64_t trxn_id);
void time_out_itti_event(const uint32_t timer_id);
};
......
......@@ -100,7 +100,7 @@ void sgw_s5s8_task (void *args_p)
}
//------------------------------------------------------------------------------
sgw_s5s8::sgw_s5s8 () : gtpv2c_stack(string(inet_ntoa(sgwc_cfg.s5s8_cp.addr4)), sgwc_cfg.s5s8_cp.port)
sgw_s5s8::sgw_s5s8 () : gtpv2c_stack(string(inet_ntoa(sgwc_cfg.s5s8_cp.addr4)), sgwc_cfg.s5s8_cp.port, sgwc_cfg.s5s8_cp.thread_rd_sched_params)
{
Logger::sgwc_s5s8().startup("Starting...");
if (itti_inst->create_task(TASK_SGWC_S5S8, sgw_s5s8_task, nullptr) ) {
......@@ -130,7 +130,7 @@ void sgw_s5s8::send_msg(itti_s5s8_release_access_bearers_request& i)
send_initial_message(i.r_endpoint, i.teid, i.gtp_ies, TASK_SGWC_S5S8, i.gtpc_tx_id);
}
//------------------------------------------------------------------------------
void sgw_s5s8::handle_receive_create_session_response(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s5s8::handle_receive_create_session_response(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -153,7 +153,7 @@ void sgw_s5s8::handle_receive_create_session_response(gtpv2c_msg& msg, const boo
// else ignore
}
//------------------------------------------------------------------------------
void sgw_s5s8::handle_receive_modify_bearer_response(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s5s8::handle_receive_modify_bearer_response(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -176,7 +176,7 @@ void sgw_s5s8::handle_receive_modify_bearer_response(gtpv2c_msg& msg, const boos
// else ignore
}
//------------------------------------------------------------------------------
void sgw_s5s8::handle_receive_release_access_bearers_response(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s5s8::handle_receive_release_access_bearers_response(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -199,7 +199,7 @@ void sgw_s5s8::handle_receive_release_access_bearers_response(gtpv2c_msg& msg, c
// else ignore
}
//------------------------------------------------------------------------------
void sgw_s5s8::handle_receive_delete_session_response(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s5s8::handle_receive_delete_session_response(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t gtpc_tx_id = 0;
......@@ -223,7 +223,7 @@ void sgw_s5s8::handle_receive_delete_session_response(gtpv2c_msg& msg, const boo
}
//------------------------------------------------------------------------------
void sgw_s5s8::handle_receive_gtpv2c_msg(gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s5s8::handle_receive_gtpv2c_msg(gtpv2c_msg& msg, const endpoint& remote_endpoint)
{
//Logger::sgwc_s5s8().trace( "handle_receive_gtpv2c_msg msg type %d length %d", msg.get_message_type(), msg.get_message_length());
switch (msg.get_message_type()) {
......@@ -334,7 +334,7 @@ void sgw_s5s8::handle_receive_gtpv2c_msg(gtpv2c_msg& msg, const boost::asio::ip:
}
}
//------------------------------------------------------------------------------
void sgw_s5s8::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint)
void sgw_s5s8::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& remote_endpoint)
{
//Logger::sgwc_s5s8().info( "handle_receive(%d bytes)", bytes_transferred);
//std::cout << string_to_hex(recv_buffer, bytes_transferred) << std::endl;
......
......@@ -40,18 +40,18 @@ private:
std::thread::id thread_id;
std::thread thread;
void handle_receive_gtpv2c_msg(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_create_session_response(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint );
void handle_receive_delete_session_response(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_modify_bearer_response(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_release_access_bearers_response(gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_gtpv2c_msg(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint);
void handle_receive_create_session_response(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint );
void handle_receive_delete_session_response(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint);
void handle_receive_modify_bearer_response(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint);
void handle_receive_release_access_bearers_response(gtpv2c::gtpv2c_msg& msg, const endpoint& remote_endpoint);
public:
sgw_s5s8();
sgw_s5s8(sgw_s5s8 const&) = delete;
void operator=(sgw_s5s8 const&) = delete;
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& remote_endpoint);
void send_msg(itti_s5s8_create_session_request& m);
void send_msg(itti_s5s8_delete_session_request& m);
......
......@@ -28,6 +28,7 @@ include_directories(${SRC_TOP_DIR}/oai_spgwu)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/spgwu)
include_directories(${SRC_TOP_DIR}/spgwu/simpleswitch)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
......
......@@ -27,6 +27,7 @@ include_directories(${SRC_TOP_DIR}/gtpv2c)
include_directories(${SRC_TOP_DIR}/oai_spgwu)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/spgwu)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
......
......@@ -34,7 +34,7 @@ using namespace pfcp;
extern spgwu::spgwu_sx *spgwu_sx_inst;
//------------------------------------------------------------------------------
bool pfcp_pdr::look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const uint32_t tunnel_id)
bool pfcp_pdr::look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const endpoint& r_endpoint, const uint32_t tunnel_id)
{
// implicit packet arrives from ACCESS interface
if (outer_header_removal.first) {
......
......@@ -30,6 +30,7 @@
#include <linux/ip.h>
#include <linux/ipv6.h>
#include "endpoint.hpp"
#include "msg_pfcp.hpp"
#include <mutex>
......@@ -90,7 +91,7 @@ namespace pfcp {
bool update(const pfcp::update_pdr& update, uint8_t& cause_value);
bool look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const uint32_t tunnel_id);
bool look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const endpoint& r_endpoint, const uint32_t tunnel_id);
bool look_up_pack_in_core(struct iphdr* const iph, const std::size_t num_bytes);
void buffering_requested(const char *buffer, const std::size_t num_bytes);
......
......@@ -410,6 +410,7 @@ void pfcp_switch::remove_pfcp_session(std::shared_ptr<pfcp::pfcp_session>& sessi
session->cleanup();
cp_fseid2pfcp_sessions.erase(session->cp_fseid);
up_seid2pfcp_sessions.erase(session->seid);
}
//------------------------------------------------------------------------------
void pfcp_switch::remove_pfcp_session(const pfcp::fseid_t& cp_fseid)
......@@ -730,14 +731,14 @@ void pfcp_switch::handle_pfcp_session_deletion_request(std::shared_ptr<itti_sxab
Logger::pfcp_switch().info(to_string());
}
//------------------------------------------------------------------------------
void pfcp_switch::pfcp_session_look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const uint32_t tunnel_id)
void pfcp_switch::pfcp_session_look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const endpoint& r_endpoint, const uint32_t tunnel_id)
{
std::shared_ptr<std::vector<std::shared_ptr<pfcp::pfcp_pdr>>> pdrs = {};
if (get_pfcp_ul_pdrs_by_up_teid(tunnel_id, pdrs)) {
bool nocp = false;
bool buff = false;
for (std::vector<std::shared_ptr<pfcp::pfcp_pdr>>::iterator it_pdr = pdrs->begin(); it_pdr < pdrs->end(); ++it_pdr) {
if ((*it_pdr)->look_up_pack_in_access(iph, num_bytes, r_endpoint, r_endpoint_addr_len, tunnel_id)) {
if ((*it_pdr)->look_up_pack_in_access(iph, num_bytes, r_endpoint, tunnel_id)) {
std::shared_ptr<pfcp::pfcp_session> ssession = {};
uint64_t lseid = 0;
if ((*it_pdr)->get(lseid)) {
......@@ -760,11 +761,11 @@ void pfcp_switch::pfcp_session_look_up_pack_in_access(struct iphdr* const iph, c
}
else {
//Logger::pfcp_switch().info( "pfcp_session_look_up_pack_in_access tunnel " TEID_FMT " not found", tunnel_id);
spgwu_s1u_inst->report_error_indication(r_endpoint, r_endpoint_addr_len, tunnel_id);
spgwu_s1u_inst->report_error_indication(r_endpoint, tunnel_id);
}
}
//------------------------------------------------------------------------------
void pfcp_switch::pfcp_session_look_up_pack_in_access(struct ipv6hdr* const ip6h, const std::size_t num_bytes, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const uint32_t tunnel_id)
void pfcp_switch::pfcp_session_look_up_pack_in_access(struct ipv6hdr* const ip6h, const std::size_t num_bytes, const endpoint& r_endpoint, const uint32_t tunnel_id)
{
//TODO
}
......
......@@ -152,10 +152,10 @@ public:
pfcp::fteid_t generate_fteid_s1u();
bool create_packet_in_access(std::shared_ptr<pfcp::pfcp_pdr>& pdr, const pfcp::fteid_t& in, uint8_t& cause);
void pfcp_session_look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const uint32_t tunnel_id);
void pfcp_session_look_up_pack_in_access(struct ipv6hdr* const iph, const std::size_t num_bytes, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const uint32_t tunnel_id);
void pfcp_session_look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len) {};
void pfcp_session_look_up_pack_in_access(struct ipv6hdr* const iph, const std::size_t num_bytes, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len) {};
void pfcp_session_look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const endpoint& r_endpoint, const uint32_t tunnel_id);
void pfcp_session_look_up_pack_in_access(struct ipv6hdr* const iph, const std::size_t num_bytes, const endpoint& r_endpoint, const uint32_t tunnel_id);
void pfcp_session_look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const endpoint& r_endpoint) {};
void pfcp_session_look_up_pack_in_access(struct ipv6hdr* const iph, const std::size_t num_bytes, const endpoint& r_endpoint) {};
//void pfcp_session_look_up(struct ethhdr* const ethh, const std::size_t num_bytes);
void pfcp_session_look_up_pack_in_core(const char *buffer, const std::size_t num_bytes);
......
......@@ -100,7 +100,7 @@ spgwu_s1u::spgwu_s1u () : gtpu_l4_stack(spgwu_cfg.s1_up.addr4, spgwu_cfg.s1_up.p
Logger::spgwu_s1u().startup( "Started" );
}
//------------------------------------------------------------------------------
void spgwu_s1u::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len)
void spgwu_s1u::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& r_endpoint)
{
#define GTPU_MESSAGE_FLAGS_POS_IN_UDP_PAYLOAD 0
struct gtpuhdr* gtpuh = (struct gtpuhdr*)&recv_buffer[0];
......@@ -119,9 +119,9 @@ void spgwu_s1u::handle_receive(char* recv_buffer, const std::size_t bytes_transf
struct iphdr* iph = (struct iphdr*)&recv_buffer[gtp_payload_offset];
if (iph->version == 4) {
pfcp_switch_inst->pfcp_session_look_up_pack_in_access(iph, gtp_payload_length, r_endpoint, r_endpoint_addr_len, tunnel_id);
pfcp_switch_inst->pfcp_session_look_up_pack_in_access(iph, gtp_payload_length, r_endpoint, tunnel_id);
} else if (iph->version == 6) {
pfcp_switch_inst->pfcp_session_look_up_pack_in_access((struct ipv6hdr*)iph, gtp_payload_length, r_endpoint, r_endpoint_addr_len, tunnel_id);
pfcp_switch_inst->pfcp_session_look_up_pack_in_access((struct ipv6hdr*)iph, gtp_payload_length, r_endpoint, tunnel_id);
} else {
Logger::spgwu_s1u().trace( "Unknown GTPU_G_PDU packet");
}
......@@ -133,7 +133,7 @@ void spgwu_s1u::handle_receive(char* recv_buffer, const std::size_t bytes_transf
gtpv1u_msg msg = {};
try {
msg.load_from(iss);
handle_receive_gtpv1u_msg(msg, r_endpoint, r_endpoint_addr_len);
handle_receive_gtpv1u_msg(msg, r_endpoint);
} catch (gtpu_exception& e) {
Logger::spgwu_s1u().info( "handle_receive exception %s", e.what());
}
......@@ -141,21 +141,21 @@ void spgwu_s1u::handle_receive(char* recv_buffer, const std::size_t bytes_transf
} else {
struct iphdr* iph = (struct iphdr*)&recv_buffer[0];
if (iph->version == 4) {
pfcp_switch_inst->pfcp_session_look_up_pack_in_access(iph, bytes_transferred, r_endpoint, r_endpoint_addr_len);
pfcp_switch_inst->pfcp_session_look_up_pack_in_access(iph, bytes_transferred, r_endpoint);
} else if (iph->version == 6) {
pfcp_switch_inst->pfcp_session_look_up_pack_in_access((struct ipv6hdr*)iph, bytes_transferred, r_endpoint, r_endpoint_addr_len);
pfcp_switch_inst->pfcp_session_look_up_pack_in_access((struct ipv6hdr*)iph, bytes_transferred, r_endpoint);
} else {
Logger::spgwu_s1u().trace( "Unknown IPX packet");
}
}
}
//------------------------------------------------------------------------------
void spgwu_s1u::handle_receive_gtpv1u_msg(gtpv1u_msg& msg, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len)
void spgwu_s1u::handle_receive_gtpv1u_msg(gtpv1u_msg& msg, const endpoint& r_endpoint)
{
//Logger::spgwu_s1u().trace( "handle_receive_gtpv1u_msg msg type %d length %d", msg.get_message_type(), msg.get_message_length());
switch (msg.get_message_type()) {
case GTPU_ECHO_REQUEST:
handle_receive_echo_request(msg, r_endpoint, r_endpoint_addr_len);
handle_receive_echo_request(msg, r_endpoint);
break;
case GTPU_ECHO_RESPONSE:
case GTPU_ERROR_INDICATION:
......@@ -189,7 +189,7 @@ void spgwu_s1u::send_g_pdu(const struct in6_addr& peer_addr, const uint16_t peer
gtpu_l4_stack::send_g_pdu(peer_sock_addr, tunnel_id, send_buffer, num_bytes);
}
//------------------------------------------------------------------------------
void spgwu_s1u::handle_receive_echo_request(gtpv1u_msg& msg, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len)
void spgwu_s1u::handle_receive_echo_request(gtpv1u_msg& msg, const endpoint& r_endpoint)
{
itti_s1u_echo_request *echo = new itti_s1u_echo_request(TASK_SPGWU_S1U, TASK_SPGWU_APP);
......@@ -198,7 +198,6 @@ void spgwu_s1u::handle_receive_echo_request(gtpv1u_msg& msg, const struct sockad
echo->gtp_ies.r_endpoint = r_endpoint;
echo->gtp_ies.r_endpoint_addr_len = r_endpoint_addr_len;
echo->gtp_ies.set_teid(msg.get_teid());
uint16_t sn = 0;
......@@ -224,11 +223,10 @@ void spgwu_s1u::handle_itti_msg (std::shared_ptr<itti_s1u_error_indication> m)
send_indication(m->gtp_ies);
}
//------------------------------------------------------------------------------
void spgwu_s1u::report_error_indication(const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const uint32_t tunnel_id)
void spgwu_s1u::report_error_indication(const endpoint& r_endpoint, const uint32_t tunnel_id)
{
itti_s1u_error_indication *error_ind = new itti_s1u_error_indication(TASK_SPGWU_S1U, TASK_SPGWU_S1U);
error_ind->gtp_ies.r_endpoint = r_endpoint;
error_ind->gtp_ies.r_endpoint_addr_len = r_endpoint_addr_len;
error_ind->gtp_ies.set_teid(0);
tunnel_endpoint_identifier_data_i_t tun_data = {};
......@@ -236,7 +234,7 @@ void spgwu_s1u::report_error_indication(const struct sockaddr_storage& r_endpoin
error_ind->gtp_ies.set(tun_data);
gtp_u_peer_address_t peer_address = {};
if (xgpp_conv::sockaddr_storage_to_gtp_u_peer_address(r_endpoint, peer_address)) {
if (xgpp_conv::endpoint_to_gtp_u_peer_address(r_endpoint, peer_address)) {
error_ind->gtp_ies.set(peer_address);
} else {
// mandatory ie
......
......@@ -28,6 +28,7 @@
#ifndef FILE_SGWU_S1U_HPP_SEEN
#define FILE_SGWU_S1U_HPP_SEEN
#include "endpoint.hpp"
#include "gtpv1u.hpp"
#include "itti_msg_s1u.hpp"
#include "msg_gtpv1u.hpp"
......@@ -44,8 +45,8 @@ private:
std::thread::id thread_id;
std::thread thread;
void handle_receive_gtpv1u_msg(gtpv1u::gtpv1u_msg& msg, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len);
void handle_receive_echo_request(gtpv1u::gtpv1u_msg& msg, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len);
void handle_receive_gtpv1u_msg(gtpv1u::gtpv1u_msg& msg, const endpoint& r_endpoint);
void handle_receive_echo_request(gtpv1u::gtpv1u_msg& msg, const endpoint& r_endpoint);
public:
spgwu_s1u();
......@@ -64,14 +65,14 @@ public:
//void send_msg (itti_s1u_supported_extension_headers_notification& s) {};
//void send_msg (itti_s1u_end_marker& s) {};
void handle_receive_s1u_msg( gtpv1u::gtpv1u_msg& msg, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len);
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len);
void handle_receive_s1u_msg( gtpv1u::gtpv1u_msg& msg, const endpoint& r_endpoint);
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& r_endpoint);
void send_g_pdu(const struct in_addr& peer_addr, const uint16_t peer_udp_port, const uint32_t tunnel_id, const char* send_buffer, const ssize_t num_bytes);
void send_g_pdu(const struct in6_addr& peer_addr, const uint16_t peer_udp_port, const uint32_t tunnel_id, const char* send_buffer, const ssize_t num_bytes);
void time_out_itti_event(const uint32_t timer_id);
void report_error_indication(const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const uint32_t tunnel_id);
void report_error_indication(const endpoint& r_endpoint, const uint32_t tunnel_id);
};
}
#endif /* FILE_SGWU_S1U_HPP_SEEN */
......@@ -155,7 +155,6 @@ void spgwu_app::handle_itti_msg (std::shared_ptr<itti_s1u_echo_request> m)
// May insert a call to a function here(throttle for example)
s1u_resp->gtp_ies.r_endpoint = m->gtp_ies.r_endpoint;
s1u_resp->gtp_ies.r_endpoint_addr_len = m->gtp_ies.r_endpoint_addr_len;
s1u_resp->gtp_ies.teid = m->gtp_ies.teid;
s1u_resp->gtp_ies.sequence_number = m->gtp_ies.sequence_number;
......
......@@ -31,6 +31,8 @@
#include "3gpp_29.244.h"
#include "gtpv1u.hpp"
#include "pfcp.hpp"
#include "thread_sched.hpp"
#include <libconfig.h++>
#include <mutex>
......@@ -126,7 +128,22 @@ public:
std::vector<pfcp::node_id_t> spgwcs;
spgwu_config() : m_rw_lock(), pid_dir(), instance(0), s1_up(), sgi(), gateway(), sx(), itti(), pdns(), spgwcs(), max_pfcp_sessions(100) {};
spgwu_config() : m_rw_lock(), pid_dir(), instance(0), s1_up(), sgi(), gateway(), sx(), itti(), pdns(), spgwcs(), max_pfcp_sessions(100)
{
itti.itti_timer_sched_params.sched_priority = 85;
itti.s1u_sched_params.sched_priority = 84;
itti.sx_sched_params.sched_priority = 84;
itti.spgwu_app_sched_params.sched_priority = 84;
itti.async_cmd_sched_params.sched_priority = 84;
s1_up.thread_rd_sched_params.sched_priority = 98;
s1_up.port = gtpv1u::default_port;
sgi.thread_rd_sched_params.sched_priority = 98;
sx.thread_rd_sched_params.sched_priority = 95;
sx.port = pfcp::default_port;
};
void lock() {m_rw_lock.lock();};
void unlock() {m_rw_lock.unlock();};
int load(const std::string& config_file);
......
......@@ -33,8 +33,6 @@
#include "spgwu_pfcp_association.hpp"
#include "spgwu_sx.hpp"
#include <boost/asio.hpp>
#include <boost/asio/ip/address.hpp>
#include <chrono>
#include <ctime>
#include <stdexcept>
......@@ -186,7 +184,7 @@ void spgwu_sx_task (void *args_p)
}
//------------------------------------------------------------------------------
spgwu_sx::spgwu_sx () : pfcp_l4_stack(std::string(inet_ntoa(spgwu_cfg.sx.addr4)), spgwu_cfg.sx.port)
spgwu_sx::spgwu_sx () : pfcp_l4_stack(std::string(inet_ntoa(spgwu_cfg.sx.addr4)), spgwu_cfg.sx.port, spgwu_cfg.sx.thread_rd_sched_params)
{
Logger::spgwu_sx().startup("Starting...");
......@@ -230,7 +228,7 @@ spgwu_sx::spgwu_sx () : pfcp_l4_stack(std::string(inet_ntoa(spgwu_cfg.sx.addr4))
}
//------------------------------------------------------------------------------
void spgwu_sx::handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void spgwu_sx::handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -249,7 +247,7 @@ void spgwu_sx::handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const boost
}
}
//------------------------------------------------------------------------------
void spgwu_sx::handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void spgwu_sx::handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -268,7 +266,7 @@ void spgwu_sx::handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const boos
}
}
//------------------------------------------------------------------------------
void spgwu_sx::handle_receive_association_setup_response(pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void spgwu_sx::handle_receive_association_setup_response(pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -298,7 +296,7 @@ void spgwu_sx::handle_receive_association_setup_response(pfcp_msg& msg, const bo
}
//------------------------------------------------------------------------------
void spgwu_sx::handle_receive_session_establishment_request(pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void spgwu_sx::handle_receive_session_establishment_request(pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -321,7 +319,7 @@ void spgwu_sx::handle_receive_session_establishment_request(pfcp_msg& msg, const
// else ignore
}
//------------------------------------------------------------------------------
void spgwu_sx::handle_receive_session_modification_request(pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void spgwu_sx::handle_receive_session_modification_request(pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -344,7 +342,7 @@ void spgwu_sx::handle_receive_session_modification_request(pfcp_msg& msg, const
// else ignore
}
//------------------------------------------------------------------------------
void spgwu_sx::handle_receive_session_deletion_request(pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void spgwu_sx::handle_receive_session_deletion_request(pfcp_msg& msg, const endpoint& remote_endpoint)
{
bool error = true;
uint64_t trxn_id = 0;
......@@ -368,7 +366,7 @@ void spgwu_sx::handle_receive_session_deletion_request(pfcp_msg& msg, const boos
}
//------------------------------------------------------------------------------
void spgwu_sx::handle_receive_pfcp_msg(pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint)
void spgwu_sx::handle_receive_pfcp_msg(pfcp_msg& msg, const endpoint& remote_endpoint)
{
//Logger::spgwu_sx().trace( "handle_receive_pfcp_msg msg type %d length %d", msg.get_message_type(), msg.get_message_length());
switch (msg.get_message_type()) {
......@@ -466,8 +464,8 @@ void spgwu_sx::start_association(const pfcp::node_id_t& node_id)
a.pfcp_ies.set(r);
a.pfcp_ies.set(up_function_features);
if (node_id.node_id_type == pfcp::NODE_ID_TYPE_IPV4_ADDRESS) {
//a.l_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(spgwu_cfg.sx.addr4), 0);
a.r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(htobe32(node_id.u1.ipv4_address.s_addr)), 8805);
//a.l_endpoint = endpoint(boost::asio::ip::address_v4(spgwu_cfg.sx.addr4), 0);
a.r_endpoint = endpoint(node_id.u1.ipv4_address, pfcp::default_port);
send_sx_msg(a);
} else {
Logger::spgwu_sx().warn( "TODO start_association() node_id IPV6, FQDN!");
......@@ -489,8 +487,8 @@ void spgwu_sx::send_sx_msg(const pfcp::fseid_t& cp_fseid, const pfcp::pfcp_sessi
pfcp::node_id_t this_node_id = {};
if (spgwu_cfg.get_pfcp_node_id(this_node_id) == RETURNok) {
if (this_node_id.node_id_type == pfcp::NODE_ID_TYPE_IPV4_ADDRESS) {
//a.l_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(spgwu_cfg.sx.addr4), 0);
isrr.r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(htobe32(this_node_id.u1.ipv4_address.s_addr)), 8805);
//a.l_endpoint = endpoint(boost::asio::ip::address_v4(spgwu_cfg.sx.addr4), 0);
isrr.r_endpoint = endpoint(this_node_id.u1.ipv4_address, pfcp::default_port);
send_sx_msg(isrr);
} else {
Logger::spgwu_sx().warn( "TODO start_association() node_id IPV6, FQDN!");
......@@ -508,7 +506,7 @@ void spgwu_sx::send_heartbeat_request(std::shared_ptr<pfcp_association>& a)
if (node_id.node_id_type == pfcp::NODE_ID_TYPE_IPV4_ADDRESS) {
a->timer_heartbeat = itti_inst->timer_setup(5,0, TASK_SPGWU_SX, TASK_SPGWU_SX_TIMEOUT_HEARTBEAT_REQUEST, a->hash_node_id);
boost::asio::ip::udp::endpoint r_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(htobe32(node_id.u1.ipv4_address.s_addr)), 8805);
endpoint r_endpoint = endpoint(node_id.u1.ipv4_address, pfcp::default_port);
a->trxn_id_heartbeat = generate_trxn_id();
send_request(r_endpoint, h, TASK_SPGWU_SX, a->trxn_id_heartbeat);
......@@ -517,7 +515,7 @@ void spgwu_sx::send_heartbeat_request(std::shared_ptr<pfcp_association>& a)
}
}
//------------------------------------------------------------------------------
void spgwu_sx::send_heartbeat_response(const boost::asio::ip::udp::endpoint& r_endpoint, const uint64_t trxn_id)
void spgwu_sx::send_heartbeat_response(const endpoint& r_endpoint, const uint64_t trxn_id)
{
pfcp::pfcp_heartbeat_response h = {};
pfcp::recovery_time_stamp_t r = {.recovery_time_stamp = (uint32_t)recovery_time_stamp};
......@@ -525,7 +523,7 @@ void spgwu_sx::send_heartbeat_response(const boost::asio::ip::udp::endpoint& r_e
send_response(r_endpoint, h, trxn_id);
}
//------------------------------------------------------------------------------
void spgwu_sx::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint)
void spgwu_sx::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& remote_endpoint)
{
Logger::spgwu_sx().info( "handle_receive(%d bytes)", bytes_transferred);
//std::cout << string_to_hex(recv_buffer, bytes_transferred) << std::endl;
......
......@@ -28,13 +28,12 @@
#ifndef FILE_SGWU_SX_HPP_SEEN
#define FILE_SGWU_SX_HPP_SEEN
#include "endpoint.hpp"
#include "pfcp.hpp"
#include "itti_msg_sxab.hpp"
#include "msg_pfcp.hpp"
#include "spgwu_pfcp_association.hpp"
#include <boost/asio.hpp>
#include <boost/asio/ip/address.hpp>
#include <thread>
namespace spgwu {
......@@ -94,18 +93,18 @@ public:
void send_sx_msg(const pfcp::fseid_t& cp_fseid, const pfcp::pfcp_session_report_request& s);
void send_heartbeat_request(std::shared_ptr<pfcp_association>& a);
void send_heartbeat_response(const boost::asio::ip::udp::endpoint& r_endpoint, const uint64_t trxn_id);
void send_heartbeat_response(const endpoint& r_endpoint, const uint64_t trxn_id);
void handle_receive_pfcp_msg( pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_pfcp_msg( pfcp::pfcp_msg& msg, const endpoint& remote_endpoint);
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& remote_endpoint);
// node related
void handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_association_setup_response(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_heartbeat_request(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint);
void handle_receive_heartbeat_response(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint);
void handle_receive_association_setup_response(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint);
// session related
void handle_receive_session_establishment_request(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_session_modification_request(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_session_deletion_request(pfcp::pfcp_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_session_establishment_request(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint);
void handle_receive_session_modification_request(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint);
void handle_receive_session_deletion_request(pfcp::pfcp_msg& msg, const endpoint& remote_endpoint);
......
################################################################################
# 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
################################################################################
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}/itti)
include_directories(${SRC_TOP_DIR}/gtpv1u)
include_directories(${SRC_TOP_DIR}/gtpv2c)
include_directories(${SRC_TOP_DIR}/oai_spgwu)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/spgwu)
include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
add_library (UDP STATIC
udp.cpp
)
/*
* 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 udp.cpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#include "udp.hpp"
#include <cstdlib>
//------------------------------------------------------------------------------
void udp_application::handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& r_endpoint)
{
Logger::udp().warn( "Missing implementation of interface udp_application\n");
}
//------------------------------------------------------------------------------
void udp_application::start_receive(udp_application * gtp_stack, const util::thread_sched_params& sched_params)
{
Logger::udp().warn( "Missing implementation of interface udp_application\n");
}
//------------------------------------------------------------------------------
static std::string string_to_hex(const std::string& input)
{
static const char* const lut = "0123456789ABCDEF";
size_t len = input.length();
std::string output;
output.reserve(2 * len);
for (size_t i = 0; i < len; ++i)
{
const unsigned char c = input[i];
output.push_back(lut[c >> 4]);
output.push_back(lut[c & 15]);
}
return output;
}
//------------------------------------------------------------------------------
void udp_server::udp_read_loop(const util::thread_sched_params& sched_params)
{
endpoint r_endpoint = {};
size_t bytes_received = 0;
sched_params.apply(TASK_NONE, Logger::udp());
while (1) {
r_endpoint.addr_storage_len = sizeof(struct sockaddr_storage);
if ((bytes_received = recvfrom (socket_, recv_buffer_, UDP_RECV_BUFFER_SIZE, 0, (struct sockaddr *)&r_endpoint.addr_storage, &r_endpoint.addr_storage_len)) > 0) {
app_->handle_receive(recv_buffer_, bytes_received, r_endpoint);
} else {
Logger::udp().error( "Recvfrom failed %s\n", strerror (errno));
}
}
}
//------------------------------------------------------------------------------
int udp_server::create_socket (const struct in_addr &address, const uint16_t port)
{
struct sockaddr_in addr = {};
int sd = 0;
/*
* Create UDP socket
*/
if ((sd = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
/*
* Socket creation has failed...
*/
Logger::udp().error( "Socket creation failed (%s)\n", strerror (errno));
return errno;
}
addr.sin_family = AF_INET;
addr.sin_port = htons (port);
addr.sin_addr.s_addr = address.s_addr;
std::string ipv4 = conv::toString(address);
Logger::udp().debug("Creating new listen socket on address %s and port %" PRIu16 "\n", ipv4.c_str(), port);
if (bind (sd, (struct sockaddr *)&addr, sizeof (struct sockaddr_in)) < 0) {
/*
* Bind failed
*/
Logger::udp().error("Socket bind failed (%s) for address %s and port %" PRIu16 "\n", strerror (errno), ipv4.c_str(), port);
close (sd);
return errno;
}
sa_family = AF_INET;
return sd;
}
//------------------------------------------------------------------------------
int udp_server::create_socket (const struct in6_addr &address, const uint16_t port)
{
struct sockaddr_in6 addr = {};
int sd = 0;
/*
* Create UDP socket
*/
if ((sd = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
/*
* Socket creation has failed...
*/
Logger::udp().error( "Socket creation failed (%s)\n", strerror (errno));
return errno;
}
addr.sin6_family = AF_INET6;
addr.sin6_port = htons (port);
addr.sin6_addr = address;
std::string ipv6 = conv::toString(address);
Logger::udp().debug("Creating new listen socket on address %s and port %" PRIu16 "\n", ipv6.c_str(), port);
if (bind (sd, (struct sockaddr *)&addr, sizeof (struct sockaddr_in6)) < 0) {
/*
* Bind failed
*/
Logger::udp().error("Socket bind failed (%s) for address %s and port %" PRIu16 "\n", strerror (errno), ipv6.c_str(), port);
close (sd);
return errno;
}
sa_family = AF_INET6;
return sd;
}
//------------------------------------------------------------------------------
int udp_server::create_socket (const char * address, const uint16_t port_num)
{
unsigned char buf_in_addr[sizeof(struct in6_addr)];
if (inet_pton (AF_INET, address, buf_in_addr) == 1) {
struct in_addr addr4 = {};
memcpy (&addr4, buf_in_addr, sizeof (struct in_addr));
return create_socket(addr4, port_num);
} else if (inet_pton (AF_INET6, address, buf_in_addr) == 1) {
struct in6_addr addr6 = {};
memcpy (&addr6, buf_in_addr, sizeof (struct in6_addr));
return create_socket(addr6, port_num);
} else {
Logger::udp().error( "udp_server::create_socket(%s:%d)", address, port_num);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
throw std::system_error(socket_, std::generic_category(), "UDP socket creation failed!");
}
}
//------------------------------------------------------------------------------
void udp_server::start_receive(udp_application * app, const util::thread_sched_params& sched_params)
{
app_ = app;
Logger::udp().trace( "udp_server::start_receive");
thread_ = std::thread(&udp_server::udp_read_loop,this, sched_params);
thread_.detach();
}
\ No newline at end of file
/*
* 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 udp.hpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_UDP_HPP_SEEN
#define FILE_UDP_HPP_SEEN
#include "conversions.hpp"
#include "endpoint.hpp"
#include "itti.hpp"
#include "thread_sched.hpp"
#include <arpa/inet.h>
#include <inttypes.h>
#include <sys/socket.h>
#include <iostream>
#include <map>
#include <memory>
#include <stdint.h>
#include <string>
#include <system_error>
#include <thread>
#include <utility>
#include <vector>
class udp_application
{
public:
virtual void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const endpoint& r_endpoint);
virtual void start_receive(udp_application * gtp_stack, const util::thread_sched_params& sched_params);
};
class udp_server
{
public:
udp_server(const struct in_addr& address, const uint16_t port_num)
: app_(nullptr), port_(port_num)
{
socket_ = create_socket (address, port_);
if (socket_ > 0) {
Logger::udp().debug( "udp_server::udp_server(%s:%d)", conv::toString(address).c_str(), port_);
sa_family = AF_INET;
} else {
Logger::udp().error( "udp_server::udp_server(%s:%d)", conv::toString(address).c_str(), port_);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
throw std::system_error(socket_, std::generic_category(), "GTPV1-U socket creation failed!");
}
}
udp_server(const struct in6_addr& address, const uint16_t port_num)
: app_(nullptr), port_(port_num)
{
socket_ = create_socket (address, port_);
if (socket_ > 0) {
Logger::udp().debug( "udp_server::udp_server(%s:%d)", conv::toString(address).c_str(), port_);
sa_family = AF_INET6;
} else {
Logger::udp().error( "udp_server::udp_server(%s:%d)", conv::toString(address).c_str(), port_);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
throw std::system_error(socket_, std::generic_category(), "GTPV1-U socket creation failed!");
}
}
udp_server(const char * address, const uint16_t port_num)
: app_(nullptr), port_(port_num)
{
socket_ = create_socket (address, port_);
if (socket_ > 0) {
Logger::udp().debug( "udp_server::udp_server(%s:%d)", address, port_);
} else {
Logger::udp().error( "udp_server::udp_server(%s:%d)", address, port_);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
throw std::system_error(socket_, std::generic_category(), "GTPV1-U socket creation failed!");
}
}
~udp_server()
{
close(socket_);
}
void udp_read_loop(const util::thread_sched_params& thread_sched_params);
void async_send_to(const char* send_buffer, const ssize_t num_bytes, const endpoint& r_endpoint)
{
ssize_t bytes_written = sendto (socket_, send_buffer, num_bytes, 0, (struct sockaddr *)&r_endpoint.addr_storage, r_endpoint.addr_storage_len);
if (bytes_written != num_bytes) {
Logger::udp().error( "sendto failed(%d:%s)\n", errno, strerror (errno));
}
}
void async_send_to(const char* send_buffer, const ssize_t num_bytes, const struct sockaddr_in& r_endpoint)
{
ssize_t bytes_written = sendto (socket_, send_buffer, num_bytes, 0, (struct sockaddr *)&r_endpoint, sizeof(struct sockaddr_in));
if (bytes_written != num_bytes) {
Logger::udp().error( "sendto failed(%d:%s)\n", errno, strerror (errno));
}
}
void async_send_to(const char* send_buffer, const ssize_t num_bytes, const struct sockaddr_in6& r_endpoint)
{
ssize_t bytes_written = sendto (socket_, send_buffer, num_bytes, 0, (struct sockaddr *)&r_endpoint, sizeof(struct sockaddr_in6));
if (bytes_written != num_bytes) {
Logger::udp().error( "sendto failed(%d:%s)\n", errno, strerror (errno));
}
}
void start_receive(udp_application * gtp_stack, const util::thread_sched_params& sched_params);
protected:
int create_socket (const struct in_addr& address, const uint16_t port);
int create_socket (const struct in6_addr& address, const uint16_t port);
int create_socket (const char * address, const uint16_t port_num);
// void handle_receive(const int& error, std::size_t bytes_transferred);
static void handle_send(const char *, /*buffer*/
const int& /*error*/,
std::size_t /*bytes_transferred*/)
{
}
udp_application* app_;
std::thread thread_;
int socket_;
uint16_t port_;
sa_family_t sa_family;
#define UDP_RECV_BUFFER_SIZE 8192
char recv_buffer_[UDP_RECV_BUFFER_SIZE];
};
#endif /* FILE_UDP_HPP_SEEN */
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