change address type from c_uint32_t to c_sockaddr_t

This commit is contained in:
Sukchan Lee 2017-11-22 19:51:06 +09:00
parent 1928da0557
commit ce827fe733
9 changed files with 20 additions and 16 deletions

View File

@ -98,7 +98,7 @@ status_t gtp_send(gtp_node_t *gnode, pkbuf_t *pkbuf)
d_assert(sock, return CORE_ERROR, "Null param");
sent = net_sendto(sock, pkbuf->payload, pkbuf->len,
gnode->addr, gnode->port);
gnode->addr.sin.sin_addr.s_addr, gnode->port);
d_trace(50, "Sent %d->%d bytes to [%s:%d]\n", pkbuf->len, sent,
INET_NTOP(&gnode->addr, buf), gnode->port);
d_trace_hex(50, pkbuf->payload, pkbuf->len);

View File

@ -3,6 +3,7 @@
#include "core_pkbuf.h"
#include "core_net.h"
#include "core_network.h"
#include "core_list.h"
#ifdef __cplusplus
@ -18,7 +19,7 @@ extern "C" {
typedef struct _gtp_node_t {
lnode_t node; /**< A node of list_t */
c_uint32_t addr; /**< Network byte order IP Address */
c_sockaddr_t addr; /**< Network byte order IP Address */
c_uint16_t port; /**< Host byte order Port number */
net_sock_t *sock; /**< Socket Descriptor */

View File

@ -140,6 +140,7 @@ static status_t mme_context_validation()
context_self()->config.path);
return CORE_ERROR;
}
#if 0 /* ADDR */
while(sgw)
{
if (sgw->addr == 0)
@ -150,6 +151,7 @@ static status_t mme_context_validation()
}
sgw = mme_sgw_next(sgw);
}
#endif
self.sgw = mme_sgw_first();
if (self.max_num_of_served_gummei == 0)
@ -774,7 +776,8 @@ status_t mme_context_parse_config()
mme_sgw_t *sgw = mme_sgw_add();
d_assert(sgw, return CORE_ERROR,);
sgw->addr = inet_addr(addr);
core_inet_pton(AF_INET, addr, &sgw->addr);
sgw->addr.c_sa_port = htons(port);
sgw->port = port;
}
} while(
@ -988,7 +991,7 @@ mme_sgw_t* mme_sgw_find(c_uint32_t addr, c_uint16_t port)
sgw = mme_sgw_first();
while (sgw)
{
if (sgw->addr == addr && sgw->port == port)
if (sgw->addr.sin.sin_addr.s_addr == addr && sgw->port == port)
break;
sgw = mme_sgw_next(sgw);

View File

@ -440,7 +440,7 @@ pgw_sgw_t* pgw_sgw_find(c_uint32_t addr, c_uint16_t port)
sgw = pgw_sgw_first();
while (sgw)
{
if (sgw->addr == addr && sgw->port == port)
if (sgw->addr.sin.sin_addr.s_addr == addr && sgw->port == port)
break;
sgw = pgw_sgw_next(sgw);
@ -498,7 +498,7 @@ pgw_sess_t *pgw_sess_add(gtp_f_teid_t *sgw_s5c_teid,
sgw = pgw_sgw_add();
d_assert(sgw, return NULL, "Can't add SGW-GTP node");
sgw->addr = addr;
sgw->addr.sin.sin_addr.s_addr = addr;
sgw->port = port;
sgw->sock = pgw_self()->gtpc_sock;
}

View File

@ -62,7 +62,7 @@ static int _gtpv1_tun_recv_cb(net_link_t *net_link, void *data)
gtp_h->teid = htonl(bearer->sgw_s5u_teid);
/* Send to SGW */
gnode.addr = bearer->sgw_s5u_addr;
gnode.addr.sin.sin_addr.s_addr = bearer->sgw_s5u_addr;
gnode.port = GTPV1_U_UDP_PORT;
gnode.sock = pgw_self()->gtpu_sock;
d_trace(50, "Send S5U PDU (teid = 0x%x)to SGW(%s)\n",

View File

@ -285,7 +285,7 @@ sgw_mme_t* sgw_mme_find(c_uint32_t addr, c_uint16_t port)
mme = sgw_mme_first();
while (mme)
{
if (mme->addr == addr && mme->port == port)
if (mme->addr.sin.sin_addr.s_addr == addr && mme->port == port)
break;
mme = sgw_mme_next(mme);
@ -358,7 +358,7 @@ sgw_pgw_t* sgw_pgw_find(c_uint32_t addr, c_uint16_t port)
pgw = sgw_pgw_first();
while (pgw)
{
if (pgw->addr == addr && pgw->port == port)
if (pgw->addr.sin.sin_addr.s_addr == addr && pgw->port == port)
break;
pgw = sgw_pgw_next(pgw);
@ -407,7 +407,7 @@ sgw_ue_t* sgw_ue_add(gtp_f_teid_t *mme_s11_teid,
mme = sgw_mme_add();
d_assert(mme, return NULL, "Can't add MME-GTP node");
mme->addr = addr;
mme->addr.sin.sin_addr.s_addr = addr;
mme->port = port;
mme->sock = sgw_self()->gtpc_sock;
}

View File

@ -96,7 +96,7 @@ static int _gtpv1_u_recv_cb(net_sock_t *sock, void *data)
/* Echo reply */
d_trace(3, "Send echo-rsp to peer\n");
gnode.addr = sock->remote.sin_addr.s_addr;
gnode.addr.sin.sin_addr.s_addr = sock->remote.sin_addr.s_addr;
gnode.port = ntohs(sock->remote.sin_port);
gnode.sock = sock;
@ -131,7 +131,7 @@ static int _gtpv1_u_recv_cb(net_sock_t *sock, void *data)
s5u_tunnel = sgw_s5u_tunnel_in_bearer(bearer);
d_assert(s5u_tunnel, return -1, "Null param");
gnode.addr = s5u_tunnel->remote_addr;
gnode.addr.sin.sin_addr.s_addr = s5u_tunnel->remote_addr;
gtp_h->teid = htonl(s5u_tunnel->remote_teid);
gtp_send(&gnode, pkbuf);
@ -143,7 +143,7 @@ static int _gtpv1_u_recv_cb(net_sock_t *sock, void *data)
s1u_tunnel = sgw_s1u_tunnel_in_bearer(bearer);
d_assert(s1u_tunnel, return -1, "Null param");
gnode.addr = s1u_tunnel->remote_addr;
gnode.addr.sin.sin_addr.s_addr = s1u_tunnel->remote_addr;
if (s1u_tunnel->remote_teid)
{
@ -291,7 +291,7 @@ status_t sgw_gtp_send_end_marker(sgw_bearer_t *bearer)
h->type = GTPU_MSGTYPE_END_MARKER;
h->teid = htonl(s1u_tunnel->remote_teid);
gnode.addr = s1u_tunnel->remote_addr;
gnode.addr.sin.sin_addr.s_addr = s1u_tunnel->remote_addr;
gnode.port = GTPV1_U_UDP_PORT;
gnode.sock = sgw_self()->gtpu_sock;

View File

@ -107,7 +107,7 @@ void sgw_s11_handle_create_session_request(gtp_xact_t *s11_xact,
pgw = sgw_pgw_add();
d_assert(pgw, return, "Can't add PGW-GTP node");
pgw->addr = addr;
pgw->addr.sin.sin_addr.s_addr = addr;
pgw->port = port;
pgw->sock = sgw_self()->gtpc_sock;
}

View File

@ -139,7 +139,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 = bearer->sgw_s1u_addr;
gnode.addr.sin.sin_addr.s_addr = bearer->sgw_s1u_addr;
gnode.port = GTPV1_U_UDP_PORT;
gnode.sock = sock;