Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mfontanini committed Feb 1, 2017
2 parents 9051197 + a71a3d2 commit 7607610
Show file tree
Hide file tree
Showing 36 changed files with 90 additions and 72 deletions.
9 changes: 0 additions & 9 deletions AUTHORS

This file was deleted.

18 changes: 9 additions & 9 deletions CHANGES → CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v3.4 - Wed Mar 9 20:24:54 PST 2016
##### v3.4 - Wed Mar 9 20:24:54 PST 2016

- Check the secure bit on HandshakeCapturer to detect 2nd packet

Expand Down Expand Up @@ -50,7 +50,7 @@ v3.4 - Wed Mar 9 20:24:54 PST 2016

- Fix invalid endian on IP fragment offset on OSX

v3.3 - Sun Jan 31 21:06:04 PST 2016
##### v3.3 - Sun Jan 31 21:06:04 PST 2016

- Add TCP connection close example

Expand Down Expand Up @@ -215,7 +215,7 @@ immutable

-------------------------------------------------------------------------------

v3.2 - Fri Mar 20 22:12:23 PST 2015
##### v3.2 - Fri Mar 20 22:12:23 PST 2015

- Added include guard for config.h.

Expand Down Expand Up @@ -298,7 +298,7 @@ conversion on integral constant.

-------------------------------------------------------------------------------

v3.1 - Sun Aug 24 21:39:43 ART 2014
##### v3.1 - Sun Aug 24 21:39:43 ART 2014

- Fixed ICMPv6 checksum error on serialization.

Expand All @@ -308,7 +308,7 @@ v3.1 - Sun Aug 24 21:39:43 ART 2014

-------------------------------------------------------------------------------

v3.0 - Thu Aug 7 21:39:09 ART 2014
##### v3.0 - Thu Aug 7 21:39:09 ART 2014

- Timestamps can now be constructed from std::chrono::duration.

Expand Down Expand Up @@ -373,7 +373,7 @@ PDU types.

-------------------------------------------------------------------------------

v2.0 - Thu Jan 23 11:09:38 ART 2014
##### v2.0 - Thu Jan 23 11:09:38 ART 2014

- DNSResourceRecord was removed. Now DNS records are added using
DNS::Resource.
Expand Down Expand Up @@ -429,7 +429,7 @@ capture size.

-------------------------------------------------------------------------------

v1.2 - Mon oct 7 23:33:49 ART 2013
##### v1.2 - Mon oct 7 23:33:49 ART 2013

- Added BaseSniffer::begin and BaseSniffer::end.

Expand Down Expand Up @@ -525,7 +525,7 @@ that used them.

-------------------------------------------------------------------------------

v0.3 - Thu Jan 31 16:47:27 ART 2013
##### v0.3 - Thu Jan 31 16:47:27 ART 2013

- Added IPv6, ICMPv6 and DHCPv6 classes.

Expand All @@ -546,7 +546,7 @@ pseudo protocol.

-------------------------------------------------------------------------------

v0.2 - Sat Oct 20 11:26:40 2012
##### v0.2 - Sat Oct 20 11:26:40 2012

- Added support for big endian architectures.

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ IF(MSVC)
ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS=1")
ADD_DEFINITIONS("-DNOGDI=1")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
ENDIF()

IF(APPLE)
Expand Down
2 changes: 2 additions & 0 deletions include/tins/cxxstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ struct smart_ptr {
typedef std::auto_ptr<T> type;
#endif
};

template<class T> void unused(const T&) { }
}
}

Expand Down
4 changes: 2 additions & 2 deletions include/tins/dot11/dot11_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ class TINS_API Dot11 : public PDU {
*/
static Dot11* from_bytes(const uint8_t* buffer, uint32_t total_sz);
protected:
virtual void write_ext_header(Memory::OutputMemoryStream& stream) { }
virtual void write_fixed_parameters(Memory::OutputMemoryStream& stream) { }
virtual void write_ext_header(Memory::OutputMemoryStream& stream);
virtual void write_fixed_parameters(Memory::OutputMemoryStream& stream);
void parse_tagged_parameters(Memory::InputMemoryStream& stream);
void add_tagged_option(OptionTypes opt, uint8_t len, const uint8_t* val);
protected:
Expand Down
2 changes: 1 addition & 1 deletion include/tins/hw_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class HWAddress {
*
* This effectively returns the address_size constant.
*/
const size_t size() const {
size_t size() const {
return address_size;
}

Expand Down
10 changes: 4 additions & 6 deletions include/tins/pdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ class TINS_API PDU {
*/
template<typename T>
const T* find_pdu(PDUType type = T::pdu_flag) const {
return const_cast<PDU*>(this)->find_pdu<T>();
return const_cast<PDU*>(this)->find_pdu<T>(type);
}

/**
Expand Down Expand Up @@ -381,7 +381,7 @@ class TINS_API PDU {
*/
template<typename T>
const T& rfind_pdu(PDUType type = T::pdu_flag) const {
return const_cast<PDU*>(this)->rfind_pdu<T>();
return const_cast<PDU*>(this)->rfind_pdu<T>(type);
}

/**
Expand Down Expand Up @@ -433,9 +433,7 @@ class TINS_API PDU {
* \param ptr The pointer to the buffer.
* \param total_sz The size of the buffer.
*/
virtual bool matches_response(const uint8_t* ptr, uint32_t total_sz) const {
return false;
}
virtual bool matches_response(const uint8_t* ptr, uint32_t total_sz) const;

/**
* \brief Check whether this PDU matches the specified flag.
Expand Down Expand Up @@ -485,7 +483,7 @@ class TINS_API PDU {
*
* \param parent The parent PDU.
*/
virtual void prepare_for_serialize(const PDU* parent) { }
virtual void prepare_for_serialize(const PDU* parent);

/**
* \brief Serializes this PDU and propagates this action to child PDUs.
Expand Down
2 changes: 1 addition & 1 deletion src/arp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/bootp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/dhcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/dhcpv6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions src/dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ using Tins::Memory::OutputMemoryStream;

namespace Tins {

PDU::metadata DNS::extract_metadata(const uint8_t *buffer, uint32_t total_sz) {
if (TINS_UNLIKELY(sizeof(dns_header))) {
PDU::metadata DNS::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
if (TINS_UNLIKELY(total_sz < sizeof(dns_header))) {
throw malformed_packet();
}
return metadata(total_sz, pdu_flag, PDU::UNKNOWN);
Expand Down Expand Up @@ -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());
Expand Down
11 changes: 8 additions & 3 deletions src/dot11/dot11_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/dot1q.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/dot3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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_);
Expand Down
2 changes: 1 addition & 1 deletion src/ethernetII.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/icmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions src/ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
4 changes: 2 additions & 2 deletions src/ipv6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -243,7 +243,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());
Expand Down
2 changes: 1 addition & 1 deletion src/llc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/offline_packet_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/

#include <stdexcept>
#include <string.h>
#include "offline_packet_filter.h"
#include "pdu.h"
#include "exceptions.h"
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/packet_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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());
Expand Down
Loading

0 comments on commit 7607610

Please sign in to comment.