miniupnpd/testgetifaddr.c: also test find_ipv6_addr()
This commit is contained in:
parent
e5146cdf24
commit
f49a70aab0
|
@ -284,7 +284,7 @@ upnpdescgen.o: miniupnpdpath.h upnpglobalvars.h upnppermissions.h
|
|||
upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h upnpurns.h getconnstatus.h
|
||||
testgetifstats.o: getifstats.h
|
||||
testupnppermissions.o: upnppermissions.h config.h
|
||||
testgetifaddr.o: getifaddr.h
|
||||
testgetifaddr.o: config.h getifaddr.h
|
||||
testgetroute.o: getroute.h upnputils.h upnpglobalvars.h upnppermissions.h
|
||||
testgetroute.o: config.h miniupnpdtypes.h
|
||||
testasyncsendto.o: miniupnpdtypes.h config.h upnputils.h asyncsendto.h
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: testgetifaddr.c,v 1.7 2013/04/27 15:38:57 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2013 Thomas Bernard
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
#include <stdio.h>
|
||||
|
@ -10,6 +10,7 @@
|
|||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "config.h"
|
||||
#include "getifaddr.h"
|
||||
|
||||
#if defined(__sun)
|
||||
|
@ -21,6 +22,10 @@ int main(int argc, char * * argv) {
|
|||
char str_addr[64];
|
||||
struct in_addr addr;
|
||||
struct in_addr mask;
|
||||
#ifdef ENABLE_IPV6
|
||||
int r;
|
||||
char str_addr6[64];
|
||||
#endif
|
||||
if(argc < 2) {
|
||||
fprintf(stderr, "Usage:\t%s interface_name\n", argv[0]);
|
||||
return 1;
|
||||
|
@ -34,5 +39,16 @@ int main(int argc, char * * argv) {
|
|||
printf("Interface %s has IP address %s.\n", argv[1], str_addr);
|
||||
printf("addr=%s ", inet_ntoa(addr));
|
||||
printf("mask=%s\n", inet_ntoa(mask));
|
||||
#ifdef ENABLE_IPV6
|
||||
r = find_ipv6_addr(argv[1], str_addr6, sizeof(str_addr6));
|
||||
if(r < 0) {
|
||||
fprintf(stderr, "find_ipv6_addr() failed\n");
|
||||
return 1;
|
||||
} else if(r == 0) {
|
||||
printf("Interface %s has no IPv6 address.\n", argv[1]);
|
||||
} else {
|
||||
printf("Interface %s has IPv6 address %s.\n", argv[1], str_addr6);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue