PGW freeDiameter is added. more test is needed

This commit is contained in:
Sukchan Lee 2017-08-16 23:40:35 +09:00
parent 75cdc9c077
commit d32c4b9743
18 changed files with 225 additions and 59 deletions

View File

@ -5,8 +5,8 @@
struct dict_object *gx_application = NULL;
struct dict_object *gx_cmd_air = NULL;
struct dict_object *gx_cmd_aia = NULL;
struct dict_object *gx_cmd_ccr = NULL;
struct dict_object *gx_cmd_cca = NULL;
int gx_dict_init(void)
{

View File

@ -63,18 +63,9 @@ static status_t hss_context_validation()
{
if (self.fd_conf_path == NULL)
{
if (self.hss_s6a_addr == NULL)
{
d_error("No HSS.FD_CONF_PATH or HSS.NETWORK.S6A_ADDR in '%s'",
context_self()->config.path);
return CORE_ERROR;
}
if (self.mme_s6a_addr == NULL)
{
d_error("No HSS.FD_CONF_PATH or MME.NETWORK.S6A_ADDR in '%s'",
context_self()->config.path);
return CORE_ERROR;
}
d_error("No HSS.FD_CONF_PATH in '%s'",
context_self()->config.path);
return CORE_ERROR;
}
return CORE_OK;

View File

@ -119,18 +119,9 @@ static status_t mme_context_validation()
{
if (self.fd_conf_path == NULL)
{
if (self.mme_s6a_addr == NULL)
{
d_error("No MME.FD_CONF_PATH or MME.NETWORK.S6A_ADDR in '%s'",
context_self()->config.path);
return CORE_ERROR;
}
if (self.hss_s6a_addr == NULL)
{
d_error("No MME.FD_CONF_PATH or HSS.NETWORK.S6A_ADDR in '%s'",
context_self()->config.path);
return CORE_ERROR;
}
d_error("No MME.FD_CONF_PATH in '%s'",
context_self()->config.path);
return CORE_ERROR;
}
if (self.s1ap_addr == 0)
{

View File

@ -18,7 +18,7 @@ struct sess_state {
struct timespec ts; /* Time of sending the message */
};
pool_declare(sess_state_pool, struct sess_state, MAX_NUM_SESSION_STATE);
pool_declare(mme_s6a_sess_pool, struct sess_state, MAX_NUM_SESSION_STATE);
/* MME received Authentication Information Answer from HSS */
static void mme_s6a_aia_cb(void *data, struct msg **msg)
@ -226,7 +226,7 @@ out:
CHECK_FCT_DO( fd_msg_free(*msg), return );
*msg = NULL;
pool_free_node(&sess_state_pool, mi);
pool_free_node(&mme_s6a_sess_pool, mi);
return;
}
@ -250,7 +250,7 @@ void mme_s6a_send_air(mme_ue_t *mme_ue)
CLEAR_SECURITY_CONTEXT(mme_ue);
/* Create the random value to store with the session */
pool_alloc_node(&sess_state_pool, &mi);
pool_alloc_node(&mme_s6a_sess_pool, &mi);
d_assert(mi, return, "malloc failed: %s", strerror(errno));
mi->mme_ue = mme_ue;
@ -332,7 +332,7 @@ void mme_s6a_send_air(mme_ue_t *mme_ue)
mme_ue->imsi_bcd);
out:
pool_free_node(&sess_state_pool, mi);
pool_free_node(&mme_s6a_sess_pool, mi);
return;
}
@ -698,7 +698,7 @@ static void mme_s6a_ula_cb(void *data, struct msg **msg)
CHECK_FCT_DO( fd_msg_free(*msg), return );
*msg = NULL;
pool_free_node(&sess_state_pool, mi);
pool_free_node(&mme_s6a_sess_pool, mi);
return;
}
@ -715,7 +715,7 @@ void mme_s6a_send_ulr(mme_ue_t *mme_ue)
d_assert(mme_ue, return, "Null Param");
/* Create the random value to store with the session */
pool_alloc_node(&sess_state_pool, &mi);
pool_alloc_node(&mme_s6a_sess_pool, &mi);
d_assert(mi, return, "malloc failed: %s", strerror(errno));
mi->mme_ue = mme_ue;
@ -799,13 +799,13 @@ void mme_s6a_send_ulr(mme_ue_t *mme_ue)
mme_ue->imsi_bcd);
out:
pool_free_node(&sess_state_pool, mi);
pool_free_node(&mme_s6a_sess_pool, mi);
return;
}
int mme_s6a_init(void)
{
pool_init(&sess_state_pool, MAX_NUM_SESSION_STATE);
pool_init(&mme_s6a_sess_pool, MAX_NUM_SESSION_STATE);
/* Install objects definitions for this application */
CHECK_FCT( s6a_dict_init() );
@ -822,14 +822,14 @@ void mme_s6a_final(void)
{
CHECK_FCT_DO( fd_sess_handler_destroy(&mme_s6a_reg, NULL), );
if (pool_size(&sess_state_pool) != pool_avail(&sess_state_pool))
d_error("%d not freed in sess_state_pool[%d] of S6A-SM",
pool_size(&sess_state_pool) - pool_avail(&sess_state_pool),
pool_size(&sess_state_pool));
if (pool_size(&mme_s6a_sess_pool) != pool_avail(&mme_s6a_sess_pool))
d_error("%d not freed in mme_s6a_sess_pool[%d] of S6A-SM",
pool_size(&mme_s6a_sess_pool) - pool_avail(&mme_s6a_sess_pool),
pool_size(&mme_s6a_sess_pool));
d_trace(3, "%d not freed in sess_state_pool[%d] of S6A-SM\n",
pool_size(&sess_state_pool) - pool_avail(&sess_state_pool),
pool_size(&sess_state_pool));
d_trace(3, "%d not freed in mme_s6a_sess_pool[%d] of S6A-SM\n",
pool_size(&mme_s6a_sess_pool) - pool_avail(&mme_s6a_sess_pool),
pool_size(&mme_s6a_sess_pool));
pool_final(&sess_state_pool);
pool_final(&mme_s6a_sess_pool);
}

View File

@ -3,24 +3,32 @@
noinst_LTLIBRARIES = libpgw.la
libpgw_la_SOURCES = \
pgw_event.h pgw_context.h \
pgw_path.h pgw_sm.h pgw_handler.h
pgw_event.h pgw_context.h pgw_sm.h \
pgw_gtp_path.h pgw_s5c_handler.h \
pgw_gx_handler.h
nodist_libpgw_la_SOURCES = \
pgw_init.c pgw_event.c pgw_context.c \
pgw_path.c pgw_sm.c pgw_handler.c
pgw_init.c pgw_event.c pgw_context.c pgw_sm.c \
pgw_gtp_path.c pgw_s5c_handler.c \
pgw_fd.c pgw_gx_handler.c
libpgw_la_DEPENDENCIES = \
$(top_srcdir)/lib/core/src/libcore.la \
$(top_srcdir)/lib/fd/gx/libfdgx.la \
$(top_srcdir)/lib/fd/libfd.la \
$(top_srcdir)/lib/gtp/libgtp.la
libpgw_la_LIBADD = \
$(top_srcdir)/lib/core/src/libcore.la \
$(top_srcdir)/lib/fd/gx/libfdgx.la \
$(top_srcdir)/lib/fd/libfd.la \
$(top_srcdir)/lib/gtp/libgtp.la
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/core/include \
-I$(top_srcdir)/lib/base \
-I$(top_srcdir)/lib/fd/gx \
-I$(top_srcdir)/lib/fd \
-I$(top_srcdir)/lib/gtp
AM_CFLAGS = \

View File

@ -4,6 +4,7 @@
#include "core_pool.h"
#include "core_index.h"
#include "fd_lib.h"
#include "gtp_path.h"
#include "context.h"
@ -92,6 +93,12 @@ static status_t pgw_context_prepare()
static status_t pgw_context_validation()
{
if (self.fd_conf_path == NULL)
{
d_error("No PGW.FD_CONF_PATH in '%s'",
context_self()->config.path);
return CORE_ERROR;
}
if (self.s5c_node.addr == 0)
{
d_error("No SGW.NEWORK.S5C_ADDR in '%s'",
@ -250,7 +257,11 @@ status_t pgw_context_parse_config()
}
case PGW_ROOT:
{
if (jsmntok_equal(json, t, "NETWORK") == 0)
if (jsmntok_equal(json, t, "FD_CONF_PATH") == 0)
{
self.fd_conf_path = jsmntok_to_string(json, t+1);
}
else if (jsmntok_equal(json, t, "NETWORK") == 0)
{
m = 1;
size = 1;
@ -407,19 +418,37 @@ status_t pgw_context_parse_config()
status_t pgw_context_setup_trace_module()
{
int others = context_self()->trace_level.others;
int fd = context_self()->trace_level.fd;
int gtp = context_self()->trace_level.gtp;
int others = context_self()->trace_level.others;
if (fd)
{
if (fd <= 1) fd_g_debug_lvl = FD_LOG_ERROR;
else if (fd <= 3) fd_g_debug_lvl = FD_LOG_NOTICE;
else if (fd <= 5) fd_g_debug_lvl = FD_LOG_DEBUG;
else fd_g_debug_lvl = FD_LOG_ANNOYING;
extern int _pgw_gx_handler;
d_trace_level(&_pgw_gx_handler, fd);
extern int _fd_init;
d_trace_level(&_fd_init, fd);
extern int _fd_context;
d_trace_level(&_fd_context, fd);
extern int _fd_logger;
d_trace_level(&_fd_logger, fd);
}
if (gtp)
{
extern int _pgw_sm;
d_trace_level(&_pgw_sm, gtp);
extern int _pgw_handler;
d_trace_level(&_pgw_handler, gtp);
extern int _pgw_s5c_handler;
d_trace_level(&_pgw_s5c_handler, gtp);
extern int _gtp_path;
d_trace_level(&_gtp_path, gtp);
extern int _pgw_path;
d_trace_level(&_pgw_path, gtp);
extern int _pgw_gtp_path;
d_trace_level(&_pgw_gtp_path, gtp);
extern int _tlv_msg;
d_trace_level(&_tlv_msg, gtp);
extern int _gtp_xact;

View File

@ -29,6 +29,8 @@ typedef struct _pgw_context_t {
c_uint32_t s5u_port; /* PGW S5-U local port */
net_sock_t* s5u_sock; /* PGW S5-U local listen socket */
char* fd_conf_path; /* PGW freeDiameter conf path */
msgq_id queue_id; /* Qsesssess for processing PGW control plane */
tm_service_t tm_service; /* Timer Service */
gtp_xact_ctx_t gtp_xact_ctx; /* GTP Transaction Context */

19
src/pgw/pgw_fd.c Normal file
View File

@ -0,0 +1,19 @@
#define TRACE_MODULE _pgw_fd
#include "fd_lib.h"
#include "pgw_context.h"
int pgw_fd_init(void)
{
fd_context_init(FD_MODE_CLIENT);
CHECK_FCT( fd_init(pgw_self()->fd_conf_path) );
return 0;
}
void pgw_fd_final(void)
{
fd_final();
}

20
src/pgw/pgw_fd.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef __PGW_FD_H__
#define __PGW_FD_H__
#include "core_errno.h"
#include "pgw_context.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(int) pgw_fd_init(void);
CORE_DECLARE(void) pgw_fd_final(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PGW_FD_H__ */

View File

@ -1,4 +1,4 @@
#define TRACE_MODULE _pgw_path
#define TRACE_MODULE _pgw_gtp_path
#include "core_debug.h"
#include "core_pkbuf.h"
#include "core_net.h"
@ -8,7 +8,7 @@
#include "pgw_context.h"
#include "pgw_event.h"
#include "pgw_path.h"
#include "pgw_gtp_path.h"
static int _gtpv1_tun_recv_cb(net_link_t *net_link, void *data)
{

61
src/pgw/pgw_gx_handler.c Normal file
View File

@ -0,0 +1,61 @@
#define TRACE_MODULE _pgw_gx_handler
#include "core_debug.h"
#include "core_pool.h"
#include "fd_lib.h"
#include "gx_lib.h"
#include "pgw_gx_handler.h"
#define MAX_NUM_SESSION_STATE 32
static struct session_handler *pgw_gx_reg = NULL;
struct sess_state {
#if 0 /* FIXME */
mme_ue_t *mme_ue;
#endif
struct timespec ts; /* Time of sending the message */
};
pool_declare(pgw_gx_sess_pool, struct sess_state, MAX_NUM_SESSION_STATE);
/* PGW Sends Credit Control Request to PCRF */
#if 0
void pgw_gx_send_air(mme_ue_t *mme_ue)
{
return;
}
#endif
int pgw_gx_init(void)
{
pool_init(&pgw_gx_sess_pool, MAX_NUM_SESSION_STATE);
/* Install objects definitions for this application */
CHECK_FCT( gx_dict_init() );
CHECK_FCT( fd_sess_handler_create(&pgw_gx_reg, (void *)free, NULL, NULL) );
/* Advertise the support for the application in the peer */
CHECK_FCT( fd_disp_app_support(gx_application, fd_vendor, 1, 0) );
return 0;
}
void pgw_gx_final(void)
{
CHECK_FCT_DO( fd_sess_handler_destroy(&pgw_gx_reg, NULL), );
if (pool_size(&pgw_gx_sess_pool) != pool_avail(&pgw_gx_sess_pool))
d_error("%d not freed in pgw_gx_sess_pool[%d] of S6A-SM",
pool_size(&pgw_gx_sess_pool) - pool_avail(&pgw_gx_sess_pool),
pool_size(&pgw_gx_sess_pool));
d_trace(3, "%d not freed in pgw_gx_sess_pool[%d] of S6A-SM\n",
pool_size(&pgw_gx_sess_pool) - pool_avail(&pgw_gx_sess_pool),
pool_size(&pgw_gx_sess_pool));
pool_final(&pgw_gx_sess_pool);
}

25
src/pgw/pgw_gx_handler.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef __PGW_GX_HANDLER_H__
#define __PGW_GX_HANDLER_H__
#include "core_errno.h"
#include "pgw_context.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(int) pgw_gx_init(void);
CORE_DECLARE(void) pgw_gx_final(void);
/* PGW Sends Credit Control Request to PCRF */
#if 0
CORE_DECLARE(void) pgw_gx_send_ccr(mme_ue_t *mme_ue);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PGW_GX_HANDLER_H__ */

View File

@ -6,6 +6,9 @@
#include "pgw_context.h"
#include "pgw_event.h"
#include "pgw_fd.h"
#include "pgw_gx_handler.h"
static thread_id sm_thread;
static void *THREAD_FUNC sm_main(thread_id id, void *data);
@ -17,6 +20,9 @@ static int initialized = 0;
status_t pgw_initialize()
{
status_t rv;
#if 0
int ret;
#endif
rv = pgw_context_init();
if (rv != CORE_OK) return rv;
@ -30,6 +36,14 @@ status_t pgw_initialize()
rv = pgw_ip_pool_generate();
if (rv != CORE_OK) return rv;
#if 0
ret = pgw_fd_init();
if (ret != 0) return CORE_ERROR;
ret = pgw_gx_init();
if (ret != 0) return CORE_ERROR;
#endif
rv = thread_create(&sm_thread, NULL, sm_main, NULL);
if (rv != CORE_OK) return rv;
rv = thread_create(&net_thread, NULL, net_main, NULL);
@ -47,6 +61,11 @@ void pgw_terminate(void)
thread_delete(net_thread);
thread_delete(sm_thread);
#if 0
pgw_gx_final();
pgw_fd_final();
#endif
pgw_context_final();
gtp_xact_final();

View File

@ -1,4 +1,4 @@
#define TRACE_MODULE _pgw_handler
#define TRACE_MODULE _pgw_s5c_handler
#include "core_debug.h"
@ -6,8 +6,8 @@
#include "pgw_event.h"
#include "pgw_context.h"
#include "pgw_path.h"
#include "pgw_handler.h"
#include "pgw_gtp_path.h"
#include "pgw_s5c_handler.h"
c_int16_t pgw_pco_build(c_uint8_t *pco_buf, tlv_pco_t *tlv_pco)
{

View File

@ -4,8 +4,8 @@
#include "pgw_sm.h"
#include "pgw_context.h"
#include "pgw_event.h"
#include "pgw_path.h"
#include "pgw_handler.h"
#include "pgw_gtp_path.h"
#include "pgw_s5c_handler.h"
void pgw_state_initial(fsm_t *s, event_t *e)
{

View File

@ -4,5 +4,6 @@ ifconfig en0 alias 10.1.35.214 netmask 255.255.255.255
ifconfig en0 alias 10.1.35.215 netmask 255.255.255.255
ifconfig en0 alias 10.1.35.216 netmask 255.255.255.255
ifconfig en0 alias 10.1.35.217 netmask 255.255.255.255
ifconfig en0 alias 10.1.35.218 netmask 255.255.255.255
ifconfig en0 alias 10.1.35.219 netmask 255.255.255.255