refine it
This commit is contained in:
parent
35f35458c7
commit
397f37cbb7
|
@ -80,31 +80,6 @@ status_t gtp_add_node(list_t *list, gtp_node_t **node,
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
gtp_node_t *gtp_add_node_by_f_teid(list_t *list, gtp_f_teid_t *f_teid,
|
||||
c_uint16_t port, int no_ipv4, int no_ipv6, int prefer_ipv4)
|
||||
{
|
||||
status_t rv;
|
||||
gtp_node_t *node = NULL;
|
||||
c_sockaddr_t *sa_list = NULL;
|
||||
|
||||
d_assert(list, return NULL,);
|
||||
d_assert(f_teid, return NULL,);
|
||||
d_assert(port, return NULL,);
|
||||
|
||||
rv = gtp_f_teid_to_sockaddr(f_teid, port, &sa_list);
|
||||
d_assert(rv == CORE_OK, return NULL,);
|
||||
|
||||
rv = gtp_add_node(list, &node, sa_list, no_ipv4, no_ipv6, prefer_ipv4);
|
||||
d_assert(rv == CORE_OK, return NULL,);
|
||||
d_assert(node, return NULL,);
|
||||
|
||||
memcpy(&node->ip, &f_teid->ip, sizeof(ip_t));
|
||||
|
||||
core_freeaddrinfo(sa_list);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
status_t gtp_remove_node(list_t *list, gtp_node_t *node)
|
||||
{
|
||||
d_assert(node, return CORE_ERROR,);
|
||||
|
@ -139,7 +114,7 @@ status_t gtp_remove_all_nodes(list_t *list)
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
gtp_node_t* gtp_find_by_ip(list_t *list, ip_t *ip)
|
||||
gtp_node_t* gtp_find_node(list_t *list, ip_t *ip)
|
||||
{
|
||||
gtp_node_t *node = NULL;
|
||||
|
||||
|
@ -154,3 +129,29 @@ gtp_node_t* gtp_find_by_ip(list_t *list, ip_t *ip)
|
|||
|
||||
return node;
|
||||
}
|
||||
|
||||
gtp_node_t *gtp_connect_node(list_t *list, gtp_f_teid_t *f_teid,
|
||||
c_uint16_t port, int no_ipv4, int no_ipv6, int prefer_ipv4)
|
||||
{
|
||||
status_t rv;
|
||||
gtp_node_t *node = NULL;
|
||||
c_sockaddr_t *sa_list = NULL;
|
||||
|
||||
d_assert(list, return NULL,);
|
||||
d_assert(f_teid, return NULL,);
|
||||
d_assert(port, return NULL,);
|
||||
|
||||
rv = gtp_f_teid_to_sockaddr(f_teid, port, &sa_list);
|
||||
d_assert(rv == CORE_OK, return NULL,);
|
||||
|
||||
rv = gtp_add_node(list, &node, sa_list, no_ipv4, no_ipv6, prefer_ipv4);
|
||||
d_assert(rv == CORE_OK, return NULL,);
|
||||
d_assert(node, return NULL,);
|
||||
|
||||
memcpy(&node->ip, &f_teid->ip, sizeof(ip_t));
|
||||
|
||||
core_freeaddrinfo(sa_list);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,13 @@ CORE_DECLARE(status_t) gtp_node_final(void);
|
|||
|
||||
CORE_DECLARE(status_t) gtp_add_node(list_t *list, gtp_node_t **node,
|
||||
c_sockaddr_t *sa_list, int no_ipv4, int no_ipv6, int prefer_ipv4);
|
||||
CORE_DECLARE(gtp_node_t *) gtp_add_node_by_f_teid(
|
||||
list_t *list, gtp_f_teid_t *f_teid,
|
||||
c_uint16_t port, int no_ipv4, int no_ipv6, int prefer_ipv4);
|
||||
CORE_DECLARE(status_t) gtp_remove_node(list_t *list, gtp_node_t *node);
|
||||
CORE_DECLARE(status_t) gtp_remove_all_nodes(list_t *list);
|
||||
CORE_DECLARE(gtp_node_t *) gtp_find_by_ip(list_t *list, ip_t *ip);
|
||||
|
||||
CORE_DECLARE(gtp_node_t *) gtp_find_node(list_t *list, ip_t *ip);
|
||||
CORE_DECLARE(gtp_node_t *) gtp_connect_node(
|
||||
list_t *list, gtp_f_teid_t *f_teid,
|
||||
c_uint16_t port, int no_ipv4, int no_ipv6, int prefer_ipv4);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -765,11 +765,11 @@ gtp_node_t *pgw_sgw_add_by_message(gtp_message_t *message)
|
|||
|
||||
sgw_s5c_teid = req->sender_f_teid_for_control_plane.data;
|
||||
d_assert(sgw_s5c_teid, return NULL,);
|
||||
sgw = gtp_find_by_ip(&pgw_self()->sgw_list, &sgw_s5c_teid->ip);
|
||||
sgw = gtp_find_node(&pgw_self()->sgw_list, &sgw_s5c_teid->ip);
|
||||
if (!sgw)
|
||||
{
|
||||
sgw = gtp_add_node_by_f_teid(
|
||||
&pgw_self()->sgw_list, sgw_s5c_teid, pgw_self()->gtpc_port,
|
||||
sgw = gtp_connect_node(&pgw_self()->sgw_list, sgw_s5c_teid,
|
||||
pgw_self()->gtpc_port,
|
||||
context_self()->parameter.no_ipv4,
|
||||
context_self()->parameter.no_ipv6,
|
||||
context_self()->parameter.prefer_ipv4);
|
||||
|
@ -866,11 +866,11 @@ pgw_sess_t *pgw_sess_find_or_add_by_message(gtp_message_t *gtp_message)
|
|||
|
||||
sgw_s5c_teid = req->sender_f_teid_for_control_plane.data;
|
||||
d_assert(sgw_s5c_teid, return NULL,);
|
||||
sgw = gtp_find_by_ip(&pgw_self()->sgw_list, &sgw_s5c_teid->ip);
|
||||
sgw = gtp_find_node(&pgw_self()->sgw_list, &sgw_s5c_teid->ip);
|
||||
if (!sgw)
|
||||
{
|
||||
sgw = gtp_add_node_by_f_teid(
|
||||
&pgw_self()->sgw_list, sgw_s5c_teid, pgw_self()->gtpc_port,
|
||||
sgw = gtp_connect_node(&pgw_self()->sgw_list, sgw_s5c_teid,
|
||||
pgw_self()->gtpc_port,
|
||||
context_self()->parameter.no_ipv4,
|
||||
context_self()->parameter.no_ipv6,
|
||||
context_self()->parameter.prefer_ipv4);
|
||||
|
|
|
@ -417,11 +417,11 @@ gtp_node_t *sgw_mme_add_by_message(gtp_message_t *message)
|
|||
|
||||
mme_s11_teid = req->sender_f_teid_for_control_plane.data;
|
||||
d_assert(mme_s11_teid, return NULL,);
|
||||
mme = gtp_find_by_ip(&sgw_self()->mme_list, &mme_s11_teid->ip);
|
||||
mme = gtp_find_node(&sgw_self()->mme_list, &mme_s11_teid->ip);
|
||||
if (!mme)
|
||||
{
|
||||
mme = gtp_add_node_by_f_teid(
|
||||
&sgw_self()->mme_list, mme_s11_teid, sgw_self()->gtpc_port,
|
||||
mme = gtp_connect_node(&sgw_self()->mme_list, mme_s11_teid,
|
||||
sgw_self()->gtpc_port,
|
||||
context_self()->parameter.no_ipv4,
|
||||
context_self()->parameter.no_ipv6,
|
||||
context_self()->parameter.prefer_ipv4);
|
||||
|
|
|
@ -109,11 +109,11 @@ void sgw_s11_handle_create_session_request(
|
|||
pgw_s5c_teid = req->pgw_s5_s8_address_for_control_plane_or_pmip.data;
|
||||
d_assert(pgw_s5c_teid, return, "Null param");
|
||||
|
||||
pgw = gtp_find_by_ip(&sgw_self()->pgw_list, &pgw_s5c_teid->ip);
|
||||
pgw = gtp_find_node(&sgw_self()->pgw_list, &pgw_s5c_teid->ip);
|
||||
if (!pgw)
|
||||
{
|
||||
pgw = gtp_add_node_by_f_teid(
|
||||
&sgw_self()->pgw_list, pgw_s5c_teid, sgw_self()->gtpc_port,
|
||||
pgw = gtp_connect_node(&sgw_self()->pgw_list, pgw_s5c_teid,
|
||||
sgw_self()->gtpc_port,
|
||||
context_self()->parameter.no_ipv4,
|
||||
context_self()->parameter.no_ipv6,
|
||||
context_self()->parameter.prefer_ipv4);
|
||||
|
|
Loading…
Reference in New Issue