1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Modified set_direction to return a bool

This commit is contained in:
Jesus Llorente
2015-12-21 17:56:18 +02:00
parent 4b9f998784
commit 6b82e50c03
2 changed files with 5 additions and 4 deletions

View File

@@ -218,7 +218,7 @@ namespace Tins {
* This calls pcap_setdirection using the provided parameter.
* \param d The direction for the sniffer.
*/
int set_direction(pcap_direction_t d);
bool set_direction(pcap_direction_t d);
/**
* \brief Sets whether to extract RawPDUs or fully parsed packets.

View File

@@ -224,8 +224,9 @@ void BaseSniffer::set_timeout(int ms) {
pcap_set_timeout(handle, ms);
}
int BaseSniffer::set_direction(pcap_direction_t d) {
return pcap_setdirection(handle, d);
bool BaseSniffer::set_direction(pcap_direction_t d) {
bool result = pcap_setdirection(handle, d) != -1;
return result;
}
// ****************************** Sniffer ******************************
@@ -453,7 +454,7 @@ void SnifferConfiguration::configure_sniffer_post_activation(Sniffer& sniffer) c
throw std::runtime_error("Could not set the filter! ");
}
}
if (sniffer.set_direction(_direction) < 0) {
if (!sniffer.set_direction(_direction)) {
throw std::runtime_error("Could not set the direction! ");
}
}