forked from acouzens/open5gs
update it
This commit is contained in:
parent
43ac434a4a
commit
52ae136923
|
@ -76,19 +76,19 @@ pkbuf_t *gtp_read(net_sock_t *net_sock)
|
|||
}
|
||||
|
||||
status_t gtp_send(net_sock_t *s,
|
||||
pkbuf_t *pkb, c_uint32_t ip_addr, c_uint16_t port)
|
||||
pkbuf_t *pkbuf, c_uint32_t ip_addr, c_uint16_t port)
|
||||
{
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
ssize_t sent;
|
||||
|
||||
d_assert(s, return CORE_ERROR, "Null param");
|
||||
d_assert(pkb, return CORE_ERROR, "Null param");
|
||||
d_assert(pkbuf, return CORE_ERROR, "Null param");
|
||||
|
||||
sent = net_sendto(s, pkb->payload, pkb->len, ip_addr, port);
|
||||
sent = net_sendto(s, pkbuf->payload, pkbuf->len, ip_addr, port);
|
||||
d_trace(1,"Sent %d->%d bytes to [%s:%d]\n",
|
||||
pkb->len, sent, INET_NTOP(&ip_addr, buf), port);
|
||||
d_trace_hex(1, pkb->payload, pkb->len);
|
||||
if (sent < 0 || sent != pkb->len)
|
||||
pkbuf->len, sent, INET_NTOP(&ip_addr, buf), port);
|
||||
d_trace_hex(1, pkbuf->payload, pkbuf->len);
|
||||
if (sent < 0 || sent != pkbuf->len)
|
||||
{
|
||||
d_error("net_send error (%d:%s)",
|
||||
s->sndrcv_errno, strerror(s->sndrcv_errno));
|
||||
|
|
|
@ -7,6 +7,7 @@ libmme_la_SOURCES = \
|
|||
event.h context.h \
|
||||
s1ap_build.h s1ap_conv.h s1ap_path.h \
|
||||
nas_conv.h nas_security.h \
|
||||
gtp_path.h \
|
||||
sm.h s6a_sm.h
|
||||
|
||||
nodist_libmme_la_SOURCES = \
|
||||
|
@ -14,6 +15,7 @@ nodist_libmme_la_SOURCES = \
|
|||
init.c event.c context.c \
|
||||
s1ap_build.c s1ap_conv.c s1ap_path.c \
|
||||
nas_conv.c nas_security.c \
|
||||
gtp_path.c \
|
||||
mme_sm.c enb_s1ap_sm.c ue_emm_sm.c s6a_sm.c
|
||||
|
||||
libmme_la_DEPENDENCIES = \
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#define SIZE_OF_UE_POOL (SIZE_OF_ENB_POOL * UE_PER_ENB)
|
||||
#define SIZE_OF_RAB_POOL (SIZE_OF_UE_POOL * RAB_PER_UE)
|
||||
|
||||
#define S1_SCTP_PORT 36412
|
||||
#define GTP_C_UDP_PORT 2123
|
||||
#define GTP_U_UDP_PORT 2152
|
||||
#define S1AP_SCTP_PORT 36412
|
||||
#define S11_UDP_PORT 2123
|
||||
#define S5_UDP_PORT 2152
|
||||
|
||||
static mme_ctx_t self;
|
||||
|
||||
|
@ -45,8 +45,12 @@ status_t mme_ctx_init()
|
|||
/* Initialize MME context */
|
||||
memset(&self, 0, sizeof(mme_ctx_t));
|
||||
|
||||
self.enb_local_addr = inet_addr("127.0.0.1");
|
||||
self.enb_s1ap_port = S1_SCTP_PORT;
|
||||
self.mme_local_addr = inet_addr("127.0.0.1");
|
||||
self.s1ap_port = S1AP_SCTP_PORT;
|
||||
|
||||
self.sgw_remote_addr = inet_addr("127.0.0.1");
|
||||
self.s11_local_port = S11_UDP_PORT;
|
||||
self.s11_remote_port = S11_UDP_PORT + 1;
|
||||
|
||||
self.plmn_id.mnc_len = 2;
|
||||
self.plmn_id.mcc = 1; /* 001 */
|
||||
|
|
|
@ -40,9 +40,15 @@ typedef struct _served_gummei {
|
|||
} srvd_gummei_t;
|
||||
|
||||
typedef struct _mme_ctx_t {
|
||||
net_sock_t *enb_s1ap_sock;
|
||||
c_uint16_t enb_s1ap_port;
|
||||
c_uint32_t enb_local_addr; /** Network byte order */
|
||||
c_uint32_t mme_local_addr;
|
||||
c_uint32_t sgw_remote_addr;
|
||||
|
||||
net_sock_t *s1ap_sock;
|
||||
c_uint16_t s1ap_port;
|
||||
|
||||
net_sock_t *s11_sock;
|
||||
c_uint16_t s11_local_port;
|
||||
c_uint16_t s11_remote_port;
|
||||
|
||||
msgq_id queue_id;
|
||||
tm_service_t tm_service;
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#define TRACE_MODULE _gtp_path
|
||||
#include "core_debug.h"
|
||||
#include "core_pkbuf.h"
|
||||
#include "core_net.h"
|
||||
|
||||
#include "3gpp_message.h"
|
||||
#include "gtp_path.h"
|
||||
|
||||
status_t mme_gtp_open()
|
||||
{
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t mme_gtp_close()
|
||||
{
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t mme_s11_send_to_sgw(pkbuf_t *pkbuf)
|
||||
{
|
||||
return CORE_OK;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef __MME_GTP_PATH_H__
|
||||
#define __MME_GTP_PATH_H__
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
CORE_DECLARE(status_t) mme_gtp_open();
|
||||
CORE_DECLARE(status_t) mme_gtp_close();
|
||||
|
||||
CORE_DECLARE(status_t) mme_s11_send_to_sgw(pkbuf_t *pkbuf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __MME_GTP_PATH_H__ */
|
|
@ -17,30 +17,30 @@ status_t s1ap_open(void)
|
|||
char buf[INET_ADDRSTRLEN];
|
||||
int rc;
|
||||
|
||||
rc = net_listen_with_addr(&mme_self()->enb_s1ap_sock,
|
||||
SOCK_STREAM, IPPROTO_SCTP, mme_self()->enb_s1ap_port,
|
||||
mme_self()->enb_local_addr);
|
||||
rc = net_listen_with_addr(&mme_self()->s1ap_sock,
|
||||
SOCK_STREAM, IPPROTO_SCTP, mme_self()->s1ap_port,
|
||||
mme_self()->mme_local_addr);
|
||||
if (rc != 0)
|
||||
{
|
||||
d_error("Can't establish S1-ENB(port:%d) path(%d:%s)",
|
||||
mme_self()->enb_s1ap_port, errno, strerror(errno));
|
||||
mme_self()->enb_s1ap_sock = NULL;
|
||||
mme_self()->s1ap_port, errno, strerror(errno));
|
||||
mme_self()->s1ap_sock = NULL;
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
rc = net_register_sock(
|
||||
mme_self()->enb_s1ap_sock, _s1ap_accept_cb, NULL);
|
||||
mme_self()->s1ap_sock, _s1ap_accept_cb, NULL);
|
||||
if (rc != 0)
|
||||
{
|
||||
d_error("Can't establish S1-ENB path(%d:%s)",
|
||||
errno, strerror(errno));
|
||||
net_close(mme_self()->enb_s1ap_sock);
|
||||
mme_self()->enb_s1ap_sock = NULL;
|
||||
net_close(mme_self()->s1ap_sock);
|
||||
mme_self()->s1ap_sock = NULL;
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
d_trace(1, "s1_enb_listen() %s:%d\n",
|
||||
INET_NTOP(&mme_self()->enb_local_addr, buf), mme_self()->enb_s1ap_port);
|
||||
INET_NTOP(&mme_self()->mme_local_addr, buf), mme_self()->s1ap_port);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ status_t s1ap_open(void)
|
|||
status_t s1ap_close()
|
||||
{
|
||||
d_assert(mme_self(), return CORE_ERROR, "Null param");
|
||||
d_assert(mme_self()->enb_s1ap_sock != NULL, return CORE_ERROR,
|
||||
d_assert(mme_self()->s1ap_sock != NULL, return CORE_ERROR,
|
||||
"S1-ENB path already opened");
|
||||
net_unregister_sock(mme_self()->enb_s1ap_sock);
|
||||
net_close(mme_self()->enb_s1ap_sock);
|
||||
mme_self()->enb_s1ap_sock = NULL;
|
||||
net_unregister_sock(mme_self()->s1ap_sock);
|
||||
net_close(mme_self()->s1ap_sock);
|
||||
mme_self()->s1ap_sock = NULL;
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ net_sock_t *tests1ap_enb_connect(void)
|
|||
|
||||
if (!mme) return NULL;
|
||||
|
||||
rv = net_open_with_addr(&sock, mme->enb_local_addr, "127.0.0.1", 0,
|
||||
mme->enb_s1ap_port, SOCK_SEQPACKET, IPPROTO_SCTP, 0);
|
||||
rv = net_open_with_addr(&sock, mme->mme_local_addr, "127.0.0.1", 0,
|
||||
mme->s1ap_port, SOCK_SEQPACKET, IPPROTO_SCTP, 0);
|
||||
if (rv != CORE_OK) return NULL;
|
||||
|
||||
return sock;
|
||||
|
|
|
@ -45,7 +45,7 @@ void test_initialize(void)
|
|||
{
|
||||
cellwire_initialize(NULL, NULL);
|
||||
|
||||
inet_pton(AF_INET, "127.0.0.1", &mme_self()->enb_local_addr);
|
||||
inet_pton(AF_INET, "127.0.0.1", &mme_self()->mme_local_addr);
|
||||
|
||||
atexit(test_terminate);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue