quote(C, " #include typedef pcap_t *pcap_handle; typedef struct pcap_pkthdr pcap_pkthdr; typedef void (*pcap_callback)(u_char *, const struct pcap_pkthdr *, const u_char *); ") /* type defitions */ /* .............. */ typedef [abstract, ptr] void * pcap_handle; struct timeval { int tv_sec; int tv_usec; }; typedef struct { struct timeval ts; int caplen; int len; } pcap_pkthdr; /* function definitions */ /* .................... */ /* experimental callback handler */ typedef [ptr,mltype("string -> pcap_pkthdr -> string -> unit")] void *pcap_callback; /* tested, OK */ pcap_handle pcap_open_live([in,string] char *dev, [in] int snaplen, [in] int promisc, [in] int to_ms, [in,out,string] char *err); /* tested, OK */ [string] char *pcap_lookupdev([in,out,string] char *errbuf); /* broken ! */ [string] unsigned char *pcap_next([in] pcap_handle p, [in,out] pcap_pkthdr * h) quote(call, "_res = (char*) pcap_next(p,h); "); /* tested, OK */ void pcap_close(pcap_handle p); /* broken ! */ int pcap_loop([in] pcap_handle p, [in] int cnt, [in] pcap_callback callback, [in,string] char *user); int pcap_dispatch([in] pcap_handle p, [in] int cnt, [in] pcap_callback callback, [in,string] char *user);