|
|
@ -228,7 +228,9 @@ int open_wintap(struct tuntap_dev *device, |
|
|
|
char *device_ip, |
|
|
|
char *device_mask, |
|
|
|
const char *device_mac, |
|
|
|
int mtu) { |
|
|
|
int mtu, |
|
|
|
int metric) { |
|
|
|
|
|
|
|
char cmd[256]; |
|
|
|
DWORD len; |
|
|
|
ULONG status = TRUE; |
|
|
@ -299,14 +301,33 @@ int open_wintap(struct tuntap_dev *device, |
|
|
|
|
|
|
|
/* ****************** */ |
|
|
|
|
|
|
|
/* MTU and network metric */ |
|
|
|
/* MTU */ |
|
|
|
|
|
|
|
_snprintf(cmd, sizeof(cmd), |
|
|
|
"netsh interface ipv4 set subinterface \"%s\" mtu=%d store=persistent > nul", |
|
|
|
device->ifName, mtu); |
|
|
|
|
|
|
|
if(system(cmd) != 0) |
|
|
|
printf("WARNING: Unable to set device %s parameters MTU=%d store=persistent [%s]\n", |
|
|
|
device->ifName, mtu, cmd); |
|
|
|
|
|
|
|
/* ****************** */ |
|
|
|
|
|
|
|
/* metric */ |
|
|
|
|
|
|
|
device->metric = metric; |
|
|
|
|
|
|
|
_snprintf(cmd, sizeof(cmd), |
|
|
|
"netsh interface ipv4 set subinterface \"%s\" mtu=%d metric=%d store=persistent > nul", |
|
|
|
device->ifName, mtu, device->metric); |
|
|
|
"netsh interface ipv4 set interface \"%s\" metric=%d > nul", |
|
|
|
device->ifName, device->metric); |
|
|
|
|
|
|
|
if(system(cmd) != 0) |
|
|
|
printf("WARNING: Unable to set device %s parameters MTU=%d metric=%d store=persistent [%s]\n", |
|
|
|
device->ifName, mtu, device->metric, cmd); |
|
|
|
printf("WARNING: Unable to set device %s parameters metric=%d [%s]\n", |
|
|
|
device->ifName, device->metric, cmd); |
|
|
|
|
|
|
|
|
|
|
|
/* ****************** */ |
|
|
|
|
|
|
|
|
|
|
|
/* set driver media status to 'connected' (i.e. set the interface up) */ |
|
|
|
if (!DeviceIoControl (device->device_handle, TAP_IOCTL_SET_MEDIA_STATUS, |
|
|
@ -389,8 +410,9 @@ int tuntap_open(struct tuntap_dev *device, |
|
|
|
char *device_ip, |
|
|
|
char *device_mask, |
|
|
|
const char * device_mac, |
|
|
|
int mtu) { |
|
|
|
return(open_wintap(device, dev, address_mode, device_ip, device_mask, device_mac, mtu)); |
|
|
|
int mtu, |
|
|
|
int metric) { |
|
|
|
return(open_wintap(device, dev, address_mode, device_ip, device_mask, device_mac, mtu, metric)); |
|
|
|
} |
|
|
|
|
|
|
|
/* ************************************************ */ |
|
|
@ -415,7 +437,7 @@ int main(int argc, char* argv[]) { |
|
|
|
|
|
|
|
printf("Welcome to n2n\n"); |
|
|
|
initWin32(); |
|
|
|
open_wintap(&tuntap, "static", "1.2.3.20", "255.255.255.0", mtu); |
|
|
|
open_wintap(&tuntap, "static", "1.2.3.20", "255.255.255.0", mtu, 0); |
|
|
|
|
|
|
|
for(i=0; i<10; i++) { |
|
|
|
u_char buf[MTU]; |
|
|
|