B3n30 / tunnler

GNU General Public License v2.0
1 stars 0 forks source link

Implemented MAC address generator #12

Closed B3n30 closed 7 years ago

B3n30 commented 7 years ago

Implemented a mac address generator. The first 3 bytes are always 0x00 0x1F 0x32. This is a Nintendo OUI used with the 3ds. This ensures that none of the specials bits used with mac addresses isn't set. This isn't important for citra<->citra communication but gets important as soon as we send these data into real wifi. Also it ensures if any game would check for a nintendo vendor mac address. (I really doubt that, but just in case).

The last 3 bytes are generated randomly between 0x00 and 0xFF, each.

The mac is transferred to the member with Room::SendJoinRequest, but isn't handled there, yet.

JayFoxRox commented 7 years ago

This made it uncompilable for me.

In file included from /usr/include/c++/6.3.1/random:49:0,
                 from /home/fox/Data/Projects/tunnler/include/tunnler/room.h:11,
                 from /home/fox/Data/Projects/tunnler/src/room.cpp:7:
/usr/include/c++/6.3.1/bits/random.h: In instantiation of ‘class std::uniform_real_distribution<unsigned char>’:
/home/fox/Data/Projects/tunnler/src/room.cpp:195:48:   required from here
/usr/include/c++/6.3.1/bits/random.h:1704:7: error: static assertion failed: template argument not a floating point type
       static_assert(std::is_floating_point<_RealType>::value,
       ^~~~~~~~~~~~~
/home/fox/Data/Projects/tunnler/src/room.cpp: In member function ‘MacAddress Room::GenerateMacAddress()’:
/home/fox/Data/Projects/tunnler/src/room.cpp:195:55: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     std::uniform_real_distribution<uint8_t> dis(0, 256); //Random byte between 0 and 0xFF
                                                       ^
In file included from /usr/include/c++/6.3.1/random:49:0,
                 from /home/fox/Data/Projects/tunnler/include/tunnler/room.h:11,
                 from /home/fox/Data/Projects/tunnler/src/room.cpp:7:
/usr/include/c++/6.3.1/bits/random.h: In instantiation of ‘struct std::__detail::_Adaptor<std::mersenne_twister_engine<long unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>, unsigned char>’:
/usr/include/c++/6.3.1/bits/random.h:1817:6:   required from ‘std::uniform_real_distribution<_RealType>::result_type std::uniform_real_distribution<_RealType>::operator()(_UniformRandomNumberGenerator&, const std::uniform_real_distribution<_RealType>::param_type&) [with _UniformRandomNumberGenerator = std::mersenne_twister_engine<long unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>; _RealType = unsigned char; std::uniform_real_distribution<_RealType>::result_type = unsigned char]’
/usr/include/c++/6.3.1/bits/random.h:1809:51:   required from ‘std::uniform_real_distribution<_RealType>::result_type std::uniform_real_distribution<_RealType>::operator()(_UniformRandomNumberGenerator&) [with _UniformRandomNumberGenerator = std::mersenne_twister_engine<long unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>; _RealType = unsigned char; std::uniform_real_distribution<_RealType>::result_type = unsigned char]’
/home/fox/Data/Projects/tunnler/src/room.cpp:198:43:   required from here
/usr/include/c++/6.3.1/bits/random.h:160:2: error: static assertion failed: template argument not a floating point type
  static_assert(std::is_floating_point<_DInputType>::value,
  ^~~~~~~~~~~~~