The Assimilation Project  based on Assimilation version
Go to the documentation of this file.
27 #ifndef _PCAP_GSOURCE_H
28 #define _PCAP_GSOURCE_H
29 #include <projectcommon.h>
30 #include <glib.h>
31 #include <pcap_min.h>
32 #include <frameset.h>
38 struct _GSource_pcap {
39  GSource gs;
40  GPollFD gfd;
41  pcap_t* capture;
42  struct bpf_program pcprog;
43  int capturefd;
44  char* capturedev;
45  unsigned listenmask;
46  gint gsourceid;
47  gpointer userdata;
48  gboolean (*dispatch)(GSource_pcap_t* gsource,
50  pcap_t* capstruct,
51  gconstpointer pkt,
52  gconstpointer pend,
53  const struct pcap_pkthdr* pkthdr,
54  const char * capturedev,
55  gpointer userdata);
56  GDestroyNotify destroynote;
58 };
60 WINEXPORT GSource* g_source_pcap_new(const char * dev,
61  unsigned listenmask,
62  gboolean (*dispatch)
63  (GSource_pcap_t* gsource,
64  pcap_t* capstruct,
65  gconstpointer pkt,
66  gconstpointer pend,
67  const struct pcap_pkthdr* pkthdr,
68  const char * capturedev,
69  gpointer userdata
70  ),
71  GDestroyNotify notify,
72  gint priority,
73  gboolean can_recurse,
74  GMainContext* context,
75  gsize objectsize,
76  gpointer userdata
77  );
78 WINEXPORT void g_source_pcap_finalize(GSource* src); // Here to work around some Glib bugs/misunderstandings...
79 WINEXPORT FrameSet* construct_pcap_frameset(guint16 framesettype, gconstpointer pkt, gconstpointer pktend,
80  const struct pcap_pkthdr* pkthdr, const char * interfacep,
81  const char * instancename);
82 #endif /* _PCAP_GSOURCE_H */
unsigned listenmask
Protocols selected from Protocols known to (supported by) create_pcap_listener()..
Definition: pcap_GSource.h:45
gpointer userdata
Saved user data.
Definition: pcap_GSource.h:47
int capturefd
Underlying file descriptor.
Definition: pcap_GSource.h:43
gint gsourceid
Source ID from g_source_attach()
Definition: pcap_GSource.h:46
Implements minimal client-oriented Frame and Frameset capabilities.
WINEXPORT GSource * g_source_pcap_new(const char *dev, unsigned listenmask, gboolean(*dispatch)(GSource_pcap_t *gsource, pcap_t *capstruct, gconstpointer pkt, gconstpointer pend, const struct pcap_pkthdr *pkthdr, const char *capturedev, gpointer userdata), GDestroyNotify notify, gint priority, gboolean can_recurse, GMainContext *context, gsize objectsize, gpointer userdata)
Construct new GSource from a newly constructed pcap capture object.
Definition: pcap_GSource.c:86
Simple libpcap interface definitions.
GSource gs
Parent GSource Object.
Definition: pcap_GSource.h:39
Definition: projectcommon.h:45
GPollFD gfd
Poll/select object for gmainloop.
Definition: pcap_GSource.h:40
Project common header file.
g_main_loop GSource object for creating events from libpcap (pcap_t) objects We manage this with our ...
Definition: pcap_GSource.h:38
WINEXPORT void g_source_pcap_finalize(GSource *src)
The GMainLoop finalize function for libpcap packet capturing Called when this object is &#39;finalized&#39; (...
Definition: pcap_GSource.c:212
GDestroyNotify destroynote
[in] function to call when we&#39;re destroyed...
Definition: pcap_GSource.h:57
WINEXPORT FrameSet * construct_pcap_frameset(guint16 framesettype, gconstpointer pkt, gconstpointer pktend, const struct pcap_pkthdr *pkthdr, const char *interfacep, const char *instancename)
Construct a PCAP capture FrameSet from a PCAP packet.
Definition: pcap_GSource.c:240
pcap_t * capture
Pcap capture object.
Definition: pcap_GSource.h:41
FrameSet class - used for collecting Frames when not on the wire, and for marshalling/demarshalling t...
Definition: frameset.h:46
char * capturedev
Capture device name.
Definition: pcap_GSource.h:44
struct bpf_program pcprog
Pcap program.
Definition: pcap_GSource.h:42
gboolean(* dispatch)(GSource_pcap_t *gsource, pcap_t *capstruct, gconstpointer pkt, gconstpointer pend, const struct pcap_pkthdr *pkthdr, const char *capturedev, gpointer userdata)
[in] user dispatch function - we call it when a packet is read
Definition: pcap_GSource.h:49