Changeset 8515


Ignore:
Timestamp:
03/08/13 11:41:35 (8 years ago)
Author:
gf
Message:

Honour global serverip setting.

The idea behind serverip set in [global] is to set the address that
oscam binds to by default but the setting was not used properly.

For modules it only worked if reader->l_port was set but for webif
it wasn't working at all.

This fixes ticket #3206.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/module-webif.c

    r8489 r8515  
    52885288    memset(&sin, 0, sizeof sin);
    52895289    sin.sin_family = AF_INET;
    5290     sin.sin_addr.s_addr = INADDR_ANY;
     5290    if (IP_ISSET(cfg.srvip))
     5291        IP_ASSIGN(SIN_GET_ADDR(sin), cfg.srvip);
     5292    else
     5293        sin.sin_addr.s_addr = INADDR_ANY;
    52915294    sin.sin_port = htons(cfg.http_port);
    52925295    if((bind(sock, (struct sockaddr *) &sin, sizeof(sin))) < 0) {
  • trunk/oscam-reader.c

    r8514 r8515  
    293293    setsockopt(client->udp_fd, IPPROTO_TCP, TCP_NODELAY, (void *)&flag, sizeof(flag));
    294294
    295     if (client->reader->l_port>0) {
    296         memset((char *)&loc_sa,0,sizeof(loc_sa));
    297         loc_sa.sin_family = AF_INET;
    298         if (IP_ISSET(cfg.srvip))
    299             IP_ASSIGN(SIN_GET_ADDR(loc_sa), cfg.srvip);
    300         else
    301             loc_sa.sin_addr.s_addr = INADDR_ANY;
    302 
     295    memset((char *)&loc_sa,0,sizeof(loc_sa));
     296    loc_sa.sin_family = AF_INET;
     297    if (IP_ISSET(cfg.srvip))
     298        IP_ASSIGN(SIN_GET_ADDR(loc_sa), cfg.srvip);
     299    else
     300        loc_sa.sin_addr.s_addr = INADDR_ANY;
     301
     302    if (client->reader->l_port)
    303303        loc_sa.sin_port = htons(client->reader->l_port);
    304         if (bind(client->udp_fd, (struct sockaddr *)&loc_sa, sizeof (loc_sa))<0) {
    305             rdr_log(rdr, "bind failed (errno=%d %s)", errno, strerror(errno));
    306             close(client->udp_fd);
    307             client->udp_fd = 0;
    308             block_connect(rdr);
    309             return -1;
    310         }
     304    if (bind(client->udp_fd, (struct sockaddr *)&loc_sa, sizeof (loc_sa))<0) {
     305        rdr_log(rdr, "bind failed (errno=%d %s)", errno, strerror(errno));
     306        close(client->udp_fd);
     307        client->udp_fd = 0;
     308        block_connect(rdr);
     309        return -1;
    311310    }
    312311
Note: See TracChangeset for help on using the changeset viewer.