mirror of
https://github.com/mfontanini/libtins
synced 2026-01-30 05:24:26 +01:00
Added wrappers to build ARP requests and replies. Defined BROADCAST in EthernetII
This commit is contained in:
@@ -35,31 +35,37 @@ namespace Tins {
|
||||
class EthernetII : public PDU {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Constructor for creating an ethernet PDU
|
||||
*
|
||||
* Constructor that builds an ethernet PDU taking the destination's
|
||||
* and source's MAC.
|
||||
*
|
||||
* \param iface string containing the interface's name from where to send the packet.
|
||||
* \param mac_dst uint8_t array of 6 bytes containing the destination's MAC.
|
||||
* \param mac_src uint8_t array of 6 bytes containing the source's MAC.
|
||||
* \param child PDU* with the PDU contained by the ethernet PDU (optional).
|
||||
*/
|
||||
EthernetII(const std::string& iface, const uint8_t* mac_dst, const uint8_t* mac_src, PDU* child = 0) throw (std::runtime_error);
|
||||
static const uint8_t* BROADCAST;
|
||||
|
||||
/**
|
||||
* \brief Constructor for creating an ethernet PDU
|
||||
*
|
||||
* Constructor that builds an ethernet PDU taking the destination's
|
||||
* and source's MAC.
|
||||
* Constructor that builds an ethernet PDU taking the interface name,
|
||||
* destination's and source's MAC.
|
||||
*
|
||||
* \param mac_dst uint8_t array of 6 bytes containing the destination's MAC.
|
||||
* \param mac_src uint8_t array of 6 bytes containing the source's MAC.
|
||||
* \param iface_index uint32_t containing the interface's index from where to send the packet.
|
||||
* \param iface string containing the interface's name from where to send the packet.
|
||||
* \param mac_dst uint8_t array of 6 bytes containing the destination's MAC(optional).
|
||||
* \param mac_src uint8_t array of 6 bytes containing the source's MAC(optional).
|
||||
* \param child PDU* with the PDU contained by the ethernet PDU (optional).
|
||||
*/
|
||||
EthernetII(const uint32_t iface_index, const uint8_t* mac_dst = 0, const uint8_t* mac_src = 0, PDU* child = 0);
|
||||
EthernetII(const std::string& iface, const uint8_t* mac_dst = 0, const uint8_t* mac_src = 0, PDU* child = 0) throw (std::runtime_error);
|
||||
|
||||
/**
|
||||
* \brief Constructor for creating an ethernet PDU
|
||||
*
|
||||
* Constructor that builds an ethernet PDU taking the interface index,
|
||||
* destination's and source's MAC.
|
||||
*
|
||||
* \param iface_index const uint32_t with the interface's index from where to send the packet.
|
||||
* \param mac_dst uint8_t array of 6 bytes containing the destination's MAC(optional).
|
||||
* \param mac_src uint8_t array of 6 bytes containing the source's MAC(optional).
|
||||
* \param child PDU* with the PDU contained by the ethernet PDU (optional).
|
||||
*/
|
||||
EthernetII(uint32_t iface_index, const uint8_t* mac_dst = 0, const uint8_t* mac_src = 0, PDU* child = 0);
|
||||
|
||||
/* Getters */
|
||||
/**
|
||||
@@ -125,15 +131,15 @@ namespace Tins {
|
||||
* \sa PDU::send()
|
||||
*/
|
||||
bool send(PacketSender* sender);
|
||||
|
||||
|
||||
/** \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);
|
||||
|
||||
|
||||
/** \brief Receives a matching response for this packet.
|
||||
*
|
||||
* \sa PDU::recv_response
|
||||
@@ -145,7 +151,7 @@ namespace Tins {
|
||||
|
||||
/** \brief Clones this pdu, filling the corresponding header with data
|
||||
* extracted from a buffer.
|
||||
*
|
||||
*
|
||||
* \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.
|
||||
@@ -163,11 +169,11 @@ namespace Tins {
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/** \brief Creates an instance of EthernetII using an ethhdr pointer.
|
||||
*
|
||||
*
|
||||
* \param eth_ptr The pointer to the ethhdr.
|
||||
*/
|
||||
EthernetII(ethhdr *eth_ptr);
|
||||
|
||||
|
||||
ethhdr _eth;
|
||||
uint32_t _iface_index;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user