# Old manifest: 794900d596312ebb885ce06d5afbb62dc04f4923 # New manifest: fd68d6e1eb48666b7e471cb121be7213ac54c09d # Summary of changes: # # add ./src/colinux/os/winnt/user/conet-bridged-daemon/pcap-registry.h # as e9262a302da3662f506033ba947dc106c5e366b1 # # patch ./ChangeLog # from b90abc35f14b3dedad338be7e8c2a94bf7d2a2a3 # to 9f8aa92ea7d28763e3965f205d37797b483c457f # # patch ./src/colinux/os/winnt/user/conet-bridged-daemon/main.c # from 539dc14941f1120be80fb24c9ee2a7278b8b6ab9 # to 4f19ae83b73247635ff774aab9bc31ad374693f8 # --- ./src/colinux/os/winnt/user/conet-bridged-daemon/pcap-registry.h +++ ./src/colinux/os/winnt/user/conet-bridged-daemon/pcap-registry.h @@ -0,0 +1,35 @@ +/* + * Registry -- Registry keys and values commonly used in the TAP-Win32 & PCAP + * drivers. Loosely based/borrowed from TAP-Win32/common.h + * + * 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 + * distribution); if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +//================= +// 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}" + --- ./ChangeLog +++ ./ChangeLog @@ -1,3 +1,9 @@ +Thu Jun 10 10:58:13 2004 George Boutwell + + * src/colinux/os/winnt/user/conet-bridged-daemon/pcap-registry.h + * src/colinux/os/winnt/user/conet-bridged-daemon/main.c: + Added pcap-registry.h, changed PCAP handling to use Connection Name instead of Adapter/Device/Driver name. Name is now uniform between PCAP & TAP and multiple devices of the same/make/model should be able to be connected to. + Sat May 29 16:15:04 2004 Dan Aloni * src/colinux/os/winnt/user/daemon/service.c (co_winnt_daemon_install_as_service): --- ./src/colinux/os/winnt/user/conet-bridged-daemon/main.c +++ ./src/colinux/os/winnt/user/conet-bridged-daemon/main.c @@ -18,6 +18,7 @@ #include #include #include "../daemon.h" +#include "pcap-registry.h" /* * IMPORTANT NOTE: @@ -26,8 +27,14 @@ * to work against coLinux0. Expect changes. * */ + /******************************************************************************* + * Defines + */ +#define PCAP_NAME_HDR "\\Device\\NPF_" + +/******************************************************************************* * Type Declarations */ @@ -295,6 +301,60 @@ } /******************************************************************************* + * Get the Connection name for an PCAP Interface (using NetCfgInstanceId). + */ +co_rc_t get_device_name(char *name, + int name_size, + char *actual_name, + int actual_name_size) +{ + char connection_string[256]; + HKEY connection_key; + char name_data[256]; + DWORD name_type; + const char name_string[] = "Name"; + LONG status; + DWORD len; + + snprintf(connection_string, + sizeof(connection_string), + "%s\\%s\\Connection", + NETWORK_CONNECTIONS_KEY, name); + + status = RegOpenKeyEx( + HKEY_LOCAL_MACHINE, + connection_string, + 0, + KEY_READ, + &connection_key); + + if (status == ERROR_SUCCESS) { + len = sizeof(name_data); + status = RegQueryValueEx( + connection_key, + name_string, + NULL, + &name_type, + name_data, + &len); + if (status != ERROR_SUCCESS || name_type != REG_SZ) { + printf("Error opening registry key: %s\\%s\\%s", NETWORK_CONNECTIONS_KEY, connection_string, name_string); + return CO_RC(ERROR); + } + else { + if (name_data) { + snprintf(actual_name, actual_name_size, "%s", name_data); + } + } + + RegCloseKey(connection_key); + + } + + return CO_RC(OK); +} + +/******************************************************************************* * Initialize winPCap interface. */ int @@ -321,15 +375,29 @@ } device = alldevs; + char name_data[256]; + char connection_name_data[256]; while (device) { - co_debug("bridged-net-daemon: Checking adapter: %s\n", device->description); + + memset(connection_name_data, 0, sizeof(connection_name_data)); if (daemon_parameters->name_specified == PFALSE) break; - - if (strstr(device->description, daemon_parameters->interface_name) != NULL) - break; + snprintf(name_data, sizeof(name_data), "%s", device->name+(sizeof(PCAP_NAME_HDR) - 1)); + + get_device_name(name_data, sizeof(name_data), + connection_name_data, sizeof(connection_name_data)); + if (strcmp(connection_name_data, "") != 0) { + co_debug("bridged-net-daemon: Checking connection: %s\n", connection_name_data); + + if (strstr(connection_name_data, daemon_parameters->interface_name) != NULL) + break; + } + else { + co_debug("briged-net-daemon: Adapter %s doesn't have a connection\n", device->description); + } + device = device->next; }