1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-24 19:21:35 +01:00

Added an overload of add_option that takes an rvalue-ref in IP, TCP, DHCP, ICMPv6 and Dot11.

This commit is contained in:
Matias Fontanini
2013-03-24 00:08:53 -03:00
parent 584fe81f04
commit d7dd1e131f
12 changed files with 386 additions and 113 deletions

View File

@@ -309,8 +309,19 @@ uint16_t IP::stream_identifier() const {
return Endian::be_to_host(*(const uint16_t*)option->data_ptr());
}
#if TINS_IS_CXX11
void IP::add_option(ip_option &&option) {
internal_add_option(option);
_ip_options.push_back(std::move(option));
}
#endif
void IP::add_option(const ip_option &option) {
internal_add_option(option);
_ip_options.push_back(option);
}
void IP::internal_add_option(const ip_option &option) {
_options_size += 1 + option.data_size();
uint8_t padding = _options_size % 4;
_padded_options_size = padding ? (_options_size - padding + 4) : _options_size;