remove old_addr

This commit is contained in:
Sukchan Lee 2017-12-07 13:47:07 +09:00
parent 03a6bb7902
commit 717439cafa
4 changed files with 115 additions and 124 deletions

View File

@ -28,8 +28,6 @@ typedef struct _gtp_node_t {
sock_id sock; /* Socket instance */ sock_id sock; /* Socket instance */
c_sockaddr_t old_addr; /* Will be removed */
list_t local_list; list_t local_list;
list_t remote_list; list_t remote_list;
} gtp_node_t; } gtp_node_t;

View File

@ -196,45 +196,28 @@ status_t gtp_send(gtp_node_t *gnode, pkbuf_t *pkbuf)
char buf[CORE_ADDRSTRLEN]; char buf[CORE_ADDRSTRLEN];
ssize_t sent; ssize_t sent;
sock_id sock = 0; sock_id sock = 0;
c_sockaddr_t *addr = NULL;
d_assert(gnode, return CORE_ERROR, "Null param"); d_assert(gnode, return CORE_ERROR, "Null param");
d_assert(pkbuf, return CORE_ERROR, "Null param"); d_assert(pkbuf, return CORE_ERROR, "Null param");
sock = gnode->sock; sock = gnode->sock;
d_assert(sock, return CORE_ERROR, "Null param"); d_assert(sock, return CORE_ERROR, "Null param");
if (gnode->sa_list) /* New interface */
{ sock = gnode->sock;
sock_id sock = 0; d_assert(sock, return CORE_ERROR,);
c_sockaddr_t *addr = NULL; addr = sock_remote_addr(sock);
/* New interface */ d_assert(addr, return CORE_ERROR,);
sock = gnode->sock;
d_assert(sock, return CORE_ERROR,);
addr = sock_remote_addr(sock);
d_assert(addr, return CORE_ERROR,);
sent = core_send(sock, pkbuf->payload, pkbuf->len, 0); sent = core_send(sock, pkbuf->payload, pkbuf->len, 0);
d_trace(50, "Sent %d->%d bytes to [%s:%d]\n", pkbuf->len, sent, d_trace(50, "Sent %d->%d bytes to [%s:%d]\n", pkbuf->len, sent,
CORE_ADDR(addr, buf), CORE_PORT(addr)); CORE_ADDR(addr, buf), CORE_PORT(addr));
d_trace_hex(50, pkbuf->payload, pkbuf->len); d_trace_hex(50, pkbuf->payload, pkbuf->len);
if (sent < 0 || sent != pkbuf->len) if (sent < 0 || sent != pkbuf->len)
{
d_error("core_send [%s]:%d failed(%d:%s)",
CORE_ADDR(addr, buf), CORE_PORT(addr), errno, strerror(errno));
return CORE_ERROR;
}
}
else
{ {
/* Old interface : Will be removed */ d_error("core_send [%s]:%d failed(%d:%s)",
sent = core_sendto(sock, pkbuf->payload, pkbuf->len, 0, &gnode->old_addr); CORE_ADDR(addr, buf), CORE_PORT(addr), errno, strerror(errno));
d_trace(50, "Sent %d->%d bytes to [%s:%d]\n", pkbuf->len, sent, return CORE_ERROR;
CORE_ADDR(&gnode->old_addr, buf), CORE_PORT(&gnode->old_addr));
d_trace_hex(50, pkbuf->payload, pkbuf->len);
if (sent < 0 || sent != pkbuf->len)
{
d_error("core_sendto failed(%d:%s)", errno, strerror(errno));
return CORE_ERROR;
}
} }
return CORE_OK; return CORE_OK;

View File

@ -116,10 +116,11 @@ gtp_xact_t *gtp_xact_local_create(
rv = gtp_xact_update_tx(xact, hdesc, pkbuf); rv = gtp_xact_update_tx(xact, hdesc, pkbuf);
d_assert(rv == CORE_OK, return NULL, "Update Tx failed"); d_assert(rv == CORE_OK, return NULL, "Update Tx failed");
d_trace(3, "[%d] %s Create peer %s:%d\n", d_trace(3, "[%d] %s Create peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
CORE_ADDR(&gnode->old_addr, buf), CORE_PORT(&gnode->old_addr)); CORE_ADDR(sock_remote_addr(gnode->sock), buf),
CORE_PORT(sock_remote_addr(gnode->sock)));
return xact; return xact;
} }
@ -159,10 +160,11 @@ gtp_xact_t *gtp_xact_remote_create(gtp_node_t *gnode, c_uint32_t sqn)
list_append(xact->org == GTP_LOCAL_ORIGINATOR ? list_append(xact->org == GTP_LOCAL_ORIGINATOR ?
&xact->gnode->local_list : &xact->gnode->remote_list, xact); &xact->gnode->local_list : &xact->gnode->remote_list, xact);
d_trace(3, "[%d] %s Create peer %s:%d\n", d_trace(3, "[%d] %s Create peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
CORE_ADDR(&gnode->old_addr, buf), CORE_PORT(&gnode->old_addr)); CORE_ADDR(sock_remote_addr(gnode->sock), buf),
CORE_PORT(sock_remote_addr(gnode->sock)));
return xact; return xact;
} }
@ -197,12 +199,12 @@ status_t gtp_xact_update_tx(gtp_xact_t *xact,
d_assert(hdesc, return CORE_ERROR, "Null param"); d_assert(hdesc, return CORE_ERROR, "Null param");
d_assert(pkbuf, return CORE_ERROR, "Null param"); d_assert(pkbuf, return CORE_ERROR, "Null param");
d_trace(3, "[%d] %s UPD TX-%d peer %s:%d\n", d_trace(3, "[%d] %s UPD TX-%d peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
hdesc->type, hdesc->type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
stage = gtp_xact_get_stage(hdesc->type, xact->xid); stage = gtp_xact_get_stage(hdesc->type, xact->xid);
if (xact->org == GTP_LOCAL_ORIGINATOR) if (xact->org == GTP_LOCAL_ORIGINATOR)
@ -211,12 +213,12 @@ status_t gtp_xact_update_tx(gtp_xact_t *xact,
{ {
case GTP_XACT_INITIAL_STAGE: case GTP_XACT_INITIAL_STAGE:
d_assert(xact->step == 0, return CORE_ERROR, d_assert(xact->step == 0, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, hdesc->type, xact->step, hdesc->type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
break; break;
case GTP_XACT_INTERMEDIATE_STAGE: case GTP_XACT_INTERMEDIATE_STAGE:
@ -224,12 +226,12 @@ status_t gtp_xact_update_tx(gtp_xact_t *xact,
case GTP_XACT_FINAL_STAGE: case GTP_XACT_FINAL_STAGE:
d_assert(xact->step == 2, return CORE_ERROR, d_assert(xact->step == 2, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, hdesc->type, xact->step, hdesc->type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
break; break;
default: default:
@ -246,12 +248,12 @@ status_t gtp_xact_update_tx(gtp_xact_t *xact,
case GTP_XACT_INTERMEDIATE_STAGE: case GTP_XACT_INTERMEDIATE_STAGE:
case GTP_XACT_FINAL_STAGE: case GTP_XACT_FINAL_STAGE:
d_assert(xact->step == 1, return CORE_ERROR, d_assert(xact->step == 1, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, hdesc->type, xact->step, hdesc->type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
break; break;
default: default:
@ -290,12 +292,12 @@ status_t gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type)
char buf[CORE_ADDRSTRLEN]; char buf[CORE_ADDRSTRLEN];
gtp_xact_stage_t stage; gtp_xact_stage_t stage;
d_trace(3, "[%d] %s UPD RX-%d peer %s:%d\n", d_trace(3, "[%d] %s UPD RX-%d peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
type, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
stage = gtp_xact_get_stage(type, xact->xid); stage = gtp_xact_get_stage(type, xact->xid);
if (xact->org == GTP_LOCAL_ORIGINATOR) if (xact->org == GTP_LOCAL_ORIGINATOR)
@ -312,12 +314,12 @@ status_t gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type)
d_assert(xact->step == 2 || xact->step == 3, d_assert(xact->step == 2 || xact->step == 3,
return CORE_ERROR, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
pkbuf = xact->seq[2].pkbuf; pkbuf = xact->seq[2].pkbuf;
if (pkbuf) if (pkbuf)
@ -326,13 +328,14 @@ status_t gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type)
tm_start(xact->tm_holding); tm_start(xact->tm_holding);
d_warn("[%d] %s Request Duplicated. Retransmit!" d_warn("[%d] %s Request Duplicated. Retransmit!"
" for type %d peer %s:%d", " for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? xact->org == GTP_LOCAL_ORIGINATOR ?
"LOCAL " : "REMOTE", "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock),
CORE_PORT(&xact->gnode->old_addr)); buf),
CORE_PORT(sock_remote_addr(xact->gnode->sock)));
rv = gtp_send(xact->gnode, pkbuf); rv = gtp_send(xact->gnode, pkbuf);
d_assert(rv == CORE_OK, return CORE_ERROR, d_assert(rv == CORE_OK, return CORE_ERROR,
"gtp_send error"); "gtp_send error");
@ -340,25 +343,26 @@ status_t gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type)
else else
{ {
d_warn("[%d] %s Request Duplicated. Discard!" d_warn("[%d] %s Request Duplicated. Discard!"
" for type %d peer %s:%d", " for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? xact->org == GTP_LOCAL_ORIGINATOR ?
"LOCAL " : "REMOTE", "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock),
CORE_PORT(&xact->gnode->old_addr)); buf),
CORE_PORT(sock_remote_addr(xact->gnode->sock)));
} }
return CORE_EAGAIN; return CORE_EAGAIN;
} }
d_assert(xact->step == 1, return CORE_ERROR, d_assert(xact->step == 1, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
if (xact->tm_holding) if (xact->tm_holding)
tm_start(xact->tm_holding); tm_start(xact->tm_holding);
@ -367,12 +371,12 @@ status_t gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type)
case GTP_XACT_FINAL_STAGE: case GTP_XACT_FINAL_STAGE:
d_assert(xact->step == 1, return CORE_ERROR, d_assert(xact->step == 1, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
break; break;
@ -391,12 +395,12 @@ status_t gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type)
d_assert(xact->step == 1 || xact->step == 2, d_assert(xact->step == 1 || xact->step == 2,
return CORE_ERROR, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
pkbuf = xact->seq[1].pkbuf; pkbuf = xact->seq[1].pkbuf;
if (pkbuf) if (pkbuf)
@ -405,13 +409,14 @@ status_t gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type)
tm_start(xact->tm_holding); tm_start(xact->tm_holding);
d_warn("[%d] %s Request Duplicated. Retransmit!" d_warn("[%d] %s Request Duplicated. Retransmit!"
" for step %d type %d peer %s:%d", " for step %d type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? xact->org == GTP_LOCAL_ORIGINATOR ?
"LOCAL " : "REMOTE", "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock),
CORE_PORT(&xact->gnode->old_addr)); buf),
CORE_PORT(sock_remote_addr(xact->gnode->sock)));
rv = gtp_send(xact->gnode, pkbuf); rv = gtp_send(xact->gnode, pkbuf);
d_assert(rv == CORE_OK, return CORE_ERROR, d_assert(rv == CORE_OK, return CORE_ERROR,
"gtp_send error"); "gtp_send error");
@ -419,25 +424,26 @@ status_t gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type)
else else
{ {
d_warn("[%d] %s Request Duplicated. Discard!" d_warn("[%d] %s Request Duplicated. Discard!"
" for step %d type %d peer %s:%d", " for step %d type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? xact->org == GTP_LOCAL_ORIGINATOR ?
"LOCAL " : "REMOTE", "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock),
CORE_PORT(&xact->gnode->old_addr)); buf),
CORE_PORT(sock_remote_addr(xact->gnode->sock)));
} }
return CORE_EAGAIN; return CORE_EAGAIN;
} }
d_assert(xact->step == 0, return CORE_ERROR, d_assert(xact->step == 0, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
if (xact->tm_holding) if (xact->tm_holding)
tm_start(xact->tm_holding); tm_start(xact->tm_holding);
@ -449,12 +455,12 @@ status_t gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type)
case GTP_XACT_FINAL_STAGE: case GTP_XACT_FINAL_STAGE:
d_assert(xact->step == 2, return CORE_ERROR, d_assert(xact->step == 2, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
/* continue */ /* continue */
break; break;
@ -491,11 +497,11 @@ status_t gtp_xact_commit(gtp_xact_t *xact)
d_assert(xact, return CORE_ERROR, "Null param"); d_assert(xact, return CORE_ERROR, "Null param");
d_assert(xact->gnode, return CORE_ERROR, "Null param"); d_assert(xact->gnode, return CORE_ERROR, "Null param");
d_trace(3, "[%d] %s Commit peer %s:%d\n", d_trace(3, "[%d] %s Commit peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
type = xact->seq[xact->step-1].type; type = xact->seq[xact->step-1].type;
stage = gtp_xact_get_stage(type, xact->xid); stage = gtp_xact_get_stage(type, xact->xid);
@ -507,12 +513,12 @@ status_t gtp_xact_commit(gtp_xact_t *xact)
case GTP_XACT_INITIAL_STAGE: case GTP_XACT_INITIAL_STAGE:
{ {
d_assert(xact->step == 1, return CORE_ERROR, d_assert(xact->step == 1, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
if (xact->tm_response) if (xact->tm_response)
tm_start(xact->tm_response); tm_start(xact->tm_response);
@ -525,12 +531,12 @@ status_t gtp_xact_commit(gtp_xact_t *xact)
case GTP_XACT_FINAL_STAGE: case GTP_XACT_FINAL_STAGE:
d_assert(xact->step == 2 || xact->step == 3, return CORE_ERROR, d_assert(xact->step == 2 || xact->step == 3, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
if (xact->step == 2) if (xact->step == 2)
{ {
@ -553,12 +559,12 @@ status_t gtp_xact_commit(gtp_xact_t *xact)
case GTP_XACT_INTERMEDIATE_STAGE: case GTP_XACT_INTERMEDIATE_STAGE:
d_assert(xact->step == 2, return CORE_ERROR, d_assert(xact->step == 2, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
if (xact->tm_response) if (xact->tm_response)
tm_start(xact->tm_response); tm_start(xact->tm_response);
@ -568,12 +574,12 @@ status_t gtp_xact_commit(gtp_xact_t *xact)
case GTP_XACT_FINAL_STAGE: case GTP_XACT_FINAL_STAGE:
d_assert(xact->step == 2 || xact->step == 3, d_assert(xact->step == 2 || xact->step == 3,
return CORE_ERROR, return CORE_ERROR,
"[%d] %s invalid step %d for type %d peer %s:%d", "[%d] %s invalid step %d for type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, type, xact->step, type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
if (xact->step == 3) if (xact->step == 3)
{ {
@ -612,12 +618,12 @@ status_t gtp_xact_timeout(index_t index, c_uintptr_t event)
if (event == g_response_event) if (event == g_response_event)
{ {
d_trace(3, "[%d] %s Response Timeout " d_trace(3, "[%d] %s Response Timeout "
"for step %d type %d peer %s:%d\n", "for step %d type %d peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, xact->seq[xact->step-1].type, xact->step, xact->seq[xact->step-1].type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
if (--xact->response_rcount > 0) if (--xact->response_rcount > 0)
{ {
@ -635,24 +641,24 @@ status_t gtp_xact_timeout(index_t index, c_uintptr_t event)
else else
{ {
d_warn("[%d] %s No Reponse. Give up! " d_warn("[%d] %s No Reponse. Give up! "
"for step %d type %d peer %s:%d", "for step %d type %d peer [%s]:%d",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, xact->seq[xact->step-1].type, xact->step, xact->seq[xact->step-1].type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
gtp_xact_delete(xact); gtp_xact_delete(xact);
} }
} }
else if (event == g_holding_event) else if (event == g_holding_event)
{ {
d_trace(3, "[%d] %s Holding Timeout " d_trace(3, "[%d] %s Holding Timeout "
"for step %d type %d peer %s:%d\n", "for step %d type %d peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, xact->seq[xact->step-1].type, xact->step, xact->seq[xact->step-1].type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
if (--xact->holding_rcount > 0) if (--xact->holding_rcount > 0)
{ {
@ -662,12 +668,12 @@ status_t gtp_xact_timeout(index_t index, c_uintptr_t event)
else else
{ {
d_trace(3, "[%d] %s Delete Transaction " d_trace(3, "[%d] %s Delete Transaction "
"for step %d type %d peer %s:%d\n", "for step %d type %d peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
xact->step, xact->seq[xact->step-1].type, xact->step, xact->seq[xact->step-1].type,
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(&xact->gnode->old_addr)); CORE_PORT(sock_remote_addr(xact->gnode->sock)));
gtp_xact_delete(xact); gtp_xact_delete(xact);
} }
} }
@ -694,10 +700,11 @@ status_t gtp_xact_receive(
new = gtp_xact_remote_create(gnode, h->sqn); new = gtp_xact_remote_create(gnode, h->sqn);
d_assert(new, return CORE_ERROR, "Null param"); d_assert(new, return CORE_ERROR, "Null param");
d_trace(3, "[%d] %s Receive peer %s:%d\n", d_trace(3, "[%d] %s Receive peer [%s]:%d\n",
new->xid, new->xid,
new->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", new->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
CORE_ADDR(&gnode->old_addr, buf), CORE_PORT(&gnode->old_addr)); CORE_ADDR(sock_remote_addr(gnode->sock), buf),
CORE_PORT(sock_remote_addr(gnode->sock)));
rv = gtp_xact_update_rx(new, h->type); rv = gtp_xact_update_rx(new, h->type);
if (rv != CORE_OK) if (rv != CORE_OK)
@ -801,10 +808,11 @@ gtp_xact_t *gtp_xact_find_by_xid(
if (xact) if (xact)
{ {
d_trace(3, "[%d] %s Find peer %s:%d\n", d_trace(3, "[%d] %s Find peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
CORE_ADDR(&gnode->old_addr, buf), CORE_PORT(&gnode->old_addr)); CORE_ADDR(sock_remote_addr(gnode->sock), buf),
CORE_PORT(sock_remote_addr(gnode->sock)));
} }
return xact; return xact;
@ -841,10 +849,11 @@ static status_t gtp_xact_delete(gtp_xact_t *xact)
d_assert(xact, , "Null param"); d_assert(xact, , "Null param");
d_assert(xact->gnode, , "Null param"); d_assert(xact->gnode, , "Null param");
d_trace(3, "[%d] %s Delete peer %s:%d\n", d_trace(3, "[%d] %s Delete peer [%s]:%d\n",
xact->xid, xact->xid,
xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE", xact->org == GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
CORE_ADDR(&xact->gnode->old_addr, buf), CORE_PORT(&xact->gnode->old_addr)); CORE_ADDR(sock_remote_addr(xact->gnode->sock), buf),
CORE_PORT(sock_remote_addr(xact->gnode->sock)));
if (xact->seq[0].pkbuf) if (xact->seq[0].pkbuf)
pkbuf_free(xact->seq[0].pkbuf); pkbuf_free(xact->seq[0].pkbuf);

View File

@ -110,7 +110,8 @@ status_t testgtpu_enb_send(sock_id sock, c_uint32_t src_ip, c_uint32_t dst_ip)
status_t rv; status_t rv;
pkbuf_t *pkbuf = NULL; pkbuf_t *pkbuf = NULL;
gtp_header_t *gtp_h = NULL; gtp_header_t *gtp_h = NULL;
gtp_node_t gnode; ssize_t sent;
c_sockaddr_t to;
struct ip *ip_h = NULL; struct ip *ip_h = NULL;
struct icmp_header_t { struct icmp_header_t {
c_int8_t type; c_int8_t type;
@ -176,16 +177,16 @@ status_t testgtpu_enb_send(sock_id sock, c_uint32_t src_ip, c_uint32_t dst_ip)
icmp_h->checksum = in_cksum( icmp_h->checksum = in_cksum(
(unsigned short *)icmp_h, sizeof(struct icmp_header_t)); (unsigned short *)icmp_h, sizeof(struct icmp_header_t));
memset(&gnode, 0, sizeof(gtp_node_t)); memset(&to, 0, sizeof(c_sockaddr_t));
gnode.old_addr.sin.sin_addr.s_addr = bearer->sgw_s1u_addr; to.sin.sin_addr.s_addr = bearer->sgw_s1u_addr;
gnode.old_addr.c_sa_port = htons(GTPV1_U_UDP_PORT); to.c_sa_port = htons(GTPV1_U_UDP_PORT);
gnode.old_addr.c_sa_family = AF_INET; to.c_sa_family = AF_INET;
gnode.sock = sock; sent = core_sendto(sock, pkbuf->payload, pkbuf->len, 0, &to);
rv = gtp_send(&gnode, pkbuf);
pkbuf_free(pkbuf); pkbuf_free(pkbuf);
if (sent < 0 || sent != pkbuf->len)
return CORE_ERROR;
return rv; return CORE_OK;
} }
status_t testgtpu_enb_read(sock_id sock, pkbuf_t *recvbuf) status_t testgtpu_enb_read(sock_id sock, pkbuf_t *recvbuf)