GTP-U reomte done

This commit is contained in:
Sukchan Lee 2017-12-06 23:42:37 +09:00
parent 397f37cbb7
commit d2dcf4a877
11 changed files with 216 additions and 119 deletions

View File

@ -6,11 +6,13 @@
#include "gtp_node.h"
#include "gtp_xact.h"
pool_declare(gtp_node_pool, gtp_node_t, MAX_NUM_OF_GTP_CLIENT);
#define MAX_GTP_NODE_POOL_SIZE 512
pool_declare(gtp_node_pool, gtp_node_t, MAX_GTP_NODE_POOL_SIZE);
status_t gtp_node_init(void)
{
pool_init(&gtp_node_pool, MAX_NUM_OF_GTP_CLIENT);
pool_init(&gtp_node_pool, MAX_GTP_NODE_POOL_SIZE);
return CORE_OK;
}
@ -114,14 +116,42 @@ status_t gtp_remove_all_nodes(list_t *list)
return CORE_OK;
}
gtp_node_t* gtp_find_node(list_t *list, ip_t *ip)
static ip_t *gtp_node_ip(ip_t *ip, gtp_f_teid_t *f_teid)
{
d_assert(ip, return NULL,);
d_assert(f_teid, return NULL,);
memset(ip, 0, sizeof(ip_t));
if (f_teid->ipv4 && f_teid->ipv6)
{
ip->both.addr = f_teid->ip.both.addr;
memcpy(ip->both.addr6, f_teid->ip.both.addr6, IPV6_LEN);
}
else if (f_teid->ipv4)
{
ip->addr = f_teid->ip.addr;
}
else if (f_teid->ipv6)
{
memcpy(ip->addr6, f_teid->ip.addr6, IPV6_LEN);
}
else
d_assert(0, return NULL,);
return ip;
}
gtp_node_t* gtp_find_node(list_t *list, gtp_f_teid_t *f_teid)
{
gtp_node_t *node = NULL;
node = list_first(list);
while (node)
{
if (memcmp(&node->ip, ip, sizeof(ip_t)) == 0)
ip_t ip;
d_assert(gtp_node_ip(&ip, f_teid), return NULL,);
if (memcmp(&node->ip, &ip, sizeof(ip_t)) == 0)
break;
node = list_next(node);
@ -136,6 +166,7 @@ gtp_node_t *gtp_connect_node(list_t *list, gtp_f_teid_t *f_teid,
status_t rv;
gtp_node_t *node = NULL;
c_sockaddr_t *sa_list = NULL;
ip_t ip;
d_assert(list, return NULL,);
d_assert(f_teid, return NULL,);
@ -148,7 +179,8 @@ gtp_node_t *gtp_connect_node(list_t *list, gtp_f_teid_t *f_teid,
d_assert(rv == CORE_OK, return NULL,);
d_assert(node, return NULL,);
memcpy(&node->ip, &f_teid->ip, sizeof(ip_t));
d_assert(gtp_node_ip(&ip, f_teid), return NULL,);
memcpy(&node->ip, &ip, sizeof(ip_t));
core_freeaddrinfo(sa_list);

View File

@ -42,7 +42,7 @@ CORE_DECLARE(status_t) gtp_add_node(list_t *list, gtp_node_t **node,
CORE_DECLARE(status_t) gtp_remove_node(list_t *list, gtp_node_t *node);
CORE_DECLARE(status_t) gtp_remove_all_nodes(list_t *list);
CORE_DECLARE(gtp_node_t *) gtp_find_node(list_t *list, ip_t *ip);
CORE_DECLARE(gtp_node_t *) gtp_find_node(list_t *list, gtp_f_teid_t *f_teid);
CORE_DECLARE(gtp_node_t *) gtp_connect_node(
list_t *list, gtp_f_teid_t *f_teid,
c_uint16_t port, int no_ipv4, int no_ipv6, int prefer_ipv4);

View File

@ -40,7 +40,8 @@ status_t pgw_context_init()
list_init(&self.gtpc_list6);
gtp_node_init();
list_init(&self.sgw_list);
list_init(&self.sgw_s5c_list);
list_init(&self.sgw_s5u_list);
index_init(&pgw_sess_pool, MAX_POOL_OF_SESS);
index_init(&pgw_bearer_pool, MAX_POOL_OF_BEARER);
@ -89,7 +90,8 @@ status_t pgw_context_final()
index_final(&pgw_bearer_pool);
index_final(&pgw_sess_pool);
gtp_remove_all_nodes(&self.sgw_list);
gtp_remove_all_nodes(&self.sgw_s5c_list);
gtp_remove_all_nodes(&self.sgw_s5u_list);
gtp_node_final();
sock_remove_all_nodes(&self.gtpc_list);
@ -765,10 +767,10 @@ gtp_node_t *pgw_sgw_add_by_message(gtp_message_t *message)
sgw_s5c_teid = req->sender_f_teid_for_control_plane.data;
d_assert(sgw_s5c_teid, return NULL,);
sgw = gtp_find_node(&pgw_self()->sgw_list, &sgw_s5c_teid->ip);
sgw = gtp_find_node(&pgw_self()->sgw_s5c_list, sgw_s5c_teid);
if (!sgw)
{
sgw = gtp_connect_node(&pgw_self()->sgw_list, sgw_s5c_teid,
sgw = gtp_connect_node(&pgw_self()->sgw_s5c_list, sgw_s5c_teid,
pgw_self()->gtpc_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
@ -821,76 +823,6 @@ pgw_sess_t *pgw_sess_add_by_message(gtp_message_t *message)
return sess;
}
pgw_sess_t *pgw_sess_find_or_add_by_message(gtp_message_t *gtp_message)
{
status_t rv;
pgw_sess_t *sess = NULL;
gtp_node_t *sgw = NULL;
gtp_create_session_request_t *req = &gtp_message->create_session_request;
c_int8_t apn[MAX_APN_LEN];
if (req->imsi.presence == 0)
{
d_error("No IMSI");
return NULL;
}
if (req->sender_f_teid_for_control_plane.presence == 0)
{
d_error("No Sender F-TEID");
return NULL;
}
if (req->access_point_name.presence == 0)
{
d_error("No APN");
return NULL;
}
if (req->bearer_contexts_to_be_created.presence == 0)
{
d_error("No Bearer");
return NULL;
}
if (req->bearer_contexts_to_be_created.eps_bearer_id.presence == 0)
{
d_error("No EPS Bearer ID");
return NULL;
}
apn_parse(apn, req->access_point_name.data, req->access_point_name.len);
sess = pgw_sess_find_by_imsi_apn(req->imsi.data, req->imsi.len, apn);
if (!sess)
{
gtp_f_teid_t *sgw_s5c_teid = NULL;
sgw_s5c_teid = req->sender_f_teid_for_control_plane.data;
d_assert(sgw_s5c_teid, return NULL,);
sgw = gtp_find_node(&pgw_self()->sgw_list, &sgw_s5c_teid->ip);
if (!sgw)
{
sgw = gtp_connect_node(&pgw_self()->sgw_list, sgw_s5c_teid,
pgw_self()->gtpc_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
context_self()->parameter.prefer_ipv4);
d_assert(sgw, return NULL,);
rv = gtp_client(sgw);
d_assert(rv == CORE_OK, return NULL,);
}
sess = pgw_sess_add(req->imsi.data, req->imsi.len, apn,
req->bearer_contexts_to_be_created.eps_bearer_id.u8);
d_assert(sess, return NULL, "No Session Context");
/* Setup GTP Node between PGW and SGW */
SETUP_GTP_NODE(sess, sgw);
}
return sess;
}
hash_index_t* pgw_sess_first()
{
d_assert(self.sess_hash, return NULL, "Null param");

View File

@ -54,7 +54,8 @@ typedef struct _pgw_context_t {
c_uint32_t secondary;
} dns;
list_t sgw_list; /* SGW GTP Node List */
list_t sgw_s5c_list; /* SGW GTPC Node List */
list_t sgw_s5u_list; /* SGW GTPU Node List */
list_t ip_pool_list;
hash_t *sess_hash; /* hash table (IMSI+APN) */
@ -119,6 +120,7 @@ typedef struct _pgw_bearer_t {
list_t pf_list;
pgw_sess_t *sess;
gtp_node_t *gnode;
} pgw_bearer_t;
typedef struct _pgw_rule_t {

View File

@ -37,10 +37,6 @@ static int _gtpv1_tun_recv_cb(sock_id sock, void *data)
if (bearer)
{
gtp_header_t *gtp_h = NULL;
gtp_node_t gnode;
char buf[INET_ADDRSTRLEN];
memset(&gnode, 0, sizeof(gtp_node_t));
/* Add GTP-U header */
rv = pkbuf_header(recvbuf, GTPV1U_HEADER_LEN);
@ -64,15 +60,9 @@ static int _gtpv1_tun_recv_cb(sock_id sock, void *data)
gtp_h->teid = htonl(bearer->sgw_s5u_teid);
/* Send to SGW */
gnode.old_addr.sin.sin_addr.s_addr = bearer->sgw_s5u_addr;
gnode.old_addr.c_sa_port = htons(GTPV1_U_UDP_PORT);
gnode.old_addr.c_sa_family = AF_INET;
gnode.sock = pgw_self()->gtpu_sock;
d_trace(50, "Send S5U PDU (teid = 0x%x)to SGW(%s)\n",
bearer->sgw_s5u_teid,
CORE_ADDR(&gnode.old_addr, buf));
rv = gtp_send(&gnode, recvbuf);
d_trace(50, "Send S5U PDU (teid = 0x%x) to SGW\n",
bearer->sgw_s5u_teid);
rv = gtp_send(bearer->gnode, recvbuf);
}
else
{

View File

@ -4,7 +4,10 @@
#include "core_lib.h"
#include "gtp_types.h"
#include "gtp_node.h"
#include "gtp_path.h"
#include "context.h"
#include "pgw_event.h"
#include "pgw_context.h"
#include "pgw_gtp_path.h"
@ -13,7 +16,9 @@
void pgw_s5c_handle_create_session_request(
gtp_xact_t *xact, pgw_sess_t *sess, gtp_create_session_request_t *req)
{
status_t rv;
gtp_f_teid_t *sgw_s5c_teid, *sgw_s5u_teid;
gtp_node_t *sgw = NULL;
pgw_bearer_t *bearer = NULL;
gtp_bearer_qos_t bearer_qos;
gtp_ambr_t *ambr = NULL;
@ -72,6 +77,21 @@ void pgw_s5c_handle_create_session_request(
d_assert(sgw_s5u_teid, return, "Null param");
bearer->sgw_s5u_teid = ntohl(sgw_s5u_teid->teid);
bearer->sgw_s5u_addr = sgw_s5u_teid->ip.addr;
sgw = gtp_find_node(&pgw_self()->sgw_s5u_list, sgw_s5u_teid);
if (!sgw)
{
sgw = gtp_connect_node(&pgw_self()->sgw_s5u_list, sgw_s5u_teid,
pgw_self()->gtpu_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
context_self()->parameter.prefer_ipv4);
d_assert(sgw, return,);
rv = gtp_client(sgw);
d_assert(rv == CORE_OK, return,);
}
/* Setup GTP Node */
SETUP_GTP_NODE(bearer, sgw);
decoded = gtp_parse_bearer_qos(&bearer_qos,
&req->bearer_contexts_to_be_created.bearer_level_qos);
@ -114,6 +134,7 @@ void pgw_s5c_handle_create_bearer_response(
{
status_t rv;
gtp_f_teid_t *sgw_s5u_teid, *pgw_s5u_teid;
gtp_node_t *sgw = NULL;
pgw_bearer_t *bearer = NULL;
d_assert(xact, return, "Null param");
@ -156,6 +177,21 @@ void pgw_s5c_handle_create_bearer_response(
sgw_s5u_teid = req->bearer_contexts.s5_s8_u_sgw_f_teid.data;
bearer->sgw_s5u_teid = ntohl(sgw_s5u_teid->teid);
bearer->sgw_s5u_addr = sgw_s5u_teid->ip.addr;
sgw = gtp_find_node(&pgw_self()->sgw_s5u_list, sgw_s5u_teid);
if (!sgw)
{
sgw = gtp_connect_node(&pgw_self()->sgw_s5u_list, sgw_s5u_teid,
pgw_self()->gtpu_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
context_self()->parameter.prefer_ipv4);
d_assert(sgw, return,);
rv = gtp_client(sgw);
d_assert(rv == CORE_OK, return,);
}
/* Setup GTP Node */
SETUP_GTP_NODE(bearer, sgw);
rv = gtp_xact_commit(xact);
d_assert(rv == CORE_OK, return, "xact_commit error");

View File

@ -39,8 +39,10 @@ status_t sgw_context_init()
list_init(&self.gtpc_list6);
gtp_node_init();
list_init(&self.mme_list);
list_init(&self.pgw_list);
list_init(&self.mme_s11_list);
list_init(&self.pgw_s5c_list);
list_init(&self.enb_s1u_list);
list_init(&self.pgw_s5u_list);
index_init(&sgw_ue_pool, MAX_POOL_OF_UE);
index_init(&sgw_sess_pool, MAX_POOL_OF_SESS);
@ -69,8 +71,10 @@ status_t sgw_context_final()
index_final(&sgw_sess_pool);
index_final(&sgw_ue_pool);
gtp_remove_all_nodes(&self.mme_list);
gtp_remove_all_nodes(&self.pgw_list);
gtp_remove_all_nodes(&self.mme_s11_list);
gtp_remove_all_nodes(&self.pgw_s5c_list);
gtp_remove_all_nodes(&self.enb_s1u_list);
gtp_remove_all_nodes(&self.pgw_s5u_list);
gtp_node_final();
sock_remove_all_nodes(&self.gtpc_list);
@ -417,10 +421,10 @@ gtp_node_t *sgw_mme_add_by_message(gtp_message_t *message)
mme_s11_teid = req->sender_f_teid_for_control_plane.data;
d_assert(mme_s11_teid, return NULL,);
mme = gtp_find_node(&sgw_self()->mme_list, &mme_s11_teid->ip);
mme = gtp_find_node(&sgw_self()->mme_s11_list, mme_s11_teid);
if (!mme)
{
mme = gtp_connect_node(&sgw_self()->mme_list, mme_s11_teid,
mme = gtp_connect_node(&sgw_self()->mme_s11_list, mme_s11_teid,
sgw_self()->gtpc_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,

View File

@ -34,8 +34,10 @@ typedef struct _sgw_context_t {
msgq_id queue_id; /* Queue for processing SGW control plane */
tm_service_t tm_service;/* Timer Service */
list_t mme_list; /* MME GTP Node List */
list_t pgw_list; /* PGW GTP Node List */
list_t mme_s11_list; /* MME GTPC Node List */
list_t pgw_s5c_list; /* PGW GTPC Node List */
list_t enb_s1u_list; /* eNB GTPU Node List */
list_t pgw_s5u_list; /* PGW GTPU Node List */
hash_t *imsi_ue_hash; /* hash table (IMSI : SGW_UE) */
} sgw_context_t;
@ -123,6 +125,7 @@ typedef struct _sgw_tunnel_t {
/* Related Context */
sgw_bearer_t *bearer;
gtp_node_t *gnode;
} sgw_tunnel_t;
CORE_DECLARE(status_t) sgw_context_init(void);

View File

@ -65,7 +65,6 @@ static int _gtpv1_u_recv_cb(sock_id sock, void *data)
status_t rv;
pkbuf_t *pkbuf = NULL;
c_sockaddr_t from;
gtp_node_t gnode;
gtp_header_t *gtp_h = NULL;
sgw_bearer_t *bearer = NULL;
sgw_tunnel_t *tunnel = NULL;
@ -73,7 +72,6 @@ static int _gtpv1_u_recv_cb(sock_id sock, void *data)
int i;
d_assert(sock, return -1, "Null param");
memset(&gnode, 0, sizeof(gtp_node_t));
rv = gtp_recvfrom(sock, &pkbuf, &from);
if (rv != CORE_OK)
@ -96,6 +94,9 @@ static int _gtpv1_u_recv_cb(sock_id sock, void *data)
echo_rsp = gtp_handle_echo_req(pkbuf);
if (echo_rsp)
{
gtp_node_t gnode;
memset(&gnode, 0, sizeof(gtp_node_t));
/* Echo reply */
d_trace(3, "Send echo-rsp to peer\n");
@ -120,10 +121,6 @@ static int _gtpv1_u_recv_cb(sock_id sock, void *data)
d_assert(bearer, return -1, "Null param");
/* Convert TEID */
gnode.old_addr.c_sa_port = htons(GTPV1_U_UDP_PORT);
gnode.old_addr.c_sa_family = AF_INET;
gnode.sock = sgw_self()->gtpu_sock;
if (tunnel->interface_type ==
GTP_F_TEID_S1_U_SGW_GTP_U ||
tunnel->interface_type ==
@ -136,10 +133,8 @@ static int _gtpv1_u_recv_cb(sock_id sock, void *data)
s5u_tunnel = sgw_s5u_tunnel_in_bearer(bearer);
d_assert(s5u_tunnel, return -1, "Null param");
gnode.old_addr.sin.sin_addr.s_addr = s5u_tunnel->remote_addr;
gtp_h->teid = htonl(s5u_tunnel->remote_teid);
gtp_send(&gnode, pkbuf);
gtp_send(s5u_tunnel->gnode, pkbuf);
}
else if (tunnel->interface_type == GTP_F_TEID_S5_S8_SGW_GTP_U)
{
@ -148,8 +143,6 @@ static int _gtpv1_u_recv_cb(sock_id sock, void *data)
s1u_tunnel = sgw_s1u_tunnel_in_bearer(bearer);
d_assert(s1u_tunnel, return -1, "Null param");
gnode.old_addr.sin.sin_addr.s_addr = s1u_tunnel->remote_addr;
if (s1u_tunnel->remote_teid)
{
/* If there is buffered packet, send it first */
@ -158,13 +151,13 @@ static int _gtpv1_u_recv_cb(sock_id sock, void *data)
gtp_h = (gtp_header_t *)bearer->buffered_pkts[i]->payload;
gtp_h->teid = htonl(s1u_tunnel->remote_teid);
gtp_send(&gnode, bearer->buffered_pkts[i]);
gtp_send(s1u_tunnel->gnode, bearer->buffered_pkts[i]);
pkbuf_free(bearer->buffered_pkts[i]);
}
bearer->num_buffered_pkt = 0;
gtp_h->teid = htonl(s1u_tunnel->remote_teid);
gtp_send(&gnode, pkbuf);
gtp_send(s1u_tunnel->gnode, pkbuf);
}
else
{

View File

@ -109,10 +109,10 @@ void sgw_s11_handle_create_session_request(
pgw_s5c_teid = req->pgw_s5_s8_address_for_control_plane_or_pmip.data;
d_assert(pgw_s5c_teid, return, "Null param");
pgw = gtp_find_node(&sgw_self()->pgw_list, &pgw_s5c_teid->ip);
pgw = gtp_find_node(&sgw_self()->pgw_s5c_list, pgw_s5c_teid);
if (!pgw)
{
pgw = gtp_connect_node(&sgw_self()->pgw_list, pgw_s5c_teid,
pgw = gtp_connect_node(&sgw_self()->pgw_s5c_list, pgw_s5c_teid,
sgw_self()->gtpc_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
@ -122,7 +122,6 @@ void sgw_s11_handle_create_session_request(
rv = gtp_client(pgw);
d_assert(rv == CORE_OK, return,);
}
/* Setup GTP Node */
SETUP_GTP_NODE(sess, pgw);
@ -132,7 +131,7 @@ void sgw_s11_handle_create_session_request(
/* Data Plane(DL) : SGW-S5U */
memset(&sgw_s5u_teid, 0, sizeof(gtp_f_teid_t));
sgw_s5u_teid.teid = htonl(s5u_tunnel->local_teid);
sgw_s5u_teid.ipv4 = s5u_tunnel->local_addr;
sgw_s5u_teid.ipv4 = 1;
sgw_s5u_teid.ip.addr = s5u_tunnel->local_addr;
sgw_s5u_teid.interface_type = GTP_F_TEID_S5_S8_SGW_GTP_U;
req->bearer_contexts_to_be_created.s5_s8_u_sgw_f_teid.presence = 1;
@ -171,6 +170,7 @@ CORE_DECLARE(void) sgw_s11_handle_modify_bearer_request(gtp_xact_t *s11_xact,
{
status_t rv;
c_uint16_t decoded;
gtp_node_t *enb = NULL;
sgw_bearer_t *bearer = NULL;
sgw_tunnel_t *s1u_tunnel = NULL;
gtp_modify_bearer_response_t *rsp = NULL;
@ -229,6 +229,21 @@ CORE_DECLARE(void) sgw_s11_handle_modify_bearer_request(gtp_xact_t *s11_xact,
enb_s1u_teid = req->bearer_contexts_to_be_modified.s1_u_enodeb_f_teid.data;
s1u_tunnel->remote_teid = ntohl(enb_s1u_teid->teid);
s1u_tunnel->remote_addr = enb_s1u_teid->ip.addr;
enb = gtp_find_node(&sgw_self()->enb_s1u_list, enb_s1u_teid);
if (!enb)
{
enb = gtp_connect_node(&sgw_self()->enb_s1u_list, enb_s1u_teid,
sgw_self()->gtpu_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
context_self()->parameter.prefer_ipv4);
d_assert(enb, return,);
rv = gtp_client(enb);
d_assert(rv == CORE_OK, return,);
}
/* Setup GTP Node */
SETUP_GTP_NODE(s1u_tunnel, enb);
/* Reset UE state */
SGW_RESET_UE_STATE(sgw_ue, SGW_S1U_INACTIVE);
@ -308,6 +323,7 @@ void sgw_s11_handle_create_bearer_response(gtp_xact_t *s11_xact,
status_t rv;
c_uint16_t decoded;
pkbuf_t *pkbuf = NULL;
gtp_node_t *enb = NULL;
gtp_xact_t *s5c_xact = NULL;
sgw_sess_t *sess = NULL;
sgw_bearer_t *bearer = NULL;
@ -375,6 +391,23 @@ void sgw_s11_handle_create_bearer_response(gtp_xact_t *s11_xact,
enb_s1u_teid = req->bearer_contexts.s1_u_enodeb_f_teid.data;
s1u_tunnel->remote_teid = ntohl(enb_s1u_teid->teid);
s1u_tunnel->remote_addr = enb_s1u_teid->ip.addr;
enb = gtp_find_node(&sgw_self()->enb_s1u_list, enb_s1u_teid);
if (!enb)
{
enb = gtp_connect_node(&sgw_self()->enb_s1u_list, enb_s1u_teid,
sgw_self()->gtpu_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
context_self()->parameter.prefer_ipv4);
d_assert(enb, return,);
rv = gtp_client(enb);
d_assert(rv == CORE_OK, return,);
}
/* Setup GTP Node */
SETUP_GTP_NODE(s1u_tunnel, enb);
/* Remove S1U-F-TEID */
req->bearer_contexts.s1_u_enodeb_f_teid.presence = 0;
decoded = gtp_parse_uli(&uli, &req->user_location_information);
@ -390,6 +423,7 @@ void sgw_s11_handle_create_bearer_response(gtp_xact_t *s11_xact,
/* Data Plane(DL) : SGW-S5U */
memset(&sgw_s5u_teid, 0, sizeof(gtp_f_teid_t));
sgw_s5u_teid.teid = htonl(s5u_tunnel->local_teid);
sgw_s5u_teid.ipv4 = 1;
sgw_s5u_teid.ip.addr = s5u_tunnel->local_addr;
sgw_s5u_teid.interface_type = GTP_F_TEID_S5_S8_SGW_GTP_U;
req->bearer_contexts.s5_s8_u_sgw_f_teid.presence = 1;
@ -551,6 +585,7 @@ void sgw_s11_handle_create_indirect_data_forwarding_tunnel_request(
gtp_message_t gtp_message;
int i;
gtp_node_t *enb = NULL;
sgw_bearer_t *bearer = NULL;
sgw_tunnel_t *tunnel = NULL;
@ -602,6 +637,22 @@ void sgw_s11_handle_create_indirect_data_forwarding_tunnel_request(
tunnel->remote_teid = ntohl(req_teid->teid);
tunnel->remote_addr = req_teid->ip.addr;
enb = gtp_find_node(&sgw_self()->enb_s1u_list, req_teid);
if (!enb)
{
enb = gtp_connect_node(&sgw_self()->enb_s1u_list, req_teid,
sgw_self()->gtpu_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
context_self()->parameter.prefer_ipv4);
d_assert(enb, return,);
rv = gtp_client(enb);
d_assert(rv == CORE_OK, return,);
}
/* Setup GTP Node */
SETUP_GTP_NODE(tunnel, enb);
memset(&rsp_dl_teid[i], 0, sizeof(gtp_f_teid_t));
rsp_dl_teid[i].ipv4 = 1;
rsp_dl_teid[i].ip.addr = tunnel->local_addr;
@ -624,6 +675,21 @@ void sgw_s11_handle_create_indirect_data_forwarding_tunnel_request(
tunnel->remote_teid = ntohl(req_teid->teid);
tunnel->remote_addr = req_teid->ip.addr;
enb = gtp_find_node(&sgw_self()->enb_s1u_list, req_teid);
if (!enb)
{
enb = gtp_connect_node(&sgw_self()->enb_s1u_list, req_teid,
sgw_self()->gtpu_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
context_self()->parameter.prefer_ipv4);
d_assert(enb, return,);
rv = gtp_client(enb);
d_assert(rv == CORE_OK, return,);
}
/* Setup GTP Node */
SETUP_GTP_NODE(tunnel, enb);
memset(&rsp_ul_teid[i], 0, sizeof(gtp_f_teid_t));
rsp_ul_teid[i].ipv4 = 1;

View File

@ -5,7 +5,10 @@
#include "gtp_conv.h"
#include "gtp_types.h"
#include "gtp_node.h"
#include "gtp_path.h"
#include "context.h"
#include "sgw_event.h"
#include "sgw_context.h"
#include "sgw_gtp_path.h"
@ -15,6 +18,7 @@ void sgw_s5c_handle_create_session_response(gtp_xact_t *s5c_xact,
sgw_sess_t *sess, gtp_message_t *gtp_message)
{
status_t rv;
gtp_node_t *pgw = NULL;
gtp_xact_t *s11_xact = NULL;
sgw_bearer_t *bearer = NULL;
sgw_tunnel_t *s1u_tunnel = NULL, *s5u_tunnel = NULL;
@ -81,6 +85,23 @@ void sgw_s5c_handle_create_session_response(gtp_xact_t *s5c_xact,
d_assert(pgw_s5u_teid, return, "Null param");
s5u_tunnel->remote_teid = ntohl(pgw_s5u_teid->teid);
s5u_tunnel->remote_addr = pgw_s5u_teid->ip.addr;
pgw = gtp_find_node(&sgw_self()->pgw_s5u_list, pgw_s5u_teid);
if (!pgw)
{
pgw = gtp_connect_node(&sgw_self()->pgw_s5u_list, pgw_s5u_teid,
sgw_self()->gtpu_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
context_self()->parameter.prefer_ipv4);
d_assert(pgw, return,);
rv = gtp_client(pgw);
d_assert(rv == CORE_OK, return,);
}
/* Setup GTP Node */
SETUP_GTP_NODE(s5u_tunnel, pgw);
/* Remove S5C-F-TEID */
rsp->bearer_contexts_created.s5_s8_u_sgw_f_teid.presence = 0;
/* Send Control Plane(UL) : SGW-S11 */
@ -193,6 +214,7 @@ void sgw_s5c_handle_create_bearer_request(gtp_xact_t *s5c_xact,
sgw_sess_t *sess, gtp_message_t *gtp_message)
{
status_t rv;
gtp_node_t *pgw = NULL;
gtp_xact_t *s11_xact = NULL;
sgw_bearer_t *bearer = NULL;
sgw_tunnel_t *s1u_tunnel = NULL, *s5u_tunnel = NULL;
@ -244,6 +266,23 @@ void sgw_s5c_handle_create_bearer_request(gtp_xact_t *s5c_xact,
d_assert(pgw_s5u_teid, return, "Null param");
s5u_tunnel->remote_teid = ntohl(pgw_s5u_teid->teid);
s5u_tunnel->remote_addr = pgw_s5u_teid->ip.addr;
pgw = gtp_find_node(&sgw_self()->pgw_s5u_list, pgw_s5u_teid);
if (!pgw)
{
pgw = gtp_connect_node(&sgw_self()->pgw_s5u_list, pgw_s5u_teid,
sgw_self()->gtpu_port,
context_self()->parameter.no_ipv4,
context_self()->parameter.no_ipv6,
context_self()->parameter.prefer_ipv4);
d_assert(pgw, return,);
rv = gtp_client(pgw);
d_assert(rv == CORE_OK, return,);
}
/* Setup GTP Node */
SETUP_GTP_NODE(s5u_tunnel, pgw);
/* Remove S5U-F-TEID */
req->bearer_contexts.s5_s8_u_sgw_f_teid.presence = 0;
/* Send Data Plane(UL) : SGW-S1U */