* Re: [Caml-list] camlIDL and callbacks
2003-11-22 19:16 [Caml-list] camlIDL and callbacks Jonathan Heusser
@ 2003-11-22 17:58 ` Daniel Bünzli
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Bünzli @ 2003-11-22 17:58 UTC (permalink / raw)
To: Jonathan Heusser; +Cc: caml-list
Le 22 nov. 03, à 20:16, Jonathan Heusser a écrit :
> Can anyone give me an idea how to solve such C-to-ocaml callback
> issues in idl ?
Maybe have a look at this thread of discussion :
<http://caml.inria.fr/archives/200207/msg00454.html>
Daniel
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Caml-list] camlIDL and callbacks
@ 2003-11-22 19:16 Jonathan Heusser
2003-11-22 17:58 ` Daniel Bünzli
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Heusser @ 2003-11-22 19:16 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 652 bytes --]
Hello,
I'm trying to implement libpcap bindings for ocaml using CamlIDL.
Currently, I'm running into trouble with C libpcap functions which are
using
callbacks. Those are: pcap_loop, pcap_dispatch and indirectly pcap_next
(which calls pcap_dispatch)
When using e.g. pcap_next in ocaml, defined by the idl code attached, it
returns a
correct pcap_pkthdr though the call to pcap_dispatch is not working due
to the missing
callback functionality..
Can anyone give me an idea how to solve such C-to-ocaml callback issues
in idl ?
thank you for any help,
jonathan heusser
--
Key fingerprint = 2A55 EB7C B7EA 6336 7767 4A47 910A 307B 1333 BD6C
[-- Attachment #2: pcap.idl --]
[-- Type: text/plain, Size: 1244 bytes --]
quote(C, "
#include <pcap.h>
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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-11-22 17:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-22 19:16 [Caml-list] camlIDL and callbacks Jonathan Heusser
2003-11-22 17:58 ` Daniel Bünzli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox