mirror of
				https://github.com/open5gs/open5gs.git
				synced 2025-11-03 21:43:25 +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
		
	
		
			
				
	
	
		
			166 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			166 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * Copyright (C) 2019,2020 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 "test-common.h"
 | 
						|
 | 
						|
ogs_socknode_t *testsctp_server(const char *ipstr, int port)
 | 
						|
{
 | 
						|
    int rv;
 | 
						|
    ogs_sockaddr_t *addr = NULL;
 | 
						|
    ogs_socknode_t *node = NULL;
 | 
						|
    ogs_sock_t *sock = NULL;
 | 
						|
 | 
						|
    rv = ogs_getaddrinfo(&addr, AF_UNSPEC, ipstr, port, 0);
 | 
						|
    ogs_assert(rv == OGS_OK);
 | 
						|
 | 
						|
    node = ogs_socknode_new(addr);
 | 
						|
    ogs_assert(node);
 | 
						|
 | 
						|
    sock = ogs_sctp_server(SOCK_SEQPACKET, node->addr, NULL);
 | 
						|
    ogs_assert(sock);
 | 
						|
 | 
						|
    node->sock = sock;
 | 
						|
    node->cleanup = ogs_sctp_destroy;
 | 
						|
 | 
						|
    return node;
 | 
						|
}
 | 
						|
 | 
						|
ogs_socknode_t *testsctp_client(const char *ipstr, int port)
 | 
						|
{
 | 
						|
    int rv;
 | 
						|
    ogs_sockaddr_t *addr = NULL;
 | 
						|
    ogs_socknode_t *node = NULL;
 | 
						|
    ogs_sock_t *sock = NULL;
 | 
						|
 | 
						|
    rv = ogs_getaddrinfo(&addr, AF_UNSPEC, ipstr, port, 0);
 | 
						|
    ogs_assert(rv == OGS_OK);
 | 
						|
 | 
						|
    node = ogs_socknode_new(addr);
 | 
						|
    ogs_assert(node);
 | 
						|
 | 
						|
    sock = ogs_sctp_client(SOCK_STREAM, node->addr, NULL);
 | 
						|
    ogs_assert(sock);
 | 
						|
 | 
						|
    node->sock = sock;
 | 
						|
    node->cleanup = ogs_sctp_destroy;
 | 
						|
 | 
						|
    return node;
 | 
						|
}
 | 
						|
 | 
						|
ogs_socknode_t *tests1ap_client(int family)
 | 
						|
{
 | 
						|
    int rv;
 | 
						|
    ogs_sockaddr_t *addr = NULL;
 | 
						|
    ogs_socknode_t *node = NULL;
 | 
						|
    ogs_sock_t *sock = NULL;
 | 
						|
 | 
						|
    if (family == AF_INET6)
 | 
						|
        ogs_assert(OGS_OK ==
 | 
						|
            ogs_copyaddrinfo(&addr, test_self()->s1ap_addr6));
 | 
						|
    else
 | 
						|
        ogs_assert(OGS_OK ==
 | 
						|
            ogs_copyaddrinfo(&addr, test_self()->s1ap_addr));
 | 
						|
 | 
						|
    ogs_assert(addr);
 | 
						|
 | 
						|
    node = ogs_socknode_new(addr);
 | 
						|
    ogs_assert(node);
 | 
						|
 | 
						|
    sock = ogs_sctp_client(SOCK_STREAM, node->addr, NULL);
 | 
						|
    ogs_assert(sock);
 | 
						|
 | 
						|
    node->sock = sock;
 | 
						|
    node->cleanup = ogs_sctp_destroy;
 | 
						|
 | 
						|
    return node;
 | 
						|
}
 | 
						|
 | 
						|
ogs_socknode_t *testngap_client(int family)
 | 
						|
{
 | 
						|
    int rv;
 | 
						|
    ogs_sockaddr_t *addr = NULL;
 | 
						|
    ogs_socknode_t *node = NULL;
 | 
						|
    ogs_sock_t *sock = NULL;
 | 
						|
 | 
						|
    if (family == AF_INET6)
 | 
						|
        ogs_assert(OGS_OK ==
 | 
						|
            ogs_copyaddrinfo(&addr, test_self()->ngap_addr6));
 | 
						|
    else
 | 
						|
        ogs_assert(OGS_OK ==
 | 
						|
            ogs_copyaddrinfo(&addr, test_self()->ngap_addr));
 | 
						|
 | 
						|
    ogs_assert(addr);
 | 
						|
 | 
						|
    node = ogs_socknode_new(addr);
 | 
						|
    ogs_assert(node);
 | 
						|
 | 
						|
    sock = ogs_sctp_client(SOCK_STREAM, node->addr, NULL);
 | 
						|
    ogs_assert(sock);
 | 
						|
 | 
						|
    node->sock = sock;
 | 
						|
    node->cleanup = ogs_sctp_destroy;
 | 
						|
 | 
						|
    return node;
 | 
						|
}
 | 
						|
 | 
						|
ogs_sockaddr_t last_addr;
 | 
						|
 | 
						|
ogs_pkbuf_t *testsctp_read(ogs_socknode_t *node, int type)
 | 
						|
{
 | 
						|
    int size;
 | 
						|
    ogs_pkbuf_t *recvbuf = NULL;
 | 
						|
 | 
						|
    ogs_assert(node);
 | 
						|
    ogs_assert(node->sock);
 | 
						|
 | 
						|
    recvbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
 | 
						|
    ogs_assert(recvbuf);
 | 
						|
    ogs_pkbuf_put(recvbuf, OGS_MAX_SDU_LEN);
 | 
						|
 | 
						|
    size = ogs_sctp_recvdata(node->sock, recvbuf->data, OGS_MAX_SDU_LEN,
 | 
						|
            type == 1 ? &last_addr : NULL, NULL);
 | 
						|
    if (size <= 0) {
 | 
						|
        ogs_error("sgsap_recv() failed");
 | 
						|
        return NULL;
 | 
						|
    }
 | 
						|
 | 
						|
    ogs_pkbuf_trim(recvbuf, size);
 | 
						|
    return recvbuf;;
 | 
						|
}
 | 
						|
 | 
						|
int testsctp_send(ogs_socknode_t *node, ogs_pkbuf_t *pkbuf,
 | 
						|
        int ppid, uint16_t stream_no, int type)
 | 
						|
{
 | 
						|
    int sent;
 | 
						|
 | 
						|
    ogs_assert(node);
 | 
						|
    ogs_assert(node->sock);
 | 
						|
    ogs_assert(pkbuf);
 | 
						|
 | 
						|
    sent = ogs_sctp_sendmsg(node->sock, pkbuf->data, pkbuf->len,
 | 
						|
            type == 1 ? &last_addr : NULL, ppid, stream_no);
 | 
						|
    if (sent < 0 || sent != pkbuf->len) {
 | 
						|
        ogs_error("ogs_sctp_sendmsg error (%d:%s)", errno, strerror(errno));
 | 
						|
        return OGS_ERROR;
 | 
						|
    }
 | 
						|
    ogs_pkbuf_free(pkbuf);
 | 
						|
 | 
						|
    return OGS_OK;
 | 
						|
}
 |