/* This sets up the Host end of the network device with an IP address, brings it up so packets will flow, the copies the MAC address into the hwaddr pointer.  */
static void configure_device(int fd, const char *tapif, u32 ipaddr)
/* This sets up the Host end of the network device with an IP address, brings it up so packets will flow, the copies the MAC address into the hwaddr pointer.  */
static void configure_device(int fd, const char *tapif, u32 ipaddr)
{
	struct ifreq ifr;
	struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
	memset(&ifr, 0, sizeof(ifr));
	strcpy(ifr.ifr_name, tapif);
	sin->sin_family = AF_INET;
	sin->sin_addr.s_addr = htonl(ipaddr);
	if (ioctl(fd, SIOCSIFADDR, &ifr) != 0)
		err(1, "Setting %s interface address", tapif);
	ifr.ifr_flags = IFF_UP;
	if (ioctl(fd, SIOCSIFFLAGS, &ifr) != 0)
		err(1, "Bringing interface %s up", tapif);
}