summaryrefslogtreecommitdiff
path: root/socket
AgeCommit message (Collapse)AuthorFilesLines
2022-07-29udp-bsd: Explicitly bind to the interface when creating a socketOlivier Crête1-0/+28
2022-05-26agent: Support adding optional headers to HTTP proxy clientJohan Sternerup2-15/+30
One use case for this is adding an ALPN header which is a MUST requirement when a HTTP proxy is used in WebRTC (see RFC8835, section 3.4).
2021-11-26tcp-active: Fix use-after-free in error caseOlivier Crête1-10/+30
Fixes issue found by Coverity
2021-11-22conncheck: don't ignore local socket errorsFabrice Bellet3-17/+52
With this patch we ensure that local socket errors during connection establishment are properly transmitted to the connection check layer, so the related pair can be put in state failed when needed. The local socket errors we are interested in, are those occuring when the local source address cannot be bound anymore, because the underlying interface vanished for example. In particular, we don't ignore errors coming from g_socket_bind() with tcp active sockets, that perform a bind to *whatever* local address is available, in case it cannot bind to the specified address. This behaviour was demonstrated with the test-tcp example, that tried to bind to the IPv4 loopback address on a socket initially created for the IPv6 loopback.
2021-11-01Remove g_assert_cmp* macros outside of the unit testsOlivier Crête3-6/+6
2021-05-10tcp-bsd: Handle send before connect() completesOle André Vadla Ravnås1-0/+1
2021-05-03udp-turn: Remove request before freeing itOlivier Crête1-1/+1
As removing the request from the queue looks into the SendRequest, one needs to unqueue it before freeing it.
2021-04-20udp-turn: don't allocate large arrays on the stackFabrice Bellet1-4/+11
2020-12-07agent: report duplicated port in udp bsd sockets tooFabrice Bellet2-4/+4
This patch fixes cases, where the range is full, some ports fail with HOST_CANDIDATE_CANT_CREATE_SOCKET, other fail with HOST_CANDIDATE_DUPLICATE_PORT, the value of res we keep when leaving the loop is randomly the one of the last iteration of the loop. CANT_CREATE_SOCKET still happens when trying to create an udp bsd socket with the same address and port than one of another component, so it is also a case of duplicate port in fact. To be homogeneous, we add a gerror for nice_udp_bsd_socket_new(), like we did in nice_tcp_passive_socket_new(), and we can catch the same G_IO_ERROR_ADDRESS_IN_USE there too, when failing to get free available udp ports. This patch is a complement to merge request !158
2020-08-18agent: Actually fail gathering on UDP port unavailabilityOlivier Crête2-4/+5
This will make it fail if either our test of UDP port clash fails or if the kernel rejects the new socket because there is a port clash. Also include a unit test for this.
2020-08-04Use g_alloca instead of g_malloc_n in socket_send_messagesLorenzo Miniero1-2/+1
2020-08-04Changed type of variable to signedLorenzo Miniero1-1/+1
2020-08-04Fixed wrong return value in socket_send_messages for n_messages=1Lorenzo Miniero1-0/+2
2020-08-04Refactored UDP socket_send_messages to use g_socket_send_messagesLorenzo Miniero1-35/+27
2020-05-22Remove autotools buildTim-Philipp Müller1-45/+0
Remove dist check on the CI, since it doesn't really add anything in the Meson case (tarball is based on files checked into git and srcdir != builddir).
2020-05-05Use g_assert_cmp.int() to get better debug logs on crashOlivier Crête3-5/+5
2020-03-02conncheck: refactor local and remote candidates validationFabrice Bellet2-0/+11
The same code to get and validate local and remote candidates from an incoming stun is shared between regular inbound stun, early checks replay, and partially in the local peer-reflexive discovery function. The selection of the matching local and remote candidate from an incoming stun sometimes requires more information than just the local socket, and the sender address and port. It happens more frequently when the port range is reduced, and when the conncheck handles both tcp and udp candidates. To help to disambiguate such situations, we add supplementary checks when two candidates in the list have the same address and and port number: * the type of the socket must compatible with the candidate transport. A socket for a tcp candidate may be active of passive, but also of type "tcp-bsd" when the parent active or passive socket is replaced after a bind() or accept(). It gives several cases. * the remote candidate transport and the local candidate transport must be compatible
2020-02-12udp-bsd: Check all return valueOlivier Crête1-4/+10
Errors found by coverity
2020-02-12udp-udp: Make coverity happy by giving it the whole unionOlivier Crête1-4/+4
2019-07-28udp-bsd: Use sockaddr_storage union to ensure big enough socketOlivier Crête1-5/+8
The IPv6 struct sockaddr variant is bigger than the IPv4 one, so use the storage struct to ensure that the size is big enough.
2019-07-19udp-bsd: log source and destination addresses on GSocket send errorJakub Adam1-4/+24
2019-07-04tcp-bsd: fix a heap-use-after-freeFabrice Bellet1-1/+3
2019-07-04socket: fix a heap use-after-free on the send queueFabrice Bellet1-6/+6
2019-06-05Assign source out of the for loopalex1-1/+2
2019-06-05Fix regression introduced by ↵alex1-0/+1
https://gitlab.freedesktop.org/libnice/libnice/commit/da41258a21102f63ec5d5b2dc20d303f772eb195. Fix #64.
2019-01-22turn: Replace magic numbers with defineOlivier Crête1-14/+16
2019-01-04udp-turn: Avoid potential integer overflowJakub Adam1-2/+2
2019-01-04udp-turn: Fix unaligned memory access on ARMJakub Adam1-2/+2
2018-12-27Makefiles: Add meson.build files to tarballOlivier Crête1-1/+1
2018-12-18udp-bsd: Fix recv with small buffer on WindowsJakub Adam1-2/+4
The underlying GSocket implementation on Windows returns an error when the user-provided buffer isn't large enough to fit the whole datagram received on a message-oriented socket. When this occurs, in order to preserve identical behavior of udp-bsd NiceSocket across platforms, we have to mute the error and set the received message length to the size of the provided NiceInputMessage. Any excess portion of the message gets discarded. Fixed udp-bsd test on Windows. GLib 2.48 is required in order to use G_IO_ERROR_MESSAGE_TOO_LARGE.
2018-12-14Fix build with MSVCNirbheek Chauhan3-0/+3
Tested inside Cerbero with VS 2017
2018-12-14Add support for Meson build systemTim-Philipp Müller1-0/+18
2018-11-21tcp-passive: Clear connection on child closingOlivier Crête4-0/+32
If this isn't done, then there may be invalid points left inside the passive socket which could be used and cause a crash. Fixes #33
2018-11-20tcp-bsd: Restore global locksJakub Adam1-7/+9
Avoids race between socket_send_more() and socket_close() leading either to crash on use of freed NiceSocket, or abort upon attempting to g_mutex_clear() a locked mutex. Akin to what d1611c0c0ba6c5bce500b96a8f61de4fe5f144e9 did to udp-turn.
2018-11-19udp-turn: Create locked version of realm&nonce cache functionOlivier Crête1-6/+13
To be able to call it from a context that is already locked.
2018-11-16udp-bsd: Protect the GSocketAddress cache with a mutexOlivier Crête1-8/+22
2018-10-31udp-turn: handle multiple RFC4571 frames received in a TCP-TURN messageJakub Adam1-1/+87
There might be multiple RFC4571-framed messages (or fragments thereof) within a single TCP-TURN message. Make sure each NiceInputMessage passed by the user into socket_recv_messages() gets exactly one RFC4571 frame, or remains empty if there aren't any messages to receive. We should keep any data that doesn't fit into the user buffers for the next time socket_recv_messages() gets called with the socket.
2018-10-31udp-turn: don't re-iterate incoming TURN control messagesJakub Adam1-9/+4
After being parsed, a TURN control message turns into a NiceInputMessage with zero length. Such message doesn't increment the iteration counter i and so is re-processed in the next iteration, which detects right away that message->length == 0 and continues to the next element in recv_messages. Thus, n_valid_messages variable serves no real purpose and to achieve the same result we can simply increment the iteration counter after each message.
2018-10-31udp-turn: Start function with lock instead of unlockOlivier Crête1-1/+1
2018-10-28udp-turn: Restore global locksOlivier Crête1-17/+119
The socket abstraction not being reference counted, we need a global lock for them in the short term.
2018-10-28udp-turn: Rename misleading function, it's a timeoutOlivier Crête1-3/+3
It's not locked in any way.
2018-10-28udp-turn: Factor our SendRequest destructionOlivier Crête1-27/+15
2018-10-28udp-turn: Restore synchronized seconds timeoutOlivier Crête1-6/+23
2018-10-28Use per-agent locks and GWeakRefs in callbacks from timeout sourcesJuan Navarro2-77/+27
Work on libnice's bug #1 in Gitlab. This work is composed of multiple merged parts: - "Global lock contention removed" Phabricator D1900: https://phabricator.freedesktop.org/D1900 By @nifigase Opened in GitLab as Merge Request !12 - "agent: properly handle NiceAgent ref in callbacks from timeout sources" Phabricator D1898: https://phabricator.freedesktop.org/D1898 By @mparis This patch was itself based upon a previous version of the work done in D1900. After the switch of hosting, it got lost. On top of these, additions to follow some review comments from @ocrete: - https://phabricator.freedesktop.org/D1900#40412 - https://phabricator.freedesktop.org/D1898#39332
2018-06-18Fix queue_clear replaced by queue_free errorNicolas Dufresne1-1/+2
There was two cases where instead of freeing the queue, we actually clear the queue so it's ready for reused. Notably in nice_socket_free_send_queue(), a missed name function and nicesrc element state change. This regression was introduced by: fa783b1dd727a6ee2b99a111ca24790ae850c2f7
2018-06-12Fix cast-function-type warning introduced in GCC 8Nicolas Dufresne4-17/+11
This is new warning introduced with GCC 8. This is being fixed by using appropriate function, like g_queue_free_full/g_list_free_full or by casting to GCallback before casting to the target function signature. Closes: #46
2017-04-04udp-turn: Add some const to internal APIsOlivier Crête2-8/+9
2017-04-04Make clang-analyzer happyOlivier Crête1-3/+2
Various little things, none of which should make a functional difference.
2017-04-03Version 0.1.140.1.14Olivier Crête1-1/+1
2017-04-03stun: Use unions fix alignment issuesOlivier Crête1-4/+7
This makes clang happy.