1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-30 05:24:26 +01:00

Added Utils::ping_address. Fixed bugs in PacketSender::recv_match_loop.

This commit is contained in:
Matias Fontanini
2012-03-20 12:07:08 -03:00
parent b6adb7ba8d
commit fa9c260d85
4 changed files with 62 additions and 8 deletions

View File

@@ -29,6 +29,7 @@
#ifndef WIN32
#include <netinet/in.h>
#include <sys/time.h>
#endif
#include "pdu.h"
@@ -169,6 +170,7 @@ namespace Tins {
typedef std::map<SocketType, int> SocketTypeMap;
int find_type(SocketType type);
int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
PDU *recv_match_loop(int sock, PDU *pdu, struct sockaddr* link_addr, socklen_t addrlen);

View File

@@ -78,6 +78,23 @@ namespace Tins {
* \param to_resolve The domain name/ip address to resolve.
*/
uint32_t resolve_ip(const std::string &to_resolve) throw (std::runtime_error);
/**
* \brief Pings an ip address.
*
* This function pings an IP address and returns the ICMP response.
* If no response is received, 0 is returned
*
* \param ip The IP address to ping.
* \param sender The PacketSender that will send the ping request.
* \param ip_src The source IP address that will be used in the packet.
* If 0, or no parameter is provided, then that IP address is looked
* up using Utils::interface_ip.
*
* \return PDU * containing either 0 if no response was received,
* or the ICMP response otherwise.
*/
PDU *ping_address(uint32_t ip, PacketSender *sender, uint32_t ip_src = 0);
/** \brief Resolves the hardware address for a given ip.
*