stream: Use new libosmocore API osmo_sock_init2_multiaddr2()

Use the new API available in libosmocore to set sockopts related to
ASCONF SCTP features. The old flag OSMO_SOCK_F_SCTP_ASCONF_SUPPORTED has
been dropped. This only affects master builds since there's no release
ever done with that flag defined.

Depends: libosmocore.git Change-Id I1f6fd09a79b0a2bd794e5669d933be25bbf1eeaa
Related: SYS#6501
Related: SYS#6558
Change-Id: I2b2073de72625b4f4f99892179c9406163d28592
This commit is contained in:
Pau Espin 2023-09-08 13:15:54 +02:00
parent 23f7d850a3
commit 839c90e149
3 changed files with 40 additions and 8 deletions

View File

@ -7,5 +7,5 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
libosmocore >1.8.0 osmo_iofd
libosmocore >1.8.0 osmo_iofd, osmo_sock_init2_multiaddr2()
stream NEW API osmo_stream_srv_link_set_name(), osmo_stream_srv_set_name(), osmo_stream_cli_set_name()

View File

@ -733,6 +733,9 @@ void osmo_stream_cli_destroy(struct osmo_stream_cli *cli)
*/
int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect)
{
#ifdef HAVE_LIBSCTP
struct osmo_sock_init2_multiaddr_pars ma_pars;
#endif
int ret;
/* we are reconfiguring this socket, close existing first. */
@ -744,10 +747,18 @@ int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect)
switch (cli->proto) {
#ifdef HAVE_LIBSCTP
case IPPROTO_SCTP:
ret = osmo_sock_init2_multiaddr(AF_UNSPEC, SOCK_STREAM, cli->proto,
ma_pars = (struct osmo_sock_init2_multiaddr_pars){
.sctp = {
.version = 0,
.sockopt_auth_supported = {.set = true, .abort_on_failure = false, .value = 1 },
.sockopt_asconf_supported = {.set = true, .abort_on_failure = false, .value = 1 },
}
};
ret = osmo_sock_init2_multiaddr2(AF_UNSPEC, SOCK_STREAM, cli->proto,
(const char **)cli->local_addr, cli->local_addrcnt, cli->local_port,
(const char **)cli->addr, cli->addrcnt, cli->port,
OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_BIND|OSMO_SOCK_F_NONBLOCK|OSMO_SOCK_F_SCTP_ASCONF_SUPPORTED);
OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_BIND|OSMO_SOCK_F_NONBLOCK,
&ma_pars);
break;
#endif
default:
@ -805,6 +816,9 @@ void osmo_stream_cli_set_nodelay(struct osmo_stream_cli *cli, bool nodelay)
* \return negative on error, 0 on success */
int osmo_stream_cli_open(struct osmo_stream_cli *cli)
{
#ifdef HAVE_LIBSCTP
struct osmo_sock_init2_multiaddr_pars ma_pars;
#endif
int ret, fd = -1;
/* we are reconfiguring this socket, close existing first. */
@ -823,10 +837,18 @@ int osmo_stream_cli_open(struct osmo_stream_cli *cli)
switch (cli->proto) {
#ifdef HAVE_LIBSCTP
case IPPROTO_SCTP:
ret = osmo_sock_init2_multiaddr(cli->sk_domain, cli->sk_type, cli->proto,
ma_pars = (struct osmo_sock_init2_multiaddr_pars){
.sctp = {
.version = 0,
.sockopt_auth_supported = {.set = true, .abort_on_failure = false, .value = 1 },
.sockopt_asconf_supported = {.set = true, .abort_on_failure = false, .value = 1 },
}
};
ret = osmo_sock_init2_multiaddr2(cli->sk_domain, cli->sk_type, cli->proto,
(const char **)cli->local_addr, cli->local_addrcnt, cli->local_port,
(const char **)cli->addr, cli->addrcnt, cli->port,
OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_BIND|OSMO_SOCK_F_NONBLOCK|OSMO_SOCK_F_SCTP_ASCONF_SUPPORTED);
OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_BIND|OSMO_SOCK_F_NONBLOCK,
&ma_pars);
break;
#endif
default:

View File

@ -387,6 +387,9 @@ void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link)
* \return negative on error, 0 on success */
int osmo_stream_srv_link_open(struct osmo_stream_srv_link *link)
{
#ifdef HAVE_LIBSCTP
struct osmo_sock_init2_multiaddr_pars ma_pars;
#endif
int ret;
if (link->ofd.fd >= 0) {
@ -409,9 +412,16 @@ int osmo_stream_srv_link_open(struct osmo_stream_srv_link *link)
switch (link->proto) {
#ifdef HAVE_LIBSCTP
case IPPROTO_SCTP:
ret = osmo_sock_init2_multiaddr(link->sk_domain, link->sk_type, link->proto,
(const char **)link->addr, link->addrcnt, link->port,
NULL, 0, 0, OSMO_SOCK_F_BIND|OSMO_SOCK_F_SCTP_ASCONF_SUPPORTED);
ma_pars = (struct osmo_sock_init2_multiaddr_pars){
.sctp = {
.version = 0,
.sockopt_auth_supported = {.set = true, .abort_on_failure = false, .value = 1 },
.sockopt_asconf_supported = {.set = true, .abort_on_failure = false, .value = 1 },
}
};
ret = osmo_sock_init2_multiaddr2(link->sk_domain, link->sk_type, link->proto,
(const char **)link->addr, link->addrcnt, link->port,
NULL, 0, 0, OSMO_SOCK_F_BIND, &ma_pars);
break;
#endif
default: