libpcap Binding & Cabal Question

Gregory Wright gwright at
Fri Apr 14 08:45:38 EDT 2006

Hi Dominic,

I wrote the binding so I'll try to have a look at the problem over the
weekend.  I've been meaning to Cabalize it for a while...perhaps
the list will give advice that will let you get there first!

It should also be updated to support the packet injection call,
which is available on both Windows and Unix now.  I will
send an update to you and the list when it is ready.

Best Regards,

On Apr 14, 2006, at 3:57 AM, Dominic Steinitz wrote:

> I am trying to build the binding for libpcap.
> 20040630/4469b357/Pcap-0001.obj
> Unfortunately when I run hsc2hs I get errors.
> [dom at tility pcap]$ hsc2hs Pcap.hs
> Pcap.hs:121:21: net/bpf.h: No such file or directory
> Pcap.hs: In function `main':
> Pcap.hs:461: error: structure has no member named `sa_len'
> The first one is easily fixed. The version of libpcap I downloaded  
> from
> (LIBPCAP 0.9.4) contains pcap-bpf.h not net/bpf.h  
> (so I
> replaced #inlcude <net/bpf.h> with #include <pcap-bpf.h>).
> The second one is a result because in some systems socket addresses  
> are
> fixed-length and sizeof (struct sockaddr) gives the size of the  
> structure but
> in other systems the socket address is variable length and there's  
> an sa_len
> field giving the length of the structure.
> The libpcap authors handle this by using configure to see if the  
> sa_len field
> exists. If it does then
> #define SA_LEN(addr)    (get_sa_len(addr))
> If does not then (actually it's more complicated than this but I  
> don't want to
> clutter up an already cluttered email)
> #define SA_LEN(addr)   (sizeof (struct sockaddr))
> Finally to my questions.
> 1. How do I get Cabal to check for the existence of sa_len? I'm  
> guessing I
> follow the instructions in "2.2. System-dependent parameters" but I  
> have
> never used autoconf in my life so if there were another easier way  
> I'd be
> happy to hear about it.
> 2. How do I tell Cabal I need LIBPCAP 0.9.4?
> Dominic.
> _______________________________________________
> Libraries mailing list
> Libraries at

More information about the Libraries mailing list