mirror of
https://github.com/mfontanini/libtins
synced 2026-01-25 19:51:34 +01:00
Added Utils::ping_address. Fixed bugs in PacketSender::recv_match_loop.
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
#include <iostream> //borrame
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#ifndef WIN32
|
||||
@@ -33,6 +32,8 @@
|
||||
#endif
|
||||
#include "utils.h"
|
||||
#include "pdu.h"
|
||||
#include "ip.h"
|
||||
#include "icmp.h"
|
||||
#include "arp.h"
|
||||
|
||||
|
||||
@@ -187,6 +188,17 @@ uint32_t Tins::Utils::resolve_ip(const string &to_resolve) throw (std::runtime_e
|
||||
return Utils::net_to_host_l(((struct in_addr**)data->h_addr_list)[0]->s_addr);
|
||||
}
|
||||
|
||||
Tins::PDU *Tins::Utils::ping_address(uint32_t ip, PacketSender *sender, uint32_t ip_src) {
|
||||
ICMP *icmp = new ICMP(ICMP::ECHO_REQUEST);
|
||||
if(!ip_src) {
|
||||
std::string iface(Utils::interface_from_ip(ip));
|
||||
if(!iface.size() || !Utils::interface_ip(iface, ip_src))
|
||||
return 0;
|
||||
}
|
||||
IP ip_packet(ip, ip_src, icmp);
|
||||
return sender->send_recv(&ip_packet);
|
||||
}
|
||||
|
||||
bool Tins::Utils::resolve_hwaddr(const string &iface, uint32_t ip, uint8_t *buffer, PacketSender *sender) {
|
||||
uint32_t my_ip;
|
||||
uint8_t my_hw[6];
|
||||
|
||||
Reference in New Issue
Block a user