summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorEli Linden <eli@lindenlab.com>2010-04-07 10:27:10 -0700
committerEli Linden <eli@lindenlab.com>2010-04-07 10:27:10 -0700
commitde62c3378171a69ff9a39f2f626f1b1d33d0763f (patch)
tree053883ba8ae6d02460736ed8a786f1913761b00d /indra/llcommon
parent25df7aca29074b6ae7f108c91673be117522bfc9 (diff)
parent3ecec85feb4e9878b32f5737ab8e35747360f138 (diff)
Merge
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/lluri.cpp3
-rw-r--r--indra/llcommon/lluuid.cpp162
2 files changed, 63 insertions, 102 deletions
diff --git a/indra/llcommon/lluri.cpp b/indra/llcommon/lluri.cpp
index 0e8f3f0f73..9d4f3a98f0 100644
--- a/indra/llcommon/lluri.cpp
+++ b/indra/llcommon/lluri.cpp
@@ -231,8 +231,7 @@ static BOOL isDefault(const std::string& scheme, U16 port)
void LLURI::parseAuthorityAndPathUsingOpaque()
{
if (mScheme == "http" || mScheme == "https" ||
- mScheme == "ftp" || mScheme == "secondlife" ||
- mScheme == "x-grid-location-info")
+ mScheme == "ftp" || mScheme == "secondlife" )
{
if (mEscapedOpaque.substr(0,2) != "//")
{
diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp
index 583c1e589b..bcbae06ec5 100644
--- a/indra/llcommon/lluuid.cpp
+++ b/indra/llcommon/lluuid.cpp
@@ -33,12 +33,9 @@
// We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes.
#if LL_WINDOWS
-#undef WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-#include <windows.h>
-// ugh, this is ugly. We need to straighten out our linking for this library
-#pragma comment(lib, "IPHLPAPI.lib")
-#include <iphlpapi.h>
+# undef WIN32_LEAN_AND_MEAN
+# include <winsock2.h>
+# include <windows.h>
#endif
#include "lldefs.h"
@@ -455,102 +452,67 @@ static void get_random_bytes(void *buf, int nbytes)
return;
}
-#if LL_WINDOWS
-// Code copied from http://msdn.microsoft.com/en-us/library/aa365939(VS.85).aspx
-// This code grabs the first hardware address, rather than the first interface.
-// Using a VPN can cause the first returned interface to be changed.
-
-const S32 MAC_ADDRESS_BYTES=6;
-
-
-// static
-S32 LLUUID::getNodeID(unsigned char *node_id)
+#if LL_WINDOWS
+typedef struct _ASTAT_
{
+ ADAPTER_STATUS adapt;
+ NAME_BUFFER NameBuff [30];
+}ASTAT, * PASTAT;
- // Declare and initialize variables.
- DWORD dwSize = 0;
- DWORD dwRetVal = 0;
- int i;
-
-/* variables used for GetIfTable and GetIfEntry */
- MIB_IFTABLE *pIfTable;
- MIB_IFROW *pIfRow;
-
- // Allocate memory for our pointers.
- pIfTable = (MIB_IFTABLE *) malloc(sizeof (MIB_IFTABLE));
- if (pIfTable == NULL)
- {
- printf("Error allocating memory needed to call GetIfTable\n");
- return 0;
- }
-
- // Before calling GetIfEntry, we call GetIfTable to make
- // sure there are entries to get and retrieve the interface index.
-
- // Make an initial call to GetIfTable to get the
- // necessary size into dwSize
- if (GetIfTable(pIfTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
- free(pIfTable);
- pIfTable = (MIB_IFTABLE *) malloc(dwSize);
- if (pIfTable == NULL)
- {
- printf("Error allocating memory\n");
- return 0;
- }
- }
- // Make a second call to GetIfTable to get the actual
- // data we want.
- if ((dwRetVal = GetIfTable(pIfTable, &dwSize, 0)) == NO_ERROR)
- {
- if (pIfTable->dwNumEntries > 0)
- {
- pIfRow = (MIB_IFROW *) malloc(sizeof (MIB_IFROW));
- if (pIfRow == NULL)
- {
- printf("Error allocating memory\n");
- if (pIfTable != NULL)
- {
- free(pIfTable);
- pIfTable = NULL;
- }
- return 0;
- }
-
- int limit = MAC_ADDRESS_BYTES;
- memcpy(node_id, "\0\0\0\0\0\0", limit); // zero out array of bytes
- for (i = 0; i < (int) pIfTable->dwNumEntries; i++)
- {
- pIfRow->dwIndex = pIfTable->table[i].dwIndex;
- if ((dwRetVal = GetIfEntry(pIfRow)) == NO_ERROR)
- {
- switch (pIfRow->dwType)
- {
- case IF_TYPE_ETHERNET_CSMACD:
- case IF_TYPE_IEEE80211:
- limit = min((int) pIfRow->dwPhysAddrLen, limit);
- if (pIfRow->dwPhysAddrLen == 0)
- break;
- memcpy(node_id, (UCHAR *)&pIfRow->bPhysAddr[0], limit); // just incase the PhysAddr is not the expected MAC_Address size
- free(pIfTable);
- return 1; //return first hardware device found.
- break;
-
- case IF_TYPE_OTHER:
- case IF_TYPE_PPP:
- case IF_TYPE_SOFTWARE_LOOPBACK:
- case IF_TYPE_ISO88025_TOKENRING:
- case IF_TYPE_IEEE1394:
- case IF_TYPE_ATM:
- case IF_TYPE_TUNNEL:
- default:
- break;
- }
- }
- }
- }
- }
- free(pIfTable);
- return 0;
+// static
+S32 LLUUID::getNodeID(unsigned char * node_id)
+{
+ ASTAT Adapter;
+ NCB Ncb;
+ UCHAR uRetCode;
+ LANA_ENUM lenum;
+ int i;
+ int retval = 0;
+
+ memset( &Ncb, 0, sizeof(Ncb) );
+ Ncb.ncb_command = NCBENUM;
+ Ncb.ncb_buffer = (UCHAR *)&lenum;
+ Ncb.ncb_length = sizeof(lenum);
+ uRetCode = Netbios( &Ncb );
+ // printf( "The NCBENUM return code is: 0x%x \n", uRetCode );
+
+ for(i=0; i < lenum.length ;i++)
+ {
+ memset( &Ncb, 0, sizeof(Ncb) );
+ Ncb.ncb_command = NCBRESET;
+ Ncb.ncb_lana_num = lenum.lana[i];
+
+ uRetCode = Netbios( &Ncb );
+ // printf( "The NCBRESET on LANA %d return code is: 0x%x \n",
+ // lenum.lana[i], uRetCode );
+
+ memset( &Ncb, 0, sizeof (Ncb) );
+ Ncb.ncb_command = NCBASTAT;
+ Ncb.ncb_lana_num = lenum.lana[i];
+
+ strcpy( (char *)Ncb.ncb_callname, "* " ); /* Flawfinder: ignore */
+ Ncb.ncb_buffer = (unsigned char *)&Adapter;
+ Ncb.ncb_length = sizeof(Adapter);
+
+ uRetCode = Netbios( &Ncb );
+// printf( "The NCBASTAT on LANA %d return code is: 0x%x \n",
+// lenum.lana[i], uRetCode );
+ if ( uRetCode == 0 )
+ {
+// printf( "The Ethernet Number on LANA %d is: %02x%02x%02x%02x%02x%02x\n",
+// lenum.lana[i],
+// Adapter.adapt.adapter_address[0],
+// Adapter.adapt.adapter_address[1],
+// Adapter.adapt.adapter_address[2],
+// Adapter.adapt.adapter_address[3],
+// Adapter.adapt.adapter_address[4],
+// Adapter.adapt.adapter_address[5] );
+ memcpy(node_id,Adapter.adapt.adapter_address,6); /* Flawfinder: ignore */
+ retval = 1;
+
+ }
+ }
+ return retval;
}
#elif LL_DARWIN