mirror of
https://github.com/mfontanini/libtins
synced 2026-01-28 20:44:26 +01:00
Added BaseSniffer::timestamp method.
This commit is contained in:
40
depends.d
40
depends.d
@@ -94,7 +94,7 @@ include/ethernetII.h:
|
||||
|
||||
include/network_interface.h:
|
||||
src/dns.o: src/dns.cpp include/dns.h include/pdu.h include/endianness.h \
|
||||
include/dns_record.h include/ip_address.h
|
||||
include/dns_record.h include/ip_address.h include/ipv6_address.h
|
||||
|
||||
include/dns.h:
|
||||
|
||||
@@ -105,6 +105,8 @@ include/endianness.h:
|
||||
include/dns_record.h:
|
||||
|
||||
include/ip_address.h:
|
||||
|
||||
include/ipv6_address.h:
|
||||
src/dns_record.o: src/dns_record.cpp include/dns_record.h \
|
||||
include/endianness.h
|
||||
|
||||
@@ -114,8 +116,8 @@ include/endianness.h:
|
||||
src/dot11.o: src/dot11.cpp include/dot11.h include/pdu.h \
|
||||
include/endianness.h include/hw_address.h include/small_uint.h \
|
||||
include/pdu_option.h include/network_interface.h include/ip_address.h \
|
||||
include/rawpdu.h include/radiotap.h include/rsn_information.h \
|
||||
include/packet_sender.h include/snap.h
|
||||
include/rawpdu.h include/rsn_information.h include/packet_sender.h \
|
||||
include/snap.h
|
||||
|
||||
include/dot11.h:
|
||||
|
||||
@@ -135,8 +137,6 @@ include/ip_address.h:
|
||||
|
||||
include/rawpdu.h:
|
||||
|
||||
include/radiotap.h:
|
||||
|
||||
include/rsn_information.h:
|
||||
|
||||
include/packet_sender.h:
|
||||
@@ -272,6 +272,9 @@ include/hw_address.h:
|
||||
include/packet_sender.h:
|
||||
|
||||
include/constants.h:
|
||||
src/ipv6_address.o: src/ipv6_address.cpp include/ipv6_address.h
|
||||
|
||||
include/ipv6_address.h:
|
||||
src/llc.o: src/llc.cpp include/pdu.h include/llc.h include/pdu.h \
|
||||
include/endianness.h include/rawpdu.h
|
||||
|
||||
@@ -328,10 +331,16 @@ include/pdu.h:
|
||||
|
||||
include/packet_sender.h:
|
||||
src/packet_writer.o: src/packet_writer.cpp include/packet_writer.h \
|
||||
include/pdu.h
|
||||
include/utils.h include/ip_address.h include/hw_address.h include/pdu.h
|
||||
|
||||
include/packet_writer.h:
|
||||
|
||||
include/utils.h:
|
||||
|
||||
include/ip_address.h:
|
||||
|
||||
include/hw_address.h:
|
||||
|
||||
include/pdu.h:
|
||||
src/pdu.o: src/pdu.cpp include/pdu.h include/rawpdu.h include/pdu.h \
|
||||
include/packet_sender.h
|
||||
@@ -466,7 +475,7 @@ src/tcp_stream.o: src/tcp_stream.cpp include/rawpdu.h include/pdu.h \
|
||||
include/endianness.h include/hw_address.h include/network_interface.h \
|
||||
include/ip_address.h include/radiotap.h include/loopback.h \
|
||||
include/dot11.h include/small_uint.h include/pdu_option.h include/tcp.h \
|
||||
include/ip.h
|
||||
include/utils.h include/ip.h
|
||||
|
||||
include/rawpdu.h:
|
||||
|
||||
@@ -498,6 +507,8 @@ include/pdu_option.h:
|
||||
|
||||
include/tcp.h:
|
||||
|
||||
include/utils.h:
|
||||
|
||||
include/ip.h:
|
||||
src/udp.o: src/udp.cpp include/udp.h include/pdu.h include/endianness.h \
|
||||
include/constants.h include/utils.h include/ip_address.h \
|
||||
@@ -526,10 +537,9 @@ include/pdu_option.h:
|
||||
|
||||
include/rawpdu.h:
|
||||
src/utils.o: src/utils.cpp include/utils.h include/ip_address.h \
|
||||
include/hw_address.h include/pdu.h include/ip.h include/pdu.h \
|
||||
include/small_uint.h include/endianness.h include/pdu_option.h \
|
||||
include/arp.h include/endianness.h include/network_interface.h \
|
||||
include/packet_sender.h
|
||||
include/hw_address.h include/pdu.h include/arp.h include/pdu.h \
|
||||
include/endianness.h include/ethernetII.h include/network_interface.h \
|
||||
include/endianness.h include/network_interface.h include/packet_sender.h
|
||||
|
||||
include/utils.h:
|
||||
|
||||
@@ -539,17 +549,15 @@ include/hw_address.h:
|
||||
|
||||
include/pdu.h:
|
||||
|
||||
include/ip.h:
|
||||
include/arp.h:
|
||||
|
||||
include/pdu.h:
|
||||
|
||||
include/small_uint.h:
|
||||
|
||||
include/endianness.h:
|
||||
|
||||
include/pdu_option.h:
|
||||
include/ethernetII.h:
|
||||
|
||||
include/arp.h:
|
||||
include/network_interface.h:
|
||||
|
||||
include/endianness.h:
|
||||
|
||||
|
||||
@@ -108,6 +108,17 @@ namespace Tins {
|
||||
* \brief Stops sniffing loops.
|
||||
*/
|
||||
void stop_sniff();
|
||||
|
||||
/**
|
||||
* \brief Retrieves the timestamp taken from the last packet
|
||||
* captured in the sniffing session.
|
||||
*
|
||||
* This timestamp will be modified each time a packet is captured
|
||||
* using both BaseSniffer::sniff_loop and BaseSniffer::next_packet.
|
||||
*/
|
||||
const struct timeval ×tamp() const {
|
||||
return timestamp_;
|
||||
}
|
||||
protected:
|
||||
/**
|
||||
* Default constructor.
|
||||
@@ -130,10 +141,12 @@ namespace Tins {
|
||||
pcap_t *handle;
|
||||
Functor c_handler;
|
||||
int iface_type;
|
||||
timeval ×tamp;
|
||||
|
||||
LoopData(pcap_t *_handle, const Functor _handler,
|
||||
int if_type)
|
||||
: handle(_handle), c_handler(_handler), iface_type(if_type) { }
|
||||
int if_type, timeval &ts)
|
||||
: handle(_handle), c_handler(_handler), iface_type(if_type),
|
||||
timestamp(ts) { }
|
||||
};
|
||||
|
||||
BaseSniffer(const BaseSniffer&);
|
||||
@@ -151,6 +164,7 @@ namespace Tins {
|
||||
bpf_u_int32 mask;
|
||||
bpf_program actual_filter;
|
||||
int iface_type;
|
||||
timeval timestamp_;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -195,7 +209,7 @@ namespace Tins {
|
||||
|
||||
template<class Functor>
|
||||
void Tins::BaseSniffer::sniff_loop(Functor function, uint32_t max_packets) {
|
||||
LoopData<Functor> data(handle, function, iface_type);
|
||||
LoopData<Functor> data(handle, function, iface_type, timestamp_);
|
||||
pcap_loop(handle, max_packets, &BaseSniffer::callback_handler<Functor>, (u_char*)&data);
|
||||
}
|
||||
|
||||
@@ -211,6 +225,7 @@ namespace Tins {
|
||||
std::auto_ptr<PDU> pdu;
|
||||
LoopData<Functor> *data = reinterpret_cast<LoopData<Functor>*>(args);
|
||||
bool ret_val(false);
|
||||
data->timestamp = header->ts;
|
||||
if(data->iface_type == DLT_EN10MB)
|
||||
ret_val = call_functor<Tins::EthernetII>(data, packet, header->caplen);
|
||||
else if(data->iface_type == DLT_IEEE802_11_RADIO)
|
||||
|
||||
@@ -34,7 +34,7 @@ using std::string;
|
||||
using std::runtime_error;
|
||||
|
||||
namespace Tins {
|
||||
BaseSniffer::BaseSniffer() : handle(0), mask(0)
|
||||
BaseSniffer::BaseSniffer() : handle(0), mask(0), timestamp_()
|
||||
{
|
||||
actual_filter.bf_insns = 0;
|
||||
}
|
||||
@@ -66,6 +66,7 @@ PDU *BaseSniffer::next_packet() {
|
||||
pcap_pkthdr header;
|
||||
PDU *ret = 0;
|
||||
const u_char *content = pcap_next(handle, &header);
|
||||
timestamp_ = header.ts;
|
||||
if(content) {
|
||||
if(iface_type == DLT_EN10MB)
|
||||
ret = new EthernetII((const uint8_t*)content, header.caplen);
|
||||
|
||||
@@ -45,8 +45,9 @@ src/dhcp.o: src/dhcp.cpp ../include/dhcp.h ../include/bootp.h \
|
||||
|
||||
../include/ip_address.h:
|
||||
src/dns.o: src/dns.cpp ../include/dns.h ../include/pdu.h \
|
||||
../include/endianness.h ../include/dns_record.h ../include/utils.h \
|
||||
../include/ip_address.h ../include/hw_address.h
|
||||
../include/endianness.h ../include/dns_record.h \
|
||||
../include/ipv6_address.h ../include/utils.h ../include/ip_address.h \
|
||||
../include/hw_address.h
|
||||
|
||||
../include/dns.h:
|
||||
|
||||
@@ -56,6 +57,8 @@ src/dns.o: src/dns.cpp ../include/dns.h ../include/pdu.h \
|
||||
|
||||
../include/dns_record.h:
|
||||
|
||||
../include/ipv6_address.h:
|
||||
|
||||
../include/utils.h:
|
||||
|
||||
../include/ip_address.h:
|
||||
@@ -137,6 +140,16 @@ src/ip.o: src/ip.cpp ../include/ip.h ../include/pdu.h \
|
||||
|
||||
../include/utils.h:
|
||||
|
||||
../include/hw_address.h:
|
||||
src/ipv6address.o: src/ipv6address.cpp ../include/ipv6_address.h \
|
||||
../include/utils.h ../include/ip_address.h ../include/hw_address.h
|
||||
|
||||
../include/ipv6_address.h:
|
||||
|
||||
../include/utils.h:
|
||||
|
||||
../include/ip_address.h:
|
||||
|
||||
../include/hw_address.h:
|
||||
src/llc.o: src/llc.cpp ../include/llc.h ../include/pdu.h \
|
||||
../include/endianness.h
|
||||
@@ -276,7 +289,7 @@ src/tcp_stream.o: src/tcp_stream.cpp ../include/tcp_stream.h \
|
||||
../include/network_interface.h ../include/ip_address.h \
|
||||
../include/radiotap.h ../include/loopback.h ../include/dot11.h \
|
||||
../include/small_uint.h ../include/pdu_option.h ../include/tcp.h \
|
||||
../include/ip.h ../include/tcp.h ../include/utils.h
|
||||
../include/utils.h ../include/ip.h ../include/tcp.h ../include/utils.h
|
||||
|
||||
../include/tcp_stream.h:
|
||||
|
||||
@@ -306,6 +319,8 @@ src/tcp_stream.o: src/tcp_stream.cpp ../include/tcp_stream.h \
|
||||
|
||||
../include/tcp.h:
|
||||
|
||||
../include/utils.h:
|
||||
|
||||
../include/ip.h:
|
||||
|
||||
../include/tcp.h:
|
||||
@@ -915,7 +930,8 @@ include/tests/dot11.h:
|
||||
|
||||
../include/network_interface.h:
|
||||
../src/dns.o: ../src/dns.cpp ../include/dns.h ../include/pdu.h \
|
||||
../include/endianness.h ../include/dns_record.h ../include/ip_address.h
|
||||
../include/endianness.h ../include/dns_record.h ../include/ip_address.h \
|
||||
../include/ipv6_address.h
|
||||
|
||||
../include/dns.h:
|
||||
|
||||
@@ -926,6 +942,8 @@ include/tests/dot11.h:
|
||||
../include/dns_record.h:
|
||||
|
||||
../include/ip_address.h:
|
||||
|
||||
../include/ipv6_address.h:
|
||||
../src/dns_record.o: ../src/dns_record.cpp ../include/dns_record.h \
|
||||
../include/endianness.h
|
||||
|
||||
@@ -1095,6 +1113,9 @@ include/tests/dot11.h:
|
||||
../include/packet_sender.h:
|
||||
|
||||
../include/constants.h:
|
||||
../src/ipv6_address.o: ../src/ipv6_address.cpp ../include/ipv6_address.h
|
||||
|
||||
../include/ipv6_address.h:
|
||||
../src/llc.o: ../src/llc.cpp ../include/pdu.h ../include/llc.h \
|
||||
../include/pdu.h ../include/endianness.h ../include/rawpdu.h
|
||||
|
||||
@@ -1151,10 +1172,17 @@ include/tests/dot11.h:
|
||||
|
||||
../include/packet_sender.h:
|
||||
../src/packet_writer.o: ../src/packet_writer.cpp \
|
||||
../include/packet_writer.h ../include/pdu.h
|
||||
../include/packet_writer.h ../include/utils.h ../include/ip_address.h \
|
||||
../include/hw_address.h ../include/pdu.h
|
||||
|
||||
../include/packet_writer.h:
|
||||
|
||||
../include/utils.h:
|
||||
|
||||
../include/ip_address.h:
|
||||
|
||||
../include/hw_address.h:
|
||||
|
||||
../include/pdu.h:
|
||||
../src/pdu.o: ../src/pdu.cpp ../include/pdu.h ../include/rawpdu.h \
|
||||
../include/pdu.h ../include/packet_sender.h
|
||||
@@ -1291,7 +1319,7 @@ include/tests/dot11.h:
|
||||
../include/network_interface.h ../include/ip_address.h \
|
||||
../include/radiotap.h ../include/loopback.h ../include/dot11.h \
|
||||
../include/small_uint.h ../include/pdu_option.h ../include/tcp.h \
|
||||
../include/ip.h
|
||||
../include/utils.h ../include/ip.h
|
||||
|
||||
../include/rawpdu.h:
|
||||
|
||||
@@ -1323,6 +1351,8 @@ include/tests/dot11.h:
|
||||
|
||||
../include/tcp.h:
|
||||
|
||||
../include/utils.h:
|
||||
|
||||
../include/ip.h:
|
||||
../src/udp.o: ../src/udp.cpp ../include/udp.h ../include/pdu.h \
|
||||
../include/endianness.h ../include/constants.h ../include/utils.h \
|
||||
@@ -1352,8 +1382,8 @@ include/tests/dot11.h:
|
||||
../include/rawpdu.h:
|
||||
../src/utils.o: ../src/utils.cpp ../include/utils.h \
|
||||
../include/ip_address.h ../include/hw_address.h ../include/pdu.h \
|
||||
../include/ip.h ../include/pdu.h ../include/small_uint.h \
|
||||
../include/endianness.h ../include/pdu_option.h ../include/arp.h \
|
||||
../include/arp.h ../include/pdu.h ../include/endianness.h \
|
||||
../include/ethernetII.h ../include/network_interface.h \
|
||||
../include/endianness.h ../include/network_interface.h \
|
||||
../include/packet_sender.h
|
||||
|
||||
@@ -1365,17 +1395,15 @@ include/tests/dot11.h:
|
||||
|
||||
../include/pdu.h:
|
||||
|
||||
../include/ip.h:
|
||||
../include/arp.h:
|
||||
|
||||
../include/pdu.h:
|
||||
|
||||
../include/small_uint.h:
|
||||
|
||||
../include/endianness.h:
|
||||
|
||||
../include/pdu_option.h:
|
||||
../include/ethernetII.h:
|
||||
|
||||
../include/arp.h:
|
||||
../include/network_interface.h:
|
||||
|
||||
../include/endianness.h:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user