2011-01-09 21:48:33 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2010 by Juliusz Chroboczek
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-01-09 21:48:36 +00:00
|
|
|
#include <assert.h>
|
2012-12-05 17:29:46 +00:00
|
|
|
#include <string.h> /* memcmp (), memcpy (), memset () */
|
|
|
|
#include <stdlib.h> /* malloc (), free () */
|
2011-01-09 21:48:36 +00:00
|
|
|
|
2014-12-13 15:22:39 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <io.h> /* dup2 () */
|
|
|
|
#else
|
|
|
|
#include <unistd.h> /* dup2 () */
|
|
|
|
#endif
|
2011-03-24 21:49:42 +00:00
|
|
|
|
2011-01-09 21:48:51 +00:00
|
|
|
#include <event2/event.h>
|
2011-01-09 21:48:46 +00:00
|
|
|
|
2012-05-30 17:47:29 +00:00
|
|
|
#include <libutp/utp.h>
|
|
|
|
|
2011-01-09 21:48:33 +00:00
|
|
|
#include "transmission.h"
|
2013-01-25 23:34:20 +00:00
|
|
|
#include "log.h"
|
2011-01-09 21:48:33 +00:00
|
|
|
#include "net.h"
|
|
|
|
#include "session.h"
|
|
|
|
#include "tr-dht.h"
|
2011-02-18 00:23:47 +00:00
|
|
|
#include "tr-utp.h"
|
2011-01-09 21:48:06 +00:00
|
|
|
#include "tr-udp.h"
|
|
|
|
|
2011-02-18 00:43:47 +00:00
|
|
|
/* Since we use a single UDP socket in order to implement multiple
|
|
|
|
uTP sockets, try to set up huge buffers. */
|
|
|
|
|
|
|
|
#define RECV_BUFFER_SIZE (4 * 1024 * 1024)
|
|
|
|
#define SEND_BUFFER_SIZE (1 * 1024 * 1024)
|
|
|
|
#define SMALL_BUFFER_SIZE (32 * 1024)
|
|
|
|
|
|
|
|
static void
|
2015-03-18 07:34:26 +00:00
|
|
|
set_socket_buffers (tr_socket_t fd,
|
|
|
|
int large)
|
2011-02-18 00:43:47 +00:00
|
|
|
{
|
|
|
|
int size, rbuf, sbuf, rc;
|
2012-12-05 17:29:46 +00:00
|
|
|
socklen_t rbuf_len = sizeof (rbuf), sbuf_len = sizeof (sbuf);
|
2015-07-01 00:54:41 +00:00
|
|
|
char err_buf[512];
|
2011-02-18 00:43:47 +00:00
|
|
|
|
|
|
|
size = large ? RECV_BUFFER_SIZE : SMALL_BUFFER_SIZE;
|
2015-01-02 04:02:13 +00:00
|
|
|
rc = setsockopt (fd, SOL_SOCKET, SO_RCVBUF, (const void *) &size, sizeof (size));
|
2012-12-05 17:29:46 +00:00
|
|
|
if (rc < 0)
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedError ("UDP", "Failed to set receive buffer: %s",
|
2015-07-01 00:54:41 +00:00
|
|
|
tr_net_strerror (err_buf, sizeof (err_buf), sockerrno));
|
2011-02-18 00:43:47 +00:00
|
|
|
|
|
|
|
size = large ? SEND_BUFFER_SIZE : SMALL_BUFFER_SIZE;
|
2015-01-02 04:02:13 +00:00
|
|
|
rc = setsockopt (fd, SOL_SOCKET, SO_SNDBUF, (const void *) &size, sizeof (size));
|
2012-12-05 17:29:46 +00:00
|
|
|
if (rc < 0)
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedError ("UDP", "Failed to set send buffer: %s",
|
2015-07-01 00:54:41 +00:00
|
|
|
tr_net_strerror (err_buf, sizeof (err_buf), sockerrno));
|
2012-12-05 17:29:46 +00:00
|
|
|
|
|
|
|
if (large) {
|
2015-01-02 04:02:13 +00:00
|
|
|
rc = getsockopt (fd, SOL_SOCKET, SO_RCVBUF, (void *) &rbuf, &rbuf_len);
|
2012-12-05 17:29:46 +00:00
|
|
|
if (rc < 0)
|
2011-02-18 00:43:47 +00:00
|
|
|
rbuf = 0;
|
|
|
|
|
2015-01-02 04:02:13 +00:00
|
|
|
rc = getsockopt (fd, SOL_SOCKET, SO_SNDBUF, (void *) &sbuf, &sbuf_len);
|
2012-12-05 17:29:46 +00:00
|
|
|
if (rc < 0)
|
2011-02-18 00:43:47 +00:00
|
|
|
sbuf = 0;
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (rbuf < RECV_BUFFER_SIZE) {
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedError ("UDP", "Failed to set receive buffer: requested %d, got %d",
|
2011-02-18 00:43:47 +00:00
|
|
|
RECV_BUFFER_SIZE, rbuf);
|
|
|
|
#ifdef __linux__
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedInfo ("UDP",
|
2011-02-18 00:43:47 +00:00
|
|
|
"Please add the line "
|
|
|
|
"\"net.core.rmem_max = %d\" to /etc/sysctl.conf",
|
|
|
|
RECV_BUFFER_SIZE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (sbuf < SEND_BUFFER_SIZE) {
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedError ("UDP", "Failed to set send buffer: requested %d, got %d",
|
2011-02-18 00:43:47 +00:00
|
|
|
SEND_BUFFER_SIZE, sbuf);
|
|
|
|
#ifdef __linux__
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedInfo ("UDP",
|
2011-02-18 00:43:47 +00:00
|
|
|
"Please add the line "
|
|
|
|
"\"net.core.wmem_max = %d\" to /etc/sysctl.conf",
|
|
|
|
SEND_BUFFER_SIZE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_udpSetSocketBuffers (tr_session *session)
|
2011-02-18 00:43:47 +00:00
|
|
|
{
|
2012-12-05 17:29:46 +00:00
|
|
|
bool utp = tr_sessionIsUTPEnabled (session);
|
2015-03-18 07:34:26 +00:00
|
|
|
if (session->udp_socket != TR_BAD_SOCKET)
|
2012-12-05 17:29:46 +00:00
|
|
|
set_socket_buffers (session->udp_socket, utp);
|
2015-03-18 07:34:26 +00:00
|
|
|
if (session->udp6_socket != TR_BAD_SOCKET)
|
2012-12-05 17:29:46 +00:00
|
|
|
set_socket_buffers (session->udp6_socket, utp);
|
2011-02-18 00:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-09 21:48:36 +00:00
|
|
|
/* BEP-32 has a rather nice explanation of why we need to bind to one
|
|
|
|
IPv6 address, if I may say so myself. */
|
|
|
|
|
|
|
|
static void
|
2012-12-05 17:29:46 +00:00
|
|
|
rebind_ipv6 (tr_session *ss, bool force)
|
2011-01-09 21:48:36 +00:00
|
|
|
{
|
2011-03-22 15:19:54 +00:00
|
|
|
bool is_default;
|
2011-01-22 13:49:15 +00:00
|
|
|
const struct tr_address * public_addr;
|
2011-01-09 21:48:36 +00:00
|
|
|
struct sockaddr_in6 sin6;
|
2012-12-05 17:29:46 +00:00
|
|
|
const unsigned char *ipv6 = tr_globalIPv6 ();
|
2015-03-18 07:34:26 +00:00
|
|
|
tr_socket_t s = TR_BAD_SOCKET;
|
|
|
|
int rc;
|
2011-01-09 21:48:36 +00:00
|
|
|
int one = 1;
|
|
|
|
|
|
|
|
/* We currently have no way to enable or disable IPv6 after initialisation.
|
|
|
|
No way to fix that without some surgery to the DHT code itself. */
|
2015-03-18 07:34:26 +00:00
|
|
|
if (ipv6 == NULL || (!force && ss->udp6_socket == TR_BAD_SOCKET)) {
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp6_bound) {
|
|
|
|
free (ss->udp6_bound);
|
2011-01-09 21:48:36 +00:00
|
|
|
ss->udp6_bound = NULL;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp6_bound != NULL && memcmp (ipv6, ss->udp6_bound, 16) == 0)
|
2011-01-09 21:48:36 +00:00
|
|
|
return;
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
s = socket (PF_INET6, SOCK_DGRAM, 0);
|
2015-03-18 07:34:26 +00:00
|
|
|
if (s == TR_BAD_SOCKET)
|
2011-01-09 21:48:36 +00:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
#ifdef IPV6_V6ONLY
|
|
|
|
/* Since we always open an IPv4 socket on the same port, this
|
|
|
|
shouldn't matter. But I'm superstitious. */
|
2015-01-02 04:02:13 +00:00
|
|
|
setsockopt (s, IPPROTO_IPV6, IPV6_V6ONLY, (const void *) &one, sizeof (one));
|
2011-01-09 21:48:36 +00:00
|
|
|
#endif
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
memset (&sin6, 0, sizeof (sin6));
|
2011-01-09 21:48:36 +00:00
|
|
|
sin6.sin6_family = AF_INET6;
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ipv6)
|
|
|
|
memcpy (&sin6.sin6_addr, ipv6, 16);
|
|
|
|
sin6.sin6_port = htons (ss->udp_port);
|
|
|
|
public_addr = tr_sessionGetPublicAddress (ss, TR_AF_INET6, &is_default);
|
|
|
|
if (public_addr && !is_default)
|
2011-01-22 13:49:15 +00:00
|
|
|
sin6.sin6_addr = public_addr->addr.addr6;
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
rc = bind (s, (struct sockaddr*)&sin6, sizeof (sin6));
|
|
|
|
if (rc < 0)
|
2011-01-09 21:48:36 +00:00
|
|
|
goto fail;
|
|
|
|
|
2015-03-18 07:34:26 +00:00
|
|
|
if (ss->udp6_socket == TR_BAD_SOCKET) {
|
2011-01-09 21:48:36 +00:00
|
|
|
ss->udp6_socket = s;
|
|
|
|
} else {
|
2014-12-13 15:22:39 +00:00
|
|
|
/* FIXME: dup2 doesn't work for sockets on Windows */
|
2012-12-05 17:29:46 +00:00
|
|
|
rc = dup2 (s, ss->udp6_socket);
|
|
|
|
if (rc < 0)
|
2011-01-09 21:48:36 +00:00
|
|
|
goto fail;
|
2014-12-13 15:22:39 +00:00
|
|
|
tr_netCloseSocket (s);
|
2011-01-09 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp6_bound == NULL)
|
|
|
|
ss->udp6_bound = malloc (16);
|
|
|
|
if (ss->udp6_bound)
|
|
|
|
memcpy (ss->udp6_bound, ipv6, 16);
|
2011-01-09 21:48:36 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
/* Something went wrong. It's difficult to recover, so let's simply
|
|
|
|
set things up so that we try again next time. */
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedError ("UDP", "Couldn't rebind IPv6 socket");
|
2015-03-18 07:34:26 +00:00
|
|
|
if (s != TR_BAD_SOCKET)
|
2014-12-13 15:22:39 +00:00
|
|
|
tr_netCloseSocket (s);
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp6_bound) {
|
|
|
|
free (ss->udp6_bound);
|
2011-01-09 21:48:36 +00:00
|
|
|
ss->udp6_bound = NULL;
|
|
|
|
}
|
|
|
|
}
|
2011-01-09 21:48:33 +00:00
|
|
|
|
2011-01-09 21:48:46 +00:00
|
|
|
static void
|
2013-09-08 17:03:11 +00:00
|
|
|
event_callback (evutil_socket_t s, short type UNUSED, void *sv)
|
2011-01-09 21:48:46 +00:00
|
|
|
{
|
2011-04-27 05:29:05 +00:00
|
|
|
int rc;
|
|
|
|
socklen_t fromlen;
|
2011-04-27 05:03:10 +00:00
|
|
|
unsigned char buf[4096];
|
2011-01-09 21:48:46 +00:00
|
|
|
struct sockaddr_storage from;
|
2011-04-27 05:29:05 +00:00
|
|
|
tr_session *ss = sv;
|
2011-01-09 21:48:46 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
assert (tr_isSession (sv));
|
|
|
|
assert (type == EV_READ);
|
2011-01-09 21:48:46 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
fromlen = sizeof (from);
|
2015-01-02 04:02:13 +00:00
|
|
|
rc = recvfrom (s, (void *) buf, 4096 - 1, 0,
|
2012-12-05 17:29:46 +00:00
|
|
|
(struct sockaddr*)&from, &fromlen);
|
2011-04-24 19:12:28 +00:00
|
|
|
|
2011-04-28 02:51:07 +00:00
|
|
|
/* Since most packets we receive here are µTP, make quick inline
|
|
|
|
checks for the other protocols. The logic is as follows:
|
|
|
|
- all DHT packets start with 'd';
|
|
|
|
- all UDP tracker packets start with a 32-bit (!) "action", which
|
|
|
|
is between 0 and 3;
|
|
|
|
- the above cannot be µTP packets, since these start with a 4-bit
|
|
|
|
version number (1). */
|
2012-12-05 17:29:46 +00:00
|
|
|
if (rc > 0) {
|
|
|
|
if (buf[0] == 'd') {
|
|
|
|
if (tr_sessionAllowsDHT (ss)) {
|
2011-07-12 12:26:24 +00:00
|
|
|
buf[rc] = '\0'; /* required by the DHT code */
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_dhtCallback (buf, rc, (struct sockaddr*)&from, fromlen, sv);
|
2011-07-12 12:26:24 +00:00
|
|
|
}
|
2012-12-05 17:29:46 +00:00
|
|
|
} else if (rc >= 8 &&
|
|
|
|
buf[0] == 0 && buf[1] == 0 && buf[2] == 0 && buf[3] <= 3) {
|
|
|
|
rc = tau_handle_message (ss, buf, rc);
|
|
|
|
if (!rc)
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedDbg ("UDP", "Couldn't parse UDP tracker packet.");
|
2011-04-28 02:51:07 +00:00
|
|
|
} else {
|
2012-12-05 17:29:46 +00:00
|
|
|
if (tr_sessionIsUTPEnabled (ss)) {
|
|
|
|
rc = tr_utpPacket (buf, rc, (struct sockaddr*)&from, fromlen, ss);
|
|
|
|
if (!rc)
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedDbg ("UDP", "Unexpected UDP packet");
|
2011-07-12 12:26:24 +00:00
|
|
|
}
|
2011-03-04 21:38:04 +00:00
|
|
|
}
|
2011-01-09 21:48:46 +00:00
|
|
|
}
|
2011-03-04 23:26:10 +00:00
|
|
|
}
|
2011-01-09 21:48:46 +00:00
|
|
|
|
2011-01-09 21:48:33 +00:00
|
|
|
void
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_udpInit (tr_session *ss)
|
2011-01-09 21:48:33 +00:00
|
|
|
{
|
2011-03-22 15:19:54 +00:00
|
|
|
bool is_default;
|
2011-01-22 20:43:36 +00:00
|
|
|
const struct tr_address * public_addr;
|
2011-01-09 21:48:36 +00:00
|
|
|
struct sockaddr_in sin;
|
|
|
|
int rc;
|
|
|
|
|
2015-03-18 07:34:26 +00:00
|
|
|
assert (ss->udp_socket == TR_BAD_SOCKET);
|
|
|
|
assert (ss->udp6_socket == TR_BAD_SOCKET);
|
2011-01-09 21:48:36 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
ss->udp_port = tr_sessionGetPeerPort (ss);
|
|
|
|
if (ss->udp_port <= 0)
|
2011-01-09 21:48:36 +00:00
|
|
|
return;
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
ss->udp_socket = socket (PF_INET, SOCK_DGRAM, 0);
|
2015-03-18 07:34:26 +00:00
|
|
|
if (ss->udp_socket == TR_BAD_SOCKET) {
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedError ("UDP", "Couldn't create IPv4 socket");
|
2011-01-09 21:48:36 +00:00
|
|
|
goto ipv6;
|
|
|
|
}
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
memset (&sin, 0, sizeof (sin));
|
2011-01-09 21:48:36 +00:00
|
|
|
sin.sin_family = AF_INET;
|
2012-12-05 17:29:46 +00:00
|
|
|
public_addr = tr_sessionGetPublicAddress (ss, TR_AF_INET, &is_default);
|
|
|
|
if (public_addr && !is_default)
|
|
|
|
memcpy (&sin.sin_addr, &public_addr->addr.addr4, sizeof (struct in_addr));
|
|
|
|
sin.sin_port = htons (ss->udp_port);
|
|
|
|
rc = bind (ss->udp_socket, (struct sockaddr*)&sin, sizeof (sin));
|
|
|
|
if (rc < 0) {
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedError ("UDP", "Couldn't bind IPv4 socket");
|
2014-12-13 15:22:39 +00:00
|
|
|
tr_netCloseSocket (ss->udp_socket);
|
2015-03-18 07:34:26 +00:00
|
|
|
ss->udp_socket = TR_BAD_SOCKET;
|
2011-01-09 21:48:36 +00:00
|
|
|
goto ipv6;
|
|
|
|
}
|
2011-01-09 21:48:51 +00:00
|
|
|
ss->udp_event =
|
2012-12-05 17:29:46 +00:00
|
|
|
event_new (ss->event_base, ss->udp_socket, EV_READ | EV_PERSIST,
|
2011-01-09 21:48:51 +00:00
|
|
|
event_callback, ss);
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp_event == NULL)
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedError ("UDP", "Couldn't allocate IPv4 event");
|
2011-01-09 21:48:46 +00:00
|
|
|
|
2011-01-09 21:48:36 +00:00
|
|
|
ipv6:
|
2012-12-05 17:29:46 +00:00
|
|
|
if (tr_globalIPv6 ())
|
|
|
|
rebind_ipv6 (ss, true);
|
2015-03-18 07:34:26 +00:00
|
|
|
if (ss->udp6_socket != TR_BAD_SOCKET) {
|
2011-01-09 21:48:51 +00:00
|
|
|
ss->udp6_event =
|
2012-12-05 17:29:46 +00:00
|
|
|
event_new (ss->event_base, ss->udp6_socket, EV_READ | EV_PERSIST,
|
2011-01-09 21:48:46 +00:00
|
|
|
event_callback, ss);
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp6_event == NULL)
|
2013-01-25 23:34:20 +00:00
|
|
|
tr_logAddNamedError ("UDP", "Couldn't allocate IPv6 event");
|
2011-01-09 21:48:46 +00:00
|
|
|
}
|
2011-01-09 21:48:36 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_udpSetSocketBuffers (ss);
|
2011-02-18 00:43:47 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->isDHTEnabled)
|
|
|
|
tr_dhtInit (ss);
|
2011-01-09 21:48:46 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp_event)
|
|
|
|
event_add (ss->udp_event, NULL);
|
|
|
|
if (ss->udp6_event)
|
|
|
|
event_add (ss->udp6_event, NULL);
|
2011-01-09 21:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_udpUninit (tr_session *ss)
|
2011-01-09 21:48:33 +00:00
|
|
|
{
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_dhtUninit (ss);
|
2011-07-12 12:26:24 +00:00
|
|
|
|
2015-03-18 07:34:26 +00:00
|
|
|
if (ss->udp_socket != TR_BAD_SOCKET) {
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_netCloseSocket (ss->udp_socket);
|
2015-03-18 07:34:26 +00:00
|
|
|
ss->udp_socket = TR_BAD_SOCKET;
|
2011-01-09 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp_event) {
|
|
|
|
event_free (ss->udp_event);
|
2011-01-09 21:48:46 +00:00
|
|
|
ss->udp_event = NULL;
|
|
|
|
}
|
|
|
|
|
2015-03-18 07:34:26 +00:00
|
|
|
if (ss->udp6_socket != TR_BAD_SOCKET) {
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_netCloseSocket (ss->udp6_socket);
|
2015-03-18 07:34:26 +00:00
|
|
|
ss->udp6_socket = TR_BAD_SOCKET;
|
2011-01-09 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp6_event) {
|
|
|
|
event_free (ss->udp6_event);
|
2011-01-09 21:48:46 +00:00
|
|
|
ss->udp6_event = NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (ss->udp6_bound) {
|
|
|
|
free (ss->udp6_bound);
|
2011-01-09 21:48:36 +00:00
|
|
|
ss->udp6_bound = NULL;
|
|
|
|
}
|
2011-01-09 21:48:33 +00:00
|
|
|
}
|