From: VMware, Inc <> Date: Thu, 17 Jun 2010 22:31:25 +0000 (-0700) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2010.06.16-268169~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f3ab1d3be7268994a4c1687dcdd2df2a11aaf02;p=thirdparty%2Fopen-vm-tools.git Changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/modules/shared/vmxnet/net.h b/open-vm-tools/modules/shared/vmxnet/net.h index aa3b92e16..82a8ce1e4 100644 --- a/open-vm-tools/modules/shared/vmxnet/net.h +++ b/open-vm-tools/modules/shared/vmxnet/net.h @@ -46,10 +46,17 @@ #define INCLUDE_ALLOW_USERLEVEL #define INCLUDE_ALLOW_MODULE +#define INCLUDE_ALLOW_VMCORE #include "includeCheck.h" #include "vm_device_version.h" +#ifdef USERLEVEL +#include "config.h" +#include "str.h" +#include "strutil.h" +#endif + #define ETHERNET_MTU 1518 #define ETH_MIN_FRAME_LEN 60 @@ -85,6 +92,13 @@ #define MORPH_PORT_SIZE 4 +typedef struct Net_AdapterCount { + uint8 vlance; + uint8 vmxnet2; + uint8 vmxnet3; + uint8 e1000; + uint8 e1000e; +} Net_AdapterCount; #ifdef USERLEVEL @@ -145,6 +159,59 @@ Net_AddAddrToLadrf(const uint8 *addr, // IN: pointer to MAC address ladrf[hashcode >> 3] |= 1 << (hashcode & 0x07); } + +/* + *---------------------------------------------------------------------- + * + * Net_GetNumAdapters -- + * + * Returns the number of each type of network adapter configured in this + * VM. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static INLINE void +Net_GetNumAdapters(Net_AdapterCount *counts) +{ + uint32 i; + + counts->vlance = 0; + counts->vmxnet2 = 0; + counts->vmxnet3 = 0; + counts->e1000 = 0; + counts->e1000e = 0; + + for (i = 0; i < MAX_ETHERNET_CARDS; i++) { + char* adapterStr; + + if (!Config_GetBool(FALSE, "ethernet%d.present", i)) { + continue; + } + adapterStr = Config_GetString("vlance", "ethernet%d.virtualDev", i); + if (Str_Strcasecmp(adapterStr, "vmxnet3") == 0) { + counts->vmxnet3++; + } else if (Str_Strcasecmp(adapterStr, "vlance") == 0) { + counts->vlance++; + } else if (Str_Strcasecmp(adapterStr, "vmxnet") == 0) { + counts->vmxnet2++; + } else if (Str_Strcasecmp(adapterStr, "e1000") == 0) { + counts->e1000++; + } else if (Str_Strcasecmp(adapterStr, "e1000e") == 0) { + counts->e1000e++; + } else { + LOG_ONCE(("%s: unknown adapter: %s\n", __FUNCTION__, adapterStr)); + } + free(adapterStr); + } +} + #endif // USERLEVEL #endif // VMWARE_DEVICES_NET_H