Changeset 10739


Ignore:
Timestamp:
Jun 9, 2010, 11:22:00 PM (12 years ago)
Author:
livings124
Message:

update miniupnpc to 20100609

Location:
trunk/third-party/miniupnp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/third-party/miniupnp/Changelog.txt

    r10472 r10739  
    1 $Id: Changelog.txt,v 1.113 2010/04/12 20:39:40 nanard Exp $
     1$Id: Changelog.txt,v 1.117 2010/06/09 10:59:08 nanard Exp $
    22miniUPnP client Changelog.
     3
     42010/06/09:
     5  update to python module to match modification made on 2010/04/05
     6  update to Java test code to match modification made on 2010/04/05
     7  all UPNP_* function now return an error if the SOAP request failed
     8  at HTTP level.
     9
     102010/04/17:
     11  Using GetBestRoute() under win32 in order to find the
     12  right interface to use.
    313
    4142010/04/12:
  • trunk/third-party/miniupnp/miniupnpc.c

    r10472 r10739  
    1 /* $Id: miniupnpc.c,v 1.80 2010/04/12 20:39:41 nanard Exp $ */
     1/* $Id: miniupnpc.c,v 1.81 2010/04/17 22:07:59 nanard Exp $ */
    22/* Project : miniupnp
    33 * Author : Thomas BERNARD
     
    2525#include <ws2tcpip.h>
    2626#include <io.h>
    27 /*#include <IPHlpApi.h>*/
     27#include <IPHlpApi.h>
    2828#define snprintf _snprintf
    2929#if defined(_MSC_VER) && (_MSC_VER >= 1400)
     
    421421        struct addrinfo hints, *servinfo, *p;
    422422#ifdef WIN32
    423         /*MIB_IPFORWARDROW ip_forward;*/
     423        MIB_IPFORWARDROW ip_forward;
    424424#endif
    425425
     
    474474/* This code could help us to use the right Network interface for
    475475 * SSDP multicast traffic */
    476 /* TODO : Get IP associated with the index given in the ip_forward struct
     476/* Get IP associated with the index given in the ip_forward struct
    477477 * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */
    478  /*
    479478        if(GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) == NO_ERROR) {
    480479                DWORD dwRetVal = 0;
    481480                PMIB_IPADDRTABLE pIPAddrTable;
    482     DWORD dwSize = 0;
    483     IN_ADDR IPAddr;
    484     int i;
    485     printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop);
    486     pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE));
    487     if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
    488             free(pIPAddrTable);
    489       pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize);
    490     }
    491     if(pIPAddrTable) {
    492         dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 );
    493         printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries);
    494         for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) {
    495         printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex);
    496         IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr;
    497         printf("\tIP Address[%d]:     \t%s\n", i, inet_ntoa(IPAddr) );
    498         IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask;
    499         printf("\tSubnet Mask[%d]:    \t%s\n", i, inet_ntoa(IPAddr) );
    500         IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr;
    501         printf("\tBroadCast[%d]:      \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr);
    502         printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize);
    503         printf("\tType and State[%d]:", i);
    504         printf("\n");
    505         }
     481                DWORD dwSize = 0;
     482#ifdef DEBUG
     483                IN_ADDR IPAddr;
     484#endif
     485                int i;
     486#ifdef DEBUG
     487                printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop);
     488#endif
     489                pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE));
     490                if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
    506491                        free(pIPAddrTable);
    507         pIPAddrTable = NULL;
    508     }
    509         }
    510 */
     492                        pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize);
     493                }
     494                if(pIPAddrTable) {
     495                        dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 );
     496#ifdef DEBUG
     497                        printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries);
     498#endif
     499                        for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) {
     500#ifdef DEBUG
     501                                printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex);
     502                                IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr;
     503                                printf("\tIP Address[%d]:     \t%s\n", i, inet_ntoa(IPAddr) );
     504                                IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask;
     505                                printf("\tSubnet Mask[%d]:    \t%s\n", i, inet_ntoa(IPAddr) );
     506                                IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr;
     507                                printf("\tBroadCast[%d]:      \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr);
     508                                printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize);
     509                                printf("\tType and State[%d]:", i);
     510                                printf("\n");
     511#endif
     512                                if (pIPAddrTable->table[i].dwIndex == ip_forward.dwForwardIfIndex) {
     513                                        /* Set the address of this interface to be used */
     514                                        struct in_addr mc_if;
     515                                        memset(&mc_if, 0, sizeof(mc_if));
     516                                        mc_if.s_addr = pIPAddrTable->table[i].dwAddr;
     517                                        if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0) {
     518                                                PRINT_SOCKET_ERROR("setsockopt");
     519                                        }
     520                                        ((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = pIPAddrTable->table[i].dwAddr;
     521#ifndef DEBUG
     522                                        break;
     523#endif
     524                                }
     525                        }
     526                        free(pIPAddrTable);
     527                        pIPAddrTable = NULL;
     528                }
     529        }
    511530#endif
    512531
  • trunk/third-party/miniupnp/upnpcommands.c

    r8798 r10739  
    1 /* $Id: upnpcommands.c,v 1.25 2009/07/09 16:00:42 nanard Exp $ */
     1/* $Id: upnpcommands.c,v 1.26 2010/06/09 10:59:09 nanard Exp $ */
    22/* Project : miniupnp
    33 * Author : Thomas Bernard
    4  * Copyright (c) 2005-2009 Thomas Bernard
     4 * Copyright (c) 2005-2010 Thomas Bernard
    55 * This software is subject to the conditions detailed in the
    66 * LICENCE file provided in this distribution.
     
    2929        unsigned int r = 0;
    3030        char * p;
    31         simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalBytesSent", 0, buffer, &bufsize);
     31        if(simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalBytesSent", 0, buffer, &bufsize) < 0) {
     32                return UPNPCOMMAND_HTTP_ERROR;
     33        }
    3234        ParseNameValue(buffer, bufsize, &pdata);
    3335        /*DisplayNameValueList(buffer, bufsize);*/
     
    4951        unsigned int r = 0;
    5052        char * p;
    51         simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalBytesReceived", 0, buffer, &bufsize);
     53        if(simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalBytesReceived", 0, buffer, &bufsize) < 0) {
     54                return UPNPCOMMAND_HTTP_ERROR;
     55        }
    5256        ParseNameValue(buffer, bufsize, &pdata);
    5357        /*DisplayNameValueList(buffer, bufsize);*/
     
    6973        unsigned int r = 0;
    7074        char * p;
    71         simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalPacketsSent", 0, buffer, &bufsize);
     75        if(simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalPacketsSent", 0, buffer, &bufsize) < 0) {
     76                return UPNPCOMMAND_HTTP_ERROR;
     77        }
    7278        ParseNameValue(buffer, bufsize, &pdata);
    7379        /*DisplayNameValueList(buffer, bufsize);*/
     
    8995        unsigned int r = 0;
    9096        char * p;
    91         simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalPacketsReceived", 0, buffer, &bufsize);
     97        if(simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalPacketsReceived", 0, buffer, &bufsize) < 0) {
     98                return UPNPCOMMAND_HTTP_ERROR;
     99        }
    92100        ParseNameValue(buffer, bufsize, &pdata);
    93101        /*DisplayNameValueList(buffer, bufsize);*/
     
    118126                return UPNPCOMMAND_INVALID_ARGS;
    119127
    120         simpleUPnPcommand(-1, controlURL, servicetype, "GetStatusInfo", 0, buffer, &bufsize);
     128        if(simpleUPnPcommand(-1, controlURL, servicetype, "GetStatusInfo", 0, buffer, &bufsize) < 0) {
     129                return UPNPCOMMAND_HTTP_ERROR;
     130        }
    121131        ParseNameValue(buffer, bufsize, &pdata);
    122132        /*DisplayNameValueList(buffer, bufsize);*/
     
    175185                return UPNPCOMMAND_INVALID_ARGS;
    176186
    177         simpleUPnPcommand(-1, controlURL, servicetype,
    178                           "GetConnectionTypeInfo", 0, buffer, &bufsize);
     187        if(simpleUPnPcommand(-1, controlURL, servicetype,
     188                          "GetConnectionTypeInfo", 0, buffer, &bufsize) < 0) {
     189                return UPNPCOMMAND_HTTP_ERROR;
     190        }
    179191        ParseNameValue(buffer, bufsize, &pdata);
    180192        p = GetValueFromNameValueList(&pdata, "NewConnectionType");
     
    219231
    220232        /* shouldn't we use GetCommonLinkProperties ? */
    221         simpleUPnPcommand(-1, controlURL, servicetype,
    222                           "GetCommonLinkProperties", 0, buffer, &bufsize);
     233        if(simpleUPnPcommand(-1, controlURL, servicetype,
     234                          "GetCommonLinkProperties", 0, buffer, &bufsize) < 0) {
    223235                          /*"GetLinkLayerMaxBitRates", 0, buffer, &bufsize);*/
     236                return UPNPCOMMAND_HTTP_ERROR;
     237        }
    224238        /*DisplayNameValueList(buffer, bufsize);*/
    225239        ParseNameValue(buffer, bufsize, &pdata);
     
    281295                return UPNPCOMMAND_INVALID_ARGS;
    282296
    283         simpleUPnPcommand(-1, controlURL, servicetype, "GetExternalIPAddress", 0, buffer, &bufsize);
     297        if(simpleUPnPcommand(-1, controlURL, servicetype, "GetExternalIPAddress", 0, buffer, &bufsize) < 0) {
     298                return UPNPCOMMAND_HTTP_ERROR;
     299        }
    284300        /*DisplayNameValueList(buffer, bufsize);*/
    285301        ParseNameValue(buffer, bufsize, &pdata);
     
    339355        AddPortMappingArgs[7].elt = "NewLeaseDuration";
    340356        AddPortMappingArgs[7].val = "0";
    341         simpleUPnPcommand(-1, controlURL, servicetype, "AddPortMapping", AddPortMappingArgs, buffer, &bufsize);
     357        if(simpleUPnPcommand(-1, controlURL, servicetype, "AddPortMapping", AddPortMappingArgs, buffer, &bufsize) < 0) {
     358                free(AddPortMappingArgs);
     359                return UPNPCOMMAND_HTTP_ERROR;
     360        }
    342361        /*DisplayNameValueList(buffer, bufsize);*/
    343362        /*buffer[bufsize] = '\0';*/
     
    380399        DeletePortMappingArgs[2].elt = "NewProtocol";
    381400        DeletePortMappingArgs[2].val = proto;
    382         simpleUPnPcommand(-1, controlURL, servicetype,
    383                           "DeletePortMapping",
    384                                           DeletePortMappingArgs, buffer, &bufsize);
     401        if(simpleUPnPcommand(-1, controlURL, servicetype,
     402                             "DeletePortMapping",
     403                             DeletePortMappingArgs, buffer, &bufsize) < 0 ) {
     404                free(DeletePortMappingArgs);
     405                return UPNPCOMMAND_HTTP_ERROR;
     406        }
    385407        /*DisplayNameValueList(buffer, bufsize);*/
    386408        ParseNameValue(buffer, bufsize, &pdata);
     
    423445        GetPortMappingArgs[0].elt = "NewPortMappingIndex";
    424446        GetPortMappingArgs[0].val = index;
    425         simpleUPnPcommand(-1, controlURL, servicetype,
     447        if(simpleUPnPcommand(-1, controlURL, servicetype,
    426448                          "GetGenericPortMappingEntry",
    427                                           GetPortMappingArgs, buffer, &bufsize);
     449                                          GetPortMappingArgs, buffer, &bufsize) < 0) {
     450                free(GetPortMappingArgs);
     451                return UPNPCOMMAND_HTTP_ERROR;
     452        }
    428453        ParseNameValue(buffer, bufsize, &pdata);
    429454        p = GetValueFromNameValueList(&pdata, "NewRemoteHost");
     
    497522        char* p;
    498523        int ret = UPNPCOMMAND_UNKNOWN_ERROR;
    499         simpleUPnPcommand(-1, controlURL, servicetype, "GetPortMappingNumberOfEntries", 0, buffer, &bufsize);
     524        if(simpleUPnPcommand(-1, controlURL, servicetype, "GetPortMappingNumberOfEntries", 0, buffer, &bufsize) < 0) {
     525                return UPNPCOMMAND_HTTP_ERROR;
     526        }
    500527#ifdef DEBUG
    501528        DisplayNameValueList(buffer, bufsize);
     
    547574        GetPortMappingArgs[2].elt = "NewProtocol";
    548575        GetPortMappingArgs[2].val = proto;
    549         simpleUPnPcommand(-1, controlURL, servicetype,
    550                           "GetSpecificPortMappingEntry",
    551                                           GetPortMappingArgs, buffer, &bufsize);
    552         /*fd = simpleUPnPcommand(fd, controlURL, data.servicetype, "GetSpecificPortMappingEntry", AddPortMappingArgs, buffer, &bufsize); */
     576        if(simpleUPnPcommand(-1, controlURL, servicetype,
     577                             "GetSpecificPortMappingEntry",
     578                             GetPortMappingArgs, buffer, &bufsize) < 0) {
     579                free(GetPortMappingArgs);
     580                return UPNPCOMMAND_HTTP_ERROR;
     581        }
    553582        /*DisplayNameValueList(buffer, bufsize);*/
    554583        ParseNameValue(buffer, bufsize, &pdata);
Note: See TracChangeset for help on using the changeset viewer.