30 #ifndef TINS_ETHERNET_II_H 31 #define TINS_ETHERNET_II_H 34 #include <tins/macros.h> 36 #include <tins/config.h> 37 #include <tins/endianness.h> 38 #include <tins/hw_address.h> 69 static metadata extract_metadata(
const uint8_t *buffer, uint32_t total_sz);
77 EthernetII(
const address_type& dst_hw_addr = address_type(),
78 const address_type& src_hw_addr = address_type());
93 EthernetII(
const uint8_t* buffer, uint32_t total_sz);
103 return header_.dst_mac;
112 return header_.src_mac;
120 return Endian::be_to_host(header_.payload_type);
130 void dst_addr(
const address_type& new_dst_addr);
137 void src_addr(
const address_type& new_src_addr);
144 void payload_type(uint16_t new_payload_type);
153 uint32_t header_size()
const;
161 uint32_t trailer_size()
const;
175 bool matches_response(
const uint8_t* ptr, uint32_t total_sz)
const;
205 struct ethernet_header {
206 uint8_t dst_mac[address_type::address_size];
207 uint8_t src_mac[address_type::address_size];
208 uint16_t payload_type;
211 void write_serialization(uint8_t* buffer, uint32_t total_sz);
213 ethernet_header header_;
218 #endif // TINS_ETHERNET_II_H address_type src_addr() const
Getter for the source's hardware address.
Definition: ethernetII.h:111
PDUType
Enum which identifies each type of PDU.
Definition: pdu.h:127
Sends packets through a network interface.
Definition: packet_sender.h:116
HWAddress< 6 > address_type
The hardware address type.
Definition: ethernetII.h:51
The Tins namespace.
Definition: address_range.h:38
static const address_type BROADCAST
Represents the ethernetII broadcast address.
Definition: ethernetII.h:61
Abstraction of a network interface.
Definition: network_interface.h:47
Represents an Ethernet II PDU.
Definition: ethernetII.h:46
PDUType pdu_type() const
Getter for the PDU's type.
Definition: ethernetII.h:190
address_type dst_addr() const
Getter for the destination's hardware address.
Definition: ethernetII.h:102
EthernetII * clone() const
Definition: ethernetII.h:197
uint16_t payload_type() const
Getter for the payload_type.
Definition: ethernetII.h:119
Base class for protocol data units.
Definition: pdu.h:107