libtins 4.5
Loading...
Searching...
No Matches
vxlan.h
1#ifndef TINS_VXLAN_H
2#define TINS_VXLAN_H
3
4#include <tins/pdu.h>
5#include <tins/small_uint.h>
6
7namespace Tins {
8
17class TINS_API VXLAN : public PDU {
18public:
22 static const PDU::PDUType pdu_flag = PDU::VXLAN;
23
29 VXLAN(const small_uint<24> vni = 0);
30
38 VXLAN(const uint8_t* buffer, uint32_t total_sz);
39
43 uint8_t get_flags() const { return Endian::be_to_host(header_.flags) >> 24; }
44
48 small_uint<24> get_vni() const { return Endian::be_to_host(header_.vni) >> 8; }
49
54 void set_flags(uint8_t new_flags) { header_.flags = Endian::host_to_be(new_flags << 24); }
55
60 void set_vni(small_uint<24> new_vni) { header_.vni = Endian::host_to_be(new_vni << 8); }
61
71 uint32_t header_size() const { return sizeof(header_); }
72
77 PDUType pdu_type() const { return pdu_flag; }
78
82 VXLAN *clone() const { return new VXLAN(*this); }
83
84private:
85 TINS_BEGIN_PACK
86 struct vxlan_header {
87 uint32_t flags;
88 uint32_t vni;
89 } TINS_END_PACK;
90
91 void write_serialization(uint8_t* buffer, uint32_t total_sz);
92
93 vxlan_header header_;
94};
95
96} // Tins
97
98#endif // TINS_VXLAN_H
Base class for protocol data units.
Definition pdu.h:107
PDUType
Enum which identifies each type of PDU.
Definition pdu.h:127
Represents a VXLAN PDU.
Definition vxlan.h:17
small_uint< 24 > get_vni() const
Getter for the VNI.
Definition vxlan.h:48
void set_flags(uint8_t new_flags)
Setter for the flags.
Definition vxlan.h:54
VXLAN * clone() const
Definition vxlan.h:82
uint32_t header_size() const
Returns the VXLAN frame's header length.
Definition vxlan.h:71
PDUType pdu_type() const
Getter for the PDU's type.
Definition vxlan.h:77
void set_vni(small_uint< 24 > new_vni)
Setter for the VNI.
Definition vxlan.h:60
uint8_t get_flags() const
Getter for the flags.
Definition vxlan.h:43
Represents a field of n bits.
Definition small_uint.h:52
The Tins namespace.
Definition address_range.h:38