36 #include <tins/macros.h> 37 #include <tins/endianness.h> 38 #include <tins/ip_address.h> 39 #include <tins/hw_address.h> 96 BootP(
const uint8_t* buffer, uint32_t total_sz, uint32_t vend_field_size = 64);
104 uint8_t
opcode()
const {
return bootp_.opcode; }
110 uint8_t
htype()
const {
return bootp_.htype; }
116 uint8_t
hlen()
const {
return bootp_.hlen; }
122 uint8_t
hops()
const {
return bootp_.hops; }
128 uint32_t
xid()
const {
return Endian::be_to_host(bootp_.xid); }
134 uint16_t
secs()
const {
return Endian::be_to_host(bootp_.secs); }
139 uint16_t
padding()
const {
return Endian::be_to_host(bootp_.padding); }
145 ipaddress_type
ciaddr()
const {
return ipaddress_type(bootp_.ciaddr); }
151 ipaddress_type
yiaddr()
const {
return ipaddress_type(bootp_.yiaddr); }
157 ipaddress_type
siaddr()
const {
return ipaddress_type(bootp_.siaddr); }
163 ipaddress_type
giaddr()
const {
return ipaddress_type(bootp_.giaddr); }
169 chaddr_type
chaddr()
const {
return bootp_.chaddr; }
175 const uint8_t*
sname()
const {
return bootp_.sname; }
181 const uint8_t*
file()
const {
return bootp_.file; }
187 const vend_type&
vend()
const {
return vend_; }
194 uint32_t header_size()
const;
201 void opcode(uint8_t code);
207 void htype(uint8_t type);
213 void hlen(uint8_t length);
219 void hops(uint8_t count);
225 void xid(uint32_t identifier);
231 void secs(uint16_t value);
237 void padding(uint16_t value);
243 void ciaddr(ipaddress_type address);
249 void yiaddr(ipaddress_type address);
255 void siaddr(ipaddress_type address);
261 void giaddr(ipaddress_type address);
270 size_t copy_threshold = std::min(n,
sizeof(bootp_.chaddr));
271 for (
size_t i = 0; i < copy_threshold; ++i) {
272 if (i < copy_threshold) {
273 bootp_.chaddr[i] = new_chaddr[i];
276 bootp_.chaddr[i] = 0;
285 void sname(
const uint8_t* new_sname);
291 void file(
const uint8_t* new_file);
297 void vend(
const vend_type& newvend_);
308 bool matches_response(
const uint8_t* ptr, uint32_t total_sz)
const;
320 return new BootP(*
this);
331 vend_type&
vend() {
return vend_; }
333 void write_serialization(uint8_t* buffer, uint32_t total_sz);
363 #endif // TINS_BOOTP_H uint32_t xid() const
Getter for the xid field.
Definition: bootp.h:128
uint8_t htype() const
Getter for the htype field.
Definition: bootp.h:110
PDUType
Enum which identifies each type of PDU.
Definition: pdu.h:127
chaddr_type chaddr() const
Getter for the chaddr field.
Definition: bootp.h:169
vend_type & vend()
Getter for the vend field.
Definition: bootp.h:331
std::vector< uint8_t > vend_type
Definition: bootp.h:62
uint8_t hlen() const
Getter for the hlen field.
Definition: bootp.h:116
ipaddress_type giaddr() const
Getter for the giaddr field.
Definition: bootp.h:163
const uint8_t * sname() const
Getter for the sname field.
Definition: bootp.h:175
uint16_t secs() const
Getter for the secs field.
Definition: bootp.h:134
void chaddr(const HWAddress< n > &new_chaddr)
Setter for the chaddr field. The new_chaddr pointer must be at least BOOTP::hlen() bytes long...
Definition: bootp.h:269
Represents a hardware address.
Definition: hw_address.h:91
ipaddress_type yiaddr() const
Getter for the yiaddr field.
Definition: bootp.h:151
HWAddress< 16 > chaddr_type
Definition: bootp.h:57
BootP * clone() const
Definition: bootp.h:319
ipaddress_type ciaddr() const
Getter for the ciaddr field.
Definition: bootp.h:145
The Tins namespace.
Definition: address_range.h:38
ipaddress_type siaddr() const
Getter for the siaddr field.
Definition: bootp.h:157
uint8_t hops() const
Getter for the hops field.
Definition: bootp.h:122
uint16_t padding() const
Getter for the padding field.
Definition: bootp.h:139
OpCodes
Enum which contains the different opcodes BootP messages.
Definition: bootp.h:72
PDUType pdu_type() const
Getter for the PDU's type.
Definition: bootp.h:314
IPv4Address ipaddress_type
Definition: bootp.h:52
Abstraction of an IPv4 address.
Definition: ip_address.h:45
const vend_type & vend() const
Getter for the vend field.
Definition: bootp.h:187
Represents a BootP PDU.
Definition: bootp.h:47
uint8_t opcode() const
Getter for the opcode field.
Definition: bootp.h:104
Base class for protocol data units.
Definition: pdu.h:107
const uint8_t * file() const
Getter for the file field.
Definition: bootp.h:181