summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-01-25 19:16:43 (GMT)
committerSwift Review <review@swift.im>2015-02-09 15:46:21 (GMT)
commit415e2a0e26af19e00b7cafb58be72909ae1d8212 (patch)
tree945996fd950a3800e17a7897efb45d915b2537fc /3rdParty/LibMiniUPnPc/src/miniupnpc/receivedata.c
parent1c64e31945e80e927f87a0a94ec5ce0e00c40a7f (diff)
downloadswift-415e2a0e26af19e00b7cafb58be72909ae1d8212.zip
swift-415e2a0e26af19e00b7cafb58be72909ae1d8212.tar.bz2
Update libminiupnpc to version 1.9
Fixes to our build of libminiupnpc: * do not build minissdpc.c on windows * if size of ip_mreqn is not defined, add -DNEED_STRUCT_IP_MREQN to the CFLAGS Test-Information: Verified it still builds. Change-Id: Idd3e19d6302cccc95fff0a01540b9abc1bc91e9e
Diffstat (limited to '3rdParty/LibMiniUPnPc/src/miniupnpc/receivedata.c')
-rw-r--r--3rdParty/LibMiniUPnPc/src/miniupnpc/receivedata.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/3rdParty/LibMiniUPnPc/src/miniupnpc/receivedata.c b/3rdParty/LibMiniUPnPc/src/miniupnpc/receivedata.c
index a1eadfc..ffbfbea 100644
--- a/3rdParty/LibMiniUPnPc/src/miniupnpc/receivedata.c
+++ b/3rdParty/LibMiniUPnPc/src/miniupnpc/receivedata.c
@@ -1,12 +1,13 @@
-/* $Id: receivedata.c,v 1.1 2011/04/11 08:21:47 nanard Exp $ */
+/* $Id: receivedata.c,v 1.5 2013/10/07 09:48:36 nanard Exp $ */
/* Project : miniupnp
+ * Website : http://miniupnp.free.fr/
* Author : Thomas Bernard
- * Copyright (c) 2011 Thomas Bernard
+ * Copyright (c) 2011-2012 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution. */
#include <stdio.h>
-#ifdef WIN32
+#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#else
@@ -17,6 +18,7 @@
#include <sys/select.h>
#endif /* #else defined(__amigaos__) && !defined(__amigaos4__) */
#include <sys/socket.h>
+#include <netinet/in.h>
#if !defined(__amigaos__) && !defined(__amigaos4__)
#include <poll.h>
#endif
@@ -24,7 +26,7 @@
#define MINIUPNPC_IGNORE_EINTR
#endif
-#ifdef WIN32
+#ifdef _WIN32
#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
#else
#define PRINT_SOCKET_ERROR(x) perror(x)
@@ -33,10 +35,21 @@
#include "receivedata.h"
int
-receivedata(int socket, char * data, int length, int timeout)
+receivedata(int socket,
+ char * data, int length,
+ int timeout, unsigned int * scope_id)
{
+#if MINIUPNPC_GET_SRC_ADDR
+#ifdef DEBUG
+ /* to shut up valgrind about uninit value */
+ struct sockaddr_storage src_addr = {0};
+#else
+ struct sockaddr_storage src_addr;
+#endif
+ socklen_t src_addr_len = sizeof(src_addr);
+#endif
int n;
-#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
+#if !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
/* using poll */
struct pollfd fds[1]; /* for the poll */
#ifdef MINIUPNPC_IGNORE_EINTR
@@ -55,8 +68,8 @@ receivedata(int socket, char * data, int length, int timeout)
/* timeout */
return 0;
}
-#else /* !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */
- /* using select under WIN32 and amigaos */
+#else /* !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */
+ /* using select under _WIN32 and amigaos */
fd_set socketSet;
TIMEVAL timeval;
FD_ZERO(&socketSet);
@@ -69,12 +82,27 @@ receivedata(int socket, char * data, int length, int timeout)
return -1;
} else if(n == 0) {
return 0;
- }
+ }
#endif
+#if MINIUPNPC_GET_SRC_ADDR
+ n = recvfrom(socket, data, length, 0,
+ (struct sockaddr *)&src_addr, &src_addr_len);
+#else
n = recv(socket, data, length, 0);
+#endif
if(n<0) {
PRINT_SOCKET_ERROR("recv");
}
+#if MINIUPNPC_GET_SRC_ADDR
+ if (src_addr.ss_family == AF_INET6) {
+ const struct sockaddr_in6 * src_addr6 = (struct sockaddr_in6 *)&src_addr;
+#ifdef DEBUG
+ printf("scope_id=%u\n", src_addr6->sin6_scope_id);
+#endif
+ if(scope_id)
+ *scope_id = src_addr6->sin6_scope_id;
+ }
+#endif
return n;
}