rusticata / pcap-parser

PCAP/PCAPNG file format parser written in pure Rust. Fast, zero-copy, safe.
Other
103 stars 24 forks source link

How to add fake pcap header before parsing #5

Closed mhristache closed 4 years ago

mhristache commented 4 years ago

Hi

I am trying to build a packet sniffer server and I am receiving pcap lib Packets via TCP but without the pcap file header. Is there a way to parse these packets using pcap-parser, e.g. add a pcap file header on the server side before calling the pcap-parser? The datalink type is always the same so that should not be an issue.

Thank you

chifflier commented 4 years ago

Hi, Not sure I understand correctly. If you are receiving encapsulated packets (assuming the encapsulation is pcap, not pcap-ng), there are several options:

mhristache commented 4 years ago

Thanks for the help! I got it working using the streaming API by creating a forged pcap header then chain it into the original data usin the Read::chain method.