2011-09-28 19:13:20 +00:00
|
|
|
/* $Id: testgetifaddr.c,v 1.3 2011/04/11 10:41:57 nanard Exp $ */
|
|
|
|
/* MiniUPnP project
|
|
|
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
2012-03-01 01:44:38 +00:00
|
|
|
* (c) 2006-2011 Thomas Bernard
|
2011-09-28 19:13:20 +00:00
|
|
|
* This software is subject to the conditions detailed
|
|
|
|
* in the LICENCE file provided within the distribution */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
#include "getifaddr.h"
|
|
|
|
|
|
|
|
int main(int argc, char * * argv) {
|
|
|
|
char addr[64];
|
|
|
|
if(argc < 2) {
|
|
|
|
fprintf(stderr, "Usage:\t%s interface_name\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
openlog("testgetifaddr", LOG_CONS|LOG_PERROR, LOG_USER);
|
|
|
|
if(getifaddr(argv[1], addr, sizeof(addr)) < 0) {
|
|
|
|
fprintf(stderr, "Cannot get address for interface %s.\n", argv[1]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
printf("Interface %s has IP address %s.\n", argv[1], addr);
|
|
|
|
return 0;
|
|
|
|
}
|