mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Merge branch 'master' of ssh://git.code.sf.net/p/libtins/code
This commit is contained in:
@@ -63,7 +63,7 @@ namespace Tins {
|
||||
*
|
||||
* \param recv_timeout The timeout which will be used when receiving responses.
|
||||
*/
|
||||
PacketSender(uint32_t recv_timeout = DEFAULT_TIMEOUT);
|
||||
PacketSender(uint32_t recv_timeout = DEFAULT_TIMEOUT, uint32_t usec = 0);
|
||||
|
||||
/** \brief PacketSender destructor.
|
||||
*
|
||||
@@ -174,7 +174,7 @@ namespace Tins {
|
||||
|
||||
std::vector<int> _sockets;
|
||||
SocketTypeMap _types;
|
||||
uint32_t _timeout;
|
||||
uint32_t _timeout, _timeout_usec;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@
|
||||
const int Tins::PacketSender::INVALID_RAW_SOCKET = -1;
|
||||
const uint32_t Tins::PacketSender::DEFAULT_TIMEOUT = 2;
|
||||
|
||||
Tins::PacketSender::PacketSender(uint32_t recv_timeout) : _sockets(SOCKETS_END, INVALID_RAW_SOCKET), _timeout(recv_timeout) {
|
||||
Tins::PacketSender::PacketSender(uint32_t recv_timeout, uint32_t usec) :
|
||||
_sockets(SOCKETS_END, INVALID_RAW_SOCKET), _timeout(recv_timeout), _timeout_usec(usec) {
|
||||
_types[IP_SOCKET] = IPPROTO_RAW;
|
||||
_types[ICMP_SOCKET] = IPPROTO_ICMP;
|
||||
}
|
||||
@@ -143,7 +144,7 @@ Tins::PDU *Tins::PacketSender::recv_match_loop(int sock, PDU *pdu, struct sockad
|
||||
uint8_t buffer[2048];
|
||||
time_t end_time = time(0) + _timeout;
|
||||
timeout.tv_sec = _timeout;
|
||||
timeout.tv_usec = 0;
|
||||
timeout.tv_usec = _timeout_usec;
|
||||
while(true) {
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(sock, &readfds);
|
||||
|
||||
Reference in New Issue
Block a user