Skip to content

Instantly share code, notes, and snippets.

@picatz
Last active November 16, 2017 01:26
Show Gist options
  • Save picatz/b0a2381c6b306eaa526c6f03f54f6196 to your computer and use it in GitHub Desktop.
Save picatz/b0a2381c6b306eaa526c6f03f54f6196 to your computer and use it in GitHub Desktop.
Using pcap_open_live
@[Link("pcap")]
lib LibPcap
# previous code ...
type PcapT = Void*
alias UChar = UInt8
alias BpfUInt32 = LibC::UInt
struct Timeval
tv_sec : LibC::Long
tv_usec : LibC::Long
end
struct PcapPkthdr
ts : Timeval
caplen : BpfUInt32
len : BpfUInt32
end
fun pcap_open_live(device : LibC::Char*,
snaplen : LibC::Int,
promisc : LibC::Int,
to_ms : LibC::Int,
errbuf : LibC::Char*) : PcapT
fun pcap_next_ex(capture : PcapT, header : PcapPkthdr**, data : UChar**) : LibC::Int
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment