-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement -O which writes a pcap file with interesting packets
currently only packets which are reported as having bad FCS are written.
- Loading branch information
Showing
8 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <unistd.h> | ||
#include <pcap/pcap.h> | ||
|
||
void pcapfile_write_header(int outfd) { | ||
write(outfd, "\xD4\xC3\xB2\xA1" "\x02\x00\x04\x00" | ||
"\x00\x00\x00\x00" "\x00\x00\x00\x00" | ||
"\x00\x00\x04\x00" "\x7F\x00\x00\x00", 24); | ||
} | ||
|
||
void pcapfile_write_packet(int outfd, struct pcap_pkthdr *h_out, const unsigned char* data) { | ||
struct pcap_file_pkthdr { | ||
unsigned sec_epoch; | ||
unsigned ms_sec; | ||
unsigned caplen; | ||
unsigned len; | ||
} hdr_out = { | ||
.sec_epoch = h_out->ts.tv_sec, | ||
.ms_sec = h_out->ts.tv_usec, | ||
.caplen = h_out->caplen, | ||
.len = h_out->len, | ||
}; | ||
write(outfd, &hdr_out, sizeof hdr_out); | ||
write(outfd, data, h_out->len); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef PCAPFILE_H | ||
#define PCAPFILE_H | ||
|
||
#include <pcap/pcap.h> | ||
|
||
void pcapfile_write_header(int outfd); | ||
void pcapfile_write_packet(int outfd, struct pcap_pkthdr *h_out, const unsigned char* data); | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters