diff options
Diffstat (limited to 'scripts/ip.c')
| -rw-r--r-- | scripts/ip.c | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/scripts/ip.c b/scripts/ip.c deleted file mode 100644 index 3276696..0000000 --- a/scripts/ip.c +++ /dev/null @@ -1,32 +0,0 @@ -#include <stdio.h> -#include <unistd.h> -#include <string.h> /* for strncpy */ - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <netinet/in.h> -#include <net/if.h> -#include <arpa/inet.h> - -int -main() -{ - int fd; - struct ifreq ifr; - - fd = socket(AF_INET, SOCK_DGRAM, 0); - - /* I want to get an IPv4 IP address */ - ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name, "wlan0", IFNAMSIZ-1); - - ioctl(fd, SIOCGIFADDR, &ifr); - - close(fd); - - /* display result */ - printf("%s\n", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr)); - - return 0; -} |