/* Generated by Pyrex 0.9.6.2 on Sun Jan 13 18:15:46 2008 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
#define PY_LONG_LONG LONG_LONG
#endif
#if PY_VERSION_HEX < 0x02050000
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
#define PyInt_AsSsize_t(o) PyInt_AsLong(o)
#endif
#ifndef WIN32
#define __stdcall
#define __cdecl
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#include "pcap.h"
#include "pcap_ex.h"
typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static int __pyx_lineno;
static char *__pyx_filename;
static char **__pyx_f;
static char __pyx_mdoc[] = "packet capture library\n\nThis module provides a high level interface to packet capture systems.\nAll packets on the network, even those destined for other hosts, are\naccessible through this mechanism.\n";
static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_WriteUnraisable(char *name); /*proto*/
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
static void __Pyx_AddTraceback(char *funcname); /*proto*/
/* Declarations from pcap */
typedef void (*__pyx_t_4pcap_pcap_handler)(void *,struct pcap_pkthdr *,char *);
struct __pyx_t_4pcap_pcap_handler_ctx {
void *callback;
void *args;
int got_exc;
};
struct __pyx_obj_4pcap_bpf {
PyObject_HEAD
struct bpf_program fcode;
};
struct __pyx_obj_4pcap_pcap {
PyObject_HEAD
pcap_t *__pcap;
char *__name;
char *__filter;
char __ebuf[256];
int __dloff;
pcap_dumper_t *__dumper;
};
static PyTypeObject *__pyx_ptype_4pcap_bpf = 0;
static PyTypeObject *__pyx_ptype_4pcap_pcap = 0;
static PyObject *__pyx_k17;
static PyObject *__pyx_k18;
static PyObject *__pyx_k19;
static PyObject *__pyx_k20;
static PyObject *__pyx_k21;
static PyObject *__pyx_k22;
static PyObject *__pyx_k24;
static PyObject *__pyx_k25;
static PyObject *__pyx_k26;
static PyObject *__pyx_k27;
static PyObject *__pyx_k28;
static void __pyx_f_4pcap___pcap_handler(void *,struct pcap_pkthdr *,char *); /*proto*/
/* Implementation of pcap */
static char __pyx_k1[] = "Network interface or dumpfile name.";
static char __pyx_k2[] = "Maximum number of bytes to capture for each packet.";
static char __pyx_k3[] = "Datalink offset (length of layer-2 frame header).";
static char __pyx_k4[] = "Current packet capture filter.";
static char __pyx_k5[] = "File descriptor (or Win32 HANDLE) for capture handle.";
static char __pyx_k6[] = "Dug Song <dugsong@monkey.org>";
static char __pyx_k7[] = "George Neville-Neil <gnn@neville-neil.com>";
static char __pyx_k8[] = "Copyright (c) 2004 Dug Song";
static char __pyx_k9[] = "BSD license";
static char __pyx_k10[] = "http://pcs.sf.net";
static char __pyx_k11[] = "1.1";
static char __pyx_k12[] = "2";
static char __pyx_k23[] = "";
static PyObject *__pyx_n___author__;
static PyObject *__pyx_n___maintainer__;
static PyObject *__pyx_n___copyright__;
static PyObject *__pyx_n___license__;
static PyObject *__pyx_n___url__;
static PyObject *__pyx_n___version__;
static PyObject *__pyx_n___revison__;
static PyObject *__pyx_n_sys;
static PyObject *__pyx_n_calendar;
static PyObject *__pyx_n_time;
static PyObject *__pyx_n_DLT_NULL;
static PyObject *__pyx_n_DLT_EN10MB;
static PyObject *__pyx_n_DLT_EN3MB;
static PyObject *__pyx_n_DLT_AX25;
static PyObject *__pyx_n_DLT_PRONET;
static PyObject *__pyx_n_DLT_CHAOS;
static PyObject *__pyx_n_DLT_IEEE802;
static PyObject *__pyx_n_DLT_ARCNET;
static PyObject *__pyx_n_DLT_SLIP;
static PyObject *__pyx_n_DLT_PPP;
static PyObject *__pyx_n_DLT_FDDI;
static PyObject *__pyx_n_DLT_LINUX_SLL;
static PyObject *__pyx_n_DLT_PFLOG;
static PyObject *__pyx_n_DLT_PFSYNC;
static PyObject *__pyx_n_platform;
static PyObject *__pyx_n_find;
static PyObject *__pyx_n_openbsd;
static PyObject *__pyx_n_DLT_LOOP;
static PyObject *__pyx_n_DLT_RAW;
static PyObject *__pyx_n_dltoff;
static PyObject *__pyx_n_True;
static PyObject *__pyx_n_False;
static PyObject *__pyx_k6p;
static PyObject *__pyx_k7p;
static PyObject *__pyx_k8p;
static PyObject *__pyx_k9p;
static PyObject *__pyx_k10p;
static PyObject *__pyx_k11p;
static PyObject *__pyx_k12p;
static PyObject *__pyx_k23p;
static void __pyx_f_4pcap___pcap_handler(void *__pyx_v_arg,struct pcap_pkthdr *__pyx_v_hdr,char *__pyx_v_pkt) {
struct __pyx_t_4pcap_pcap_handler_ctx *__pyx_v_ctx;
int __pyx_v_gil;
PyObject *__pyx_1 = 0;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":104 */
__pyx_v_ctx = ((struct __pyx_t_4pcap_pcap_handler_ctx *)__pyx_v_arg);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":105 */
__pyx_v_gil = PyGILState_Ensure();
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":106 */
/*try:*/ {
__pyx_1 = (PyObject *)__pyx_v_ctx->callback;
Py_INCREF(__pyx_1);
__pyx_2 = PyFloat_FromDouble((__pyx_v_hdr->ts.tv_sec + (__pyx_v_hdr->ts.tv_usec / 1000000.0))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L2;}
__pyx_3 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L2;}
__pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L2;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
__pyx_2 = 0;
__pyx_3 = 0;
__pyx_2 = (PyObject *)__pyx_v_ctx->args;
Py_INCREF(__pyx_2);
__pyx_3 = PySequence_Tuple(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L2;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_2 = PyNumber_Add(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L2;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L2;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
}
goto __pyx_L3;
__pyx_L2:;
Py_XDECREF(__pyx_3); __pyx_3 = 0;
Py_XDECREF(__pyx_1); __pyx_1 = 0;
Py_XDECREF(__pyx_2); __pyx_2 = 0;
Py_XDECREF(__pyx_4); __pyx_4 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":110 */
/*except:*/ {
__Pyx_AddTraceback("pcap.__pcap_handler");
if (__Pyx_GetException(&__pyx_3, &__pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;}
__pyx_v_ctx->got_exc = 1;
Py_DECREF(__pyx_3);
Py_DECREF(__pyx_1);
Py_DECREF(__pyx_2);
goto __pyx_L3;
}
__pyx_L3:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":112 */
PyGILState_Release(__pyx_v_gil);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
__Pyx_WriteUnraisable("pcap.__pcap_handler");
__pyx_L0:;
}
static PyObject *__pyx_n_IOError;
static PyObject *__pyx_k29p;
static char __pyx_k29[] = "bad filter";
static int __pyx_f_4pcap_3bpf___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_4pcap_3bpf___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
char *__pyx_v_filter;
PyObject *__pyx_v_dlt = 0;
int __pyx_r;
int __pyx_1;
int __pyx_2;
PyObject *__pyx_3 = 0;
static char *__pyx_argnames[] = {"filter","dlt",0};
__pyx_v_dlt = __pyx_k17;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "s|O", __pyx_argnames, &__pyx_v_filter, &__pyx_v_dlt)) return -1;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_dlt);
__pyx_1 = PyInt_AsLong(__pyx_v_dlt); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}
__pyx_2 = (pcap_ex_compile_nopcap(65535,__pyx_1,(&((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode),__pyx_v_filter,1,0) < 0);
if (__pyx_2) {
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_IOError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; goto __pyx_L1;}
__Pyx_Raise(__pyx_3, __pyx_k29p, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_3);
__Pyx_AddTraceback("pcap.bpf.__init__");
__pyx_r = -1;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_dlt);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_3bpf_filter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_3bpf_filter[] = "Return boolean match for buf against our filter.";
static PyObject *__pyx_f_4pcap_3bpf_filter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_buf = 0;
int __pyx_v_n;
PyObject *__pyx_r;
char *__pyx_1;
int __pyx_2;
PyObject *__pyx_3 = 0;
static char *__pyx_argnames[] = {"buf",0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_buf)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_buf);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":150 */
__pyx_v_n = PyObject_Length(__pyx_v_buf);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":151 */
__pyx_1 = PyString_AsString(__pyx_v_buf); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;}
__pyx_2 = (bpf_filter(((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode.bf_insns,__pyx_1,__pyx_v_n,__pyx_v_n) == 0);
if (__pyx_2) {
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L1;}
__pyx_r = __pyx_3;
__pyx_3 = 0;
goto __pyx_L0;
goto __pyx_L2;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":153 */
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; goto __pyx_L1;}
__pyx_r = __pyx_3;
__pyx_3 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_3);
__Pyx_AddTraceback("pcap.bpf.filter");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_buf);
return __pyx_r;
}
static void __pyx_f_4pcap_3bpf___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_4pcap_3bpf___dealloc__(PyObject *__pyx_v_self) {
Py_INCREF(__pyx_v_self);
pcap_freecode((&((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode));
Py_DECREF(__pyx_v_self);
}
static PyObject *__pyx_n_OSError;
static PyObject *__pyx_n_KeyError;
static PyObject *__pyx_k30p;
static PyObject *__pyx_k31p;
static PyObject *__pyx_k33p;
static char __pyx_k30[] = "Internal error pcap_open_dead.";
static char __pyx_k31[] = "";
static char __pyx_k32[] = "";
static char __pyx_k33[] = "couldn't set BPF immediate mode";
static int __pyx_f_4pcap_4pcap___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_4pcap_4pcap___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_name = 0;
PyObject *__pyx_v_snaplen = 0;
PyObject *__pyx_v_promisc = 0;
PyObject *__pyx_v_timeout_ms = 0;
PyObject *__pyx_v_immediate = 0;
PyObject *__pyx_v_dumpfile = 0;
PyObject *__pyx_v_dumptype = 0;
char *__pyx_v_p;
int __pyx_r;
int __pyx_1;
int __pyx_2;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
PyObject *__pyx_6 = 0;
char *__pyx_7;
int __pyx_8;
static char *__pyx_argnames[] = {"name","snaplen","promisc","timeout_ms","immediate","dumpfile","dumptype",0};
__pyx_v_name = __pyx_k18;
__pyx_v_snaplen = __pyx_k19;
__pyx_v_promisc = __pyx_k20;
__pyx_v_timeout_ms = __pyx_k21;
__pyx_v_immediate = __pyx_k22;
__pyx_v_dumpfile = __pyx_k24;
__pyx_v_dumptype = __pyx_k25;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOOOOOO", __pyx_argnames, &__pyx_v_name, &__pyx_v_snaplen, &__pyx_v_promisc, &__pyx_v_timeout_ms, &__pyx_v_immediate, &__pyx_v_dumpfile, &__pyx_v_dumptype)) return -1;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_name);
Py_INCREF(__pyx_v_snaplen);
Py_INCREF(__pyx_v_promisc);
Py_INCREF(__pyx_v_timeout_ms);
Py_INCREF(__pyx_v_immediate);
Py_INCREF(__pyx_v_dumpfile);
Py_INCREF(__pyx_v_dumptype);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":184 */
if (PyObject_Cmp(__pyx_v_dumptype, Py_None, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L1;}
__pyx_1 = __pyx_1 != 0;
if (__pyx_1) {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":185 */
/*try:*/ {
__pyx_1 = PyInt_AsLong(__pyx_v_dumptype); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L3;}
__pyx_2 = PyInt_AsLong(__pyx_v_snaplen); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L3;}
((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap = pcap_open_dead(__pyx_1,__pyx_2);
}
goto __pyx_L4;
__pyx_L3:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":187 */
/*except:*/ {
__Pyx_AddTraceback("pcap.__init__");
if (__Pyx_GetException(&__pyx_3, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;}
__pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;}
__Pyx_Raise(__pyx_6, __pyx_k30p, 0);
Py_DECREF(__pyx_6); __pyx_6 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;}
Py_DECREF(__pyx_3);
Py_DECREF(__pyx_4);
Py_DECREF(__pyx_5);
goto __pyx_L4;
}
__pyx_L4:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":189 */
__pyx_7 = PyString_AsString(__pyx_v_dumpfile); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;}
__pyx_v_p = __pyx_7;
goto __pyx_L2;
}
/*else*/ {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":191 */
__pyx_1 = PyObject_IsTrue(__pyx_v_name); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}
__pyx_2 = (!__pyx_1);
if (__pyx_2) {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":192 */
__pyx_v_p = pcap_ex_lookupdev(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":193 */
__pyx_1 = (__pyx_v_p == NULL);
if (__pyx_1) {
__pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;}
__pyx_3 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;}
__Pyx_Raise(__pyx_6, __pyx_3, 0);
Py_DECREF(__pyx_6); __pyx_6 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
goto __pyx_L5;
}
/*else*/ {
__pyx_7 = PyString_AsString(__pyx_v_name); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; goto __pyx_L1;}
__pyx_v_p = __pyx_7;
}
__pyx_L5:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":198 */
((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap = pcap_open_offline(__pyx_v_p,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":200 */
__pyx_2 = (!(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap != 0));
if (__pyx_2) {
__pyx_1 = PyInt_AsLong(__pyx_v_snaplen); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; goto __pyx_L1;}
__pyx_2 = PyInt_AsLong(__pyx_v_promisc); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L1;}
__pyx_8 = PyInt_AsLong(__pyx_v_timeout_ms); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L1;}
((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap = pcap_open_live(pcap_ex_name(__pyx_v_p),__pyx_1,__pyx_2,__pyx_8,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);
goto __pyx_L7;
}
__pyx_L7:;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":205 */
__pyx_1 = (!(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap != 0));
if (__pyx_1) {
__pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;}
__pyx_5 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;}
__Pyx_Raise(__pyx_4, __pyx_5, 0);
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;}
goto __pyx_L8;
}
__pyx_L8:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":208 */
if (PyObject_Cmp(__pyx_v_dumpfile, __pyx_k31p, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
__pyx_2 = __pyx_2 != 0;
if (__pyx_2) {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":209 */
__pyx_7 = PyString_AsString(__pyx_v_dumpfile); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}
((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__dumper = pcap_dump_open(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_7);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":210 */
__pyx_8 = (!(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__dumper != 0));
if (__pyx_8) {
__pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
__pyx_3 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
__Pyx_Raise(__pyx_6, __pyx_3, 0);
Py_DECREF(__pyx_6); __pyx_6 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
goto __pyx_L10;
}
__pyx_L10:;
goto __pyx_L9;
}
__pyx_L9:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":213 */
((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__name = strdup(__pyx_v_p);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":214 */
((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter = strdup(__pyx_k32);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":215 */
/*try:*/ {
__pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_dltoff); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L11;}
__pyx_5 = PyInt_FromLong(pcap_datalink(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L11;}
__pyx_6 = PyObject_GetItem(__pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L11;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
__pyx_1 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L11;}
Py_DECREF(__pyx_6); __pyx_6 = 0;
((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__dloff = __pyx_1;
}
goto __pyx_L12;
__pyx_L11:;
Py_XDECREF(__pyx_3); __pyx_3 = 0;
Py_XDECREF(__pyx_4); __pyx_4 = 0;
Py_XDECREF(__pyx_5); __pyx_5 = 0;
Py_XDECREF(__pyx_6); __pyx_6 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":216 */
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_KeyError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;}
__pyx_2 = PyErr_ExceptionMatches(__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_2) {
__Pyx_AddTraceback("pcap.__init__");
if (__Pyx_GetException(&__pyx_4, &__pyx_5, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;}
Py_DECREF(__pyx_4);
Py_DECREF(__pyx_5);
Py_DECREF(__pyx_6);
goto __pyx_L12;
}
goto __pyx_L1;
__pyx_L12:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":217 */
__pyx_3 = __pyx_v_immediate;
Py_INCREF(__pyx_3);
__pyx_8 = PyObject_IsTrue(__pyx_3); if (__pyx_8 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
if (__pyx_8) {
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_3 = PyInt_FromLong((pcap_ex_immediate(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap) < 0)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
}
__pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
__pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;}
__Pyx_Raise(__pyx_4, __pyx_k33p, 0);
Py_DECREF(__pyx_4); __pyx_4 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;}
goto __pyx_L13;
}
__pyx_L13:;
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
Py_XDECREF(__pyx_5);
Py_XDECREF(__pyx_6);
__Pyx_AddTraceback("pcap.pcap.__init__");
__pyx_r = -1;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_name);
Py_DECREF(__pyx_v_snaplen);
Py_DECREF(__pyx_v_promisc);
Py_DECREF(__pyx_v_timeout_ms);
Py_DECREF(__pyx_v_immediate);
Py_DECREF(__pyx_v_dumpfile);
Py_DECREF(__pyx_v_dumptype);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_4name___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap_4name___get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
Py_INCREF(__pyx_v_self);
__pyx_1 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__name); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
__Pyx_AddTraceback("pcap.pcap.name.__get__");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_7snaplen___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap_7snaplen___get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
Py_INCREF(__pyx_v_self);
__pyx_1 = PyInt_FromLong(pcap_snapshot(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
__Pyx_AddTraceback("pcap.pcap.snaplen.__get__");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_5dloff___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap_5dloff___get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
Py_INCREF(__pyx_v_self);
__pyx_1 = PyInt_FromLong(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__dloff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
__Pyx_AddTraceback("pcap.pcap.dloff.__get__");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_6filter___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap_6filter___get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
Py_INCREF(__pyx_v_self);
__pyx_1 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
__Pyx_AddTraceback("pcap.pcap.filter.__get__");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_2fd___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap_2fd___get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
Py_INCREF(__pyx_v_self);
__pyx_1 = PyInt_FromLong(pcap_ex_fileno(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
__Pyx_AddTraceback("pcap.pcap.fd.__get__");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_fileno(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_fileno[] = "Return file descriptor (or Win32 HANDLE) for capture handle.";
static PyObject *__pyx_f_4pcap_4pcap_fileno(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
__pyx_1 = PyInt_FromLong(pcap_ex_fileno(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
__Pyx_AddTraceback("pcap.pcap.fileno");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_setfilter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_setfilter[] = "Set BPF-format packet capture filter.";
static PyObject *__pyx_f_4pcap_4pcap_setfilter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_value = 0;
PyObject *__pyx_v_optimize = 0;
struct bpf_program __pyx_v_fcode;
PyObject *__pyx_r;
char *__pyx_1;
int __pyx_2;
int __pyx_3;
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"value","optimize",0};
__pyx_v_optimize = __pyx_k26;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_value, &__pyx_v_optimize)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_value);
Py_INCREF(__pyx_v_optimize);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":252 */
free(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":253 */
__pyx_1 = PyString_AsString(__pyx_v_value); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;}
((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter = strdup(__pyx_1);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":254 */
__pyx_2 = PyInt_AsLong(__pyx_v_optimize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;}
__pyx_3 = (pcap_compile(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_fcode),((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter,__pyx_2,0) < 0);
if (__pyx_3) {
__pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}
__pyx_5 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}
__Pyx_Raise(__pyx_4, __pyx_5, 0);
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":256 */
__pyx_2 = (pcap_setfilter(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_fcode)) < 0);
if (__pyx_2) {
__pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;}
__pyx_5 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;}
__Pyx_Raise(__pyx_4, __pyx_5, 0);
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":258 */
pcap_freecode((&__pyx_v_fcode));
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_4);
Py_XDECREF(__pyx_5);
__Pyx_AddTraceback("pcap.pcap.setfilter");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_value);
Py_DECREF(__pyx_v_optimize);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_setnonblock(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_setnonblock[] = "Set non-blocking capture mode.";
static PyObject *__pyx_f_4pcap_4pcap_setnonblock(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_nonblock = 0;
PyObject *__pyx_r;
int __pyx_1;
static char *__pyx_argnames[] = {"nonblock",0};
__pyx_v_nonblock = __pyx_k27;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_nonblock)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_nonblock);
__pyx_1 = PyInt_AsLong(__pyx_v_nonblock); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; goto __pyx_L1;}
pcap_ex_setnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
__Pyx_AddTraceback("pcap.pcap.setnonblock");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_nonblock);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_getnonblock(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_getnonblock[] = "Return non-blocking capture mode as boolean.";
static PyObject *__pyx_f_4pcap_4pcap_getnonblock(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_ret;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
int __pyx_2;
PyObject *__pyx_3 = 0;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
__pyx_v_ret = Py_None; Py_INCREF(Py_None);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":266 */
__pyx_1 = PyInt_FromLong(pcap_ex_getnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}
Py_DECREF(__pyx_v_ret);
__pyx_v_ret = __pyx_1;
__pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":267 */
__pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;}
if (PyObject_Cmp(__pyx_v_ret, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;}
__pyx_2 = __pyx_2 < 0;
Py_DECREF(__pyx_1); __pyx_1 = 0;
if (__pyx_2) {
__pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;}
__pyx_3 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;}
__Pyx_Raise(__pyx_1, __pyx_3, 0);
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_2 = PyObject_IsTrue(__pyx_v_ret); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; goto __pyx_L1;}
if (__pyx_2) {
__pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
goto __pyx_L2;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":271 */
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; goto __pyx_L1;}
__pyx_r = __pyx_3;
__pyx_3 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
Py_XDECREF(__pyx_3);
__Pyx_AddTraceback("pcap.pcap.getnonblock");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_ret);
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_datalink(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_datalink[] = "Return datalink type (DLT_* values).";
static PyObject *__pyx_f_4pcap_4pcap_datalink(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
__pyx_1 = PyInt_FromLong(pcap_datalink(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
__Pyx_AddTraceback("pcap.pcap.datalink");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_next(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_next[] = "Return the next (timestamp, packet) tuple, or None on error.";
static PyObject *__pyx_f_4pcap_4pcap_next(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
struct pcap_pkthdr __pyx_v_hdr;
char *__pyx_v_pkt;
PyObject *__pyx_r;
int __pyx_1;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":281 */
__pyx_v_pkt = ((char *)pcap_next(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_hdr)));
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":282 */
__pyx_1 = (!(__pyx_v_pkt != 0));
if (__pyx_1) {
Py_INCREF(Py_None);
__pyx_r = Py_None;
goto __pyx_L0;
goto __pyx_L2;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":284 */
__pyx_2 = PyFloat_FromDouble((__pyx_v_hdr.ts.tv_sec + (__pyx_v_hdr.ts.tv_usec / 1000000.0))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}
__pyx_3 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr.caplen); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;}
__pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
__pyx_2 = 0;
__pyx_3 = 0;
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
__Pyx_AddTraceback("pcap.pcap.next");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_n_append;
static PyObject *__pyx_f_4pcap_4pcap___add_pkts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap___add_pkts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_ts = 0;
PyObject *__pyx_v_pkt = 0;
PyObject *__pyx_v_pkts = 0;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
static char *__pyx_argnames[] = {"ts","pkt","pkts",0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_ts, &__pyx_v_pkt, &__pyx_v_pkts)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_ts);
Py_INCREF(__pyx_v_pkt);
Py_INCREF(__pyx_v_pkts);
__pyx_1 = PyObject_GetAttr(__pyx_v_pkts, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
__pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
Py_INCREF(__pyx_v_ts);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_ts);
Py_INCREF(__pyx_v_pkt);
PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_pkt);
__pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
__pyx_2 = 0;
__pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_3);
__Pyx_AddTraceback("pcap.pcap.__add_pkts");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_ts);
Py_DECREF(__pyx_v_pkt);
Py_DECREF(__pyx_v_pkts);
return __pyx_r;
}
static PyObject *__pyx_n_dispatch;
static PyObject *__pyx_n___add_pkts;
static PyObject *__pyx_f_4pcap_4pcap_readpkts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_readpkts[] = "Return a list of (timestamp, packet) tuples received in one buffer.";
static PyObject *__pyx_f_4pcap_4pcap_readpkts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_pkts;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
__pyx_v_pkts = Py_None; Py_INCREF(Py_None);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":292 */
__pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
Py_DECREF(__pyx_v_pkts);
__pyx_v_pkts = __pyx_1;
__pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":293 */
__pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_dispatch); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n___add_pkts); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
__pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
Py_INCREF(__pyx_v_pkts);
PyTuple_SET_ITEM(__pyx_4, 2, __pyx_v_pkts);
__pyx_2 = 0;
__pyx_3 = 0;
__pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":294 */
Py_INCREF(__pyx_v_pkts);
__pyx_r = __pyx_v_pkts;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
__Pyx_AddTraceback("pcap.pcap.readpkts");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_pkts);
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_n_exc_info;
static PyObject *__pyx_f_4pcap_4pcap_dispatch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_dispatch[] = "Collect and process packets with a user callback,\n return the number of packets processed, or 0 for a savefile.\n \n Arguments:\n \n cnt -- number of packets to process;\n or 0 to process all packets until an error occurs,\n EOF is reached, or the read times out;\n or -1 to process all packets received in one buffer\n callback -- function with (timestamp, pkt, *args) prototype\n *args -- optional arguments passed to callback on execution\n ";
static PyObject *__pyx_f_4pcap_4pcap_dispatch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_cnt = 0;
PyObject *__pyx_v_callback = 0;
PyObject *__pyx_v_args = 0;
struct __pyx_t_4pcap_pcap_handler_ctx __pyx_v_ctx;
int __pyx_v_n;
PyObject *__pyx_v_exc;
PyObject *__pyx_r;
int __pyx_1;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"cnt","callback",0};
if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 2, &__pyx_v_args, 0, 0) < 0) return 0;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cnt, &__pyx_v_callback)) {
Py_XDECREF(__pyx_args);
Py_XDECREF(__pyx_kwds);
Py_XDECREF(__pyx_v_args);
return 0;
}
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_cnt);
Py_INCREF(__pyx_v_callback);
__pyx_v_exc = Py_None; Py_INCREF(Py_None);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":312 */
__pyx_v_ctx.callback = ((void *)__pyx_v_callback);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":313 */
__pyx_v_ctx.args = ((void *)__pyx_v_args);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":314 */
__pyx_v_ctx.got_exc = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":315 */
__pyx_1 = PyInt_AsLong(__pyx_v_cnt); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;}
__pyx_v_n = pcap_dispatch(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,__pyx_f_4pcap___pcap_handler,((unsigned char *)(&__pyx_v_ctx)));
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":317 */
__pyx_1 = __pyx_v_ctx.got_exc;
if (__pyx_1) {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":318 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_exc_info); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_v_exc);
__pyx_v_exc = __pyx_2;
__pyx_2 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":319 */
__pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}
__pyx_2 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}
__pyx_4 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}
__pyx_5 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, __pyx_4, __pyx_5);
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":320 */
__pyx_3 = PyInt_FromLong(__pyx_v_n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; goto __pyx_L1;}
__pyx_r = __pyx_3;
__pyx_3 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
Py_XDECREF(__pyx_5);
__Pyx_AddTraceback("pcap.pcap.dispatch");
__pyx_r = 0;
__pyx_L0:;
Py_XDECREF(__pyx_v_args);
Py_DECREF(__pyx_v_exc);
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_cnt);
Py_DECREF(__pyx_v_callback);
Py_XDECREF(__pyx_args);
Py_XDECREF(__pyx_kwds);
return __pyx_r;
}
static PyObject *__pyx_n_KeyboardInterrupt;
static PyObject *__pyx_f_4pcap_4pcap_loop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_loop[] = "Loop forever, processing packets with a user callback.\n The loop can be exited with an exception, including KeyboardInterrupt.\n \n Arguments:\n\n callback -- function with (timestamp, pkt, *args) prototype\n *args -- optional arguments passed to callback on execution\n ";
static PyObject *__pyx_f_4pcap_4pcap_loop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_callback = 0;
PyObject *__pyx_v_args = 0;
struct pcap_pkthdr *__pyx_v_hdr;
char *__pyx_v_pkt;
int __pyx_v_n;
PyObject *__pyx_r;
long __pyx_1;
int __pyx_2;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"callback",0};
if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 1, &__pyx_v_args, 0, 0) < 0) return 0;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_callback)) {
Py_XDECREF(__pyx_args);
Py_XDECREF(__pyx_kwds);
Py_XDECREF(__pyx_v_args);
return 0;
}
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_callback);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":334 */
pcap_ex_setup(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":335 */
while (1) {
__pyx_1 = 1;
if (!__pyx_1) break;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":336 */
Py_BEGIN_ALLOW_THREADS;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":337 */
__pyx_v_n = pcap_ex_next(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_hdr),(&__pyx_v_pkt));
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":338 */
Py_END_ALLOW_THREADS;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":339 */
__pyx_2 = (__pyx_v_n == 1);
if (__pyx_2) {
__pyx_3 = PyFloat_FromDouble((__pyx_v_hdr->ts.tv_sec + (__pyx_v_hdr->ts.tv_usec / 1000000.0))); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
__pyx_4 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}
__pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
__pyx_3 = 0;
__pyx_4 = 0;
__pyx_3 = PySequence_Tuple(__pyx_v_args); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
__pyx_4 = PyNumber_Add(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_5 = PyObject_CallObject(__pyx_v_callback, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
goto __pyx_L4;
}
__pyx_2 = (__pyx_v_n == (-1));
if (__pyx_2) {
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_KeyboardInterrupt); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_2 = (__pyx_v_n == (-2));
if (__pyx_2) {
goto __pyx_L3;
goto __pyx_L4;
}
__pyx_L4:;
}
__pyx_L3:;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
Py_XDECREF(__pyx_5);
__Pyx_AddTraceback("pcap.pcap.loop");
__pyx_r = 0;
__pyx_L0:;
Py_XDECREF(__pyx_v_args);
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_callback);
Py_XDECREF(__pyx_args);
Py_XDECREF(__pyx_kwds);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_inject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_inject[] = "Inject a packet onto an interface.\n May or may not work depending on platform.\n\n Arguments:\n\n packet -- a pointer to the packet in memory\n ";
static PyObject *__pyx_f_4pcap_4pcap_inject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_packet = 0;
PyObject *__pyx_v_len = 0;
int __pyx_v_n;
PyObject *__pyx_r;
char *__pyx_1;
int __pyx_2;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
static char *__pyx_argnames[] = {"packet","len",0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_packet, &__pyx_v_len)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_packet);
Py_INCREF(__pyx_v_len);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":356 */
__pyx_1 = PyString_AsString(__pyx_v_packet); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;}
__pyx_2 = PyInt_AsLong(__pyx_v_len); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;}
__pyx_v_n = pcap_inject(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,__pyx_2);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":357 */
__pyx_2 = (__pyx_v_n < 0);
if (__pyx_2) {
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}
__pyx_4 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}
__Pyx_Raise(__pyx_3, __pyx_4, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":360 */
__pyx_3 = PyInt_FromLong(__pyx_v_n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;}
__pyx_r = __pyx_3;
__pyx_3 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
__Pyx_AddTraceback("pcap.pcap.inject");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_packet);
Py_DECREF(__pyx_v_len);
return __pyx_r;
}
static PyObject *__pyx_n_sec;
static PyObject *__pyx_n_usec;
static PyObject *__pyx_n_caplen;
static PyObject *__pyx_n_timegm;
static PyObject *__pyx_n_gmtime;
static PyObject *__pyx_f_4pcap_4pcap_dump(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_dump[] = "Dump a packet to a previously opened save file.\n\n Arguments:\n\n packet -- the packet\n header -- a pcap header provided by the caller\n A user supplied header MUST contain the following fields\n header.sec: The timestamp in seconds from the Unix epoch\n header.usec: The timestamp in micro seconds\n header.caplen: Length of packet present\n header.len: Total length of packet\n ";
static PyObject *__pyx_f_4pcap_4pcap_dump(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_packet = 0;
PyObject *__pyx_v_header = 0;
struct pcap_pkthdr __pyx_v_hdr;
PyObject *__pyx_r;
int __pyx_1;
PyObject *__pyx_2 = 0;
unsigned int __pyx_3;
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
char *__pyx_6;
static char *__pyx_argnames[] = {"packet","header",0};
__pyx_v_header = __pyx_k28;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_packet, &__pyx_v_header)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_packet);
Py_INCREF(__pyx_v_header);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":376 */
if (PyObject_Cmp(__pyx_v_header, Py_None, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;}
__pyx_1 = __pyx_1 != 0;
if (__pyx_1) {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":377 */
__pyx_2 = PyObject_GetAttr(__pyx_v_header, __pyx_n_sec); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; goto __pyx_L1;}
__pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_v_hdr.ts.tv_sec = __pyx_3;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":378 */
__pyx_2 = PyObject_GetAttr(__pyx_v_header, __pyx_n_usec); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}
__pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_v_hdr.ts.tv_usec = __pyx_3;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":379 */
__pyx_2 = PyObject_GetAttr(__pyx_v_header, __pyx_n_caplen); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;}
__pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_v_hdr.caplen = __pyx_3;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":380 */
__pyx_v_hdr.len = PyObject_Length(__pyx_v_packet);
goto __pyx_L2;
}
/*else*/ {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":382 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_calendar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
__pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_timegm); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_time); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
__pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_gmtime); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_2 = PyObject_CallObject(__pyx_5, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
__pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
__pyx_2 = 0;
__pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
__pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_v_hdr.ts.tv_sec = __pyx_3;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":383 */
__pyx_v_hdr.ts.tv_usec = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":384 */
__pyx_v_hdr.caplen = PyObject_Length(__pyx_v_packet);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":385 */
__pyx_v_hdr.len = PyObject_Length(__pyx_v_packet);
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":387 */
__pyx_6 = PyString_AsString(__pyx_v_packet); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}
pcap_dump(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__dumper,(&__pyx_v_hdr),__pyx_6);
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_4);
Py_XDECREF(__pyx_5);
__Pyx_AddTraceback("pcap.pcap.dump");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
Py_DECREF(__pyx_v_packet);
Py_DECREF(__pyx_v_header);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_dump_close(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap_dump_close(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_r;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
pcap_dump_close(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__dumper);
__pyx_r = Py_None; Py_INCREF(Py_None);
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_close(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap_close(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_r;
int __pyx_1;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
__pyx_1 = (((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap != 0);
if (__pyx_1) {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":394 */
pcap_close(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":395 */
((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap = NULL;
goto __pyx_L2;
}
__pyx_L2:;
__pyx_r = Py_None; Py_INCREF(Py_None);
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_geterr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_geterr[] = "Return the last error message associated with this handle.";
static PyObject *__pyx_f_4pcap_4pcap_geterr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
__pyx_1 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
__Pyx_AddTraceback("pcap.pcap.geterr");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap_stats(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_stats[] = "Return a 3-tuple of the total number of packets received,\n dropped, and dropped by the interface.";
static PyObject *__pyx_f_4pcap_4pcap_stats(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
struct pcap_stat __pyx_v_pstat;
PyObject *__pyx_r;
int __pyx_1;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":405 */
__pyx_1 = (pcap_stats(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_pstat)) < 0);
if (__pyx_1) {
__pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; goto __pyx_L1;}
__pyx_3 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; goto __pyx_L1;}
__Pyx_Raise(__pyx_2, __pyx_3, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":407 */
__pyx_2 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_recv); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
__pyx_3 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_drop); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
__pyx_4 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_ifdrop); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
__pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
__pyx_2 = 0;
__pyx_3 = 0;
__pyx_4 = 0;
__pyx_r = __pyx_5;
__pyx_5 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
Py_XDECREF(__pyx_5);
__Pyx_AddTraceback("pcap.pcap.stats");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_4pcap___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap___iter__(PyObject *__pyx_v_self) {
PyObject *__pyx_r;
Py_INCREF(__pyx_v_self);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":410 */
pcap_ex_setup(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":411 */
Py_INCREF(__pyx_v_self);
__pyx_r = __pyx_v_self;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static PyObject *__pyx_n_StopIteration;
static PyObject *__pyx_f_4pcap_4pcap___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_4pcap_4pcap___next__(PyObject *__pyx_v_self) {
struct pcap_pkthdr *__pyx_v_hdr;
char *__pyx_v_pkt;
int __pyx_v_n;
PyObject *__pyx_r;
long __pyx_1;
int __pyx_2;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
Py_INCREF(__pyx_v_self);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":417 */
while (1) {
__pyx_1 = 1;
if (!__pyx_1) break;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":418 */
Py_BEGIN_ALLOW_THREADS;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":419 */
__pyx_v_n = pcap_ex_next(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_hdr),(&__pyx_v_pkt));
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":420 */
Py_END_ALLOW_THREADS;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":421 */
__pyx_2 = (__pyx_v_n == 1);
if (__pyx_2) {
__pyx_3 = PyFloat_FromDouble((__pyx_v_hdr->ts.tv_sec + (__pyx_v_hdr->ts.tv_usec / 1000000.0))); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}
__pyx_4 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;}
__pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
__pyx_3 = 0;
__pyx_4 = 0;
__pyx_r = __pyx_5;
__pyx_5 = 0;
goto __pyx_L0;
goto __pyx_L4;
}
__pyx_2 = (__pyx_v_n == (-1));
if (__pyx_2) {
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_KeyboardInterrupt); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_2 = (__pyx_v_n == (-2));
if (__pyx_2) {
__pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_StopIteration); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
__Pyx_Raise(__pyx_4, 0, 0);
Py_DECREF(__pyx_4); __pyx_4 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
}
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
Py_XDECREF(__pyx_5);
__Pyx_AddTraceback("pcap.pcap.__next__");
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
}
static void __pyx_f_4pcap_4pcap___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_4pcap_4pcap___dealloc__(PyObject *__pyx_v_self) {
int __pyx_1;
Py_INCREF(__pyx_v_self);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":430 */
__pyx_1 = (((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__name != 0);
if (__pyx_1) {
free(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__name);
goto __pyx_L2;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":432 */
__pyx_1 = (((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter != 0);
if (__pyx_1) {
free(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter);
goto __pyx_L3;
}
__pyx_L3:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":434 */
__pyx_1 = (((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap != 0);
if (__pyx_1) {
pcap_close(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap);
goto __pyx_L4;
}
__pyx_L4:;
Py_DECREF(__pyx_v_self);
}
static PyObject *__pyx_f_4pcap_ex_name(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4pcap_ex_name(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
char *__pyx_v_foo;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
static char *__pyx_argnames[] = {"foo",0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "s", __pyx_argnames, &__pyx_v_foo)) return 0;
__pyx_1 = PyString_FromString(pcap_ex_name(__pyx_v_foo)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
__Pyx_AddTraceback("pcap.ex_name");
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
static PyObject *__pyx_f_4pcap_lookupdev(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_lookupdev[] = "Return the name of a network device suitable for sniffing.";
static PyObject *__pyx_f_4pcap_lookupdev(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
char *__pyx_v_p;
char __pyx_v_ebuf[256];
PyObject *__pyx_r;
int __pyx_1;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":443 */
__pyx_v_p = pcap_ex_lookupdev(__pyx_v_ebuf);
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":444 */
__pyx_1 = (__pyx_v_p == NULL);
if (__pyx_1) {
__pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;}
__pyx_3 = PyString_FromString(__pyx_v_ebuf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;}
__Pyx_Raise(__pyx_2, __pyx_3, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":446 */
__pyx_2 = PyString_FromString(__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_3);
__Pyx_AddTraceback("pcap.lookupdev");
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
static __Pyx_InternTabEntry __pyx_intern_tab[] = {
{&__pyx_n_DLT_ARCNET, "DLT_ARCNET"},
{&__pyx_n_DLT_AX25, "DLT_AX25"},
{&__pyx_n_DLT_CHAOS, "DLT_CHAOS"},
{&__pyx_n_DLT_EN10MB, "DLT_EN10MB"},
{&__pyx_n_DLT_EN3MB, "DLT_EN3MB"},
{&__pyx_n_DLT_FDDI, "DLT_FDDI"},
{&__pyx_n_DLT_IEEE802, "DLT_IEEE802"},
{&__pyx_n_DLT_LINUX_SLL, "DLT_LINUX_SLL"},
{&__pyx_n_DLT_LOOP, "DLT_LOOP"},
{&__pyx_n_DLT_NULL, "DLT_NULL"},
{&__pyx_n_DLT_PFLOG, "DLT_PFLOG"},
{&__pyx_n_DLT_PFSYNC, "DLT_PFSYNC"},
{&__pyx_n_DLT_PPP, "DLT_PPP"},
{&__pyx_n_DLT_PRONET, "DLT_PRONET"},
{&__pyx_n_DLT_RAW, "DLT_RAW"},
{&__pyx_n_DLT_SLIP, "DLT_SLIP"},
{&__pyx_n_False, "False"},
{&__pyx_n_IOError, "IOError"},
{&__pyx_n_KeyError, "KeyError"},
{&__pyx_n_KeyboardInterrupt, "KeyboardInterrupt"},
{&__pyx_n_OSError, "OSError"},
{&__pyx_n_StopIteration, "StopIteration"},
{&__pyx_n_True, "True"},
{&__pyx_n___add_pkts, "__add_pkts"},
{&__pyx_n___author__, "__author__"},
{&__pyx_n___copyright__, "__copyright__"},
{&__pyx_n___license__, "__license__"},
{&__pyx_n___maintainer__, "__maintainer__"},
{&__pyx_n___revison__, "__revison__"},
{&__pyx_n___url__, "__url__"},
{&__pyx_n___version__, "__version__"},
{&__pyx_n_append, "append"},
{&__pyx_n_calendar, "calendar"},
{&__pyx_n_caplen, "caplen"},
{&__pyx_n_dispatch, "dispatch"},
{&__pyx_n_dltoff, "dltoff"},
{&__pyx_n_exc_info, "exc_info"},
{&__pyx_n_find, "find"},
{&__pyx_n_gmtime, "gmtime"},
{&__pyx_n_openbsd, "openbsd"},
{&__pyx_n_platform, "platform"},
{&__pyx_n_sec, "sec"},
{&__pyx_n_sys, "sys"},
{&__pyx_n_time, "time"},
{&__pyx_n_timegm, "timegm"},
{&__pyx_n_usec, "usec"},
{0, 0}
};
static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_k6p, __pyx_k6, sizeof(__pyx_k6)},
{&__pyx_k7p, __pyx_k7, sizeof(__pyx_k7)},
{&__pyx_k8p, __pyx_k8, sizeof(__pyx_k8)},
{&__pyx_k9p, __pyx_k9, sizeof(__pyx_k9)},
{&__pyx_k10p, __pyx_k10, sizeof(__pyx_k10)},
{&__pyx_k11p, __pyx_k11, sizeof(__pyx_k11)},
{&__pyx_k12p, __pyx_k12, sizeof(__pyx_k12)},
{&__pyx_k23p, __pyx_k23, sizeof(__pyx_k23)},
{&__pyx_k29p, __pyx_k29, sizeof(__pyx_k29)},
{&__pyx_k30p, __pyx_k30, sizeof(__pyx_k30)},
{&__pyx_k31p, __pyx_k31, sizeof(__pyx_k31)},
{&__pyx_k33p, __pyx_k33, sizeof(__pyx_k33)},
{0, 0, 0}
};
static PyObject *__pyx_tp_new_4pcap_bpf(PyTypeObject *t, PyObject *a, PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
}
static void __pyx_tp_dealloc_4pcap_bpf(PyObject *o) {
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++o->ob_refcnt;
__pyx_f_4pcap_3bpf___dealloc__(o);
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
--o->ob_refcnt;
PyErr_Restore(etype, eval, etb);
}
(*o->ob_type->tp_free)(o);
}
static int __pyx_tp_traverse_4pcap_bpf(PyObject *o, visitproc v, void *a) {
return 0;
}
static int __pyx_tp_clear_4pcap_bpf(PyObject *o) {
return 0;
}
static struct PyMethodDef __pyx_methods_4pcap_bpf[] = {
{"filter", (PyCFunction)__pyx_f_4pcap_3bpf_filter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_3bpf_filter},
{0, 0, 0, 0}
};
static PyNumberMethods __pyx_tp_as_number_bpf = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
0, /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
0, /*nb_negative*/
0, /*nb_positive*/
0, /*nb_absolute*/
0, /*nb_nonzero*/
0, /*nb_invert*/
0, /*nb_lshift*/
0, /*nb_rshift*/
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
0, /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
0, /*nb_oct*/
0, /*nb_hex*/
0, /*nb_inplace_add*/
0, /*nb_inplace_subtract*/
0, /*nb_inplace_multiply*/
0, /*nb_inplace_divide*/
0, /*nb_inplace_remainder*/
0, /*nb_inplace_power*/
0, /*nb_inplace_lshift*/
0, /*nb_inplace_rshift*/
0, /*nb_inplace_and*/
0, /*nb_inplace_xor*/
0, /*nb_inplace_or*/
0, /*nb_floor_divide*/
0, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
0, /*nb_inplace_true_divide*/
#if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
0, /*nb_index*/
#endif
};
static PySequenceMethods __pyx_tp_as_sequence_bpf = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
0, /*sq_item*/
0, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
0, /*sq_contains*/
0, /*sq_inplace_concat*/
0, /*sq_inplace_repeat*/
};
static PyMappingMethods __pyx_tp_as_mapping_bpf = {
0, /*mp_length*/
0, /*mp_subscript*/
0, /*mp_ass_subscript*/
};
static PyBufferProcs __pyx_tp_as_buffer_bpf = {
0, /*bf_getreadbuffer*/
0, /*bf_getwritebuffer*/
0, /*bf_getsegcount*/
0, /*bf_getcharbuffer*/
};
PyTypeObject __pyx_type_4pcap_bpf = {
PyObject_HEAD_INIT(0)
0, /*ob_size*/
"pcap.bpf", /*tp_name*/
sizeof(struct __pyx_obj_4pcap_bpf), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc_4pcap_bpf, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
&__pyx_tp_as_number_bpf, /*tp_as_number*/
&__pyx_tp_as_sequence_bpf, /*tp_as_sequence*/
&__pyx_tp_as_mapping_bpf, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
&__pyx_tp_as_buffer_bpf, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
"bpf(filter, dlt=DLT_RAW) -> BPF filter object", /*tp_doc*/
__pyx_tp_traverse_4pcap_bpf, /*tp_traverse*/
__pyx_tp_clear_4pcap_bpf, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_4pcap_bpf, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
__pyx_f_4pcap_3bpf___init__, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_4pcap_bpf, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
};
static PyObject *__pyx_tp_new_4pcap_pcap(PyTypeObject *t, PyObject *a, PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
}
static void __pyx_tp_dealloc_4pcap_pcap(PyObject *o) {
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++o->ob_refcnt;
__pyx_f_4pcap_4pcap___dealloc__(o);
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
--o->ob_refcnt;
PyErr_Restore(etype, eval, etb);
}
(*o->ob_type->tp_free)(o);
}
static int __pyx_tp_traverse_4pcap_pcap(PyObject *o, visitproc v, void *a) {
return 0;
}
static int __pyx_tp_clear_4pcap_pcap(PyObject *o) {
return 0;
}
static PyObject *__pyx_getprop_4pcap_4pcap_name(PyObject *o, void *x) {
return __pyx_f_4pcap_4pcap_4name___get__(o);
}
static PyObject *__pyx_getprop_4pcap_4pcap_snaplen(PyObject *o, void *x) {
return __pyx_f_4pcap_4pcap_7snaplen___get__(o);
}
static PyObject *__pyx_getprop_4pcap_4pcap_dloff(PyObject *o, void *x) {
return __pyx_f_4pcap_4pcap_5dloff___get__(o);
}
static PyObject *__pyx_getprop_4pcap_4pcap_filter(PyObject *o, void *x) {
return __pyx_f_4pcap_4pcap_6filter___get__(o);
}
static PyObject *__pyx_getprop_4pcap_4pcap_fd(PyObject *o, void *x) {
return __pyx_f_4pcap_4pcap_2fd___get__(o);
}
static struct PyMethodDef __pyx_methods_4pcap_pcap[] = {
{"fileno", (PyCFunction)__pyx_f_4pcap_4pcap_fileno, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_fileno},
{"setfilter", (PyCFunction)__pyx_f_4pcap_4pcap_setfilter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_setfilter},
{"setnonblock", (PyCFunction)__pyx_f_4pcap_4pcap_setnonblock, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_setnonblock},
{"getnonblock", (PyCFunction)__pyx_f_4pcap_4pcap_getnonblock, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_getnonblock},
{"datalink", (PyCFunction)__pyx_f_4pcap_4pcap_datalink, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_datalink},
{"next", (PyCFunction)__pyx_f_4pcap_4pcap_next, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_next},
{"__add_pkts", (PyCFunction)__pyx_f_4pcap_4pcap___add_pkts, METH_VARARGS|METH_KEYWORDS, 0},
{"readpkts", (PyCFunction)__pyx_f_4pcap_4pcap_readpkts, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_readpkts},
{"dispatch", (PyCFunction)__pyx_f_4pcap_4pcap_dispatch, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_dispatch},
{"loop", (PyCFunction)__pyx_f_4pcap_4pcap_loop, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_loop},
{"inject", (PyCFunction)__pyx_f_4pcap_4pcap_inject, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_inject},
{"dump", (PyCFunction)__pyx_f_4pcap_4pcap_dump, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_dump},
{"dump_close", (PyCFunction)__pyx_f_4pcap_4pcap_dump_close, METH_VARARGS|METH_KEYWORDS, 0},
{"close", (PyCFunction)__pyx_f_4pcap_4pcap_close, METH_VARARGS|METH_KEYWORDS, 0},
{"geterr", (PyCFunction)__pyx_f_4pcap_4pcap_geterr, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_geterr},
{"stats", (PyCFunction)__pyx_f_4pcap_4pcap_stats, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_stats},
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets_4pcap_pcap[] = {
{"name", __pyx_getprop_4pcap_4pcap_name, 0, __pyx_k1, 0},
{"snaplen", __pyx_getprop_4pcap_4pcap_snaplen, 0, __pyx_k2, 0},
{"dloff", __pyx_getprop_4pcap_4pcap_dloff, 0, __pyx_k3, 0},
{"filter", __pyx_getprop_4pcap_4pcap_filter, 0, __pyx_k4, 0},
{"fd", __pyx_getprop_4pcap_4pcap_fd, 0, __pyx_k5, 0},
{0, 0, 0, 0, 0}
};
static PyNumberMethods __pyx_tp_as_number_pcap = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
0, /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
0, /*nb_negative*/
0, /*nb_positive*/
0, /*nb_absolute*/
0, /*nb_nonzero*/
0, /*nb_invert*/
0, /*nb_lshift*/
0, /*nb_rshift*/
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
0, /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
0, /*nb_oct*/
0, /*nb_hex*/
0, /*nb_inplace_add*/
0, /*nb_inplace_subtract*/
0, /*nb_inplace_multiply*/
0, /*nb_inplace_divide*/
0, /*nb_inplace_remainder*/
0, /*nb_inplace_power*/
0, /*nb_inplace_lshift*/
0, /*nb_inplace_rshift*/
0, /*nb_inplace_and*/
0, /*nb_inplace_xor*/
0, /*nb_inplace_or*/
0, /*nb_floor_divide*/
0, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
0, /*nb_inplace_true_divide*/
#if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
0, /*nb_index*/
#endif
};
static PySequenceMethods __pyx_tp_as_sequence_pcap = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
0, /*sq_item*/
0, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
0, /*sq_contains*/
0, /*sq_inplace_concat*/
0, /*sq_inplace_repeat*/
};
static PyMappingMethods __pyx_tp_as_mapping_pcap = {
0, /*mp_length*/
0, /*mp_subscript*/
0, /*mp_ass_subscript*/
};
static PyBufferProcs __pyx_tp_as_buffer_pcap = {
0, /*bf_getreadbuffer*/
0, /*bf_getwritebuffer*/
0, /*bf_getsegcount*/
0, /*bf_getcharbuffer*/
};
PyTypeObject __pyx_type_4pcap_pcap = {
PyObject_HEAD_INIT(0)
0, /*ob_size*/
"pcap.pcap", /*tp_name*/
sizeof(struct __pyx_obj_4pcap_pcap), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc_4pcap_pcap, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
&__pyx_tp_as_number_pcap, /*tp_as_number*/
&__pyx_tp_as_sequence_pcap, /*tp_as_sequence*/
&__pyx_tp_as_mapping_pcap, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
&__pyx_tp_as_buffer_pcap, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
"pcap(name=None, snaplen=65535, promisc=True, immediate=False) -> packet capture object\n \n Open a handle to a packet capture descriptor.\n \n Keyword arguments:\n name -- name of a network interface or dumpfile to open,\n or None to open the first available up interface\n snaplen -- maximum number of bytes to capture for each packet\n promisc -- boolean to specify promiscuous mode sniffing\n immediate -- disable buffering, if possible\n dumpfile -- name of a dumpfile to open, if necessary\n dumptype -- only open a dumpfile and specify its type\n ", /*tp_doc*/
__pyx_tp_traverse_4pcap_pcap, /*tp_traverse*/
__pyx_tp_clear_4pcap_pcap, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
__pyx_f_4pcap_4pcap___iter__, /*tp_iter*/
__pyx_f_4pcap_4pcap___next__, /*tp_iternext*/
__pyx_methods_4pcap_pcap, /*tp_methods*/
0, /*tp_members*/
__pyx_getsets_4pcap_pcap, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
__pyx_f_4pcap_4pcap___init__, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_4pcap_pcap, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
};
static struct PyMethodDef __pyx_methods[] = {
{"ex_name", (PyCFunction)__pyx_f_4pcap_ex_name, METH_VARARGS|METH_KEYWORDS, 0},
{"lookupdev", (PyCFunction)__pyx_f_4pcap_lookupdev, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_lookupdev},
{0, 0, 0, 0}
};
static void __pyx_init_filenames(void); /*proto*/
PyMODINIT_FUNC initpcap(void); /*proto*/
PyMODINIT_FUNC initpcap(void) {
PyObject *__pyx_1 = 0;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
int __pyx_4;
PyObject *__pyx_5 = 0;
PyObject *__pyx_6 = 0;
PyObject *__pyx_7 = 0;
PyObject *__pyx_8 = 0;
__pyx_init_filenames();
__pyx_m = Py_InitModule4("pcap", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;};
__pyx_b = PyImport_AddModule("__builtin__");
if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;};
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;};
if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;};
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;};
if (PyType_Ready(&__pyx_type_4pcap_bpf) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;}
if (PyObject_SetAttrString(__pyx_m, "bpf", (PyObject *)&__pyx_type_4pcap_bpf) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;}
__pyx_ptype_4pcap_bpf = &__pyx_type_4pcap_bpf;
if (PyType_Ready(&__pyx_type_4pcap_pcap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}
if (PyObject_SetAttrString(__pyx_m, "pcap", (PyObject *)&__pyx_type_4pcap_pcap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}
__pyx_ptype_4pcap_pcap = &__pyx_type_4pcap_pcap;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":13 */
if (PyObject_SetAttr(__pyx_m, __pyx_n___author__, __pyx_k6p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":14 */
if (PyObject_SetAttr(__pyx_m, __pyx_n___maintainer__, __pyx_k7p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":15 */
if (PyObject_SetAttr(__pyx_m, __pyx_n___copyright__, __pyx_k8p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":16 */
if (PyObject_SetAttr(__pyx_m, __pyx_n___license__, __pyx_k9p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":17 */
if (PyObject_SetAttr(__pyx_m, __pyx_n___url__, __pyx_k10p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;}
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":18 */
if (PyObject_SetAttr(__pyx_m, __pyx_n___version__, __pyx_k11p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;}
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":19 */
if (PyObject_SetAttr(__pyx_m, __pyx_n___revison__, __pyx_k12p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":21 */
__pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_sys, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":22 */
__pyx_1 = __Pyx_Import(__pyx_n_calendar, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_calendar, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":23 */
__pyx_1 = __Pyx_Import(__pyx_n_time, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_time, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":114 */
__pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_NULL, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":115 */
__pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_EN10MB, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":116 */
__pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_EN3MB, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":117 */
__pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_AX25, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":118 */
__pyx_1 = PyInt_FromLong(4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PRONET, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":119 */
__pyx_1 = PyInt_FromLong(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_CHAOS, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":120 */
__pyx_1 = PyInt_FromLong(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_IEEE802, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":121 */
__pyx_1 = PyInt_FromLong(7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_ARCNET, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":122 */
__pyx_1 = PyInt_FromLong(8); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_SLIP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":123 */
__pyx_1 = PyInt_FromLong(9); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PPP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":124 */
__pyx_1 = PyInt_FromLong(10); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_FDDI, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":126 */
__pyx_1 = PyInt_FromLong(113); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_LINUX_SLL, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":128 */
__pyx_1 = PyInt_FromLong(117); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PFLOG, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":129 */
__pyx_1 = PyInt_FromLong(18); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PFSYNC, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":130 */
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
__pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_platform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
__pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_find); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
Py_INCREF(__pyx_n_openbsd);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_openbsd);
__pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = PyInt_FromLong((-1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
__pyx_4 = __pyx_4 != 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_1); __pyx_1 = 0;
if (__pyx_4) {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":131 */
__pyx_2 = PyInt_FromLong(12); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_LOOP, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":132 */
__pyx_3 = PyInt_FromLong(14); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_RAW, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
goto __pyx_L3;
}
/*else*/ {
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":134 */
__pyx_1 = PyInt_FromLong(108); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_LOOP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":135 */
__pyx_2 = PyInt_FromLong(12); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_RAW, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
}
__pyx_L3:;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":137 */
__pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_NULL); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_EN10MB); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(14); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_IEEE802); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(22); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_ARCNET); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_SLIP); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(16); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_PPP); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_FDDI); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(21); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_PFLOG); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(48); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_PFSYNC); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_LOOP); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_RAW); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_LINUX_SLL); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
__pyx_2 = PyInt_FromLong(16); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (PyObject_SetAttr(__pyx_m, __pyx_n_dltoff, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":144 */
__pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_RAW); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
__pyx_k17 = __pyx_1;
__pyx_1 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":178 */
Py_INCREF(Py_None);
__pyx_k18 = Py_None;
__pyx_2 = PyInt_FromLong(65535); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; goto __pyx_L1;}
__pyx_k19 = __pyx_2;
__pyx_2 = 0;
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; goto __pyx_L1;}
__pyx_k20 = __pyx_3;
__pyx_3 = 0;
__pyx_5 = PyInt_FromLong(500); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
__pyx_k21 = __pyx_5;
__pyx_5 = 0;
__pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
__pyx_k22 = __pyx_6;
__pyx_6 = 0;
Py_INCREF(__pyx_k23p);
__pyx_k24 = __pyx_k23p;
Py_INCREF(Py_None);
__pyx_k25 = Py_None;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":249 */
__pyx_7 = PyInt_FromLong(1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
__pyx_k26 = __pyx_7;
__pyx_7 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":260 */
__pyx_8 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;}
__pyx_k27 = __pyx_8;
__pyx_8 = 0;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":362 */
Py_INCREF(Py_None);
__pyx_k28 = Py_None;
/* "/mnt/gmirror/ports/net/py-pcs/work/pcs-0.5/pcs/pcap/pcap.pyx":440 */
return;
__pyx_L1:;
Py_XDECREF(__pyx_1);
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_5);
Py_XDECREF(__pyx_6);
Py_XDECREF(__pyx_7);
Py_XDECREF(__pyx_8);
__Pyx_AddTraceback("pcap");
}
static char *__pyx_filenames[] = {
"pcap.pyx",
};
/* Runtime support code */
static void __pyx_init_filenames(void) {
__pyx_f = __pyx_filenames;
}
static int __Pyx_GetStarArgs(
PyObject **args,
PyObject **kwds,
char *kwd_list[],
Py_ssize_t nargs,
PyObject **args2,
PyObject **kwds2,
char rqd_kwds[])
{
PyObject *x = 0, *args1 = 0, *kwds1 = 0;
int i;
char **p;
if (args2)
*args2 = 0;
if (kwds2)
*kwds2 = 0;
if (args2) {
args1 = PyTuple_GetSlice(*args, 0, nargs);
if (!args1)
goto bad;
*args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args));
if (!*args2)
goto bad;
}
else if (PyTuple_GET_SIZE(*args) > nargs) {
int m = nargs;
int n = PyTuple_GET_SIZE(*args);
PyErr_Format(PyExc_TypeError,
"function takes at most %d positional arguments (%d given)",
m, n);
goto bad;
}
else {
args1 = *args;
Py_INCREF(args1);
}
if (rqd_kwds && !*kwds)
for (i = 0, p = kwd_list; *p; i++, p++)
if (rqd_kwds[i])
goto missing_kwarg;
if (kwds2) {
if (*kwds) {
kwds1 = PyDict_New();
if (!kwds1)
goto bad;
*kwds2 = PyDict_Copy(*kwds);
if (!*kwds2)
goto bad;
for (i = 0, p = kwd_list; *p; i++, p++) {
x = PyDict_GetItemString(*kwds, *p);
if (x) {
if (PyDict_SetItemString(kwds1, *p, x) < 0)
goto bad;
if (PyDict_DelItemString(*kwds2, *p) < 0)
goto bad;
}
else if (rqd_kwds && rqd_kwds[i])
goto missing_kwarg;
}
}
else {
*kwds2 = PyDict_New();
if (!*kwds2)
goto bad;
}
}
else {
kwds1 = *kwds;
Py_XINCREF(kwds1);
if (rqd_kwds && *kwds)
for (i = 0, p = kwd_list; *p; i++, p++)
if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p))
goto missing_kwarg;
}
*args = args1;
*kwds = kwds1;
return 0;
missing_kwarg:
PyErr_Format(PyExc_TypeError,
"required keyword argument '%s' is missing", *p);
bad:
Py_XDECREF(args1);
Py_XDECREF(kwds1);
if (args2) {
Py_XDECREF(*args2);
}
if (kwds2) {
Py_XDECREF(*kwds2);
}
return -1;
}
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
PyObject *__import__ = 0;
PyObject *empty_list = 0;
PyObject *module = 0;
PyObject *global_dict = 0;
PyObject *empty_dict = 0;
PyObject *list;
__import__ = PyObject_GetAttrString(__pyx_b, "__import__");
if (!__import__)
goto bad;
if (from_list)
list = from_list;
else {
empty_list = PyList_New(0);
if (!empty_list)
goto bad;
list = empty_list;
}
global_dict = PyModule_GetDict(__pyx_m);
if (!global_dict)
goto bad;
empty_dict = PyDict_New();
if (!empty_dict)
goto bad;
module = PyObject_CallFunction(__import__, "OOOO",
name, global_dict, empty_dict, list);
bad:
Py_XDECREF(empty_list);
Py_XDECREF(__import__);
Py_XDECREF(empty_dict);
return module;
}
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
PyObject *result;
result = PyObject_GetAttr(dict, name);
if (!result)
PyErr_SetObject(PyExc_NameError, name);
return result;
}
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
PyThreadState *tstate = PyThreadState_Get();
PyErr_Fetch(type, value, tb);
PyErr_NormalizeException(type, value, tb);
if (PyErr_Occurred())
goto bad;
Py_INCREF(*type);
Py_INCREF(*value);
Py_INCREF(*tb);
Py_XDECREF(tstate->exc_type);
Py_XDECREF(tstate->exc_value);
Py_XDECREF(tstate->exc_traceback);
tstate->exc_type = *type;
tstate->exc_value = *value;
tstate->exc_traceback = *tb;
return 0;
bad:
Py_XDECREF(*type);
Py_XDECREF(*value);
Py_XDECREF(*tb);
return -1;
}
static void __Pyx_WriteUnraisable(char *name) {
PyObject *old_exc, *old_val, *old_tb;
PyObject *ctx;
PyErr_Fetch(&old_exc, &old_val, &old_tb);
ctx = PyString_FromString(name);
PyErr_Restore(old_exc, old_val, old_tb);
if (!ctx)
ctx = Py_None;
PyErr_WriteUnraisable(ctx);
}
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
Py_XINCREF(type);
Py_XINCREF(value);
Py_XINCREF(tb);
/* First, check the traceback argument, replacing None with NULL. */
if (tb == Py_None) {
Py_DECREF(tb);
tb = 0;
}
else if (tb != NULL && !PyTraceBack_Check(tb)) {
PyErr_SetString(PyExc_TypeError,
"raise: arg 3 must be a traceback or None");
goto raise_error;
}
/* Next, replace a missing value with None */
if (value == NULL) {
value = Py_None;
Py_INCREF(value);
}
#if PY_VERSION_HEX < 0x02050000
if (!PyClass_Check(type))
#else
if (!PyType_Check(type))
#endif
{
/* Raising an instance. The value should be a dummy. */
if (value != Py_None) {
PyErr_SetString(PyExc_TypeError,
"instance exception may not have a separate value");
goto raise_error;
}
/* Normalize to raise <class>, <instance> */
Py_DECREF(value);
value = type;
#if PY_VERSION_HEX < 0x02050000
if (PyInstance_Check(type)) {
type = (PyObject*) ((PyInstanceObject*)type)->in_class;
Py_INCREF(type);
}
else {
PyErr_SetString(PyExc_TypeError,
"raise: exception must be an old-style class or instance");
goto raise_error;
}
#else
type = (PyObject*) type->ob_type;
Py_INCREF(type);
if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
PyErr_SetString(PyExc_TypeError,
"raise: exception class must be a subclass of BaseException");
goto raise_error;
}
#endif
}
PyErr_Restore(type, value, tb);
return;
raise_error:
Py_XDECREF(value);
Py_XDECREF(type);
Py_XDECREF(tb);
return;
}
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
while (t->p) {
*t->p = PyString_InternFromString(t->s);
if (!*t->p)
return -1;
++t;
}
return 0;
}
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
while (t->p) {
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
if (!*t->p)
return -1;
++t;
}
return 0;
}
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static void __Pyx_AddTraceback(char *funcname) {
PyObject *py_srcfile = 0;
PyObject *py_funcname = 0;
PyObject *py_globals = 0;
PyObject *empty_tuple = 0;
PyObject *empty_string = 0;
PyCodeObject *py_code = 0;
PyFrameObject *py_frame = 0;
py_srcfile = PyString_FromString(__pyx_filename);
if (!py_srcfile) goto bad;
py_funcname = PyString_FromString(funcname);
if (!py_funcname) goto bad;
py_globals = PyModule_GetDict(__pyx_m);
if (!py_globals) goto bad;
empty_tuple = PyTuple_New(0);
if (!empty_tuple) goto bad;
empty_string = PyString_FromString("");
if (!empty_string) goto bad;
py_code = PyCode_New(
0, /*int argcount,*/
0, /*int nlocals,*/
0, /*int stacksize,*/
0, /*int flags,*/
empty_string, /*PyObject *code,*/
empty_tuple, /*PyObject *consts,*/
empty_tuple, /*PyObject *names,*/
empty_tuple, /*PyObject *varnames,*/
empty_tuple, /*PyObject *freevars,*/
empty_tuple, /*PyObject *cellvars,*/
py_srcfile, /*PyObject *filename,*/
py_funcname, /*PyObject *name,*/
__pyx_lineno, /*int firstlineno,*/
empty_string /*PyObject *lnotab*/
);
if (!py_code) goto bad;
py_frame = PyFrame_New(
PyThreadState_Get(), /*PyThreadState *tstate,*/
py_code, /*PyCodeObject *code,*/
py_globals, /*PyObject *globals,*/
0 /*PyObject *locals*/
);
if (!py_frame) goto bad;
py_frame->f_lineno = __pyx_lineno;
PyTraceBack_Here(py_frame);
bad:
Py_XDECREF(py_srcfile);
Py_XDECREF(py_funcname);
Py_XDECREF(empty_tuple);
Py_XDECREF(empty_string);
Py_XDECREF(py_code);
Py_XDECREF(py_frame);
}
syntax highlighted by Code2HTML, v. 0.9.1