pcap_compile()
compiles a string into a filter program in the form of a bpf_program
struct. In theory I could save the compiled form of the program and supply it to pcap_setfilter()
on a different network interface or even on a different machine.
Will that work? Is the bpf_program
form portable across different interfaces? Different processes? Different architectures? Or is it safest to compile the expression each time I want to use it?
Based on the existence of pcap_open_dead()
I assume it is somewhat portable, but what's safe and what's not doesn't seem to be spelled out anywhere in the documentation.