Changeset 1373

Show
Ignore:
Timestamp:
09/30/08 05:27:40 (4 years ago)
Author:
wichert
Message:

Clean up compiler warnings

Location:
trunk/wifidog
Files:
16 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/ChangeLog

    r1372 r1373  
    22 
    332008-09-30 Wichert Akkerman <wichert@wiggy.net> 
     4        * Clean up compiler warnings (mostly signed/unsigned comparisons) 
    45        * Security: strncpy may not NUL-terminate strings, so enforce this 
    56          ourselves. 
  • trunk/wifidog/src/auth.c

    r1346 r1373  
    6161*/   
    6262void 
    63 thread_client_timeout_check(void *arg) 
     63thread_client_timeout_check(const void *arg) 
    6464{ 
    6565        pthread_cond_t          cond = PTHREAD_COND_INITIALIZER; 
  • trunk/wifidog/src/auth.h

    r1305 r1373  
    5757 
    5858/** @brief Periodically check if connections expired */ 
    59 void thread_client_timeout_check(void *arg); 
     59void thread_client_timeout_check(const void *arg); 
    6060 
    6161#endif 
  • trunk/wifidog/src/centralserver.c

    r1305 r1373  
    6363*/ 
    6464t_authcode 
    65 auth_server_request(t_authresponse *authresponse, char *request_type, char *ip, char *mac, char *token, unsigned long long int incoming, unsigned long long int outgoing) 
     65auth_server_request(t_authresponse *authresponse, const char *request_type, const char *ip, const char *mac, const char *token, unsigned long long int incoming, unsigned long long int outgoing) 
    6666{ 
    6767        int sockfd; 
    68         size_t  numbytes, totalbytes; 
     68        ssize_t numbytes; 
     69        size_t totalbytes; 
    6970        char buf[MAX_BUF]; 
    7071        char *tmp; 
  • trunk/wifidog/src/centralserver.h

    r1305 r1373  
    4747 
    4848/** @brief Initiates a transaction with the auth server */ 
    49 t_authcode auth_server_request(t_authresponse *authresponse, char *request_type, char *ip, char *mac, char *token, unsigned long long int incoming, unsigned long long int outgoing); 
     49t_authcode auth_server_request(t_authresponse *authresponse, 
     50                        const char *request_type, 
     51                        const char *ip, 
     52                        const char *mac, 
     53                        const char *token, 
     54                        unsigned long long int incoming, 
     55                        unsigned long long int outgoing); 
    5056 
    5157/** @brief Tries really hard to connect to an auth server.  Returns a connected file descriptor or -1 on error */ 
  • trunk/wifidog/src/client_list.c

    r901 r1373  
    7878 */ 
    7979t_client         * 
    80 client_list_append(char *ip, char *mac, char *token) 
     80client_list_append(const char *ip, const char *mac, const char *token) 
    8181{ 
    8282    t_client         *curclient, *prevclient; 
     
    118118 */ 
    119119t_client         * 
    120 client_list_find(char *ip, char *mac) 
     120client_list_find(const char *ip, const char *mac) 
    121121{ 
    122122    t_client         *ptr; 
     
    139139 */ 
    140140t_client         * 
    141 client_list_find_by_ip(char *ip) 
     141client_list_find_by_ip(const char *ip) 
    142142{ 
    143143    t_client         *ptr; 
     
    160160 */ 
    161161t_client         * 
    162 client_list_find_by_mac(char *mac) 
     162client_list_find_by_mac(const char *mac) 
    163163{ 
    164164    t_client         *ptr; 
     
    179179 */ 
    180180t_client * 
    181 client_list_find_by_token(char *token) 
     181client_list_find_by_token(const char *token) 
    182182{ 
    183183    t_client         *ptr; 
  • trunk/wifidog/src/client_list.h

    r901 r1373  
    6262 
    6363/** @brief Adds a new client to the connections list */ 
    64 t_client *client_list_append(char *ip, char *mac, char *token); 
     64t_client *client_list_append(const char *ip, const char *mac, const char *token); 
    6565 
    6666/** @brief Finds a client by its IP and MAC */ 
    67 t_client *client_list_find(char *ip, char *mac); 
     67t_client *client_list_find(const char *ip, const char *mac); 
    6868 
    6969/** @brief Finds a client only by its IP */ 
    70 t_client *client_list_find_by_ip(char *ip); /* needed by fw_iptables.c, auth.c  
     70t_client *client_list_find_by_ip(const char *ip); /* needed by fw_iptables.c, auth.c  
    7171                                             * and wdctl_thread.c */ 
    7272 
    7373/** @brief Finds a client only by its Mac */ 
    74 t_client *client_list_find_by_mac(char *mac); /* needed by wdctl_thread.c */ 
     74t_client *client_list_find_by_mac(const char *mac); /* needed by wdctl_thread.c */ 
    7575 
    7676/** @brief Finds a client by its token */ 
    77 t_client *client_list_find_by_token(char *token); 
     77t_client *client_list_find_by_token(const char *token); 
    7878 
    7979/** @brief Deletes a client from the connections list */ 
  • trunk/wifidog/src/conf.c

    r1369 r1373  
    103103        const char *name; 
    104104        OpCodes opcode; 
    105         int required; 
    106105} keywords[] = { 
    107         { "daemon",             oDaemon }, 
    108         { "debuglevel",         oDebugLevel }, 
    109         { "externalinterface",  oExternalInterface }, 
    110         { "gatewayid",          oGatewayID }, 
    111         { "gatewayinterface",   oGatewayInterface }, 
    112         { "gatewayaddress",     oGatewayAddress }, 
    113         { "gatewayport",        oGatewayPort }, 
    114         { "authserver",         oAuthServer }, 
    115         { "httpdmaxconn",       oHTTPDMaxConn }, 
    116         { "httpdname",          oHTTPDName }, 
    117         { "httpdrealm",         oHTTPDRealm }, 
    118         { "httpdusername",      oHTTPDUsername }, 
    119         { "httpdpassword",      oHTTPDPassword }, 
    120         { "clienttimeout",      oClientTimeout }, 
    121         { "checkinterval",      oCheckInterval }, 
    122         { "syslogfacility",     oSyslogFacility }, 
    123         { "wdctlsocket",            oWdctlSocket }, 
    124         { "hostname",               oAuthServHostname }, 
    125         { "sslavailable",           oAuthServSSLAvailable }, 
    126         { "sslport",                oAuthServSSLPort }, 
    127         { "httpport",               oAuthServHTTPPort }, 
    128         { "path",                       oAuthServPath }, 
     106        { "daemon",                     oDaemon }, 
     107        { "debuglevel",                 oDebugLevel }, 
     108        { "externalinterface",          oExternalInterface }, 
     109        { "gatewayid",                  oGatewayID }, 
     110        { "gatewayinterface",           oGatewayInterface }, 
     111        { "gatewayaddress",             oGatewayAddress }, 
     112        { "gatewayport",                oGatewayPort }, 
     113        { "authserver",                 oAuthServer }, 
     114        { "httpdmaxconn",               oHTTPDMaxConn }, 
     115        { "httpdname",                  oHTTPDName }, 
     116        { "httpdrealm",                 oHTTPDRealm }, 
     117        { "httpdusername",              oHTTPDUsername }, 
     118        { "httpdpassword",              oHTTPDPassword }, 
     119        { "clienttimeout",              oClientTimeout }, 
     120        { "checkinterval",              oCheckInterval }, 
     121        { "syslogfacility",             oSyslogFacility }, 
     122        { "wdctlsocket",                oWdctlSocket }, 
     123        { "hostname",                   oAuthServHostname }, 
     124        { "sslavailable",               oAuthServSSLAvailable }, 
     125        { "sslport",                    oAuthServSSLPort }, 
     126        { "httpport",                   oAuthServHTTPPort }, 
     127        { "path",                       oAuthServPath }, 
    129128        { "loginscriptpathfragment",    oAuthServLoginScriptPathFragment }, 
    130129        { "portalscriptpathfragment",   oAuthServPortalScriptPathFragment }, 
    131         { "msgscriptpathfragment",              oAuthServMsgScriptPathFragment }, 
    132         { "pingscriptpathfragment",             oAuthServPingScriptPathFragment }, 
    133         { "authscriptpathfragment",             oAuthServAuthScriptPathFragment }, 
    134         { "firewallruleset",    oFirewallRuleSet }, 
    135         { "firewallrule",           oFirewallRule }, 
    136         { "trustedmaclist",         oTrustedMACList }, 
    137         { "htmlmessagefile",    oHtmlMessageFile }, 
    138         { NULL,                 oBadOption }, 
     130        { "msgscriptpathfragment",      oAuthServMsgScriptPathFragment }, 
     131        { "pingscriptpathfragment",     oAuthServPingScriptPathFragment }, 
     132        { "authscriptpathfragment",     oAuthServAuthScriptPathFragment }, 
     133        { "firewallruleset",            oFirewallRuleSet }, 
     134        { "firewallrule",               oFirewallRule }, 
     135        { "trustedmaclist",             oTrustedMACList }, 
     136        { "htmlmessagefile",            oHtmlMessageFile }, 
     137        { NULL,                         oBadOption }, 
    139138}; 
    140139 
    141 static void config_notnull(void *parm, char *parmname); 
     140static void config_notnull(const void *parm, const char *parmname); 
    142141static int parse_boolean_value(char *); 
    143 static void parse_auth_server(FILE *, char *, int *); 
    144 static int _parse_firewall_rule(char *ruleset, char *leftover); 
    145 static void parse_firewall_ruleset(char *, FILE *, char *, int *); 
     142static void parse_auth_server(FILE *, const char *, int *); 
     143static int _parse_firewall_rule(const char *ruleset, char *leftover); 
     144static void parse_firewall_ruleset(const char *, FILE *, const char *, int *); 
    146145 
    147146static OpCodes config_parse_token(const char *cp, const char *filename, int linenum); 
     
    216215*/ 
    217216static void 
    218 parse_auth_server(FILE *file, char *filename, int *linenum) 
     217parse_auth_server(FILE *file, const char *filename, int *linenum) 
    219218{ 
    220219        char            *host = NULL, 
     
    401400*/ 
    402401static void 
    403 parse_firewall_ruleset(char *ruleset, FILE *file, char *filename, int *linenum) 
     402parse_firewall_ruleset(const char *ruleset, FILE *file, const char *filename, int *linenum) 
    404403{ 
    405404        char            line[MAX_BUF], 
     
    478477*/ 
    479478static int 
    480 _parse_firewall_rule(char *ruleset, char *leftover) 
     479_parse_firewall_rule(const char *ruleset, char *leftover) 
    481480{ 
    482481        int i; 
     
    614613 
    615614t_firewall_rule * 
    616 get_ruleset(char *ruleset) 
     615get_ruleset(const char *ruleset) 
    617616{ 
    618617        t_firewall_ruleset      *tmp; 
     
    631630*/ 
    632631void 
    633 config_read(char *filename) 
     632config_read(const char *filename) 
    634633{ 
    635634        FILE *fd; 
     
    830829{ 
    831830        config_notnull(config.gw_interface, "GatewayInterface"); 
    832     config_notnull(config.auth_servers, "AuthServer"); 
     831        config_notnull(config.auth_servers, "AuthServer"); 
    833832 
    834833        if (missing_parms) { 
     
    842841*/ 
    843842static void 
    844 config_notnull(void *parm, char *parmname) 
     843config_notnull(const void *parm, const char *parmname) 
    845844{ 
    846845        if (parm == NULL) { 
  • trunk/wifidog/src/conf.h

    r1369 r1373  
    166166 
    167167/** @brief Reads the configuration file */ 
    168 void config_read(char *filename); 
     168void config_read(const char *filename); 
    169169 
    170170/** @brief Check that the configuration is valid */ 
     
    178178 
    179179/** @brief Fetch a firewall rule set. */ 
    180 t_firewall_rule *get_ruleset(char *); 
     180t_firewall_rule *get_ruleset(const char *); 
    181181 
    182182void parse_trusted_mac_list(char *); 
  • trunk/wifidog/src/fw_iptables.c

    r1305 r1373  
    4949#include "client_list.h" 
    5050 
    51 static int iptables_do_command(char *format, ...); 
    52 static char *iptables_compile(char *, char *, t_firewall_rule *); 
    53 static void iptables_load_ruleset(char *, char *, char *); 
     51static int iptables_do_command(const char *format, ...); 
     52static char *iptables_compile(const char *, const char *, const t_firewall_rule *); 
     53static void iptables_load_ruleset(const char *, const char *, const char *); 
    5454 
    5555extern pthread_mutex_t  client_list_mutex; 
     
    6363 * */ 
    6464static int 
    65 iptables_do_command(char *format, ...) 
     65iptables_do_command(const char *format, ...) 
    6666{ 
    6767    va_list vlist; 
     
    8181         
    8282    rc = execute(cmd, fw_quiet); 
     83 
     84    if (rc!=0) 
     85        debug(LOG_ERR, "iptables comand tailed: %s", cmd); 
    8386 
    8487    free(cmd); 
     
    9699 */ 
    97100static char * 
    98 iptables_compile(char * table, char *chain, t_firewall_rule *rule) 
     101iptables_compile(const char * table, const char *chain, const t_firewall_rule *rule) 
    99102{ 
    100103    char        command[MAX_BUF], 
     
    140143 */ 
    141144static void 
    142 iptables_load_ruleset(char * table, char *ruleset, char *chain) 
     145iptables_load_ruleset(const char * table, const char *ruleset, const char *chain) 
    143146{ 
    144147        t_firewall_rule         *rule; 
     
    167170iptables_fw_set_authservers(void) 
    168171{ 
    169     s_config *config; 
     172    const s_config *config; 
    170173    t_auth_serv *auth_server; 
    171174    
     
    186189iptables_fw_init(void) 
    187190{ 
    188     s_config *config; 
    189          char * gw_interface = NULL; 
    190          char * gw_address = NULL; 
    191          char * ext_interface = NULL; 
    192          int gw_port = 0; 
    193      t_trusted_mac *p; 
     191        const s_config *config; 
     192        char * gw_interface = NULL; 
     193        char * gw_address = NULL; 
     194        char * ext_interface = NULL; 
     195        int gw_port = 0; 
     196        t_trusted_mac *p; 
    194197    
    195     fw_quiet = 0; 
     198        fw_quiet = 0; 
    196199 
    197200         LOCK_CONFIG(); 
     
    400403int 
    401404iptables_fw_destroy_mention( 
    402                 char * table, 
    403                 char * chain, 
    404                 char * mention 
     405                const char * table, 
     406                const char * chain, 
     407                const char * mention 
    405408) { 
    406409        FILE *p = NULL; 
     
    451454/** Set if a specific client has access through the firewall */ 
    452455int 
    453 iptables_fw_access(fw_access_t type, char *ip, char *mac, int tag) 
     456iptables_fw_access(fw_access_t type, const char *ip, const char *mac, int tag) 
    454457{ 
    455458    int rc; 
  • trunk/wifidog/src/fw_iptables.h

    r901 r1373  
    6464 
    6565/** @brief Helper function for iptables_fw_destroy */ 
    66 int iptables_fw_destroy_mention( char * table, char * chain, char * mention); 
     66int iptables_fw_destroy_mention( const char * table, const char * chain, const char * mention); 
    6767 
    6868/** @brief Define the access of a specific client */ 
    69 int iptables_fw_access(fw_access_t type, char *ip, char *mac, int tag); 
     69int iptables_fw_access(fw_access_t type, const char *ip, const char *mac, int tag); 
    7070 
    7171/** @brief All counters in the client list */ 
  • trunk/wifidog/src/http.c

    r1370 r1373  
    290290{ 
    291291    s_config    *config = config_get_config(); 
    292     unsigned char *buffer; 
     292    char *buffer; 
    293293    struct stat stat_info; 
    294294    int fd; 
     
    307307    } 
    308308 
    309     buffer=(unsigned char*)safe_malloc(stat_info.st_size+1); 
     309    buffer=(char*)safe_malloc(stat_info.st_size+1); 
    310310    written=read(fd, buffer, stat_info.st_size); 
    311311    if (written==-1) { 
  • trunk/wifidog/src/ping_thread.c

    r1305 r1373  
    9494ping(void) 
    9595{ 
    96         size_t                  numbytes, 
    97                                 totalbytes; 
     96        ssize_t                 numbytes; 
     97        size_t                  totalbytes; 
    9898        int                     sockfd, nfds, done; 
    9999        char                    request[MAX_BUF]; 
  • trunk/wifidog/src/util.c

    r1358 r1373  
    5252 
    5353#ifdef __linux__ 
     54#include <netinet/in.h> 
    5455#include <net/if.h> 
    5556#endif 
     
    155156 
    156157char * 
    157 get_iface_ip(char *ifname) 
     158get_iface_ip(const char *ifname) 
    158159{ 
    159160#if defined(__linux__) 
     
    181182        in.s_addr = ip; 
    182183 
    183         ip_str = (char *)inet_ntoa(in); 
     184        ip_str = inet_ntoa(in); 
    184185        close(sockd); 
    185186        return safe_strdup(ip_str); 
     
    213214 
    214215char * 
    215 get_iface_mac(char *ifname) 
     216get_iface_mac(const char *ifname) 
    216217{ 
    217218#if defined(__linux__) 
  • trunk/wifidog/src/util.h

    r969 r1373  
    3636 
    3737/* @brief Get IP address of an interface */ 
    38 char *get_iface_ip(char *ifname); 
     38char *get_iface_ip(const char *ifname); 
    3939 
    4040/* @brief Get MAC address of an interface */ 
    41 char *get_iface_mac(char *ifname); 
     41char *get_iface_mac(const char *ifname); 
    4242 
    4343/* @brief Get interface name of default gateway */ 
  • trunk/wifidog/src/wdctl.c

    r901 r1373  
    4747static void parse_commandline(int, char **); 
    4848static int connect_to_server(char *); 
    49 static int send_request(int, char *); 
     49static size_t send_request(int, char *); 
    5050static void wdctl_status(void); 
    5151static void wdctl_stop(void); 
     
    167167} 
    168168 
    169 static int 
     169static size_t 
    170170send_request(int sock, char *request) 
    171171{ 
    172         ssize_t len, 
    173                 written; 
     172        size_t  len; 
     173        ssize_t written; 
    174174                 
    175175        len = 0; 
     
    184184        } 
    185185 
    186         return((int)len); 
     186        return len; 
    187187} 
    188188 
     
    239239        char    buffer[4096]; 
    240240        char    request[64]; 
    241         int     len, 
    242                 rlen; 
     241        size_t  len; 
     242        int     rlen; 
    243243 
    244244        sock = connect_to_server(config.socket);