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

Moved definitions inside TINS_IS_CXX11 into header files.

This commit is contained in:
Matias Fontanini
2013-04-23 13:04:57 -03:00
parent f8134be8b7
commit 0f2bc45059
22 changed files with 90 additions and 148 deletions

View File

@@ -82,13 +82,6 @@ void DHCP::add_option(const option &opt) {
_options.push_back(opt);
}
#if TINS_IS_CXX11
void DHCP::add_option(option &&opt) {
internal_add_option(opt);
_options.push_back(std::move(opt));
}
#endif
void DHCP::internal_add_option(const option &opt) {
_size += opt.data_size() + (sizeof(uint8_t) << 1);
}

View File

@@ -107,24 +107,6 @@ DNSResourceRecord& DNSResourceRecord::operator=(const DNSResourceRecord &rhs)
return *this;
}
#if TINS_IS_CXX11
DNSResourceRecord::DNSResourceRecord(DNSResourceRecord &&rhs) noexcept
: info_(rhs.info_), data(std::move(rhs.data)), impl(0) {
std::swap(impl, rhs.impl);
}
DNSResourceRecord& DNSResourceRecord::operator=(DNSResourceRecord &&rhs)
noexcept
{
info_ = rhs.info_;
data = std::move(rhs.data);
delete impl;
impl = 0;
std::swap(impl, rhs.impl);
return *this;
}
#endif
DNSResourceRecord::~DNSResourceRecord() {
delete impl;
}

View File

@@ -104,13 +104,6 @@ void Dot11::add_tagged_option(OptionTypes opt, uint8_t len, const uint8_t *val)
_options_size += opt_size;
}
#if TINS_IS_CXX11
void Dot11::add_option(option &&opt) {
internal_add_option(opt);
_options.push_back(std::move(opt));
}
#endif
void Dot11::internal_add_option(const option &opt) {
_options_size += opt.data_size() + sizeof(uint8_t) * 2;
}

View File

@@ -251,13 +251,6 @@ void ICMPv6::add_option(const option &option) {
_options.push_back(option);
}
#if TINS_IS_CXX11
void ICMPv6::add_option(option &&option) {
internal_add_option(option);
_options.push_back(std::move(option));
}
#endif
void ICMPv6::internal_add_option(const option &option) {
_options_size += option.data_size() + sizeof(uint8_t) * 2;
}

View File

@@ -293,13 +293,6 @@ uint16_t IP::stream_identifier() const {
return Endian::be_to_host(*(const uint16_t*)option->data_ptr());
}
#if TINS_IS_CXX11
void IP::add_option(option &&opt) {
internal_add_option(opt);
_ip_options.push_back(std::move(opt));
}
#endif
void IP::add_option(const option &opt) {
internal_add_option(opt);
_ip_options.push_back(opt);

View File

@@ -97,33 +97,6 @@ PacketSender::PacketSender(const NetworkInterface &iface, uint32_t recv_timeout,
_types[ICMP_SOCKET] = IPPROTO_ICMP;
}
#if TINS_IS_CXX11
PacketSender::PacketSender(PacketSender &&rhs)
{
*this = std::move(rhs);
}
PacketSender& PacketSender::operator=(PacketSender &&rhs)
{
_sockets = std::move(rhs._sockets);
rhs._sockets = std::vector<int>(SOCKETS_END, INVALID_RAW_SOCKET);
#ifndef WIN32
#if defined(BSD) || defined(__FreeBSD_kernel__)
_ether_socket = std::move(rhs._ether_socket);
#else
_ether_socket = rhs._ether_socket;
rhs._ether_socket = INVALID_RAW_SOCKET;
#endif
#endif
_types = rhs._types; // no move
_timeout = rhs._timeout;
_timeout_usec = rhs._timeout_usec;
default_iface = rhs.default_iface;
return *this;
}
#endif
PacketSender::~PacketSender() {
for(unsigned i(0); i < _sockets.size(); ++i) {
if(_sockets[i] != INVALID_RAW_SOCKET)

View File

@@ -47,20 +47,6 @@ PacketWriter::PacketWriter(const std::string &file_name, LinkType lt) {
}
}
#if TINS_IS_CXX11
PacketWriter::PacketWriter(PacketWriter &&rhs) noexcept {
*this = std::move(rhs);
}
PacketWriter& PacketWriter::operator=(PacketWriter &&rhs) noexcept {
handle = 0;
dumper = 0;
std::swap(handle, rhs.handle);
std::swap(dumper, rhs.dumper);
return *this;
}
#endif
PacketWriter::~PacketWriter() {
if(dumper && handle) {
pcap_dump_close(dumper);

View File

@@ -40,19 +40,6 @@ PDU::PDU(PDU *next_pdu) : _inner_pdu(next_pdu) {
}
#if TINS_IS_CXX11
PDU::PDU(PDU &&rhs) noexcept
: _inner_pdu(0)
{
std::swap(_inner_pdu, rhs._inner_pdu);
}
PDU& PDU::operator=(PDU &&rhs) noexcept {
std::swap(_inner_pdu, rhs._inner_pdu);
return *this;
}
#endif
PDU::PDU(const PDU &other) : _inner_pdu(0) {
copy_inner_pdu(other);
}

View File

@@ -131,13 +131,6 @@ void PPPoE::add_tag(const tag &option) {
_tags.push_back(option);
}
#if TINS_IS_CXX11
void PPPoE::add_tag(tag &&option) {
_tags_size += option.data_size() + sizeof(uint16_t) * 2;
_tags.push_back(std::move(option));
}
#endif
// *********************** Setters *************************
void PPPoE::end_of_list() {

View File

@@ -39,24 +39,6 @@ BaseSniffer::BaseSniffer() : handle(0), mask(0)
{
actual_filter.bf_insns = 0;
}
#if TINS_IS_CXX11
BaseSniffer::BaseSniffer(BaseSniffer &&rhs) noexcept
{
*this = std::move(rhs);
}
BaseSniffer& BaseSniffer::operator=(BaseSniffer &&rhs) noexcept
{
handle = 0;
mask = rhs.mask;
iface_type = rhs.iface_type;
actual_filter.bf_insns = 0;
std::swap(handle, rhs.handle);
std::swap(actual_filter, rhs.actual_filter);
return *this;
}
#endif
BaseSniffer::~BaseSniffer() {
if(actual_filter.bf_insns)

View File

@@ -349,13 +349,6 @@ uint8_t *TCP::write_option(const option &opt, uint8_t *buffer) {
}
}
#if TINS_IS_CXX11
void TCP::add_option(option &&opt) {
internal_add_option(opt);
_options.push_back(std::move(opt));
}
#endif
void TCP::internal_add_option(const option &opt) {
uint8_t padding;