[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r4267: Update the bundled version of miniupnpc to 1.4.20100418. Sti (in vidalia/trunk: . src/miniupnpc)



Author: edmanm
Date: 2010-04-18 23:08:46 -0400 (Sun, 18 Apr 2010)
New Revision: 4267

Modified:
   vidalia/trunk/CHANGELOG
   vidalia/trunk/src/miniupnpc/minisoap.c
   vidalia/trunk/src/miniupnpc/minisoap.h
   vidalia/trunk/src/miniupnpc/miniupnpc.c
   vidalia/trunk/src/miniupnpc/miniwget.c
Log:

Update the bundled version of miniupnpc to 1.4.20100418. Still busted on
OS X 10.4.


Modified: vidalia/trunk/CHANGELOG
===================================================================
--- vidalia/trunk/CHANGELOG	2010-04-17 21:45:21 UTC (rev 4266)
+++ vidalia/trunk/CHANGELOG	2010-04-19 03:08:46 UTC (rev 4267)
@@ -1,5 +1,6 @@
 0.2.9   xx-xxx-2010
   o Add Danish, Brazilian Portguese and Vietnamese translations.
+  o Update the bundled version of miniupnpc to 1.4.20100418.
 
 
 0.2.8   11-Apr-2010

Modified: vidalia/trunk/src/miniupnpc/minisoap.c
===================================================================
--- vidalia/trunk/src/miniupnpc/minisoap.c	2010-04-17 21:45:21 UTC (rev 4266)
+++ vidalia/trunk/src/miniupnpc/minisoap.c	2010-04-19 03:08:46 UTC (rev 4267)
@@ -1,4 +1,4 @@
-/* $Id: minisoap.c,v 1.18 2009/12/04 11:29:18 nanard Exp $ */
+/* $Id: minisoap.c,v 1.19 2010/04/12 20:39:41 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
  * Copyright (c) 2005-2009 Thomas Bernard
@@ -75,7 +75,8 @@
 				   const char * host,
 				   unsigned short port,
 				   const char * action,
-				   const char * body)
+				   const char * body,
+				   const char * httpversion)
 {
 	int bodysize;
 	char headerbuf[512];
@@ -93,8 +94,7 @@
 	if(port != 80)
 		snprintf(portstr, sizeof(portstr), ":%hu", port);
 	headerssize = snprintf(headerbuf, sizeof(headerbuf),
-/*                       "POST %s HTTP/1.1\r\n" */
-                       "POST %s HTTP/1.0\r\n"
+                       "POST %s HTTP/%s\r\n"
 	                   "Host: %s%s\r\n"
 					   "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n"
 	                   "Content-Length: %d\r\n"
@@ -104,7 +104,7 @@
 					   "Cache-Control: no-cache\r\n"	/* ??? */
 					   "Pragma: no-cache\r\n"
 					   "\r\n",
-					   url, host, portstr, bodysize, action);
+					   url, httpversion, host, portstr, bodysize, action);
 #ifdef DEBUG
 	printf("SOAP request : headersize=%d bodysize=%d\n",
 	       headerssize, bodysize);

Modified: vidalia/trunk/src/miniupnpc/minisoap.h
===================================================================
--- vidalia/trunk/src/miniupnpc/minisoap.h	2010-04-17 21:45:21 UTC (rev 4266)
+++ vidalia/trunk/src/miniupnpc/minisoap.h	2010-04-19 03:08:46 UTC (rev 4267)
@@ -1,4 +1,4 @@
-/* $Id: minisoap.h,v 1.3 2006/11/19 22:32:34 nanard Exp $ */
+/* $Id: minisoap.h,v 1.4 2010/04/12 20:39:41 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
  * Copyright (c) 2005 Thomas Bernard
@@ -9,7 +9,7 @@
 
 /*int httpWrite(int, const char *, int, const char *);*/
 int soapPostSubmit(int, const char *, const char *, unsigned short,
-				   const char *, const char *);
+		   const char *, const char *, const char *);
 
 #endif
 

Modified: vidalia/trunk/src/miniupnpc/miniupnpc.c
===================================================================
--- vidalia/trunk/src/miniupnpc/miniupnpc.c	2010-04-17 21:45:21 UTC (rev 4266)
+++ vidalia/trunk/src/miniupnpc/miniupnpc.c	2010-04-19 03:08:46 UTC (rev 4267)
@@ -1,4 +1,4 @@
-/* $Id: miniupnpc.c,v 1.78 2010/04/05 20:36:59 nanard Exp $ */
+/* $Id: miniupnpc.c,v 1.81 2010/04/17 22:07:59 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas BERNARD
  * copyright (c) 2005-2010 Thomas Bernard
@@ -16,9 +16,6 @@
 #endif
 #endif
 
-#ifdef __APPLE__
-#define _DARWIN_C_SOURCE
-#endif
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -28,7 +25,7 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #include <io.h>
-/*#include <IPHlpApi.h>*/
+#include <IPHlpApi.h>
 #define snprintf _snprintf
 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
 #define strncasecmp _memicmp
@@ -172,14 +169,14 @@
 	}
 }
 
-/* simpleUPnPcommand :
+/* simpleUPnPcommand2 :
  * not so simple !
  * return values :
  *   0 - OK
  *  -1 - error */
-int simpleUPnPcommand(int s, const char * url, const char * service,
-                      const char * action, struct UPNParg * args,
-                      char * buffer, int * bufsize)
+static int simpleUPnPcommand2(int s, const char * url, const char * service,
+		       const char * action, struct UPNParg * args,
+		       char * buffer, int * bufsize, const char * httpversion)
 {
 	char hostname[MAXHOSTNAMELEN+1];
 	unsigned short port = 0;
@@ -267,7 +264,7 @@
 		}
 	}
 
-	n = soapPostSubmit(s, path, hostname, port, soapact, soapbody);
+	n = soapPostSubmit(s, path, hostname, port, soapact, soapbody, httpversion);
 	if(n<=0) {
 #ifdef DEBUG
 		printf("Error sending SOAP request\n");
@@ -300,6 +297,30 @@
 	return 0;
 }
 
+/* simpleUPnPcommand :
+ * not so simple !
+ * return values :
+ *   0 - OK
+ *  -1 - error */
+int simpleUPnPcommand(int s, const char * url, const char * service,
+		       const char * action, struct UPNParg * args,
+		       char * buffer, int * bufsize)
+{
+	int result;
+	int origbufsize = *bufsize;
+
+	result = simpleUPnPcommand2(s, url, service, action, args, buffer, bufsize, "1.0");
+	if (result < 0 || *bufsize == 0)
+	{
+#if DEBUG
+	    printf("Error or no result from SOAP request; retrying with HTTP/1.1\n");
+#endif
+		*bufsize = origbufsize;
+		result = simpleUPnPcommand2(s, url, service, action, args, buffer, bufsize, "1.1");
+	}
+	return result;
+}
+
 /* parseMSEARCHReply()
  * the last 4 arguments are filled during the parsing :
  *    - location/locationsize : "location:" field of the SSDP reply packet
@@ -400,7 +421,7 @@
 	int rv;
 	struct addrinfo hints, *servinfo, *p;
 #ifdef WIN32
-	/*MIB_IPFORWARDROW ip_forward;*/
+	MIB_IPFORWARDROW ip_forward;
 #endif
 
 #if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
@@ -453,41 +474,60 @@
 #ifdef WIN32
 /* This code could help us to use the right Network interface for 
  * SSDP multicast traffic */
-/* TODO : Get IP associated with the index given in the ip_forward struct
+/* Get IP associated with the index given in the ip_forward struct
  * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */
- /*
 	if(GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) == NO_ERROR) {
 		DWORD dwRetVal = 0;
 		PMIB_IPADDRTABLE pIPAddrTable;
-    DWORD dwSize = 0;
-    IN_ADDR IPAddr;
-    int i;
-    printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop);
-    pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE));
-    if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
-	    free(pIPAddrTable);
-      pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize);
-    }
-    if(pIPAddrTable) {
-    	dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 );
-    	printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries);
-    	for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) {
-        printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex);
-        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr;
-        printf("\tIP Address[%d]:     \t%s\n", i, inet_ntoa(IPAddr) );
-        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask;
-        printf("\tSubnet Mask[%d]:    \t%s\n", i, inet_ntoa(IPAddr) );
-        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr;
-        printf("\tBroadCast[%d]:      \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr);
-        printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize);
-        printf("\tType and State[%d]:", i);
-        printf("\n");
-    	}
+		DWORD dwSize = 0;
+#ifdef DEBUG
+		IN_ADDR IPAddr;
+#endif
+		int i;
+#ifdef DEBUG
+		printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop);
+#endif
+		pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE));
+		if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
 			free(pIPAddrTable);
-    	pIPAddrTable = NULL;
-    }
+			pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize);
+		}
+		if(pIPAddrTable) {
+			dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 );
+#ifdef DEBUG
+			printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries);
+#endif
+			for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) {
+#ifdef DEBUG
+				printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex);
+				IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr;
+				printf("\tIP Address[%d]:     \t%s\n", i, inet_ntoa(IPAddr) );
+				IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask;
+				printf("\tSubnet Mask[%d]:    \t%s\n", i, inet_ntoa(IPAddr) );
+				IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr;
+				printf("\tBroadCast[%d]:      \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr);
+				printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize);
+				printf("\tType and State[%d]:", i);
+				printf("\n");
+#endif
+				if (pIPAddrTable->table[i].dwIndex == ip_forward.dwForwardIfIndex) {
+					/* Set the address of this interface to be used */
+					struct in_addr mc_if;
+					memset(&mc_if, 0, sizeof(mc_if));
+					mc_if.s_addr = pIPAddrTable->table[i].dwAddr;
+					if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0) {
+						PRINT_SOCKET_ERROR("setsockopt");
+					}
+					((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = pIPAddrTable->table[i].dwAddr;
+#ifndef DEBUG
+					break;
+#endif
+				}
+			}
+			free(pIPAddrTable);
+			pIPAddrTable = NULL;
+		}
 	}
-*/
 #endif
 
 #ifdef WIN32
@@ -589,8 +629,21 @@
 		parseMSEARCHReply(bufr, n, &descURL, &urlsize, &st, &stsize);
 		if(st&&descURL)
 		{
-			/*printf("M-SEARCH Reply:\nST: %.*s\nLocation: %.*s\n",
-			       stsize, st, urlsize, descURL); */
+#ifdef DEBUG
+			printf("M-SEARCH Reply:\nST: %.*s\nLocation: %.*s\n",
+			       stsize, st, urlsize, descURL);
+#endif
+			for(tmp=devlist; tmp; tmp = tmp->pNext) {
+				if(memcmp(tmp->descURL, descURL, urlsize) == 0 &&
+				   tmp->descURL[urlsize] == '\0' &&
+				   memcmp(tmp->st, st, stsize) == 0 &&
+				   tmp->st[stsize] == '\0')
+					break;
+			}
+			/* at the exit of the loop above, tmp is null if
+			 * no duplicate device was found */
+			if(tmp)
+				continue;
 			tmp = (struct UPNPDev *)malloc(sizeof(struct UPNPDev)+urlsize+stsize);
 			tmp->pNext = devlist;
 			tmp->descURL = tmp->buffer;

Modified: vidalia/trunk/src/miniupnpc/miniwget.c
===================================================================
--- vidalia/trunk/src/miniupnpc/miniwget.c	2010-04-17 21:45:21 UTC (rev 4266)
+++ vidalia/trunk/src/miniupnpc/miniwget.c	2010-04-19 03:08:46 UTC (rev 4267)
@@ -1,4 +1,4 @@
-/* $Id: miniwget.c,v 1.36 2010/04/05 12:34:05 nanard Exp $ */
+/* $Id: miniwget.c,v 1.37 2010/04/12 20:39:42 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
  * Copyright (c) 2005-2010 Thomas Bernard
@@ -41,13 +41,13 @@
 #include "miniwget.h"
 #include "connecthostport.h"
 
-/* miniwget2() :
+/* miniwget3() :
  * do all the work.
  * Return NULL if something failed. */
 static void *
-miniwget2(const char * url, const char * host,
+miniwget3(const char * url, const char * host,
 		  unsigned short port, const char * path,
-		  int * size, char * addr_str, int addr_str_len)
+		  int * size, char * addr_str, int addr_str_len, const char * httpversion)
 {
 	char buf[2048];
     int s;
@@ -103,13 +103,13 @@
 	}
 
 	len = snprintf(buf, sizeof(buf),
-                 "GET %s HTTP/1.0\r\n"
+                 "GET %s HTTP/%s\r\n"
 			     "Host: %s:%d\r\n"
 				 "Connection: Close\r\n"
 				 "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n"
 
 				 "\r\n",
-		    path, host, port);
+			   path, httpversion, host, port);
 	sent = 0;
 	/* sending the HTTP request */
 	while(sent < len)
@@ -176,6 +176,30 @@
 	}
 }
 
+/* miniwget2() :
+ * Call miniwget3(); retry with HTTP/1.1 if 1.0 fails. */
+static void *
+miniwget2(const char * url, const char * host,
+		  unsigned short port, const char * path,
+		  int * size, char * addr_str, int addr_str_len)
+{
+	char * respbuffer;
+
+	respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.0");
+	if (*size == 0)
+	{
+#ifdef DEBUG
+		printf("Retrying with HTTP/1.1\n");
+#endif
+		free(respbuffer);
+		respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.1");
+	}
+	return respbuffer;
+}
+
+
+
+
 /* parseURL()
  * arguments :
  *   url :		source string not modified