Changeset 8574


Ignore:
Timestamp:
03/25/13 22:22:57 (8 years ago)
Author:
gf
Message:

Fix IPv6 binding on local addresses.

Patch by manio posted in ticket #3206.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/globals.h

    r8562 r8574  
    105105#define IN_ADDR_T struct in6_addr
    106106#define SOCKADDR sockaddr_storage
     107#define ADDR_ANY in6addr_any
    107108#else
    108109#define IN_ADDR_T in_addr_t
    109110#define SOCKADDR sockaddr_in
     111#define ADDR_ANY INADDR_ANY
    110112#endif
    111113
  • trunk/module-gbox.c

    r8499 r8574  
    14181418  memset((char *)&loc_sa,0,sizeof(loc_sa));
    14191419  SIN_GET_FAMILY(loc_sa) = AF_INET;
    1420   SIN_GET_ADDR(loc_sa) =
    1421 #ifdef IPV6SUPPORT
    1422     in6addr_any;
    1423 #else
    1424     INADDR_ANY;
    1425 #endif
     1420  SIN_GET_ADDR(loc_sa) = ADDR_ANY;
    14261421  SIN_GET_PORT(loc_sa) = htons(rdr->l_port);
    14271422
  • trunk/oscam-reader.c

    r8570 r8574  
    242242    if (!rdr) return -1;
    243243    struct s_client *client = rdr->client;
     244    struct SOCKADDR loc_sa;
     245
    244246    memset((char *)&client->udp_sa, 0, sizeof(client->udp_sa));
    245247
     
    269271
    270272    int s_domain = PF_INET;
     273    int s_family = AF_INET;
    271274#ifdef IPV6SUPPORT
    272     if (!IN6_IS_ADDR_V4MAPPED(&rdr->client->ip) && !IN6_IS_ADDR_V4COMPAT(&rdr->client->ip))
     275    if (!IN6_IS_ADDR_V4MAPPED(&rdr->client->ip) && !IN6_IS_ADDR_V4COMPAT(&rdr->client->ip)) {
    273276        s_domain = PF_INET6;
     277        s_family = AF_INET6;
     278    }
    274279#endif
    275280    int s_type   = client->is_udp ? SOCK_DGRAM : SOCK_STREAM;
     
    291296    setsockopt(client->udp_fd, IPPROTO_TCP, TCP_NODELAY, (void *)&flag, sizeof(flag));
    292297
    293 #ifndef IPV6SUPPORT
    294     struct sockaddr_in loc_sa;
    295298    memset((char *)&loc_sa,0,sizeof(loc_sa));
    296     loc_sa.sin_family = AF_INET;
     299    SIN_GET_FAMILY(loc_sa) = s_family;
    297300    if (IP_ISSET(cfg.srvip))
    298301        IP_ASSIGN(SIN_GET_ADDR(loc_sa), cfg.srvip);
    299302    else
    300         loc_sa.sin_addr.s_addr = INADDR_ANY;
     303        SIN_GET_ADDR(loc_sa) = ADDR_ANY;
    301304
    302305    if (client->reader->l_port)
    303         loc_sa.sin_port = htons(client->reader->l_port);
     306        SIN_GET_PORT(loc_sa) = htons(client->reader->l_port);
    304307    if (bind(client->udp_fd, (struct sockaddr *)&loc_sa, sizeof (loc_sa))<0) {
    305308        rdr_log(rdr, "bind failed (errno=%d %s)", errno, strerror(errno));
     
    309312        return -1;
    310313    }
    311 #endif
    312314
    313315#ifdef IPV6SUPPORT
Note: See TracChangeset for help on using the changeset viewer.