diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2016-02-26 12:46:20 +0100 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2016-02-26 12:46:20 +0100 |
| commit | 1d07fee3671147a760597fdea850b63c2afd91b1 (patch) | |
| tree | 62d852f4726a335b5cbc0127c4dcbbced1873290 /Source/Core/Common/Network.cpp | |
| parent | a0c51806ec09d149667398fa1c94dd360a37f44f (diff) | |
| parent | a870253cd64a726130b333c6bb75822ad842b8e1 (diff) | |
Merge pull request #3432 from stenzek/bba-tap-win
EXI: Refactor Windows BBA-TAP interface to a read thread, crash fixes, cleanups
Diffstat (limited to 'Source/Core/Common/Network.cpp')
| -rw-r--r-- | Source/Core/Common/Network.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Source/Core/Common/Network.cpp b/Source/Core/Common/Network.cpp index 23c570045f..c03ed0fc76 100644 --- a/Source/Core/Common/Network.cpp +++ b/Source/Core/Common/Network.cpp @@ -3,12 +3,13 @@ // Refer to the license.txt file included. #include <cctype> -#include <cstdlib> #include <cstring> #include <ctime> +#include <random> #include "Common/Network.h" #include "Common/StringUtil.h" +#include "Common/Timer.h" void GenerateMacAddress(const MACConsumer type, u8* mac) { @@ -27,16 +28,12 @@ void GenerateMacAddress(const MACConsumer type, u8* mac) break; } - srand((unsigned int)time(nullptr)); - - u8 id[3] = - { - (u8)rand(), - (u8)rand(), - (u8)rand() - }; - - memcpy(&mac[3], id, 3); + // Generate the 24-bit NIC-specific portion of the MAC address. + std::default_random_engine generator(Common::Timer::GetTimeMs()); + std::uniform_int_distribution<int> distribution(0x00, 0xFF); + mac[3] = static_cast<u8>(distribution(generator)); + mac[4] = static_cast<u8>(distribution(generator)); + mac[5] = static_cast<u8>(distribution(generator)); } std::string MacAddressToString(const u8* mac) |
