| 1 |
MLpcap - 0.9 |
| 2 |
------------ |
| 3 |
|
| 4 |
MLpcap implements ocaml stubs to libpcap. |
| 5 |
It is distributed under the Lesser GPL. |
| 6 |
Libpcap is available at www.tcpdump.org. |
| 7 |
|
| 8 |
tests/ contains code snippets showing the usage of MLpcap functions. |
| 9 |
|
| 10 |
|
| 11 |
Software requirements |
| 12 |
--------------------- |
| 13 |
|
| 14 |
libpcap 0.7-0.8.x: http://www.tcpdump.org/ |
| 15 |
|
| 16 |
CamlIDL: http://caml.inria.fr/camlidl/ |
| 17 |
Download: http://caml.inria.fr/distrib/bazar-ocaml/ |
| 18 |
|
| 19 |
FFCall: http://www.gnu.org/directory/libs/c/ffcall.html |
| 20 |
Download: ftp://ftp.santafe.edu/pub/gnu/ |
| 21 |
|
| 22 |
|
| 23 |
Building the library |
| 24 |
-------------------- |
| 25 |
|
| 26 |
Run the configure script with the appropriate paths to ffcall and |
| 27 |
camlidl (read INSTALL) and type 'make' afterwards. |
| 28 |
|
| 29 |
|
| 30 |
MLpcap vs. libpcap types |
| 31 |
------------------------ |
| 32 |
|
| 33 |
pcap_handle <-> pcap_t* |
| 34 |
pcap_pkthdr <-> struct pcap_pkthdr |
| 35 |
pcap_stat <-> struct pcap_stat |
| 36 |
pcap_dumper <-> struct pcap_dumper* |
| 37 |
pcap_if <-> struct pcap_if |
| 38 |
bpf_program <-> struct bpf_program* |
| 39 |
|
| 40 |
|
| 41 |
Differences to the original libpcap |
| 42 |
----------------------------------- |
| 43 |
|
| 44 |
- All functions which return values,structs etc as one of its arguments |
| 45 |
in the C version use N-tuple return values in ocaml. |
| 46 |
E.g. pcap_stats defined in C: |
| 47 |
int pcap_stats(pcap_t *p, struct pcap_stat *ps) |
| 48 |
and in OCaml: |
| 49 |
pcap_stats : pcap_handle -> int * pcap_stat |
| 50 |
|
| 51 |
- All functions containing an errbuf argument in its C version don't |
| 52 |
use errbuf as argument in MLpcap. If an error occurs the function raises |
| 53 |
an exception Failure with errbuf as argument. |
| 54 |
|
| 55 |
These functions are: pcap_open_live, pcap_open_offline, pcap_setnonblock, |
| 56 |
pcap_getnonblock, pcap_findalldevs, pcap_lookupnet |
| 57 |
|
| 58 |
- pcap_dump is called pcap_dump_direct and must be used as shown in |
| 59 |
tests/pcap_dump_direct.ml |
| 60 |
|
| 61 |
- pcap_next/pcap_next_ex has not been implemented since it's only a |
| 62 |
wrapper to pcap_dispatch and can be implemented as shown in |
| 63 |
tests/pcap_next.ml |
| 64 |
|
| 65 |
|
| 66 |
Comments and Bugreports |
| 67 |
----------------------- |
| 68 |
|
| 69 |
Comments, Suggestions etc are welcome. Write me to: [email protected] |
| 70 |
|
| 71 |
|