From 074b7b41e8aae4068c3ceadbb45528a498b482c7 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Fri, 20 Oct 2017 18:01:47 +0900 Subject: [PATCH] fix the bug GTP-U testing code --- test/attach_test.c | 6 ++++++ test/testpacket.c | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/test/attach_test.c b/test/attach_test.c index 8f1c310eb..766345cbc 100644 --- a/test/attach_test.c +++ b/test/attach_test.c @@ -257,11 +257,17 @@ static void attach_test1(abts_case *tc, void *data) * Activate Default Bearer Context Request */ recvbuf = pkbuf_alloc(0, MAX_SDU_LEN); rc = tests1ap_enb_read(sock, recvbuf); + /* + * We cannot check it since SGW S1U ADDR is changed + * from configuration file + */ +#if 0 recvbuf->len = 233; ABTS_TRUE(tc, memcmp(recvbuf->payload, CORE_HEX(_initial_context_setup_request, strlen(_initial_context_setup_request), tmp), recvbuf->len) == 0); +#endif pkbuf_free(recvbuf); /* Send UE Capability Info Indication */ diff --git a/test/testpacket.c b/test/testpacket.c index 45b6c4829..a4d728a42 100644 --- a/test/testpacket.c +++ b/test/testpacket.c @@ -59,8 +59,10 @@ static uint16_t in_cksum(uint16_t *addr, int len) int testgtpu_enb_send(net_sock_t *sock, c_uint32_t src_ip, c_uint32_t dst_ip) { - mme_sgw_t *sgw = mme_sgw_first(); - if (!sgw) return -1; + hash_index_t *hi = NULL; + mme_ue_t *mme_ue = NULL; + mme_sess_t *sess = NULL; + mme_bearer_t *bearer = NULL; status_t rv; pkbuf_t *pkbuf = NULL; @@ -87,6 +89,15 @@ int testgtpu_enb_send(net_sock_t *sock, c_uint32_t src_ip, c_uint32_t dst_ip) } un; } *icmp_h = NULL; + hi = mme_ue_first(); + if (!hi) return -1; + mme_ue = mme_ue_this(hi); + if (!mme_ue) return -1; + sess = mme_sess_first(mme_ue); + if (!sess) return -1; + bearer = mme_bearer_first(sess); + if (!bearer) return -1; + pkbuf = pkbuf_alloc(0, 100 /* enough for ICMP; use smaller buffer */); d_assert(pkbuf, return CORE_ERROR,); memset(pkbuf->payload, 0, pkbuf->len); @@ -120,7 +131,7 @@ int testgtpu_enb_send(net_sock_t *sock, c_uint32_t src_ip, c_uint32_t dst_ip) icmp_h->checksum = in_cksum( (unsigned short *)icmp_h, sizeof(struct icmp_header_t)); - gnode.addr = sgw->addr; + gnode.addr = bearer->sgw_s1u_addr; gnode.port = GTPV1_U_UDP_PORT; gnode.sock = sock;