mirror of
https://github.com/open5gs/open5gs.git
synced 2025-11-16 20:01:36 +00:00
o GTP-C Option (Default)
- so_bindtodevice : NULL
gtpc:
addr: 127.0.0.7
option:
so_bindtodevice: vrf-blue
o GTP-U Option (Default)
- so_bindtodevice : NULL
gtpu:
addr: 127.0.0.7
option:
so_bindtodevice: vrf-blue
o PFCP Option (Default)
- so_bindtodevice : NULL
pfcp:
addr: 127.0.0.7
option:
so_bindtodevice: vrf-blue
o SBI Option (Default)
- tcp_nodelay : true
- so_linger.l_onoff : false
sbi:
addr: 127.0.0.10
option:
tcp_nodelay: false
so_linger:
l_onoff: true
l_linger: 10
o NGAP Option (Default)
- sctp_nodelay : true
- so_linger.l_onoff : false
ngap:
addr: 127.0.0.5
option:
stcp_nodelay: false
so_linger:
l_onoff: true
l_linger: 10
o NGAP SCTP Option (Default)
- spp_hbinterval : 5000 (5secs)
- spp_sackdelay : 200 (200ms)
- srto_initial : 3000 (3secs)
- srto_min : 1000 (1sec)
- srto_max : 5000 (5secs)
- sinit_num_ostreams : 30
- sinit_max_instreams : 65535
- sinit_max_attempts : 4
- sinit_max_init_timeo : 8000(8secs)
ngap:
addr: 127.0.0.5
option:
sctp:
spp_hbinterval : 5000
spp_sackdelay : 200
srto_initial : 3000
srto_min : 1000
srto_max : 5000
sinit_num_ostreams : 30
sinit_max_instreams : 65535
sinit_max_attempts : 4
sinit_max_init_timeo : 8000
140 lines
3.6 KiB
C
140 lines
3.6 KiB
C
/*
|
|
* 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/>.
|
|
*/
|
|
|
|
#include "ogs-gtp.h"
|
|
|
|
ogs_sock_t *ogs_gtp_server(ogs_socknode_t *node)
|
|
{
|
|
char buf[OGS_ADDRSTRLEN];
|
|
ogs_sock_t *gtp;
|
|
ogs_assert(node);
|
|
|
|
gtp = ogs_udp_server(node->addr, node->option);
|
|
if (gtp) {
|
|
ogs_info("gtp_server() [%s]:%d",
|
|
OGS_ADDR(node->addr, buf), OGS_PORT(node->addr));
|
|
|
|
node->sock = gtp;
|
|
}
|
|
|
|
return gtp;
|
|
}
|
|
|
|
int ogs_gtp_connect(ogs_sock_t *ipv4, ogs_sock_t *ipv6, ogs_gtp_node_t *gnode)
|
|
{
|
|
ogs_sockaddr_t *addr;
|
|
char buf[OGS_ADDRSTRLEN];
|
|
|
|
ogs_assert(ipv4 || ipv6);
|
|
ogs_assert(gnode);
|
|
ogs_assert(gnode->sa_list);
|
|
|
|
addr = gnode->sa_list;
|
|
while (addr) {
|
|
ogs_sock_t *sock = NULL;
|
|
|
|
if (addr->ogs_sa_family == AF_INET)
|
|
sock = ipv4;
|
|
else if (addr->ogs_sa_family == AF_INET6)
|
|
sock = ipv6;
|
|
else
|
|
ogs_assert_if_reached();
|
|
|
|
if (sock) {
|
|
ogs_info("gtp_connect() [%s]:%d",
|
|
OGS_ADDR(addr, buf), OGS_PORT(addr));
|
|
|
|
gnode->sock = sock;
|
|
memcpy(&gnode->addr, addr, sizeof gnode->addr);
|
|
break;
|
|
}
|
|
|
|
addr = addr->next;
|
|
}
|
|
|
|
if (addr == NULL) {
|
|
ogs_log_message(OGS_LOG_WARN, ogs_socket_errno,
|
|
"gtp_connect() [%s]:%d failed",
|
|
OGS_ADDR(gnode->sa_list, buf), OGS_PORT(gnode->sa_list));
|
|
return OGS_ERROR;
|
|
}
|
|
|
|
return OGS_OK;
|
|
}
|
|
|
|
int ogs_gtp_send(ogs_gtp_node_t *gnode, ogs_pkbuf_t *pkbuf)
|
|
{
|
|
ssize_t sent;
|
|
ogs_sock_t *sock = NULL;
|
|
|
|
ogs_assert(gnode);
|
|
ogs_assert(pkbuf);
|
|
sock = gnode->sock;
|
|
ogs_assert(sock);
|
|
|
|
sent = ogs_send(sock->fd, pkbuf->data, pkbuf->len, 0);
|
|
if (sent < 0 || sent != pkbuf->len) {
|
|
if (ogs_socket_errno != OGS_EAGAIN) {
|
|
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno,
|
|
"ogs_gtp_send() failed");
|
|
}
|
|
return OGS_ERROR;
|
|
}
|
|
|
|
return OGS_OK;
|
|
}
|
|
|
|
int ogs_gtp_sendto(ogs_gtp_node_t *gnode, ogs_pkbuf_t *pkbuf)
|
|
{
|
|
ssize_t sent;
|
|
ogs_sock_t *sock = NULL;
|
|
ogs_sockaddr_t *addr = NULL;
|
|
|
|
ogs_assert(gnode);
|
|
ogs_assert(pkbuf);
|
|
sock = gnode->sock;
|
|
ogs_assert(sock);
|
|
addr = &gnode->addr;
|
|
ogs_assert(addr);
|
|
|
|
sent = ogs_sendto(sock->fd, pkbuf->data, pkbuf->len, 0, addr);
|
|
if (sent < 0 || sent != pkbuf->len) {
|
|
if (ogs_socket_errno != OGS_EAGAIN) {
|
|
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno,
|
|
"ogs_gtp_sendto() failed");
|
|
}
|
|
return OGS_ERROR;
|
|
}
|
|
|
|
return OGS_OK;
|
|
}
|
|
|
|
void ogs_gtp_send_error_message(
|
|
ogs_gtp_xact_t *xact, uint32_t teid, uint8_t type, uint8_t cause_value)
|
|
{
|
|
switch (xact->gtp_version) {
|
|
case 1:
|
|
ogs_gtp1_send_error_message(xact, teid, type, cause_value);
|
|
break;
|
|
case 2:
|
|
ogs_gtp2_send_error_message(xact, teid, type, cause_value);
|
|
break;
|
|
}
|
|
}
|