network/tun: modify mtu and some checks to give correct types/flags

tun & tap tested

Change-Id: Ifac4ba40c56358ac9e845aa3d07cee75f1e8ce46
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6460
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Swangeon 2023-05-19 14:09:58 -05:00 committed by Jérôme Duval
parent 840faa402b
commit 2815686c1d

View File

@ -22,7 +22,6 @@
#include <string.h>
struct net_buffer_module_info* gBufferModule;
static struct net_stack_module_info* sStackModule;
@ -51,9 +50,18 @@ tun_init(const char* name, net_device** _device)
memset(device, 0, sizeof(tun_device));
strcpy(device->name, name);
device->flags = IFF_LINK;
device->type = strncmp(name, "tap", 3) ? IFT_TUN : IFT_ETHER;
device->mtu = 16384;
if (strncmp(name, "tun", 3) == 0) {
device->flags = IFF_LOOPBACK | IFF_LINK;
device->type = IFT_TUN;
} else if (strncmp(name, "tap", 3) == 0) {
device->flags = IFF_BROADCAST | IFF_ALLMULTI | IFF_LINK;
device->type = IFT_ETHER;
} else {
return B_BAD_VALUE;
}
device->mtu = 1500; /* Almost all VPN MTU's are no more than 1500 bytes */
device->media = IFM_ACTIVE;
*_device = device;