The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pcap_GSource.c File Reference

libpcap Packet capture Gsource module. More...

#include <memory.h>
#include <projectcommon.h>
#include <proj_classes.h>
#include <pcap_min.h>
#include <pcap_GSource.h>
#include <intframe.h>
#include <addrframe.h>
#include <cstringframe.h>
#include <frametypes.h>
#include <misc.h>
Include dependency graph for pcap_GSource.c:

Go to the source code of this file.

Functions

FSTATIC gboolean g_source_pcap_prepare (GSource *source,gint *timeout)
 The GMainLoop prepare function for libpcap packet capturing. More...
 
FSTATIC gboolean g_source_pcap_check (GSource *src)
 The GMainLoop check function for libpcap packet capturing. More...
 
FSTATIC gboolean g_source_pcap_dispatch (GSource *src,GSourceFunc callback,gpointer user_data)
 The GMainLoop dispatch function for libpcap packet capturing. More...
 
FSTATIC void g_source_pcap_finalize (GSource *src)
 The GMainLoop finalize function for libpcap packet capturing Called when this object is 'finalized' (destroyed) More...
 
FSTATIC guint64 proj_timeval_to_g_real_time (const struct timeval *tv)
 Convert struct timeval to g_get_real_time() style value. More...
 
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. More...
 
FrameSetconstruct_pcap_frameset (guint16 framesettype, gconstpointer pkt, gconstpointer pktend, const struct pcap_pkthdr *pkthdr, const char *interfacep)
 Construct a PCAP capture FrameSet from a PCAP packet. More...
 

Detailed Description

libpcap Packet capture Gsource module.

This code is based on (and meets the API expectations of) the the Glib main event loop (g_main_loop) event scheduler/dispatcher concept. We set things up so that when a libpcap packet arrives that we get invoked. It's a little complicated to set up, but really pretty nice, and quite easy to use once set up. The main function defined in this file is g_source_pcap_new(). We supply four key functions in order to meet the Glib main event loop API:

The main types we use from Glib are:

This file is part of the Assimilation Project.

Author
Copyright © 2011, 2012 - Alan Robertson alanr.nosp@m.@uni.nosp@m.x.sh
The Assimilation software is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Assimilation software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/

Definition in file pcap_GSource.c.