mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
PDU::matches_response is now const.
This commit is contained in:
@@ -271,7 +271,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \sa PDU::clone
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the PDU's type.
|
||||
|
||||
@@ -813,7 +813,7 @@ public:
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the PDU's type.
|
||||
|
||||
@@ -577,7 +577,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \sa PDU::clone
|
||||
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
private:
|
||||
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
#ifndef WIN32
|
||||
/**
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
#ifndef WIN32
|
||||
/**
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the PDU's type.
|
||||
|
||||
@@ -769,7 +769,7 @@ public:
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \brief Searchs for an option that matchs the given flag.
|
||||
|
||||
@@ -579,7 +579,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \brief Receives a matching response for this packet.
|
||||
|
||||
@@ -255,7 +255,7 @@ public:
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \sa PDU::clone
|
||||
|
||||
@@ -326,7 +326,9 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
virtual bool matches_response(uint8_t *ptr, uint32_t total_sz) { return false; }
|
||||
virtual bool matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check wether this PDU matches the specified flag.
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
/**
|
||||
* Forwards the call to the cached PDU. \sa PDU::matches_response.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
return cached.matches_response(ptr, total_sz);
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \brief Returns the RadioTap frame's header length.
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the PDU's type.
|
||||
|
||||
@@ -395,7 +395,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the PDU's type.
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Tins {
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
bool matches_response(const uint8_t *ptr, uint32_t total_sz) const;
|
||||
|
||||
/**
|
||||
* \brief Returns the header size.
|
||||
|
||||
@@ -112,10 +112,10 @@ void ARP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) {
|
||||
memcpy(buffer, &_arp, sizeof(arphdr));
|
||||
}
|
||||
|
||||
bool ARP::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool ARP::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(arphdr))
|
||||
return false;
|
||||
arphdr *arp_ptr = (arphdr*)ptr;
|
||||
const arphdr *arp_ptr = (const arphdr*)ptr;
|
||||
return arp_ptr->ar_sip == _arp.ar_tip && arp_ptr->ar_tip == _arp.ar_sip;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ void BootP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *p
|
||||
std::copy(_vend.begin(), _vend.end(), buffer + sizeof(bootphdr));
|
||||
}
|
||||
|
||||
bool BootP::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool BootP::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(bootphdr))
|
||||
return false;
|
||||
const bootphdr *bootp_ptr = (const bootphdr *)ptr;
|
||||
|
||||
@@ -131,7 +131,7 @@ uint32_t DHCPv6::header_size() const {
|
||||
return (is_relay_message() ? (2 + ipaddress_type::address_size * 2) : 4) + options_size;
|
||||
}
|
||||
|
||||
bool DHCPv6::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool DHCPv6::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(!is_relay_message()) {
|
||||
if(total_sz < 4 || (ptr[0] == 12 || ptr[0] == 13))
|
||||
return false;
|
||||
|
||||
@@ -481,7 +481,7 @@ DNS::resources_type DNS::answers() const {
|
||||
return res;
|
||||
}
|
||||
|
||||
bool DNS::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool DNS::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(dnshdr))
|
||||
return false;
|
||||
const dnshdr *hdr = (const dnshdr*)ptr;
|
||||
|
||||
@@ -129,7 +129,7 @@ void Dot1Q::append_padding(bool value) {
|
||||
_append_padding = value;
|
||||
}
|
||||
|
||||
bool Dot1Q::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool Dot1Q::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(_header))
|
||||
return false;
|
||||
const dot1q_hdr *dot1q_ptr = (const dot1q_hdr*)ptr;
|
||||
|
||||
@@ -110,7 +110,7 @@ void Dot3::send(PacketSender &sender, const NetworkInterface &iface) {
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
bool Dot3::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool Dot3::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(ethhdr))
|
||||
return false;
|
||||
const size_t addr_sz = address_type::address_size;
|
||||
|
||||
@@ -122,7 +122,7 @@ void EthernetII::send(PacketSender &sender, const NetworkInterface &iface) {
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
bool EthernetII::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool EthernetII::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(ethhdr))
|
||||
return false;
|
||||
const size_t addr_sz = address_type::address_size;
|
||||
|
||||
@@ -160,7 +160,7 @@ void ICMP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *)
|
||||
_icmp.check = 0;
|
||||
}
|
||||
|
||||
bool ICMP::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool ICMP::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(icmphdr))
|
||||
return false;
|
||||
const icmphdr *icmp_ptr = (const icmphdr*)ptr;
|
||||
|
||||
@@ -181,7 +181,7 @@ uint32_t ICMPv6::header_size() const {
|
||||
(has_dest_addr() ? ipaddress_type::address_size : 0);
|
||||
}
|
||||
|
||||
bool ICMPv6::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool ICMPv6::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(icmp6hdr))
|
||||
return false;
|
||||
const icmp6hdr *hdr_ptr = (const icmp6hdr*)ptr;
|
||||
|
||||
@@ -429,7 +429,7 @@ void IP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU* pare
|
||||
}
|
||||
}
|
||||
|
||||
bool IP::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool IP::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(iphdr))
|
||||
return false;
|
||||
const iphdr *ip_ptr = (const iphdr*)ptr;
|
||||
|
||||
@@ -162,7 +162,7 @@ uint32_t IPv6::header_size() const {
|
||||
return sizeof(_header) + headers_size;
|
||||
}
|
||||
|
||||
bool IPv6::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool IPv6::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(ipv6_header))
|
||||
return false;
|
||||
const ipv6_header *hdr_ptr = (const ipv6_header*)ptr;
|
||||
|
||||
@@ -263,7 +263,7 @@ void RadioTap::send(PacketSender &sender, const NetworkInterface &iface) {
|
||||
}
|
||||
#endif
|
||||
|
||||
bool RadioTap::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool RadioTap::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(sizeof(_radio) < total_sz)
|
||||
return false;
|
||||
const radiotap_hdr *radio_ptr = (const radiotap_hdr*)ptr;
|
||||
|
||||
@@ -57,7 +57,7 @@ void RawPDU::payload(const payload_type &pload) {
|
||||
_payload = pload;
|
||||
}
|
||||
|
||||
bool RawPDU::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool RawPDU::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ void TCP::internal_add_option(const option &opt) {
|
||||
_total_options_size = (padding) ? _options_size - padding + 4 : _options_size;
|
||||
}
|
||||
|
||||
bool TCP::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool TCP::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(tcphdr))
|
||||
return false;
|
||||
const tcphdr *tcp_ptr = (const tcphdr*)ptr;
|
||||
|
||||
@@ -98,7 +98,7 @@ void UDP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *par
|
||||
}
|
||||
}
|
||||
|
||||
bool UDP::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool UDP::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(udphdr))
|
||||
return false;
|
||||
const udphdr *udp_ptr = (const udphdr*)ptr;
|
||||
|
||||
Reference in New Issue
Block a user