Show
Ignore:
Timestamp:
02/03/05 16:25:33 (8 years ago)
Author:
aprilp
Message:

* Ping the users everytime we check their counters, that way we keep them alive
* Optional ExternalInterface?
* Optional GatewayAddress? (we discover it. finally.)
* We check for the traffic from the clients to the firewall, to catch the traffic the icmp ping is generating
* Bumped to alpha7

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/src/util.c

    r256 r422  
    3939#include <sys/unistd.h> 
    4040#include <netinet/in.h> 
     41#include <sys/ioctl.h> 
     42#include <net/if.h> 
    4143 
    4244#include <string.h> 
     
    117119        return h_addr; 
    118120} 
     121 
     122char *get_iface_ip(char *ifname) { 
     123    struct ifreq if_data; 
     124    struct in_addr in; 
     125    int sockd; 
     126    u_int32_t ip; 
     127 
     128    /* Create a socket */ 
     129    if ((sockd = socket (AF_INET, SOCK_PACKET, htons(0x8086))) < 0) { 
     130        debug(LOG_ERR, "socket(): %s", strerror(errno)); 
     131        return NULL; 
     132    } 
     133 
     134    /* Get IP of internal interface */ 
     135    strcpy (if_data.ifr_name, ifname); 
     136 
     137    /* Get the IP address */ 
     138    if (ioctl (sockd, SIOCGIFADDR, &if_data) < 0) { 
     139        debug(LOG_ERR, "ioctl(): SIOCGIFADDR %s", strerror(errno)); 
     140        return NULL; 
     141    } 
     142    memcpy ((void *) &ip, (void *) &if_data.ifr_addr.sa_data + 2, 4); 
     143    in.s_addr = ip; 
     144 
     145    return (char *)inet_ntoa(in); 
     146}