intermidiate

This commit is contained in:
Sukchan Lee 2017-02-13 14:17:26 +09:00
parent 0edd783ff8
commit 47a9d20c0a
6 changed files with 50 additions and 53 deletions

6
main.c
View File

@ -192,12 +192,10 @@ int main(int argc, char *argv[])
/* FIXME: Pass built symbol table to HypcerCell module. */
{
extern int _mme_sm;
extern int _ctx;
extern int _s1_path;
extern int _enb_s1_sm;
d_trace_level(&_mme_sm, 100);
d_trace_level(&_ctx, 100);
d_trace_level(&_s1_path, 100);
d_trace_level(&_enb_s1_sm, 100);
}
signal_init();

View File

@ -3,12 +3,12 @@
noinst_LTLIBRARIES = libcellwire.la
libcellwire_la_SOURCES = \
cellwire.h event.h context.h s1ap_message.h s1ap_conv.h s1_path.h \
cellwire.h event.h context.h s1ap_message.h s1ap_conv.h s1ap_path.h \
sm.h
nodist_libcellwire_la_SOURCES = \
init.c event.c context.c s1ap_message.c s1ap_conv.c s1_path.c \
init.c event.c context.c s1ap_message.c s1ap_conv.c s1ap_path.c \
mme_sm.c enb_s1_sm.c
AM_CPPFLAGS = \

View File

@ -4,7 +4,7 @@
#include "sm.h"
#include "context.h"
#include "event.h"
#include "s1_path.h"
#include "s1ap_path.h"
void mme_state_initial(mme_sm_t *s, event_t *e)
{
@ -36,7 +36,7 @@ void mme_state_operational(mme_sm_t *s, event_t *e)
{
case FSM_ENTRY_SIG:
{
rv = s1_open(s->queue_id);
rv = s1ap_open(s->queue_id);
if (rv != CORE_OK)
{
d_error("Can't establish S1 path");
@ -46,7 +46,7 @@ void mme_state_operational(mme_sm_t *s, event_t *e)
}
case FSM_EXIT_SIG:
{
rv = s1_close();
rv = s1ap_close();
if (rv != CORE_OK)
{
d_error("Can't close S1 path");
@ -67,8 +67,8 @@ void mme_state_operational(mme_sm_t *s, event_t *e)
enb_ctx_t *enb = enb_ctx_find_by_sock(sock);
if (!enb)
{
rc = net_register_sock(sock, _s1_recv_cb, (void*)s->queue_id);
d_assert(rc == 0, break, "register _s1_recv_cb failed");
rc = net_register_sock(sock, _s1ap_recv_cb, (void*)s->queue_id);
d_assert(rc == 0, break, "register _s1ap_recv_cb failed");
enb_ctx_t *enb = enb_ctx_add();
d_assert(enb, break, "Null param");

View File

@ -1,26 +0,0 @@
#ifndef __S1_PATH_H__
#define __S1_PATH_H__
#include "core.h"
#include "core_pkbuf.h"
#include "core_msgq.h"
#include "context.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(status_t) s1_open(msgq_id queue_id);
CORE_DECLARE(status_t) s1_close();
CORE_DECLARE(status_t) s1_send(net_sock_t *s, pkbuf_t *pkb);
CORE_DECLARE(status_t) s1_send_to_enb(enb_ctx_t *enb, pkbuf_t *pkb);
int _s1_recv_cb(net_sock_t *net_sock, void *data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* !__S1_PATH_H__ */

View File

@ -1,17 +1,16 @@
#define TRACE_MODULE _s1_path
#define TRACE_MODULE _s1ap_path
#include "core.h"
#include "core_debug.h"
#include "core_net.h"
#include "event.h"
#include "s1_path.h"
#include "s1ap_message.h"
#include "s1ap_path.h"
#define MAX_S1_PKBUF_SIZE 8192
static int _s1ap_accept_cb(net_sock_t *net_sock, void *data);
static int _s1_accept_cb(net_sock_t *net_sock, void *data);
status_t s1_open(msgq_id queue_id)
status_t s1ap_open(msgq_id queue_id)
{
char buf[INET_ADDRSTRLEN];
int rc;
@ -28,7 +27,7 @@ status_t s1_open(msgq_id queue_id)
}
rc = net_register_sock(
mme_self()->enb_s1_sock, _s1_accept_cb, (void *)queue_id);
mme_self()->enb_s1_sock, _s1ap_accept_cb, (void *)queue_id);
if (rc != 0)
{
d_error("Can't establish S1-ENB path(%d:%s)",
@ -44,7 +43,7 @@ status_t s1_open(msgq_id queue_id)
return CORE_OK;
}
status_t s1_close()
status_t s1ap_close()
{
d_assert(mme_self(), return CORE_ERROR, "Null param");
d_assert(mme_self()->enb_s1_sock != NULL, return CORE_ERROR,
@ -56,7 +55,7 @@ status_t s1_close()
return CORE_OK;
}
static int _s1_accept_cb(net_sock_t *net_sock, void *data)
static int _s1ap_accept_cb(net_sock_t *net_sock, void *data)
{
char buf[INET_ADDRSTRLEN];
ssize_t r;
@ -84,7 +83,7 @@ static int _s1_accept_cb(net_sock_t *net_sock, void *data)
return r;
}
static status_t s1_recv(net_sock_t *net_sock, pkbuf_t *pkb, msgq_id queue_id)
static status_t s1ap_recv(net_sock_t *net_sock, pkbuf_t *pkb, msgq_id queue_id)
{
event_t e;
@ -101,7 +100,7 @@ static status_t s1_recv(net_sock_t *net_sock, pkbuf_t *pkb, msgq_id queue_id)
return event_send(queue_id, &e);
}
int _s1_recv_cb(net_sock_t *net_sock, void *data)
int _s1ap_recv_cb(net_sock_t *net_sock, void *data)
{
status_t rv;
pkbuf_t *pkb;
@ -111,7 +110,7 @@ int _s1_recv_cb(net_sock_t *net_sock, void *data)
d_assert(net_sock, return -1, "Null param");
d_assert(queue_id, return -1, "Null param");
pkb = pkbuf_alloc(0, MAX_S1_PKBUF_SIZE);
pkb = pkbuf_alloc(0, S1AP_SDU_SIZE);
d_assert(pkb, return -1, "Can't allocate pkbuf");
r = net_read(net_sock, pkb->payload, pkb->len, 0);
@ -151,7 +150,7 @@ int _s1_recv_cb(net_sock_t *net_sock, void *data)
{
pkb->len = r;
rv = s1_recv(net_sock, pkb, queue_id);
rv = s1ap_recv(net_sock, pkb, queue_id);
if (rv == CORE_ERROR)
{
pkbuf_free(pkb);
@ -163,7 +162,7 @@ int _s1_recv_cb(net_sock_t *net_sock, void *data)
return 0;
}
status_t s1_send(net_sock_t *s, pkbuf_t *pkb)
status_t s1ap_send(net_sock_t *s, pkbuf_t *pkb)
{
char buf[INET_ADDRSTRLEN];
@ -187,11 +186,11 @@ status_t s1_send(net_sock_t *s, pkbuf_t *pkb)
return CORE_OK;
}
status_t s1_send_to_enb(enb_ctx_t *enb, pkbuf_t *pkb)
status_t s1ap_send_to_enb(enb_ctx_t *enb, pkbuf_t *pkb)
{
d_assert(enb, return CORE_ERROR, "Null param");
d_assert(pkb, return CORE_ERROR, "Null param");
d_assert(enb->s1_sock, return CORE_ERROR, "No S1 path with ENB");
return s1_send(enb->s1_sock, pkb);
return s1ap_send(enb->s1_sock, pkb);
}

26
src/s1ap_path.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef __S1AP_PATH_H__
#define __S1AP_PATH_H__
#include "core.h"
#include "core_pkbuf.h"
#include "core_msgq.h"
#include "context.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(status_t) s1ap_open(msgq_id queue_id);
CORE_DECLARE(status_t) s1ap_close();
CORE_DECLARE(status_t) s1ap_send(net_sock_t *s, pkbuf_t *pkb);
CORE_DECLARE(status_t) s1ap_send_to_enb(enb_ctx_t *enb, pkbuf_t *pkb);
int _s1ap_recv_cb(net_sock_t *net_sock, void *data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* !__S1_PATH_H__ */