Skip to content

Commit

Permalink
Remove useless includes
Browse files Browse the repository at this point in the history
  • Loading branch information
mfontanini committed May 1, 2017
1 parent a9747a3 commit 19ae1f3
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 58 deletions.
5 changes: 3 additions & 2 deletions include/tins/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#ifndef TINS_PACKET_H
#define TINS_PACKET_H

#include <algorithm>
#include "cxxstd.h"
#include "pdu.h"
#include "timestamp.h"
Expand Down Expand Up @@ -234,7 +233,9 @@ class Packet {
*/
Packet& operator=(Packet &&rhs) TINS_NOEXCEPT {
if (this != &rhs) {
std::swap(pdu_, rhs.pdu_);
PDU* tmp = std::move(pdu_);
pdu_ = std::move(rhs.pdu_);
rhs.pdu_ = std::move(tmp);
ts_ = rhs.timestamp();
}
return* this;
Expand Down
3 changes: 0 additions & 3 deletions include/tins/tcp_ip/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@

#ifdef TINS_HAVE_TCPIP

#include <vector>
#include <array>
#include <map>
#include <functional>
#include <stdint.h>
#include "../hw_address.h"
#include "../macros.h"
#include "ack_tracker.h"
#include "data_tracker.h"
Expand Down
1 change: 0 additions & 1 deletion include/tins/tcp_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include <map>
#include <utility>
#include <iterator>
#include <vector>
#include <algorithm>
#include <stdint.h>
Expand Down
4 changes: 1 addition & 3 deletions src/arp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@
#include <cstring>
#include <algorithm>
#include "arp.h"
#include "ip.h"
#include "ethernetII.h"
#include "rawpdu.h"
#include "constants.h"
#include "network_interface.h"
#include "exceptions.h"
#include "memory_helpers.h"

Expand All @@ -58,7 +56,7 @@ ARP::ARP(ipaddress_type target_ip,
hw_addr_format((uint16_t)Constants::ARP::ETHER);
prot_addr_format((uint16_t)Constants::Ethernet::IP);
hw_addr_length(Tins::EthernetII::address_type::address_size);
prot_addr_length(Tins::IP::address_type::address_size);
prot_addr_length(4 /* IP address size */);
sender_ip_addr(sender_ip);
target_ip_addr(target_ip);
sender_hw_addr(sender_hw);
Expand Down
5 changes: 2 additions & 3 deletions src/dhcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <algorithm>
#include "endianness.h"
#include "dhcp.h"
#include "ethernetII.h"
#include "exceptions.h"
#include "memory_helpers.h"

Expand All @@ -58,8 +57,8 @@ PDU::metadata DHCP::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_s
DHCP::DHCP()
: size_(sizeof(uint32_t)) {
opcode(BOOTREQUEST);
htype(1); //ethernet
hlen(EthernetII::address_type::address_size);
htype(1); // ethernet
hlen(6); // MAC address length
}

DHCP::DHCP(const uint8_t* buffer, uint32_t total_sz)
Expand Down
1 change: 0 additions & 1 deletion src/dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "ip_address.h"
#include "ipv6_address.h"
#include "exceptions.h"
#include "rawpdu.h"
#include "endianness.h"
#include "memory_helpers.h"

Expand Down
9 changes: 3 additions & 6 deletions src/dot11/dot11_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
#ifdef TINS_HAVE_DOT11

#include <cstring>
#include <stdexcept>
#include <algorithm>
#include <utility>
#include "macros.h"
#include "exceptions.h"

Expand All @@ -49,12 +47,11 @@
#include <netinet/in.h>
#endif
#include "dot11.h"
#include "rawpdu.h"
#include "rsn_information.h"
#include "packet_sender.h"
#include "snap.h"
#include "memory_helpers.h"

using std::list;

using Tins::Memory::InputMemoryStream;
using Tins::Memory::OutputMemoryStream;

Expand Down Expand Up @@ -218,7 +215,7 @@ void Dot11::write_serialization(uint8_t* buffer, uint32_t total_sz) {
stream.write(header_);
write_ext_header(stream);
write_fixed_parameters(stream);
for (std::list<option>::const_iterator it = options_.begin(); it != options_.end(); ++it) {
for (list<option>::const_iterator it = options_.begin(); it != options_.end(); ++it) {
stream.write<uint8_t>(it->option());
stream.write<uint8_t>(it->length_field());
stream.write(it->data_ptr(), it->data_size());
Expand Down
1 change: 0 additions & 1 deletion src/eapol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <stdexcept>
#include <algorithm>
#include "eapol.h"
#include "rsn_information.h"
#include "exceptions.h"
#include "rawpdu.h"
#include "memory_helpers.h"
Expand Down
4 changes: 0 additions & 4 deletions src/ethernetII.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@
#include "ethernetII.h"
#include "config.h"
#include "packet_sender.h"
#include "rawpdu.h"
#include "pppoe.h"
#include "ip.h"
#include "ipv6.h"
#include "arp.h"
#include "constants.h"
#include "exceptions.h"
#include "memory_helpers.h"
Expand Down
29 changes: 29 additions & 0 deletions src/hw_address.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
/*
* Copyright (c) 2017, Matias Fontanini
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/

#include <sstream>
#include <iomanip>
#include <stdexcept>
Expand Down
1 change: 0 additions & 1 deletion src/ip_reassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/

#include "ip.h"
#include "rawpdu.h"
#include "constants.h"
#include "ip_reassembler.h"
#include "detail/pdu_helpers.h"
Expand Down
1 change: 0 additions & 1 deletion src/ipv6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "pdu_allocator.h"
#include "memory_helpers.h"
#include "detail/pdu_helpers.h"
#include "pdu_allocator.h"

using std::copy;

Expand Down
1 change: 0 additions & 1 deletion src/packet_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#include <algorithm>
#include "pdu.h"
#include "macros.h"
#include "network_interface.h"
// PDUs required by PacketSender::send(PDU&, NetworkInterface)
#include "ethernetII.h"
#include "radiotap.h"
Expand Down
1 change: 0 additions & 1 deletion src/pdu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/

#include "pdu.h"
#include "rawpdu.h"
#include "packet_sender.h"

using std::swap;
Expand Down
3 changes: 0 additions & 3 deletions src/snap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
#endif
#include "snap.h"
#include "constants.h"
#include "arp.h"
#include "ip.h"
#include "eapol.h"
#include "exceptions.h"
#include "memory_helpers.h"
#include "detail/pdu_helpers.h"
Expand Down
2 changes: 0 additions & 2 deletions src/sniffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#define TINS_PREFIX_INTERFACE(x) (x)
#endif // _WIN32

#include <algorithm>
#include <sstream>
#include "sniffer.h"
#include "dot11/dot11_base.h"
#include "ethernetII.h"
Expand Down
5 changes: 1 addition & 4 deletions src/stp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@
*/

#include <cstring>
#include <algorithm>
#include "stp.h"
#include "exceptions.h"
#include "memory_helpers.h"

using std::copy;

using Tins::Memory::InputMemoryStream;
using Tins::Memory::OutputMemoryStream;

Expand Down Expand Up @@ -128,7 +125,7 @@ STP::bpdu_id_type STP::convert(const pvt_bpdu_id& id) {
STP::pvt_bpdu_id STP::convert(const bpdu_id_type& id) {
pvt_bpdu_id result;
result.priority = id.priority;
copy(id.id.begin(), id.id.end(), result.id);
id.id.copy(result.id);
#if TINS_IS_LITTLE_ENDIAN
result.ext_id = (id.ext_id >> 8) & 0xf;
result.ext_idL = id.ext_id & 0xff;
Expand Down
4 changes: 0 additions & 4 deletions src/tcp_ip/flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#ifdef TINS_HAVE_TCPIP

#include <limits>
#include <algorithm>
#include "memory.h"
#include "ip_address.h"
#include "ipv6_address.h"
#include "tcp.h"
Expand All @@ -49,8 +47,6 @@ using std::bind;
using std::pair;
using std::runtime_error;
using std::numeric_limits;
using std::max;
using std::swap;

using Tins::Memory::OutputMemoryStream;
using Tins::Memory::InputMemoryStream;
Expand Down
6 changes: 0 additions & 6 deletions src/tcp_ip/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#ifdef TINS_HAVE_TCPIP

#include <limits>
#include <algorithm>
#include "memory.h"
#include "ip_address.h"
#include "ipv6_address.h"
Expand All @@ -42,18 +41,13 @@
#include "ethernetII.h"
#include "rawpdu.h"
#include "exceptions.h"
#include "memory_helpers.h"

using std::make_pair;
using std::bind;
using std::pair;
using std::runtime_error;
using std::numeric_limits;
using std::max;
using std::swap;

using Tins::Memory::OutputMemoryStream;
using Tins::Memory::InputMemoryStream;

namespace Tins {
namespace TCPIP {
Expand Down
7 changes: 0 additions & 7 deletions src/tcp_ip/stream_follower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#ifdef TINS_HAVE_TCPIP

#include <limits>
#include <algorithm>
#include "memory.h"
#include "ip_address.h"
#include "ipv6_address.h"
Expand All @@ -42,22 +41,16 @@
#include "rawpdu.h"
#include "packet.h"
#include "exceptions.h"
#include "memory_helpers.h"

using std::make_pair;
using std::bind;
using std::pair;
using std::runtime_error;
using std::numeric_limits;
using std::max;
using std::swap;
using std::chrono::system_clock;
using std::chrono::minutes;
using std::chrono::duration_cast;

using Tins::Memory::OutputMemoryStream;
using Tins::Memory::InputMemoryStream;

namespace Tins {
namespace TCPIP {

Expand Down
8 changes: 4 additions & 4 deletions src/tcp_ip/stream_identifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ StreamIdentifier StreamIdentifier::make_identifier(const PDU& packet) {

StreamIdentifier StreamIdentifier::make_identifier(const Stream& stream) {
if (stream.is_v6()) {
return StreamIdentifier(serialize(stream.client_addr_v6()), stream.client_port(),
serialize(stream.server_addr_v6()), stream.server_port());
return StreamIdentifier(serialize(stream.client_addr_v6()), stream.client_port(),
serialize(stream.server_addr_v6()), stream.server_port());
} else {
return StreamIdentifier(serialize(stream.client_addr_v4()), stream.client_port(),
serialize(stream.server_addr_v4()), stream.server_port());
return StreamIdentifier(serialize(stream.client_addr_v4()), stream.client_port(),
serialize(stream.server_addr_v4()), stream.server_port());
}
}

Expand Down

0 comments on commit 19ae1f3

Please sign in to comment.