File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / miniupnpd / testgetifaddr.c
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 00:32:35 2013 UTC (10 years, 10 months ago) by misho
Branches: miniupnpd, elwix, MAIN
CVS tags: v1_8p0, v1_8, HEAD
1.8

    1: /* $Id: testgetifaddr.c,v 1.1.1.3 2013/07/22 00:32:35 misho Exp $ */
    2: /* MiniUPnP project
    3:  * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
    4:  * (c) 2006-2011 Thomas Bernard
    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: 
   11: #if defined(__sun)
   12: /* solaris 10 does not define LOG_PERROR */
   13: #define LOG_PERROR 0
   14: #endif
   15: 
   16: int main(int argc, char * * argv) {
   17: 	char addr[64];
   18: 	if(argc < 2) {
   19: 		fprintf(stderr, "Usage:\t%s interface_name\n", argv[0]);
   20: 		return 1;
   21: 	}
   22: 
   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>