Annotation of embedaddon/miniupnpd/testgetifaddr.c, revision 1.1.1.3
1.1.1.3 ! misho 1: /* $Id: testgetifaddr.c,v 1.5 2012/06/22 16:11:58 nanard Exp $ */
1.1 misho 2: /* MiniUPnP project
3: * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
1.1.1.3 ! misho 4: * (c) 2006-2011 Thomas Bernard
1.1 misho 5: * This software is subject to the conditions detailed
6: * in the LICENCE file provided within the distribution */
7: #include <stdio.h>
8: #include <syslog.h>
9: #include "getifaddr.h"
10:
1.1.1.3 ! misho 11: #if defined(__sun)
! 12: /* solaris 10 does not define LOG_PERROR */
! 13: #define LOG_PERROR 0
! 14: #endif
! 15:
1.1 misho 16: int main(int argc, char * * argv) {
1.1.1.2 misho 17: char addr[64];
1.1 misho 18: if(argc < 2) {
19: fprintf(stderr, "Usage:\t%s interface_name\n", argv[0]);
20: return 1;
21: }
1.1.1.3 ! misho 22:
1.1 misho 23: openlog("testgetifaddr", LOG_CONS|LOG_PERROR, LOG_USER);
24: if(getifaddr(argv[1], addr, sizeof(addr)) < 0) {
25: fprintf(stderr, "Cannot get address for interface %s.\n", argv[1]);
26: return 1;
27: }
28: printf("Interface %s has IP address %s.\n", argv[1], addr);
29: return 0;
30: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>