
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, Greg On Apr 14, 2006, at 3:57 AM, Dominic Steinitz wrote:
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@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
with #include ). 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@haskell.org http://www.haskell.org/mailman/listinfo/libraries