Skip to content

Instantly share code, notes, and snippets.

@neel
Created February 22, 2015 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neel/6c369946dca99b8e2245 to your computer and use it in GitHub Desktop.
Save neel/6c369946dca99b8e2245 to your computer and use it in GitHub Desktop.
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