gtp_node is added

This commit is contained in:
Sukchan Lee 2017-11-30 20:13:15 +09:00
parent 4baf7ece46
commit 5a818eb8cd
33 changed files with 233 additions and 34 deletions

View File

@ -3,8 +3,8 @@
pkglib_LTLIBRARIES = libgtp.la
libgtp_la_SOURCES = \
gtp_message.h gtp_types.h gtp_conv.h gtp_path.h gtp_xact.h \
gtp_message.c gtp_types.c gtp_conv.c gtp_path.c gtp_xact.c
gtp_message.h gtp_types.h gtp_conv.h gtp_node.h gtp_path.h gtp_xact.h \
gtp_message.c gtp_types.c gtp_conv.c gtp_node.c gtp_path.c gtp_xact.c
libgtp_la_DEPENDENCIES = \
$(top_srcdir)/lib/core/src/libcore.la \

3
lib/gtp/gtp_node.c Normal file
View File

@ -0,0 +1,3 @@
#define TRACE_MODULE _gtp_node
#include "gtp_node.h"

31
lib/gtp/gtp_node.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef __GTP_NODE_H__
#define __GTP_NODE_H__
#include "core_list.h"
#include "core_network.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef list_t gnode_list_t;
/**
* This structure represents the commonalities of GTP node such as MME, SGW,
* PGW gateway. Some of members may not be used by the specific type of node */
typedef struct _gtp_node_t {
lnode_t node; /**< A node of list_t */
c_sockaddr_t *addr; /**< Socket Address */
c_sockaddr_t old_addr; /**< Will be removed */
sock_id sock; /**< Socket Descriptor */
list_t local_list;
list_t remote_list;
} gtp_node_t;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTP_NODE_H__ */

View File

@ -1,11 +1,56 @@
#define TRACE_MODULE _gtp_path
#include "core_debug.h"
#include "core_pkbuf.h"
#include "types.h"
#include "gtp_message.h"
#include "gtp_node.h"
#include "gtp_path.h"
status_t gtp_server(sock_id *new, c_sockaddr_t *sa, sock_handler handler)
{
status_t rv;
char buf[CORE_ADDRSTRLEN];
while(sa)
{
rv = udp_socket(new, sa->c_sa_family);
d_assert(rv == CORE_OK, return CORE_ERROR,);
d_assert(sock_setsockopt(*new, SOCK_O_REUSEADDR, 1) == CORE_OK,
return CORE_ERROR,
"setsockopt(%s:%d) failed(%d:%s)",
CORE_ADDR(sa, buf), CORE_PORT(sa), errno, strerror(errno));
if (sock_bind(*new, sa) == CORE_OK)
{
d_trace(1, "udp bind %s:%d\n", CORE_ADDR(sa, buf), CORE_PORT(sa));
break;
}
rv = sock_delete(*new);
d_assert(rv == CORE_OK, return CORE_ERROR,);
sa = sa->next;
}
if (sa == NULL)
{
d_error("udp bind(%s:%d) failed(%d:%s)",
CORE_ADDR(sa, buf), CORE_PORT(sa), errno, strerror(errno));
return CORE_ERROR;
}
rv = sock_register(*new, handler, NULL);
d_assert(rv == CORE_OK, return CORE_ERROR,);
d_trace(1, "gtp_server [%s]:%d\n", CORE_ADDR(sa, buf), CORE_PORT(sa));
return CORE_OK;
}
status_t gtp_listen(sock_id *sock,
sock_handler handler, c_uint32_t ipv4, c_uint16_t port, void *data)
{

View File

@ -3,24 +3,15 @@
#include "core_pkbuf.h"
#include "core_network.h"
#include "core_list.h"
typedef struct _gtp_node_t gtp_node_t;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* This structure represents the commonalities of GTP node such as MME, SGW,
* PGW gateway. Some of members may not be used by the specific type of node */
typedef struct _gtp_node_t {
lnode_t node; /**< A node of list_t */
c_sockaddr_t old_addr; /**< Will be removed */
sock_id sock; /**< Socket Descriptor */
list_t local_list;
list_t remote_list;
} gtp_node_t;
CORE_DECLARE(status_t) gtp_server(sock_id *new,
c_sockaddr_t *sa, sock_handler handler);
CORE_DECLARE(status_t) gtp_listen(sock_id *sock,
sock_handler handler, c_uint32_t addr, c_uint16_t port, void *data);

View File

@ -4,8 +4,11 @@
#include "core_event.h"
#include "types.h"
#include "gtp_xact.h"
#include "gtp_message.h"
#include "gtp_node.h"
#include "gtp_path.h"
#include "gtp_xact.h"
#define SIZE_OF_GTP_XACT_POOL 64
#define GTP_MIN_XACT_ID 1

View File

@ -6,13 +6,14 @@
#include "core_index.h"
#include "core_timer.h"
#include "gtp_path.h"
#include "gtp_message.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _gtp_node_t gtp_node_t;
/**
* Transaction context
*/

View File

@ -16,6 +16,7 @@
#include "nas_path.h"
#include "s1ap_path.h"
#include "mme_gtp_path.h"
#include "mme_sm.h"
void emm_state_initial(fsm_t *s, event_t *e)
{

View File

@ -7,6 +7,7 @@
#include "nas_security.h"
#include "esm_build.h"
#include "mme_sm.h"
status_t esm_build_pdn_connectivity_reject(
pkbuf_t **pkbuf, mme_sess_t *sess, nas_esm_cause_t esm_cause)

View File

@ -5,6 +5,7 @@
#include "nas_message.h"
#include "mme_event.h"
#include "mme_sm.h"
#include "mme_fd_path.h"
#include "emm_handler.h"
#include "esm_build.h"

View File

@ -3,13 +3,16 @@
#include "core_debug.h"
#include "core_pool.h"
#include "core_lib.h"
#include "core_msgq.h"
#include "core_fsm.h"
#include <mongoc.h>
#include <yaml.h>
#include "yaml_helper.h"
#include "gtp_path.h"
#include "s1ap_message.h"
#include "gtp_xact.h"
#include "gtp_node.h"
#include "fd_lib.h"
#include "context.h"
@ -17,12 +20,14 @@
#include "mme_context.h"
#include "mme_event.h"
#include "s1ap_path.h"
#include "mme_sm.h"
#define MAX_CELL_PER_ENB 8
static mme_context_t self;
pool_declare(mme_s1ap_pool, mme_s1ap_t, MAX_NUM_OF_S1AP_SERVER);
pool_declare(mme_gtpc_pool, mme_gtpc_t, MAX_NUM_OF_GTP_SERVER);
pool_declare(mme_sgw_pool, mme_sgw_t, MAX_NUM_OF_GTP_CLIENT);
index_declare(mme_enb_pool, mme_enb_t, MAX_NUM_OF_ENB);
@ -43,6 +48,8 @@ status_t mme_context_init()
pool_init(&mme_s1ap_pool, MAX_NUM_OF_S1AP_SERVER);
list_init(&self.s1ap_list);
pool_init(&mme_gtpc_pool, MAX_NUM_OF_GTP_SERVER);
list_init(&self.gtpc_list);
pool_init(&mme_sgw_pool, MAX_NUM_OF_GTP_CLIENT);
list_init(&self.sgw_list);
@ -73,6 +80,7 @@ status_t mme_context_final()
"MME context already has been finalized");
mme_s1ap_remove_all();
mme_gtpc_remove_all();
mme_sgw_remove_all();
mme_enb_remove_all();
@ -102,6 +110,7 @@ status_t mme_context_final()
pool_final(&mme_sgw_pool);
pool_final(&mme_s1ap_pool);
pool_final(&mme_gtpc_pool);
context_initialized = 0;
@ -1099,6 +1108,59 @@ mme_s1ap_t* mme_s1ap_next(mme_s1ap_t *s1ap)
return list_next(s1ap);
}
mme_gtpc_t* mme_gtpc_add(c_sockaddr_t *addr)
{
mme_gtpc_t *gtpc = NULL;
pool_alloc_node(&mme_gtpc_pool, &gtpc);
d_assert(gtpc, return NULL, "Null param");
memset(gtpc, 0, sizeof(mme_gtpc_t));
gtpc->addr = addr;
list_append(&self.gtpc_list, gtpc);
return gtpc;
}
status_t mme_gtpc_remove(mme_gtpc_t *gtpc)
{
d_assert(gtpc, return CORE_ERROR, "Null param");
list_remove(&self.gtpc_list, gtpc);
pool_free_node(&mme_gtpc_pool, gtpc);
return CORE_OK;
}
status_t mme_gtpc_remove_all()
{
mme_gtpc_t *gtpc = NULL, *next_gtpc = NULL;
gtpc = mme_gtpc_first();
while (gtpc)
{
next_gtpc = mme_gtpc_next(gtpc);
mme_gtpc_remove(gtpc);
gtpc = next_gtpc;
}
return CORE_OK;
}
mme_gtpc_t* mme_gtpc_first()
{
return list_first(&self.gtpc_list);
}
mme_gtpc_t* mme_gtpc_next(mme_gtpc_t *gtpc)
{
return list_next(gtpc);
}
mme_sgw_t* mme_sgw_add()
{
mme_sgw_t *sgw = NULL;

View File

@ -6,15 +6,17 @@
#include "core_errno.h"
#include "core_sha2.h"
#include "core_hash.h"
#include "core_network.h"
#include "core_tlv_msg.h"
#include "core_fsm.h"
#include "core_msgq.h"
#include "core_timer.h"
#include "types.h"
#include "s1ap_message.h"
#include "nas_message.h"
#include "gtp_xact.h"
#include "s6a_message.h"
#include "mme_sm.h"
/* S1AP */
#include "S1ap-Cause.h"
@ -36,6 +38,10 @@ extern "C" {
typedef struct _enb_ue_t enb_ue_t;
typedef struct _mme_ue_t mme_ue_t;
typedef struct _gtp_node_t gtp_node_t;
typedef struct _gtp_xact_t gtp_xact_t;
typedef gtp_node_t mme_gtpc_t;
typedef gtp_node_t mme_sgw_t;
typedef struct _served_gummei {
@ -51,8 +57,9 @@ typedef struct _served_gummei {
typedef struct _mme_context_t {
const char *fd_conf_path; /* MME freeDiameter conf path */
list_t s1ap_list; /* MME S1AP Socket List */
list_t sgw_list; /* SGW GTP Node List */
list_t s1ap_list; /* MME S1AP Server List */
list_t gtpc_list; /* MME GTPC Server List */
list_t sgw_list; /* SGW GTPC Client List */
c_uint32_t gtpc_addr; /* MME GTPC local address */
c_uint16_t gtpc_port; /* MME GTPC local port */
@ -452,6 +459,12 @@ CORE_DECLARE(status_t) mme_s1ap_remove_all(void);
CORE_DECLARE(mme_s1ap_t*) mme_s1ap_first(void);
CORE_DECLARE(mme_s1ap_t*) mme_s1ap_next(mme_s1ap_t *s1ap);
CORE_DECLARE(mme_gtpc_t*) mme_gtpc_add(c_sockaddr_t *addr);
CORE_DECLARE(status_t) mme_gtpc_remove(mme_gtpc_t *gtpc);
CORE_DECLARE(status_t) mme_gtpc_remove_all(void);
CORE_DECLARE(mme_gtpc_t*) mme_gtpc_first(void);
CORE_DECLARE(mme_gtpc_t*) mme_gtpc_next(mme_gtpc_t *gtpc);
CORE_DECLARE(mme_sgw_t*) mme_sgw_add(void);
CORE_DECLARE(status_t) mme_sgw_remove(mme_sgw_t *sgw);
CORE_DECLARE(status_t) mme_sgw_remove_all(void);

View File

@ -2,6 +2,10 @@
#include "core_debug.h"
#include "core_pkbuf.h"
#include "gtp_node.h"
#include "gtp_path.h"
#include "gtp_xact.h"
#include "mme_event.h"
#include "mme_gtp_path.h"
#include "mme_s11_build.h"

View File

@ -2,12 +2,18 @@
#include "core_debug.h"
#include "core_thread.h"
#include "core_msgq.h"
#include "core_fsm.h"
#include "gtp_xact.h"
#include "mme_event.h"
#include "mme_fd_path.h"
#include "s1ap_path.h"
#include "mme_sm.h"
static thread_id sm_thread;
static void *THREAD_FUNC sm_main(thread_id id, void *data);

View File

@ -4,8 +4,10 @@
#include "gtp_types.h"
#include "gtp_conv.h"
#include "gtp_xact.h"
#include "mme_event.h"
#include "mme_sm.h"
#include "mme_context.h"
#include "s1ap_path.h"

View File

@ -6,6 +6,7 @@
#include "nas_path.h"
#include "s1ap_path.h"
#include "mme_sm.h"
#include "mme_s6a_handler.h"
void mme_s6a_handle_aia(mme_ue_t *mme_ue, s6a_aia_message_t *aia_message)

View File

@ -3,8 +3,10 @@
#include "s1ap_message.h"
#include "nas_message.h"
#include "gtp_xact.h"
#include "mme_event.h"
#include "mme_sm.h"
#include "s1ap_handler.h"
#include "s1ap_path.h"

View File

@ -7,6 +7,7 @@
#include "emm_build.h"
#include "nas_path.h"
#include "mme_event.h"
#include "mme_sm.h"
status_t nas_send_to_enb(mme_ue_t *mme_ue, pkbuf_t *pkbuf)
{

View File

@ -14,6 +14,8 @@
#include "s1ap_build.h"
#include "s1ap_handler.h"
#include "mme_sm.h"
void s1ap_handle_s1_setup_request(mme_enb_t *enb, s1ap_message_t *message)
{
char buf[CORE_ADDRSTRLEN];

View File

@ -5,11 +5,12 @@
#include "nas_message.h"
#include "gtp_message.h"
#include "mme_event.h"
#include "s1ap_build.h"
#include "s1ap_handler.h"
#include "mme_event.h"
#include "mme_sm.h"
void s1ap_state_initial(fsm_t *s, event_t *e)
{
d_assert(s, return, "Null param");

View File

@ -8,9 +8,11 @@
#include <yaml.h>
#include "yaml_helper.h"
#include "gtp_node.h"
#include "gtp_path.h"
#include "gtp_xact.h"
#include "fd_lib.h"
#include "gtp_path.h"
#include "context.h"
#include "pgw_context.h"

View File

@ -2,13 +2,15 @@
#define __PGW_CONTEXT_H__
#include "core_list.h"
#include "core_index.h"
#include "core_errno.h"
#include "core_hash.h"
#include "core_network.h"
#include "core_msgq.h"
#include "core_timer.h"
#include "gtp_types.h"
#include "gtp_xact.h"
#include "pgw_sm.h"
#include "gtp_message.h"
#define MAX_NUM_OF_UE_NETWORK 16
@ -16,6 +18,7 @@
extern "C" {
#endif /* __cplusplus */
typedef struct _gtp_node_t gtp_node_t;
typedef gtp_node_t pgw_sgw_t;
typedef struct _pgw_context_t {

View File

@ -4,6 +4,8 @@
#include "core_pool.h"
#include "core_lib.h"
#include "gtp_xact.h"
#include "fd_lib.h"
#include "gx_dict.h"
#include "gx_message.h"

View File

@ -9,6 +9,8 @@
extern "C" {
#endif /* __cplusplus */
typedef struct _gtp_xact_t gtp_xact_t;
CORE_DECLARE(int) pgw_fd_init(void);
CORE_DECLARE(void) pgw_fd_final(void);

View File

@ -3,6 +3,7 @@
#include "core_pkbuf.h"
#include "types.h"
#include "gtp_node.h"
#include "gtp_path.h"
#include "pgw_context.h"

View File

@ -3,8 +3,11 @@
#include "core_debug.h"
#include "core_thread.h"
#include "gtp_xact.h"
#include "pgw_context.h"
#include "pgw_event.h"
#include "pgw_sm.h"
#include "pgw_fd_path.h"

View File

@ -11,6 +11,8 @@
#include "types.h"
#include "gtp_types.h"
#include "gtp_node.h"
#include "gtp_xact.h"
#include "context.h"
#include "sgw_context.h"

View File

@ -2,21 +2,23 @@
#define __SGW_CONTEXT_H__
#include "core_list.h"
#include "core_index.h"
#include "core_errno.h"
#include "core_event.h"
#include "core_hash.h"
#include "core_network.h"
#include "gtp_xact.h"
#include "gtp_types.h"
#include "types.h"
#include "sgw_sm.h"
#include "gtp_types.h"
#include "gtp_message.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _sgw_tunnel_t sgw_tunnel_t;
typedef struct _gtp_node_t gtp_node_t;
typedef gtp_node_t sgw_mme_t;
typedef gtp_node_t sgw_pgw_t;

View File

@ -4,6 +4,7 @@
#include "types.h"
#include "gtp_types.h"
#include "gtp_node.h"
#include "gtp_path.h"
#include "sgw_context.h"

View File

@ -3,7 +3,10 @@
#include "core_debug.h"
#include "core_thread.h"
#include "gtp_xact.h"
#include "sgw_context.h"
#include "sgw_sm.h"
#include "sgw_event.h"
static thread_id sgw_thread;

View File

@ -5,6 +5,7 @@
#include "gtp_types.h"
#include "gtp_conv.h"
#include "gtp_node.h"
#include "sgw_event.h"
#include "sgw_context.h"

View File

@ -3,6 +3,7 @@
#include "sgw_context.h"
#include "sgw_event.h"
#include "sgw_sm.h"
#include "sgw_gtp_path.h"
#include "sgw_s11_handler.h"
#include "sgw_s5c_handler.h"

View File

@ -4,11 +4,16 @@
#include "core_pkbuf.h"
#include "core_lib.h"
#include "mme_context.h"
#include "s1ap_build.h"
#include "s1ap_conv.h"
#include "s1ap_path.h"
#include "gtp_message.h"
#include "gtp_node.h"
#include "gtp_path.h"
#include "mme_context.h"
extern int test_only_control_plane;
status_t tests1ap_enb_connect(sock_id *new)