Browse Source

Windows compilation fixes

pull/166/head
emanuele-f 5 years ago
parent
commit
1b1900358b
  1. 13
      win32/wintap.c

13
win32/wintap.c

@ -97,7 +97,7 @@ static void iterate_win_network_adapters(
/* ***************************************************** */ /* ***************************************************** */
static int print_adapter_callback(struct win_adapter_info *adapter, void *userdata) { static int print_adapter_callback(struct win_adapter_info *adapter, struct tuntap_dev *device) {
printf(" %s - %s\n", adapter->adapterid, adapter->adaptername); printf(" %s - %s\n", adapter->adapterid, adapter->adaptername);
/* continue */ /* continue */
@ -158,7 +158,7 @@ static void set_interface_mac(struct tuntap_dev *device, const char *mac_str) {
char adapter_info_reg[1024]; char adapter_info_reg[1024];
uint64_t mac = 0; uint64_t mac = 0;
uint8_t *ptr = (u_int8_t*)&mac; uint8_t *ptr = (uint8_t*)&mac;
if(strlen(mac_str) != 17) { if(strlen(mac_str) != 17) {
printf("Invalid MAC: %s\n", mac_str); printf("Invalid MAC: %s\n", mac_str);
@ -197,9 +197,7 @@ static void set_interface_mac(struct tuntap_dev *device, const char *mac_str) {
/* ***************************************************** */ /* ***************************************************** */
static int choose_adapter_callback(struct win_adapter_info *adapter, void *userdata) { static int choose_adapter_callback(struct win_adapter_info *adapter, struct tuntap_dev *device) {
struct tuntap_dev *device = (struct tuntap_dev *)userdata;
if(device->device_name) { if(device->device_name) {
/* A device name filter was set, name must match */ /* A device name filter was set, name must match */
if(strcmp(device->device_name, adapter->adapterid) && if(strcmp(device->device_name, adapter->adapterid) &&
@ -211,6 +209,7 @@ static int choose_adapter_callback(struct win_adapter_info *adapter, void *userd
/* Adapter found, break */ /* Adapter found, break */
device->device_handle = adapter->handle; device->device_handle = adapter->handle;
if(device->device_name) free(device->device_name);
device->device_name = _strdup(adapter->adapterid); device->device_name = _strdup(adapter->adapterid);
device->ifName = _strdup(adapter->adaptername); device->ifName = _strdup(adapter->adaptername);
return(0); return(0);
@ -226,12 +225,12 @@ int open_wintap(struct tuntap_dev *device,
const char *device_mac, const char *device_mac,
int mtu) { int mtu) {
char cmd[256]; char cmd[256];
int len; DWORD len;
ULONG status = TRUE; ULONG status = TRUE;
memset(device, 0, sizeof(struct tuntap_dev)); memset(device, 0, sizeof(struct tuntap_dev));
device->device_handle = INVALID_HANDLE_VALUE; device->device_handle = INVALID_HANDLE_VALUE;
device->device_name = devname[0] ? devname : NULL; device->device_name = devname[0] ? _strdup(devname) : NULL;
device->ifName = NULL; device->ifName = NULL;
device->ip_addr = inet_addr(device_ip); device->ip_addr = inet_addr(device_ip);

Loading…
Cancel
Save