1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-26 20:01:35 +01:00

TCP options now use PDUOption<>::length_field when it is != from data_size.

This commit is contained in:
Matias Fontanini
2013-04-10 18:44:00 -03:00
parent fee938b46d
commit 1fbef641da
2 changed files with 14 additions and 10 deletions

View File

@@ -346,10 +346,12 @@ uint8_t *TCP::write_option(const option &opt, uint8_t *buffer) {
}
else {
buffer[0] = opt.option();
buffer[1] = opt.length_field() + (sizeof(uint8_t) << 1);
if(opt.data_size() != 0)
std::copy(opt.data_ptr(), opt.data_ptr() + opt.data_size(), buffer + 2);
return buffer + opt.data_size() + (sizeof(uint8_t) << 1);
buffer[1] = opt.length_field();
// only add the identifier and size field sizes if the length
// field hasn't been spoofed.
if(opt.length_field() == opt.data_size())
buffer[1] += (sizeof(uint8_t) << 1);
return std::copy(opt.data_ptr(), opt.data_ptr() + opt.data_size(), buffer + 2);
}
}