mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Renamed IEEE802_3 to Dot3.
This commit is contained in:
@@ -19,12 +19,12 @@ libtins_la_SOURCES=src/arp.cpp \
|
||||
src/dns.cpp \
|
||||
src/dns_record.cpp \
|
||||
src/dot11.cpp \
|
||||
src/dot3.cpp \
|
||||
src/dot1q.cpp \
|
||||
src/eapol.cpp \
|
||||
src/ethernetII.cpp \
|
||||
src/icmp.cpp \
|
||||
src/icmpv6.cpp \
|
||||
src/ieee802_3.cpp \
|
||||
src/internals.cpp \
|
||||
src/ip.cpp src/ip_address.cpp \
|
||||
src/ipv6.cpp \
|
||||
@@ -51,6 +51,7 @@ libtins_include_HEADERS = include/internals.h \
|
||||
include/dhcpv6.h \
|
||||
include/dot11.h \
|
||||
include/dot1q.h \
|
||||
include/dot3.h \
|
||||
include/small_uint.h \
|
||||
include/ip.h \
|
||||
include/dns_record.h \
|
||||
@@ -61,7 +62,6 @@ libtins_include_HEADERS = include/internals.h \
|
||||
include/endianness.h \
|
||||
include/rsn_information.h \
|
||||
include/loopback.h \
|
||||
include/ieee802_3.h \
|
||||
include/ethernetII.h \
|
||||
include/crypto.h \
|
||||
include/packet.h \
|
||||
|
||||
16
Makefile.in
16
Makefile.in
@@ -102,8 +102,8 @@ libtins_la_LIBADD =
|
||||
am__dirstamp = $(am__leading_dot)dirstamp
|
||||
am_libtins_la_OBJECTS = src/arp.lo src/bootp.lo src/crypto.lo \
|
||||
src/dhcp.lo src/dhcpv6.lo src/dns.lo src/dns_record.lo \
|
||||
src/dot11.lo src/dot1q.lo src/eapol.lo src/ethernetII.lo \
|
||||
src/icmp.lo src/icmpv6.lo src/ieee802_3.lo src/internals.lo \
|
||||
src/dot11.lo src/dot3.lo src/dot1q.lo src/eapol.lo \
|
||||
src/ethernetII.lo src/icmp.lo src/icmpv6.lo src/internals.lo \
|
||||
src/ip.lo src/ip_address.lo src/ipv6.lo src/ipv6_address.lo \
|
||||
src/llc.lo src/loopback.lo src/network_interface.lo \
|
||||
src/packet_sender.lo src/packet_writer.lo src/pdu.lo \
|
||||
@@ -291,12 +291,12 @@ libtins_la_SOURCES = src/arp.cpp \
|
||||
src/dns.cpp \
|
||||
src/dns_record.cpp \
|
||||
src/dot11.cpp \
|
||||
src/dot3.cpp \
|
||||
src/dot1q.cpp \
|
||||
src/eapol.cpp \
|
||||
src/ethernetII.cpp \
|
||||
src/icmp.cpp \
|
||||
src/icmpv6.cpp \
|
||||
src/ieee802_3.cpp \
|
||||
src/internals.cpp \
|
||||
src/ip.cpp src/ip_address.cpp \
|
||||
src/ipv6.cpp \
|
||||
@@ -323,6 +323,7 @@ libtins_include_HEADERS = include/internals.h \
|
||||
include/dhcpv6.h \
|
||||
include/dot11.h \
|
||||
include/dot1q.h \
|
||||
include/dot3.h \
|
||||
include/small_uint.h \
|
||||
include/ip.h \
|
||||
include/dns_record.h \
|
||||
@@ -333,7 +334,6 @@ libtins_include_HEADERS = include/internals.h \
|
||||
include/endianness.h \
|
||||
include/rsn_information.h \
|
||||
include/loopback.h \
|
||||
include/ieee802_3.h \
|
||||
include/ethernetII.h \
|
||||
include/crypto.h \
|
||||
include/packet.h \
|
||||
@@ -452,12 +452,12 @@ src/dhcpv6.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/dns.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/dns_record.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/dot11.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/dot3.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/dot1q.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/eapol.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/ethernetII.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/icmp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/icmpv6.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/ieee802_3.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/internals.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/ip.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/ip_address.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
|
||||
@@ -506,6 +506,8 @@ mostlyclean-compile:
|
||||
-rm -f src/dot11.lo
|
||||
-rm -f src/dot1q.$(OBJEXT)
|
||||
-rm -f src/dot1q.lo
|
||||
-rm -f src/dot3.$(OBJEXT)
|
||||
-rm -f src/dot3.lo
|
||||
-rm -f src/eapol.$(OBJEXT)
|
||||
-rm -f src/eapol.lo
|
||||
-rm -f src/ethernetII.$(OBJEXT)
|
||||
@@ -514,8 +516,6 @@ mostlyclean-compile:
|
||||
-rm -f src/icmp.lo
|
||||
-rm -f src/icmpv6.$(OBJEXT)
|
||||
-rm -f src/icmpv6.lo
|
||||
-rm -f src/ieee802_3.$(OBJEXT)
|
||||
-rm -f src/ieee802_3.lo
|
||||
-rm -f src/internals.$(OBJEXT)
|
||||
-rm -f src/internals.lo
|
||||
-rm -f src/ip.$(OBJEXT)
|
||||
@@ -571,11 +571,11 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dns_record.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dot11.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dot1q.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dot3.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/eapol.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/ethernetII.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/icmp.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/icmpv6.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/ieee802_3.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/internals.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/ip.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/ip_address.Plo@am__quote@
|
||||
|
||||
222
include/dot3.h
Normal file
222
include/dot3.h
Normal file
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Nasel
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TINS_DOT3_H
|
||||
#define TINS_DOT3_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "macros.h"
|
||||
#include "pdu.h"
|
||||
#include "endianness.h"
|
||||
#include "hw_address.h"
|
||||
#include "network_interface.h"
|
||||
|
||||
namespace Tins {
|
||||
|
||||
/**
|
||||
* \brief Class representing an Ethernet II PDU.
|
||||
*/
|
||||
class Dot3 : public PDU {
|
||||
public:
|
||||
/**
|
||||
* \brief The address type.
|
||||
*/
|
||||
typedef HWAddress<6> address_type;
|
||||
|
||||
/**
|
||||
* \brief This PDU's flag.
|
||||
*/
|
||||
static const PDU::PDUType pdu_flag = PDU::IEEE802_3;
|
||||
|
||||
/**
|
||||
* \brief Represents the Dot3 broadcast address.
|
||||
*/
|
||||
static const address_type BROADCAST;
|
||||
|
||||
/**
|
||||
* \brief Constructor for creating an Dot3 PDU
|
||||
*
|
||||
* Constructor that builds an Dot3 PDU taking the interface name,
|
||||
* destination's and source's MAC.
|
||||
*
|
||||
* \param iface string containing the interface's name from where to send the packet.
|
||||
* \param dst_hw_addr The destination hardware address.
|
||||
* \param src_hw_addr The source hardware address.
|
||||
* \param child The PDU which will be set as the inner PDU.
|
||||
*/
|
||||
Dot3(const NetworkInterface& iface = NetworkInterface(),
|
||||
const address_type &dst_hw_addr = address_type(),
|
||||
const address_type &src_hw_addr = address_type(),
|
||||
PDU* child = 0);
|
||||
|
||||
/**
|
||||
* \brief Constructor which creates an Dot3 object from a buffer and adds all identifiable
|
||||
* PDUs found in the buffer as children of this one.
|
||||
* \param buffer The buffer from which this PDU will be constructed.
|
||||
* \param total_sz The total size of the buffer.
|
||||
*/
|
||||
Dot3(const uint8_t *buffer, uint32_t total_sz);
|
||||
|
||||
/* Getters */
|
||||
/**
|
||||
* \brief Getter for the destination hardware address.
|
||||
*
|
||||
* \return The destination hardware address.
|
||||
*/
|
||||
address_type dst_addr() const { return _eth.dst_mac; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the source hardware address.
|
||||
*
|
||||
* \return The source hardware address.
|
||||
*/
|
||||
address_type src_addr() const { return _eth.src_mac; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the interface.
|
||||
*
|
||||
* \return The network interface.
|
||||
*/
|
||||
const NetworkInterface &iface() const { return this->_iface; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the length field.
|
||||
* \return The length field value.
|
||||
*/
|
||||
uint16_t length() const { return Endian::be_to_host(_eth.length); };
|
||||
|
||||
/* Setters */
|
||||
|
||||
/**
|
||||
* \brief Setter for the destination hardware address.
|
||||
*
|
||||
* \param new_dst_mac The new destination hardware address.
|
||||
*/
|
||||
void dst_addr(const address_type &new_dst_mac);
|
||||
|
||||
/**
|
||||
* \brief Setter for the source hardware address.
|
||||
*
|
||||
* \param new_src_mac The new source hardware address.
|
||||
*/
|
||||
void src_addr(const address_type &new_src_mac);
|
||||
|
||||
/**
|
||||
* \brief Setter for the interface.
|
||||
*
|
||||
* \param new_iface The interface in which to send this PDU.
|
||||
*/
|
||||
void iface(const NetworkInterface &new_iface);
|
||||
|
||||
/**
|
||||
* \brief Setter for the length field.
|
||||
*
|
||||
* \param new_length uint16_t with the new value of the length field.
|
||||
*/
|
||||
void length(uint16_t new_length);
|
||||
|
||||
/* Virtual methods */
|
||||
/**
|
||||
* \brief Returns the Dot3 frame's header length.
|
||||
*
|
||||
* \return An uint32_t with the header's size.
|
||||
* \sa PDU::header_size()
|
||||
*/
|
||||
uint32_t header_size() const;
|
||||
|
||||
#ifndef WIN32
|
||||
/**
|
||||
* \sa PDU::send()
|
||||
*/
|
||||
void send(PacketSender &sender);
|
||||
#endif // WIN32
|
||||
|
||||
/** \brief Check wether ptr points to a valid response for this PDU.
|
||||
*
|
||||
* \sa PDU::matches_response
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
|
||||
#ifndef WIN32
|
||||
/** \brief Receives a matching response for this packet.
|
||||
*
|
||||
* \sa PDU::recv_response
|
||||
* \param sender The packet sender which will receive the packet.
|
||||
*/
|
||||
PDU *recv_response(PacketSender &sender);
|
||||
#endif // WIN32
|
||||
|
||||
/**
|
||||
* \brief Getter for the PDU's type.
|
||||
* \sa PDU::pdu_type
|
||||
*/
|
||||
PDUType pdu_type() const { return pdu_flag; }
|
||||
|
||||
/**
|
||||
* \brief Clones this pdu, filling the corresponding header with data
|
||||
* extracted from a buffer.
|
||||
*
|
||||
* \deprecated This method is obsolete.
|
||||
*
|
||||
* \param ptr The pointer to the from from which the data will be extracted.
|
||||
* \param total_sz The size of the buffer.
|
||||
* \return The cloned PDU.
|
||||
* \sa PDU::clone_packet
|
||||
*/
|
||||
TINS_DEPRECATED(PDU *clone_packet(const uint8_t *ptr, uint32_t total_sz));
|
||||
|
||||
/**
|
||||
* \sa PDU::clone
|
||||
*/
|
||||
Dot3 *clone() const {
|
||||
return new Dot3(*this);
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* Struct that represents the Ethernet II header
|
||||
*/
|
||||
TINS_BEGIN_PACK
|
||||
struct ethhdr {
|
||||
uint8_t dst_mac[address_type::address_size];
|
||||
uint8_t src_mac[address_type::address_size];
|
||||
uint16_t length;
|
||||
} TINS_END_PACK;
|
||||
|
||||
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
|
||||
|
||||
|
||||
ethhdr _eth;
|
||||
NetworkInterface _iface;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif // TINS_DOT3_H
|
||||
@@ -30,192 +30,10 @@
|
||||
#ifndef TINS_IEEE802_3_H
|
||||
#define TINS_IEEE802_3_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "macros.h"
|
||||
#include "pdu.h"
|
||||
#include "endianness.h"
|
||||
#include "hw_address.h"
|
||||
#include "network_interface.h"
|
||||
#include "dot3.h"
|
||||
|
||||
namespace Tins {
|
||||
|
||||
/**
|
||||
* \brief Class representing an Ethernet II PDU.
|
||||
*/
|
||||
class IEEE802_3 : public PDU {
|
||||
public:
|
||||
/**
|
||||
* \brief The address type.
|
||||
*/
|
||||
typedef HWAddress<6> address_type;
|
||||
|
||||
/**
|
||||
* \brief This PDU's flag.
|
||||
*/
|
||||
static const PDU::PDUType pdu_flag = PDU::IEEE802_3;
|
||||
|
||||
/**
|
||||
* \brief Represents the IEEE802_3 broadcast address.
|
||||
*/
|
||||
static const address_type BROADCAST;
|
||||
|
||||
/**
|
||||
* \brief Constructor for creating an IEEE802_3 PDU
|
||||
*
|
||||
* Constructor that builds an IEEE802_3 PDU taking the interface name,
|
||||
* destination's and source's MAC.
|
||||
*
|
||||
* \param iface string containing the interface's name from where to send the packet.
|
||||
* \param dst_hw_addr The destination hardware address.
|
||||
* \param src_hw_addr The source hardware address.
|
||||
* \param child The PDU which will be set as the inner PDU.
|
||||
*/
|
||||
IEEE802_3(const NetworkInterface& iface = NetworkInterface(),
|
||||
const address_type &dst_hw_addr = address_type(),
|
||||
const address_type &src_hw_addr = address_type(),
|
||||
PDU* child = 0);
|
||||
|
||||
/**
|
||||
* \brief Constructor which creates an IEEE802_3 object from a buffer and adds all identifiable
|
||||
* PDUs found in the buffer as children of this one.
|
||||
* \param buffer The buffer from which this PDU will be constructed.
|
||||
* \param total_sz The total size of the buffer.
|
||||
*/
|
||||
IEEE802_3(const uint8_t *buffer, uint32_t total_sz);
|
||||
|
||||
/* Getters */
|
||||
/**
|
||||
* \brief Getter for the destination hardware address.
|
||||
*
|
||||
* \return The destination hardware address.
|
||||
*/
|
||||
address_type dst_addr() const { return _eth.dst_mac; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the source hardware address.
|
||||
*
|
||||
* \return The source hardware address.
|
||||
*/
|
||||
address_type src_addr() const { return _eth.src_mac; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the interface.
|
||||
*
|
||||
* \return The network interface.
|
||||
*/
|
||||
const NetworkInterface &iface() const { return this->_iface; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the length field.
|
||||
* \return The length field value.
|
||||
*/
|
||||
uint16_t length() const { return Endian::be_to_host(_eth.length); };
|
||||
|
||||
/* Setters */
|
||||
|
||||
/**
|
||||
* \brief Setter for the destination hardware address.
|
||||
*
|
||||
* \param new_dst_mac The new destination hardware address.
|
||||
*/
|
||||
void dst_addr(const address_type &new_dst_mac);
|
||||
|
||||
/**
|
||||
* \brief Setter for the source hardware address.
|
||||
*
|
||||
* \param new_src_mac The new source hardware address.
|
||||
*/
|
||||
void src_addr(const address_type &new_src_mac);
|
||||
|
||||
/**
|
||||
* \brief Setter for the interface.
|
||||
*
|
||||
* \param new_iface The interface in which to send this PDU.
|
||||
*/
|
||||
void iface(const NetworkInterface &new_iface);
|
||||
|
||||
/**
|
||||
* \brief Setter for the length field.
|
||||
*
|
||||
* \param new_length uint16_t with the new value of the length field.
|
||||
*/
|
||||
void length(uint16_t new_length);
|
||||
|
||||
/* Virtual methods */
|
||||
/**
|
||||
* \brief Returns the IEEE802_3 frame's header length.
|
||||
*
|
||||
* \return An uint32_t with the header's size.
|
||||
* \sa PDU::header_size()
|
||||
*/
|
||||
uint32_t header_size() const;
|
||||
|
||||
#ifndef WIN32
|
||||
/**
|
||||
* \sa PDU::send()
|
||||
*/
|
||||
void send(PacketSender &sender);
|
||||
#endif // WIN32
|
||||
|
||||
/** \brief Check wether ptr points to a valid response for this PDU.
|
||||
*
|
||||
* \sa PDU::matches_response
|
||||
* \param ptr The pointer to the buffer.
|
||||
* \param total_sz The size of the buffer.
|
||||
*/
|
||||
bool matches_response(uint8_t *ptr, uint32_t total_sz);
|
||||
|
||||
#ifndef WIN32
|
||||
/** \brief Receives a matching response for this packet.
|
||||
*
|
||||
* \sa PDU::recv_response
|
||||
* \param sender The packet sender which will receive the packet.
|
||||
*/
|
||||
PDU *recv_response(PacketSender &sender);
|
||||
#endif // WIN32
|
||||
|
||||
/**
|
||||
* \brief Getter for the PDU's type.
|
||||
* \sa PDU::pdu_type
|
||||
*/
|
||||
PDUType pdu_type() const { return PDU::IEEE802_3; }
|
||||
|
||||
/**
|
||||
* \brief Clones this pdu, filling the corresponding header with data
|
||||
* extracted from a buffer.
|
||||
*
|
||||
* \deprecated This method is obsolete.
|
||||
*
|
||||
* \param ptr The pointer to the from from which the data will be extracted.
|
||||
* \param total_sz The size of the buffer.
|
||||
* \return The cloned PDU.
|
||||
* \sa PDU::clone_packet
|
||||
*/
|
||||
TINS_DEPRECATED(PDU *clone_packet(const uint8_t *ptr, uint32_t total_sz));
|
||||
|
||||
/**
|
||||
* \sa PDU::clone
|
||||
*/
|
||||
IEEE802_3 *clone() const {
|
||||
return new IEEE802_3(*this);
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* Struct that represents the Ethernet II header
|
||||
*/
|
||||
TINS_BEGIN_PACK
|
||||
struct ethhdr {
|
||||
uint8_t dst_mac[address_type::address_size];
|
||||
uint8_t src_mac[address_type::address_size];
|
||||
uint16_t length;
|
||||
} TINS_END_PACK;
|
||||
|
||||
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
|
||||
|
||||
|
||||
ethhdr _eth;
|
||||
NetworkInterface _iface;
|
||||
};
|
||||
typedef Dot3 IEEE802_3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,14 +41,14 @@
|
||||
#include <net/ethernet.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include "ieee802_3.h"
|
||||
#include "dot3.h"
|
||||
#include "packet_sender.h"
|
||||
#include "llc.h"
|
||||
|
||||
namespace Tins {
|
||||
const IEEE802_3::address_type IEEE802_3::BROADCAST("ff:ff:ff:ff:ff:ff");
|
||||
const Dot3::address_type Dot3::BROADCAST("ff:ff:ff:ff:ff:ff");
|
||||
|
||||
IEEE802_3::IEEE802_3(const NetworkInterface& iface,
|
||||
Dot3::Dot3(const NetworkInterface& iface,
|
||||
const address_type &dst_hw_addr, const address_type &src_hw_addr,
|
||||
PDU* child)
|
||||
: PDU(child)
|
||||
@@ -61,7 +61,7 @@ IEEE802_3::IEEE802_3(const NetworkInterface& iface,
|
||||
|
||||
}
|
||||
|
||||
IEEE802_3::IEEE802_3(const uint8_t *buffer, uint32_t total_sz)
|
||||
Dot3::Dot3(const uint8_t *buffer, uint32_t total_sz)
|
||||
{
|
||||
if(total_sz < sizeof(ethhdr))
|
||||
throw std::runtime_error("Not enough size for an ethernetII header in the buffer.");
|
||||
@@ -72,28 +72,28 @@ IEEE802_3::IEEE802_3(const uint8_t *buffer, uint32_t total_sz)
|
||||
inner_pdu(new Tins::LLC(buffer, total_sz));
|
||||
}
|
||||
|
||||
void IEEE802_3::dst_addr(const address_type &new_dst_mac) {
|
||||
void Dot3::dst_addr(const address_type &new_dst_mac) {
|
||||
std::copy(new_dst_mac.begin(), new_dst_mac.end(), _eth.dst_mac);
|
||||
}
|
||||
|
||||
void IEEE802_3::src_addr(const address_type &new_src_mac) {
|
||||
void Dot3::src_addr(const address_type &new_src_mac) {
|
||||
std::copy(new_src_mac.begin(), new_src_mac.end(), _eth.src_mac);
|
||||
}
|
||||
|
||||
void IEEE802_3::iface(const NetworkInterface &new_iface) {
|
||||
void Dot3::iface(const NetworkInterface &new_iface) {
|
||||
_iface = new_iface;
|
||||
}
|
||||
|
||||
void IEEE802_3::length(uint16_t new_length) {
|
||||
void Dot3::length(uint16_t new_length) {
|
||||
this->_eth.length = Endian::host_to_be(new_length);
|
||||
}
|
||||
|
||||
uint32_t IEEE802_3::header_size() const {
|
||||
uint32_t Dot3::header_size() const {
|
||||
return sizeof(ethhdr);
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
void IEEE802_3::send(PacketSender &sender) {
|
||||
void Dot3::send(PacketSender &sender) {
|
||||
if(!_iface)
|
||||
throw std::runtime_error("Interface has not been set");
|
||||
|
||||
@@ -115,7 +115,7 @@ void IEEE802_3::send(PacketSender &sender) {
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
bool IEEE802_3::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
bool Dot3::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
if(total_sz < sizeof(ethhdr))
|
||||
return false;
|
||||
ethhdr *eth_ptr = (ethhdr*)ptr;
|
||||
@@ -125,7 +125,7 @@ bool IEEE802_3::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void IEEE802_3::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) {
|
||||
uint32_t my_sz = header_size();
|
||||
bool set_length = _eth.length == 0;
|
||||
assert(total_sz >= my_sz);
|
||||
@@ -140,7 +140,7 @@ void IEEE802_3::write_serialization(uint8_t *buffer, uint32_t total_sz, const PD
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
PDU *IEEE802_3::recv_response(PacketSender &sender) {
|
||||
PDU *Dot3::recv_response(PacketSender &sender) {
|
||||
if(!_iface)
|
||||
throw std::runtime_error("Interface has not been set");
|
||||
#ifndef BSD
|
||||
@@ -160,7 +160,7 @@ PDU *IEEE802_3::recv_response(PacketSender &sender) {
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
PDU *IEEE802_3::clone_packet(const uint8_t *ptr, uint32_t total_sz) {
|
||||
return new IEEE802_3(ptr, total_sz);
|
||||
PDU *Dot3::clone_packet(const uint8_t *ptr, uint32_t total_sz) {
|
||||
return new Dot3(ptr, total_sz);
|
||||
}
|
||||
}
|
||||
@@ -218,6 +218,30 @@
|
||||
../include/internals.h:
|
||||
|
||||
../include/constants.h:
|
||||
../src/dot3.o: ../src/dot3.cpp ../include/macros.h ../include/dot3.h \
|
||||
../include/macros.h ../include/pdu.h ../include/endianness.h \
|
||||
../include/hw_address.h ../include/network_interface.h \
|
||||
../include/ip_address.h ../include/packet_sender.h ../include/llc.h
|
||||
|
||||
../include/macros.h:
|
||||
|
||||
../include/dot3.h:
|
||||
|
||||
../include/macros.h:
|
||||
|
||||
../include/pdu.h:
|
||||
|
||||
../include/endianness.h:
|
||||
|
||||
../include/hw_address.h:
|
||||
|
||||
../include/network_interface.h:
|
||||
|
||||
../include/ip_address.h:
|
||||
|
||||
../include/packet_sender.h:
|
||||
|
||||
../include/llc.h:
|
||||
../src/eapol.o: ../src/eapol.cpp ../include/eapol.h ../include/pdu.h \
|
||||
../include/macros.h ../include/small_uint.h ../include/endianness.h \
|
||||
../include/dot11.h ../include/hw_address.h ../include/pdu_option.h \
|
||||
@@ -359,37 +383,12 @@
|
||||
../include/constants.h:
|
||||
|
||||
../include/constants.h:
|
||||
../src/ieee802_3.o: ../src/ieee802_3.cpp ../include/macros.h \
|
||||
../include/ieee802_3.h ../include/macros.h ../include/pdu.h \
|
||||
../include/endianness.h ../include/hw_address.h \
|
||||
../include/network_interface.h ../include/ip_address.h \
|
||||
../include/packet_sender.h ../include/llc.h
|
||||
|
||||
../include/macros.h:
|
||||
|
||||
../include/ieee802_3.h:
|
||||
|
||||
../include/macros.h:
|
||||
|
||||
../include/pdu.h:
|
||||
|
||||
../include/endianness.h:
|
||||
|
||||
../include/hw_address.h:
|
||||
|
||||
../include/network_interface.h:
|
||||
|
||||
../include/ip_address.h:
|
||||
|
||||
../include/packet_sender.h:
|
||||
|
||||
../include/llc.h:
|
||||
../src/internals.o: ../src/internals.cpp ../include/internals.h \
|
||||
../include/constants.h ../include/pdu.h ../include/macros.h \
|
||||
../include/ip.h ../include/small_uint.h ../include/endianness.h \
|
||||
../include/ip_address.h ../include/pdu_option.h ../include/cxxstd.h \
|
||||
../include/ethernetII.h ../include/hw_address.h \
|
||||
../include/network_interface.h ../include/ieee802_3.h \
|
||||
../include/network_interface.h ../include/ieee802_3.h ../include/dot3.h \
|
||||
../include/radiotap.h ../include/dot11.h ../include/ipv6.h \
|
||||
../include/ipv6_address.h ../include/arp.h ../include/eapol.h \
|
||||
../include/rawpdu.h ../include/dot1q.h
|
||||
@@ -422,6 +421,8 @@
|
||||
|
||||
../include/ieee802_3.h:
|
||||
|
||||
../include/dot3.h:
|
||||
|
||||
../include/radiotap.h:
|
||||
|
||||
../include/dot11.h:
|
||||
@@ -632,7 +633,7 @@
|
||||
../include/ethernetII.h ../include/pdu.h ../include/endianness.h \
|
||||
../include/radiotap.h ../include/dot11.h ../include/small_uint.h \
|
||||
../include/pdu_option.h ../include/cxxstd.h ../include/ieee802_3.h \
|
||||
../include/internals.h ../include/constants.h
|
||||
../include/dot3.h ../include/internals.h ../include/constants.h
|
||||
|
||||
../include/packet_sender.h:
|
||||
|
||||
@@ -668,6 +669,8 @@
|
||||
|
||||
../include/ieee802_3.h:
|
||||
|
||||
../include/dot3.h:
|
||||
|
||||
../include/internals.h:
|
||||
|
||||
../include/constants.h:
|
||||
|
||||
Reference in New Issue
Block a user