Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No functional changes #51

Merged
merged 6 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions wifibroadcast/src/HelperSources/SchedulingHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

namespace SchedulingHelper {

// Only 'low' in comparison to other realtime tasks
static constexpr int PRIORITY_REALTIME_LOW = 30;
static constexpr int PRIORITY_REALTIME_MID = 40;
static constexpr int PRIORITY_REALTIME_HIGH = 50;

// this thread should run as close to realtime as possible
// https://youtu.be/NrjXEaTSyrw?t=647
// COMMENT: Please don't ever use 99 for your application, there are some kernel
Expand Down
16 changes: 16 additions & 0 deletions wifibroadcast/src/WBTxRx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ void WBTxRx::tx_inject_packet(const uint8_t stream_index, const uint8_t* data,
m_tx_stats.n_injected_bytes_excluding_overhead += data_len;
m_tx_stats.n_injected_bytes_including_overhead += packet_size;
m_tx_stats.n_injected_packets++;
} else {
m_console->debug("inject error, sleeping ...");
// m_tx_mutex.unlock(); for now, don't unlock ... therefore we block all
// threads calling inject
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}

Expand Down Expand Up @@ -246,16 +251,27 @@ bool WBTxRx::inject_radiotap_packet(int card_index, const uint8_t* packet_buff,
if (len_injected != (int)packet_size) {
// This basically should never fail - if the tx queue is full, pcap seems to
// wait ?!
bool has_fatal_error = false;
if (m_options.tx_without_pcap) {
m_console->warn(
"raw sock - unable to inject packet size:{} ret:{} err:[{}]",
packet_size, len_injected, strerror(errno));
if (errno == ENXIO) {
// See https://man7.org/linux/man-pages/man3/errno.3.html
m_console->warn("Fatal error, no device");
has_fatal_error = true;
}
} else {
m_console->warn("pcap -unable to inject packet size:{} ret:{} err:[{}]",
packet_size, len_injected,
pcap_geterr(m_pcap_handles[card_index].tx));
}
m_tx_stats.count_tx_dropped_packets++;
if (has_fatal_error) {
if (m_fatal_error_cb != nullptr) {
m_fatal_error_cb(errno);
}
}
return false;
}
return true;
Expand Down
5 changes: 4 additions & 1 deletion wifibroadcast/src/WBTxRx.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ class WBTxRx {
// register callback that is called each time a valid packet is received (any
// multiplexed stream)
void rx_register_callback(OUTPUT_DATA_CALLBACK cb);

// register callback that is called when the wifi card (probably)
// disconneccted
typedef std::function<void(int error)> DEVICE_FATAL_ERROR_CALLBACK;
DEVICE_FATAL_ERROR_CALLBACK m_fatal_error_cb = nullptr;
/**
* Receiving packets happens in the background in another thread.
*/
Expand Down
1 change: 1 addition & 0 deletions wifibroadcast/src/pcap_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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

#include <string>

Expand Down
Loading