openafs/tests/common/network.c
Simon Wilkinson 072828a1f5 tests: Tidy up loopback adapter tests
Remove the unused h_errno extern, which in turn removes the need
for disabling strict prototype warnings in the Makefile

Use roken.h, instead of hardcoding system libraries

Change-Id: Ie654c77ff60ed14fc3b659fa3eb527535be71164
Reviewed-on: http://gerrit.openafs.org/8228
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2012-10-12 18:32:17 -07:00

41 lines
858 B
C

#include <afsconfig.h>
#include <afs/param.h>
#include <roken.h>
#include <afs/cellconfig.h>
#include <rx/rx.h>
#include <tests/tap/basic.h>
#include "common.h"
/*! Check if the current machine's hostname resolves to the loopback
* network.
*/
int
afstest_IsLoopbackNetworkDefault(void) {
char hostname[MAXHOSTCHARS];
afs_uint32 addr;
struct hostent *host;
gethostname(hostname, sizeof(hostname));
host = gethostbyname(hostname);
memcpy(&addr, host->h_addr, sizeof(addr));
return(rx_IsLoopbackAddr(ntohl(addr)));
}
/*! Skips all TAP tests if the current machine's hostname resolves to the
* loopback network.
*/
int
afstest_SkipTestsIfLoopbackNetIsDefault(void) {
int retval=0;
retval=afstest_IsLoopbackNetworkDefault();
if(retval==1) {
skip_all("Default IP address is on the loopback network!\n");
}
return retval;
}