sctp: Add sack_delay in sctp configuration (#895)

This commit is contained in:
Sukchan Lee 2021-04-01 15:40:46 +09:00
parent c0396171ff
commit 5f9785af52
18 changed files with 165 additions and 233 deletions

View File

@ -242,9 +242,6 @@ nrf:
#
# parameter:
#
# o Number of output streams per SCTP associations.
# sctp_streams: 30
#
# o Disable use of IPv4 addresses (only IPv6)
# no_ipv4: true
#
@ -294,6 +291,27 @@ max:
#
pool:
#
# sockopt:
# no_delay : true
#
sockopt:
#
# sctp:
# heartbit_interval : 5000 (5secs)
# sack_delay : 200 (200ms)
# rto_initial : 3000 (3secs)
# rto_min : 1000 (1sec)
# rto_max : 5000 (5secs)
# max_num_of_ostreams : 30
# max_num_of_istreams : 65535
# max_attempts : 4
# max_initial_timeout : 8000(8secs)
# usrsctp_udp_port : 9899
#
sctp:
#
# time:
#

View File

@ -335,9 +335,6 @@ smf:
#
# parameter:
#
# o Number of output streams per SCTP associations.
# sctp_streams: 30
#
# o Disable use of IPv4 addresses (only IPv6)
# no_ipv4: true
#
@ -389,17 +386,23 @@ max:
pool:
#
# sctp:
# sockopt:
# no_delay : true
#
# o heartbit_interval : 5000 (5secs)
# o rto_initial : 3000 (3secs)
# o rto_min : 1000 (1sec)
# o rto_max : 5000 (5secs)
# o max_num_of_ostreams : 30
# o max_num_of_istreams : 65535
# o max_attempts : 4
# o max_initial_timeout : 8000(8secs)
# o usrsctp_udp_port : 9899
sockopt:
#
# sctp:
# heartbit_interval : 5000 (5secs)
# sack_delay : 200 (200ms)
# rto_initial : 3000 (3secs)
# rto_min : 1000 (1sec)
# rto_max : 5000 (5secs)
# max_num_of_ostreams : 30
# max_num_of_istreams : 65535
# max_attempts : 4
# max_initial_timeout : 8000(8secs)
# usrsctp_udp_port : 9899
#
sctp:

View File

@ -173,6 +173,18 @@ static void app_context_prepare(void)
#define USRSCTP_LOCAL_UDP_PORT 9899
self.usrsctp.udp_port = USRSCTP_LOCAL_UDP_PORT;
self.sctp.heartbit_interval = 5000; /* 5 seconds */
self.sctp.sack_delay = 200; /* 200 ms */
self.sctp.rto_initial = 3000; /* 3 seconds */
self.sctp.rto_min = 1000; /* 1 seconds */
self.sctp.rto_max = 5000; /* 5 seconds */
self.sctp.max_num_of_ostreams = OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS;
self.sctp.max_num_of_istreams = 65535;
self.sctp.max_attempts = 4;
self.sctp.max_initial_timeout = 8000; /* 8 seconds */
self.sockopt.no_delay = true;
#define MAX_NUM_OF_UE 1024 /* Num of UE per AMF/MME */
#define MAX_NUM_OF_GNB 32 /* Num of gNB per AMF/MME */
@ -345,6 +357,22 @@ int ogs_app_context_parse_config(void)
} else
ogs_warn("unknown key `%s`", parameter_key);
}
} else if (!strcmp(root_key, "sockopt")) {
ogs_yaml_iter_t sockopt_iter;
ogs_yaml_iter_recurse(&root_iter, &sockopt_iter);
while (ogs_yaml_iter_next(&sockopt_iter)) {
const char *sockopt_key = ogs_yaml_iter_key(&sockopt_iter);
ogs_assert(sockopt_key);
if (!strcmp(sockopt_key, "no_delay")) {
self.sockopt.no_delay =
ogs_yaml_iter_bool(&sockopt_iter);
} else if (!strcmp(sockopt_key, "linger")) {
const char *v = ogs_yaml_iter_value(&sockopt_iter);
if (v) self.sockopt.l_linger = atoi(v);
self.sockopt.l_onoff = true;
} else
ogs_warn("unknown key `%s`", sockopt_key);
}
} else if (!strcmp(root_key, "sctp")) {
ogs_yaml_iter_t sctp_iter;
ogs_yaml_iter_recurse(&root_iter, &sctp_iter);
@ -353,31 +381,34 @@ int ogs_app_context_parse_config(void)
ogs_assert(sctp_key);
if (!strcmp(sctp_key, "heartbit_interval")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.sockopt.sctp.heartbit_interval = atoi(v);
if (v) self.sctp.heartbit_interval = atoi(v);
} else if (!strcmp(sctp_key, "sack_delay")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.sctp.sack_delay = atoi(v);
} else if (!strcmp(sctp_key, "rto_initial")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.sockopt.sctp.rto_initial = atoi(v);
if (v) self.sctp.rto_initial = atoi(v);
} else if (!strcmp(sctp_key, "rto_min")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.sockopt.sctp.rto_min = atoi(v);
if (v) self.sctp.rto_min = atoi(v);
} else if (!strcmp(sctp_key, "rto_max")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.sockopt.sctp.rto_max = atoi(v);
if (v) self.sctp.rto_max = atoi(v);
} else if (!strcmp(sctp_key, "max_num_of_ostreams")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v)
self.sockopt.sctp.max_num_of_ostreams = atoi(v);
self.sctp.max_num_of_ostreams = atoi(v);
} else if (!strcmp(sctp_key, "max_num_of_istreams")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v)
self.sockopt.sctp.max_num_of_istreams = atoi(v);
self.sctp.max_num_of_istreams = atoi(v);
} else if (!strcmp(sctp_key, "max_attempts")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.sockopt.sctp.max_attempts = atoi(v);
if (v) self.sctp.max_attempts = atoi(v);
} else if (!strcmp(sctp_key, "max_initial_timeout")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v)
self.sockopt.sctp.max_initial_timeout = atoi(v);
self.sctp.max_initial_timeout = atoi(v);
} else if (!strcmp(sctp_key, "usrsctp_udp_port")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.usrsctp.udp_port = atoi(v);

View File

@ -78,7 +78,24 @@ typedef struct ogs_app_context_s {
int ignore_requested_nssai;
} parameter;
ogs_sockopt_t sockopt;
struct {
int no_delay;
int l_onoff;
int l_linger;
} sockopt;
struct {
int heartbit_interval;
int sack_delay;
int rto_initial;
int rto_min;
int rto_max;
int max_num_of_ostreams;
int max_num_of_istreams;
int max_attempts;
int max_initial_timeout;
} sctp;
struct {
int udp_port;
} usrsctp;

View File

@ -90,6 +90,8 @@ extern "C" {
#define OGS_MAX_QOS_FLOW_ID 63
#define OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS 30
/************************************
* PLMN_ID Structure */
#define OGS_MAX_NUM_OF_PLMN 6

View File

@ -243,27 +243,6 @@ int ogs_socknode_fill_scope_id_in_local(ogs_sockaddr_t *sa_list)
#endif
}
void ogs_socknode_sctp_option(ogs_socknode_t *node, ogs_sockopt_t *option)
{
ogs_assert(node);
ogs_assert(option);
memcpy(&node->option.sctp, &option->sctp, sizeof(option->sctp));
}
void ogs_socknode_nodelay(ogs_socknode_t *node, int on)
{
ogs_assert(node);
node->option.nodelay = on;
}
void ogs_socknode_linger(ogs_socknode_t *node, int onoff, int linger)
{
ogs_assert(node);
node->option.l_onoff = onoff;
node->option.l_linger = linger;
}
void ogs_socknode_set_cleanup(
ogs_socknode_t *node, void (*cleanup)(ogs_sock_t *))
{

View File

@ -28,23 +28,6 @@
extern "C" {
#endif
typedef struct ogs_sockopt_s {
struct {
int heartbit_interval;
int rto_initial;
int rto_min;
int rto_max;
int max_num_of_ostreams;
int max_num_of_istreams;
int max_attempts;
int max_initial_timeout;
} sctp;
int nodelay;
int l_onoff;
int l_linger;;
} ogs_sockopt_t;
typedef struct ogs_pollset_s ogs_pollset_t;
typedef struct ogs_poll_s ogs_poll_t;
@ -56,8 +39,6 @@ typedef struct ogs_socknode_s {
ogs_sock_t *sock;
void (*cleanup)(ogs_sock_t *sock);
ogs_poll_t *poll;
ogs_sockopt_t option;
} ogs_socknode_t;
ogs_socknode_t *ogs_socknode_new(ogs_sockaddr_t *addr);
@ -72,10 +53,6 @@ int ogs_socknode_probe(
ogs_list_t *list, ogs_list_t *list6, const char *dev, uint16_t port);
int ogs_socknode_fill_scope_id_in_local(ogs_sockaddr_t *sa_list);
void ogs_socknode_sctp_option(ogs_socknode_t *node, ogs_sockopt_t *option);
void ogs_socknode_nodelay(ogs_socknode_t *node, int on);
void ogs_socknode_linger(ogs_socknode_t *node, int onoff, int linger);
void ogs_socknode_set_cleanup(
ogs_socknode_t *node, void (*cleanup)(ogs_sock_t *));

View File

@ -23,9 +23,9 @@
#define OGS_LOG_DOMAIN __ogs_sock_domain
static int subscribe_to_events(ogs_sock_t *sock);
static int set_paddrparams(ogs_sock_t *sock, ogs_sockopt_t *option);
static int set_rtoinfo(ogs_sock_t *sock, ogs_sockopt_t *option);
static int set_initmsg(ogs_sock_t *sock, ogs_sockopt_t *option);
static int set_paddrparams(ogs_sock_t *sock);
static int set_rtoinfo(ogs_sock_t *sock);
static int set_initmsg(ogs_sock_t *sock);
static int set_nodelay(ogs_sock_t *sock, int on);
void ogs_sctp_init(uint16_t port)
@ -40,18 +40,6 @@ ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node)
{
ogs_sock_t *new = NULL;
int rv;
ogs_sockopt_t option = {
.sctp.heartbit_interval = 5000, /* 5 seconds */
.sctp.rto_initial = 3000, /* 3 seconds */
.sctp.rto_min = 1000, /* 1 seconds */
.sctp.rto_max = 5000, /* 5 seconds */
.sctp.max_num_of_ostreams = DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS,
.sctp.max_num_of_istreams = 65535,
.sctp.max_attempts = 4,
.sctp.max_initial_timeout = 8000, /* 8 seconds */
};
ogs_sctp_set_option(&option, node);
new = ogs_sock_socket(family, type, IPPROTO_SCTP);
ogs_assert(new);
@ -59,20 +47,20 @@ ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node)
rv = subscribe_to_events(new);
ogs_assert(rv == OGS_OK);
rv = set_paddrparams(new, &option);
rv = set_paddrparams(new);
ogs_assert(rv == OGS_OK);
rv = set_rtoinfo(new, &option);
rv = set_rtoinfo(new);
ogs_assert(rv == OGS_OK);
rv = set_initmsg(new, &option);
rv = set_initmsg(new);
ogs_assert(rv == OGS_OK);
if (node) {
if (node->option.nodelay) {
rv = set_nodelay(new, node->option.nodelay);
ogs_assert(rv == OGS_OK);
}
if (ogs_app()->sockopt.no_delay == true) {
rv = set_nodelay(new, true);
ogs_assert(rv == OGS_OK);
} else {
ogs_warn("SCTP NO_DELAY Disabled");
}
return new;
@ -464,13 +452,12 @@ static int sctp_setsockopt_paddrparams_workaround(
}
}
static int set_paddrparams(ogs_sock_t *sock, ogs_sockopt_t *option)
static int set_paddrparams(ogs_sock_t *sock)
{
struct sctp_paddrparams paddrparams;
socklen_t socklen;
ogs_assert(sock);
ogs_assert(option);
memset(&paddrparams, 0, sizeof(paddrparams));
socklen = sizeof(paddrparams);
@ -481,12 +468,14 @@ static int set_paddrparams(ogs_sock_t *sock, ogs_sockopt_t *option)
return OGS_ERROR;
}
ogs_trace("OLD spp_flags = 0x%x hbinter = %d pathmax = %d",
ogs_debug("OLD spp_flags = 0x%x hbinter = %d pathmax = %d, sackdelay = %d",
paddrparams.spp_flags,
paddrparams.spp_hbinterval,
paddrparams.spp_pathmaxrxt);
paddrparams.spp_pathmaxrxt,
paddrparams.spp_sackdelay);
paddrparams.spp_hbinterval = option->sctp.heartbit_interval;
paddrparams.spp_hbinterval = ogs_app()->sctp.heartbit_interval;
paddrparams.spp_sackdelay = ogs_app()->sctp.sack_delay;
#ifdef DISABLE_SCTP_EVENT_WORKAROUND
if (setsockopt(sock->fd, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS,
@ -502,21 +491,21 @@ static int set_paddrparams(ogs_sock_t *sock, ogs_sockopt_t *option)
}
#endif
ogs_trace("NEW spp_flags = 0x%x hbinter = %d pathmax = %d",
ogs_debug("NEW spp_flags = 0x%x hbinter = %d pathmax = %d, sackdelay = %d",
paddrparams.spp_flags,
paddrparams.spp_hbinterval,
paddrparams.spp_pathmaxrxt);
paddrparams.spp_pathmaxrxt,
paddrparams.spp_sackdelay);
return OGS_OK;
}
static int set_rtoinfo(ogs_sock_t *sock, ogs_sockopt_t *option)
static int set_rtoinfo(ogs_sock_t *sock)
{
struct sctp_rtoinfo rtoinfo;
socklen_t socklen;
ogs_assert(sock);
ogs_assert(option);
memset(&rtoinfo, 0, sizeof(rtoinfo));
socklen = sizeof(rtoinfo);
@ -527,14 +516,14 @@ static int set_rtoinfo(ogs_sock_t *sock, ogs_sockopt_t *option)
return OGS_ERROR;
}
ogs_trace("OLD RTO (initial:%d max:%d min:%d)",
ogs_debug("OLD RTO (initial:%d max:%d min:%d)",
rtoinfo.srto_initial,
rtoinfo.srto_max,
rtoinfo.srto_min);
rtoinfo.srto_initial = option->sctp.rto_initial;
rtoinfo.srto_min = option->sctp.rto_min;
rtoinfo.srto_max = option->sctp.rto_max;
rtoinfo.srto_initial = ogs_app()->sctp.rto_initial;
rtoinfo.srto_min = ogs_app()->sctp.rto_min;
rtoinfo.srto_max = ogs_app()->sctp.rto_max;
if (setsockopt(sock->fd, IPPROTO_SCTP, SCTP_RTOINFO,
&rtoinfo, sizeof(rtoinfo)) != 0) {
@ -542,7 +531,7 @@ static int set_rtoinfo(ogs_sock_t *sock, ogs_sockopt_t *option)
"setsockopt for SCTP_RTOINFO failed");
return OGS_ERROR;
}
ogs_trace("New RTO (initial:%d max:%d min:%d)",
ogs_debug("New RTO (initial:%d max:%d min:%d)",
rtoinfo.srto_initial,
rtoinfo.srto_max,
rtoinfo.srto_min);
@ -550,14 +539,13 @@ static int set_rtoinfo(ogs_sock_t *sock, ogs_sockopt_t *option)
return OGS_OK;
}
static int set_initmsg(ogs_sock_t *sock, ogs_sockopt_t *option)
static int set_initmsg(ogs_sock_t *sock)
{
struct sctp_initmsg initmsg;
socklen_t socklen;
ogs_assert(sock);
ogs_assert(option);
ogs_assert(option->sctp.max_num_of_ostreams > 1);
ogs_assert(ogs_app()->sctp.max_num_of_ostreams > 1);
memset(&initmsg, 0, sizeof(initmsg));
socklen = sizeof(initmsg);
@ -568,16 +556,16 @@ static int set_initmsg(ogs_sock_t *sock, ogs_sockopt_t *option)
return OGS_ERROR;
}
ogs_trace("Old INITMSG (numout:%d maxin:%d maxattempt:%d maxinit_to:%d)",
ogs_debug("Old INITMSG (numout:%d maxin:%d maxattempt:%d maxinit_to:%d)",
initmsg.sinit_num_ostreams,
initmsg.sinit_max_instreams,
initmsg.sinit_max_attempts,
initmsg.sinit_max_init_timeo);
initmsg.sinit_num_ostreams = option->sctp.max_num_of_ostreams;
initmsg.sinit_max_instreams = option->sctp.max_num_of_istreams;
initmsg.sinit_max_attempts = option->sctp.max_attempts;
initmsg.sinit_max_init_timeo = option->sctp.max_initial_timeout;
initmsg.sinit_num_ostreams = ogs_app()->sctp.max_num_of_ostreams;
initmsg.sinit_max_instreams = ogs_app()->sctp.max_num_of_istreams;
initmsg.sinit_max_attempts = ogs_app()->sctp.max_attempts;
initmsg.sinit_max_init_timeo = ogs_app()->sctp.max_initial_timeout;
if (setsockopt(sock->fd, IPPROTO_SCTP, SCTP_INITMSG,
&initmsg, sizeof(initmsg)) != 0) {
@ -586,7 +574,7 @@ static int set_initmsg(ogs_sock_t *sock, ogs_sockopt_t *option)
return OGS_ERROR;
}
ogs_trace("New INITMSG (numout:%d maxin:%d maxattempt:%d maxinit_to:%d)",
ogs_debug("New INITMSG (numout:%d maxin:%d maxattempt:%d maxinit_to:%d)",
initmsg.sinit_num_ostreams,
initmsg.sinit_max_instreams,
initmsg.sinit_max_attempts,
@ -599,7 +587,7 @@ static int set_nodelay(ogs_sock_t *sock, int on)
{
ogs_assert(sock);
ogs_trace("Turn on SCTP_NODELAY");
ogs_debug("Turn on SCTP_NODELAY");
if (setsockopt(sock->fd, IPPROTO_SCTP, SCTP_NODELAY,
&on, sizeof(on)) != 0) {
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno,

View File

@ -24,57 +24,6 @@ int __ogs_sctp_domain;
static void sctp_write_callback(short when, ogs_socket_t fd, void *data);
void ogs_sctp_set_option(ogs_sockopt_t *option, ogs_socknode_t *node)
{
ogs_assert(option);
if (node) {
if (node->option.sctp.heartbit_interval) {
option->sctp.heartbit_interval =
node->option.sctp.heartbit_interval;
ogs_debug("[SCTP] heartbit_interval - [%d]",
option->sctp.heartbit_interval);
}
if (node->option.sctp.rto_initial) {
option->sctp.rto_initial = node->option.sctp.rto_initial;
ogs_debug("[SCTP] rto_initial - [%d]",
option->sctp.rto_initial);
}
if (node->option.sctp.rto_min) {
option->sctp.rto_min = node->option.sctp.rto_min;
ogs_debug("[SCTP] rto_min - [%d]",
option->sctp.rto_min);
}
if (node->option.sctp.rto_max) {
option->sctp.rto_max = node->option.sctp.rto_max;
ogs_debug("[SCTP] rto_max - [%d]", option->sctp.rto_max);
}
if (node->option.sctp.max_num_of_ostreams) {
option->sctp.max_num_of_ostreams =
node->option.sctp.max_num_of_ostreams;
ogs_debug("[SCTP] max_num_of_ostreams - [%d]",
option->sctp.max_num_of_ostreams);
}
if (node->option.sctp.max_num_of_istreams) {
option->sctp.max_num_of_istreams =
node->option.sctp.max_num_of_istreams;
ogs_debug("[SCTP] max_num_of_istreams - [%d]",
option->sctp.max_num_of_istreams);
}
if (node->option.sctp.max_attempts) {
option->sctp.max_attempts = node->option.sctp.max_attempts;
ogs_debug("[SCTP] max_attempts - [%d]",
option->sctp.max_attempts);
}
if (node->option.sctp.max_initial_timeout) {
option->sctp.max_initial_timeout =
node->option.sctp.max_initial_timeout;
ogs_debug("[SCTP] max_initial_timeout - [%d]",
option->sctp.max_initial_timeout);
}
}
}
int ogs_sctp_recvdata(ogs_sock_t *sock, void *msg, size_t len,
ogs_sockaddr_t *from, ogs_sctp_info_t *sinfo)
{

View File

@ -20,7 +20,7 @@
#ifndef OGS_SCTP_H
#define OGS_SCTP_H
#include "ogs-core.h"
#include "ogs-app.h"
#include "sctp/sctp-config.h"
@ -80,8 +80,6 @@ ogs_sock_t *ogs_sctp_accept(ogs_sock_t *sock);
#endif
#define DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS 30
typedef struct ogs_sctp_sock_s {
int type; /* SOCK_STREAM or SOCK_SEQPACKET */
@ -108,8 +106,6 @@ void ogs_sctp_final(void);
ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node);
void ogs_sctp_set_option(ogs_sockopt_t *option, ogs_socknode_t *node);
ogs_sock_t *ogs_sctp_server(int type, ogs_socknode_t *node);
ogs_sock_t *ogs_sctp_client(int type, ogs_socknode_t *node);

View File

@ -59,42 +59,30 @@ ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node)
socklen_t socklen;
int i;
ogs_sockopt_t option = {
.sctp.heartbit_interval = 5000, /* 5 seconds */
.sctp.rto_initial = 3000, /* 3 seconds */
.sctp.rto_min = 1000, /* 1 seconds */
.sctp.rto_max = 5000, /* 5 seconds */
.sctp.max_num_of_ostreams = DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS,
.sctp.max_num_of_istreams = 65535,
.sctp.max_attempts = 4,
.sctp.max_initial_timeout = 8000, /* 8 seconds */
};
ogs_sctp_set_option(&option, node);
if (!(socket = usrsctp_socket(family, type, IPPROTO_SCTP,
NULL, NULL, 0, NULL))) {
ogs_error("ogs_sctp_socket() failed");
return NULL;
}
if (node) {
if (node->option.nodelay) {
if (usrsctp_setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY,
&on, sizeof(int)) < 0) {
ogs_error("usrsctp_setsockopt SCTP_NODELAY failed");
return NULL;
}
if (ogs_app()->sockopt.no_delay == true) {
if (usrsctp_setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY,
&on, sizeof(int)) < 0) {
ogs_error("usrsctp_setsockopt SCTP_NODELAY failed");
return NULL;
}
if (node->option.l_onoff) {
memset(&l, 0, sizeof(l));
l.l_onoff = node->option.l_onoff;
l.l_linger = node->option.l_linger;
if (usrsctp_setsockopt(socket, SOL_SOCKET, SO_LINGER,
(const void *)&l, (socklen_t) sizeof(struct linger)) < 0) {
ogs_error("Could not set SO_LINGER on SCTP socket");
return NULL;
}
} else {
ogs_warn("SCTP NO_DELAY Disabled");
}
if (ogs_app()->sockopt.l_onoff == true) {
memset(&l, 0, sizeof(l));
l.l_onoff = 1;
l.l_linger = ogs_app()->sockopt.l_linger;
if (usrsctp_setsockopt(socket, SOL_SOCKET, SO_LINGER,
(const void *)&l, (socklen_t) sizeof(struct linger)) < 0) {
ogs_error("Could not set SO_LINGER on SCTP socket");
return NULL;
}
}
@ -131,12 +119,12 @@ ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node)
initmsg.sinit_max_attempts,
initmsg.sinit_max_init_timeo);
ogs_assert(option.sctp.max_num_of_ostreams > 1);
ogs_assert(ogs_app()->sctp.max_num_of_ostreams > 1);
initmsg.sinit_num_ostreams = option.sctp.max_num_of_ostreams;
initmsg.sinit_max_instreams = option.sctp.max_num_of_istreams;
initmsg.sinit_max_attempts = option.sctp.max_attempts;
initmsg.sinit_max_init_timeo = option.sctp.max_initial_timeout;
initmsg.sinit_num_ostreams = ogs_app()->sctp.max_num_of_ostreams;
initmsg.sinit_max_instreams = ogs_app()->sctp.max_num_of_istreams;
initmsg.sinit_max_attempts = ogs_app()->sctp.max_attempts;
initmsg.sinit_max_init_timeo = ogs_app()->sctp.max_initial_timeout;
if (usrsctp_setsockopt(socket, IPPROTO_SCTP, SCTP_INITMSG,
&initmsg, sizeof(initmsg)) != 0) {

View File

@ -842,11 +842,10 @@ amf_gnb_t *amf_gnb_add(ogs_sock_t *sock, ogs_sockaddr_t *addr)
ogs_assert(gnb->sctp.poll.read);
}
gnb->max_num_of_ostreams = DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS;
gnb->max_num_of_ostreams = OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS;
gnb->ostream_id = 0;
if (ogs_app()->sockopt.sctp.max_num_of_ostreams) {
gnb->max_num_of_ostreams =
ogs_app()->sockopt.sctp.max_num_of_ostreams;
if (ogs_app()->sctp.max_num_of_ostreams) {
gnb->max_num_of_ostreams = ogs_app()->sctp.max_num_of_ostreams;
ogs_info("[GNB] max_num_of_ostreams : %d", gnb->max_num_of_ostreams);
}

View File

@ -37,9 +37,6 @@ ogs_sock_t *ngap_server(ogs_socknode_t *node)
ogs_assert(node);
ogs_socknode_sctp_option(node, &ogs_app()->sockopt);
ogs_socknode_nodelay(node, true);
#if HAVE_USRSCTP
sock = ogs_sctp_server(SOCK_SEQPACKET, node);
ogs_assert(sock);

View File

@ -1634,7 +1634,7 @@ mme_vlr_t *mme_vlr_add(ogs_sockaddr_t *sa_list)
ogs_assert(vlr);
memset(vlr, 0, sizeof *vlr);
vlr->max_num_of_ostreams = DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS;
vlr->max_num_of_ostreams = OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS;
vlr->ostream_id = 0;
vlr->sa_list = sa_list;
@ -1775,11 +1775,10 @@ mme_enb_t *mme_enb_add(ogs_sock_t *sock, ogs_sockaddr_t *addr)
ogs_list_init(&enb->sctp.write_queue);
}
enb->max_num_of_ostreams = DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS;
enb->max_num_of_ostreams = OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS;
enb->ostream_id = 0;
if (ogs_app()->sockopt.sctp.max_num_of_ostreams) {
enb->max_num_of_ostreams =
ogs_app()->sockopt.sctp.max_num_of_ostreams;
if (ogs_app()->sctp.max_num_of_ostreams) {
enb->max_num_of_ostreams = ogs_app()->sctp.max_num_of_ostreams;
ogs_info("[ENB] max_num_of_ostreams : %d", enb->max_num_of_ostreams);
}

View File

@ -38,9 +38,6 @@ ogs_sock_t *s1ap_server(ogs_socknode_t *node)
ogs_assert(node);
ogs_socknode_sctp_option(node, &ogs_app()->sockopt);
ogs_socknode_nodelay(node, true);
#if HAVE_USRSCTP
sock = ogs_sctp_server(SOCK_SEQPACKET, node);
ogs_assert(sock);

View File

@ -43,14 +43,6 @@ ogs_sock_t *sgsap_client(mme_vlr_t *vlr)
memset(&node, 0, sizeof node);
node.addr = vlr->sa_list;
ogs_socknode_sctp_option(&node, &ogs_app()->sockopt);
ogs_socknode_nodelay(&node, true);
#if 0 /* Try to remove LINGER in usrsctp */
#if HAVE_USRSCTP
ogs_socknode_linger(&node, true, 0);
#endif
#endif
sock = ogs_sctp_client(SOCK_SEQPACKET, &node);
if (sock) {
vlr->sock = sock;

View File

@ -30,7 +30,6 @@ ogs_socknode_t *testsctp_server(const char *ipstr, int port)
node = ogs_socknode_new(addr);
ogs_assert(node);
ogs_socknode_nodelay(node, true);
ogs_sctp_server(SOCK_SEQPACKET, node);
ogs_assert(node->sock);
@ -49,7 +48,6 @@ ogs_socknode_t *testsctp_client(const char *ipstr, int port)
node = ogs_socknode_new(addr);
ogs_assert(node);
ogs_socknode_nodelay(node, true);
ogs_sctp_client(SOCK_STREAM, node);
ogs_assert(node->sock);
@ -117,7 +115,6 @@ ogs_socknode_t *tests1ap_client(int family)
node = ogs_socknode_new(addr);
ogs_assert(node);
ogs_socknode_nodelay(node, true);
ogs_sctp_client(SOCK_STREAM, node);
ogs_assert(node->sock);
@ -140,7 +137,6 @@ ogs_socknode_t *testngap_client(int family)
node = ogs_socknode_new(addr);
ogs_assert(node);
ogs_socknode_nodelay(node, true);
ogs_sctp_client(SOCK_STREAM, node);
ogs_assert(node->sock);

View File

@ -75,7 +75,11 @@ int main(int argc, const char *const argv[])
ogs_pkbuf_default_init(&config);
ogs_pkbuf_default_create(&config);
ogs_app_setup_log();
ogs_app_context_init();
ogs_log_install_domain(&__ogs_sctp_domain, "sctp", OGS_LOG_ERROR);
#define USRSCTP_LOCAL_UDP_PORT 9899
ogs_sctp_init(USRSCTP_LOCAL_UDP_PORT);
atexit(terminate);