how to use raw sockets

James Miller james at aatch.net
Wed Feb 29 13:50:36 PST 2012


On 1 March 2012 10:05, maarten van damme <maartenvd1994 at gmail.com> wrote:
> I've tried porting libcap once but I failed miserably. If I'd succeed in
> porting they wouldn't be of good quality.

Not porting, writing bindings for it. Its pretty easy. just convert
the declarations into D extern (C) { declarations.
By the looks of it, you'll want to do bindings for
https://github.com/mcr/libpcap/blob/master/pcap/pcap.h and possibly
https://github.com/mcr/libpcap/blob/master/pcap/bpf.h.

The man page here, http://www.tcpdump.org/pcap3_man.html can also give
you a good starting point, and you could just write the bindings
straight from that if you want.

There is documentation to help people write C bindings here:
http://dlang.org/interfaceToC.html

Also if you submit it to Deimos, and if it happens to be a little
rough-around-the-edges or incomplete, somebody else can fill in the
gaps. Obviously you need to do a reasonable job, but it is only
writing function prototypes, so there's not much that can go wrong.

--
James Miller


More information about the Digitalmars-d-learn mailing list