badger/tests/tap_alloc.c
/*
 * OS X drive has no auto-allocate, so get name from environment.
 * The driver disables the 4-byte header by default, which what we want.
 * It does provide ioctls, though, so maybe this could be made explicit.
 */
OS X drive has no auto-allocate, so get name from environment.
The driver disables the 4-byte header by default, which what we want.
It does provide ioctls, though, so maybe this could be made explicit.
OS X drive has no auto - allocate so get name from environment . The driver disables the 4 - byte header by default which what we want . It does provide ioctls though so maybe this could be made explicit .
int tap_alloc(char *dev)
{
	int fd;
	const char *ifName;
	char dName[40];
	ifName = getenv("VVP_NETWORK_NAME");
	if (ifName == NULL) ifName = "tap0";
	if ((strchr(ifName, '/') != NULL)
	 || (strchr(ifName, '.') != NULL)
	 || (strchr(ifName, '"') != NULL)
	 || (snprintf(dName, sizeof dName, "/dev/%s", ifName) >= (int)sizeof dName)) {
		fprintf(stderr, "VVP_NETWORK_NAME must be interface name only, e.g. \"tap0\"\n");
		return -1;
	}
	if( (fd = open(dName, O_RDWR)) < 0 ) {
		fprintf(stderr, "Can't open \"%s\": %s\n", dName, strerror(errno));
		printf("Maybe you want to: chmod 666 %s && ifconfig %s <ip_address> up\n", dName, ifName);
		return -1;
	}
	strcpy(dev, dName);
	return fd;
}
int tap_alloc ( char * dev ) { int fd ; const char * ifName ; char dName [ 40 ] ; ifName = getenv ( " " ) ; if ( ifName == NULL ) ifName = " " ; if ( ( strchr ( ifName , ' ' ) != NULL ) || ( strchr ( ifName , ' ' ) != NULL ) || ( strchr ( ifName , ' ' ) != NULL ) || ( snprintf ( dName , sizeof dName , " " , ifName ) >= ( int ) sizeof dName ) ) { fprintf ( stderr , " \" \" \n " ) ; return -1 ; } if ( ( fd = open ( dName , O_RDWR ) ) < 0 ) { fprintf ( stderr , " \" \" \n " , dName , strerror ( errno ) ) ; printf ( " \n " , dName , ifName ) ; return -1 ; } strcpy ( dev , dName ) ; return fd ; }
OS X drive has no auto-allocate, so get name from environment.
OS X drive has no auto - allocate so get name from environment .