Skip to content
Snippets Groups Projects
Commit 2cb9ffc4 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Make NetBios go away.

parent 94a31ec3
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,6 @@ if (WINDOWS) ...@@ -65,7 +65,6 @@ if (WINDOWS)
mswsock mswsock
psapi psapi
winmm winmm
netapi32
wldap32 wldap32
gdi32 gdi32
user32 user32
......
...@@ -5,7 +5,6 @@ if (WINDOWS) ...@@ -5,7 +5,6 @@ if (WINDOWS)
wsock32 wsock32
ws2_32 ws2_32
psapi psapi
netapi32
advapi32 advapi32
user32 user32
) )
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
// We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes. // We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes.
#if LL_WINDOWS #if LL_WINDOWS
#include "llwin32headers.h" #include "llwin32headerslean.h"
// ugh, this is ugly. We need to straighten out our linking for this library // ugh, this is ugly. We need to straighten out our linking for this library
#pragma comment(lib, "IPHLPAPI.lib") #pragma comment(lib, "IPHLPAPI.lib")
#include <iphlpapi.h> #include <iphlpapi.h>
...@@ -456,51 +456,88 @@ static void get_random_bytes(void *buf, int nbytes) ...@@ -456,51 +456,88 @@ static void get_random_bytes(void *buf, int nbytes)
#if LL_WINDOWS #if LL_WINDOWS
typedef struct _ASTAT_
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff [30];
}ASTAT, * PASTAT;
// static // static
S32 LLUUID::getNodeID(unsigned char *node_id) S32 LLUUID::getNodeID(unsigned char *node_id)
{ {
ASTAT Adapter; static bool got_node_id = false;
NCB Ncb; static unsigned char local_node_id[6];
UCHAR uRetCode; if (got_node_id)
LANA_ENUM lenum; {
int i; memcpy(node_id, local_node_id, sizeof(local_node_id));
int retval = 0; return 1;
}
memset( &Ncb, 0, sizeof(Ncb) ); S32 retval = 0;
Ncb.ncb_command = NCBENUM; PIP_ADAPTER_ADDRESSES pAddresses = nullptr;
Ncb.ncb_buffer = (UCHAR *)&lenum; ULONG outBufLen = 0U;
Ncb.ncb_length = sizeof(lenum); DWORD dwRetVal = 0U;
uRetCode = Netbios( &Ncb );
for(i=0; i < lenum.length ;i++) ULONG family = AF_INET;
{ ULONG flags = GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_INCLUDE_GATEWAYS;
memset( &Ncb, 0, sizeof(Ncb) );
Ncb.ncb_command = NCBRESET;
Ncb.ncb_lana_num = lenum.lana[i];
uRetCode = Netbios( &Ncb ); GetAdaptersAddresses(
AF_INET,
flags,
nullptr,
nullptr,
&outBufLen);
memset( &Ncb, 0, sizeof (Ncb) ); constexpr U32 MAX_TRIES = 3U;
Ncb.ncb_command = NCBASTAT; U32 iteration = 0U;
Ncb.ncb_lana_num = lenum.lana[i]; do {
strcpy( (char *)Ncb.ncb_callname, "* " ); /* Flawfinder: ignore */ pAddresses = reinterpret_cast<PIP_ADAPTER_ADDRESSES>(malloc(outBufLen));
Ncb.ncb_buffer = (unsigned char *)&Adapter; if (pAddresses == nullptr) {
Ncb.ncb_length = sizeof(Adapter); return 0;
}
uRetCode = Netbios( &Ncb ); dwRetVal =
if ( uRetCode == 0 ) GetAdaptersAddresses(family, flags, nullptr, pAddresses, &outBufLen);
{
memcpy(node_id,Adapter.adapt.adapter_address,6); /* Flawfinder: ignore */ if (dwRetVal == ERROR_BUFFER_OVERFLOW) {
retval = 1; free(pAddresses);
pAddresses = nullptr;
} }
else {
break;
}
++iteration;
} while ((dwRetVal == ERROR_BUFFER_OVERFLOW) && (iteration < MAX_TRIES));
if (dwRetVal == NO_ERROR)
{
PIP_ADAPTER_ADDRESSES pCurrAddresses = pAddresses;
PIP_ADAPTER_GATEWAY_ADDRESS pFirstGateway = nullptr;
do {
pFirstGateway = pCurrAddresses->FirstGatewayAddress;
if (pFirstGateway)
{
if ((pCurrAddresses->IfType == IF_TYPE_ETHERNET_CSMACD || pCurrAddresses->IfType == IF_TYPE_IEEE80211) && pCurrAddresses->ConnectionType == NET_IF_CONNECTION_DEDICATED
&& pCurrAddresses->OperStatus == IfOperStatusUp)
{
if (pCurrAddresses->PhysicalAddressLength == 6)
{
for (size_t i = 0; i < 5; ++i)
{
node_id[i] = pCurrAddresses->PhysicalAddress[i];
local_node_id[i] = pCurrAddresses->PhysicalAddress[i];
}
retval = 1;
got_node_id = true;
break;
}
}
}
pCurrAddresses = pCurrAddresses->Next;
} while (pCurrAddresses); // Terminate if last adapter
} }
if(pAddresses)
free(pAddresses);
pAddresses = nullptr;
return retval; return retval;
} }
...@@ -892,7 +929,9 @@ U32 LLUUID::getRandomSeed() ...@@ -892,7 +929,9 @@ U32 LLUUID::getRandomSeed()
md5_seed.finalize(); md5_seed.finalize();
md5_seed.raw_digest(seed); md5_seed.raw_digest(seed);
return(*(U32 *)seed); U32 out;
memcpy(&out, seed, sizeof(out));
return out;
} }
BOOL LLUUID::parseUUID(const std::string& buf, LLUUID* value) BOOL LLUUID::parseUUID(const std::string& buf, LLUUID* value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment