Exemplo n.º 1
0
int
main(void) {
	int ret;
	char *hwaddr;
	struct device *dev;

	ret = 0;
	dev = tuntap_init();
	if (tuntap_start(dev, TUNTAP_MODE_ETHERNET, TUNTAP_ID_ANY)
	    == -1) {
		ret = 1;
		goto clean;
	}

	if (tuntap_set_hwaddr(dev, "54:1a:13:ef:b6:b5") == -1) {
		ret = 1;
		goto clean;
	}

	hwaddr = tuntap_get_hwaddr(dev);
	if (strcasecmp(hwaddr, "54:1a:13:ef:b6:b5") != 0)
		ret = 1;

clean:
	tuntap_destroy(dev);
	return ret;
}
Exemplo n.º 2
0
int
main(void) {
	int ret;
	struct device *dev;
	char *hwaddr;

	ret = 1;
	dev = tuntap_init();
	if (tuntap_start(dev, TUNTAP_MODE_ETHERNET, TUNTAP_ID_ANY) == -1) {
		goto clean;
	}

	hwaddr = tuntap_get_hwaddr(dev);
	(void)fprintf(stderr, "%s\n", hwaddr);
	if (strcmp(hwaddr, "0:0:0:0:0:0") == 0)
		goto clean;
	if (strcmp(hwaddr, "00:00:00:00:00:00") == 0)
		goto clean;

	ret = 0;
clean:
	tuntap_destroy(dev);
	return ret;
}