From e83acc92ccc461450ffe61c63541cea7de2ec8d2 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Thu, 16 Aug 2012 23:45:50 -0300 Subject: [PATCH] No code uses net_to_host_* now. --- include/snap.h | 2 +- src/dot11.cpp | 4 ++-- src/ethernetII.cpp | 4 ++-- src/ipaddress.cpp | 7 +------ src/network_interface.cpp | 8 ++++---- src/radiotap.cpp | 4 ++-- src/snap.cpp | 6 +++--- 7 files changed, 15 insertions(+), 20 deletions(-) diff --git a/include/snap.h b/include/snap.h index d7daeb9..919c056 100644 --- a/include/snap.h +++ b/include/snap.h @@ -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 */ diff --git a/src/dot11.cpp b/src/dot11.cpp index ed81de0..7cefd63 100644 --- a/src/dot11.cpp +++ b/src/dot11.cpp @@ -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(PF_PACKET); + addr.sll_protocol = Utils::host_to_be(ETH_P_ALL); addr.sll_halen = 6; addr.sll_ifindex = this->_iface.id(); memcpy(&(addr.sll_addr), this->_header.addr1, 6); diff --git a/src/ethernetII.cpp b/src/ethernetII.cpp index 38f209a..bf5d0ca 100644 --- a/src/ethernetII.cpp +++ b/src/ethernetII.cpp @@ -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)); } diff --git a/src/ipaddress.cpp b/src/ipaddress.cpp index cbb5eda..8cc6458 100644 --- a/src/ipaddress.cpp +++ b/src/ipaddress.cpp @@ -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 { diff --git a/src/network_interface.cpp b/src/network_interface.cpp index bcf7266..4f47db7 100644 --- a/src/network_interface.cpp +++ b/src/network_interface.cpp @@ -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; diff --git a/src/radiotap.cpp b/src/radiotap.cpp index f157f5f..037018f 100644 --- a/src/radiotap.cpp +++ b/src/radiotap.cpp @@ -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(PF_PACKET); + addr.sll_protocol = Utils::host_to_be(ETH_P_ALL); addr.sll_halen = 6; addr.sll_ifindex = _iface.id(); diff --git a/src/snap.cpp b/src/snap.cpp index 21f4bb1..914ff72 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -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)); }