mirror of
https://github.com/mfontanini/libtins
synced 2026-01-25 19:51:34 +01:00
Started fixing endianess issues.
This commit is contained in:
12
src/icmp.cpp
12
src/icmp.cpp
@@ -66,23 +66,23 @@ void Tins::ICMP::type(Flags new_type) {
|
||||
}
|
||||
|
||||
void Tins::ICMP::check(uint16_t new_check) {
|
||||
_icmp.check = Utils::net_to_host_s(new_check);
|
||||
_icmp.check = Utils::to_be(new_check);
|
||||
}
|
||||
|
||||
void Tins::ICMP::id(uint16_t new_id) {
|
||||
_icmp.un.echo.id = Utils::net_to_host_s(new_id);
|
||||
_icmp.un.echo.id = Utils::to_be(new_id);
|
||||
}
|
||||
|
||||
void Tins::ICMP::sequence(uint16_t new_seq) {
|
||||
_icmp.un.echo.sequence = Utils::net_to_host_s(new_seq);
|
||||
_icmp.un.echo.sequence = Utils::to_be(new_seq);
|
||||
}
|
||||
|
||||
void Tins::ICMP::gateway(uint32_t new_gw) {
|
||||
_icmp.un.gateway = Utils::net_to_host_l(new_gw);
|
||||
_icmp.un.gateway = Utils::to_be(new_gw);
|
||||
}
|
||||
|
||||
void Tins::ICMP::mtu(uint16_t new_mtu) {
|
||||
_icmp.un.frag.mtu = Utils::net_to_host_s(new_mtu);
|
||||
_icmp.un.frag.mtu = Utils::to_be(new_mtu);
|
||||
}
|
||||
|
||||
void Tins::ICMP::pointer(uint8_t new_pointer) {
|
||||
@@ -171,7 +171,7 @@ void Tins::ICMP::write_serialization(uint8_t *buffer, uint32_t total_sz, const P
|
||||
Utils::do_checksum((uint8_t*)&_icmp, ((uint8_t*)&_icmp) + sizeof(icmphdr));
|
||||
while (checksum >> 16)
|
||||
checksum = (checksum & 0xffff) + (checksum >> 16);
|
||||
_icmp.check = Utils::net_to_host_s(~checksum);
|
||||
_icmp.check = Utils::to_be<uint16_t>(~checksum);
|
||||
}
|
||||
memcpy(buffer, &_icmp, sizeof(icmphdr));
|
||||
_icmp.check = 0;
|
||||
|
||||
Reference in New Issue
Block a user