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

Removed deprecated methods/types.

This commit is contained in:
Matias Fontanini
2013-04-21 19:52:39 -03:00
parent 9e20c0241f
commit 69968cbc5c
26 changed files with 33 additions and 238 deletions

View File

@@ -119,10 +119,6 @@ bool ARP::matches_response(uint8_t *ptr, uint32_t total_sz) {
return arp_ptr->ar_sip == _arp.ar_tip && arp_ptr->ar_tip == _arp.ar_sip;
}
PDU *ARP::clone_packet(const uint8_t *ptr, uint32_t total_sz) {
return new ARP(ptr, total_sz);
}
EthernetII ARP::make_arp_request(ipaddress_type target, ipaddress_type sender,
const hwaddress_type &hw_snd)
{

View File

@@ -120,11 +120,6 @@ void Dot11::add_option(const option &opt) {
_options.push_back(opt);
}
void Dot11::add_tagged_option(const option &opt) {
internal_add_option(opt);
_options.push_back(opt);
}
const Dot11::option *Dot11::search_option(OptionTypes opt) const {
for(std::list<option>::const_iterator it = _options.begin(); it != _options.end(); ++it)
if(it->option() == (uint8_t)opt)

View File

@@ -160,8 +160,4 @@ PDU *Dot3::recv_response(PacketSender &sender, const NetworkInterface &iface) {
#endif
}
#endif // WIN32
PDU *Dot3::clone_packet(const uint8_t *ptr, uint32_t total_sz) {
return new Dot3(ptr, total_sz);
}
}

View File

@@ -169,8 +169,4 @@ PDU *EthernetII::recv_response(PacketSender &sender, const NetworkInterface &ifa
#endif
}
#endif // WIN32
PDU *EthernetII::clone_packet(const uint8_t *ptr, uint32_t total_sz) {
return new EthernetII(ptr, total_sz);
}
}

View File

@@ -39,13 +39,14 @@
#include "utils.h"
#include "exceptions.h"
Tins::ICMP::ICMP(Flags flag)
namespace Tins {
ICMP::ICMP(Flags flag)
{
std::memset(&_icmp, 0, sizeof(icmphdr));
type(flag);
}
Tins::ICMP::ICMP(const uint8_t *buffer, uint32_t total_sz)
ICMP::ICMP(const uint8_t *buffer, uint32_t total_sz)
{
if(total_sz < sizeof(icmphdr))
throw malformed_packet();
@@ -55,78 +56,78 @@ Tins::ICMP::ICMP(const uint8_t *buffer, uint32_t total_sz)
inner_pdu(new RawPDU(buffer + sizeof(icmphdr), total_sz));
}
void Tins::ICMP::code(uint8_t new_code) {
void ICMP::code(uint8_t new_code) {
_icmp.code = new_code;
}
void Tins::ICMP::type(Flags new_type) {
void ICMP::type(Flags new_type) {
_icmp.type = new_type;
}
void Tins::ICMP::check(uint16_t new_check) {
void ICMP::check(uint16_t new_check) {
_icmp.check = Endian::host_to_be(new_check);
}
void Tins::ICMP::id(uint16_t new_id) {
void ICMP::id(uint16_t new_id) {
_icmp.un.echo.id = Endian::host_to_be(new_id);
}
void Tins::ICMP::sequence(uint16_t new_seq) {
void ICMP::sequence(uint16_t new_seq) {
_icmp.un.echo.sequence = Endian::host_to_be(new_seq);
}
void Tins::ICMP::gateway(uint32_t new_gw) {
void ICMP::gateway(uint32_t new_gw) {
_icmp.un.gateway = Endian::host_to_be(new_gw);
}
void Tins::ICMP::mtu(uint16_t new_mtu) {
void ICMP::mtu(uint16_t new_mtu) {
_icmp.un.frag.mtu = Endian::host_to_be(new_mtu);
}
void Tins::ICMP::pointer(uint8_t new_pointer) {
void ICMP::pointer(uint8_t new_pointer) {
_icmp.un.pointer = new_pointer;
}
uint32_t Tins::ICMP::header_size() const {
uint32_t ICMP::header_size() const {
return sizeof(icmphdr);
}
void Tins::ICMP::set_echo_request(uint16_t id, uint16_t seq) {
void ICMP::set_echo_request(uint16_t id, uint16_t seq) {
type(ECHO_REQUEST);
this->id(id);
sequence(seq);
}
void Tins::ICMP::set_echo_reply(uint16_t id, uint16_t seq) {
void ICMP::set_echo_reply(uint16_t id, uint16_t seq) {
type(ECHO_REPLY);
this->id(id);
sequence(seq);
}
void Tins::ICMP::set_info_request(uint16_t id, uint16_t seq) {
void ICMP::set_info_request(uint16_t id, uint16_t seq) {
type(INFO_REQUEST);
code(0);
this->id(id);
sequence(seq);
}
void Tins::ICMP::set_info_reply(uint16_t id, uint16_t seq) {
void ICMP::set_info_reply(uint16_t id, uint16_t seq) {
type(INFO_REPLY);
code(0);
this->id(id);
sequence(seq);
}
void Tins::ICMP::set_dest_unreachable() {
void ICMP::set_dest_unreachable() {
type(DEST_UNREACHABLE);
}
void Tins::ICMP::set_time_exceeded(bool ttl_exceeded) {
void ICMP::set_time_exceeded(bool ttl_exceeded) {
type(TIME_EXCEEDED);
code((ttl_exceeded) ? 0 : 1);
}
void Tins::ICMP::set_param_problem(bool set_pointer, uint8_t bad_octet) {
void ICMP::set_param_problem(bool set_pointer, uint8_t bad_octet) {
type(PARAM_PROBLEM);
if(set_pointer) {
code(0);
@@ -136,17 +137,17 @@ void Tins::ICMP::set_param_problem(bool set_pointer, uint8_t bad_octet) {
code(1);
}
void Tins::ICMP::set_source_quench() {
void ICMP::set_source_quench() {
type(SOURCE_QUENCH);
}
void Tins::ICMP::set_redirect(uint8_t icode, uint32_t address) {
void ICMP::set_redirect(uint8_t icode, uint32_t address) {
type(REDIRECT);
code(icode);
gateway(address);
}
void Tins::ICMP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) {
void ICMP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) {
assert(total_sz >= sizeof(icmphdr));
if(!_icmp.check) {
uint32_t checksum = Utils::do_checksum(buffer + sizeof(icmphdr), buffer + total_sz) +
@@ -159,7 +160,7 @@ void Tins::ICMP::write_serialization(uint8_t *buffer, uint32_t total_sz, const P
_icmp.check = 0;
}
bool Tins::ICMP::matches_response(uint8_t *ptr, uint32_t total_sz) {
bool ICMP::matches_response(uint8_t *ptr, uint32_t total_sz) {
if(total_sz < sizeof(icmphdr))
return false;
const icmphdr *icmp_ptr = (const icmphdr*)ptr;
@@ -168,7 +169,4 @@ bool Tins::ICMP::matches_response(uint8_t *ptr, uint32_t total_sz) {
}
return false;
}
Tins::PDU *Tins::ICMP::clone_packet(const uint8_t *ptr, uint32_t total_sz) {
return new ICMP(ptr, total_sz);
}
} // namespace Tins

View File

@@ -441,8 +441,4 @@ bool IP::matches_response(uint8_t *ptr, uint32_t total_sz) {
}
return false;
}
PDU *IP::clone_packet(const uint8_t *ptr, uint32_t total_sz) {
return new IP(ptr, total_sz);
}
}

View File

@@ -121,8 +121,4 @@ void PDU::serialize(uint8_t *buffer, uint32_t total_sz, const PDU *parent) {
_inner_pdu->serialize(buffer + header_size(), total_sz - sz, this);
write_serialization(buffer, total_sz, parent);
}
PDU *PDU::clone_packet(const uint8_t *ptr, uint32_t total_sz) {
return 0;
}
}

View File

@@ -269,10 +269,6 @@ void TCP::set_flag(Flags tcp_flag, small_uint<1> value) {
};
}
void TCP::add_option(OptionTypes opt, uint8_t length, const uint8_t *data) {
add_option(option(opt, data, data + length));
}
void TCP::add_option(const option &opt) {
_options.push_back(opt);
internal_add_option(opt);

View File

@@ -88,13 +88,6 @@ namespace Tins {
/** \endcond */
namespace Utils {
IPv4Address resolve_ip(const string &to_resolve) {
struct hostent *data = gethostbyname(to_resolve.c_str());
if(!data)
throw std::runtime_error("Could not resolve IP");
return IPv4Address(((struct in_addr**)data->h_addr_list)[0]->s_addr);
}
IPv4Address resolve_domain(const std::string &to_resolve) {
addrinfo *result = ::resolve_domain(to_resolve, AF_INET);
@@ -110,23 +103,6 @@ IPv6Address resolve_domain6(const std::string &to_resolve) {
return addr;
}
bool resolve_hwaddr(const NetworkInterface &iface, IPv4Address ip,
HWAddress<6> *address, PacketSender &sender)
{
IPv4Address my_ip;
NetworkInterface::Info info(iface.addresses());
EthernetII packet = ARP::make_arp_request(ip, info.ip_addr, info.hw_addr);
Internals::smart_ptr<PDU>::type response(sender.send_recv(packet, iface));
if(response.get()) {
ARP *arp_resp = response->find_pdu<ARP>();
if(arp_resp)
*address = arp_resp->sender_hw_addr();
return arp_resp != 0;
}
else
return false;
}
HWAddress<6> resolve_hwaddr(const NetworkInterface &iface, IPv4Address ip, PacketSender &sender)
{
IPv4Address my_ip;