mirror of
https://github.com/mfontanini/libtins
synced 2026-01-27 04:11:35 +01:00
Added more DHCP options.
This commit is contained in:
@@ -61,14 +61,14 @@ void Tins::UDP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PD
|
||||
const Tins::IP *ip_packet = dynamic_cast<const Tins::IP*>(parent);
|
||||
if(inner_pdu())
|
||||
length(sizeof(udphdr) + inner_pdu()->size());
|
||||
std::memcpy(buffer, &_udp, sizeof(udphdr));
|
||||
if(!_udp.check && ip_packet) {
|
||||
uint32_t checksum = PDU::pseudoheader_checksum(ip_packet->source_address(), ip_packet->dest_address(), size(), IPPROTO_UDP) +
|
||||
PDU::do_checksum(buffer + sizeof(udphdr), buffer + total_sz) + PDU::do_checksum((uint8_t*)&_udp, ((uint8_t*)&_udp) + sizeof(udphdr));
|
||||
PDU::do_checksum(buffer, buffer + total_sz);
|
||||
while (checksum >> 16)
|
||||
checksum = (checksum & 0xffff)+(checksum >> 16);
|
||||
_udp.check = Utils::net_to_host_s(~checksum);
|
||||
((udphdr*)buffer)->check = Utils::net_to_host_s(~checksum);
|
||||
}
|
||||
std::memcpy(buffer, &_udp, sizeof(udphdr));
|
||||
_udp.check = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user