From 16a81c0589103e022d88774d790cf141bdc09fba Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Wed, 3 Oct 2012 00:35:16 -0300 Subject: [PATCH] Fixed bugs on IP+big endian architecture. --- include/ip.h | 6 ++++++ src/ip.cpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/include/ip.h b/include/ip.h index 561869f..9e40cb6 100644 --- a/include/ip.h +++ b/include/ip.h @@ -118,9 +118,15 @@ namespace Tins { * initialization */ option_identifier(uint8_t value) + #if TINS_IS_LITTLE_ENDIAN : number(value & 0x1f), op_class((value >> 5) & 0x03), copied((value >> 7) & 0x01) {} + #elif TINS_IS_BIG_ENDIAN + : copied((value >> 7) & 0x01), + op_class((value >> 5) & 0x03), + number(value & 0x1f) {} + #endif /** * Constructor using user provided values for each field. diff --git a/src/ip.cpp b/src/ip.cpp index 195878d..1f98fe3 100644 --- a/src/ip.cpp +++ b/src/ip.cpp @@ -238,6 +238,9 @@ void IP::add_route_option(option_identifier id, const generic_route_option_type opt_data[0] = data.pointer; for(size_t i(0); i < data.routes.size(); ++i) { uint32_t ip = data.routes[i]; + #if TINS_IS_BIG_ENDIAN + ip = Endian::change_endian(ip); + #endif opt_data[1 + i * 4] = ip & 0xff; opt_data[1 + i * 4 + 1] = (ip >> 8) & 0xff; opt_data[1 + i * 4 + 2] = (ip >> 16) & 0xff;