1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-30 05:24:26 +01:00

Added some fixes to the build system. Fixed bugs in DNS and ICMPv6 triggered in big-endian architectures.

This commit is contained in:
Matias Fontanini
2013-01-24 23:55:01 -03:00
parent 0dc762f15d
commit 5ee0ebb264
14 changed files with 843 additions and 1454 deletions

View File

@@ -95,7 +95,6 @@ const DHCPv6::dhcpv6_option *DHCPv6::search_option(Option id) const {
uint8_t* DHCPv6::write_option(const dhcpv6_option &option, uint8_t* buffer) const {
*(uint16_t*)buffer = Endian::host_to_be(option.option());
*(uint16_t*)&buffer[sizeof(uint16_t)] = Endian::host_to_be(option.data_size());
std::cout << "Size: " << option.data_size() << std::endl;
return std::copy(
option.data_ptr(),
option.data_ptr() + option.data_size(),

View File

@@ -174,7 +174,7 @@ bool DNSResourceRecord::matches(const std::string &dname) const {
// OffsetedRecord
OffsetedDNSRRImpl::OffsetedDNSRRImpl(uint16_t off)
: offset_(off | 0xc0)
: offset_(off | Endian::host_to_be<uint16_t>(0xc000))
{
}

View File

@@ -606,7 +606,9 @@ ICMPv6::addr_list_type ICMPv6::search_addr_list(Options type) const {
ICMPv6::rsa_sign_type ICMPv6::rsa_signature() const {
const icmpv6_option *opt = search_option(RSA_SIGN);
// 2 bytes reserved + at least 1 byte signature.
if(!opt || opt->data_size() < 2 + sizeof(rsa_sign_type::key_hash) + 1)
// 16 == sizeof(rsa_sign_type::key_hash), removed the sizeof
// expression since gcc 4.2 doesn't like it
if(!opt || opt->data_size() < 2 + 16 + 1)
throw option_not_found();
const uint8_t *ptr = opt->data_ptr() + 2;
rsa_sign_type output;