~ubuntu-branches/ubuntu/lucid/transmission/lucid

« back to all changes in this revision

Viewing changes to third-party/miniupnp/miniupnpc.c

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda, Krzysztof Klimonda, Chris Coulson
  • Date: 2010-03-03 02:55:26 UTC
  • mfrom: (1.1.34 upstream) (2.1.17 sid)
  • Revision ID: james.westby@ubuntu.com-20100303025526-qcjmpnlvk9jv3y5o
Tags: 1.92-0ubuntu1
[ Krzysztof Klimonda ]
* New upstream release (LP: #538034), rebased on debian testing.
  Remaining changes:
  - debian/control:
    + Added replaces & provides clutch (now included as part of transmission).
      Can be removed in lucid+1
    + Added liblaunchpad-integration-dev and lsb-release to Build-Depends
  - debian/rules:
    + create a po template during package build.
  - debian/patches/01_lpi.patch:
    + integrate transmission with launchpad
  - debian/patches/20_add_x-ubuntu-gettext-domain.diff:
    + add x-ubuntu-gettext-domain to .desktop file.
  - debian/transmission-daemon.default:
    - remove --auth from OPTIONS
  - debian/control, debian/rules:
    + build transmission gtk+ client with both gconf and libcanberra support.
  - debian/patches/dont_build_libevent.patch:
    + disable libevent in configure.ac and Makefile.am because we use autotools
      to regenerate build files.
  - lucid/debian/patches/updateminiupnpcstrings_double_escape_slash.patch:
    + Deleted as the bug is fixed upstream
* Fixes bugs:
  - Fix directory selection error in GTK+ 2.19 (LP: #518692)
  - Transmission "Set Location" - dialog doesn't disappear (LP: #529037)
  - The "Torrent Options" dialog's Torrent Priority row gets too much
    vertical stretch (LP: #527299)
  - "Open Folder" behavior can be confusing for single-file torrents
    (LP: #505861)
* Refreshed 99_autoreconf.patch

[ Chris Coulson ]
* debian/patches/disable_web_ui.patch:
  - Disable the web UI by default again (LP: #542194)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: miniupnpc.c,v 1.66 2009/10/10 19:15:34 nanard Exp $ */
 
1
/* $Id: miniupnpc.c,v 1.74 2010/01/09 23:54:40 nanard Exp $ */
2
2
/* Project : miniupnp
3
3
 * Author : Thomas BERNARD
4
 
 * copyright (c) 2005-2009 Thomas Bernard
 
4
 * copyright (c) 2005-2010 Thomas Bernard
5
5
 * This software is subjet to the conditions detailed in the
6
 
 * provided LICENCE file. */
 
6
 * provided LICENSE file. */
7
7
#define __EXTENSIONS__ 1
8
8
#if !defined(MACOSX) && !defined(__sun)
9
9
#if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__)
16
16
#endif
17
17
#endif
18
18
 
 
19
#ifdef __APPLE__
 
20
#define _DARWIN_C_SOURCE
 
21
#endif
 
22
 
19
23
#include <stdlib.h>
20
24
#include <stdio.h>
21
25
#include <string.h>
24
28
#include <winsock2.h>
25
29
#include <ws2tcpip.h>
26
30
#include <io.h>
 
31
/*#include <IPHlpApi.h>*/
27
32
#define snprintf _snprintf
28
33
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
29
34
#define strncasecmp _memicmp
30
 
#else
 
35
#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
31
36
#define strncasecmp memicmp
32
 
#endif
 
37
#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
33
38
#define MAXHOSTNAMELEN 64
34
 
#else
 
39
#else /* #ifdef WIN32 */
35
40
/* Standard POSIX includes */
36
41
#include <unistd.h>
 
42
#if defined(__amigaos__) && !defined(__amigaos4__)
 
43
/* Amiga OS 3 specific stuff */
 
44
#define socklen_t int
 
45
#else
37
46
#include <sys/select.h>
 
47
#endif
38
48
#include <sys/socket.h>
39
49
#include <sys/types.h>
40
50
#include <sys/param.h>
41
51
#include <netinet/in.h>
42
52
#include <arpa/inet.h>
 
53
#if !defined(__amigaos__) && !defined(__amigaos4__)
43
54
#include <poll.h>
 
55
#endif
44
56
#include <netdb.h>
45
57
#include <strings.h>
46
58
#include <errno.h>
47
59
#define closesocket close
48
60
#define MINIUPNPC_IGNORE_EINTR
49
 
#endif
 
61
#endif /* #else WIN32 */
50
62
#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
51
63
#include <sys/time.h>
52
64
#endif
 
65
#if defined(__amigaos__) || defined(__amigaos4__)
 
66
/* Amiga OS specific stuff */
 
67
#define TIMEVAL struct timeval
 
68
#endif
 
69
 
53
70
#include "miniupnpc.h"
54
71
#include "minissdpc.h"
55
72
#include "miniwget.h"
85
102
#endif
86
103
}
87
104
 
88
 
/* Content-length: nnn */
 
105
/* getcontentlenfromline() : parse the Content-Length HTTP header line.
 
106
 * Content-length: nnn */
89
107
static int getcontentlenfromline(const char * p, int n)
90
108
{
91
109
        static const char contlenstr[] = "content-length";
120
138
        return a;
121
139
}
122
140
 
 
141
/* getContentLengthAndHeaderLength()
 
142
 * retrieve header length and content length from an HTTP response
 
143
 * TODO : retrieve Transfer-Encoding: header value, in order to support
 
144
 *        HTTP/1.1, chunked transfer encoding must be supported. */
123
145
static void
124
146
getContentLengthAndHeaderLength(char * p, int n,
125
147
                                int * contentlen, int * headerlen)
430
452
        int n;
431
453
        struct sockaddr_in sockudp_r, sockudp_w;
432
454
        unsigned int mx;
 
455
#ifdef WIN32
 
456
        /*MIB_IPFORWARDROW ip_forward;*/
 
457
#endif
433
458
 
434
 
#ifndef WIN32
 
459
#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
435
460
        /* first try to get infos from minissdpd ! */
436
461
        if(!minissdpdsock)
437
462
                minissdpdsock = "/var/run/minissdpd.sock";
467
492
    sockudp_w.sin_family = AF_INET;
468
493
    sockudp_w.sin_port = htons(PORT);
469
494
    sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);
 
495
#ifdef WIN32
 
496
/* This code could help us to use the right Network interface for 
 
497
 * SSDP multicast traffic */
 
498
/* TODO : Get IP associated with the index given in the ip_forward struct
 
499
 * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */
 
500
 /*
 
501
        if(GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) == NO_ERROR) {
 
502
                DWORD dwRetVal = 0;
 
503
                PMIB_IPADDRTABLE pIPAddrTable;
 
504
    DWORD dwSize = 0;
 
505
    IN_ADDR IPAddr;
 
506
    int i;
 
507
    printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop);
 
508
    pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE));
 
509
    if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
 
510
            free(pIPAddrTable);
 
511
      pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize);
 
512
    }
 
513
    if(pIPAddrTable) {
 
514
        dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 );
 
515
        printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries);
 
516
        for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) {
 
517
        printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex);
 
518
        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr;
 
519
        printf("\tIP Address[%d]:     \t%s\n", i, inet_ntoa(IPAddr) );
 
520
        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask;
 
521
        printf("\tSubnet Mask[%d]:    \t%s\n", i, inet_ntoa(IPAddr) );
 
522
        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr;
 
523
        printf("\tBroadCast[%d]:      \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr);
 
524
        printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize);
 
525
        printf("\tType and State[%d]:", i);
 
526
        printf("\n");
 
527
        }
 
528
                        free(pIPAddrTable);
 
529
        pIPAddrTable = NULL;
 
530
    }
 
531
        }
 
532
*/
 
533
#endif
470
534
 
471
535
#ifdef WIN32
472
536
        if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof (opt)) < 0)
652
716
int ReceiveData(int socket, char * data, int length, int timeout)
653
717
{
654
718
    int n;
655
 
#ifndef WIN32
 
719
#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
656
720
    struct pollfd fds[1]; /* for the poll */
657
721
#ifdef MINIUPNPC_IGNORE_EINTR
658
722
    do {