mirror of
https://github.com/transmission/transmission
synced 2025-03-03 02:05:19 +00:00
update miniupnp to 20100412
This commit is contained in:
parent
e115a0a2ad
commit
c1f73b89d7
5 changed files with 90 additions and 26 deletions
9
third-party/miniupnp/Changelog.txt
vendored
9
third-party/miniupnp/Changelog.txt
vendored
|
@ -1,6 +1,13 @@
|
|||
$Id: Changelog.txt,v 1.111 2010/04/05 20:36:59 nanard Exp $
|
||||
$Id: Changelog.txt,v 1.113 2010/04/12 20:39:40 nanard Exp $
|
||||
miniUPnP client Changelog.
|
||||
|
||||
2010/04/12:
|
||||
Retrying with HTTP/1.1 if HTTP/1.0 failed. see
|
||||
http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1703
|
||||
|
||||
2010/04/07:
|
||||
avoid returning duplicates in upnpDiscover()
|
||||
|
||||
2010/04/05:
|
||||
Create a connecthostport.h/.c with connecthostport() function
|
||||
and use it in miniwget and miniupnpc.
|
||||
|
|
10
third-party/miniupnp/minisoap.c
vendored
10
third-party/miniupnp/minisoap.c
vendored
|
@ -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 @@ int soapPostSubmit(int fd,
|
|||
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 @@ int soapPostSubmit(int fd,
|
|||
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 @@ int soapPostSubmit(int fd,
|
|||
"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);
|
||||
|
|
4
third-party/miniupnp/minisoap.h
vendored
4
third-party/miniupnp/minisoap.h
vendored
|
@ -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
|
||||
|
||||
|
|
57
third-party/miniupnp/miniupnpc.c
vendored
57
third-party/miniupnp/miniupnpc.c
vendored
|
@ -1,4 +1,4 @@
|
|||
/* $Id: miniupnpc.c,v 1.78 2010/04/05 20:36:59 nanard Exp $ */
|
||||
/* $Id: miniupnpc.c,v 1.80 2010/04/12 20:39:41 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* Author : Thomas BERNARD
|
||||
* copyright (c) 2005-2010 Thomas Bernard
|
||||
|
@ -16,10 +16,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define _DARWIN_C_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -172,14 +168,14 @@ getContentLengthAndHeaderLength(char * p, int n,
|
|||
}
|
||||
}
|
||||
|
||||
/* 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 +263,7 @@ int simpleUPnPcommand(int s, const char * url, const char * service,
|
|||
}
|
||||
}
|
||||
|
||||
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 +296,30 @@ int simpleUPnPcommand(int s, const char * url, const char * service,
|
|||
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
|
||||
|
@ -589,8 +609,21 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
|
|||
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;
|
||||
|
|
36
third-party/miniupnp/miniwget.c
vendored
36
third-party/miniupnp/miniwget.c
vendored
|
@ -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 @@ miniwget2(const char * url, const char * host,
|
|||
}
|
||||
|
||||
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(const char * url, const char * host,
|
|||
}
|
||||
}
|
||||
|
||||
/* 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
|
||||
|
|
Loading…
Reference in a new issue