Skip to content

Instantly share code, notes, and snippets.

@picatz
Last active November 15, 2017 20:03
Show Gist options
  • Save picatz/86ff283d234c6824c6e02557097ff08f to your computer and use it in GitHub Desktop.
Save picatz/86ff283d234c6824c6e02557097ff08f to your computer and use it in GitHub Desktop.
Get interface to listen on
@[Link("pcap")]
lib LibPcap
PCAP_ERRBUF_SIZE = UInt8.new(256)
fun pcap_lookupdev(errbuf : LibC::Char* ) : LibC::Char*
end
err = LibPcap::PCAP_ERRBUF_SIZE.dup
dev = LibPcap.pcap_lookupdev(pointerof(err))
raise Exception.new("Couldn't find a default interface: #{String.new(err)}") if dev.null?
puts String.new(dev)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment