Diff for /embedaddon/miniupnpc/receivedata.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:16:22 version 1.1.1.2, 2013/07/22 00:36:10
Line 1 Line 1
 /* $Id$ */  /* $Id$ */
 /* Project : miniupnp  /* Project : miniupnp
    * Website : http://miniupnp.free.fr/
  * Author : Thomas Bernard   * Author : Thomas Bernard
 * Copyright (c) 2011 Thomas Bernard * Copyright (c) 2011-2012 Thomas Bernard
  * This software is subject to the conditions detailed in the   * This software is subject to the conditions detailed in the
  * LICENCE file provided in this distribution. */   * LICENCE file provided in this distribution. */
   
 #include <stdio.h>  #include <stdio.h>
#ifdef WIN32#ifdef _WIN32
 #include <winsock2.h>  #include <winsock2.h>
 #include <ws2tcpip.h>  #include <ws2tcpip.h>
 #else  #else
Line 17 Line 18
 #include <sys/select.h>  #include <sys/select.h>
 #endif /* #else defined(__amigaos__) && !defined(__amigaos4__) */  #endif /* #else defined(__amigaos__) && !defined(__amigaos4__) */
 #include <sys/socket.h>  #include <sys/socket.h>
   #include <netinet/in.h>
 #if !defined(__amigaos__) && !defined(__amigaos4__)  #if !defined(__amigaos__) && !defined(__amigaos4__)
 #include <poll.h>  #include <poll.h>
 #endif  #endif
Line 24 Line 26
 #define MINIUPNPC_IGNORE_EINTR  #define MINIUPNPC_IGNORE_EINTR
 #endif  #endif
   
#ifdef WIN32#ifdef _WIN32
 #define PRINT_SOCKET_ERROR(x)    printf("Socket error: %s, %d\n", x, WSAGetLastError());  #define PRINT_SOCKET_ERROR(x)    printf("Socket error: %s, %d\n", x, WSAGetLastError());
 #else  #else
 #define PRINT_SOCKET_ERROR(x) perror(x)  #define PRINT_SOCKET_ERROR(x) perror(x)
Line 33 Line 35
 #include "receivedata.h"  #include "receivedata.h"
   
 int  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
           struct sockaddr_storage src_addr;
           socklen_t src_addr_len = sizeof(src_addr);
   #endif
     int n;      int n;
#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)#if !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
         /* using poll */          /* using poll */
     struct pollfd fds[1]; /* for the poll */      struct pollfd fds[1]; /* for the poll */
 #ifdef MINIUPNPC_IGNORE_EINTR  #ifdef MINIUPNPC_IGNORE_EINTR
Line 55  receivedata(int socket, char * data, int length, int t Line 63  receivedata(int socket, char * data, int length, int t
                 /* timeout */                  /* timeout */
         return 0;          return 0;
     }      }
#else /* !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */#else /* !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */
        /* using select under WIN32 and amigaos */        /* using select under _WIN32 and amigaos */
     fd_set socketSet;      fd_set socketSet;
     TIMEVAL timeval;      TIMEVAL timeval;
     FD_ZERO(&socketSet);      FD_ZERO(&socketSet);
Line 69  receivedata(int socket, char * data, int length, int t Line 77  receivedata(int socket, char * data, int length, int t
         return -1;          return -1;
     } else if(n == 0) {      } else if(n == 0) {
         return 0;          return 0;
    }        }
 #endif  #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);          n = recv(socket, data, length, 0);
   #endif
         if(n<0) {          if(n<0) {
                 PRINT_SOCKET_ERROR("recv");                  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;          return n;
 }  }
   

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>