mirror of
https://github.com/mfontanini/libtins
synced 2026-01-27 12:14:26 +01:00
Fix -Wextra compiler warnings. (#184)
* Fix -Wextra compiler warnings. Fix #183. Signed-off-by: Kyle Fazzari <github@status.e4ward.com> * Comment out unused parameters. This is done everywhere possible instead of using Internals::unused(). Note that this involved moving some implementations into the corresponding .cpp file. Signed-off-by: Kyle Fazzari <github@status.e4ward.com> * Fix warnings in tests as well. Signed-off-by: Kyle Fazzari <github@status.e4ward.com> * Leave IPv4Reassembler alone, it's growing. Signed-off-by: Kyle Fazzari <github@status.e4ward.com>
This commit is contained in:
committed by
Matias Fontanini
parent
94e5ac2109
commit
a71a3d29ff
@@ -43,7 +43,7 @@ using Tins::Memory::OutputMemoryStream;
|
||||
|
||||
namespace Tins {
|
||||
|
||||
PDU::metadata ARP::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
|
||||
PDU::metadata ARP::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
|
||||
if (TINS_UNLIKELY(total_sz < sizeof(arp_header))) {
|
||||
throw malformed_packet();
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ void BootP::vend(const vend_type& newvend_) {
|
||||
vend_ = newvend_;
|
||||
}
|
||||
|
||||
void BootP::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent) {
|
||||
void BootP::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* /*parent*/) {
|
||||
OutputMemoryStream stream(buffer, total_sz);
|
||||
stream.write(bootp_);
|
||||
stream.write(vend_.begin(), vend_.end());
|
||||
|
||||
@@ -47,7 +47,7 @@ using Tins::Memory::OutputMemoryStream;
|
||||
|
||||
namespace Tins {
|
||||
|
||||
PDU::metadata DHCP::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
|
||||
PDU::metadata DHCP::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
|
||||
if (TINS_UNLIKELY(total_sz < sizeof(bootp_header))) {
|
||||
throw malformed_packet();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ using Tins::Memory::OutputMemoryStream;
|
||||
|
||||
namespace Tins {
|
||||
|
||||
PDU::metadata DHCPv6::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
|
||||
PDU::metadata DHCPv6::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
|
||||
if (TINS_UNLIKELY(total_sz < 2)) {
|
||||
throw malformed_packet();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ using Tins::Memory::OutputMemoryStream;
|
||||
|
||||
namespace Tins {
|
||||
|
||||
PDU::metadata DNS::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
|
||||
PDU::metadata DNS::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
|
||||
if (TINS_UNLIKELY(total_sz < sizeof(dns_header))) {
|
||||
throw malformed_packet();
|
||||
}
|
||||
@@ -386,7 +386,7 @@ uint32_t DNS::compose_name(const uint8_t* ptr, char* out_ptr) const {
|
||||
return end_ptr - start_ptr;
|
||||
}
|
||||
|
||||
void DNS::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent) {
|
||||
void DNS::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* /*parent*/) {
|
||||
OutputMemoryStream stream(buffer, total_sz);
|
||||
stream.write(header_);
|
||||
stream.write(records_data_.begin(), records_data_.end());
|
||||
|
||||
@@ -67,9 +67,8 @@ Dot11::Dot11(const address_type& dst_hw_addr)
|
||||
addr1(dst_hw_addr);
|
||||
}
|
||||
|
||||
Dot11::Dot11(const dot11_header* header_ptr)
|
||||
Dot11::Dot11(const dot11_header* /*header_ptr*/)
|
||||
: header_(), options_size_(0) {
|
||||
|
||||
}
|
||||
|
||||
Dot11::Dot11(const uint8_t* buffer, uint32_t total_sz)
|
||||
@@ -78,6 +77,12 @@ Dot11::Dot11(const uint8_t* buffer, uint32_t total_sz)
|
||||
stream.read(header_);
|
||||
}
|
||||
|
||||
void Dot11::write_ext_header(Memory::OutputMemoryStream& /*stream*/) {
|
||||
}
|
||||
|
||||
void Dot11::write_fixed_parameters(Memory::OutputMemoryStream& /*stream*/) {
|
||||
}
|
||||
|
||||
void Dot11::parse_tagged_parameters(InputMemoryStream& stream) {
|
||||
if (stream) {
|
||||
while (stream.size() >= 2) {
|
||||
@@ -208,7 +213,7 @@ void Dot11::send(PacketSender& sender, const NetworkInterface& iface) {
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
void Dot11::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent) {
|
||||
void Dot11::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* /*parent*/) {
|
||||
OutputMemoryStream stream(buffer, total_sz);
|
||||
stream.write(header_);
|
||||
write_ext_header(stream);
|
||||
|
||||
@@ -39,7 +39,7 @@ using Tins::Memory::OutputMemoryStream;
|
||||
|
||||
namespace Tins {
|
||||
|
||||
PDU::metadata Dot1Q::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
|
||||
PDU::metadata Dot1Q::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
|
||||
if (TINS_UNLIKELY(total_sz < sizeof(dot1q_header))) {
|
||||
throw malformed_packet();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Tins {
|
||||
|
||||
const Dot3::address_type Dot3::BROADCAST("ff:ff:ff:ff:ff:ff");
|
||||
|
||||
PDU::metadata Dot3::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
|
||||
PDU::metadata Dot3::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
|
||||
if (TINS_UNLIKELY(total_sz < sizeof(dot3_header))) {
|
||||
throw malformed_packet();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ bool Dot3::matches_response(const uint8_t* ptr, uint32_t total_sz) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Dot3::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent) {
|
||||
void Dot3::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* /*parent*/) {
|
||||
OutputMemoryStream stream(buffer, total_sz);
|
||||
header_.length = Endian::host_to_be<uint16_t>(size() - sizeof(header_));
|
||||
stream.write(header_);
|
||||
|
||||
@@ -161,7 +161,7 @@ bool EthernetII::matches_response(const uint8_t* ptr, uint32_t total_sz) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void EthernetII::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent) {
|
||||
void EthernetII::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* /*parent*/) {
|
||||
OutputMemoryStream stream(buffer, total_sz);
|
||||
if (inner_pdu()) {
|
||||
Constants::Ethernet::e flag;
|
||||
|
||||
@@ -46,7 +46,7 @@ using Tins::Memory::OutputMemoryStream;
|
||||
|
||||
namespace Tins {
|
||||
|
||||
PDU::metadata ICMP::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
|
||||
PDU::metadata ICMP::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
|
||||
if (TINS_UNLIKELY(total_sz < sizeof(icmp_header))) {
|
||||
throw malformed_packet();
|
||||
}
|
||||
|
||||
@@ -450,6 +450,8 @@ void IP::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* pare
|
||||
total_sz = Endian::host_to_be<uint16_t>(total_sz);
|
||||
header_.frag_off = Endian::be_to_host(header_.frag_off);
|
||||
}
|
||||
#else
|
||||
Internals::unused(parent);
|
||||
#endif
|
||||
tot_len(total_sz);
|
||||
head_len(static_cast<uint8_t>(header_size() / sizeof(uint32_t)));
|
||||
|
||||
@@ -70,7 +70,7 @@ PDU::metadata IPv6::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
|
||||
return metadata(header_size, pdu_flag, PDU::UNKNOWN);
|
||||
}
|
||||
|
||||
IPv6::IPv6(address_type ip_dst, address_type ip_src, PDU* child)
|
||||
IPv6::IPv6(address_type ip_dst, address_type ip_src, PDU* /*child*/)
|
||||
: header_(), headers_size_(0) {
|
||||
version(6);
|
||||
dst_addr(ip_dst);
|
||||
@@ -219,7 +219,7 @@ bool IPv6::matches_response(const uint8_t* ptr, uint32_t total_sz) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void IPv6::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent) {
|
||||
void IPv6::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* /*parent*/) {
|
||||
OutputMemoryStream stream(buffer, total_sz);
|
||||
if (inner_pdu()) {
|
||||
uint8_t new_flag = Internals::pdu_flag_to_ip_type(inner_pdu()->pdu_type());
|
||||
|
||||
@@ -196,7 +196,7 @@ void LLC::clear_information_fields() {
|
||||
information_fields_.clear();
|
||||
}
|
||||
|
||||
void LLC::write_serialization(uint8_t* buffer, uint32_t total_sz, const Tins::PDU* parent) {
|
||||
void LLC::write_serialization(uint8_t* buffer, uint32_t total_sz, const Tins::PDU* /*parent*/) {
|
||||
OutputMemoryStream stream(buffer, total_sz);
|
||||
if (inner_pdu() && inner_pdu()->pdu_type() == PDU::STP) {
|
||||
dsap(0x42);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string.h>
|
||||
#include "offline_packet_filter.h"
|
||||
#include "pdu.h"
|
||||
#include "exceptions.h"
|
||||
@@ -64,7 +65,8 @@ void OfflinePacketFilter::init(const string& pcap_filter,
|
||||
}
|
||||
|
||||
bool OfflinePacketFilter::matches_filter(const uint8_t* buffer, uint32_t total_sz) const {
|
||||
pcap_pkthdr header = {};
|
||||
pcap_pkthdr header;
|
||||
memset(&header, 0, sizeof(header));
|
||||
header.len = total_sz;
|
||||
header.caplen = total_sz;
|
||||
return pcap_offline_filter(&filter_, &header, buffer) != 0;
|
||||
|
||||
@@ -156,6 +156,7 @@ bool PacketSender::ether_socket_initialized(const NetworkInterface& iface) const
|
||||
#if defined(BSD) || defined(__FreeBSD_kernel__)
|
||||
return ether_socket_.count(iface.id());
|
||||
#else
|
||||
Internals::unused(iface);
|
||||
return ether_socket_ != INVALID_RAW_SOCKET;
|
||||
#endif
|
||||
}
|
||||
@@ -234,6 +235,7 @@ void PacketSender::open_l2_socket(const NetworkInterface& iface) {
|
||||
}
|
||||
ether_socket_[iface.id()] = sock;
|
||||
#else
|
||||
Internals::unused(iface);
|
||||
if (ether_socket_ == INVALID_RAW_SOCKET) {
|
||||
ether_socket_ = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
||||
|
||||
@@ -284,6 +286,7 @@ void PacketSender::close_socket(SocketType type, const NetworkInterface& iface)
|
||||
}
|
||||
ether_socket_.erase(it);
|
||||
#elif !defined(_WIN32)
|
||||
Internals::unused(iface);
|
||||
if (ether_socket_ == INVALID_RAW_SOCKET) {
|
||||
throw invalid_socket_type();
|
||||
}
|
||||
@@ -294,6 +297,7 @@ void PacketSender::close_socket(SocketType type, const NetworkInterface& iface)
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
Internals::unused(iface);
|
||||
if (type >= SOCKETS_END || sockets_[type] == INVALID_RAW_SOCKET) {
|
||||
throw invalid_socket_type();
|
||||
}
|
||||
@@ -354,6 +358,8 @@ void PacketSender::send_l2(PDU& pdu,
|
||||
PDU::serialization_type buffer = pdu.serialize();
|
||||
|
||||
#ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
|
||||
Internals::unused(len_addr);
|
||||
Internals::unused(link_addr);
|
||||
open_l2_socket(iface);
|
||||
pcap_t* handle = pcap_handles_[iface];
|
||||
const int buf_size = static_cast<int>(buffer.size());
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <stdexcept>
|
||||
#include <string.h>
|
||||
#include "packet_writer.h"
|
||||
#include "packet.h"
|
||||
#include "pdu.h"
|
||||
@@ -71,11 +72,11 @@ void PacketWriter::write(Packet& packet) {
|
||||
|
||||
void PacketWriter::write(PDU& pdu, const struct timeval& tv) {
|
||||
PDU::serialization_type buffer = pdu.serialize();
|
||||
struct pcap_pkthdr header = {
|
||||
tv,
|
||||
static_cast<bpf_u_int32>(buffer.size()),
|
||||
static_cast<bpf_u_int32>(buffer.size())
|
||||
};
|
||||
struct pcap_pkthdr header;
|
||||
memset(&header, 0, sizeof(header));
|
||||
header.ts = tv;
|
||||
header.caplen = static_cast<bpf_u_int32>(buffer.size());
|
||||
header.len = static_cast<bpf_u_int32>(buffer.size());
|
||||
pcap_dump((u_char*)dumper_, &header, &buffer[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,9 @@ void PDU::copy_inner_pdu(const PDU& pdu) {
|
||||
}
|
||||
}
|
||||
|
||||
void PDU::prepare_for_serialize(const PDU* /*parent*/) {
|
||||
}
|
||||
|
||||
uint32_t PDU::size() const {
|
||||
uint32_t sz = header_size() + trailer_size();
|
||||
const PDU* ptr(inner_pdu_);
|
||||
@@ -91,6 +94,10 @@ PDU* PDU::recv_response(PacketSender &, const NetworkInterface &) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool PDU::matches_response(const uint8_t* /*ptr*/, uint32_t /*total_sz*/) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void PDU::inner_pdu(PDU* next_pdu) {
|
||||
delete inner_pdu_;
|
||||
inner_pdu_ = next_pdu;
|
||||
|
||||
@@ -65,7 +65,7 @@ uint32_t PKTAP::header_size() const {
|
||||
return sizeof(header_);
|
||||
}
|
||||
|
||||
void PKTAP::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent) {
|
||||
void PKTAP::write_serialization(uint8_t* /*buffer*/, uint32_t /*total_sz*/, const PDU* /*parent*/) {
|
||||
throw pdu_not_serializable();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ uint32_t PPI::header_size() const {
|
||||
return static_cast<uint32_t>(sizeof(header_) + data_.size());
|
||||
}
|
||||
|
||||
void PPI::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU *) {
|
||||
void PPI::write_serialization(uint8_t* /*buffer*/, uint32_t /*total_sz*/, const PDU *) {
|
||||
throw pdu_not_serializable();
|
||||
}
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ bool RadioTap::matches_response(const uint8_t* ptr, uint32_t total_sz) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RadioTap::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent) {
|
||||
void RadioTap::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* /*parent*/) {
|
||||
OutputMemoryStream stream(buffer, total_sz);
|
||||
uint8_t* buffer_start = buffer;
|
||||
radio_.it_len = Endian::host_to_le<uint16_t>(header_size());
|
||||
|
||||
@@ -57,7 +57,7 @@ void RawPDU::payload(const payload_type& pload) {
|
||||
payload_ = pload;
|
||||
}
|
||||
|
||||
bool RawPDU::matches_response(const uint8_t* ptr, uint32_t total_sz) const {
|
||||
bool RawPDU::matches_response(const uint8_t* /*ptr*/, uint32_t /*total_sz*/) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ uint32_t SNAP::header_size() const {
|
||||
return sizeof(snap_);
|
||||
}
|
||||
|
||||
void SNAP::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent) {
|
||||
void SNAP::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* /*parent*/) {
|
||||
OutputMemoryStream stream(buffer, total_sz);
|
||||
if (inner_pdu()) {
|
||||
Constants::Ethernet::e flag = Internals::pdu_flag_to_ether_type(
|
||||
|
||||
@@ -356,6 +356,8 @@ void Sniffer::set_immediate_mode(bool enabled) {
|
||||
if (pcap_set_immediate_mode(get_pcap_handle(), enabled)) {
|
||||
throw pcap_error(pcap_geterr(get_pcap_handle()));
|
||||
}
|
||||
#else
|
||||
Internals::unused(enabled);
|
||||
#endif // HAVE_PCAP_IMMEDIATE_MODE
|
||||
}
|
||||
|
||||
@@ -366,6 +368,8 @@ void Sniffer::set_timestamp_precision(int value) {
|
||||
if (result == PCAP_ERROR_TSTAMP_PRECISION_NOTSUP) {
|
||||
throw pcap_error("Timestamp precision not supported");
|
||||
}
|
||||
#else
|
||||
Internals::unused(value);
|
||||
#endif // HAVE_PCAP_TIMESTAMP_PRECISION
|
||||
}
|
||||
|
||||
|
||||
@@ -309,13 +309,13 @@ void Stream::on_server_flow_data(const Flow& /*flow*/) {
|
||||
}
|
||||
}
|
||||
|
||||
void Stream::on_client_out_of_order(const Flow& flow, uint32_t seq, const payload_type& payload) {
|
||||
void Stream::on_client_out_of_order(const Flow& /*flow*/, uint32_t seq, const payload_type& payload) {
|
||||
if (on_client_out_of_order_callback_) {
|
||||
on_client_out_of_order_callback_(*this, seq, payload);
|
||||
}
|
||||
}
|
||||
|
||||
void Stream::on_server_out_of_order(const Flow& flow, uint32_t seq, const payload_type& payload) {
|
||||
void Stream::on_server_out_of_order(const Flow& /*flow*/, uint32_t seq, const payload_type& payload) {
|
||||
if (on_server_out_of_order_callback_) {
|
||||
on_server_out_of_order_callback_(*this, seq, payload);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ void TCPStream::safe_insert(fragments_type& frags, uint32_t seq, RawPDU* raw) {
|
||||
}
|
||||
|
||||
bool TCPStream::generic_process(uint32_t& my_seq,
|
||||
uint32_t& other_seq,
|
||||
uint32_t& /*other_seq*/,
|
||||
payload_type& pload,
|
||||
fragments_type& frags,
|
||||
TCP* tcp) {
|
||||
|
||||
@@ -43,7 +43,7 @@ using Tins::Memory::OutputMemoryStream;
|
||||
|
||||
namespace Tins {
|
||||
|
||||
PDU::metadata UDP::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
|
||||
PDU::metadata UDP::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
|
||||
if (TINS_UNLIKELY(total_sz < sizeof(udp_header))) {
|
||||
throw malformed_packet();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user