2019-04-27 14:54:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
|
|
|
*
|
|
|
|
* This file is part of Open5GS.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-09-13 12:07:47 +00:00
|
|
|
#if !defined(OGS_GTP_INSIDE) && !defined(OGS_GTP_COMPILATION)
|
|
|
|
#error "This header cannot be included directly."
|
|
|
|
#endif
|
2017-11-30 11:13:15 +00:00
|
|
|
|
2019-09-13 12:07:47 +00:00
|
|
|
#ifndef OGS_GTP_NODE_H
|
|
|
|
#define OGS_GTP_NODE_H
|
2017-12-01 15:44:07 +00:00
|
|
|
|
2017-11-30 11:13:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2019-06-11 09:28:25 +00:00
|
|
|
#endif
|
2017-11-30 11:13:15 +00:00
|
|
|
|
2019-09-13 12:07:47 +00:00
|
|
|
#define OGS_SETUP_GTP_NODE(__cTX, __gNODE) \
|
2017-12-06 08:58:38 +00:00
|
|
|
do { \
|
2019-04-27 14:54:30 +00:00
|
|
|
ogs_assert((__cTX)); \
|
|
|
|
ogs_assert((__gNODE)); \
|
2017-12-06 08:58:38 +00:00
|
|
|
(__cTX)->gnode = __gNODE; \
|
|
|
|
} while(0)
|
|
|
|
|
2017-11-30 11:13:15 +00:00
|
|
|
/**
|
|
|
|
* This structure represents the commonalities of GTP node such as MME, SGW,
|
|
|
|
* PGW gateway. Some of members may not be used by the specific type of node */
|
2019-09-13 12:07:47 +00:00
|
|
|
typedef struct ogs_gtp_node_s {
|
2019-04-27 14:54:30 +00:00
|
|
|
ogs_lnode_t node; /* A node of list_t */
|
2017-12-04 10:45:02 +00:00
|
|
|
|
2020-04-26 19:36:05 +00:00
|
|
|
ogs_sockaddr_t *sa_list; /* Socket Address List Candidate */
|
2017-12-04 10:45:02 +00:00
|
|
|
|
2019-11-07 14:07:29 +00:00
|
|
|
ogs_sock_t *sock; /* Socket Instance */
|
2020-04-26 19:36:05 +00:00
|
|
|
ogs_sockaddr_t addr; /* Remote Address */
|
|
|
|
|
|
|
|
ogs_ip_t ip; /* F-TEID IP Address Duplicate Check */
|
2017-12-04 10:45:02 +00:00
|
|
|
|
2019-04-27 14:54:30 +00:00
|
|
|
ogs_list_t local_list;
|
|
|
|
ogs_list_t remote_list;
|
2019-09-13 12:07:47 +00:00
|
|
|
} ogs_gtp_node_t;
|
2017-11-30 11:13:15 +00:00
|
|
|
|
2020-08-26 03:05:01 +00:00
|
|
|
int ogs_gtp_node_init(void);
|
|
|
|
void ogs_gtp_node_final(void);
|
2017-12-02 05:17:32 +00:00
|
|
|
|
2019-11-07 14:07:29 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_new(ogs_sockaddr_t *sa_list);
|
2019-09-13 12:07:47 +00:00
|
|
|
void ogs_gtp_node_free(ogs_gtp_node_t *node);
|
2018-09-23 04:16:40 +00:00
|
|
|
|
2020-04-26 19:36:05 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_add_by_f_teid(
|
2019-09-13 12:07:47 +00:00
|
|
|
ogs_list_t *list, ogs_gtp_f_teid_t *f_teid,
|
2019-04-27 14:54:30 +00:00
|
|
|
uint16_t port, int no_ipv4, int no_ipv6, int prefer_ipv4);
|
2019-11-07 14:07:29 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_add_by_addr(
|
|
|
|
ogs_list_t *list, ogs_sockaddr_t *addr);
|
2019-09-13 12:07:47 +00:00
|
|
|
void ogs_gtp_node_remove(ogs_list_t *list, ogs_gtp_node_t *node);
|
|
|
|
void ogs_gtp_node_remove_all(ogs_list_t *list);
|
2017-12-06 11:52:32 +00:00
|
|
|
|
2019-11-07 14:07:29 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_find_by_addr(
|
|
|
|
ogs_list_t *list, ogs_sockaddr_t *addr);
|
|
|
|
ogs_gtp_node_t *ogs_gtp_node_find_by_f_teid(
|
|
|
|
ogs_list_t *list, ogs_gtp_f_teid_t *f_teid);
|
2017-12-02 05:17:32 +00:00
|
|
|
|
2020-04-26 19:36:05 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_add_by_ip(ogs_list_t *list, ogs_ip_t *ip,
|
|
|
|
uint16_t port, int no_ipv4, int no_ipv6, int prefer_ipv4);
|
|
|
|
ogs_gtp_node_t *ogs_gtp_node_find_by_ip(ogs_list_t *list, ogs_ip_t *ip);
|
|
|
|
|
2017-11-30 11:13:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2019-06-11 09:28:25 +00:00
|
|
|
#endif
|
2017-11-30 11:13:15 +00:00
|
|
|
|
2019-09-13 12:07:47 +00:00
|
|
|
#endif /* OGS_GTP_NODE_H */
|