Commit Graph

9 Commits

Author SHA1 Message Date
Alexander Couzens 43957e69ca socket: introduce osmo_sock_init_osa & osmo_sock_init_osa_ofd
osmo_sock_init_osa() takes osmo_sockaddr* as local and remote endpoints
to setup a socket.

Change-Id: I1eece543e3241ef0e095eb63bb831f7c15a16794
2020-09-02 18:42:21 +02:00
Pau Espin d8cf52b993 socket: Fix bug in osmo_sock_init2(AF_UNSPEC) matching IP versions
See previous commit for a bug description.

Fixes: 2c962f5de1

Change-Id: I59bf4b4b3ed14766a5a5285923d1ffa9fc8b2294
2020-08-31 19:01:02 +02:00
Pau Espin d9e04177a2 tests: Add test to showcase osmo_sock_init2 bug with AF_UNSPEC
The function is checking for IP version matching between local and
remote addresses even if only one is needed based on flags. For example,
if user only desired to bind, the remote address should not be
used nor checked.

Bug was introduced here: 2c962f5de1

Change-Id: I87afd1db9bd017426abcc959fa515d15784cdf1c
2020-08-31 18:59:04 +02:00
Pau Espin 16b076cd15 tests: Split SCTP tests to its own file and run them conditionally
Some systmes (like the ones available in OBS) don't support creating
SCTP sockets, so we need to skip those tests there.

Change-Id: I1d16280674625877ec22cc60cbc5deb67868a656
2020-08-25 14:22:03 +02:00
Pau Espin ba828c30a0 socket: Log proper getaddrinfo() error
Drop one of the two log lines since it would be a duplicated and anyway
it misses context (return code).

Change-Id: I4620bf86f4bcda58ae85209278ac9ae9a0f3012a
2020-08-24 08:29:19 +00:00
Pau Espin cd133316cf socket: multiaddr: Support IPv4 + IPv6 addresses in SCTP associations
The function is improved to support AF_INET:v4->v4, AF_INET6:v6->v6 and
AF_UNSPEC:v4+v6->v4+v6.
Unit tests for the function are added to make sure function behaves
correctly in several scenarios.

Change-Id: I36d8ab85d92bba4d6adb83bc1875eb61094ed2ef
2020-08-24 08:29:19 +00:00
Alexander Couzens 2c962f5de1 osmo_sock_init2: improve support for AF_UNSPEC
osmo_sock_init2 abstract two calls of getaddrinfo into one.
While there aren't problems with AF_INET or AF_INET6. When using
AF_UNSPEC there are corner cases when this fails. E.g. calling
local_host with "" and remote_host with an IPv6 only address results in
setting up a local socket with AF_INET while trying to connect from there towards
AF_INET6 will most likely fail.
To prevent such cases with AF_UNSPEC, search prio calling any syscalls if local and remote site
supports AF_INET or AF_INET6. In case both supported, prefer AF_INET6

Change-Id: I397c633931fd00d4f083955a3c49a40fb002d766
2020-08-06 16:41:20 +00:00
Harald Welte dda70fca79 Add osmo_sock_init2() function, allowing both BIND *and* CONNECT
The old osmo_sock_init() function allows only either a bind (for a
server socket), or a connect (for a client socket), but not both
together.  So there's no way to have a client socket that is bound to a
specific local IP and/or port, which is needed for some use cases.

Change-Id: Idab124bcca47872f55311a82d6818aed590965e6
2017-04-09 21:46:21 +02:00
Harald Welte 4ffb43f654 Add minimal testing of socket.c helper functions
Change-Id: I2773b3859a206f96fb8fa095d50a653d9eeb8d79
2017-02-08 18:23:06 +01:00