Changeset 286

Show
Ignore:
Timestamp:
11/21/04 16:07:50 (4 years ago)
Author:
alexcv
Message:

Fixed the problems with inet_ntoa. Don't ask me to explain!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/WIFIDOG_1_0_X/wifidog/ChangeLog

    r285 r286  
    11# $Header$ 
     2 
     32004-11-21 Alexandre Carmel-Veilleux <acv@acv.ca> 
     4        * src/fw_iptables.c: reverted phil's change and fixed it properly 
     5        * src/ping_thread.c: this is where ntoa should've been. 
     6        * src/*: Fixed the problems with inet_ntoa. Don't ask me to explain! 
     7 
    282004-11-21 Philippe April <philippe@philippeapril.com> 
    39        * src/fw_iptables.c: changed call to iptables to use IP address instead of 
  • branches/WIFIDOG_1_0_X/wifidog/src/conf.h

    r278 r286  
    6262                                     listens on */ 
    6363    int authserv_use_ssl;       /**< @brief Use SSL or not */ 
    64     struct in_addr *last_ip;  /**< @brief Last IP of the authserver */ 
     64    char *last_ip;    /**< @brief Last IP of the authserver */ 
    6565    struct _auth_serv_t *next; 
    6666} t_auth_serv; 
  • branches/WIFIDOG_1_0_X/wifidog/src/fw_iptables.c

    r285 r286  
    3737#include <netinet/in.h> 
    3838 
    39 #include "conf.h" 
    4039#include "fw_iptables.h" 
    4140#include "firewall.h" 
     
    4342#include "util.h" 
    4443#include "client_list.h" 
     44#include "conf.h" 
    4545 
    4646static int iptables_do_command(char *format, ...); 
     
    8585    s_config *config; 
    8686    t_auth_serv *auth_server; 
     87    char *ip; 
     88    void *bs; 
     89    struct in_addr *tmp; 
    8790    
    8891    config = config_get_config(); 
     
    9396    for (auth_server = config->auth_servers; auth_server != NULL; 
    9497                    auth_server = auth_server->next) { 
    95         if (auth_server->last_ip && strcmp(inet_ntoa(auth_server->last_ip->s_addr), "0.0.0.0") != 0) { 
    96             iptables_do_command("-t nat -A " TABLE_WIFIDOG_AUTHSERVERS " -d %s -j ACCEPT", inet_ntoa(auth_server->last_ip->s_addr)); 
     98        if (auth_server->last_ip) { 
     99            iptables_do_command("-t nat -A " TABLE_WIFIDOG_AUTHSERVERS " -d %s -j ACCEPT", auth_server->last_ip); 
    97100        } else { 
    98101            iptables_do_command("-t nat -A " TABLE_WIFIDOG_AUTHSERVERS " -d %s -j ACCEPT", auth_server->authserv_hostname); 
  • branches/WIFIDOG_1_0_X/wifidog/src/ping_thread.c

    r280 r286  
    9797                                i; 
    9898        t_auth_serv             *auth_server; 
    99         char                    request[MAX_BUF]; 
     99        char                    request[MAX_BUF], 
     100                                *tmp_addr; 
    100101        struct in_addr          *h_addr; 
    101102        struct sockaddr_in      their_addr; 
     
    127128 
    128129        if (auth_server->last_ip == NULL) { 
    129                 auth_server->last_ip = (struct in_addr *)malloc( 
    130                                 sizeof(struct in_addr)); 
     130                auth_server->last_ip = strdup(inet_ntoa(*h_addr)); 
    131131                if (auth_server->last_ip == NULL) { 
    132132                        debug(LOG_CRIT, "Could not allocate memory, Banzai!"); 
    133133                        exit(-1); 
    134134                } 
    135                 memcpy(auth_server->last_ip, h_addr, sizeof(struct in_addr)); 
    136135        } else { 
    137                 for (i = 0; i < sizeof(struct in_addr) 
    138                                 && (*((char *)auth_server->last_ip + i) 
    139                                         == *((char *)h_addr + i)); i++); 
    140                 if (i < sizeof(struct in_addr)) { 
    141                     memcpy(auth_server->last_ip, h_addr, sizeof(struct in_addr)); 
     136                tmp_addr = strdup(inet_ntoa(*h_addr)); 
     137                if (strcmp(tmp_addr, auth_server->last_ip) != 0) { 
     138                        free(auth_server->last_ip); 
     139                        auth_server->last_ip = tmp_addr; 
    142140                        fw_clear_authservers(); 
    143141                        fw_set_authservers();