/* Generated by Pyrex 0.9.8.5 on Tue Apr  2 06:11:44 2013 */

#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
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#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; int i; 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_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 PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i); /*proto*/

static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[],     Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static void __Pyx_AddTraceback(char *funcname); /*proto*/

/* Declarations from pcap */


/* Declarations from implementation of 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;
};



static PyTypeObject *__pyx_ptype_4pcap_bpf = 0;
static PyTypeObject *__pyx_ptype_4pcap_pcap = 0;
static void __pyx_f_4pcap___pcap_handler(void *,struct pcap_pkthdr *,char *); /*proto*/

static char __pyx_k1[] = "bad filter";
static char __pyx_k2[] = "";
static char __pyx_k3[] = "dltoff";
static char __pyx_k4[] = "couldn't enable immediate mode";
static char __pyx_k5[] = "append";
static char __pyx_k6[] = "dispatch";
static char __pyx_k7[] = "__add_pkts";
static char __pyx_k8[] = "sys";
static char __pyx_k9[] = "exc_info";
static char __pyx_k10[] = "struct";
static char __pyx_k11[] = "pack";
static char __pyx_k12[] = "I";
static char __pyx_k13[] = "Network interface or dumpfile name.";
static char __pyx_k14[] = "Maximum number of bytes to capture for each packet.";
static char __pyx_k15[] = "Datalink offset (length of layer-2 frame header).";
static char __pyx_k16[] = "Current packet capture filter.";
static char __pyx_k17[] = "File descriptor (or Win32 HANDLE) for capture handle.";
static char __pyx_k18[] = "Dug Song <dugsong@monkey.org>";
static char __pyx_k19[] = "__author__";
static char __pyx_k20[] = "Copyright (c) 2004 Dug Song";
static char __pyx_k21[] = "__copyright__";
static char __pyx_k22[] = "BSD license";
static char __pyx_k23[] = "__license__";
static char __pyx_k24[] = "http://monkey.org/~dugsong/pypcap/";
static char __pyx_k25[] = "__url__";
static char __pyx_k26[] = "1.1";
static char __pyx_k27[] = "__version__";
static char __pyx_k28[] = "DLT_NULL";
static char __pyx_k29[] = "DLT_EN10MB";
static char __pyx_k30[] = "DLT_EN3MB";
static char __pyx_k31[] = "DLT_AX25";
static char __pyx_k32[] = "DLT_PRONET";
static char __pyx_k33[] = "DLT_CHAOS";
static char __pyx_k34[] = "DLT_IEEE802";
static char __pyx_k35[] = "DLT_ARCNET";
static char __pyx_k36[] = "DLT_SLIP";
static char __pyx_k37[] = "DLT_PPP";
static char __pyx_k38[] = "DLT_FDDI";
static char __pyx_k39[] = "DLT_LINUX_SLL";
static char __pyx_k40[] = "DLT_PFLOG";
static char __pyx_k41[] = "DLT_PFSYNC";
static char __pyx_k42[] = "platform";
static char __pyx_k43[] = "find";
static char __pyx_k44[] = "openbsd";
static char __pyx_k45[] = "DLT_LOOP";
static char __pyx_k46[] = "DLT_RAW";

static PyObject *__pyx_n_DLT_ARCNET;
static PyObject *__pyx_n_DLT_AX25;
static PyObject *__pyx_n_DLT_CHAOS;
static PyObject *__pyx_n_DLT_EN10MB;
static PyObject *__pyx_n_DLT_EN3MB;
static PyObject *__pyx_n_DLT_FDDI;
static PyObject *__pyx_n_DLT_IEEE802;
static PyObject *__pyx_n_DLT_LINUX_SLL;
static PyObject *__pyx_n_DLT_LOOP;
static PyObject *__pyx_n_DLT_NULL;
static PyObject *__pyx_n_DLT_PFLOG;
static PyObject *__pyx_n_DLT_PFSYNC;
static PyObject *__pyx_n_DLT_PPP;
static PyObject *__pyx_n_DLT_PRONET;
static PyObject *__pyx_n_DLT_RAW;
static PyObject *__pyx_n_DLT_SLIP;
static PyObject *__pyx_n_I;
static PyObject *__pyx_n___add_pkts;
static PyObject *__pyx_n___author__;
static PyObject *__pyx_n___copyright__;
static PyObject *__pyx_n___license__;
static PyObject *__pyx_n___url__;
static PyObject *__pyx_n___version__;
static PyObject *__pyx_n_append;
static PyObject *__pyx_n_dispatch;
static PyObject *__pyx_n_dltoff;
static PyObject *__pyx_n_exc_info;
static PyObject *__pyx_n_find;
static PyObject *__pyx_n_openbsd;
static PyObject *__pyx_n_pack;
static PyObject *__pyx_n_platform;
static PyObject *__pyx_n_struct;
static PyObject *__pyx_n_sys;

static PyObject *__pyx_k1p;
static PyObject *__pyx_k4p;
static PyObject *__pyx_k18p;
static PyObject *__pyx_k20p;
static PyObject *__pyx_k22p;
static PyObject *__pyx_k24p;
static PyObject *__pyx_k26p;

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_DLT_ARCNET, 1, __pyx_k35, sizeof(__pyx_k35)},
  {&__pyx_n_DLT_AX25, 1, __pyx_k31, sizeof(__pyx_k31)},
  {&__pyx_n_DLT_CHAOS, 1, __pyx_k33, sizeof(__pyx_k33)},
  {&__pyx_n_DLT_EN10MB, 1, __pyx_k29, sizeof(__pyx_k29)},
  {&__pyx_n_DLT_EN3MB, 1, __pyx_k30, sizeof(__pyx_k30)},
  {&__pyx_n_DLT_FDDI, 1, __pyx_k38, sizeof(__pyx_k38)},
  {&__pyx_n_DLT_IEEE802, 1, __pyx_k34, sizeof(__pyx_k34)},
  {&__pyx_n_DLT_LINUX_SLL, 1, __pyx_k39, sizeof(__pyx_k39)},
  {&__pyx_n_DLT_LOOP, 1, __pyx_k45, sizeof(__pyx_k45)},
  {&__pyx_n_DLT_NULL, 1, __pyx_k28, sizeof(__pyx_k28)},
  {&__pyx_n_DLT_PFLOG, 1, __pyx_k40, sizeof(__pyx_k40)},
  {&__pyx_n_DLT_PFSYNC, 1, __pyx_k41, sizeof(__pyx_k41)},
  {&__pyx_n_DLT_PPP, 1, __pyx_k37, sizeof(__pyx_k37)},
  {&__pyx_n_DLT_PRONET, 1, __pyx_k32, sizeof(__pyx_k32)},
  {&__pyx_n_DLT_RAW, 1, __pyx_k46, sizeof(__pyx_k46)},
  {&__pyx_n_DLT_SLIP, 1, __pyx_k36, sizeof(__pyx_k36)},
  {&__pyx_n_I, 1, __pyx_k12, sizeof(__pyx_k12)},
  {&__pyx_n___add_pkts, 1, __pyx_k7, sizeof(__pyx_k7)},
  {&__pyx_n___author__, 1, __pyx_k19, sizeof(__pyx_k19)},
  {&__pyx_n___copyright__, 1, __pyx_k21, sizeof(__pyx_k21)},
  {&__pyx_n___license__, 1, __pyx_k23, sizeof(__pyx_k23)},
  {&__pyx_n___url__, 1, __pyx_k25, sizeof(__pyx_k25)},
  {&__pyx_n___version__, 1, __pyx_k27, sizeof(__pyx_k27)},
  {&__pyx_n_append, 1, __pyx_k5, sizeof(__pyx_k5)},
  {&__pyx_n_dispatch, 1, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_n_dltoff, 1, __pyx_k3, sizeof(__pyx_k3)},
  {&__pyx_n_exc_info, 1, __pyx_k9, sizeof(__pyx_k9)},
  {&__pyx_n_find, 1, __pyx_k43, sizeof(__pyx_k43)},
  {&__pyx_n_openbsd, 1, __pyx_k44, sizeof(__pyx_k44)},
  {&__pyx_n_pack, 1, __pyx_k11, sizeof(__pyx_k11)},
  {&__pyx_n_platform, 1, __pyx_k42, sizeof(__pyx_k42)},
  {&__pyx_n_struct, 1, __pyx_k10, sizeof(__pyx_k10)},
  {&__pyx_n_sys, 1, __pyx_k8, sizeof(__pyx_k8)},
  {&__pyx_k1p, 0, __pyx_k1, sizeof(__pyx_k1)},
  {&__pyx_k4p, 0, __pyx_k4, sizeof(__pyx_k4)},
  {&__pyx_k18p, 0, __pyx_k18, sizeof(__pyx_k18)},
  {&__pyx_k20p, 0, __pyx_k20, sizeof(__pyx_k20)},
  {&__pyx_k22p, 0, __pyx_k22, sizeof(__pyx_k22)},
  {&__pyx_k24p, 0, __pyx_k24, sizeof(__pyx_k24)},
  {&__pyx_k26p, 0, __pyx_k26, sizeof(__pyx_k26)},
  {0, 0, 0, 0}
};

static PyObject *__pyx_d1;
static PyObject *__pyx_d2;
static PyObject *__pyx_d3;
static PyObject *__pyx_d4;
static PyObject *__pyx_d5;
static PyObject *__pyx_d6;
static PyObject *__pyx_d7;
static PyObject *__pyx_d8;


/* Implementation of pcap */

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;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":105 */
  __pyx_v_ctx = ((struct __pyx_t_4pcap_pcap_handler_ctx *)__pyx_v_arg);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":106 */
  __pyx_v_gil = PyGILState_Ensure();

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":107 */
  /*try:*/ {
    __pyx_1 = PyFloat_FromDouble((__pyx_v_hdr->ts.tv_sec + (__pyx_v_hdr->ts.tv_usec / 1000000.0))); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L2;}
    __pyx_2 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; goto __pyx_L2;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L2;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
    __pyx_1 = 0;
    __pyx_2 = 0;
    __pyx_1 = PySequence_Tuple(((PyObject *)__pyx_v_ctx->args)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L2;}
    __pyx_2 = PyNumber_Add(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L2;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = PyObject_CallObject(((PyObject *)__pyx_v_ctx->callback), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L2;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  goto __pyx_L3;
  __pyx_L2:;
  Py_XDECREF(__pyx_1); __pyx_1 = 0;
  Py_XDECREF(__pyx_2); __pyx_2 = 0;
  Py_XDECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":111 */
  /*except:*/ {
    __Pyx_AddTraceback("pcap.__pcap_handler");
    if (__Pyx_GetException(&__pyx_1, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;}
    __pyx_v_ctx->got_exc = 1;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":113 */
  PyGILState_Release(__pyx_v_gil);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("pcap.__pcap_handler");
  __pyx_L0:;
}

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;
  static char *__pyx_argnames[] = {"filter","dlt",0};
  __pyx_v_dlt = __pyx_d1;
  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 = 146; 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_Raise(PyExc_IOError, __pyx_k1p, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __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;
  char *__pyx_v_p;
  int __pyx_v_n;
  PyObject *__pyx_r;
  int __pyx_1;
  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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":152 */
  __pyx_1 = (PyObject_AsCharBuffer(__pyx_v_buf,(&__pyx_v_p),(&__pyx_v_n)) < 0);
  if (__pyx_1) {
    __Pyx_Raise(PyExc_TypeError, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":154 */
  __pyx_1 = (bpf_filter(((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode.bf_insns,__pyx_v_p,__pyx_v_n,__pyx_v_n) == 0);
  if (__pyx_1) {
    Py_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":156 */
  Py_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  __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 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;
  char *__pyx_v_p;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  char *__pyx_4;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  static char *__pyx_argnames[] = {"name","snaplen","promisc","timeout_ms","immediate",0};
  __pyx_v_name = __pyx_d2;
  __pyx_v_snaplen = __pyx_d3;
  __pyx_v_promisc = __pyx_d4;
  __pyx_v_timeout_ms = __pyx_d5;
  __pyx_v_immediate = __pyx_d6;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOOOO", __pyx_argnames, &__pyx_v_name, &__pyx_v_snaplen, &__pyx_v_promisc, &__pyx_v_timeout_ms, &__pyx_v_immediate)) 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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":186 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_name); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":187 */
    __pyx_v_p = pcap_ex_lookupdev(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":188 */
    __pyx_1 = (__pyx_v_p == NULL);
    if (__pyx_1) {
      __pyx_3 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;}
      __Pyx_Raise(PyExc_OSError, __pyx_3, 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_4 = PyString_AsString(__pyx_v_name); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}
    __pyx_v_p = __pyx_4;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":193 */
  ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap = pcap_open_offline(__pyx_v_p,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":194 */
  __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 = 195; goto __pyx_L1;}
    __pyx_2 = PyInt_AsLong(__pyx_v_promisc); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;}
    __pyx_5 = PyInt_AsLong(__pyx_v_timeout_ms); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; 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_5,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":197 */
  __pyx_1 = (!(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap != 0));
  if (__pyx_1) {
    __pyx_3 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}
    __Pyx_Raise(PyExc_OSError, __pyx_3, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":200 */
  ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__name = strdup(__pyx_v_p);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":201 */
  ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter = strdup(__pyx_k2);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":202 */
  /*try:*/ {
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_dltoff); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L6;}
    __pyx_6 = __Pyx_GetItemInt(__pyx_3, pcap_datalink(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L6;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_2 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L6;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__dloff = __pyx_2;
  }
  goto __pyx_L7;
  __pyx_L6:;
  Py_XDECREF(__pyx_3); __pyx_3 = 0;
  Py_XDECREF(__pyx_6); __pyx_6 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":203 */
  __pyx_5 = PyErr_ExceptionMatches(PyExc_KeyError);
  if (__pyx_5) {
    __Pyx_AddTraceback("pcap.__init__");
    if (__Pyx_GetException(&__pyx_3, &__pyx_6, &__pyx_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_7); __pyx_7 = 0;
    goto __pyx_L7;
  }
  goto __pyx_L1;
  __pyx_L7:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":204 */
  __pyx_3 = __pyx_v_immediate;
  Py_INCREF(__pyx_3);
  __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;}
  if (__pyx_1) {
    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 = 204; goto __pyx_L1;}
  }
  __pyx_2 = PyObject_IsTrue(__pyx_3); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_2) {
    __Pyx_Raise(PyExc_OSError, __pyx_k4p, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __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);
  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 = 210; 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 = 215; 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 = 220; 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 = 225; 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 = 230; 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 = 234; 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;
  static char *__pyx_argnames[] = {"value","optimize",0};
  __pyx_v_optimize = __pyx_d7;
  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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":239 */
  free(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":240 */
  __pyx_1 = PyString_AsString(__pyx_v_value); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;}
  ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter = strdup(__pyx_1);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":241 */
  __pyx_2 = PyInt_AsLong(__pyx_v_optimize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; 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 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}
    __Pyx_Raise(PyExc_OSError, __pyx_4, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":243 */
  __pyx_2 = (pcap_setfilter(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_fcode)) < 0);
  if (__pyx_2) {
    __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 = 244; goto __pyx_L1;}
    __Pyx_Raise(PyExc_OSError, __pyx_4, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":245 */
  pcap_freecode((&__pyx_v_fcode));

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_4);
  __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_d8;
  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 = 249; 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;
  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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":253 */
  __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 = 253; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ret);
  __pyx_v_ret = __pyx_1;
  __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":254 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_v_ret, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;}
  __pyx_2 = __pyx_2 < 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {
    __pyx_1 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}
    __Pyx_Raise(PyExc_OSError, __pyx_1, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_2 = PyObject_IsTrue(__pyx_v_ret); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;}
  if (__pyx_2) {
    Py_INCREF(Py_True);
    __pyx_r = Py_True;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":258 */
  Py_INCREF(Py_False);
  __pyx_r = Py_False;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __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 = 262; 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___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 = 265; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; 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 = 265; 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 = 265; 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_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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":269 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; goto __pyx_L1;}
  Py_DECREF(__pyx_v_pkts);
  __pyx_v_pkts = __pyx_1;
  __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":270 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_dispatch); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n___add_pkts); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; 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 = 270; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":271 */
  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_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;
  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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":289 */
  __pyx_v_ctx.callback = ((void *)__pyx_v_callback);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":290 */
  __pyx_v_ctx.args = ((void *)__pyx_v_args);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":291 */
  __pyx_v_ctx.got_exc = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":292 */
  __pyx_1 = PyInt_AsLong(__pyx_v_cnt); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; 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)));

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":294 */
  __pyx_1 = __pyx_v_ctx.got_exc;
  if (__pyx_1) {

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":295 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_exc_info); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; 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 = 295; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_exc);
    __pyx_v_exc = __pyx_2;
    __pyx_2 = 0;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":296 */
    __pyx_3 = __Pyx_GetItemInt(__pyx_v_exc, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;}
    __pyx_2 = __Pyx_GetItemInt(__pyx_v_exc, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;}
    __pyx_4 = __Pyx_GetItemInt(__pyx_v_exc, 2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;}
    __Pyx_Raise(__pyx_3, __pyx_2, __pyx_4);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":297 */
  __pyx_3 = PyInt_FromLong(__pyx_v_n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; 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);
  __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_f_4pcap_4pcap_loop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_loop[] = "Processing packets with a user callback during a loop.\n        The loop can be exited when cnt value is reached\n        or with an exception, including KeyboardInterrupt.\n        \n        Arguments:\n\n        cnt      -- number of packets to process;\n                    0 or -1 to process all packets until an error occurs,\n                    EOF is reached;\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_cnt = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_args = 0;
  struct pcap_pkthdr *__pyx_v_hdr;
  char *__pyx_v_pkt;
  int __pyx_v_n;
  int __pyx_v_i;
  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[] = {"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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":316 */
  __pyx_v_i = 1;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":317 */
  pcap_ex_setup(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":318 */
  while (1) {
    __pyx_1 = 1;
    if (!__pyx_1) break;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":319 */
    Py_BEGIN_ALLOW_THREADS;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":320 */
    __pyx_v_n = pcap_ex_next(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_hdr),(&__pyx_v_pkt));

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":321 */
    Py_END_ALLOW_THREADS;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":322 */
    __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 = 323; goto __pyx_L1;}
      __pyx_4 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
      __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; 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 = 323; goto __pyx_L1;}
      __pyx_4 = PyNumber_Add(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; 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 = 323; 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 == 0);
    if (__pyx_2) {
      goto __pyx_L3;
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_n == (-1));
    if (__pyx_2) {
      __Pyx_Raise(PyExc_KeyboardInterrupt, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; goto __pyx_L1;}
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_n == (-2));
    if (__pyx_2) {
      goto __pyx_L3;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":331 */
    __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_3, __pyx_v_cnt, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}
    __pyx_2 = __pyx_2 == 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_2) {
      goto __pyx_L3;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":333 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __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_cnt);
  Py_DECREF(__pyx_v_callback);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static PyObject *__pyx_f_4pcap_4pcap_sendpacket(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_4pcap_sendpacket[] = "Send a raw network packet on the interface.";
static PyObject *__pyx_f_4pcap_4pcap_sendpacket(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_buf = 0;
  PyObject *__pyx_v_ret;
  PyObject *__pyx_r;
  char *__pyx_1;
  Py_ssize_t __pyx_2;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  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);
  __pyx_v_ret = Py_None; Py_INCREF(Py_None);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":337 */
  __pyx_1 = PyString_AsString(__pyx_v_buf); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}
  __pyx_2 = PyObject_Length(__pyx_v_buf); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(pcap_sendpacket(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,__pyx_2)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ret);
  __pyx_v_ret = __pyx_3;
  __pyx_3 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":338 */
  __pyx_3 = PyInt_FromLong((-1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_v_ret, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}
  __pyx_4 = __pyx_4 == 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {
    __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 = 339; goto __pyx_L1;}
    __Pyx_Raise(PyExc_OSError, __pyx_3, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":340 */
  __pyx_2 = PyObject_Length(__pyx_v_buf); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
  __pyx_3 = PyInt_FromSsize_t(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; 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.pcap.sendpacket");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ret);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_buf);
  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 = 344; 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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":350 */
  __pyx_1 = (pcap_stats(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_pstat)) < 0);
  if (__pyx_1) {
    __pyx_2 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
    __Pyx_Raise(PyExc_OSError, __pyx_2, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":352 */
  __pyx_2 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_recv); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;}
  __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_drop); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;}
  __pyx_4 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_ifdrop); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; 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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":355 */
  pcap_ex_setup(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":356 */
  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_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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":362 */
  while (1) {
    __pyx_1 = 1;
    if (!__pyx_1) break;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":363 */
    Py_BEGIN_ALLOW_THREADS;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":364 */
    __pyx_v_n = pcap_ex_next(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_hdr),(&__pyx_v_pkt));

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":365 */
    Py_END_ALLOW_THREADS;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":366 */
    __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 = 367; goto __pyx_L1;}
      __pyx_4 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}
      __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; 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 == 0);
    if (__pyx_2) {
      Py_INCREF(Py_None);
      __pyx_r = Py_None;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_n == (-1));
    if (__pyx_2) {
      __Pyx_Raise(PyExc_KeyboardInterrupt, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;}
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_n == (-2));
    if (__pyx_2) {
      __Pyx_Raise(PyExc_StopIteration, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; 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);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":377 */
  __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:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":379 */
  __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:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":381 */
  __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 = 385; 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;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":390 */
  __pyx_v_p = pcap_ex_lookupdev(__pyx_v_ebuf);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":391 */
  __pyx_1 = (__pyx_v_p == NULL);
  if (__pyx_1) {
    __pyx_2 = PyString_FromString(__pyx_v_ebuf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}
    __Pyx_Raise(PyExc_OSError, __pyx_2, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":393 */
  __pyx_2 = PyString_FromString(__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; 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);
  __Pyx_AddTraceback("pcap.lookupdev");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_4pcap_findalldevs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_findalldevs[] = "Return a list of capture devices.";
static PyObject *__pyx_f_4pcap_findalldevs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  pcap_if_t *__pyx_v_devs;
  pcap_if_t *__pyx_v_curr;
  char __pyx_v_ebuf[256];
  PyObject *__pyx_v_status;
  PyObject *__pyx_v_retval;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  long __pyx_4;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  __pyx_v_status = Py_None; Py_INCREF(Py_None);
  __pyx_v_retval = Py_None; Py_INCREF(Py_None);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":400 */
  __pyx_1 = PyInt_FromLong(pcap_findalldevs((&__pyx_v_devs),__pyx_v_ebuf)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
  Py_DECREF(__pyx_v_status);
  __pyx_v_status = __pyx_1;
  __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":401 */
  __pyx_2 = PyObject_IsTrue(__pyx_v_status); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;}
  if (__pyx_2) {
    __pyx_1 = PyString_FromString(__pyx_v_ebuf); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
    __pyx_1 = 0;
    __pyx_1 = PyObject_CallObject(PyExc_OSError, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":403 */
  __pyx_3 = PyList_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; goto __pyx_L1;}
  Py_DECREF(__pyx_v_retval);
  __pyx_v_retval = __pyx_3;
  __pyx_3 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":404 */
  __pyx_2 = (!(__pyx_v_devs != 0));
  if (__pyx_2) {
    Py_INCREF(__pyx_v_retval);
    __pyx_r = __pyx_v_retval;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":406 */
  __pyx_v_curr = __pyx_v_devs;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":407 */
  while (1) {
    __pyx_4 = 1;
    if (!__pyx_4) break;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":408 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_retval, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(__pyx_v_curr->name); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":409 */
    __pyx_2 = (!(__pyx_v_curr->next != 0));
    if (__pyx_2) {
      goto __pyx_L5;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":411 */
    __pyx_v_curr = __pyx_v_curr->next;
  }
  __pyx_L5:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":412 */
  pcap_freealldevs(__pyx_v_devs);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":413 */
  Py_INCREF(__pyx_v_retval);
  __pyx_r = __pyx_v_retval;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("pcap.findalldevs");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_status);
  Py_DECREF(__pyx_v_retval);
  return __pyx_r;
}

static PyObject *__pyx_f_4pcap_lookupnet(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4pcap_lookupnet[] = "\n    Return the address and the netmask of a given device\n    as network-byteorder integers.\n    ";
static PyObject *__pyx_f_4pcap_lookupnet(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_dev;
  unsigned int __pyx_v_netp;
  unsigned int __pyx_v_maskp;
  char __pyx_v_ebuf[256];
  PyObject *__pyx_v_status;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"dev",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "s", __pyx_argnames, &__pyx_v_dev)) return 0;
  __pyx_v_status = Py_None; Py_INCREF(Py_None);

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":424 */
  __pyx_1 = PyInt_FromLong(pcap_lookupnet(__pyx_v_dev,(&__pyx_v_netp),(&__pyx_v_maskp),__pyx_v_ebuf)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; goto __pyx_L1;}
  Py_DECREF(__pyx_v_status);
  __pyx_v_status = __pyx_1;
  __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":425 */
  __pyx_2 = PyObject_IsTrue(__pyx_v_status); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}
  if (__pyx_2) {
    __pyx_1 = PyString_FromString(__pyx_v_ebuf); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
    __pyx_1 = 0;
    __pyx_1 = PyObject_CallObject(PyExc_OSError, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":427 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_struct); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_pack); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_netp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  Py_INCREF(__pyx_n_I);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_I);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
  __pyx_3 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_struct); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  __pyx_4 = PyObject_GetAttr(__pyx_1, __pyx_n_pack); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyLong_FromUnsignedLong(__pyx_v_maskp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  Py_INCREF(__pyx_n_I);
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_n_I);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);
  __pyx_1 = 0;
  __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_1);
  __pyx_3 = 0;
  __pyx_1 = 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_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("pcap.lookupnet");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_status);
  return __pyx_r;
}

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 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, /*tp_flags*/
  "bpf(filter, dlt=DLT_RAW) -> BPF filter object", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*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 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},
  {"__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},
  {"sendpacket", (PyCFunction)__pyx_f_4pcap_4pcap_sendpacket, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_4pcap_sendpacket},
  {"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_k13, 0},
  {"snaplen", __pyx_getprop_4pcap_4pcap_snaplen, 0, __pyx_k14, 0},
  {"dloff", __pyx_getprop_4pcap_4pcap_dloff, 0, __pyx_k15, 0},
  {"filter", __pyx_getprop_4pcap_4pcap_filter, 0, __pyx_k16, 0},
  {"fd", __pyx_getprop_4pcap_4pcap_fd, 0, __pyx_k17, 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, /*tp_flags*/
  "pcap(name=None, snaplen=65535, promisc=True, timeout_ms=None, 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    timeout_ms -- requests for the next packet will return None if the timeout\n                  (in milliseconds) is reached and no packets were received\n                  (Default: no timeout)  \n    immediate -- disable buffering, if possible\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*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},
  {"findalldevs", (PyCFunction)__pyx_f_4pcap_findalldevs, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_findalldevs},
  {"lookupnet", (PyCFunction)__pyx_f_4pcap_lookupnet, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_lookupnet},
  {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;
  __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;};
  Py_INCREF(__pyx_m);
  __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_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 = 142; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "bpf", (PyObject *)&__pyx_type_4pcap_bpf) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; 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 = 160; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "pcap", (PyObject *)&__pyx_type_4pcap_pcap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;}
  __pyx_ptype_4pcap_pcap = &__pyx_type_4pcap_pcap;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":13 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n___author__, __pyx_k18p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":14 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n___copyright__, __pyx_k20p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":15 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n___license__, __pyx_k22p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":16 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n___url__, __pyx_k24p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":17 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n___version__, __pyx_k26p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;}

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":19 */
  __pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_sys, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":20 */
  __pyx_1 = __Pyx_Import(__pyx_n_struct, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_struct, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":115 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_NULL, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":116 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_EN10MB, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":117 */
  __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_EN3MB, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":118 */
  __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_AX25, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":119 */
  __pyx_1 = PyInt_FromLong(4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PRONET, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":120 */
  __pyx_1 = PyInt_FromLong(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_CHAOS, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":121 */
  __pyx_1 = PyInt_FromLong(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_IEEE802, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":122 */
  __pyx_1 = PyInt_FromLong(7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_ARCNET, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":123 */
  __pyx_1 = PyInt_FromLong(8); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_SLIP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":124 */
  __pyx_1 = PyInt_FromLong(9); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PPP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":125 */
  __pyx_1 = PyInt_FromLong(10); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_FDDI, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":127 */
  __pyx_1 = PyInt_FromLong(113); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_LINUX_SLL, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":129 */
  __pyx_1 = PyInt_FromLong(117); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PFLOG, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":130 */
  __pyx_1 = PyInt_FromLong(18); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PFSYNC, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":131 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_platform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; 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 = 131; 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 = 131; 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 = 131; 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 = 131; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; 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) {

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":132 */
    __pyx_2 = PyInt_FromLong(12); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
    if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_LOOP, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":133 */
    __pyx_3 = PyInt_FromLong(14); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
    if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_RAW, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":135 */
    __pyx_1 = PyInt_FromLong(108); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; goto __pyx_L1;}
    if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_LOOP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/tsally/src/pypcap-read-only/pcap.pyx":136 */
    __pyx_2 = PyInt_FromLong(12); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L1;}
    if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_RAW, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L3:;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":138 */
  __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_NULL); 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 = 138; 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 = 138; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(14); 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 = 138; 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 = 138; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(22); 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 = 138; 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 = 138; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(6); 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 = 138; 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 = 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 = 138; 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 = 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 = 138; 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 = 139; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(21); 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 = 138; 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 = 139; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(48); 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 = 138; 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 = 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 = 138; 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 = 140; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}
  if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; 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 = 140; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}
  if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; 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 = 140; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(16); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}
  if (PyDict_SetItem(__pyx_3, __pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; 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 = 138; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":145 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_RAW); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}
  __pyx_d1 = __pyx_1;
  __pyx_1 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":181 */
  Py_INCREF(Py_None);
  __pyx_d2 = Py_None;
  __pyx_2 = PyInt_FromLong(65535); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_d3 = __pyx_2;
  __pyx_2 = 0;
  Py_INCREF(Py_True);
  __pyx_d4 = Py_True;
  __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
  __pyx_d5 = __pyx_3;
  __pyx_3 = 0;
  Py_INCREF(Py_False);
  __pyx_d6 = Py_False;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":236 */
  __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;}
  __pyx_d7 = __pyx_5;
  __pyx_5 = 0;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":247 */
  Py_INCREF(Py_True);
  __pyx_d8 = Py_True;

  /* "/home/tsally/src/pypcap-read-only/pcap.pyx":415 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __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_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 PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i) {
    PyTypeObject *t = o->ob_type;
    PyObject *r;
    if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
        r = PySequence_GetItem(o, i);
    else {
        PyObject *j = PyInt_FromLong(i);
        if (!j)
            return 0;
        r = PyObject_GetItem(o, j);
        Py_DECREF(j);
    }
    return r;
}

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 int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        if (t->i)
            PyString_InternInPlace(t->p);
        ++t;
    }
    return 0;
}

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;
}

#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);
}
