mirror of
https://github.com/open5gs/open5gs.git
synced 2025-11-01 20:44:06 +00:00
UDP interface is changed
This commit is contained in:
@@ -28,7 +28,7 @@ int gtp_server(ogs_socknode_t *snode)
|
||||
char buf[OGS_ADDRSTRLEN];
|
||||
ogs_assert(snode);
|
||||
|
||||
snode->sock = ogs_udp_server(snode->addr);
|
||||
ogs_udp_server(snode);
|
||||
ogs_assert(snode->sock);
|
||||
|
||||
ogs_info("gtp_server() [%s]:%d",
|
||||
@@ -37,21 +37,6 @@ int gtp_server(ogs_socknode_t *snode)
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
int gtp_client(gtp_node_t *gnode)
|
||||
{
|
||||
char buf[OGS_ADDRSTRLEN];
|
||||
ogs_assert(gnode);
|
||||
|
||||
gnode->sock = ogs_udp_client(gnode->sa_list);
|
||||
ogs_assert(gnode->sock);
|
||||
memcpy(&gnode->conn, &gnode->sock->remote_addr, sizeof gnode->conn);
|
||||
|
||||
ogs_info("gtp_client() [%s]:%d",
|
||||
OGS_ADDR(gnode->sa_list, buf), OGS_PORT(gnode->sa_list));
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
int gtp_connect(ogs_sock_t *ipv4, ogs_sock_t *ipv6, gtp_node_t *gnode)
|
||||
{
|
||||
ogs_sockaddr_t *addr;
|
||||
|
||||
@@ -27,7 +27,6 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int gtp_server(ogs_socknode_t *snode);
|
||||
int gtp_client(gtp_node_t *gnode);
|
||||
int gtp_connect(ogs_sock_t *ipv4, ogs_sock_t *ipv6, gtp_node_t *gnode);
|
||||
|
||||
ogs_sock_t *gtp_local_sock_first(ogs_list_t *list);
|
||||
|
||||
Submodule lib/ogslib updated: 814d1871da...d8d6d399ab
@@ -95,12 +95,16 @@ int mme_gtp_close()
|
||||
ogs_list_for_each(&mme_self()->gtpc_list, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
ogs_list_for_each(&mme_self()->gtpc_list6, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
|
||||
@@ -45,7 +45,9 @@ void s1ap_delete(ogs_socknode_t *snode)
|
||||
ogs_assert(snode);
|
||||
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0 /* FIXME */
|
||||
s1ap_closesocket(snode->sock);
|
||||
#endif
|
||||
}
|
||||
|
||||
int s1ap_send(ogs_sock_t *sock, ogs_pkbuf_t *pkbuf,
|
||||
|
||||
@@ -315,23 +315,31 @@ int pgw_gtp_close()
|
||||
ogs_list_for_each(&pgw_self()->gtpc_list, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
ogs_list_for_each(&pgw_self()->gtpc_list6, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
|
||||
ogs_list_for_each(&pgw_self()->gtpu_list, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
ogs_list_for_each(&pgw_self()->gtpu_list6, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
|
||||
for (dev = pgw_dev_first(); dev; dev = pgw_dev_next(dev))
|
||||
|
||||
@@ -320,23 +320,31 @@ int sgw_gtp_close()
|
||||
ogs_list_for_each(&sgw_self()->gtpc_list, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
ogs_list_for_each(&sgw_self()->gtpc_list6, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
|
||||
ogs_list_for_each(&sgw_self()->gtpu_list, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
ogs_list_for_each(&sgw_self()->gtpu_list6, snode)
|
||||
{
|
||||
ogs_pollset_remove(snode->poll);
|
||||
#if 0
|
||||
ogs_sock_destroy(snode->sock);
|
||||
#endif
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
|
||||
@@ -77,32 +77,33 @@ int testenb_s1ap_close(ogs_sock_t *sock)
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
ogs_sock_t *testenb_gtpu_server(const char *ipstr)
|
||||
ogs_socknode_t *testenb_gtpu_server(const char *ipstr)
|
||||
{
|
||||
int rv;
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
ogs_socknode_t *node = NULL;
|
||||
ogs_sock_t *sock = NULL;
|
||||
|
||||
rv = ogs_getaddrinfo(&addr, AF_UNSPEC, ipstr, GTPV1_U_UDP_PORT, 0);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
node = ogs_socknode_new(AF_UNSPEC, ipstr, GTPV1_U_UDP_PORT, 0);
|
||||
ogs_assert(node);
|
||||
|
||||
sock = ogs_udp_server(addr);
|
||||
sock = ogs_udp_server(node);
|
||||
ogs_assert(sock);
|
||||
|
||||
ogs_freeaddrinfo(addr);
|
||||
|
||||
return sock;
|
||||
return node;
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *testenb_gtpu_read(ogs_sock_t *sock)
|
||||
ogs_pkbuf_t *testenb_gtpu_read(ogs_socknode_t *node)
|
||||
{
|
||||
int rc = 0;
|
||||
ogs_pkbuf_t *recvbuf = ogs_pkbuf_alloc(NULL, MAX_SDU_LEN);
|
||||
ogs_pkbuf_put(recvbuf, MAX_SDU_LEN);
|
||||
|
||||
ogs_assert(node);
|
||||
ogs_assert(node->sock);
|
||||
|
||||
while(1)
|
||||
{
|
||||
rc = ogs_recv(sock->fd, recvbuf->data, recvbuf->len, 0);
|
||||
rc = ogs_recv(node->sock->fd, recvbuf->data, recvbuf->len, 0);
|
||||
if (rc == -2)
|
||||
{
|
||||
continue;
|
||||
@@ -125,7 +126,7 @@ ogs_pkbuf_t *testenb_gtpu_read(ogs_sock_t *sock)
|
||||
return recvbuf;
|
||||
}
|
||||
|
||||
int testenb_gtpu_send(ogs_sock_t *sock, ogs_pkbuf_t *sendbuf)
|
||||
int testenb_gtpu_send(ogs_socknode_t *node, ogs_pkbuf_t *sendbuf)
|
||||
{
|
||||
int rv;
|
||||
ogs_hash_index_t *hi = NULL;
|
||||
@@ -136,7 +137,8 @@ int testenb_gtpu_send(ogs_sock_t *sock, ogs_pkbuf_t *sendbuf)
|
||||
ogs_sockaddr_t sgw;
|
||||
ssize_t sent;
|
||||
|
||||
ogs_assert(sock);
|
||||
ogs_assert(node);
|
||||
ogs_assert(node->sock);
|
||||
|
||||
hi = mme_ue_first();
|
||||
ogs_assert(hi);
|
||||
@@ -167,7 +169,7 @@ int testenb_gtpu_send(ogs_sock_t *sock, ogs_pkbuf_t *sendbuf)
|
||||
sgw.sin.sin_addr.s_addr = bearer->sgw_s1u_ip.addr;
|
||||
}
|
||||
|
||||
sent = ogs_sendto(sock->fd, sendbuf->data, sendbuf->len, 0, &sgw);
|
||||
sent = ogs_sendto(node->sock->fd, sendbuf->data, sendbuf->len, 0, &sgw);
|
||||
ogs_pkbuf_free(sendbuf);
|
||||
if (sent < 0 || sent != sendbuf->len)
|
||||
return OGS_ERROR;
|
||||
@@ -175,10 +177,9 @@ int testenb_gtpu_send(ogs_sock_t *sock, ogs_pkbuf_t *sendbuf)
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
int testenb_gtpu_close(ogs_sock_t *sock)
|
||||
void testenb_gtpu_close(ogs_socknode_t *node)
|
||||
{
|
||||
ogs_sock_destroy(sock);
|
||||
return OGS_OK;
|
||||
ogs_socknode_free(node);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ ogs_pkbuf_t *testenb_s1ap_read(ogs_sock_t *sock);
|
||||
int testenb_s1ap_send(ogs_sock_t *sock, ogs_pkbuf_t *sendbuf);
|
||||
int testenb_s1ap_close(ogs_sock_t *sock);
|
||||
|
||||
ogs_sock_t *testenb_gtpu_server(const char *ipstr);
|
||||
ogs_pkbuf_t *testenb_gtpu_read(ogs_sock_t *sock);
|
||||
int testenb_gtpu_send(ogs_sock_t *sock, ogs_pkbuf_t *sendbuf);
|
||||
int testenb_gtpu_close(ogs_sock_t *sock);
|
||||
ogs_socknode_t *testenb_gtpu_server(const char *ipstr);
|
||||
ogs_pkbuf_t *testenb_gtpu_read(ogs_socknode_t *node);
|
||||
int testenb_gtpu_send(ogs_socknode_t *node, ogs_pkbuf_t *sendbuf);
|
||||
void testenb_gtpu_close(ogs_socknode_t *node);
|
||||
|
||||
int tests1ap_build_setup_req(
|
||||
ogs_pkbuf_t **pkbuf, S1AP_ENB_ID_PR present, uint32_t enb_id,
|
||||
|
||||
@@ -18,7 +18,7 @@ static void attach_test1(abts_case *tc, void *data)
|
||||
{
|
||||
int rv;
|
||||
ogs_sock_t *sock;
|
||||
ogs_sock_t *gtpu;
|
||||
ogs_socknode_t *gtpu;
|
||||
ogs_pkbuf_t *sendbuf;
|
||||
ogs_pkbuf_t *recvbuf;
|
||||
s1ap_message_t message;
|
||||
@@ -439,8 +439,7 @@ static void attach_test1(abts_case *tc, void *data)
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* eNB disonncect from SGW */
|
||||
rv = testenb_gtpu_close(gtpu);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
testenb_gtpu_close(gtpu);
|
||||
|
||||
ogs_msleep(300);
|
||||
return;
|
||||
@@ -463,8 +462,7 @@ out:
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* eNB disonncect from SGW */
|
||||
rv = testenb_gtpu_close(gtpu);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
testenb_gtpu_close(gtpu);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1164,7 +1162,7 @@ static void attach_test4(abts_case *tc, void *data)
|
||||
{
|
||||
int rv;
|
||||
ogs_sock_t *sock;
|
||||
ogs_sock_t *gtpu;
|
||||
ogs_socknode_t *gtpu;
|
||||
ogs_pkbuf_t *sendbuf;
|
||||
ogs_pkbuf_t *recvbuf;
|
||||
s1ap_message_t message;
|
||||
@@ -1345,8 +1343,7 @@ static void attach_test4(abts_case *tc, void *data)
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* eNB disonncect from SGW */
|
||||
rv = testenb_gtpu_close(gtpu);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
testenb_gtpu_close(gtpu);
|
||||
|
||||
ogs_msleep(300);
|
||||
}
|
||||
@@ -1355,7 +1352,6 @@ static void attach_test5(abts_case *tc, void *data)
|
||||
{
|
||||
int rv;
|
||||
ogs_sock_t *sock;
|
||||
ogs_sock_t *gtpu;
|
||||
ogs_pkbuf_t *sendbuf;
|
||||
ogs_pkbuf_t *recvbuf;
|
||||
s1ap_message_t message;
|
||||
|
||||
@@ -13,7 +13,7 @@ static void handover_test1(abts_case *tc, void *data)
|
||||
{
|
||||
int rv;
|
||||
ogs_sock_t *sock1, *sock2;
|
||||
ogs_sock_t *gtpu1, *gtpu2;
|
||||
ogs_socknode_t *gtpu1, *gtpu2;
|
||||
ogs_pkbuf_t *sendbuf;
|
||||
ogs_pkbuf_t *recvbuf;
|
||||
s1ap_message_t message;
|
||||
@@ -314,11 +314,8 @@ static void handover_test1(abts_case *tc, void *data)
|
||||
mongoc_collection_destroy(collection);
|
||||
|
||||
/* eNB disonncect from SGW */
|
||||
rv = testenb_gtpu_close(gtpu2);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
rv = testenb_gtpu_close(gtpu1);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
testenb_gtpu_close(gtpu2);
|
||||
testenb_gtpu_close(gtpu1);
|
||||
|
||||
/* Two eNB disonncect from MME */
|
||||
rv = testenb_s1ap_close(sock2);
|
||||
@@ -334,7 +331,7 @@ static void handover_test2(abts_case *tc, void *data)
|
||||
{
|
||||
int rv;
|
||||
ogs_sock_t *sock1, *sock2;
|
||||
ogs_sock_t *gtpu1, *gtpu2;
|
||||
ogs_socknode_t *gtpu1, *gtpu2;
|
||||
ogs_pkbuf_t *sendbuf;
|
||||
ogs_pkbuf_t *recvbuf;
|
||||
s1ap_message_t message;
|
||||
@@ -824,11 +821,8 @@ static void handover_test2(abts_case *tc, void *data)
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* eNB disonncect from SGW */
|
||||
rv = testenb_gtpu_close(gtpu1);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
rv = testenb_gtpu_close(gtpu2);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
testenb_gtpu_close(gtpu1);
|
||||
testenb_gtpu_close(gtpu2);
|
||||
|
||||
ogs_msleep(300);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ static void test1_func(abts_case *tc, void *data)
|
||||
{
|
||||
int rv;
|
||||
ogs_sock_t *sock;
|
||||
ogs_sock_t *gtpu;
|
||||
ogs_socknode_t *gtpu;
|
||||
ogs_pkbuf_t *sendbuf;
|
||||
ogs_pkbuf_t *recvbuf;
|
||||
s1ap_message_t message;
|
||||
@@ -254,8 +254,7 @@ static void test1_func(abts_case *tc, void *data)
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* eNB disonncect from SGW */
|
||||
rv = testenb_gtpu_close(gtpu);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
testenb_gtpu_close(gtpu);
|
||||
|
||||
ogs_msleep(300);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user