contrib/hostapd/hostapd/vlan_init.c
static int br_addbr(const char *br_name)
{
	int fd;
	unsigned long arg[2];

	if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		perror("socket[AF_INET,SOCK_STREAM]");
		return -1;
	}

	arg[0] = BRCTL_ADD_BRIDGE;
	arg[1] = (unsigned long) br_name;

	if (ioctl(fd, SIOCGIFBR, arg) < 0) {
 		if (errno == EEXIST) {
			/* The bridge is already added. */
			close(fd);
			return 1;
		} else {
			perror("ioctl[BRCTL_ADD_BRIDGE]");
			close(fd);
			return -1;
		}
	}

	close(fd);
	return 0;
}
/*
	Add a bridge with the name 'br_name'.

	returns -1 on error
	returns 1 if the bridge already exists
	returns 0 otherwise
*/
Add a bridge with the name 'br_name'.
returns -1 on error
returns 1 if the bridge already exists
returns 0 otherwise
Add a bridge with the name ' br_name ' . returns - 1 on error returns 1 if the bridge already exists returns 0 otherwise
static int br_addbr(const char *br_name)
{
	int fd;
	unsigned long arg[2];
	if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		perror("socket[AF_INET,SOCK_STREAM]");
		return -1;
	}
	arg[0] = BRCTL_ADD_BRIDGE;
	arg[1] = (unsigned long) br_name;
	if (ioctl(fd, SIOCGIFBR, arg) < 0) {
 		if (errno == EEXIST) {
			close(fd);
			return 1;
		} else {
			perror("ioctl[BRCTL_ADD_BRIDGE]");
			close(fd);
			return -1;
		}
	}
	close(fd);
	return 0;
}
static int br_addbr ( const char * br_name ) { int fd ; unsigned long arg [ 2 ] ; if ( ( fd = socket ( AF_INET , SOCK_STREAM , 0 ) ) < 0 ) { perror ( " " ) ; return -1 ; } arg [ 0 ] = BRCTL_ADD_BRIDGE ; arg [ 1 ] = ( unsigned long ) br_name ; if ( ioctl ( fd , SIOCGIFBR , arg ) < 0 ) { if ( errno == EEXIST ) { close ( fd ) ; return 1 ; } else { perror ( " " ) ; close ( fd ) ; return -1 ; } } close ( fd ) ; return 0 ; }
Add a bridge with the name 'br_name'.
Add a bridge with the name ' br_name ' .
/* The bridge is already added. */