mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Fixed bug in DHCP.
This commit is contained in:
@@ -330,7 +330,7 @@ namespace Tins {
|
||||
* \brief Getter for the PDU's type.
|
||||
* \sa PDU::pdu_type
|
||||
*/
|
||||
PDUType pdu_type() const { return PDU::UDP; }
|
||||
PDUType pdu_type() const { return PDU::DHCP; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the header size.
|
||||
|
||||
@@ -27,14 +27,14 @@
|
||||
#include "ip.h"
|
||||
#include "rawpdu.h"
|
||||
|
||||
Tins::UDP::UDP(uint16_t dport, uint16_t sport, PDU *child) : PDU(Constants::IP::PROTO_TCP, child) {
|
||||
Tins::UDP::UDP(uint16_t dport, uint16_t sport, PDU *child) : PDU(Constants::IP::PROTO_UDP, child) {
|
||||
this->dport(dport);
|
||||
this->sport(sport);
|
||||
_udp.check = 0;
|
||||
_udp.len = 0;
|
||||
}
|
||||
|
||||
Tins::UDP::UDP(const uint8_t *buffer, uint32_t total_sz) : PDU(Constants::IP::PROTO_TCP) {
|
||||
Tins::UDP::UDP(const uint8_t *buffer, uint32_t total_sz) : PDU(Constants::IP::PROTO_UDP) {
|
||||
if(total_sz < sizeof(udphdr))
|
||||
throw std::runtime_error("Not enough size for an UDP header in the buffer.");
|
||||
std::memcpy(&_udp, buffer, sizeof(udphdr));
|
||||
@@ -80,7 +80,7 @@ void Tins::UDP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PD
|
||||
length(sizeof(udphdr) + inner_pdu()->size());
|
||||
std::memcpy(buffer, &_udp, sizeof(udphdr));
|
||||
if(!_udp.check && ip_packet) {
|
||||
uint32_t checksum = Utils::pseudoheader_checksum(ip_packet->src_addr(), ip_packet->dst_addr(), size(), Constants::IP::PROTO_TCP) +
|
||||
uint32_t checksum = Utils::pseudoheader_checksum(ip_packet->src_addr(), ip_packet->dst_addr(), size(), Constants::IP::PROTO_UDP) +
|
||||
Utils::do_checksum(buffer, buffer + total_sz);
|
||||
while (checksum >> 16)
|
||||
checksum = (checksum & 0xffff)+(checksum >> 16);
|
||||
|
||||
Reference in New Issue
Block a user