1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-29 21:14:28 +01:00

Prefix HAVE_ config.h macros with TINS_

This commit is contained in:
Matias Fontanini
2016-02-20 09:10:33 -08:00
parent bac8388cec
commit 64b84fa91d
66 changed files with 180 additions and 180 deletions

View File

@@ -29,13 +29,13 @@
#include "crypto.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#ifdef HAVE_WPA2_DECRYPTION
#ifdef TINS_HAVE_WPA2_DECRYPTION
#include <openssl/evp.h>
#include <openssl/hmac.h>
#include <openssl/aes.h>
#endif // HAVE_WPA2_DECRYPTION
#endif // TINS_HAVE_WPA2_DECRYPTION
#include "dot11/dot11_data.h"
#include "dot11/dot11_beacon.h"
#include "exceptions.h"
@@ -130,7 +130,7 @@ PDU* WEPDecrypter::decrypt(RawPDU& raw, const string& password) {
}
}
#ifdef HAVE_WPA2_DECRYPTION
#ifdef TINS_HAVE_WPA2_DECRYPTION
// WPA2Decrypter
using WPA2::SessionKeys;
@@ -629,9 +629,9 @@ bool WPA2Decrypter::decrypt(PDU& pdu) {
return false;
}
#endif // HAVE_WPA2_DECRYPTION
#endif // TINS_HAVE_WPA2_DECRYPTION
} // namespace Crypto
} // namespace Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -28,7 +28,7 @@
*/
#include "dot11/dot11_assoc.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include "memory_helpers.h"
@@ -192,4 +192,4 @@ void Dot11ReAssocResponse::write_fixed_parameters(OutputMemoryStream& stream) {
} // Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -28,7 +28,7 @@
*/
#include "dot11/dot11_auth.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include "memory_helpers.h"
@@ -104,4 +104,4 @@ void Dot11Deauthentication::write_fixed_parameters(OutputMemoryStream& stream) {
} // Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -29,7 +29,7 @@
#include "dot11/dot11_base.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include <stdexcept>
@@ -288,4 +288,4 @@ Dot11* Dot11::from_bytes(const uint8_t* buffer, uint32_t total_sz) {
} // Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -28,7 +28,7 @@
*/
#include "dot11/dot11_beacon.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include "memory_helpers.h"
@@ -72,4 +72,4 @@ void Dot11Beacon::write_fixed_parameters(OutputMemoryStream& stream) {
} // Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -28,7 +28,7 @@
*/
#include "dot11/dot11_control.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <algorithm>
#include "memory_helpers.h"
@@ -251,4 +251,4 @@ uint32_t Dot11BlockAck::header_size() const {
} // Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -28,7 +28,7 @@
*/
#include "dot11/dot11_data.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include "rawpdu.h"
@@ -161,4 +161,4 @@ void Dot11QoSData::write_fixed_parameters(OutputMemoryStream& stream) {
} // Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -28,7 +28,7 @@
*/
#include "dot11/dot11_mgmt.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include "rsn_information.h"
@@ -641,4 +641,4 @@ Dot11ManagementFrame::tim_type Dot11ManagementFrame::tim_type::from_option(const
} // Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -29,7 +29,7 @@
#include "dot11/dot11_probe.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include "memory_helpers.h"
@@ -88,4 +88,4 @@ void Dot11ProbeResponse::write_fixed_parameters(OutputMemoryStream& stream) {
} // namespace Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -86,13 +86,13 @@ uint32_t Dot3::header_size() const {
return sizeof(header_);
}
#if !defined(_WIN32) || defined(HAVE_PACKET_SENDER_PCAP_SENDPACKET)
#if !defined(_WIN32) || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET)
void Dot3::send(PacketSender& sender, const NetworkInterface& iface) {
if (!iface) {
throw invalid_interface();
}
#if defined(BSD) || defined(__FreeBSD_kernel__) || defined(HAVE_PACKET_SENDER_PCAP_SENDPACKET)
#if defined(BSD) || defined(__FreeBSD_kernel__) || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET)
sender.send_l2(*this, 0, 0, iface);
#else
struct sockaddr_ll addr;
@@ -108,7 +108,7 @@ void Dot3::send(PacketSender& sender, const NetworkInterface& iface) {
sender.send_l2(*this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr));
#endif
}
#endif // !_WIN32 || HAVE_PACKET_SENDER_PCAP_SENDPACKET
#endif // !_WIN32 || TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
bool Dot3::matches_response(const uint8_t* ptr, uint32_t total_sz) const {
if (total_sz < sizeof(header_)) {

View File

@@ -112,7 +112,7 @@ void EthernetII::send(PacketSender& sender, const NetworkInterface& iface) {
if (!iface) {
throw invalid_interface();
}
#if defined(HAVE_PACKET_SENDER_PCAP_SENDPACKET) || defined(BSD) || defined(__FreeBSD_kernel__)
#if defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET) || defined(BSD) || defined(__FreeBSD_kernel__)
// Sending using pcap_sendpacket/BSD bpf packet mode is the same here
sender.send_l2(*this, 0, 0, iface);
#elif defined(_WIN32)

View File

@@ -29,7 +29,7 @@
#include "handshake_capturer.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include "dot11/dot11_data.h"
@@ -106,4 +106,4 @@ bool RSNHandshakeCapturer::do_insert(const handshake_map::key_type& key,
} // namespace Tins;
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -164,16 +164,16 @@ PDU* pdu_from_dlt_flag(int flag,
case DLT_EN10MB:
return new EthernetII(buffer, size);
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
case DLT_IEEE802_11_RADIO:
return new RadioTap(buffer, size);
case DLT_IEEE802_11:
return Dot11::from_bytes(buffer, size);
#else // HAVE_DOT11
#else // TINS_HAVE_DOT11
case DLT_IEEE802_11_RADIO:
case DLT_IEEE802_11:
throw protocol_disabled();
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11
case DLT_NULL:
return new Loopback(buffer, size);
@@ -200,7 +200,7 @@ Tins::PDU* pdu_from_flag(PDU::PDUType type, const uint8_t* buffer, uint32_t size
return new Tins::IEEE802_3(buffer, size);
case Tins::PDU::PPPOE:
return new Tins::PPPoE(buffer, size);
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
case Tins::PDU::RADIOTAP:
return new Tins::RadioTap(buffer, size);
case Tins::PDU::DOT11:
@@ -226,7 +226,7 @@ Tins::PDU* pdu_from_flag(PDU::PDUType type, const uint8_t* buffer, uint32_t size
case Tins::PDU::DOT11_RTS:
case Tins::PDU::DOT11_QOS_DATA:
return Tins::Dot11::from_bytes(buffer, size);
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11
default:
return 0;
};

View File

@@ -129,12 +129,12 @@ PacketSender::~PacketSender() {
}
#endif
#ifdef HAVE_PACKET_SENDER_PCAP_SENDPACKET
#ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
for (PcapHandleMap::iterator it = pcap_handles_.begin(); it != pcap_handles_.end(); ++it) {
pcap_close(it->second);
}
pcap_handles_.clear();
#endif // HAVE_PACKET_SENDER_PCAP_SENDPACKET
#endif // TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
}
void PacketSender::default_interface(const NetworkInterface& iface) {
@@ -145,7 +145,7 @@ const NetworkInterface& PacketSender::default_interface() const {
return default_iface_;
}
#if !defined(_WIN32) || defined(HAVE_PACKET_SENDER_PCAP_SENDPACKET)
#if !defined(_WIN32) || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET)
#ifndef _WIN32
bool PacketSender::ether_socket_initialized(const NetworkInterface& iface) const {
@@ -168,7 +168,7 @@ int PacketSender::get_ether_socket(const NetworkInterface& iface) {
}
#endif // _WIN32
#ifdef HAVE_PACKET_SENDER_PCAP_SENDPACKET
#ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
pcap_t* PacketSender::make_pcap_handle(const NetworkInterface& iface) const {
// This is an ugly fix to make interface names look like what
@@ -193,10 +193,10 @@ pcap_t* PacketSender::make_pcap_handle(const NetworkInterface& iface) const {
return handle;
}
#endif // HAVE_PACKET_SENDER_PCAP_SENDPACKET
#endif // TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
void PacketSender::open_l2_socket(const NetworkInterface& iface) {
#ifdef HAVE_PACKET_SENDER_PCAP_SENDPACKET
#ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
if (pcap_handles_.count(iface) == 0) {
pcap_handles_.insert(make_pair(iface, make_pcap_handle(iface)));
}
@@ -239,7 +239,7 @@ void PacketSender::open_l2_socket(const NetworkInterface& iface) {
}
#endif
}
#endif // !_WIN32 || HAVE_PACKET_SENDER_PCAP_SENDPACKET
#endif // !_WIN32 || TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
void PacketSender::open_l3_socket(SocketType type) {
int socktype = find_type(type);
@@ -309,14 +309,14 @@ void PacketSender::send(PDU& pdu, const NetworkInterface& iface) {
if (pdu.matches_flag(PDU::ETHERNET_II)) {
send<Tins::EthernetII>(pdu, iface);
}
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
else if (pdu.matches_flag(PDU::DOT11)) {
send<Tins::Dot11>(pdu, iface);
}
else if (pdu.matches_flag(PDU::RADIOTAP)) {
send<Tins::RadioTap>(pdu, iface);
}
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11
else if (pdu.matches_flag(PDU::IEEE802_3)) {
send<Tins::IEEE802_3>(pdu, iface);
}
@@ -339,14 +339,14 @@ PDU* PacketSender::send_recv(PDU& pdu, const NetworkInterface& iface) {
return pdu.recv_response(*this, iface);
}
#if !defined(_WIN32) || defined(HAVE_PACKET_SENDER_PCAP_SENDPACKET)
#if !defined(_WIN32) || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET)
void PacketSender::send_l2(PDU& pdu,
struct sockaddr* link_addr,
uint32_t len_addr,
const NetworkInterface& iface) {
PDU::serialization_type buffer = pdu.serialize();
#ifdef HAVE_PACKET_SENDER_PCAP_SENDPACKET
#ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
open_l2_socket(iface);
pcap_t* handle = pcap_handles_[iface];
const int buf_size = static_cast<int>(buffer.size());
@@ -354,7 +354,7 @@ void PacketSender::send_l2(PDU& pdu,
throw runtime_error("Failed to send packet: " +
string(pcap_geterr(handle)));
}
#else // HAVE_PACKET_SENDER_PCAP_SENDPACKET
#else // TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
int sock = get_ether_socket(iface);
if (!buffer.empty()) {
#if defined(BSD) || defined(__FreeBSD_kernel__)
@@ -365,10 +365,10 @@ void PacketSender::send_l2(PDU& pdu,
throw socket_write_error(make_error_string());
}
}
#endif // HAVE_PACKET_SENDER_PCAP_SENDPACKET
#endif // TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
}
#endif // !_WIN32 || HAVE_PACKET_SENDER_PCAP_SENDPACKET
#endif // !_WIN32 || TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET
#ifndef _WIN32
PDU* PacketSender::recv_l2(PDU& pdu,

View File

@@ -59,7 +59,7 @@ PPI::PPI(const uint8_t* buffer, uint32_t total_sz) {
if (stream) {
switch (dlt()) {
case DLT_IEEE802_11:
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
parse_80211(stream.pointer(), stream.size());
#else
throw protocol_disabled();
@@ -74,7 +74,7 @@ PPI::PPI(const uint8_t* buffer, uint32_t total_sz) {
}
break;
case DLT_IEEE802_11_RADIO:
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
inner_pdu(new RadioTap(stream.pointer(), stream.size()));
#else
throw protocol_disabled();
@@ -99,7 +99,7 @@ void PPI::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU *) {
}
void PPI::parse_80211(const uint8_t* buffer, uint32_t total_sz) {
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
if (data_.size() >= 13) {
// Is FCS-at-end on?
if ((data_[12] & 1) == 1) {
@@ -111,7 +111,7 @@ void PPI::parse_80211(const uint8_t* buffer, uint32_t total_sz) {
}
}
inner_pdu(Dot11::from_bytes(buffer, total_sz));
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11
}
} // Tins

View File

@@ -29,7 +29,7 @@
#include "radiotap.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include <stdexcept>
@@ -576,4 +576,4 @@ void RadioTap::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU
} // Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -28,7 +28,7 @@
*/
#include "rsn_information.h"
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include <stdexcept>
@@ -137,4 +137,4 @@ RSNInformation RSNInformation::from_option(const PDUOption<uint8_t, Dot11>& opt)
} // Tins
#endif // HAVE_DOT11
#endif // TINS_HAVE_DOT11

View File

@@ -120,7 +120,7 @@ void sniff_loop_eth_handler(u_char* user, const struct pcap_pkthdr* h, const u_c
}
}
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
void sniff_loop_dot11_handler(u_char* user, const struct pcap_pkthdr* h, const u_char* bytes) {
sniff_data* data = (sniff_data*)user;
data->packet_processed = true;
@@ -145,14 +145,14 @@ PtrPacket BaseSniffer::next_packet() {
handler = sniff_loop_eth_handler;
}
else if (iface_type == DLT_IEEE802_11_RADIO) {
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
handler = &sniff_loop_handler<RadioTap>;
#else
throw protocol_disabled();
#endif
}
else if (iface_type == DLT_IEEE802_11) {
#ifdef HAVE_DOT11
#ifdef TINS_HAVE_DOT11
handler = sniff_loop_dot11_handler;
#else
throw protocol_disabled();

View File

@@ -29,7 +29,7 @@
#include "tcp_ip/ack_tracker.h"
#ifdef HAVE_ACK_TRACKER
#ifdef TINS_HAVE_ACK_TRACKER
#include <limits>
#include "tcp.h"
@@ -171,4 +171,4 @@ bool AckTracker::is_segment_acked(uint32_t sequence_number, uint32_t length) con
} // TCPIP
} // Tins
#endif // HAVE_ACK_TRACKER
#endif // TINS_HAVE_ACK_TRACKER

View File

@@ -97,11 +97,11 @@ void Flow::process_packet(PDU& pdu) {
// Update the internal state first
if (tcp) {
update_state(*tcp);
#ifdef HAVE_ACK_TRACKER
#ifdef TINS_HAVE_ACK_TRACKER
if (flags_.ack_tracking) {
ack_tracker_.process_packet(*tcp);
}
#endif // HAVE_ACK_TRACKER
#endif // TINS_HAVE_ACK_TRACKER
}
if (flags_.ignore_data_packets) {
return;
@@ -213,17 +213,17 @@ void Flow::update_state(const TCP& tcp) {
state_ = RST_SENT;
}
else if (state_ == SYN_SENT && (tcp.flags() & TCP::ACK) != 0) {
#ifdef HAVE_ACK_TRACKER
#ifdef TINS_HAVE_ACK_TRACKER
ack_tracker_ = AckTracker(tcp.ack_seq());
#endif // HAVE_ACK_TRACKER
#endif // TINS_HAVE_ACK_TRACKER
state_ = ESTABLISHED;
seq_number_++;
}
else if (state_ == UNKNOWN && (tcp.flags() & TCP::SYN) != 0) {
// This is the server's state, sending it's first SYN|ACK
#ifdef HAVE_ACK_TRACKER
#ifdef TINS_HAVE_ACK_TRACKER
ack_tracker_ = AckTracker(tcp.ack_seq());
#endif // HAVE_ACK_TRACKER
#endif // TINS_HAVE_ACK_TRACKER
state_ = SYN_SENT;
seq_number_ = tcp.seq();
const TCP::option* mss_option = tcp.search_option(TCP::MSS);
@@ -318,7 +318,7 @@ bool Flow::sack_permitted() const {
}
void Flow::enable_ack_tracking() {
#ifdef HAVE_ACK_TRACKER
#ifdef TINS_HAVE_ACK_TRACKER
flags_.ack_tracking = 1;
#else
throw feature_disabled();
@@ -329,7 +329,7 @@ bool Flow::ack_tracking_enabled() const {
return flags_.ack_tracking;
}
#ifdef HAVE_ACK_TRACKER
#ifdef TINS_HAVE_ACK_TRACKER
const AckTracker& Flow::ack_tracker() const {
return ack_tracker_;
}
@@ -338,7 +338,7 @@ AckTracker& Flow::ack_tracker() {
return ack_tracker_;
}
#endif // HAVE_ACK_TRACKER
#endif // TINS_HAVE_ACK_TRACKER
} // TCPIP
} // Tins

View File

@@ -129,7 +129,7 @@ void StreamFollower::process_packet(PDU& packet, const timestamp_type& ts) {
bool terminate_stream = total_chunks > max_buffered_chunks_ ||
total_buffered_bytes > max_buffered_bytes_;
TerminationReason reason = BUFFERED_DATA;
#ifdef HAVE_ACK_TRACKER
#ifdef TINS_HAVE_ACK_TRACKER
if (!terminate_stream) {
uint32_t count = 0;
count += stream.client_flow().ack_tracker().acked_intervals().iterative_size();
@@ -137,7 +137,7 @@ void StreamFollower::process_packet(PDU& packet, const timestamp_type& ts) {
terminate_stream = count > DEFAULT_MAX_SACKED_INTERVALS;
reason = SACKED_SEGMENTS;
}
#endif // HAVE_ACK_TRACKER
#endif // TINS_HAVE_ACK_TRACKER
if (stream.is_finished() || terminate_stream) {
// If we're terminating the stream, execute the termination callback
if (terminate_stream && on_stream_termination_) {