2006-02-02 02:06:55 +03:00
|
|
|
/*
|
|
|
|
* TAP-Win32 -- A kernel driver to provide virtual tap device functionality
|
|
|
|
* on Windows. Originally derived from the CIPE-Win32
|
|
|
|
* project by Damion K. Wilson, with extensive modifications by
|
|
|
|
* James Yonan.
|
|
|
|
*
|
|
|
|
* All source code which derives from the CIPE-Win32 project is
|
|
|
|
* Copyright (C) Damion K. Wilson, 2003, and is released under the
|
|
|
|
* GPL version 2 (see below).
|
|
|
|
*
|
|
|
|
* All other source code is Copyright (C) James Yonan, 2003-2004,
|
|
|
|
* and is released under the GPL version 2 (see below).
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program (see the file COPYING included with this
|
2009-07-17 00:47:01 +04:00
|
|
|
* distribution); if not, see <http://www.gnu.org/licenses/>.
|
2006-02-02 02:06:55 +03:00
|
|
|
*/
|
2009-10-22 20:49:05 +04:00
|
|
|
|
2016-01-29 20:50:00 +03:00
|
|
|
#include "qemu/osdep.h"
|
2012-10-24 10:43:34 +04:00
|
|
|
#include "tap_int.h"
|
2009-10-22 20:49:05 +04:00
|
|
|
|
2007-11-17 20:14:51 +03:00
|
|
|
#include "qemu-common.h"
|
2012-10-17 21:53:50 +04:00
|
|
|
#include "clients.h" /* net_init_tap */
|
2012-10-24 10:43:34 +04:00
|
|
|
#include "net/net.h"
|
2012-12-21 02:09:53 +04:00
|
|
|
#include "net/tap.h" /* tap_has_ufo, ... */
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/sysemu.h"
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/error-report.h"
|
2006-02-02 02:06:55 +03:00
|
|
|
#include <windows.h>
|
2009-07-27 19:02:01 +04:00
|
|
|
#include <winioctl.h>
|
2006-02-02 02:06:55 +03:00
|
|
|
|
|
|
|
//=============
|
|
|
|
// TAP IOCTLs
|
|
|
|
//=============
|
|
|
|
|
|
|
|
#define TAP_CONTROL_CODE(request,method) \
|
|
|
|
CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS)
|
|
|
|
|
|
|
|
#define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE (1, METHOD_BUFFERED)
|
|
|
|
#define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE (2, METHOD_BUFFERED)
|
|
|
|
#define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE (3, METHOD_BUFFERED)
|
|
|
|
#define TAP_IOCTL_GET_INFO TAP_CONTROL_CODE (4, METHOD_BUFFERED)
|
|
|
|
#define TAP_IOCTL_CONFIG_POINT_TO_POINT TAP_CONTROL_CODE (5, METHOD_BUFFERED)
|
|
|
|
#define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE (6, METHOD_BUFFERED)
|
|
|
|
#define TAP_IOCTL_CONFIG_DHCP_MASQ TAP_CONTROL_CODE (7, METHOD_BUFFERED)
|
|
|
|
#define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE (8, METHOD_BUFFERED)
|
|
|
|
#define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE (9, METHOD_BUFFERED)
|
|
|
|
|
|
|
|
//=================
|
|
|
|
// Registry keys
|
|
|
|
//=================
|
|
|
|
|
|
|
|
#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
|
|
|
|
|
|
|
|
#define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
|
|
|
|
|
|
|
|
//======================
|
|
|
|
// Filesystem prefixes
|
|
|
|
//======================
|
|
|
|
|
|
|
|
#define USERMODEDEVICEDIR "\\\\.\\Global\\"
|
|
|
|
#define TAPSUFFIX ".tap"
|
|
|
|
|
|
|
|
|
|
|
|
//======================
|
|
|
|
// Compile time configuration
|
|
|
|
//======================
|
|
|
|
|
2008-11-06 12:38:51 +03:00
|
|
|
//#define DEBUG_TAP_WIN32
|
2006-02-02 02:06:55 +03:00
|
|
|
|
2015-11-18 22:45:09 +03:00
|
|
|
/* FIXME: The asynch write path appears to be broken at
|
|
|
|
* present. WriteFile() ignores the lpNumberOfBytesWritten parameter
|
|
|
|
* for overlapped writes, with the result we return zero bytes sent,
|
|
|
|
* and after handling a single packet, receive is disabled for this
|
|
|
|
* interface. */
|
|
|
|
/* #define TUN_ASYNCHRONOUS_WRITES 1 */
|
2006-02-02 02:06:55 +03:00
|
|
|
|
|
|
|
#define TUN_BUFFER_SIZE 1560
|
|
|
|
#define TUN_MAX_BUFFER_COUNT 32
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The data member "buffer" must be the first element in the tun_buffer
|
|
|
|
* structure. See the function, tap_win32_free_buffer.
|
|
|
|
*/
|
|
|
|
typedef struct tun_buffer_s {
|
|
|
|
unsigned char buffer [TUN_BUFFER_SIZE];
|
|
|
|
unsigned long read_size;
|
|
|
|
struct tun_buffer_s* next;
|
2009-10-02 01:12:16 +04:00
|
|
|
} tun_buffer_t;
|
2006-02-02 02:06:55 +03:00
|
|
|
|
|
|
|
typedef struct tap_win32_overlapped {
|
|
|
|
HANDLE handle;
|
|
|
|
HANDLE read_event;
|
|
|
|
HANDLE write_event;
|
|
|
|
HANDLE output_queue_semaphore;
|
|
|
|
HANDLE free_list_semaphore;
|
2006-08-19 16:37:52 +04:00
|
|
|
HANDLE tap_semaphore;
|
2006-02-02 02:06:55 +03:00
|
|
|
CRITICAL_SECTION output_queue_cs;
|
|
|
|
CRITICAL_SECTION free_list_cs;
|
|
|
|
OVERLAPPED read_overlapped;
|
|
|
|
OVERLAPPED write_overlapped;
|
2009-10-02 01:12:16 +04:00
|
|
|
tun_buffer_t buffers[TUN_MAX_BUFFER_COUNT];
|
|
|
|
tun_buffer_t* free_list;
|
|
|
|
tun_buffer_t* output_queue_front;
|
|
|
|
tun_buffer_t* output_queue_back;
|
|
|
|
} tap_win32_overlapped_t;
|
2006-02-02 02:06:55 +03:00
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static tap_win32_overlapped_t tap_overlapped;
|
2006-02-02 02:06:55 +03:00
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static tun_buffer_t* get_buffer_from_free_list(tap_win32_overlapped_t* const overlapped)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
tun_buffer_t* buffer = NULL;
|
2006-02-02 02:06:55 +03:00
|
|
|
WaitForSingleObject(overlapped->free_list_semaphore, INFINITE);
|
|
|
|
EnterCriticalSection(&overlapped->free_list_cs);
|
|
|
|
buffer = overlapped->free_list;
|
|
|
|
// assert(buffer != NULL);
|
|
|
|
overlapped->free_list = buffer->next;
|
|
|
|
LeaveCriticalSection(&overlapped->free_list_cs);
|
|
|
|
buffer->next = NULL;
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static void put_buffer_on_free_list(tap_win32_overlapped_t* const overlapped, tun_buffer_t* const buffer)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
|
|
|
EnterCriticalSection(&overlapped->free_list_cs);
|
|
|
|
buffer->next = overlapped->free_list;
|
|
|
|
overlapped->free_list = buffer;
|
|
|
|
LeaveCriticalSection(&overlapped->free_list_cs);
|
|
|
|
ReleaseSemaphore(overlapped->free_list_semaphore, 1, NULL);
|
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static tun_buffer_t* get_buffer_from_output_queue(tap_win32_overlapped_t* const overlapped, const int block)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
tun_buffer_t* buffer = NULL;
|
2006-02-02 02:06:55 +03:00
|
|
|
DWORD result, timeout = block ? INFINITE : 0L;
|
|
|
|
|
|
|
|
// Non-blocking call
|
2007-09-17 01:08:06 +04:00
|
|
|
result = WaitForSingleObject(overlapped->output_queue_semaphore, timeout);
|
2006-02-02 02:06:55 +03:00
|
|
|
|
2007-09-17 01:08:06 +04:00
|
|
|
switch (result)
|
|
|
|
{
|
2006-02-02 02:06:55 +03:00
|
|
|
// The semaphore object was signaled.
|
2007-09-17 01:08:06 +04:00
|
|
|
case WAIT_OBJECT_0:
|
2006-02-02 02:06:55 +03:00
|
|
|
EnterCriticalSection(&overlapped->output_queue_cs);
|
|
|
|
|
|
|
|
buffer = overlapped->output_queue_front;
|
|
|
|
overlapped->output_queue_front = buffer->next;
|
|
|
|
|
|
|
|
if(overlapped->output_queue_front == NULL) {
|
|
|
|
overlapped->output_queue_back = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&overlapped->output_queue_cs);
|
2007-09-17 01:08:06 +04:00
|
|
|
break;
|
2006-02-02 02:06:55 +03:00
|
|
|
|
|
|
|
// Semaphore was nonsignaled, so a time-out occurred.
|
2007-09-17 01:08:06 +04:00
|
|
|
case WAIT_TIMEOUT:
|
2006-02-02 02:06:55 +03:00
|
|
|
// Cannot open another window.
|
2007-09-17 01:08:06 +04:00
|
|
|
break;
|
2006-02-02 02:06:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static tun_buffer_t* get_buffer_from_output_queue_immediate (tap_win32_overlapped_t* const overlapped)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
|
|
|
return get_buffer_from_output_queue(overlapped, 0);
|
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static void put_buffer_on_output_queue(tap_win32_overlapped_t* const overlapped, tun_buffer_t* const buffer)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
|
|
|
EnterCriticalSection(&overlapped->output_queue_cs);
|
|
|
|
|
|
|
|
if(overlapped->output_queue_front == NULL && overlapped->output_queue_back == NULL) {
|
|
|
|
overlapped->output_queue_front = overlapped->output_queue_back = buffer;
|
|
|
|
} else {
|
|
|
|
buffer->next = NULL;
|
|
|
|
overlapped->output_queue_back->next = buffer;
|
|
|
|
overlapped->output_queue_back = buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&overlapped->output_queue_cs);
|
|
|
|
|
|
|
|
ReleaseSemaphore(overlapped->output_queue_semaphore, 1, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int is_tap_win32_dev(const char *guid)
|
|
|
|
{
|
|
|
|
HKEY netcard_key;
|
|
|
|
LONG status;
|
|
|
|
DWORD len;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
status = RegOpenKeyEx(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
ADAPTER_KEY,
|
|
|
|
0,
|
|
|
|
KEY_READ,
|
|
|
|
&netcard_key);
|
|
|
|
|
|
|
|
if (status != ERROR_SUCCESS) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
char enum_name[256];
|
|
|
|
char unit_string[256];
|
|
|
|
HKEY unit_key;
|
|
|
|
char component_id_string[] = "ComponentId";
|
|
|
|
char component_id[256];
|
|
|
|
char net_cfg_instance_id_string[] = "NetCfgInstanceId";
|
|
|
|
char net_cfg_instance_id[256];
|
|
|
|
DWORD data_type;
|
|
|
|
|
|
|
|
len = sizeof (enum_name);
|
|
|
|
status = RegEnumKeyEx(
|
|
|
|
netcard_key,
|
|
|
|
i,
|
|
|
|
enum_name,
|
|
|
|
&len,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (status == ERROR_NO_MORE_ITEMS)
|
|
|
|
break;
|
|
|
|
else if (status != ERROR_SUCCESS) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf (unit_string, sizeof(unit_string), "%s\\%s",
|
|
|
|
ADAPTER_KEY, enum_name);
|
|
|
|
|
|
|
|
status = RegOpenKeyEx(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
unit_string,
|
|
|
|
0,
|
|
|
|
KEY_READ,
|
|
|
|
&unit_key);
|
|
|
|
|
|
|
|
if (status != ERROR_SUCCESS) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
len = sizeof (component_id);
|
|
|
|
status = RegQueryValueEx(
|
|
|
|
unit_key,
|
|
|
|
component_id_string,
|
|
|
|
NULL,
|
|
|
|
&data_type,
|
2009-04-05 22:03:31 +04:00
|
|
|
(LPBYTE)component_id,
|
2006-02-02 02:06:55 +03:00
|
|
|
&len);
|
|
|
|
|
|
|
|
if (!(status != ERROR_SUCCESS || data_type != REG_SZ)) {
|
|
|
|
len = sizeof (net_cfg_instance_id);
|
|
|
|
status = RegQueryValueEx(
|
|
|
|
unit_key,
|
|
|
|
net_cfg_instance_id_string,
|
|
|
|
NULL,
|
|
|
|
&data_type,
|
2009-04-05 22:03:31 +04:00
|
|
|
(LPBYTE)net_cfg_instance_id,
|
2006-02-02 02:06:55 +03:00
|
|
|
&len);
|
|
|
|
|
|
|
|
if (status == ERROR_SUCCESS && data_type == REG_SZ) {
|
|
|
|
if (/* !strcmp (component_id, TAP_COMPONENT_ID) &&*/
|
|
|
|
!strcmp (net_cfg_instance_id, guid)) {
|
|
|
|
RegCloseKey (unit_key);
|
|
|
|
RegCloseKey (netcard_key);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey (unit_key);
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey (netcard_key);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int get_device_guid(
|
|
|
|
char *name,
|
|
|
|
int name_size,
|
|
|
|
char *actual_name,
|
|
|
|
int actual_name_size)
|
|
|
|
{
|
|
|
|
LONG status;
|
|
|
|
HKEY control_net_key;
|
|
|
|
DWORD len;
|
|
|
|
int i = 0;
|
|
|
|
int stop = 0;
|
|
|
|
|
|
|
|
status = RegOpenKeyEx(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
NETWORK_CONNECTIONS_KEY,
|
|
|
|
0,
|
|
|
|
KEY_READ,
|
|
|
|
&control_net_key);
|
|
|
|
|
|
|
|
if (status != ERROR_SUCCESS) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!stop)
|
|
|
|
{
|
|
|
|
char enum_name[256];
|
|
|
|
char connection_string[256];
|
|
|
|
HKEY connection_key;
|
|
|
|
char name_data[256];
|
|
|
|
DWORD name_type;
|
|
|
|
const char name_string[] = "Name";
|
|
|
|
|
|
|
|
len = sizeof (enum_name);
|
|
|
|
status = RegEnumKeyEx(
|
|
|
|
control_net_key,
|
|
|
|
i,
|
|
|
|
enum_name,
|
|
|
|
&len,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (status == ERROR_NO_MORE_ITEMS)
|
|
|
|
break;
|
|
|
|
else if (status != ERROR_SUCCESS) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-09-17 01:08:06 +04:00
|
|
|
snprintf(connection_string,
|
2006-02-02 02:06:55 +03:00
|
|
|
sizeof(connection_string),
|
|
|
|
"%s\\%s\\Connection",
|
|
|
|
NETWORK_CONNECTIONS_KEY, enum_name);
|
|
|
|
|
|
|
|
status = RegOpenKeyEx(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
connection_string,
|
|
|
|
0,
|
|
|
|
KEY_READ,
|
|
|
|
&connection_key);
|
2007-09-17 12:09:54 +04:00
|
|
|
|
2006-02-02 02:06:55 +03:00
|
|
|
if (status == ERROR_SUCCESS) {
|
|
|
|
len = sizeof (name_data);
|
|
|
|
status = RegQueryValueEx(
|
|
|
|
connection_key,
|
|
|
|
name_string,
|
|
|
|
NULL,
|
|
|
|
&name_type,
|
2009-04-05 22:03:31 +04:00
|
|
|
(LPBYTE)name_data,
|
2006-02-02 02:06:55 +03:00
|
|
|
&len);
|
|
|
|
|
|
|
|
if (status != ERROR_SUCCESS || name_type != REG_SZ) {
|
2015-11-18 22:45:08 +03:00
|
|
|
++i;
|
|
|
|
continue;
|
2006-02-02 02:06:55 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (is_tap_win32_dev(enum_name)) {
|
|
|
|
snprintf(name, name_size, "%s", enum_name);
|
|
|
|
if (actual_name) {
|
|
|
|
if (strcmp(actual_name, "") != 0) {
|
|
|
|
if (strcmp(name_data, actual_name) != 0) {
|
|
|
|
RegCloseKey (connection_key);
|
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
snprintf(actual_name, actual_name_size, "%s", name_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stop = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey (connection_key);
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey (control_net_key);
|
|
|
|
|
|
|
|
if (stop == 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tap_win32_set_status(HANDLE handle, int status)
|
|
|
|
{
|
|
|
|
unsigned long len = 0;
|
|
|
|
|
|
|
|
return DeviceIoControl(handle, TAP_IOCTL_SET_MEDIA_STATUS,
|
|
|
|
&status, sizeof (status),
|
|
|
|
&status, sizeof (status), &len, NULL);
|
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, const HANDLE handle)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
|
|
|
overlapped->handle = handle;
|
|
|
|
|
|
|
|
overlapped->read_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
|
|
overlapped->write_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
|
|
|
|
|
|
overlapped->read_overlapped.Offset = 0;
|
|
|
|
overlapped->read_overlapped.OffsetHigh = 0;
|
|
|
|
overlapped->read_overlapped.hEvent = overlapped->read_event;
|
|
|
|
|
|
|
|
overlapped->write_overlapped.Offset = 0;
|
|
|
|
overlapped->write_overlapped.OffsetHigh = 0;
|
|
|
|
overlapped->write_overlapped.hEvent = overlapped->write_event;
|
|
|
|
|
|
|
|
InitializeCriticalSection(&overlapped->output_queue_cs);
|
|
|
|
InitializeCriticalSection(&overlapped->free_list_cs);
|
|
|
|
|
2007-09-17 01:08:06 +04:00
|
|
|
overlapped->output_queue_semaphore = CreateSemaphore(
|
2006-02-02 02:06:55 +03:00
|
|
|
NULL, // default security attributes
|
|
|
|
0, // initial count
|
|
|
|
TUN_MAX_BUFFER_COUNT, // maximum count
|
|
|
|
NULL); // unnamed semaphore
|
|
|
|
|
|
|
|
if(!overlapped->output_queue_semaphore) {
|
|
|
|
fprintf(stderr, "error creating output queue semaphore!\n");
|
|
|
|
}
|
|
|
|
|
2007-09-17 01:08:06 +04:00
|
|
|
overlapped->free_list_semaphore = CreateSemaphore(
|
2006-02-02 02:06:55 +03:00
|
|
|
NULL, // default security attributes
|
|
|
|
TUN_MAX_BUFFER_COUNT, // initial count
|
|
|
|
TUN_MAX_BUFFER_COUNT, // maximum count
|
|
|
|
NULL); // unnamed semaphore
|
|
|
|
|
|
|
|
if(!overlapped->free_list_semaphore) {
|
|
|
|
fprintf(stderr, "error creating free list semaphore!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
overlapped->free_list = overlapped->output_queue_front = overlapped->output_queue_back = NULL;
|
|
|
|
|
|
|
|
{
|
|
|
|
unsigned index;
|
|
|
|
for(index = 0; index < TUN_MAX_BUFFER_COUNT; index++) {
|
2009-10-02 01:12:16 +04:00
|
|
|
tun_buffer_t* element = &overlapped->buffers[index];
|
2006-02-02 02:06:55 +03:00
|
|
|
element->next = overlapped->free_list;
|
|
|
|
overlapped->free_list = element;
|
|
|
|
}
|
|
|
|
}
|
2006-08-19 16:37:52 +04:00
|
|
|
/* To count buffers, initially no-signal. */
|
|
|
|
overlapped->tap_semaphore = CreateSemaphore(NULL, 0, TUN_MAX_BUFFER_COUNT, NULL);
|
|
|
|
if(!overlapped->tap_semaphore)
|
|
|
|
fprintf(stderr, "error creating tap_semaphore.\n");
|
2006-02-02 02:06:55 +03:00
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static int tap_win32_write(tap_win32_overlapped_t *overlapped,
|
2006-02-02 02:06:55 +03:00
|
|
|
const void *buffer, unsigned long size)
|
|
|
|
{
|
|
|
|
unsigned long write_size;
|
|
|
|
BOOL result;
|
|
|
|
DWORD error;
|
|
|
|
|
2015-11-18 22:45:09 +03:00
|
|
|
#ifdef TUN_ASYNCHRONOUS_WRITES
|
2006-02-02 02:06:55 +03:00
|
|
|
result = GetOverlappedResult( overlapped->handle, &overlapped->write_overlapped,
|
|
|
|
&write_size, FALSE);
|
|
|
|
|
|
|
|
if (!result && GetLastError() == ERROR_IO_INCOMPLETE)
|
|
|
|
WaitForSingleObject(overlapped->write_event, INFINITE);
|
2015-11-18 22:45:09 +03:00
|
|
|
#endif
|
2006-02-02 02:06:55 +03:00
|
|
|
|
|
|
|
result = WriteFile(overlapped->handle, buffer, size,
|
|
|
|
&write_size, &overlapped->write_overlapped);
|
2007-09-17 12:09:54 +04:00
|
|
|
|
2015-11-18 22:45:09 +03:00
|
|
|
#ifdef TUN_ASYNCHRONOUS_WRITES
|
|
|
|
/* FIXME: we can't sensibly set write_size here, without waiting
|
|
|
|
* for the IO to complete! Moreover, we can't return zero,
|
|
|
|
* because that will disable receive on this interface, and we
|
|
|
|
* also can't assume it will succeed and return the full size,
|
|
|
|
* because that will result in the buffer being reclaimed while
|
|
|
|
* the IO is in progress. */
|
|
|
|
#error Async writes are broken. Please disable TUN_ASYNCHRONOUS_WRITES.
|
|
|
|
#else /* !TUN_ASYNCHRONOUS_WRITES */
|
2007-09-17 01:08:06 +04:00
|
|
|
if (!result) {
|
2015-11-18 22:45:09 +03:00
|
|
|
error = GetLastError();
|
|
|
|
if (error == ERROR_IO_PENDING) {
|
|
|
|
result = GetOverlappedResult(overlapped->handle,
|
|
|
|
&overlapped->write_overlapped,
|
|
|
|
&write_size, TRUE);
|
2007-09-17 01:08:06 +04:00
|
|
|
}
|
2006-02-02 02:06:55 +03:00
|
|
|
}
|
2015-11-18 22:45:09 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
#ifdef DEBUG_TAP_WIN32
|
|
|
|
LPTSTR msgbuf;
|
|
|
|
error = GetLastError();
|
|
|
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
&msgbuf, 0, NULL);
|
|
|
|
fprintf(stderr, "Tap-Win32: Error WriteFile %d - %s\n", error, msgbuf);
|
|
|
|
LocalFree(msgbuf);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-02 02:06:55 +03:00
|
|
|
|
2011-02-21 14:47:50 +03:00
|
|
|
return write_size;
|
2006-02-02 02:06:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI tap_win32_thread_entry(LPVOID param)
|
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
tap_win32_overlapped_t *overlapped = (tap_win32_overlapped_t*)param;
|
2006-02-02 02:06:55 +03:00
|
|
|
unsigned long read_size;
|
|
|
|
BOOL result;
|
|
|
|
DWORD dwError;
|
2009-10-02 01:12:16 +04:00
|
|
|
tun_buffer_t* buffer = get_buffer_from_free_list(overlapped);
|
2006-02-02 02:06:55 +03:00
|
|
|
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
result = ReadFile(overlapped->handle,
|
|
|
|
buffer->buffer,
|
|
|
|
sizeof(buffer->buffer),
|
|
|
|
&read_size,
|
|
|
|
&overlapped->read_overlapped);
|
|
|
|
if (!result) {
|
|
|
|
dwError = GetLastError();
|
|
|
|
if (dwError == ERROR_IO_PENDING) {
|
|
|
|
WaitForSingleObject(overlapped->read_event, INFINITE);
|
|
|
|
result = GetOverlappedResult( overlapped->handle, &overlapped->read_overlapped,
|
|
|
|
&read_size, FALSE);
|
|
|
|
if (!result) {
|
2008-11-06 12:38:51 +03:00
|
|
|
#ifdef DEBUG_TAP_WIN32
|
2006-02-02 02:06:55 +03:00
|
|
|
LPVOID lpBuffer;
|
|
|
|
dwError = GetLastError();
|
|
|
|
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
(LPTSTR) & lpBuffer, 0, NULL );
|
|
|
|
fprintf(stderr, "Tap-Win32: Error GetOverlappedResult %d - %s\n", dwError, lpBuffer);
|
|
|
|
LocalFree( lpBuffer );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
} else {
|
2008-11-06 12:38:51 +03:00
|
|
|
#ifdef DEBUG_TAP_WIN32
|
2006-02-02 02:06:55 +03:00
|
|
|
LPVOID lpBuffer;
|
|
|
|
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
(LPTSTR) & lpBuffer, 0, NULL );
|
|
|
|
fprintf(stderr, "Tap-Win32: Error ReadFile %d - %s\n", dwError, lpBuffer);
|
|
|
|
LocalFree( lpBuffer );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(read_size > 0) {
|
|
|
|
buffer->read_size = read_size;
|
|
|
|
put_buffer_on_output_queue(overlapped, buffer);
|
2006-08-19 16:37:52 +04:00
|
|
|
ReleaseSemaphore(overlapped->tap_semaphore, 1, NULL);
|
2006-02-02 02:06:55 +03:00
|
|
|
buffer = get_buffer_from_free_list(overlapped);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static int tap_win32_read(tap_win32_overlapped_t *overlapped,
|
2006-02-02 02:06:55 +03:00
|
|
|
uint8_t **pbuf, int max_size)
|
|
|
|
{
|
|
|
|
int size = 0;
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
tun_buffer_t* buffer = get_buffer_from_output_queue_immediate(overlapped);
|
2006-02-02 02:06:55 +03:00
|
|
|
|
|
|
|
if(buffer != NULL) {
|
|
|
|
*pbuf = buffer->buffer;
|
|
|
|
size = (int)buffer->read_size;
|
|
|
|
if(size > max_size) {
|
|
|
|
size = max_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static void tap_win32_free_buffer(tap_win32_overlapped_t *overlapped,
|
2009-04-05 22:03:31 +04:00
|
|
|
uint8_t *pbuf)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
tun_buffer_t* buffer = (tun_buffer_t*)pbuf;
|
2006-02-02 02:06:55 +03:00
|
|
|
put_buffer_on_free_list(overlapped, buffer);
|
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static int tap_win32_open(tap_win32_overlapped_t **phandle,
|
2012-11-02 11:14:12 +04:00
|
|
|
const char *preferred_name)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
|
|
|
char device_path[256];
|
|
|
|
char device_guid[0x100];
|
|
|
|
int rc;
|
|
|
|
HANDLE handle;
|
|
|
|
BOOL bret;
|
|
|
|
char name_buffer[0x100] = {0, };
|
|
|
|
struct {
|
|
|
|
unsigned long major;
|
|
|
|
unsigned long minor;
|
|
|
|
unsigned long debug;
|
|
|
|
} version;
|
2009-04-05 22:03:31 +04:00
|
|
|
DWORD version_len;
|
2006-02-02 02:06:55 +03:00
|
|
|
DWORD idThread;
|
|
|
|
|
2012-11-02 11:14:12 +04:00
|
|
|
if (preferred_name != NULL) {
|
|
|
|
snprintf(name_buffer, sizeof(name_buffer), "%s", preferred_name);
|
|
|
|
}
|
2006-02-02 02:06:55 +03:00
|
|
|
|
|
|
|
rc = get_device_guid(device_guid, sizeof(device_guid), name_buffer, sizeof(name_buffer));
|
|
|
|
if (rc)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
snprintf (device_path, sizeof(device_path), "%s%s%s",
|
|
|
|
USERMODEDEVICEDIR,
|
|
|
|
device_guid,
|
|
|
|
TAPSUFFIX);
|
|
|
|
|
|
|
|
handle = CreateFile (
|
|
|
|
device_path,
|
|
|
|
GENERIC_READ | GENERIC_WRITE,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
OPEN_EXISTING,
|
|
|
|
FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED,
|
|
|
|
0 );
|
|
|
|
|
|
|
|
if (handle == INVALID_HANDLE_VALUE) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bret = DeviceIoControl(handle, TAP_IOCTL_GET_VERSION,
|
|
|
|
&version, sizeof (version),
|
|
|
|
&version, sizeof (version), &version_len, NULL);
|
|
|
|
|
|
|
|
if (bret == FALSE) {
|
|
|
|
CloseHandle(handle);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tap_win32_set_status(handle, TRUE)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
tap_win32_overlapped_init(&tap_overlapped, handle);
|
|
|
|
|
|
|
|
*phandle = &tap_overlapped;
|
|
|
|
|
2010-10-13 22:41:29 +04:00
|
|
|
CreateThread(NULL, 0, tap_win32_thread_entry,
|
|
|
|
(LPVOID)&tap_overlapped, 0, &idThread);
|
2006-02-02 02:06:55 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************/
|
|
|
|
|
|
|
|
typedef struct TAPState {
|
2012-07-24 19:35:13 +04:00
|
|
|
NetClientState nc;
|
2009-10-02 01:12:16 +04:00
|
|
|
tap_win32_overlapped_t *handle;
|
2006-02-02 02:06:55 +03:00
|
|
|
} TAPState;
|
|
|
|
|
2012-07-24 19:35:13 +04:00
|
|
|
static void tap_cleanup(NetClientState *nc)
|
2009-04-17 21:11:08 +04:00
|
|
|
{
|
2009-11-25 21:49:05 +03:00
|
|
|
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
2009-04-17 21:11:08 +04:00
|
|
|
|
|
|
|
qemu_del_wait_object(s->handle->tap_semaphore, NULL, NULL);
|
|
|
|
|
|
|
|
/* FIXME: need to kill thread and close file handle:
|
|
|
|
tap_win32_close(s);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2012-07-24 19:35:13 +04:00
|
|
|
static ssize_t tap_receive(NetClientState *nc, const uint8_t *buf, size_t size)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
2009-11-25 21:49:05 +03:00
|
|
|
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
2006-02-02 02:06:55 +03:00
|
|
|
|
2009-05-18 16:40:55 +04:00
|
|
|
return tap_win32_write(s->handle, buf, size);
|
2006-02-02 02:06:55 +03:00
|
|
|
}
|
|
|
|
|
2006-08-19 16:37:52 +04:00
|
|
|
static void tap_win32_send(void *opaque)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
2006-08-19 16:37:52 +04:00
|
|
|
TAPState *s = opaque;
|
2006-02-02 02:06:55 +03:00
|
|
|
uint8_t *buf;
|
|
|
|
int max_size = 4096;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
size = tap_win32_read(s->handle, &buf, max_size);
|
|
|
|
if (size > 0) {
|
2009-11-25 21:49:05 +03:00
|
|
|
qemu_send_packet(&s->nc, buf, size);
|
2006-02-02 02:06:55 +03:00
|
|
|
tap_win32_free_buffer(s->handle, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-06 20:02:19 +04:00
|
|
|
static bool tap_has_ufo(NetClientState *nc)
|
2014-02-06 20:02:17 +04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-06 20:02:19 +04:00
|
|
|
static bool tap_has_vnet_hdr(NetClientState *nc)
|
2014-02-06 20:02:17 +04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tap_probe_vnet_hdr_len(int fd, int len)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tap_fd_set_vnet_hdr_len(int fd, int len)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-06-18 17:52:23 +03:00
|
|
|
int tap_fd_set_vnet_le(int fd, int is_le)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tap_fd_set_vnet_be(int fd, int is_be)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-02-06 20:02:19 +04:00
|
|
|
static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr)
|
2014-02-06 20:02:17 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-06 20:02:19 +04:00
|
|
|
static void tap_set_offload(NetClientState *nc, int csum, int tso4,
|
2014-02-06 20:02:17 +04:00
|
|
|
int tso6, int ecn, int ufo)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
struct vhost_net *tap_get_vhost_net(NetClientState *nc)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-02-06 20:02:19 +04:00
|
|
|
static bool tap_has_vnet_hdr_len(NetClientState *nc, int len)
|
2014-02-06 20:02:17 +04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-06 20:02:19 +04:00
|
|
|
static void tap_set_vnet_hdr_len(NetClientState *nc, int len)
|
2014-02-06 20:02:17 +04:00
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2009-11-25 21:49:05 +03:00
|
|
|
static NetClientInfo net_tap_win32_info = {
|
2012-07-17 18:17:12 +04:00
|
|
|
.type = NET_CLIENT_OPTIONS_KIND_TAP,
|
2009-11-25 21:49:05 +03:00
|
|
|
.size = sizeof(TAPState),
|
|
|
|
.receive = tap_receive,
|
|
|
|
.cleanup = tap_cleanup,
|
2014-02-06 20:02:17 +04:00
|
|
|
.has_ufo = tap_has_ufo,
|
|
|
|
.has_vnet_hdr = tap_has_vnet_hdr,
|
|
|
|
.has_vnet_hdr_len = tap_has_vnet_hdr_len,
|
|
|
|
.using_vnet_hdr = tap_using_vnet_hdr,
|
|
|
|
.set_offload = tap_set_offload,
|
|
|
|
.set_vnet_hdr_len = tap_set_vnet_hdr_len,
|
2009-11-25 21:49:05 +03:00
|
|
|
};
|
|
|
|
|
2012-07-24 19:35:13 +04:00
|
|
|
static int tap_win32_init(NetClientState *peer, const char *model,
|
2009-10-22 20:49:05 +04:00
|
|
|
const char *name, const char *ifname)
|
2006-02-02 02:06:55 +03:00
|
|
|
{
|
2012-07-24 19:35:13 +04:00
|
|
|
NetClientState *nc;
|
2006-02-02 02:06:55 +03:00
|
|
|
TAPState *s;
|
2009-11-25 21:49:05 +03:00
|
|
|
tap_win32_overlapped_t *handle;
|
2007-09-17 12:09:54 +04:00
|
|
|
|
2009-11-25 21:49:05 +03:00
|
|
|
if (tap_win32_open(&handle, ifname) < 0) {
|
2006-02-02 02:06:55 +03:00
|
|
|
printf("tap: Could not open '%s'\n", ifname);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-07-24 19:35:08 +04:00
|
|
|
nc = qemu_new_net_client(&net_tap_win32_info, peer, model, name);
|
2007-09-17 12:09:54 +04:00
|
|
|
|
2009-12-04 21:06:20 +03:00
|
|
|
s = DO_UPCAST(TAPState, nc, nc);
|
|
|
|
|
2009-11-25 21:49:05 +03:00
|
|
|
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
2006-02-02 02:06:55 +03:00
|
|
|
"tap: ifname=%s", ifname);
|
2006-06-25 21:18:27 +04:00
|
|
|
|
2009-11-25 21:49:05 +03:00
|
|
|
s->handle = handle;
|
|
|
|
|
2006-08-19 16:37:52 +04:00
|
|
|
qemu_add_wait_object(s->handle->tap_semaphore, tap_win32_send, s);
|
2009-11-25 21:49:05 +03:00
|
|
|
|
2006-02-02 02:06:55 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2009-10-22 20:49:05 +04:00
|
|
|
|
2012-07-17 18:17:21 +04:00
|
|
|
int net_init_tap(const NetClientOptions *opts, const char *name,
|
2015-05-15 14:58:50 +03:00
|
|
|
NetClientState *peer, Error **errp)
|
2009-10-22 20:49:05 +04:00
|
|
|
{
|
2015-05-15 14:58:50 +03:00
|
|
|
/* FIXME error_setg(errp, ...) on failure */
|
2012-07-17 18:17:19 +04:00
|
|
|
const NetdevTapOptions *tap;
|
2009-10-22 20:49:05 +04:00
|
|
|
|
2015-10-27 01:34:56 +03:00
|
|
|
assert(opts->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type(). But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:
| struct q_obj_ImageInfoSpecificQCow2_wrapper {
| ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
| ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
| ImageInfoSpecificKind type;
| union { /* union tag is @type */
| void *data;
|- ImageInfoSpecificQCow2 *qcow2;
|- ImageInfoSpecificVmdk *vmdk;
|+ q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+ q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
| } u;
| };
Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation). Using the implicit type
also lets us get rid of the simple_union_type() hack.
Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access. The generated
qapi-visit.c code is also affected by the layout change:
|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
| }
| switch (obj->type) {
| case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|- visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+ visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
| break;
| case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|- visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+ visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
| break;
| default:
| abort();
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 01:48:37 +03:00
|
|
|
tap = opts->u.tap.data;
|
2009-10-22 20:49:05 +04:00
|
|
|
|
2012-07-17 18:17:19 +04:00
|
|
|
if (!tap->has_ifname) {
|
2010-02-18 19:25:24 +03:00
|
|
|
error_report("tap: no interface name");
|
2009-10-22 20:49:05 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-07-24 19:35:05 +04:00
|
|
|
if (tap_win32_init(peer, "tap", name, tap->ifname) == -1) {
|
2009-10-22 20:49:05 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-30 15:12:32 +04:00
|
|
|
int tap_enable(NetClientState *nc)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
int tap_disable(NetClientState *nc)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|