Skip to content

Commit

Permalink
add option sock_qdisc_bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Mar 20, 2024
1 parent 5e0aa45 commit 56446ed
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions wifibroadcast/src/WBTxRx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ WBTxRx::WBTxRx(
// TX part - using raw socket or pcap
if (m_options.tx_without_pcap) {
pcapTxRx.tx_sockfd = open_wifi_interface_as_raw_socket(wifi_card.name);
if (m_options.set_tx_sock_qdisc_bypass) {
wifibroadcast::pcap_helper::set_tx_sock_qdisc_bypass(
pcapTxRx.tx_sockfd);
}
} else {
pcapTxRx.tx = wifibroadcast::pcap_helper::open_pcap_tx(wifi_card.name);
if (m_options.set_tx_sock_qdisc_bypass) {
wifibroadcast::pcap_helper::pcap_set_tx_sock_qdisc_bypass(
pcapTxRx.tx);
}
}
m_pcap_handles.push_back(pcapTxRx);
}
Expand Down
1 change: 1 addition & 0 deletions wifibroadcast/src/WBTxRx.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class WBTxRx {
// on the rx pcap rx fd, set direction PCAP_D_IN (aka only packets received
// by the card) - doesn't work on AR9271
bool pcap_rx_set_direction = true;
bool set_tx_sock_qdisc_bypass = false;
// thy spam the console, but usefully for debugging
// log all received packets (regardless where they are from)
bool log_all_received_packets = false;
Expand Down
17 changes: 17 additions & 0 deletions wifibroadcast/src/pcap_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef WIFIBROADCAST_SRC_PCAP_HELPER_H_
#define WIFIBROADCAST_SRC_PCAP_HELPER_H_

#include <netpacket/packet.h>
#include <pcap/pcap.h>

#include <string>
Expand Down Expand Up @@ -113,6 +114,22 @@ static pcap_t *open_pcap_tx(const std::string &wlan) {
return p;
}

static void set_tx_sock_qdisc_bypass(int fd) {
/* setting PACKET_QDISC_BYPASS to 1 ?? */
int32_t sock_qdisc_bypass = 1;
const auto ret = setsockopt(fd, SOL_PACKET, PACKET_QDISC_BYPASS,
&sock_qdisc_bypass, sizeof(sock_qdisc_bypass));
if (ret != 0) {
wifibroadcast::log::get_default()->warn("Cannot set PACKET_QDISC_BYPASS");
} else {
wifibroadcast::log::get_default()->debug("PACKET_QDISC_BYPASS set");
}
}
static void pcap_set_tx_sock_qdisc_bypass(pcap_t *handle) {
auto fd = pcap_get_selectable_fd(handle);
set_tx_sock_qdisc_bypass(fd);
}

} // namespace wifibroadcast::pcap_helper

#endif // WIFIBROADCAST_SRC_PCAP_HELPER_H_

0 comments on commit 56446ed

Please sign in to comment.