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

No code uses net_to_host_* now.

This commit is contained in:
Matias Fontanini
2012-08-16 23:45:50 -03:00
parent 27f6eeccd4
commit e83acc92cc
7 changed files with 15 additions and 20 deletions

View File

@@ -92,7 +92,7 @@ namespace Tins {
* \brief Setter for the eth type field.
* \param new_eth The new eth type to be set.
*/
void eth_type(uint32_t new_eth);
void eth_type(uint16_t new_eth);
/* Getters */

View File

@@ -194,8 +194,8 @@ bool Dot11::send(PacketSender* sender) {
memset(&addr, 0, sizeof(struct sockaddr_ll));
addr.sll_family = Utils::net_to_host_s(PF_PACKET);
addr.sll_protocol = Utils::net_to_host_s(ETH_P_ALL);
addr.sll_family = Utils::host_to_be<uint16_t>(PF_PACKET);
addr.sll_protocol = Utils::host_to_be<uint16_t>(ETH_P_ALL);
addr.sll_halen = 6;
addr.sll_ifindex = this->_iface.id();
memcpy(&(addr.sll_addr), this->_header.addr1, 6);

View File

@@ -86,7 +86,7 @@ void EthernetII::iface(const NetworkInterface& new_iface) {
}
void EthernetII::payload_type(uint16_t new_payload_type) {
this->_eth.payload_type = Utils::net_to_host_s(new_payload_type);
this->_eth.payload_type = Utils::host_to_be(new_payload_type);
}
uint32_t EthernetII::header_size() const {
@@ -137,7 +137,7 @@ void EthernetII::write_serialization(uint8_t *buffer, uint32_t total_sz, const P
default:
type = 0;
}
_eth.payload_type = Utils::net_to_host_s(type);
_eth.payload_type = Utils::host_to_be(type);
}
memcpy(buffer, &_eth, sizeof(ethhdr));
}

View File

@@ -35,11 +35,6 @@ IPv4Address::IPv4Address(const std::string &ip)
}
/*IPv4Address::IPv4Address(const char *ip)
: ip_addr(Utils::ip_to_int(ip)) {
}*/
IPv4Address &IPv4Address::operator=(uint32_t ip) {
ip_addr = ip;
return *this;
@@ -51,7 +46,7 @@ IPv4Address &Tins::IPv4Address::operator=(const string &ip) {
}
IPv4Address::operator uint32_t() const {
return Utils::net_to_host_l(ip_addr);
return Utils::host_to_be(ip_addr);
}
IPv4Address::operator std::string() const {

View File

@@ -41,16 +41,16 @@ struct InterfaceInfoCollector {
: info(res), iface_id(id), iface_name(if_name), found(false) { }
bool operator() (struct ifaddrs *addr) {
using Tins::Utils::net_to_host_l;
using Tins::Utils::host_to_be;
const struct sockaddr_ll* addr_ptr = ((struct sockaddr_ll*)addr->ifa_addr);
if(addr->ifa_addr->sa_family == AF_PACKET && addr_ptr->sll_ifindex == iface_id)
info->hw_addr = addr_ptr->sll_addr;
else if(addr->ifa_addr->sa_family == AF_INET && !std::strcmp(addr->ifa_name, iface_name)) {
info->ip_addr = net_to_host_l(((struct sockaddr_in *)addr->ifa_addr)->sin_addr.s_addr);
info->netmask = net_to_host_l(((struct sockaddr_in *)addr->ifa_netmask)->sin_addr.s_addr);
info->ip_addr = host_to_be(((struct sockaddr_in *)addr->ifa_addr)->sin_addr.s_addr);
info->netmask = host_to_be(((struct sockaddr_in *)addr->ifa_netmask)->sin_addr.s_addr);
if((addr->ifa_flags & (IFF_BROADCAST | IFF_POINTOPOINT)))
info->bcast_addr = net_to_host_l(((struct sockaddr_in *)addr->ifa_ifu.ifu_broadaddr)->sin_addr.s_addr);
info->bcast_addr = host_to_be(((struct sockaddr_in *)addr->ifa_ifu.ifu_broadaddr)->sin_addr.s_addr);
else
info->bcast_addr = 0;
found = true;

View File

@@ -197,8 +197,8 @@ bool Tins::RadioTap::send(PacketSender* sender) {
memset(&addr, 0, sizeof(struct sockaddr_ll));
addr.sll_family = Utils::net_to_host_s(PF_PACKET);
addr.sll_protocol = Utils::net_to_host_s(ETH_P_ALL);
addr.sll_family = Utils::host_to_be<uint16_t>(PF_PACKET);
addr.sll_protocol = Utils::host_to_be<uint16_t>(ETH_P_ALL);
addr.sll_halen = 6;
addr.sll_ifindex = _iface.id();

View File

@@ -79,8 +79,8 @@ void Tins::SNAP::org_code(uint32_t new_org) {
_snap.org_code = new_org;
}
void Tins::SNAP::eth_type(uint32_t new_eth) {
_snap.eth_type = Utils::net_to_host_s(new_eth);
void Tins::SNAP::eth_type(uint16_t new_eth) {
_snap.eth_type = Utils::host_to_be(new_eth);
}
uint32_t Tins::SNAP::header_size() const {
@@ -104,7 +104,7 @@ void Tins::SNAP::write_serialization(uint8_t *buffer, uint32_t total_sz, const P
default:
type = 0;
}
_snap.eth_type = Utils::net_to_host_s(type);
_snap.eth_type = Utils::host_to_be(type);
}
std::memcpy(buffer, &_snap, sizeof(_snap));
}