X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=tap-win32.c;h=3ff957fe699b7484190edf4e1150f97fb4f5e2ac;hb=d33a1810d7f558dd1d486bc84f1cf8f96c982e2d;hp=bfec14578a51c23286215d3f53c018372c60d67e;hpb=4fddf62a74c26f8da3c5ee61600e4d61052b0610;p=qemu diff --git a/tap-win32.c b/tap-win32.c index bfec145..3ff957f 100644 --- a/tap-win32.c +++ b/tap-win32.c @@ -24,13 +24,12 @@ * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING included with this * distribution); if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "qemu-common.h" #include "net.h" #include "sysemu.h" #include -#define WIN32_LEAN_AND_MEAN #include /* NOTE: PCIBus is redefined in winddk.h */ @@ -77,7 +76,7 @@ // Compile time configuration //====================== -//#define DEBUG_TAP_WIN32 1 +//#define DEBUG_TAP_WIN32 #define TUN_ASYNCHRONOUS_WRITES 1 @@ -255,7 +254,7 @@ static int is_tap_win32_dev(const char *guid) component_id_string, NULL, &data_type, - component_id, + (LPBYTE)component_id, &len); if (!(status != ERROR_SUCCESS || data_type != REG_SZ)) { @@ -265,7 +264,7 @@ static int is_tap_win32_dev(const char *guid) net_cfg_instance_id_string, NULL, &data_type, - net_cfg_instance_id, + (LPBYTE)net_cfg_instance_id, &len); if (status == ERROR_SUCCESS && data_type == REG_SZ) { @@ -354,7 +353,7 @@ static int get_device_guid( name_string, NULL, &name_type, - name_data, + (LPBYTE)name_data, &len); if (status != ERROR_SUCCESS || name_type != REG_SZ) { @@ -509,7 +508,7 @@ static DWORD WINAPI tap_win32_thread_entry(LPVOID param) result = GetOverlappedResult( overlapped->handle, &overlapped->read_overlapped, &read_size, FALSE); if (!result) { -#if DEBUG_TAP_WIN32 +#ifdef DEBUG_TAP_WIN32 LPVOID lpBuffer; dwError = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, @@ -520,7 +519,7 @@ static DWORD WINAPI tap_win32_thread_entry(LPVOID param) #endif } } else { -#if DEBUG_TAP_WIN32 +#ifdef DEBUG_TAP_WIN32 LPVOID lpBuffer; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), @@ -561,7 +560,7 @@ static int tap_win32_read(tap_win32_overlapped_t *overlapped, } static void tap_win32_free_buffer(tap_win32_overlapped_t *overlapped, - char* pbuf) + uint8_t *pbuf) { tun_buffer_t* buffer = (tun_buffer_t*)pbuf; put_buffer_on_free_list(overlapped, buffer); @@ -581,7 +580,7 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle, unsigned long minor; unsigned long debug; } version; - LONG version_len; + DWORD version_len; DWORD idThread; HANDLE hThread; @@ -639,6 +638,18 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle, tap_win32_overlapped_t *handle; } TAPState; +static void tap_cleanup(VLANClientState *vc) +{ + TAPState *s = vc->opaque; + + qemu_del_wait_object(s->handle->tap_semaphore, NULL, NULL); + + /* FIXME: need to kill thread and close file handle: + tap_win32_close(s); + */ + qemu_free(s); +} + static void tap_receive(void *opaque, const uint8_t *buf, int size) { TAPState *s = opaque; @@ -660,7 +671,8 @@ static void tap_win32_send(void *opaque) } } -int tap_win32_init(VLANState *vlan, const char *ifname) +int tap_win32_init(VLANState *vlan, const char *model, + const char *name, const char *ifname) { TAPState *s; @@ -672,7 +684,8 @@ int tap_win32_init(VLANState *vlan, const char *ifname) return -1; } - s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s); + s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive, + NULL, tap_cleanup, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: ifname=%s", ifname);