mirror of
https://github.com/mfontanini/libtins
synced 2026-01-29 04:54:28 +01:00
Fixed bugs on IP+big endian architecture.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user