diff options
Diffstat (limited to 'mysys/my_gethwaddr.c')
-rw-r--r-- | mysys/my_gethwaddr.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c index 38fa0313c5d..c6a7af58f57 100644 --- a/mysys/my_gethwaddr.c +++ b/mysys/my_gethwaddr.c @@ -102,47 +102,49 @@ err: } #elif defined(__WIN__) -
-/* Workaround for BUG#32082 (Definition of VOID in my_global.h conflicts with
-windows headers) */
-#ifdef VOID
-#undef VOID
-#define VOID void
-#endif
+ +/* + Workaround for BUG#32082 (Definition of VOID in my_global.h conflicts with + windows headers) +*/ +#ifdef VOID +#undef VOID +#define VOID void +#endif #include <iphlpapi.h> -/* - The following typedef is for dynamically loading - iphlpapi.dll / GetAdaptersAddresses. Dynamic loading is - used because GetAdaptersAddresses is not available on Windows 2000 - which MySQL still supports. Static linking would cause an unresolved export. +/* + The following typedef is for dynamically loading iphlpapi.dll / + GetAdaptersAddresses. Dynamic loading is used because + GetAdaptersAddresses is not available on Windows 2000 which MySQL + still supports. Static linking would cause an unresolved export. */ typedef DWORD (WINAPI *pfnGetAdaptersAddresses)(IN ULONG Family, IN DWORD Flags,IN PVOID Reserved, - OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses, + OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses, IN OUT PULONG pOutBufLen); /* - my_gethwaddr - Windows version + my_gethwaddr - Windows version @brief Retrieve MAC address from network hardware - + @param[out] to MAC address exactly six bytes - + @return Operation status @retval 0 OK - @retval <>0 FAILED + @retval <>0 FAILED */ my_bool my_gethwaddr(uchar *to) -{ +{ PIP_ADAPTER_ADDRESSES pAdapterAddresses; PIP_ADAPTER_ADDRESSES pCurrAddresses; IP_ADAPTER_ADDRESSES adapterAddresses; ULONG address_len; - my_bool return_val= 1; - static pfnGetAdaptersAddresses fnGetAdaptersAddresses= - (pfnGetAdaptersAddresses)-1; + my_bool return_val= 1; + static pfnGetAdaptersAddresses fnGetAdaptersAddresses= + (pfnGetAdaptersAddresses)-1; if(fnGetAdaptersAddresses == (pfnGetAdaptersAddresses)-1) { @@ -156,7 +158,7 @@ my_bool my_gethwaddr(uchar *to) address_len= sizeof (IP_ADAPTER_ADDRESSES); /* Get the required size for the address data. */ - if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, &adapterAddresses, &address_len) + if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, &adapterAddresses, &address_len) == ERROR_BUFFER_OVERFLOW) { pAdapterAddresses= my_malloc(address_len, 0); @@ -167,29 +169,29 @@ my_bool my_gethwaddr(uchar *to) pAdapterAddresses= &adapterAddresses; /* one is enough don't alloc */ /* Get the hardware info. */ - if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &address_len) + if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &address_len) == NO_ERROR) { pCurrAddresses= pAdapterAddresses; - while (pCurrAddresses) + while (pCurrAddresses) { /* Look for ethernet cards. */ if (pCurrAddresses->IfType == IF_TYPE_ETHERNET_CSMACD) { /* check for a good address */ if (pCurrAddresses->PhysicalAddressLength < 6) - continue; /* bad address */ + continue; /* bad address */ /* save 6 bytes of the address in the 'to' parameter */ memcpy(to, pCurrAddresses->PhysicalAddress, 6); /* Network card found, we're done. */ return_val= 0; - break; + break; } pCurrAddresses= pCurrAddresses->Next; - } + } } /* Clean up memory allocation. */ |