Created
February 22, 2015 10:55
-
-
Save neel/6c369946dca99b8e2245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string buffer; | |
std::copy(_packet.body(), _packet.body()+_packet.payload_size(), buffer.begin()); | |
const char* buff = buffer.c_str(); | |
const char* i = buff; | |
boost::uint32_t address_size = *reinterpret_cast<const boost::uint32_t*>(i); | |
i += sizeof(boost::uint32_t); | |
std::string address; | |
std::copy(i, i+address_size, address.begin()); | |
i += address_size; | |
boost::uint32_t time = *reinterpret_cast<const boost::uint32_t*>(i); | |
i += sizeof(boost::uint32_t); | |
// 1 Y38 (<38:0, >=38:1) | |
// 1 role (requesting:0, reporting:1) | |
// 6 UNUSED | |
char flags = *reinterpret_cast<const char*>(i); | |
i += sizeof(char); | |
boost::uint32_t signature_size = *reinterpret_cast<const boost::uint32_t*>(i); | |
i += sizeof(boost::uint32_t); | |
std::string signature; | |
std::copy(i, i+signature_size, signature.begin()); | |
_meta.hello.address = address; | |
_meta.hello.time = time; | |
_meta.hello.flags = flags; | |
_meta.hello.signature = signature; | |
std::cout << address_size << address << signature << std::endl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment