update it

This commit is contained in:
Sukchan Lee 2017-04-03 15:27:00 +09:00
parent aa78a92cc0
commit 74e44dd4f1
5 changed files with 103 additions and 27 deletions

View File

@ -122,8 +122,8 @@ sgw_ctx_t* mme_ctx_sgw_add()
list_init(&sgw->gnode.initial_list);
list_init(&sgw->gnode.triggered_list);
sgw->gnode.local_list = &sgw->gnode.initial_list;
sgw->gnode.remote_list = &sgw->gnode.triggered_list;
sgw->gnode.local_list = &sgw->gnode.triggered_list;
sgw->gnode.remote_list = &sgw->gnode.initial_list;
list_append(&sgw_list, sgw);

View File

@ -144,11 +144,92 @@ void mme_state_operational(mme_sm_t *s, event_t *e)
}
case EVT_MSG_MME_S11:
{
s11_ctx_t *s11 = (s11_ctx_t *)event_get_param1(e);
d_assert(s11, break, "Null param");
net_sock_t *sock = (net_sock_t *)event_get_param1(e);
gtp_node_t *gnode = (gtp_node_t *)event_get_param2(e);
pkbuf_t *pkbuf = (pkbuf_t *)event_get_param3(e);
gtp_xact_t *xact = NULL;
gtpv2c_header_t *h = NULL;
gtp_message_t gtp_message;
d_assert(FSM_STATE(&s11->s11_sm), break, "Null param");
fsm_dispatch((fsm_t*)&s11->s11_sm, (fsm_event_t*)e);
d_assert(sock, break, "Null param");
d_assert(gnode, break, "Null param");
d_assert(pkbuf, break, "Null param");
h = pkbuf->payload;
d_assert(h, break, "Null param");
xact = gtp_xact_find(gnode, pkbuf);
if (!xact)
{
xact = gtp_xact_remote_create(&mme_self()->gtp_xact_ctx,
sock, gnode, h->sqn);
}
if (xact->org == GTP_LOCAL_ORIGINATOR)
{
if (xact->assoc_xact)
{
if (h->teid_presence)
pkbuf_header(pkbuf, -GTPV2C_HEADER_LEN);
else
pkbuf_header(pkbuf, -(GTPV2C_HEADER_LEN-GTPV2C_TEID_LEN));
memset(&gtp_message, 0, sizeof(gtp_message_t));
gtp_message.type = h->type;
d_assert(gtp_parse_msg(&gtp_message, pkbuf) == CORE_OK,
break, "parse error");
switch(gtp_message.type)
{
case GTP_CREATE_SESSION_RESPONSE_TYPE:
{
d_info("received response");
break;
}
}
}
gtp_xact_delete(xact);
}
else
{
if (xact->pkbuf)
{
d_assert(gtp_send(xact->sock, xact->gnode, xact->pkbuf)
== CORE_OK, break, "gtp_send error");
}
else
{
if (h->teid_presence)
pkbuf_header(pkbuf, -GTPV2C_HEADER_LEN);
else
pkbuf_header(pkbuf, -(GTPV2C_HEADER_LEN-GTPV2C_TEID_LEN));
memset(&gtp_message, 0, sizeof(gtp_message_t));
gtp_message.type = h->type;
d_assert(gtp_parse_msg(&gtp_message, pkbuf) == CORE_OK,
break, "parse error");
switch(gtp_message.type)
{
case GTP_CREATE_SESSION_RESPONSE_TYPE:
{
d_info("received response");
break;
}
}
}
}
pkbuf_free(pkbuf);
break;
}
case EVT_TM_MME_S11_T3:
{
gtp_xact_t *xact = (gtp_xact_t *)event_get_param1(e);
d_assert(xact, break, "Null param");
gtp_xact_timeout(xact);
break;
}
case EVT_LO_ENB_S1AP_CONNREFUSED:

View File

@ -7,7 +7,7 @@
#include "context.h"
#include "s11_path.h"
static int _gtpv2_c_recv_cb(net_sock_t *net_sock, void *data)
static int _gtpv2_c_recv_cb(net_sock_t *sock, void *data)
{
char buf[INET_ADDRSTRLEN];
status_t rv;
@ -16,31 +16,32 @@ static int _gtpv2_c_recv_cb(net_sock_t *net_sock, void *data)
gtp_node_t gnode;
sgw_ctx_t *sgw = NULL;
d_assert(net_sock, return -1, "Null param");
d_assert(sock, return -1, "Null param");
gnode.addr = net_sock->remote.sin_addr.s_addr;
gnode.port = net_sock->remote.sin_port;
sgw = mme_ctx_sgw_find_by_node(&gnode);
d_assert(sgw, return -1, "Can't find SGW from [%s:%d]",
INET_NTOP(&gnode.addr, buf), gnode.port);
pkbuf = gtp_read(net_sock);
pkbuf = gtp_read(sock);
if (pkbuf == NULL)
{
if (net_sock->sndrcv_errno == EAGAIN)
if (sock->sndrcv_errno == EAGAIN)
return 0;
return -1;
}
gnode.addr = sock->remote.sin_addr.s_addr;
gnode.port = ntohs(sock->remote.sin_port);
sgw = mme_ctx_sgw_find_by_node(&gnode);
d_assert(sgw, return -1, "Can't find SGW from [%s:%d]",
INET_NTOP(&gnode.addr, buf), gnode.port);
d_trace(1, "S11_PDU is received from SGW[%s:%d]\n",
INET_NTOP(&gnode.addr, buf), gnode.port);
d_trace_hex(1, pkbuf->payload, pkbuf->len);
event_set(&e, EVT_MSG_MME_S11);
event_set_param1(&e, (c_uintptr_t)sgw);
event_set_param2(&e, (c_uintptr_t)pkbuf);
event_set_param1(&e, (c_uintptr_t)sock);
event_set_param2(&e, (c_uintptr_t)sgw);
event_set_param3(&e, (c_uintptr_t)pkbuf);
rv = mme_event_send(&e);
if (rv != CORE_OK)
{
@ -96,10 +97,6 @@ status_t mme_s11_send_to_sgw(
d_assert(gtp_xact_commit(xact, gtp_message) == CORE_OK,
return CORE_ERROR, "xact commit error");
#if 1 /* FIXME */
gtp_xact_delete(xact);
#endif
return CORE_OK;
}

View File

@ -122,8 +122,8 @@ status_t pgw_s5c_send_to_sgw(gtp_xact_t *xact, gtp_message_t *gtp_message)
if (!xact)
{
xact = gtp_xact_local_create(&pgw_self()->gtp_xact_ctx, pgw_self()->s5c_sock,
&pgw_self()->s5c_node);
xact = gtp_xact_local_create(&pgw_self()->gtp_xact_ctx,
pgw_self()->s5c_sock, &pgw_self()->s5c_node);
}
d_assert(xact, return CORE_ERROR, "Null param");

View File

@ -17,8 +17,6 @@ void sgw_s11_handle_create_session_response(
gtp_xact_t *xact, gtp_message_t *gtp_message)
{
d_info("handle create_session response");
#if 0
d_assert(sgw_s11_send_to_mme(xact, gtp_message) == CORE_OK, return,
"failed to send message");
#endif
}