mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Renamed TCP::Options to TCP::Option.
This commit is contained in:
@@ -65,7 +65,7 @@ namespace Tins {
|
|||||||
* This enum identifies valid options supported by TCP PDU.
|
* This enum identifies valid options supported by TCP PDU.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum Options {
|
enum Option {
|
||||||
EOL = 0,
|
EOL = 0,
|
||||||
NOP = 1,
|
NOP = 1,
|
||||||
MSS = 2,
|
MSS = 2,
|
||||||
@@ -385,7 +385,7 @@ namespace Tins {
|
|||||||
* \param length The length of this option(optional).
|
* \param length The length of this option(optional).
|
||||||
* \param data Pointer to this option's data(optional).
|
* \param data Pointer to this option's data(optional).
|
||||||
*/
|
*/
|
||||||
void add_option(Options tcp_option, uint8_t length = 0, const uint8_t *data = 0);
|
void add_option(Option tcp_option, uint8_t length = 0, const uint8_t *data = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns the header size.
|
* \brief Returns the header size.
|
||||||
@@ -409,7 +409,7 @@ namespace Tins {
|
|||||||
* \param opt_flag The flag to be searched.
|
* \param opt_flag The flag to be searched.
|
||||||
* \return A pointer to the option, or 0 if it was not found.
|
* \return A pointer to the option, or 0 if it was not found.
|
||||||
*/
|
*/
|
||||||
const TCPOption *search_option(Options opt) const;
|
const TCPOption *search_option(Option opt) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Clones this PDU.
|
* \brief Clones this PDU.
|
||||||
@@ -457,7 +457,7 @@ namespace Tins {
|
|||||||
|
|
||||||
void copy_fields(const TCP *other);
|
void copy_fields(const TCP *other);
|
||||||
|
|
||||||
template<class T> bool generic_search(Options opt, T *value) {
|
template<class T> bool generic_search(Option opt, T *value) {
|
||||||
const TCPOption *option = search_option(opt);
|
const TCPOption *option = search_option(opt);
|
||||||
if(option && option->length == sizeof(T)) {
|
if(option && option->length == sizeof(T)) {
|
||||||
*value = *(T*)option->value;
|
*value = *(T*)option->value;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ Tins::TCP::TCP(const uint8_t *buffer, uint32_t total_sz) : PDU(Constants::IP::PR
|
|||||||
// Not enough size for this option
|
// Not enough size for this option
|
||||||
if(header_end - index < args[1])
|
if(header_end - index < args[1])
|
||||||
throw std::runtime_error("Not enough size for a TCP header in the buffer.");
|
throw std::runtime_error("Not enough size for a TCP header in the buffer.");
|
||||||
add_option((Options)args[0], args[1], buffer + index);
|
add_option((Option)args[0], args[1], buffer + index);
|
||||||
index += args[1];
|
index += args[1];
|
||||||
}
|
}
|
||||||
else if(args[0] == EOL)
|
else if(args[0] == EOL)
|
||||||
@@ -276,7 +276,7 @@ void Tins::TCP::set_flag(Flags tcp_flag, uint8_t value) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tins::TCP::add_option(Options tcp_option, uint8_t length, const uint8_t *data) {
|
void Tins::TCP::add_option(Option tcp_option, uint8_t length, const uint8_t *data) {
|
||||||
uint8_t *new_data = 0, padding;
|
uint8_t *new_data = 0, padding;
|
||||||
if(length) {
|
if(length) {
|
||||||
new_data = new uint8_t[length];
|
new_data = new uint8_t[length];
|
||||||
@@ -320,7 +320,7 @@ void Tins::TCP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PD
|
|||||||
_tcp.check = 0;
|
_tcp.check = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tins::TCP::TCPOption *Tins::TCP::search_option(Options opt) const {
|
const Tins::TCP::TCPOption *Tins::TCP::search_option(Option opt) const {
|
||||||
for(std::list<TCPOption>::const_iterator it = _options.begin(); it != _options.end(); ++it) {
|
for(std::list<TCPOption>::const_iterator it = _options.begin(); it != _options.end(); ++it) {
|
||||||
if(it->option == opt)
|
if(it->option == opt)
|
||||||
return &(*it);
|
return &(*it);
|
||||||
@@ -328,7 +328,6 @@ const Tins::TCP::TCPOption *Tins::TCP::search_option(Options opt) const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TCPOptions */
|
/* TCPOptions */
|
||||||
|
|
||||||
uint8_t *Tins::TCP::TCPOption::write(uint8_t *buffer) {
|
uint8_t *Tins::TCP::TCPOption::write(uint8_t *buffer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user