1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-29 13:04:28 +01:00

Fixed some bugs in Dot11 and DNS. Most of the code uses host_to_be and be_to_host.

This commit is contained in:
Matias Fontanini
2012-08-16 00:34:18 -03:00
parent 892bc0ecd3
commit 27f6eeccd4
23 changed files with 185 additions and 181 deletions

View File

@@ -77,7 +77,7 @@ namespace Tins {
* \brief Getter for the length field.
* \return The length field.
*/
uint16_t length() const { return Utils::net_to_host_s(_header.length); }
uint16_t length() const { return Utils::be_to_host(_header.length); }
/**
* \brief Getter for the type field.
@@ -103,7 +103,7 @@ namespace Tins {
* \brief Sets the length field.
* \param new_length The new length to be set.
*/
void length(uint8_t new_length);
void length(uint16_t new_length);
/**
* \brief Sets the type field.
@@ -209,13 +209,13 @@ namespace Tins {
* \brief Getter for the key length field.
* \return The key length field.
*/
uint16_t key_length() const { return Utils::net_to_host_s(_header.key_length); }
uint16_t key_length() const { return Utils::be_to_host(_header.key_length); }
/**
* \brief Getter for the replay counter field.
* \return The replay counter field.
*/
uint64_t replay_counter() const { return Utils::net_to_host_ll(_header.replay_counter); }
uint64_t replay_counter() const { return Utils::be_to_host(_header.replay_counter); }
/**
* \brief Getter for the key IV field.
@@ -389,13 +389,13 @@ namespace Tins {
* \brief Getter for the key length field.
* \return The key length field.
*/
uint16_t key_length() const { return Utils::net_to_host_s(_header.key_length); }
uint16_t key_length() const { return Utils::be_to_host(_header.key_length); }
/**
* \brief Getter for the replay counter field.
* \return The replay counter field.
*/
uint64_t replay_counter() const { return Utils::net_to_host_ll(_header.replay_counter); }
uint64_t replay_counter() const { return Utils::be_to_host(_header.replay_counter); }
/**
* \brief Getter for the key IV field.
@@ -413,13 +413,13 @@ namespace Tins {
* \brief Getter for the rsc field.
* \return The rsc field.
*/
uint64_t rsc() const { return Utils::net_to_host_ll(_header.rsc); }
uint64_t rsc() const { return Utils::be_to_host(_header.rsc); }
/**
* \brief Getter for the id field.
* \return The id field.
*/
uint64_t id() const { return Utils::net_to_host_ll(_header.id); }
uint64_t id() const { return Utils::be_to_host(_header.id); }
/**
* \brief Getter for the mic field.
@@ -431,7 +431,7 @@ namespace Tins {
* \brief Getter for the wpa length field.
* \return The wpa length field.
*/
uint16_t wpa_length() const { return Utils::net_to_host_s(_header.wpa_length); }
uint16_t wpa_length() const { return Utils::be_to_host(_header.wpa_length); }
/**
* \brief Getter for the key field.

View File

@@ -109,7 +109,7 @@ namespace Tins {
* \brief Getter for the payload_type
* \return The payload type.
*/
uint16_t payload_type() const { return Utils::net_to_host_s(_eth.payload_type); };
uint16_t payload_type() const { return Utils::be_to_host(_eth.payload_type); };
/* Setters */

View File

@@ -102,7 +102,7 @@ namespace Tins {
* \brief Getter for the length field.
* \return The length field value.
*/
uint16_t length() const { return Utils::net_to_host_s(_eth.length); };
uint16_t length() const { return Utils::be_to_host(_eth.length); };
/* Setters */

View File

@@ -100,37 +100,37 @@ namespace Tins {
* \brief Getter for the dsap field.
* \return The dsap field.
*/
inline uint8_t dsap() const { return _snap.dsap; }
uint8_t dsap() const { return _snap.dsap; }
/**
* \brief Getter for the ssap field.
* \return The ssap field.
*/
inline uint8_t ssap() const { return _snap.ssap; }
uint8_t ssap() const { return _snap.ssap; }
/**
* \brief Getter for the id field.
* \return The id field.
*/
inline uint8_t id() const { return _snap.id; }
uint8_t id() const { return _snap.id; }
/**
* \brief Getter for the poll field.
* \return The poll field.
*/
inline uint8_t poll() const { return _snap.poll; }
uint8_t poll() const { return _snap.poll; }
/**
* \brief Getter for the org code field.
* \return The org code field.
*/
inline uint32_t org_code() const { return _snap.org_code; }
uint32_t org_code() const { return _snap.org_code; }
/**
* \brief Getter for the eth type field.
* \return The eth field.
*/
inline uint16_t eth_type() const { return Utils::net_to_host_s(_snap.eth_type); }
uint16_t eth_type() const { return Utils::be_to_host(_snap.eth_type); }
/**
* \brief Returns the SNAP frame's header length.

View File

@@ -93,7 +93,7 @@ namespace Tins {
*
* \param to_resolve The domain name/ip address to resolve.
*/
uint32_t resolve_ip(const std::string &to_resolve);
IPv4Address resolve_ip(const std::string &to_resolve);
/**
* \brief Pings an ip address.
@@ -190,7 +190,7 @@ namespace Tins {
* \param data The data to convert.
*/
template<typename T>
inline T to_be(T data) {
inline T host_to_be(T data) {
return change_endian(data);
}
@@ -202,7 +202,7 @@ namespace Tins {
* \param data The data to convert.
*/
template<typename T>
inline T to_le(T data) {
inline T host_to_le(T data) {
return data;
}
@@ -232,7 +232,7 @@ namespace Tins {
* \param data The data to convert.
*/
template<typename T>
inline T to_be(T data) {
inline T host_to_be(T data) {
return data;
}
@@ -244,7 +244,7 @@ namespace Tins {
* \param data The data to convert.
*/
template<typename T>
inline T to_le(T data) {
inline T host_to_le(T data) {
return change_endian(data);
}
@@ -371,11 +371,11 @@ void Tins::Utils::route_entries(ForwardIterator output) {
for(unsigned i(0); i < 5; ++i)
input >> mask;
from_hex(destination, dummy);
entry.destination = net_to_host_l(dummy);
entry.destination = be_to_host(dummy);
from_hex(mask, dummy);
entry.mask = net_to_host_l(dummy);
entry.mask = be_to_host(dummy);
from_hex(gw, dummy);
entry.gateway = net_to_host_l(dummy);
entry.gateway = be_to_host(dummy);
skip_line(input);
*output = entry;
++output;