libpcap Binding & Cabal Question
Dominic Steinitz
dominic.steinitz at blueyonder.co.uk
Fri Apr 14 03:57:05 EDT 2006
I am trying to build the binding for libpcap.
http://www.haskell.org/pipermail/libraries/2004-June/002285.html
http://www.haskell.org//pipermail/libraries/attachments/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
www.tcpdump.org (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.
More information about the Libraries
mailing list