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

Exception for packet serialization #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/cmake-build-*
/.idea
10 changes: 9 additions & 1 deletion dot11decrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ using std::move;
using std::memset;
using std::bind;
using std::cout;
using std::cerr;
using std::endl;
using std::runtime_error;
using std::invalid_argument;
Expand Down Expand Up @@ -194,7 +195,14 @@ class packet_buffer {
auto pkt = make_eth_packet(dot11);
// move the inner pdu into the EthernetII to avoid copying
pkt.inner_pdu(snap.release_inner_pdu());
auto buffer = pkt.serialize();
vector<uint8_t> buffer;
try {
buffer = pkt.serialize();
}
catch (Tins::serialization_error) {
cerr << "Serialization error!" << endl;
return false;
}
if (write(*fd_, buffer.data(), buffer.size()) == -1) {
throw runtime_error("Error writing to tap interface");
}
Expand Down