From be8ddc621977dcebbaa11f85136b5e50c720ee8b Mon Sep 17 00:00:00 2001 From: Matt Fox Date: Fri, 14 Oct 2011 14:14:25 -0700 Subject: [PATCH] Specify any callback, no more use by inheritance Change version to 0.3.0 Update and bugfixes in readme.rst --- README.rst | 76 +- netfilterqueue.c | 1750 ++++++++++++++++++++++++-------------------- netfilterqueue.pxd | 5 +- netfilterqueue.pyx | 42 +- setup.py | 2 +- 5 files changed, 1014 insertions(+), 861 deletions(-) diff --git a/README.rst b/README.rst index ae56c0e..1a08a15 100644 --- a/README.rst +++ b/README.rst @@ -12,17 +12,16 @@ Example The following script prints a short description of each packet before accepting it. :: - from netfilterqueue import QueueHandler + from netfilterqueue import NetfilterQueue - class PacketPrinter(QueueHandler): - def handle(self, packet): - print packet - packet.accept() + def print_and_accept(pkt): + print pkt + pkt.accept() - p = PacketPrinter() - p.bind(1) + nfqueue = NetfilterQueue() + nfqueue.bind(1, print_and_accept) try: - p.run() + nfqueue.run() except KeyboardInterrupt: print @@ -43,7 +42,7 @@ NetfilterQueue is a C extention module that links against libnetfilter_queue. Be On Debian or Ubuntu, install these files with:: - sudo apt-get install build-essential python-dev libnetfilter-queue-dev + apt-get install build-essential python-dev libnetfilter-queue-dev From PyPI --------- @@ -57,12 +56,12 @@ From source To install from source:: - wget http://pypi.python.org/packages/source/N/NetfilterQueue/NetfilterQueue-0.2.tar.gz - tar -xvzf NetfilterQueue-0.2.tar.gz - cd NetfilterQueue-0.2 + wget http://pypi.python.org/packages/source/N/NetfilterQueue/NetfilterQueue-0.3.tar.gz + tar -xvzf NetfilterQueue-0.3.tar.gz + cd NetfilterQueue-0.3 python setup.py install -Setup will use Cython if it is installed, regenerating the .c source from the .pyx before compiling the .so. +If Cython is installed, Distutils will use it to regenerate the .c source from the .pyx. It will then compile the .c into a .so. API === @@ -74,35 +73,32 @@ API ``NetfilterQueue.COPY_PACKET`` These constants specify how much of the packet should be given to the script- nothing, metadata, or the whole packet. -QueueHandler objects --------------------- +NetfilterQueue objects +---------------------- -You should define a class that inherits from QueueHandler and implenents the -handle() method. Handle() is called for each packet that appears in the queue. +A NetfilterQueue object represents a single queue. Configure your queue with +a call to ``bind``, then start receiving packets with a call to ``run``. -``QueueHandler.bind(queue_num[, max_len[, mode[, range]]])`` +``QueueHandler.bind(queue_num, callback[, max_len[, mode[, range]]])`` Create and bind to the queue. ``queue_num`` must match the number in your - iptables rule. ``max_len`` sets the largest number of packets that can be - in the queue; new packets are dropped if the size of the queue reaches this - number. ``mode`` determines how much of the packet data is provided to - your script. Use the constants above. ``range`` defines how many bytes of - the packet you want to get. For example, if you only want the source and - destination IPs of a IPv4 packet, ``range`` could be 20. + iptables rule. ``callback`` is a function or method that takes one + argument, a Packet object (see below). ``max_len`` sets the largest number + of packets that can be in the queue; new packets are dropped if the size of + the queue reaches this number. ``mode`` determines how much of the packet + data is provided to your script. Use the constants above. ``range`` defines + how many bytes of the packet you want to get. For example, if you only want + the source and destination IPs of a IPv4 packet, ``range`` could be 20. ``QueueHandler.unbind()`` Remove the queue. Packets matched by your iptables rule will be dropped. ``QueueHandler.run()`` - Begin accepting packets. - -``QueueHandler.handle(packet)`` - Handle a single packet from the queue. You must call either - ``packet.accept()`` or ``packet.drop()``. + Send packets to your callback. This method blocks. Packet objects -------------- -Objects of this type are passed to your handle() method. +Objects of this type are passed to your callback. ``Packet.get_payload()`` Return the packet's payload as a string. @@ -118,11 +114,22 @@ Objects of this type are passed to your handle() method. ``Packet.drop()`` Drop the packet. + +Callback objects +---------------- + +Your callback can be function or a method and must accept one argument, a +Packet object. You must call either Packet.accept() or Packet.drop() before +returning. + +``callback(packet)`` or ``callback(self, packet)`` + Handle a single packet from the queue. You must call either + ``packet.accept()`` or ``packet.drop()``. Usage ===== -To route packets to the queue:: +To send packets to the queue:: iptables -I -j NFQUEUE --queue-num @@ -133,7 +140,7 @@ For example:: The only special part of the rule is the target. Rules can have any match and can be added to any table or chain. -Valid queue numbers are integers from 0 to 65,536 inclusive. +Valid queue numbers are integers from 0 to 65,535 inclusive. To view libnetfilter_queue stats, refer to /proc/net/netfilter/nfnetlink_queue:: @@ -158,7 +165,7 @@ The fields are: 8. Total number of packets sent to queue -9. Libnetfilter_queue internal use +9. Something for libnetfilter_queue's internal use Limitations =========== @@ -190,6 +197,5 @@ License ======= Copyright (c) 2011, Kerkhoff Technologies, Inc. -All rights reserved. -Licensed under `BSD `_ +`MIT licensed `_ diff --git a/netfilterqueue.c b/netfilterqueue.c index bb1c5b5..77b8c15 100644 --- a/netfilterqueue.c +++ b/netfilterqueue.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.14.1 on Fri May 13 09:28:25 2011 */ +/* Generated by Cython 0.15.1 on Fri Oct 14 08:35:07 2011 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -46,7 +46,7 @@ #define PY_SSIZE_T_MIN INT_MIN #define PY_FORMAT_SIZE_T "" #define PyInt_FromSsize_t(z) PyInt_FromLong(z) - #define PyInt_AsSsize_t(o) PyInt_AsLong(o) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) #define PyNumber_Index(o) PyNumber_Int(o) #define PyIndex_Check(o) PyNumber_Check(o) #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) @@ -159,6 +159,15 @@ #define PyBoolObject PyLongObject #endif +#if PY_VERSION_HEX < 0x03020000 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif + #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) @@ -209,16 +218,19 @@ #define __Pyx_DOCSTR(n) (n) #endif -#ifdef __cplusplus -#define __PYX_EXTERN_C extern "C" -#else -#define __PYX_EXTERN_C extern +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include +#define __PYX_HAVE__netfilterqueue #define __PYX_HAVE_API__netfilterqueue #include "sys/types.h" #include "netinet/ip.h" @@ -228,6 +240,9 @@ #include "libnetfilter_queue/linux_nfnetlink_queue.h" #include "libnetfilter_queue/libnetfilter_queue.h" #include "sys/socket.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS @@ -270,6 +285,7 @@ typedef struct {PyObject **p; char *s; const long n; const char* encoding; const #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s) #define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s)) +#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); @@ -282,17 +298,17 @@ static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); #ifdef __GNUC__ -/* Test for GCC > 2.95 */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#else /* __GNUC__ > 2 ... */ -#define likely(x) (x) -#define unlikely(x) (x) -#endif /* __GNUC__ > 2 ... */ + /* Test for GCC > 2.95 */ + #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #else /* __GNUC__ > 2 ... */ + #define likely(x) (x) + #define unlikely(x) (x) + #endif /* __GNUC__ > 2 ... */ #else /* __GNUC__ */ -#define likely(x) (x) -#define unlikely(x) (x) + #define likely(x) (x) + #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; @@ -310,7 +326,9 @@ static const char *__pyx_f[] = { "netfilterqueue.pxd", }; -/* Type declarations */ +/*--- Type declarations ---*/ +struct __pyx_obj_14netfilterqueue_Packet; +struct __pyx_obj_14netfilterqueue_NetfilterQueue; /* "netfilterqueue.pxd":19 * @@ -319,7 +337,6 @@ static const char *__pyx_f[] = { * IPPROTO_IP = 0 # Dummy protocol for TCP. * IPPROTO_HOPOPTS = 0 # IPv6 Hop-by-Hop options. */ - enum { __pyx_e_14netfilterqueue_IPPROTO_IP = 0, __pyx_e_14netfilterqueue_IPPROTO_HOPOPTS = 0, @@ -358,7 +375,6 @@ enum { * PF_INET = 2 * PF_INET6 = 10 */ - enum { __pyx_e_14netfilterqueue_PF_INET = 2, __pyx_e_14netfilterqueue_PF_INET6 = 10 @@ -371,7 +387,6 @@ enum { * NF_DROP * NF_ACCEPT */ - enum { /* "netfilterqueue.pxd":149 @@ -390,22 +405,6 @@ enum { __pyx_e_14netfilterqueue_NF_MAX_VERDICT = __pyx_e_14netfilterqueue_NF_STOP }; -/* "netfilterqueue.pxd":186 - * cpdef drop(self) - * - * cdef class QueueHandler: # <<<<<<<<<<<<<< - * cdef nfq_handle *h # Handle to NFQueue library - * cdef nfq_q_handle *qh # A handle to the queue - */ - -struct __pyx_obj_14netfilterqueue_QueueHandler { - PyObject_HEAD - struct nfq_handle *h; - struct nfq_q_handle *qh; - u_int16_t af; - PyObject *packet_copy_size; -}; - /* "netfilterqueue.pxd":151 * NF_MAX_VERDICT = NF_STOP * @@ -413,7 +412,6 @@ struct __pyx_obj_14netfilterqueue_QueueHandler { * cdef nfq_q_handle *_qh * cdef nfq_data *_nfa */ - struct __pyx_obj_14netfilterqueue_Packet { PyObject_HEAD struct __pyx_vtabstruct_14netfilterqueue_Packet *__pyx_vtab; @@ -433,7 +431,25 @@ struct __pyx_obj_14netfilterqueue_Packet { }; -/* "netfilterqueue.pyx":23 +/* "netfilterqueue.pxd":186 + * cpdef drop(self) + * + * cdef class NetfilterQueue: # <<<<<<<<<<<<<< + * cdef object user_callback # User callback + * cdef nfq_handle *h # Handle to NFQueue library + */ +struct __pyx_obj_14netfilterqueue_NetfilterQueue { + PyObject_HEAD + PyObject *user_callback; + struct nfq_handle *h; + struct nfq_q_handle *qh; + u_int16_t af; + PyObject *packet_copy_size; +}; + + + +/* "netfilterqueue.pyx":34 * return 1 * * cdef class Packet: # <<<<<<<<<<<<<< @@ -466,40 +482,42 @@ static struct __pyx_vtabstruct_14netfilterqueue_Packet *__pyx_vtabptr_14netfilte void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); - end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; - } - #define __Pyx_RefNannySetupContext(name) void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; + #define __Pyx_RefNannySetupContext(name) __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #define __Pyx_RefNannyFinishContext() __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else + #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) #endif /* CYTHON_REFNANNY */ -#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0) -#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0) static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ +#ifndef __PYX_FORCE_INIT_THREADS + #if PY_VERSION_HEX < 0x02040200 + #define __PYX_FORCE_INIT_THREADS 1 + #else + #define __PYX_FORCE_INIT_THREADS 0 + #endif +#endif + static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ @@ -509,7 +527,7 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { PyObject* value; @@ -546,9 +564,6 @@ static void __Pyx_RaiseDoubleKeywordsError( static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/ -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); /*proto*/ - static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_u_int32_t(u_int32_t); static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_u_int16_t(u_int16_t); @@ -559,14 +574,6 @@ static CYTHON_INLINE u_int32_t __Pyx_PyInt_from_py_u_int32_t(PyObject *); static CYTHON_INLINE u_int16_t __Pyx_PyInt_from_py_u_int16_t(PyObject *); -#ifndef __PYX_FORCE_INIT_THREADS - #if PY_VERSION_HEX < 0x02040200 - #define __PYX_FORCE_INIT_THREADS 1 - #else - #define __PYX_FORCE_INIT_THREADS 0 - #endif -#endif - static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); @@ -599,24 +606,28 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); -static void __Pyx_WriteUnraisable(const char *name); /*proto*/ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename); /*proto*/ static CYTHON_INLINE u_int8_t __Pyx_PyInt_from_py_u_int8_t(PyObject *); +static int __Pyx_check_binary_version(void); + static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ -static void __Pyx_AddTraceback(const char *funcname); /*proto*/ +static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno, + int __pyx_lineno, const char *__pyx_filename); /*proto*/ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ -/* Module declarations from netfilterqueue */ +/* Module declarations from 'netfilterqueue' */ static PyTypeObject *__pyx_ptype_14netfilterqueue_Packet = 0; -static PyTypeObject *__pyx_ptype_14netfilterqueue_QueueHandler = 0; +static PyTypeObject *__pyx_ptype_14netfilterqueue_NetfilterQueue = 0; static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *, struct nfgenmsg *, struct nfq_data *, void *); /*proto*/ #define __Pyx_MODULE_NAME "netfilterqueue" -static int __pyx_module_is_main_netfilterqueue = 0; +int __pyx_module_is_main_netfilterqueue = 0; -/* Implementation of netfilterqueue */ +/* Implementation of 'netfilterqueue' */ static PyObject *__pyx_builtin_OSError; static PyObject *__pyx_builtin_RuntimeWarning; static char __pyx_k_1[] = "Unknown protocol"; @@ -627,49 +638,49 @@ static char __pyx_k_7[] = "Failed to open NFQueue."; static char __pyx_k_9[] = "Failed to bind family %s. Are you root?"; static char __pyx_k_12[] = "Failed to create queue %s."; static char __pyx_k_13[] = "Failed to set packet copy mode."; -static char __pyx_k_15[] = "DEFAULT_MAX_QUEUELEN"; -static char __pyx_k_16[] = "BBN-RCC-MON"; -static char __pyx_k_17[] = "NVP-II"; -static char __pyx_k_18[] = "DCN-MEAS"; -static char __pyx_k_19[] = "XNS-IDP"; -static char __pyx_k_20[] = "TRUNK-1"; -static char __pyx_k_21[] = "TRUNK-2"; -static char __pyx_k_22[] = "LEAF-1"; -static char __pyx_k_23[] = "LEAF-2"; -static char __pyx_k_24[] = "ISO-TP4"; -static char __pyx_k_25[] = "MFE-NSP"; -static char __pyx_k_26[] = "MERIT-INP"; -static char __pyx_k_27[] = "IDPR-CMTP"; -static char __pyx_k_28[] = "TP++"; -static char __pyx_k_29[] = "IPv6-Route"; -static char __pyx_k_30[] = "IPv6-Frag"; -static char __pyx_k_31[] = "I-NLSP"; -static char __pyx_k_32[] = "IPv6-ICMP"; -static char __pyx_k_33[] = "IPv6-NoNxt"; -static char __pyx_k_34[] = "IPv6-Opts"; -static char __pyx_k_35[] = "any host internal protocol"; -static char __pyx_k_36[] = "any local network"; -static char __pyx_k_37[] = "SAT-EXPAK"; -static char __pyx_k_38[] = "any distributed file system"; -static char __pyx_k_39[] = "SAT-MON"; -static char __pyx_k_40[] = "BR-SAT-MON"; -static char __pyx_k_41[] = "SUN-ND"; -static char __pyx_k_42[] = "WB-MON"; -static char __pyx_k_43[] = "WB-EXPAK"; -static char __pyx_k_44[] = "ISO-IP"; -static char __pyx_k_45[] = "SECURE-VMTP"; -static char __pyx_k_46[] = "NSFNET-IGP"; -static char __pyx_k_47[] = "Sprite-RPC"; -static char __pyx_k_48[] = "AX.25"; -static char __pyx_k_49[] = "SCC-SP"; -static char __pyx_k_50[] = "any private encryption scheme"; -static char __pyx_k_51[] = "A/N"; -static char __pyx_k_52[] = "Compaq-Peer"; -static char __pyx_k_53[] = "IPX-in-IP"; -static char __pyx_k_54[] = "any 0-hop protocol"; -static char __pyx_k_55[] = "RSVP-E2E-IGNORE"; -static char __pyx_k_56[] = "MPLS-in-IP"; -static char __pyx_k__h[] = "h"; +static char __pyx_k_15[] = "\nBind to a Linux netfilter queue. Send packets to a user-specified callback \nfunction.\n\nCopyright: (c) 2011 Kerkhoff Technologies Inc.\nLicense: GPL\n"; +static char __pyx_k_17[] = "DEFAULT_MAX_QUEUELEN"; +static char __pyx_k_18[] = "BBN-RCC-MON"; +static char __pyx_k_19[] = "NVP-II"; +static char __pyx_k_20[] = "DCN-MEAS"; +static char __pyx_k_21[] = "XNS-IDP"; +static char __pyx_k_22[] = "TRUNK-1"; +static char __pyx_k_23[] = "TRUNK-2"; +static char __pyx_k_24[] = "LEAF-1"; +static char __pyx_k_25[] = "LEAF-2"; +static char __pyx_k_26[] = "ISO-TP4"; +static char __pyx_k_27[] = "MFE-NSP"; +static char __pyx_k_28[] = "MERIT-INP"; +static char __pyx_k_29[] = "IDPR-CMTP"; +static char __pyx_k_30[] = "TP++"; +static char __pyx_k_31[] = "IPv6-Route"; +static char __pyx_k_32[] = "IPv6-Frag"; +static char __pyx_k_33[] = "I-NLSP"; +static char __pyx_k_34[] = "IPv6-ICMP"; +static char __pyx_k_35[] = "IPv6-NoNxt"; +static char __pyx_k_36[] = "IPv6-Opts"; +static char __pyx_k_37[] = "any host internal protocol"; +static char __pyx_k_38[] = "any local network"; +static char __pyx_k_39[] = "SAT-EXPAK"; +static char __pyx_k_40[] = "any distributed file system"; +static char __pyx_k_41[] = "SAT-MON"; +static char __pyx_k_42[] = "BR-SAT-MON"; +static char __pyx_k_43[] = "SUN-ND"; +static char __pyx_k_44[] = "WB-MON"; +static char __pyx_k_45[] = "WB-EXPAK"; +static char __pyx_k_46[] = "ISO-IP"; +static char __pyx_k_47[] = "SECURE-VMTP"; +static char __pyx_k_48[] = "NSFNET-IGP"; +static char __pyx_k_49[] = "Sprite-RPC"; +static char __pyx_k_50[] = "AX.25"; +static char __pyx_k_51[] = "SCC-SP"; +static char __pyx_k_52[] = "any private encryption scheme"; +static char __pyx_k_53[] = "A/N"; +static char __pyx_k_54[] = "Compaq-Peer"; +static char __pyx_k_55[] = "IPX-in-IP"; +static char __pyx_k_56[] = "any 0-hop protocol"; +static char __pyx_k_57[] = "RSVP-E2E-IGNORE"; +static char __pyx_k_58[] = "MPLS-in-IP"; static char __pyx_k__AH[] = "AH"; static char __pyx_k__FC[] = "FC"; static char __pyx_k__IL[] = "IL"; @@ -677,8 +688,6 @@ static char __pyx_k__IP[] = "IP"; static char __pyx_k__SM[] = "SM"; static char __pyx_k__ST[] = "ST"; static char __pyx_k__af[] = "af"; -static char __pyx_k__id[] = "id"; -static char __pyx_k__qh[] = "qh"; static char __pyx_k__3PC[] = "3PC"; static char __pyx_k__BNA[] = "BNA"; static char __pyx_k__CBT[] = "CBT"; @@ -716,7 +725,6 @@ static char __pyx_k__UDP[] = "UDP"; static char __pyx_k__UTI[] = "UTI"; static char __pyx_k__WSN[] = "WSN"; static char __pyx_k__XTP[] = "XTP"; -static char __pyx_k___qh[] = "_qh"; static char __pyx_k__get[] = "get"; static char __pyx_k__ARIS[] = "ARIS"; static char __pyx_k__CFTP[] = "CFTP"; @@ -755,10 +763,7 @@ static char __pyx_k__VISA[] = "VISA"; static char __pyx_k__VMTP[] = "VMTP"; static char __pyx_k__VRRP[] = "VRRP"; static char __pyx_k__XNET[] = "XNET"; -static char __pyx_k___hdr[] = "_hdr"; -static char __pyx_k___nfa[] = "_nfa"; static char __pyx_k__drop[] = "drop"; -static char __pyx_k__hook[] = "hook"; static char __pyx_k__mode[] = "mode"; static char __pyx_k__ARGUS[] = "ARGUS"; static char __pyx_k__CHAOS[] = "CHAOS"; @@ -776,47 +781,32 @@ static char __pyx_k__IPComp[] = "IPComp"; static char __pyx_k__MOBILE[] = "MOBILE"; static char __pyx_k__NETBLT[] = "NETBLT"; static char __pyx_k__accept[] = "accept"; -static char __pyx_k__handle[] = "handle"; -static char __pyx_k__tv_sec[] = "tv_sec"; static char __pyx_k__ETHERIP[] = "ETHERIP"; static char __pyx_k__OSError[] = "OSError"; static char __pyx_k__OSPFIGP[] = "OSPFIGP"; static char __pyx_k__UDPLite[] = "UDPLite"; +static char __pyx_k__VERSION[] = "VERSION"; static char __pyx_k__max_len[] = "max_len"; -static char __pyx_k__payload[] = "payload"; -static char __pyx_k__tv_usec[] = "tv_usec"; -static char __pyx_k__verdict[] = "verdict"; static char __pyx_k__Mobility[] = "Mobility"; static char __pyx_k__Reserved[] = "Reserved"; static char __pyx_k__SSCOPMCE[] = "SSCOPMCE"; static char __pyx_k____main__[] = "__main__"; static char __pyx_k____test__[] = "__test__"; -static char __pyx_k__protocol[] = "protocol"; static char __pyx_k__set_mark[] = "set_mark"; static char __pyx_k__COPY_META[] = "COPY_META"; static char __pyx_k__COPY_NONE[] = "COPY_NONE"; static char __pyx_k__KRYPTOLAN[] = "KRYPTOLAN"; static char __pyx_k__PROTOCOLS[] = "PROTOCOLS"; -static char __pyx_k__packet_id[] = "packet_id"; static char __pyx_k__queue_num[] = "queue_num"; -static char __pyx_k__timestamp[] = "timestamp"; static char __pyx_k__COPY_PACKET[] = "COPY_PACKET"; -static char __pyx_k___given_mark[] = "_given_mark"; -static char __pyx_k__hw_protocol[] = "hw_protocol"; -static char __pyx_k__payload_len[] = "payload_len"; -static char __pyx_k___mark_is_set[] = "_mark_is_set"; -static char __pyx_k__set_nfq_data[] = "set_nfq_data"; static char __pyx_k__get_timestamp[] = "get_timestamp"; +static char __pyx_k__user_callback[] = "user_callback"; static char __pyx_k__RuntimeWarning[] = "RuntimeWarning"; -static char __pyx_k___given_payload[] = "_given_payload"; -static char __pyx_k___verdict_is_set[] = "_verdict_is_set"; static char __pyx_k__get_payload_len[] = "get_payload_len"; static PyObject *__pyx_kp_s_1; static PyObject *__pyx_kp_s_12; static PyObject *__pyx_kp_s_13; -static PyObject *__pyx_n_s_15; -static PyObject *__pyx_kp_s_16; -static PyObject *__pyx_kp_s_17; +static PyObject *__pyx_n_s_17; static PyObject *__pyx_kp_s_18; static PyObject *__pyx_kp_s_19; static PyObject *__pyx_kp_s_2; @@ -859,6 +849,8 @@ static PyObject *__pyx_kp_s_53; static PyObject *__pyx_kp_s_54; static PyObject *__pyx_kp_s_55; static PyObject *__pyx_kp_s_56; +static PyObject *__pyx_kp_s_57; +static PyObject *__pyx_kp_s_58; static PyObject *__pyx_kp_s_7; static PyObject *__pyx_kp_s_9; static PyObject *__pyx_kp_s__3PC; @@ -960,6 +952,7 @@ static PyObject *__pyx_n_s__TTP; static PyObject *__pyx_n_s__UDP; static PyObject *__pyx_n_s__UDPLite; static PyObject *__pyx_n_s__UTI; +static PyObject *__pyx_n_s__VERSION; static PyObject *__pyx_n_s__VINES; static PyObject *__pyx_n_s__VISA; static PyObject *__pyx_n_s__VMTP; @@ -969,40 +962,19 @@ static PyObject *__pyx_n_s__XNET; static PyObject *__pyx_n_s__XTP; static PyObject *__pyx_n_s____main__; static PyObject *__pyx_n_s____test__; -static PyObject *__pyx_n_s___given_mark; -static PyObject *__pyx_n_s___given_payload; -static PyObject *__pyx_n_s___hdr; -static PyObject *__pyx_n_s___mark_is_set; -static PyObject *__pyx_n_s___nfa; -static PyObject *__pyx_n_s___qh; -static PyObject *__pyx_n_s___verdict_is_set; static PyObject *__pyx_n_s__accept; static PyObject *__pyx_n_s__af; static PyObject *__pyx_n_s__drop; static PyObject *__pyx_n_s__get; static PyObject *__pyx_n_s__get_payload_len; static PyObject *__pyx_n_s__get_timestamp; -static PyObject *__pyx_n_s__h; -static PyObject *__pyx_n_s__handle; -static PyObject *__pyx_n_s__hook; -static PyObject *__pyx_n_s__hw_protocol; -static PyObject *__pyx_n_s__id; static PyObject *__pyx_n_s__manet; static PyObject *__pyx_n_s__max_len; static PyObject *__pyx_n_s__mode; -static PyObject *__pyx_n_s__packet_id; -static PyObject *__pyx_n_s__payload; -static PyObject *__pyx_n_s__payload_len; -static PyObject *__pyx_n_s__protocol; -static PyObject *__pyx_n_s__qh; static PyObject *__pyx_n_s__queue_num; static PyObject *__pyx_n_s__range; static PyObject *__pyx_n_s__set_mark; -static PyObject *__pyx_n_s__set_nfq_data; -static PyObject *__pyx_n_s__timestamp; -static PyObject *__pyx_n_s__tv_sec; -static PyObject *__pyx_n_s__tv_usec; -static PyObject *__pyx_n_s__verdict; +static PyObject *__pyx_n_s__user_callback; static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_2; @@ -1152,74 +1124,95 @@ static PyObject *__pyx_k_tuple_4; static PyObject *__pyx_k_tuple_6; static PyObject *__pyx_k_tuple_8; static PyObject *__pyx_k_tuple_14; +static PyObject *__pyx_k_tuple_16; -/* "netfilterqueue.pyx":15 +/* "netfilterqueue.pyx":23 * DEF MaxCopySize = BufferSize - MetadataSize * * cdef int global_callback(nfq_q_handle *qh, nfgenmsg *nfmsg, # <<<<<<<<<<<<<< * nfq_data *nfa, void *data) with gil: - * """Create an Packet and pass it to appropriate Python/Cython callback.""" + * """Create a Packet and pass it to appropriate Python/Cython callback.""" */ -static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_v_qh, struct nfgenmsg *__pyx_v_nfmsg, struct nfq_data *__pyx_v_nfa, void *__pyx_v_data) { - struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_packet; +static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_v_qh, struct nfgenmsg *__pyx_v_nfmsg, struct nfq_data *__pyx_v_nfa, void *__pyx_v_data) { + struct __pyx_obj_14netfilterqueue_NetfilterQueue *__pyx_v_nfqueue = 0; + PyObject *__pyx_v_user_callback = 0; + struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_packet = NULL; int __pyx_r; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; #ifdef WITH_THREAD - PyGILState_STATE _save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("global_callback"); - __pyx_v_packet = ((struct __pyx_obj_14netfilterqueue_Packet *)Py_None); __Pyx_INCREF(Py_None); - /* "netfilterqueue.pyx":18 + /* "netfilterqueue.pyx":26 * nfq_data *nfa, void *data) with gil: - * """Create an Packet and pass it to appropriate Python/Cython callback.""" + * """Create a Packet and pass it to appropriate Python/Cython callback.""" + * cdef NetfilterQueue nfqueue = data # <<<<<<<<<<<<<< + * cdef object user_callback = nfqueue.user_callback + * + */ + __Pyx_INCREF(((PyObject *)((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_data))); + __pyx_v_nfqueue = ((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_data); + + /* "netfilterqueue.pyx":27 + * """Create a Packet and pass it to appropriate Python/Cython callback.""" + * cdef NetfilterQueue nfqueue = data + * cdef object user_callback = nfqueue.user_callback # <<<<<<<<<<<<<< + * + * packet = Packet() + */ + __Pyx_INCREF(((PyObject *)__pyx_v_nfqueue->user_callback)); + __pyx_v_user_callback = __pyx_v_nfqueue->user_callback; + + /* "netfilterqueue.pyx":29 + * cdef object user_callback = nfqueue.user_callback + * * packet = Packet() # <<<<<<<<<<<<<< * packet.set_nfq_data(qh, nfa) - * (data).handle(packet) + * user_callback(packet) */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14netfilterqueue_Packet)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14netfilterqueue_Packet)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_v_packet)); __pyx_v_packet = ((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_t_1); __pyx_t_1 = 0; - /* "netfilterqueue.pyx":19 - * """Create an Packet and pass it to appropriate Python/Cython callback.""" + /* "netfilterqueue.pyx":30 + * * packet = Packet() * packet.set_nfq_data(qh, nfa) # <<<<<<<<<<<<<< - * (data).handle(packet) + * user_callback(packet) * return 1 */ - __pyx_t_1 = ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)__pyx_v_packet->__pyx_vtab)->set_nfq_data(__pyx_v_packet, __pyx_v_qh, __pyx_v_nfa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)__pyx_v_packet->__pyx_vtab)->set_nfq_data(__pyx_v_packet, __pyx_v_qh, __pyx_v_nfa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "netfilterqueue.pyx":20 + /* "netfilterqueue.pyx":31 * packet = Packet() * packet.set_nfq_data(qh, nfa) - * (data).handle(packet) # <<<<<<<<<<<<<< + * user_callback(packet) # <<<<<<<<<<<<<< * return 1 * */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_data), __pyx_n_s__handle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_INCREF(((PyObject *)__pyx_v_packet)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_packet)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_packet)); __Pyx_GIVEREF(((PyObject *)__pyx_v_packet)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_2 = PyObject_Call(__pyx_v_user_callback, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "netfilterqueue.pyx":21 + /* "netfilterqueue.pyx":32 * packet.set_nfq_data(qh, nfa) - * (data).handle(packet) + * user_callback(packet) * return 1 # <<<<<<<<<<<<<< * * cdef class Packet: @@ -1232,19 +1225,20 @@ static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_WriteUnraisable("netfilterqueue.global_callback"); + __Pyx_WriteUnraisable("netfilterqueue.global_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_DECREF((PyObject *)__pyx_v_packet); + __Pyx_XDECREF((PyObject *)__pyx_v_nfqueue); + __Pyx_XDECREF(__pyx_v_user_callback); + __Pyx_XDECREF((PyObject *)__pyx_v_packet); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD - PyGILState_Release(_save); + PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } -/* "netfilterqueue.pyx":25 +/* "netfilterqueue.pyx":36 * cdef class Packet: * """A packet received from QueueHandler.""" * def __cinit__(self): # <<<<<<<<<<<<<< @@ -1255,12 +1249,13 @@ static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; + __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__"); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; - /* "netfilterqueue.pyx":26 + /* "netfilterqueue.pyx":37 * """A packet received from QueueHandler.""" * def __cinit__(self): * self._verdict_is_set = False # <<<<<<<<<<<<<< @@ -1269,7 +1264,7 @@ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(PyObject *__pyx_v_self, P */ ((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->_verdict_is_set = 0; - /* "netfilterqueue.pyx":27 + /* "netfilterqueue.pyx":38 * def __cinit__(self): * self._verdict_is_set = False * self._mark_is_set = False # <<<<<<<<<<<<<< @@ -1278,7 +1273,7 @@ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(PyObject *__pyx_v_self, P */ ((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->_mark_is_set = 0; - /* "netfilterqueue.pyx":28 + /* "netfilterqueue.pyx":39 * self._verdict_is_set = False * self._mark_is_set = False * self._given_payload = NULL # <<<<<<<<<<<<<< @@ -1292,7 +1287,7 @@ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(PyObject *__pyx_v_self, P return __pyx_r; } -/* "netfilterqueue.pyx":30 +/* "netfilterqueue.pyx":41 * self._given_payload = NULL * * def __str__(self): # <<<<<<<<<<<<<< @@ -1303,15 +1298,18 @@ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(PyObject *__pyx_v_self, P static PyObject *__pyx_pf_14netfilterqueue_6Packet_1__str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pf_14netfilterqueue_6Packet_1__str__(PyObject *__pyx_v_self) { struct iphdr *__pyx_v_hdr; - PyObject *__pyx_v_protocol; + PyObject *__pyx_v_protocol = NULL; PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__"); - __pyx_v_protocol = Py_None; __Pyx_INCREF(Py_None); - /* "netfilterqueue.pyx":31 + /* "netfilterqueue.pyx":42 * * def __str__(self): * cdef iphdr *hdr = self.payload # <<<<<<<<<<<<<< @@ -1320,21 +1318,21 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_1__str__(PyObject *__pyx_v_se */ __pyx_v_hdr = ((struct iphdr *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->payload); - /* "netfilterqueue.pyx":32 + /* "netfilterqueue.pyx":43 * def __str__(self): * cdef iphdr *hdr = self.payload * protocol = PROTOCOLS.get(hdr.protocol, "Unknown protocol") # <<<<<<<<<<<<<< * return "%s packet, %s bytes" % (protocol, self.payload_len) * */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__PROTOCOLS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__PROTOCOLS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_to_py_u_int8_t(__pyx_v_hdr->protocol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_to_py_u_int8_t(__pyx_v_hdr->protocol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -1342,15 +1340,14 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_1__str__(PyObject *__pyx_v_se PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_kp_s_1)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_v_protocol); __pyx_v_protocol = __pyx_t_1; __pyx_t_1 = 0; - /* "netfilterqueue.pyx":33 + /* "netfilterqueue.pyx":44 * cdef iphdr *hdr = self.payload * protocol = PROTOCOLS.get(hdr.protocol, "Unknown protocol") * return "%s packet, %s bytes" % (protocol, self.payload_len) # <<<<<<<<<<<<<< @@ -1358,9 +1355,9 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_1__str__(PyObject *__pyx_v_se * cdef set_nfq_data(self, nfq_q_handle *qh, nfq_data *nfa): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromSsize_t(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->payload_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->payload_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); __Pyx_INCREF(__pyx_v_protocol); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_protocol); @@ -1368,7 +1365,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_1__str__(PyObject *__pyx_v_se PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = ((PyObject *)__pyx_t_1); @@ -1381,16 +1378,16 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_1__str__(PyObject *__pyx_v_se __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("netfilterqueue.Packet.__str__"); + __Pyx_AddTraceback("netfilterqueue.Packet.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_DECREF(__pyx_v_protocol); + __Pyx_XDECREF(__pyx_v_protocol); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "netfilterqueue.pyx":35 +/* "netfilterqueue.pyx":46 * return "%s packet, %s bytes" % (protocol, self.payload_len) * * cdef set_nfq_data(self, nfq_q_handle *qh, nfq_data *nfa): # <<<<<<<<<<<<<< @@ -1398,13 +1395,17 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_1__str__(PyObject *__pyx_v_se * Assign a packet from NFQ to this object. Parse the header and load */ -static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, struct nfq_q_handle *__pyx_v_qh, struct nfq_data *__pyx_v_nfa) { +static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, struct nfq_q_handle *__pyx_v_qh, struct nfq_data *__pyx_v_nfa) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_nfq_data"); - /* "netfilterqueue.pyx":40 + /* "netfilterqueue.pyx":51 * local values. * """ * self._qh = qh # <<<<<<<<<<<<<< @@ -1413,7 +1414,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj */ __pyx_v_self->_qh = __pyx_v_qh; - /* "netfilterqueue.pyx":41 + /* "netfilterqueue.pyx":52 * """ * self._qh = qh * self._nfa = nfa # <<<<<<<<<<<<<< @@ -1422,7 +1423,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj */ __pyx_v_self->_nfa = __pyx_v_nfa; - /* "netfilterqueue.pyx":42 + /* "netfilterqueue.pyx":53 * self._qh = qh * self._nfa = nfa * self._hdr = nfq_get_msg_packet_hdr(nfa) # <<<<<<<<<<<<<< @@ -1431,7 +1432,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj */ __pyx_v_self->_hdr = nfq_get_msg_packet_hdr(__pyx_v_nfa); - /* "netfilterqueue.pyx":44 + /* "netfilterqueue.pyx":55 * self._hdr = nfq_get_msg_packet_hdr(nfa) * * self.id = ntohl(self._hdr.packet_id) # <<<<<<<<<<<<<< @@ -1440,7 +1441,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj */ __pyx_v_self->id = ntohl(__pyx_v_self->_hdr->packet_id); - /* "netfilterqueue.pyx":45 + /* "netfilterqueue.pyx":56 * * self.id = ntohl(self._hdr.packet_id) * self.hw_protocol = ntohs(self._hdr.hw_protocol) # <<<<<<<<<<<<<< @@ -1449,7 +1450,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj */ __pyx_v_self->hw_protocol = ntohs(__pyx_v_self->_hdr->hw_protocol); - /* "netfilterqueue.pyx":46 + /* "netfilterqueue.pyx":57 * self.id = ntohl(self._hdr.packet_id) * self.hw_protocol = ntohs(self._hdr.hw_protocol) * self.hook = self._hdr.hook # <<<<<<<<<<<<<< @@ -1458,7 +1459,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj */ __pyx_v_self->hook = __pyx_v_self->_hdr->hook; - /* "netfilterqueue.pyx":48 + /* "netfilterqueue.pyx":59 * self.hook = self._hdr.hook * * self.payload_len = nfq_get_payload(self._nfa, &self.payload) # <<<<<<<<<<<<<< @@ -1467,7 +1468,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj */ __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload)); - /* "netfilterqueue.pyx":49 + /* "netfilterqueue.pyx":60 * * self.payload_len = nfq_get_payload(self._nfa, &self.payload) * if self.payload_len < 0: # <<<<<<<<<<<<<< @@ -1477,23 +1478,23 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj __pyx_t_1 = (__pyx_v_self->payload_len < 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":50 + /* "netfilterqueue.pyx":61 * self.payload_len = nfq_get_payload(self._nfa, &self.payload) * if self.payload_len < 0: * raise OSError("Failed to get payload of packet.") # <<<<<<<<<<<<<< * * nfq_get_timestamp(self._nfa, &self.timestamp) */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "netfilterqueue.pyx":52 + /* "netfilterqueue.pyx":63 * raise OSError("Failed to get payload of packet.") * * nfq_get_timestamp(self._nfa, &self.timestamp) # <<<<<<<<<<<<<< @@ -1506,7 +1507,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("netfilterqueue.Packet.set_nfq_data"); + __Pyx_AddTraceback("netfilterqueue.Packet.set_nfq_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1514,7 +1515,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj return __pyx_r; } -/* "netfilterqueue.pyx":54 +/* "netfilterqueue.pyx":65 * nfq_get_timestamp(self._nfa, &self.timestamp) * * cdef void verdict(self, u_int8_t verdict): # <<<<<<<<<<<<<< @@ -1522,11 +1523,15 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj * if self._verdict_is_set: */ -static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, u_int8_t __pyx_v_verdict) { +static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, u_int8_t __pyx_v_verdict) { + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("verdict"); - /* "netfilterqueue.pyx":56 + /* "netfilterqueue.pyx":67 * cdef void verdict(self, u_int8_t verdict): * """Call appropriate set_verdict... function on packet.""" * if self._verdict_is_set: # <<<<<<<<<<<<<< @@ -1535,23 +1540,23 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilt */ if (__pyx_v_self->_verdict_is_set) { - /* "netfilterqueue.pyx":57 + /* "netfilterqueue.pyx":68 * """Call appropriate set_verdict... function on packet.""" * if self._verdict_is_set: * raise RuntimeWarning("Verdict already given for this packet.") # <<<<<<<<<<<<<< * * if self._mark_is_set: */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeWarning, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeWarning, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "netfilterqueue.pyx":59 + /* "netfilterqueue.pyx":70 * raise RuntimeWarning("Verdict already given for this packet.") * * if self._mark_is_set: # <<<<<<<<<<<<<< @@ -1560,7 +1565,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilt */ if (__pyx_v_self->_mark_is_set) { - /* "netfilterqueue.pyx":66 + /* "netfilterqueue.pyx":77 * htonl(self._given_mark), * 0, # TODO: adapt to use self._given_payload * NULL # TODO: adapt to use self._given_payload # <<<<<<<<<<<<<< @@ -1572,7 +1577,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilt } /*else*/ { - /* "netfilterqueue.pyx":74 + /* "netfilterqueue.pyx":85 * verdict, * 0, # TODO: adapt to use self._given_payload * NULL # TODO: adapt to use self._given_payload # <<<<<<<<<<<<<< @@ -1583,7 +1588,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilt } __pyx_L4:; - /* "netfilterqueue.pyx":77 + /* "netfilterqueue.pyx":88 * ) * * self._verdict_is_set = True # <<<<<<<<<<<<<< @@ -1595,12 +1600,12 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilt goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_WriteUnraisable("netfilterqueue.Packet.verdict"); + __Pyx_WriteUnraisable("netfilterqueue.Packet.verdict", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_RefNannyFinishContext(); } -/* "netfilterqueue.pyx":79 +/* "netfilterqueue.pyx":90 * self._verdict_is_set = True * * def get_payload(self): # <<<<<<<<<<<<<< @@ -1613,22 +1618,26 @@ static char __pyx_doc_14netfilterqueue_6Packet_2get_payload[] = "Return payload static PyObject *__pyx_pf_14netfilterqueue_6Packet_2get_payload(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_v_py_string = 0; PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_payload"); - /* "netfilterqueue.pyx":81 + /* "netfilterqueue.pyx":92 * def get_payload(self): * """Return payload as Python string.""" * cdef object py_string = PyString_FromStringAndSize(self.payload, self.payload_len) # <<<<<<<<<<<<<< * return py_string * */ - __pyx_t_1 = PyString_FromStringAndSize(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->payload, ((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->payload_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyString_FromStringAndSize(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->payload, ((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->payload_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_py_string = __pyx_t_1; __pyx_t_1 = 0; - /* "netfilterqueue.pyx":82 + /* "netfilterqueue.pyx":93 * """Return payload as Python string.""" * cdef object py_string = PyString_FromStringAndSize(self.payload, self.payload_len) * return py_string # <<<<<<<<<<<<<< @@ -1644,7 +1653,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2get_payload(PyObject *__pyx_ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.get_payload"); + __Pyx_AddTraceback("netfilterqueue.Packet.get_payload", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_py_string); @@ -1653,7 +1662,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2get_payload(PyObject *__pyx_ return __pyx_r; } -/* "netfilterqueue.pyx":84 +/* "netfilterqueue.pyx":95 * return py_string * * cpdef Py_ssize_t get_payload_len(self): # <<<<<<<<<<<<<< @@ -1662,22 +1671,26 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2get_payload(PyObject *__pyx_ */ static PyObject *__pyx_pf_14netfilterqueue_6Packet_3get_payload_len(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static Py_ssize_t __pyx_f_14netfilterqueue_6Packet_get_payload_len(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch) { +static Py_ssize_t __pyx_f_14netfilterqueue_6Packet_get_payload_len(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch) { Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; Py_ssize_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_payload_len"); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__get_payload_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__get_payload_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_14netfilterqueue_6Packet_3get_payload_len)) { - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1686,7 +1699,7 @@ static Py_ssize_t __pyx_f_14netfilterqueue_6Packet_get_payload_len(struct __pyx __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":85 + /* "netfilterqueue.pyx":96 * * cpdef Py_ssize_t get_payload_len(self): * return self.payload_len # <<<<<<<<<<<<<< @@ -1701,14 +1714,14 @@ static Py_ssize_t __pyx_f_14netfilterqueue_6Packet_get_payload_len(struct __pyx __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_WriteUnraisable("netfilterqueue.Packet.get_payload_len"); + __Pyx_WriteUnraisable("netfilterqueue.Packet.get_payload_len", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "netfilterqueue.pyx":84 +/* "netfilterqueue.pyx":95 * return py_string * * cpdef Py_ssize_t get_payload_len(self): # <<<<<<<<<<<<<< @@ -1719,10 +1732,14 @@ static Py_ssize_t __pyx_f_14netfilterqueue_6Packet_get_payload_len(struct __pyx static PyObject *__pyx_pf_14netfilterqueue_6Packet_3get_payload_len(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pf_14netfilterqueue_6Packet_3get_payload_len(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_payload_len"); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromSsize_t(((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->get_payload_len(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->get_payload_len(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1732,7 +1749,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_3get_payload_len(PyObject *__ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.get_payload_len"); + __Pyx_AddTraceback("netfilterqueue.Packet.get_payload_len", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1740,7 +1757,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_3get_payload_len(PyObject *__ return __pyx_r; } -/* "netfilterqueue.pyx":87 +/* "netfilterqueue.pyx":98 * return self.payload_len * * cpdef double get_timestamp(self): # <<<<<<<<<<<<<< @@ -1749,22 +1766,26 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_3get_payload_len(PyObject *__ */ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4get_timestamp(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static double __pyx_f_14netfilterqueue_6Packet_get_timestamp(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch) { +static double __pyx_f_14netfilterqueue_6Packet_get_timestamp(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch) { double __pyx_r; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; double __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_timestamp"); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__get_timestamp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__get_timestamp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_14netfilterqueue_6Packet_4get_timestamp)) { - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1773,7 +1794,7 @@ static double __pyx_f_14netfilterqueue_6Packet_get_timestamp(struct __pyx_obj_1 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":88 + /* "netfilterqueue.pyx":99 * * cpdef double get_timestamp(self): * return self.timestamp.tv_sec + (self.timestamp.tv_usec/1000000.0) # <<<<<<<<<<<<<< @@ -1788,14 +1809,14 @@ static double __pyx_f_14netfilterqueue_6Packet_get_timestamp(struct __pyx_obj_1 __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_WriteUnraisable("netfilterqueue.Packet.get_timestamp"); + __Pyx_WriteUnraisable("netfilterqueue.Packet.get_timestamp", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "netfilterqueue.pyx":87 +/* "netfilterqueue.pyx":98 * return self.payload_len * * cpdef double get_timestamp(self): # <<<<<<<<<<<<<< @@ -1806,10 +1827,14 @@ static double __pyx_f_14netfilterqueue_6Packet_get_timestamp(struct __pyx_obj_1 static PyObject *__pyx_pf_14netfilterqueue_6Packet_4get_timestamp(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4get_timestamp(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_timestamp"); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->get_timestamp(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->get_timestamp(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1819,7 +1844,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4get_timestamp(PyObject *__py goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.get_timestamp"); + __Pyx_AddTraceback("netfilterqueue.Packet.get_timestamp", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1827,7 +1852,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4get_timestamp(PyObject *__py return __pyx_r; } -/* "netfilterqueue.pyx":95 +/* "netfilterqueue.pyx":106 * # self._given_payload = payload * * cpdef set_mark(self, u_int32_t mark): # <<<<<<<<<<<<<< @@ -1836,28 +1861,32 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4get_timestamp(PyObject *__py */ static PyObject *__pyx_pf_14netfilterqueue_6Packet_5set_mark(PyObject *__pyx_v_self, PyObject *__pyx_arg_mark); /*proto*/ -static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, u_int32_t __pyx_v_mark, int __pyx_skip_dispatch) { +static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, u_int32_t __pyx_v_mark, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_mark"); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__set_mark); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__set_mark); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_14netfilterqueue_6Packet_5set_mark)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_to_py_u_int32_t(__pyx_v_mark); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_to_py_u_int32_t(__pyx_v_mark); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; @@ -1868,7 +1897,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14n __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":96 + /* "netfilterqueue.pyx":107 * * cpdef set_mark(self, u_int32_t mark): * self._given_mark = mark # <<<<<<<<<<<<<< @@ -1877,7 +1906,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14n */ __pyx_v_self->_given_mark = __pyx_v_mark; - /* "netfilterqueue.pyx":97 + /* "netfilterqueue.pyx":108 * cpdef set_mark(self, u_int32_t mark): * self._given_mark = mark * self._mark_is_set = True # <<<<<<<<<<<<<< @@ -1892,7 +1921,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14n __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("netfilterqueue.Packet.set_mark"); + __Pyx_AddTraceback("netfilterqueue.Packet.set_mark", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1900,7 +1929,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14n return __pyx_r; } -/* "netfilterqueue.pyx":95 +/* "netfilterqueue.pyx":106 * # self._given_payload = payload * * cpdef set_mark(self, u_int32_t mark): # <<<<<<<<<<<<<< @@ -1912,19 +1941,23 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_5set_mark(PyObject *__pyx_v_s static PyObject *__pyx_pf_14netfilterqueue_6Packet_5set_mark(PyObject *__pyx_v_self, PyObject *__pyx_arg_mark) { u_int32_t __pyx_v_mark; PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_mark"); assert(__pyx_arg_mark); { - __pyx_v_mark = __Pyx_PyInt_from_py_u_int32_t(__pyx_arg_mark); if (unlikely((__pyx_v_mark == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_mark = __Pyx_PyInt_from_py_u_int32_t(__pyx_arg_mark); if (unlikely((__pyx_v_mark == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; - __Pyx_AddTraceback("netfilterqueue.Packet.set_mark"); + __Pyx_AddTraceback("netfilterqueue.Packet.set_mark", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->set_mark(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), __pyx_v_mark, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->set_mark(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), __pyx_v_mark, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1934,7 +1967,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_5set_mark(PyObject *__pyx_v_s goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.set_mark"); + __Pyx_AddTraceback("netfilterqueue.Packet.set_mark", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1942,7 +1975,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_5set_mark(PyObject *__pyx_v_s return __pyx_r; } -/* "netfilterqueue.pyx":99 +/* "netfilterqueue.pyx":110 * self._mark_is_set = True * * cpdef accept(self): # <<<<<<<<<<<<<< @@ -1951,20 +1984,24 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_5set_mark(PyObject *__pyx_v_s */ static PyObject *__pyx_pf_14netfilterqueue_6Packet_6accept(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch) { +static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("accept"); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__accept); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__accept); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_14netfilterqueue_6Packet_6accept)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -1974,7 +2011,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14net __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":101 + /* "netfilterqueue.pyx":112 * cpdef accept(self): * """Accept the packet.""" * self.verdict(NF_ACCEPT) # <<<<<<<<<<<<<< @@ -1988,7 +2025,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14net __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("netfilterqueue.Packet.accept"); + __Pyx_AddTraceback("netfilterqueue.Packet.accept", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1996,7 +2033,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14net return __pyx_r; } -/* "netfilterqueue.pyx":99 +/* "netfilterqueue.pyx":110 * self._mark_is_set = True * * cpdef accept(self): # <<<<<<<<<<<<<< @@ -2008,10 +2045,14 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_6accept(PyObject *__pyx_v_sel static char __pyx_doc_14netfilterqueue_6Packet_6accept[] = "Accept the packet."; static PyObject *__pyx_pf_14netfilterqueue_6Packet_6accept(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("accept"); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->accept(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->accept(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2021,7 +2062,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_6accept(PyObject *__pyx_v_sel goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.accept"); + __Pyx_AddTraceback("netfilterqueue.Packet.accept", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2029,7 +2070,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_6accept(PyObject *__pyx_v_sel return __pyx_r; } -/* "netfilterqueue.pyx":103 +/* "netfilterqueue.pyx":114 * self.verdict(NF_ACCEPT) * * cpdef drop(self): # <<<<<<<<<<<<<< @@ -2038,20 +2079,24 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_6accept(PyObject *__pyx_v_sel */ static PyObject *__pyx_pf_14netfilterqueue_6Packet_7drop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch) { +static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("drop"); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__drop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__drop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_14netfilterqueue_6Packet_7drop)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -2061,12 +2106,12 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfi __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":105 + /* "netfilterqueue.pyx":116 * cpdef drop(self): * """Drop the packet.""" * self.verdict(NF_DROP) # <<<<<<<<<<<<<< * - * cdef class QueueHandler: + * cdef class NetfilterQueue: */ ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)__pyx_v_self->__pyx_vtab)->verdict(__pyx_v_self, __pyx_e_14netfilterqueue_NF_DROP); @@ -2075,7 +2120,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfi __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("netfilterqueue.Packet.drop"); + __Pyx_AddTraceback("netfilterqueue.Packet.drop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2083,7 +2128,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfi return __pyx_r; } -/* "netfilterqueue.pyx":103 +/* "netfilterqueue.pyx":114 * self.verdict(NF_ACCEPT) * * cpdef drop(self): # <<<<<<<<<<<<<< @@ -2095,10 +2140,14 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_7drop(PyObject *__pyx_v_self, static char __pyx_doc_14netfilterqueue_6Packet_7drop[] = "Drop the packet."; static PyObject *__pyx_pf_14netfilterqueue_6Packet_7drop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("drop"); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->drop(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->__pyx_vtab)->drop(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2108,7 +2157,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_7drop(PyObject *__pyx_v_self, goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.drop"); + __Pyx_AddTraceback("netfilterqueue.Packet.drop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2127,7 +2176,11 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_7drop(PyObject *__pyx_v_self, static PyObject *__pyx_pf_14netfilterqueue_6Packet_2id___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2id___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__"); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_to_py_u_int32_t(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -2140,7 +2193,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2id___get__(PyObject *__pyx_v goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.id.__get__"); + __Pyx_AddTraceback("netfilterqueue.Packet.id.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2159,7 +2212,11 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2id___get__(PyObject *__pyx_v static PyObject *__pyx_pf_14netfilterqueue_6Packet_11hw_protocol___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pf_14netfilterqueue_6Packet_11hw_protocol___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__"); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_to_py_u_int16_t(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->hw_protocol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -2172,7 +2229,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_11hw_protocol___get__(PyObjec goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.hw_protocol.__get__"); + __Pyx_AddTraceback("netfilterqueue.Packet.hw_protocol.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2191,7 +2248,11 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_11hw_protocol___get__(PyObjec static PyObject *__pyx_pf_14netfilterqueue_6Packet_4hook___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4hook___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__"); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_to_py_u_int8_t(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->hook); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -2204,7 +2265,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4hook___get__(PyObject *__pyx goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.hook.__get__"); + __Pyx_AddTraceback("netfilterqueue.Packet.hook.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2223,7 +2284,11 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4hook___get__(PyObject *__pyx static PyObject *__pyx_pf_14netfilterqueue_6Packet_7payload___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pf_14netfilterqueue_6Packet_7payload___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__"); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self)->payload); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -2236,7 +2301,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_7payload___get__(PyObject *__ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.Packet.payload.__get__"); + __Pyx_AddTraceback("netfilterqueue.Packet.payload.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2244,23 +2309,27 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_7payload___get__(PyObject *__ return __pyx_r; } -/* "netfilterqueue.pyx":109 - * cdef class QueueHandler: +/* "netfilterqueue.pyx":120 + * cdef class NetfilterQueue: * """Handle a single numbered queue.""" * def __cinit__(self, *args, **kwargs): # <<<<<<<<<<<<<< * self.af = kwargs.get("af", PF_INET) * */ -static int __pyx_pf_14netfilterqueue_12QueueHandler___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pf_14netfilterqueue_12QueueHandler___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_args = 0; PyObject *__pyx_v_kwargs = 0; int __pyx_r; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; u_int16_t __pyx_t_3; int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__"); if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1; __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); @@ -2269,102 +2338,102 @@ static int __pyx_pf_14netfilterqueue_12QueueHandler___cinit__(PyObject *__pyx_v_ __Pyx_INCREF(__pyx_args); __pyx_v_args = __pyx_args; - /* "netfilterqueue.pyx":110 + /* "netfilterqueue.pyx":121 * """Handle a single numbered queue.""" * def __cinit__(self, *args, **kwargs): * self.af = kwargs.get("af", PF_INET) # <<<<<<<<<<<<<< * * self.h = nfq_open() */ - if (unlikely(__pyx_v_kwargs == Py_None)) { - PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(((PyObject *)__pyx_v_kwargs) == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_1 = PyInt_FromLong(__pyx_e_14netfilterqueue_PF_INET); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_e_14netfilterqueue_PF_INET); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__af), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__af), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyInt_from_py_u_int16_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (u_int16_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_from_py_u_int16_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (u_int16_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - ((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->af = __pyx_t_3; + ((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->af = __pyx_t_3; - /* "netfilterqueue.pyx":112 + /* "netfilterqueue.pyx":123 * self.af = kwargs.get("af", PF_INET) * * self.h = nfq_open() # <<<<<<<<<<<<<< * if self.h == NULL: * raise OSError("Failed to open NFQueue.") */ - ((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->h = nfq_open(); + ((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->h = nfq_open(); - /* "netfilterqueue.pyx":113 + /* "netfilterqueue.pyx":124 * * self.h = nfq_open() * if self.h == NULL: # <<<<<<<<<<<<<< * raise OSError("Failed to open NFQueue.") * nfq_unbind_pf(self.h, self.af) # This does NOT kick out previous */ - __pyx_t_4 = (((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->h == NULL); + __pyx_t_4 = (((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->h == NULL); if (__pyx_t_4) { - /* "netfilterqueue.pyx":114 + /* "netfilterqueue.pyx":125 * self.h = nfq_open() * if self.h == NULL: * raise OSError("Failed to open NFQueue.") # <<<<<<<<<<<<<< * nfq_unbind_pf(self.h, self.af) # This does NOT kick out previous * # running queues */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; - /* "netfilterqueue.pyx":115 + /* "netfilterqueue.pyx":126 * if self.h == NULL: * raise OSError("Failed to open NFQueue.") * nfq_unbind_pf(self.h, self.af) # This does NOT kick out previous # <<<<<<<<<<<<<< * # running queues * if nfq_bind_pf(self.h, self.af) < 0: */ - nfq_unbind_pf(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->h, ((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->af); + nfq_unbind_pf(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->h, ((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->af); - /* "netfilterqueue.pyx":117 + /* "netfilterqueue.pyx":128 * nfq_unbind_pf(self.h, self.af) # This does NOT kick out previous * # running queues * if nfq_bind_pf(self.h, self.af) < 0: # <<<<<<<<<<<<<< * raise OSError("Failed to bind family %s. Are you root?" % self.af) * */ - __pyx_t_4 = (nfq_bind_pf(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->h, ((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->af) < 0); + __pyx_t_4 = (nfq_bind_pf(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->h, ((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->af) < 0); if (__pyx_t_4) { - /* "netfilterqueue.pyx":118 + /* "netfilterqueue.pyx":129 * # running queues * if nfq_bind_pf(self.h, self.af) < 0: * raise OSError("Failed to bind family %s. Are you root?" % self.af) # <<<<<<<<<<<<<< * * def __dealloc__(self): */ - __pyx_t_2 = __Pyx_PyInt_to_py_u_int16_t(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->af); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_to_py_u_int16_t(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->af); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_Raise(__pyx_t_1, 0, 0); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L6; } __pyx_L6:; @@ -2374,16 +2443,16 @@ static int __pyx_pf_14netfilterqueue_12QueueHandler___cinit__(PyObject *__pyx_v_ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("netfilterqueue.QueueHandler.__cinit__"); + __Pyx_AddTraceback("netfilterqueue.NetfilterQueue.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; - __Pyx_DECREF(__pyx_v_args); - __Pyx_DECREF(__pyx_v_kwargs); + __Pyx_XDECREF(__pyx_v_args); + __Pyx_XDECREF(__pyx_v_kwargs); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "netfilterqueue.pyx":120 +/* "netfilterqueue.pyx":131 * raise OSError("Failed to bind family %s. Are you root?" % self.af) * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -2391,186 +2460,214 @@ static int __pyx_pf_14netfilterqueue_12QueueHandler___cinit__(PyObject *__pyx_v_ * nfq_destroy_queue(self.qh) */ -static void __pyx_pf_14netfilterqueue_12QueueHandler_1__dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_pf_14netfilterqueue_12QueueHandler_1__dealloc__(PyObject *__pyx_v_self) { +static void __pyx_pf_14netfilterqueue_14NetfilterQueue_1__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pf_14netfilterqueue_14NetfilterQueue_1__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__"); - /* "netfilterqueue.pyx":121 + /* "netfilterqueue.pyx":132 * * def __dealloc__(self): * if self.qh != NULL: # <<<<<<<<<<<<<< * nfq_destroy_queue(self.qh) * # Don't call nfq_unbind_pf unless you want to disconnect any other */ - __pyx_t_1 = (((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->qh != NULL); + __pyx_t_1 = (((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->qh != NULL); if (__pyx_t_1) { - /* "netfilterqueue.pyx":122 + /* "netfilterqueue.pyx":133 * def __dealloc__(self): * if self.qh != NULL: * nfq_destroy_queue(self.qh) # <<<<<<<<<<<<<< * # Don't call nfq_unbind_pf unless you want to disconnect any other * # processes using this libnetfilter_queue on this protocol family! */ - nfq_destroy_queue(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->qh); + nfq_destroy_queue(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->qh); goto __pyx_L5; } __pyx_L5:; - /* "netfilterqueue.pyx":125 + /* "netfilterqueue.pyx":136 * # Don't call nfq_unbind_pf unless you want to disconnect any other * # processes using this libnetfilter_queue on this protocol family! * nfq_close(self.h) # <<<<<<<<<<<<<< * - * def bind(self, int queue_num, u_int32_t max_len=DEFAULT_MAX_QUEUELEN, u_int8_t mode=NFQNL_COPY_PACKET, u_int32_t range=MaxPacketSize): + * def bind(self, int queue_num, object user_callback, u_int32_t max_len=DEFAULT_MAX_QUEUELEN, */ - nfq_close(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->h); + nfq_close(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->h); __Pyx_RefNannyFinishContext(); } -/* "netfilterqueue.pyx":127 +/* "netfilterqueue.pyx":138 * nfq_close(self.h) * - * def bind(self, int queue_num, u_int32_t max_len=DEFAULT_MAX_QUEUELEN, u_int8_t mode=NFQNL_COPY_PACKET, u_int32_t range=MaxPacketSize): # <<<<<<<<<<<<<< + * def bind(self, int queue_num, object user_callback, u_int32_t max_len=DEFAULT_MAX_QUEUELEN, # <<<<<<<<<<<<<< + * u_int8_t mode=NFQNL_COPY_PACKET, u_int32_t range=MaxPacketSize): * """Create and bind to a new queue.""" - * self.qh = nfq_create_queue(self.h, queue_num, global_callback, self) */ -static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_2bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_14netfilterqueue_12QueueHandler_2bind[] = "Create and bind to a new queue."; -static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_2bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_2bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_14netfilterqueue_14NetfilterQueue_2bind[] = "Create and bind to a new queue."; +static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_2bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_queue_num; + PyObject *__pyx_v_user_callback = 0; u_int32_t __pyx_v_max_len; u_int8_t __pyx_v_mode; u_int32_t __pyx_v_range; PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__queue_num,&__pyx_n_s__max_len,&__pyx_n_s__mode,&__pyx_n_s__range,0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__queue_num,&__pyx_n_s__user_callback,&__pyx_n_s__max_len,&__pyx_n_s__mode,&__pyx_n_s__range,0}; __Pyx_RefNannySetupContext("bind"); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); - PyObject* values[4] = {0,0,0,0}; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__queue_num); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_len); - if (value) { values[1] = value; kw_args--; } + { + PyObject* values[5] = {0,0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode); - if (value) { values[2] = value; kw_args--; } + kw_args = PyDict_Size(__pyx_kwds); + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 0: + values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__queue_num); + if (likely(values[0])) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__user_callback); + if (likely(values[1])) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("bind", 0, 2, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_len); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__range); + if (value) { values[4] = value; kw_args--; } + } } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__range); - if (value) { values[3] = value; kw_args--; } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "bind") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; } } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "bind") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - __pyx_v_queue_num = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_queue_num == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - if (values[1]) { - __pyx_v_max_len = __Pyx_PyInt_from_py_u_int32_t(values[1]); if (unlikely((__pyx_v_max_len == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_queue_num = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_queue_num == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_user_callback = values[1]; + if (values[2]) { + __pyx_v_max_len = __Pyx_PyInt_from_py_u_int32_t(values[2]); if (unlikely((__pyx_v_max_len == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_max_len = __pyx_k_10; } - if (values[2]) { - __pyx_v_mode = __Pyx_PyInt_from_py_u_int8_t(values[2]); if (unlikely((__pyx_v_mode == (u_int8_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (values[3]) { + __pyx_v_mode = __Pyx_PyInt_from_py_u_int8_t(values[3]); if (unlikely((__pyx_v_mode == (u_int8_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_mode = __pyx_k_11; } - if (values[3]) { - __pyx_v_range = __Pyx_PyInt_from_py_u_int32_t(values[3]); if (unlikely((__pyx_v_range == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (values[4]) { + __pyx_v_range = __Pyx_PyInt_from_py_u_int32_t(values[4]); if (unlikely((__pyx_v_range == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_range = ((u_int32_t)65535); } - } else { - __pyx_v_max_len = __pyx_k_10; - __pyx_v_mode = __pyx_k_11; - __pyx_v_range = ((u_int32_t)65535); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 4: __pyx_v_range = __Pyx_PyInt_from_py_u_int32_t(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_range == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 3: __pyx_v_mode = __Pyx_PyInt_from_py_u_int8_t(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_mode == (u_int8_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 2: __pyx_v_max_len = __Pyx_PyInt_from_py_u_int32_t(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_max_len == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 1: __pyx_v_queue_num = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_queue_num == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - break; - default: goto __pyx_L5_argtuple_error; - } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("bind", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("bind", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("netfilterqueue.QueueHandler.bind"); + __Pyx_AddTraceback("netfilterqueue.NetfilterQueue.bind", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - /* "netfilterqueue.pyx":129 - * def bind(self, int queue_num, u_int32_t max_len=DEFAULT_MAX_QUEUELEN, u_int8_t mode=NFQNL_COPY_PACKET, u_int32_t range=MaxPacketSize): + /* "netfilterqueue.pyx":141 + * u_int8_t mode=NFQNL_COPY_PACKET, u_int32_t range=MaxPacketSize): * """Create and bind to a new queue.""" + * self.user_callback = user_callback # <<<<<<<<<<<<<< + * self.qh = nfq_create_queue(self.h, queue_num, global_callback, self) + * if self.qh == NULL: + */ + __Pyx_INCREF(__pyx_v_user_callback); + __Pyx_GIVEREF(__pyx_v_user_callback); + __Pyx_GOTREF(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->user_callback); + __Pyx_DECREF(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->user_callback); + ((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->user_callback = __pyx_v_user_callback; + + /* "netfilterqueue.pyx":142 + * """Create and bind to a new queue.""" + * self.user_callback = user_callback * self.qh = nfq_create_queue(self.h, queue_num, global_callback, self) # <<<<<<<<<<<<<< * if self.qh == NULL: * raise OSError("Failed to create queue %s." % queue_num) */ - ((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->qh = nfq_create_queue(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->h, __pyx_v_queue_num, ((nfq_callback *)__pyx_f_14netfilterqueue_global_callback), ((void *)__pyx_v_self)); + ((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->qh = nfq_create_queue(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->h, __pyx_v_queue_num, ((nfq_callback *)__pyx_f_14netfilterqueue_global_callback), ((void *)__pyx_v_self)); - /* "netfilterqueue.pyx":130 - * """Create and bind to a new queue.""" + /* "netfilterqueue.pyx":143 + * self.user_callback = user_callback * self.qh = nfq_create_queue(self.h, queue_num, global_callback, self) * if self.qh == NULL: # <<<<<<<<<<<<<< * raise OSError("Failed to create queue %s." % queue_num) * */ - __pyx_t_1 = (((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->qh == NULL); + __pyx_t_1 = (((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->qh == NULL); if (__pyx_t_1) { - /* "netfilterqueue.pyx":131 + /* "netfilterqueue.pyx":144 * self.qh = nfq_create_queue(self.h, queue_num, global_callback, self) * if self.qh == NULL: * raise OSError("Failed to create queue %s." % queue_num) # <<<<<<<<<<<<<< * * if range > MaxCopySize: */ - __pyx_t_2 = PyInt_FromLong(__pyx_v_queue_num); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_queue_num); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L6; } __pyx_L6:; - /* "netfilterqueue.pyx":133 + /* "netfilterqueue.pyx":146 * raise OSError("Failed to create queue %s." % queue_num) * * if range > MaxCopySize: # <<<<<<<<<<<<<< @@ -2580,7 +2677,7 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_2bind(PyObject *__pyx_ __pyx_t_1 = (__pyx_v_range > 4016); if (__pyx_t_1) { - /* "netfilterqueue.pyx":134 + /* "netfilterqueue.pyx":147 * * if range > MaxCopySize: * range = MaxCopySize # <<<<<<<<<<<<<< @@ -2592,47 +2689,47 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_2bind(PyObject *__pyx_ } __pyx_L7:; - /* "netfilterqueue.pyx":135 + /* "netfilterqueue.pyx":148 * if range > MaxCopySize: * range = MaxCopySize * if nfq_set_mode(self.qh, mode, range) < 0: # <<<<<<<<<<<<<< * raise OSError("Failed to set packet copy mode.") * */ - __pyx_t_1 = (nfq_set_mode(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->qh, __pyx_v_mode, __pyx_v_range) < 0); + __pyx_t_1 = (nfq_set_mode(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->qh, __pyx_v_mode, __pyx_v_range) < 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":136 + /* "netfilterqueue.pyx":149 * range = MaxCopySize * if nfq_set_mode(self.qh, mode, range) < 0: * raise OSError("Failed to set packet copy mode.") # <<<<<<<<<<<<<< * * nfq_set_queue_maxlen(self.qh, max_len) */ - __pyx_t_3 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L8; } __pyx_L8:; - /* "netfilterqueue.pyx":138 + /* "netfilterqueue.pyx":151 * raise OSError("Failed to set packet copy mode.") * * nfq_set_queue_maxlen(self.qh, max_len) # <<<<<<<<<<<<<< * * def unbind(self): */ - nfq_set_queue_maxlen(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->qh, __pyx_v_max_len); + nfq_set_queue_maxlen(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->qh, __pyx_v_max_len); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("netfilterqueue.QueueHandler.bind"); + __Pyx_AddTraceback("netfilterqueue.NetfilterQueue.bind", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2640,7 +2737,7 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_2bind(PyObject *__pyx_ return __pyx_r; } -/* "netfilterqueue.pyx":140 +/* "netfilterqueue.pyx":153 * nfq_set_queue_maxlen(self.qh, max_len) * * def unbind(self): # <<<<<<<<<<<<<< @@ -2648,31 +2745,32 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_2bind(PyObject *__pyx_ * if self.qh != NULL: */ -static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_3unbind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_14netfilterqueue_12QueueHandler_3unbind[] = "Destroy the queue."; -static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_3unbind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_3unbind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_14netfilterqueue_14NetfilterQueue_3unbind[] = "Destroy the queue."; +static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_3unbind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("unbind"); - /* "netfilterqueue.pyx":142 + /* "netfilterqueue.pyx":155 * def unbind(self): * """Destroy the queue.""" * if self.qh != NULL: # <<<<<<<<<<<<<< * nfq_destroy_queue(self.qh) * # See warning about nfq_unbind_pf in __dealloc__ above. */ - __pyx_t_1 = (((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->qh != NULL); + __pyx_t_1 = (((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->qh != NULL); if (__pyx_t_1) { - /* "netfilterqueue.pyx":143 + /* "netfilterqueue.pyx":156 * """Destroy the queue.""" * if self.qh != NULL: * nfq_destroy_queue(self.qh) # <<<<<<<<<<<<<< * # See warning about nfq_unbind_pf in __dealloc__ above. * */ - nfq_destroy_queue(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->qh); + nfq_destroy_queue(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->qh); goto __pyx_L5; } __pyx_L5:; @@ -2683,7 +2781,7 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_3unbind(PyObject *__py return __pyx_r; } -/* "netfilterqueue.pyx":146 +/* "netfilterqueue.pyx":159 * # See warning about nfq_unbind_pf in __dealloc__ above. * * def run(self): # <<<<<<<<<<<<<< @@ -2691,26 +2789,27 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_3unbind(PyObject *__py * cdef int fd = nfq_fd(self.h) */ -static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_4run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_14netfilterqueue_12QueueHandler_4run[] = "Begin accepting packets."; -static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_4run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_14netfilterqueue_14NetfilterQueue_4run[] = "Begin accepting packets."; +static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { int __pyx_v_fd; char __pyx_v_buf[4096]; int __pyx_v_rv; PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("run"); - /* "netfilterqueue.pyx":148 + /* "netfilterqueue.pyx":161 * def run(self): * """Begin accepting packets.""" * cdef int fd = nfq_fd(self.h) # <<<<<<<<<<<<<< * cdef char buf[BufferSize] * cdef int rv */ - __pyx_v_fd = nfq_fd(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->h); + __pyx_v_fd = nfq_fd(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->h); - /* "netfilterqueue.pyx":151 + /* "netfilterqueue.pyx":164 * cdef char buf[BufferSize] * cdef int rv * with nogil: # <<<<<<<<<<<<<< @@ -2718,35 +2817,35 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_4run(PyObject *__pyx_v * while rv >= 0: */ { - #ifdef WITH_THREAD - PyThreadState *_save; - #endif - Py_UNBLOCK_THREADS - /*try:*/ { + #ifdef WITH_THREAD + PyThreadState *_save = NULL; + #endif + Py_UNBLOCK_THREADS + /*try:*/ { - /* "netfilterqueue.pyx":152 + /* "netfilterqueue.pyx":165 * cdef int rv * with nogil: * rv = recv(fd, buf, sizeof(buf), 0) # <<<<<<<<<<<<<< * while rv >= 0: * nfq_handle_packet(self.h, buf, rv) */ - __pyx_v_rv = recv(__pyx_v_fd, __pyx_v_buf, (sizeof(__pyx_v_buf)), 0); - } + __pyx_v_rv = recv(__pyx_v_fd, __pyx_v_buf, (sizeof(__pyx_v_buf)), 0); + } - /* "netfilterqueue.pyx":151 + /* "netfilterqueue.pyx":164 * cdef char buf[BufferSize] * cdef int rv * with nogil: # <<<<<<<<<<<<<< * rv = recv(fd, buf, sizeof(buf), 0) * while rv >= 0: */ - /*finally:*/ { - Py_BLOCK_THREADS - } + /*finally:*/ { + Py_BLOCK_THREADS + } } - /* "netfilterqueue.pyx":153 + /* "netfilterqueue.pyx":166 * with nogil: * rv = recv(fd, buf, sizeof(buf), 0) * while rv >= 0: # <<<<<<<<<<<<<< @@ -2757,16 +2856,16 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_4run(PyObject *__pyx_v __pyx_t_1 = (__pyx_v_rv >= 0); if (!__pyx_t_1) break; - /* "netfilterqueue.pyx":154 + /* "netfilterqueue.pyx":167 * rv = recv(fd, buf, sizeof(buf), 0) * while rv >= 0: * nfq_handle_packet(self.h, buf, rv) # <<<<<<<<<<<<<< * with nogil: * rv = recv(fd, buf, sizeof(buf), 0) */ - nfq_handle_packet(((struct __pyx_obj_14netfilterqueue_QueueHandler *)__pyx_v_self)->h, __pyx_v_buf, __pyx_v_rv); + nfq_handle_packet(((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_v_self)->h, __pyx_v_buf, __pyx_v_rv); - /* "netfilterqueue.pyx":155 + /* "netfilterqueue.pyx":168 * while rv >= 0: * nfq_handle_packet(self.h, buf, rv) * with nogil: # <<<<<<<<<<<<<< @@ -2774,32 +2873,32 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_4run(PyObject *__pyx_v * */ { - #ifdef WITH_THREAD - PyThreadState *_save; - #endif - Py_UNBLOCK_THREADS - /*try:*/ { + #ifdef WITH_THREAD + PyThreadState *_save = NULL; + #endif + Py_UNBLOCK_THREADS + /*try:*/ { - /* "netfilterqueue.pyx":156 + /* "netfilterqueue.pyx":169 * nfq_handle_packet(self.h, buf, rv) * with nogil: * rv = recv(fd, buf, sizeof(buf), 0) # <<<<<<<<<<<<<< * - * def handle(self, Packet packet): + * PROTOCOLS = { */ - __pyx_v_rv = recv(__pyx_v_fd, __pyx_v_buf, (sizeof(__pyx_v_buf)), 0); - } + __pyx_v_rv = recv(__pyx_v_fd, __pyx_v_buf, (sizeof(__pyx_v_buf)), 0); + } - /* "netfilterqueue.pyx":155 + /* "netfilterqueue.pyx":168 * while rv >= 0: * nfq_handle_packet(self.h, buf, rv) * with nogil: # <<<<<<<<<<<<<< * rv = recv(fd, buf, sizeof(buf), 0) * */ - /*finally:*/ { - Py_BLOCK_THREADS - } + /*finally:*/ { + Py_BLOCK_THREADS + } } } @@ -2808,45 +2907,6 @@ static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_4run(PyObject *__pyx_v __Pyx_RefNannyFinishContext(); return __pyx_r; } - -/* "netfilterqueue.pyx":158 - * rv = recv(fd, buf, sizeof(buf), 0) - * - * def handle(self, Packet packet): # <<<<<<<<<<<<<< - * """Handle a single packet. User-defined classes should override this.""" - * packet.accept() - */ - -static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_5handle(PyObject *__pyx_v_self, PyObject *__pyx_v_packet); /*proto*/ -static char __pyx_doc_14netfilterqueue_12QueueHandler_5handle[] = "Handle a single packet. User-defined classes should override this."; -static PyObject *__pyx_pf_14netfilterqueue_12QueueHandler_5handle(PyObject *__pyx_v_self, PyObject *__pyx_v_packet) { - PyObject *__pyx_r = NULL; - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("handle"); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_packet), __pyx_ptype_14netfilterqueue_Packet, 1, "packet", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "netfilterqueue.pyx":160 - * def handle(self, Packet packet): - * """Handle a single packet. User-defined classes should override this.""" - * packet.accept() # <<<<<<<<<<<<<< - * - * PROTOCOLS = { - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_packet)->__pyx_vtab)->accept(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_packet), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("netfilterqueue.QueueHandler.handle"); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} static struct __pyx_vtabstruct_14netfilterqueue_Packet __pyx_vtable_14netfilterqueue_Packet; static PyObject *__pyx_tp_new_14netfilterqueue_Packet(PyTypeObject *t, PyObject *a, PyObject *k) { @@ -3053,60 +3113,67 @@ static PyTypeObject __pyx_type_14netfilterqueue_Packet = { #endif }; -static PyObject *__pyx_tp_new_14netfilterqueue_QueueHandler(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_14netfilterqueue_QueueHandler *p; +static PyObject *__pyx_tp_new_14netfilterqueue_NetfilterQueue(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14netfilterqueue_NetfilterQueue *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_14netfilterqueue_QueueHandler *)o); + p = ((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)o); + p->user_callback = Py_None; Py_INCREF(Py_None); p->packet_copy_size = Py_None; Py_INCREF(Py_None); - if (__pyx_pf_14netfilterqueue_12QueueHandler___cinit__(o, a, k) < 0) { + if (__pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_14netfilterqueue_QueueHandler(PyObject *o) { - struct __pyx_obj_14netfilterqueue_QueueHandler *p = (struct __pyx_obj_14netfilterqueue_QueueHandler *)o; +static void __pyx_tp_dealloc_14netfilterqueue_NetfilterQueue(PyObject *o) { + struct __pyx_obj_14netfilterqueue_NetfilterQueue *p = (struct __pyx_obj_14netfilterqueue_NetfilterQueue *)o; { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); - __pyx_pf_14netfilterqueue_12QueueHandler_1__dealloc__(o); + __pyx_pf_14netfilterqueue_14NetfilterQueue_1__dealloc__(o); if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } + Py_XDECREF(p->user_callback); Py_XDECREF(p->packet_copy_size); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_14netfilterqueue_QueueHandler(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_14netfilterqueue_NetfilterQueue(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_14netfilterqueue_QueueHandler *p = (struct __pyx_obj_14netfilterqueue_QueueHandler *)o; + struct __pyx_obj_14netfilterqueue_NetfilterQueue *p = (struct __pyx_obj_14netfilterqueue_NetfilterQueue *)o; + if (p->user_callback) { + e = (*v)(p->user_callback, a); if (e) return e; + } if (p->packet_copy_size) { e = (*v)(p->packet_copy_size, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_14netfilterqueue_QueueHandler(PyObject *o) { - struct __pyx_obj_14netfilterqueue_QueueHandler *p = (struct __pyx_obj_14netfilterqueue_QueueHandler *)o; +static int __pyx_tp_clear_14netfilterqueue_NetfilterQueue(PyObject *o) { + struct __pyx_obj_14netfilterqueue_NetfilterQueue *p = (struct __pyx_obj_14netfilterqueue_NetfilterQueue *)o; PyObject* tmp; + tmp = ((PyObject*)p->user_callback); + p->user_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); tmp = ((PyObject*)p->packet_copy_size); p->packet_copy_size = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_14netfilterqueue_QueueHandler[] = { - {__Pyx_NAMESTR("bind"), (PyCFunction)__pyx_pf_14netfilterqueue_12QueueHandler_2bind, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_14netfilterqueue_12QueueHandler_2bind)}, - {__Pyx_NAMESTR("unbind"), (PyCFunction)__pyx_pf_14netfilterqueue_12QueueHandler_3unbind, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_14netfilterqueue_12QueueHandler_3unbind)}, - {__Pyx_NAMESTR("run"), (PyCFunction)__pyx_pf_14netfilterqueue_12QueueHandler_4run, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_14netfilterqueue_12QueueHandler_4run)}, - {__Pyx_NAMESTR("handle"), (PyCFunction)__pyx_pf_14netfilterqueue_12QueueHandler_5handle, METH_O, __Pyx_DOCSTR(__pyx_doc_14netfilterqueue_12QueueHandler_5handle)}, +static PyMethodDef __pyx_methods_14netfilterqueue_NetfilterQueue[] = { + {__Pyx_NAMESTR("bind"), (PyCFunction)__pyx_pf_14netfilterqueue_14NetfilterQueue_2bind, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_14netfilterqueue_14NetfilterQueue_2bind)}, + {__Pyx_NAMESTR("unbind"), (PyCFunction)__pyx_pf_14netfilterqueue_14NetfilterQueue_3unbind, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_14netfilterqueue_14NetfilterQueue_3unbind)}, + {__Pyx_NAMESTR("run"), (PyCFunction)__pyx_pf_14netfilterqueue_14NetfilterQueue_4run, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_14netfilterqueue_14NetfilterQueue_4run)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_QueueHandler = { +static PyNumberMethods __pyx_tp_as_number_NetfilterQueue = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -3164,7 +3231,7 @@ static PyNumberMethods __pyx_tp_as_number_QueueHandler = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_QueueHandler = { +static PySequenceMethods __pyx_tp_as_sequence_NetfilterQueue = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -3177,13 +3244,13 @@ static PySequenceMethods __pyx_tp_as_sequence_QueueHandler = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_QueueHandler = { +static PyMappingMethods __pyx_tp_as_mapping_NetfilterQueue = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_QueueHandler = { +static PyBufferProcs __pyx_tp_as_buffer_NetfilterQueue = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -3204,12 +3271,12 @@ static PyBufferProcs __pyx_tp_as_buffer_QueueHandler = { #endif }; -static PyTypeObject __pyx_type_14netfilterqueue_QueueHandler = { +static PyTypeObject __pyx_type_14netfilterqueue_NetfilterQueue = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("netfilterqueue.QueueHandler"), /*tp_name*/ - sizeof(struct __pyx_obj_14netfilterqueue_QueueHandler), /*tp_basicsize*/ + __Pyx_NAMESTR("netfilterqueue.NetfilterQueue"), /*tp_name*/ + sizeof(struct __pyx_obj_14netfilterqueue_NetfilterQueue), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_14netfilterqueue_QueueHandler, /*tp_dealloc*/ + __pyx_tp_dealloc_14netfilterqueue_NetfilterQueue, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -3219,24 +3286,24 @@ static PyTypeObject __pyx_type_14netfilterqueue_QueueHandler = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_QueueHandler, /*tp_as_number*/ - &__pyx_tp_as_sequence_QueueHandler, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_QueueHandler, /*tp_as_mapping*/ + &__pyx_tp_as_number_NetfilterQueue, /*tp_as_number*/ + &__pyx_tp_as_sequence_NetfilterQueue, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_NetfilterQueue, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_QueueHandler, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_NetfilterQueue, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ __Pyx_DOCSTR("Handle a single numbered queue."), /*tp_doc*/ - __pyx_tp_traverse_14netfilterqueue_QueueHandler, /*tp_traverse*/ - __pyx_tp_clear_14netfilterqueue_QueueHandler, /*tp_clear*/ + __pyx_tp_traverse_14netfilterqueue_NetfilterQueue, /*tp_traverse*/ + __pyx_tp_clear_14netfilterqueue_NetfilterQueue, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_14netfilterqueue_QueueHandler, /*tp_methods*/ + __pyx_methods_14netfilterqueue_NetfilterQueue, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -3246,7 +3313,7 @@ static PyTypeObject __pyx_type_14netfilterqueue_QueueHandler = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_14netfilterqueue_QueueHandler, /*tp_new*/ + __pyx_tp_new_14netfilterqueue_NetfilterQueue, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -3268,7 +3335,7 @@ static PyMethodDef __pyx_methods[] = { static struct PyModuleDef __pyx_moduledef = { PyModuleDef_HEAD_INIT, __Pyx_NAMESTR("netfilterqueue"), - 0, /* m_doc */ + __Pyx_DOCSTR(__pyx_k_15), /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ @@ -3282,9 +3349,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0}, {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0}, - {&__pyx_n_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 1}, - {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0}, - {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0}, + {&__pyx_n_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 1}, {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0}, {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0}, {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0}, @@ -3327,6 +3392,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 0}, {&__pyx_kp_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 0}, {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0}, + {&__pyx_kp_s_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 0}, + {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0}, {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0}, {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0}, {&__pyx_kp_s__3PC, __pyx_k__3PC, sizeof(__pyx_k__3PC), 0, 0, 1, 0}, @@ -3428,6 +3495,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__UDP, __pyx_k__UDP, sizeof(__pyx_k__UDP), 0, 0, 1, 1}, {&__pyx_n_s__UDPLite, __pyx_k__UDPLite, sizeof(__pyx_k__UDPLite), 0, 0, 1, 1}, {&__pyx_n_s__UTI, __pyx_k__UTI, sizeof(__pyx_k__UTI), 0, 0, 1, 1}, + {&__pyx_n_s__VERSION, __pyx_k__VERSION, sizeof(__pyx_k__VERSION), 0, 0, 1, 1}, {&__pyx_n_s__VINES, __pyx_k__VINES, sizeof(__pyx_k__VINES), 0, 0, 1, 1}, {&__pyx_n_s__VISA, __pyx_k__VISA, sizeof(__pyx_k__VISA), 0, 0, 1, 1}, {&__pyx_n_s__VMTP, __pyx_k__VMTP, sizeof(__pyx_k__VMTP), 0, 0, 1, 1}, @@ -3437,108 +3505,108 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__XTP, __pyx_k__XTP, sizeof(__pyx_k__XTP), 0, 0, 1, 1}, {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, - {&__pyx_n_s___given_mark, __pyx_k___given_mark, sizeof(__pyx_k___given_mark), 0, 0, 1, 1}, - {&__pyx_n_s___given_payload, __pyx_k___given_payload, sizeof(__pyx_k___given_payload), 0, 0, 1, 1}, - {&__pyx_n_s___hdr, __pyx_k___hdr, sizeof(__pyx_k___hdr), 0, 0, 1, 1}, - {&__pyx_n_s___mark_is_set, __pyx_k___mark_is_set, sizeof(__pyx_k___mark_is_set), 0, 0, 1, 1}, - {&__pyx_n_s___nfa, __pyx_k___nfa, sizeof(__pyx_k___nfa), 0, 0, 1, 1}, - {&__pyx_n_s___qh, __pyx_k___qh, sizeof(__pyx_k___qh), 0, 0, 1, 1}, - {&__pyx_n_s___verdict_is_set, __pyx_k___verdict_is_set, sizeof(__pyx_k___verdict_is_set), 0, 0, 1, 1}, {&__pyx_n_s__accept, __pyx_k__accept, sizeof(__pyx_k__accept), 0, 0, 1, 1}, {&__pyx_n_s__af, __pyx_k__af, sizeof(__pyx_k__af), 0, 0, 1, 1}, {&__pyx_n_s__drop, __pyx_k__drop, sizeof(__pyx_k__drop), 0, 0, 1, 1}, {&__pyx_n_s__get, __pyx_k__get, sizeof(__pyx_k__get), 0, 0, 1, 1}, {&__pyx_n_s__get_payload_len, __pyx_k__get_payload_len, sizeof(__pyx_k__get_payload_len), 0, 0, 1, 1}, {&__pyx_n_s__get_timestamp, __pyx_k__get_timestamp, sizeof(__pyx_k__get_timestamp), 0, 0, 1, 1}, - {&__pyx_n_s__h, __pyx_k__h, sizeof(__pyx_k__h), 0, 0, 1, 1}, - {&__pyx_n_s__handle, __pyx_k__handle, sizeof(__pyx_k__handle), 0, 0, 1, 1}, - {&__pyx_n_s__hook, __pyx_k__hook, sizeof(__pyx_k__hook), 0, 0, 1, 1}, - {&__pyx_n_s__hw_protocol, __pyx_k__hw_protocol, sizeof(__pyx_k__hw_protocol), 0, 0, 1, 1}, - {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1}, {&__pyx_n_s__manet, __pyx_k__manet, sizeof(__pyx_k__manet), 0, 0, 1, 1}, {&__pyx_n_s__max_len, __pyx_k__max_len, sizeof(__pyx_k__max_len), 0, 0, 1, 1}, {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1}, - {&__pyx_n_s__packet_id, __pyx_k__packet_id, sizeof(__pyx_k__packet_id), 0, 0, 1, 1}, - {&__pyx_n_s__payload, __pyx_k__payload, sizeof(__pyx_k__payload), 0, 0, 1, 1}, - {&__pyx_n_s__payload_len, __pyx_k__payload_len, sizeof(__pyx_k__payload_len), 0, 0, 1, 1}, - {&__pyx_n_s__protocol, __pyx_k__protocol, sizeof(__pyx_k__protocol), 0, 0, 1, 1}, - {&__pyx_n_s__qh, __pyx_k__qh, sizeof(__pyx_k__qh), 0, 0, 1, 1}, {&__pyx_n_s__queue_num, __pyx_k__queue_num, sizeof(__pyx_k__queue_num), 0, 0, 1, 1}, {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, {&__pyx_n_s__set_mark, __pyx_k__set_mark, sizeof(__pyx_k__set_mark), 0, 0, 1, 1}, - {&__pyx_n_s__set_nfq_data, __pyx_k__set_nfq_data, sizeof(__pyx_k__set_nfq_data), 0, 0, 1, 1}, - {&__pyx_n_s__timestamp, __pyx_k__timestamp, sizeof(__pyx_k__timestamp), 0, 0, 1, 1}, - {&__pyx_n_s__tv_sec, __pyx_k__tv_sec, sizeof(__pyx_k__tv_sec), 0, 0, 1, 1}, - {&__pyx_n_s__tv_usec, __pyx_k__tv_usec, sizeof(__pyx_k__tv_usec), 0, 0, 1, 1}, - {&__pyx_n_s__verdict, __pyx_k__verdict, sizeof(__pyx_k__verdict), 0, 0, 1, 1}, + {&__pyx_n_s__user_callback, __pyx_k__user_callback, sizeof(__pyx_k__user_callback), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_OSError = __Pyx_GetName(__pyx_b, __pyx_n_s__OSError); if (!__pyx_builtin_OSError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_RuntimeWarning = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeWarning); if (!__pyx_builtin_RuntimeWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_OSError = __Pyx_GetName(__pyx_b, __pyx_n_s__OSError); if (!__pyx_builtin_OSError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_RuntimeWarning = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeWarning); if (!__pyx_builtin_RuntimeWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants"); - /* "netfilterqueue.pyx":50 + /* "netfilterqueue.pyx":61 * self.payload_len = nfq_get_payload(self._nfa, &self.payload) * if self.payload_len < 0: * raise OSError("Failed to get payload of packet.") # <<<<<<<<<<<<<< * * nfq_get_timestamp(self._nfa, &self.timestamp) */ - __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4)); __Pyx_INCREF(((PyObject *)__pyx_kp_s_3)); PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_s_3)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4)); - /* "netfilterqueue.pyx":57 + /* "netfilterqueue.pyx":68 * """Call appropriate set_verdict... function on packet.""" * if self._verdict_is_set: * raise RuntimeWarning("Verdict already given for this packet.") # <<<<<<<<<<<<<< * * if self._mark_is_set: */ - __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_6)); __Pyx_INCREF(((PyObject *)__pyx_kp_s_5)); PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_kp_s_5)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); - /* "netfilterqueue.pyx":114 + /* "netfilterqueue.pyx":125 * self.h = nfq_open() * if self.h == NULL: * raise OSError("Failed to open NFQueue.") # <<<<<<<<<<<<<< * nfq_unbind_pf(self.h, self.af) # This does NOT kick out previous * # running queues */ - __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_8)); __Pyx_INCREF(((PyObject *)__pyx_kp_s_7)); PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_kp_s_7)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8)); - /* "netfilterqueue.pyx":136 + /* "netfilterqueue.pyx":149 * range = MaxCopySize * if nfq_set_mode(self.qh, mode, range) < 0: * raise OSError("Failed to set packet copy mode.") # <<<<<<<<<<<<<< * * nfq_set_queue_maxlen(self.qh, max_len) */ - __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_14)); __Pyx_INCREF(((PyObject *)__pyx_kp_s_13)); PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_13)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14)); + + /* "netfilterqueue.pyx":8 + * License: GPL + * """ + * VERSION = (0, 3, 0) # <<<<<<<<<<<<<< + * + * # Constants for module users + */ + __pyx_k_tuple_16 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_16)); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_k_tuple_16, 0, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_k_tuple_16, 1, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_k_tuple_16, 2, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_16)); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -3706,8 +3774,8 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) { PyObject *__pyx_t_1 = NULL; u_int32_t __pyx_t_2; + __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY - void* __pyx_refnanny = NULL; __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); @@ -3715,8 +3783,9 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } - __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_netfilterqueue(void)", __LINE__, __FILE__); #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_netfilterqueue(void)"); + if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #ifdef __pyx_binding_PyCFunctionType_USED @@ -3731,7 +3800,7 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4(__Pyx_NAMESTR("netfilterqueue"), __pyx_methods, 0, 0, PYTHON_API_VERSION); + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("netfilterqueue"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_15), 0, PYTHON_API_VERSION); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif @@ -3752,6 +3821,7 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) /*--- Constants init code ---*/ if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ + /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ __pyx_vtabptr_14netfilterqueue_Packet = &__pyx_vtable_14netfilterqueue_Packet; @@ -3762,225 +3832,243 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) __pyx_vtable_14netfilterqueue_Packet.set_mark = (PyObject *(*)(struct __pyx_obj_14netfilterqueue_Packet *, u_int32_t, int __pyx_skip_dispatch))__pyx_f_14netfilterqueue_6Packet_set_mark; __pyx_vtable_14netfilterqueue_Packet.accept = (PyObject *(*)(struct __pyx_obj_14netfilterqueue_Packet *, int __pyx_skip_dispatch))__pyx_f_14netfilterqueue_6Packet_accept; __pyx_vtable_14netfilterqueue_Packet.drop = (PyObject *(*)(struct __pyx_obj_14netfilterqueue_Packet *, int __pyx_skip_dispatch))__pyx_f_14netfilterqueue_6Packet_drop; - if (PyType_Ready(&__pyx_type_14netfilterqueue_Packet) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_14netfilterqueue_Packet.tp_dict, __pyx_vtabptr_14netfilterqueue_Packet) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Packet", (PyObject *)&__pyx_type_14netfilterqueue_Packet) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_14netfilterqueue_Packet) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_14netfilterqueue_Packet.tp_dict, __pyx_vtabptr_14netfilterqueue_Packet) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Packet", (PyObject *)&__pyx_type_14netfilterqueue_Packet) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_14netfilterqueue_Packet = &__pyx_type_14netfilterqueue_Packet; - if (PyType_Ready(&__pyx_type_14netfilterqueue_QueueHandler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "QueueHandler", (PyObject *)&__pyx_type_14netfilterqueue_QueueHandler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_14netfilterqueue_QueueHandler = &__pyx_type_14netfilterqueue_QueueHandler; + if (PyType_Ready(&__pyx_type_14netfilterqueue_NetfilterQueue) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "NetfilterQueue", (PyObject *)&__pyx_type_14netfilterqueue_NetfilterQueue) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_14netfilterqueue_NetfilterQueue = &__pyx_type_14netfilterqueue_NetfilterQueue; /*--- Type import code ---*/ + /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ - /* "netfilterqueue.pyx":3 - * ## cython: profile=True + /* "netfilterqueue.pyx":8 + * License: GPL + * """ + * VERSION = (0, 3, 0) # <<<<<<<<<<<<<< + * + * # Constants for module users + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VERSION, ((PyObject *)__pyx_k_tuple_16)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "netfilterqueue.pyx":11 + * * # Constants for module users * COPY_NONE = 1 # <<<<<<<<<<<<<< * COPY_META = 2 * COPY_PACKET = 3 */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__COPY_NONE, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__COPY_NONE, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "netfilterqueue.pyx":4 + /* "netfilterqueue.pyx":12 * # Constants for module users * COPY_NONE = 1 * COPY_META = 2 # <<<<<<<<<<<<<< * COPY_PACKET = 3 * */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__COPY_META, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__COPY_META, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "netfilterqueue.pyx":5 + /* "netfilterqueue.pyx":13 * COPY_NONE = 1 * COPY_META = 2 * COPY_PACKET = 3 # <<<<<<<<<<<<<< * * DEFAULT_MAX_QUEUELEN = 1024 */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__COPY_PACKET, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__COPY_PACKET, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "netfilterqueue.pyx":7 + /* "netfilterqueue.pyx":15 * COPY_PACKET = 3 * * DEFAULT_MAX_QUEUELEN = 1024 # <<<<<<<<<<<<<< * * # Packet copying defaults */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_15, __pyx_int_1024) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_17, __pyx_int_1024) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "netfilterqueue.pyx":127 + /* "netfilterqueue.pyx":138 * nfq_close(self.h) * - * def bind(self, int queue_num, u_int32_t max_len=DEFAULT_MAX_QUEUELEN, u_int8_t mode=NFQNL_COPY_PACKET, u_int32_t range=MaxPacketSize): # <<<<<<<<<<<<<< + * def bind(self, int queue_num, object user_callback, u_int32_t max_len=DEFAULT_MAX_QUEUELEN, # <<<<<<<<<<<<<< + * u_int8_t mode=NFQNL_COPY_PACKET, u_int32_t range=MaxPacketSize): * """Create and bind to a new queue.""" - * self.qh = nfq_create_queue(self.h, queue_num, global_callback, self) */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_15); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_17); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_from_py_u_int32_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_from_py_u_int32_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (u_int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_k_10 = __pyx_t_2; + + /* "netfilterqueue.pyx":139 + * + * def bind(self, int queue_num, object user_callback, u_int32_t max_len=DEFAULT_MAX_QUEUELEN, + * u_int8_t mode=NFQNL_COPY_PACKET, u_int32_t range=MaxPacketSize): # <<<<<<<<<<<<<< + * """Create and bind to a new queue.""" + * self.user_callback = user_callback + */ __pyx_k_11 = NFQNL_COPY_PACKET; - /* "netfilterqueue.pyx":162 - * packet.accept() + /* "netfilterqueue.pyx":171 + * rv = recv(fd, buf, sizeof(buf), 0) * * PROTOCOLS = { # <<<<<<<<<<<<<< * 0: "HOPOPT", * 1: "ICMP", */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyDict_SetItem(__pyx_t_1, __pyx_int_0, ((PyObject *)__pyx_n_s__HOPOPT)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_1, ((PyObject *)__pyx_n_s__ICMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_2, ((PyObject *)__pyx_n_s__IGMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_3, ((PyObject *)__pyx_n_s__GGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_4, ((PyObject *)__pyx_n_s__IP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_5, ((PyObject *)__pyx_n_s__ST)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_6, ((PyObject *)__pyx_n_s__TCP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_7, ((PyObject *)__pyx_n_s__CBT)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_8, ((PyObject *)__pyx_n_s__EGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_9, ((PyObject *)__pyx_n_s__IGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_10, ((PyObject *)__pyx_kp_s_16)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_11, ((PyObject *)__pyx_kp_s_17)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_12, ((PyObject *)__pyx_n_s__PUP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_13, ((PyObject *)__pyx_n_s__ARGUS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_14, ((PyObject *)__pyx_n_s__EMCON)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_15, ((PyObject *)__pyx_n_s__XNET)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_16, ((PyObject *)__pyx_n_s__CHAOS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_17, ((PyObject *)__pyx_n_s__UDP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_18, ((PyObject *)__pyx_n_s__MUX)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_19, ((PyObject *)__pyx_kp_s_18)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_20, ((PyObject *)__pyx_n_s__HMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_21, ((PyObject *)__pyx_n_s__PRM)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_22, ((PyObject *)__pyx_kp_s_19)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_23, ((PyObject *)__pyx_kp_s_20)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_24, ((PyObject *)__pyx_kp_s_21)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_25, ((PyObject *)__pyx_kp_s_22)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_26, ((PyObject *)__pyx_kp_s_23)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_27, ((PyObject *)__pyx_n_s__RDP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_28, ((PyObject *)__pyx_n_s__IRTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_29, ((PyObject *)__pyx_kp_s_24)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_30, ((PyObject *)__pyx_n_s__NETBLT)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_31, ((PyObject *)__pyx_kp_s_25)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_32, ((PyObject *)__pyx_kp_s_26)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_33, ((PyObject *)__pyx_n_s__DCCP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_34, ((PyObject *)__pyx_kp_s__3PC)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_35, ((PyObject *)__pyx_n_s__IDPR)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_36, ((PyObject *)__pyx_n_s__XTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_37, ((PyObject *)__pyx_n_s__DDP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_38, ((PyObject *)__pyx_kp_s_27)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_39, ((PyObject *)__pyx_kp_s_28)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_40, ((PyObject *)__pyx_n_s__IL)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_41, ((PyObject *)__pyx_n_s__IPv6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_42, ((PyObject *)__pyx_n_s__SDRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_43, ((PyObject *)__pyx_kp_s_29)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_44, ((PyObject *)__pyx_kp_s_30)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_45, ((PyObject *)__pyx_n_s__IDRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_46, ((PyObject *)__pyx_n_s__RSVP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_47, ((PyObject *)__pyx_n_s__GRE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_48, ((PyObject *)__pyx_n_s__DSR)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_49, ((PyObject *)__pyx_n_s__BNA)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_50, ((PyObject *)__pyx_n_s__ESP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_51, ((PyObject *)__pyx_n_s__AH)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_52, ((PyObject *)__pyx_kp_s_31)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_53, ((PyObject *)__pyx_n_s__SWIPE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_54, ((PyObject *)__pyx_n_s__NARP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_55, ((PyObject *)__pyx_n_s__MOBILE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_56, ((PyObject *)__pyx_n_s__TLSP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_57, ((PyObject *)__pyx_n_s__SKIP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_58, ((PyObject *)__pyx_kp_s_32)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_59, ((PyObject *)__pyx_kp_s_33)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_60, ((PyObject *)__pyx_kp_s_34)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_61, ((PyObject *)__pyx_kp_s_35)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_62, ((PyObject *)__pyx_n_s__CFTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_63, ((PyObject *)__pyx_kp_s_36)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_64, ((PyObject *)__pyx_kp_s_37)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_65, ((PyObject *)__pyx_n_s__KRYPTOLAN)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_66, ((PyObject *)__pyx_n_s__RVD)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_67, ((PyObject *)__pyx_n_s__IPPC)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_68, ((PyObject *)__pyx_kp_s_38)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_69, ((PyObject *)__pyx_kp_s_39)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_70, ((PyObject *)__pyx_n_s__VISA)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_71, ((PyObject *)__pyx_n_s__IPCV)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_72, ((PyObject *)__pyx_n_s__CPNX)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_73, ((PyObject *)__pyx_n_s__CPHB)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_74, ((PyObject *)__pyx_n_s__WSN)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_75, ((PyObject *)__pyx_n_s__PVP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_76, ((PyObject *)__pyx_kp_s_40)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_77, ((PyObject *)__pyx_kp_s_41)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_78, ((PyObject *)__pyx_kp_s_42)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_79, ((PyObject *)__pyx_kp_s_43)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_80, ((PyObject *)__pyx_kp_s_44)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_81, ((PyObject *)__pyx_n_s__VMTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_82, ((PyObject *)__pyx_kp_s_45)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_83, ((PyObject *)__pyx_n_s__VINES)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_84, ((PyObject *)__pyx_n_s__TTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_85, ((PyObject *)__pyx_kp_s_46)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_86, ((PyObject *)__pyx_n_s__DGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_87, ((PyObject *)__pyx_n_s__TCF)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_88, ((PyObject *)__pyx_n_s__EIGRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_89, ((PyObject *)__pyx_n_s__OSPFIGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_90, ((PyObject *)__pyx_kp_s_47)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_91, ((PyObject *)__pyx_n_s__LARP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_92, ((PyObject *)__pyx_n_s__MTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_93, ((PyObject *)__pyx_kp_s_48)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_94, ((PyObject *)__pyx_n_s__IPIP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_95, ((PyObject *)__pyx_n_s__MICP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_96, ((PyObject *)__pyx_kp_s_49)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_97, ((PyObject *)__pyx_n_s__ETHERIP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_98, ((PyObject *)__pyx_n_s__ENCAP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_99, ((PyObject *)__pyx_kp_s_50)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_100, ((PyObject *)__pyx_n_s__GMTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_101, ((PyObject *)__pyx_n_s__IFMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_102, ((PyObject *)__pyx_n_s__PNNI)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_103, ((PyObject *)__pyx_n_s__PIM)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_104, ((PyObject *)__pyx_n_s__ARIS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_105, ((PyObject *)__pyx_n_s__SCPS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_106, ((PyObject *)__pyx_n_s__QNX)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_107, ((PyObject *)__pyx_kp_s_51)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_108, ((PyObject *)__pyx_n_s__IPComp)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_109, ((PyObject *)__pyx_n_s__SNP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_110, ((PyObject *)__pyx_kp_s_52)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_111, ((PyObject *)__pyx_kp_s_53)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_112, ((PyObject *)__pyx_n_s__VRRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_113, ((PyObject *)__pyx_n_s__PGM)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_114, ((PyObject *)__pyx_kp_s_54)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_115, ((PyObject *)__pyx_n_s__L2TP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_116, ((PyObject *)__pyx_n_s__DDX)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_117, ((PyObject *)__pyx_n_s__IATP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_118, ((PyObject *)__pyx_n_s__STP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_119, ((PyObject *)__pyx_n_s__SRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_120, ((PyObject *)__pyx_n_s__UTI)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_121, ((PyObject *)__pyx_n_s__SMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_122, ((PyObject *)__pyx_n_s__SM)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_123, ((PyObject *)__pyx_n_s__PTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_124, ((PyObject *)__pyx_n_s__ISIS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_125, ((PyObject *)__pyx_n_s__FIRE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_126, ((PyObject *)__pyx_n_s__CRTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_127, ((PyObject *)__pyx_n_s__CRUDP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_128, ((PyObject *)__pyx_n_s__SSCOPMCE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_129, ((PyObject *)__pyx_n_s__IPLT)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_130, ((PyObject *)__pyx_n_s__SPS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_131, ((PyObject *)__pyx_n_s__PIPE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_132, ((PyObject *)__pyx_n_s__SCTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_133, ((PyObject *)__pyx_n_s__FC)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_134, ((PyObject *)__pyx_kp_s_55)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_135, ((PyObject *)__pyx_n_s__Mobility)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_136, ((PyObject *)__pyx_n_s__UDPLite)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_137, ((PyObject *)__pyx_kp_s_56)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_138, ((PyObject *)__pyx_n_s__manet)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_139, ((PyObject *)__pyx_n_s__HIP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_140, ((PyObject *)__pyx_n_s__Shim6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, __pyx_int_255, ((PyObject *)__pyx_n_s__Reserved)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PROTOCOLS, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_0, ((PyObject *)__pyx_n_s__HOPOPT)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_1, ((PyObject *)__pyx_n_s__ICMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_2, ((PyObject *)__pyx_n_s__IGMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_3, ((PyObject *)__pyx_n_s__GGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_4, ((PyObject *)__pyx_n_s__IP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_5, ((PyObject *)__pyx_n_s__ST)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_6, ((PyObject *)__pyx_n_s__TCP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_7, ((PyObject *)__pyx_n_s__CBT)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_8, ((PyObject *)__pyx_n_s__EGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_9, ((PyObject *)__pyx_n_s__IGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_10, ((PyObject *)__pyx_kp_s_18)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_11, ((PyObject *)__pyx_kp_s_19)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_12, ((PyObject *)__pyx_n_s__PUP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_13, ((PyObject *)__pyx_n_s__ARGUS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_14, ((PyObject *)__pyx_n_s__EMCON)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_15, ((PyObject *)__pyx_n_s__XNET)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_16, ((PyObject *)__pyx_n_s__CHAOS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_17, ((PyObject *)__pyx_n_s__UDP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_18, ((PyObject *)__pyx_n_s__MUX)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_19, ((PyObject *)__pyx_kp_s_20)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_20, ((PyObject *)__pyx_n_s__HMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_21, ((PyObject *)__pyx_n_s__PRM)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_22, ((PyObject *)__pyx_kp_s_21)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_23, ((PyObject *)__pyx_kp_s_22)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_24, ((PyObject *)__pyx_kp_s_23)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_25, ((PyObject *)__pyx_kp_s_24)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_26, ((PyObject *)__pyx_kp_s_25)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_27, ((PyObject *)__pyx_n_s__RDP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_28, ((PyObject *)__pyx_n_s__IRTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_29, ((PyObject *)__pyx_kp_s_26)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_30, ((PyObject *)__pyx_n_s__NETBLT)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_31, ((PyObject *)__pyx_kp_s_27)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_32, ((PyObject *)__pyx_kp_s_28)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_33, ((PyObject *)__pyx_n_s__DCCP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_34, ((PyObject *)__pyx_kp_s__3PC)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_35, ((PyObject *)__pyx_n_s__IDPR)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_36, ((PyObject *)__pyx_n_s__XTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_37, ((PyObject *)__pyx_n_s__DDP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_38, ((PyObject *)__pyx_kp_s_29)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_39, ((PyObject *)__pyx_kp_s_30)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_40, ((PyObject *)__pyx_n_s__IL)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_41, ((PyObject *)__pyx_n_s__IPv6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_42, ((PyObject *)__pyx_n_s__SDRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_43, ((PyObject *)__pyx_kp_s_31)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_44, ((PyObject *)__pyx_kp_s_32)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_45, ((PyObject *)__pyx_n_s__IDRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_46, ((PyObject *)__pyx_n_s__RSVP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_47, ((PyObject *)__pyx_n_s__GRE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_48, ((PyObject *)__pyx_n_s__DSR)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_49, ((PyObject *)__pyx_n_s__BNA)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_50, ((PyObject *)__pyx_n_s__ESP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_51, ((PyObject *)__pyx_n_s__AH)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_52, ((PyObject *)__pyx_kp_s_33)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_53, ((PyObject *)__pyx_n_s__SWIPE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_54, ((PyObject *)__pyx_n_s__NARP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_55, ((PyObject *)__pyx_n_s__MOBILE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_56, ((PyObject *)__pyx_n_s__TLSP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_57, ((PyObject *)__pyx_n_s__SKIP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_58, ((PyObject *)__pyx_kp_s_34)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_59, ((PyObject *)__pyx_kp_s_35)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_60, ((PyObject *)__pyx_kp_s_36)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_61, ((PyObject *)__pyx_kp_s_37)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_62, ((PyObject *)__pyx_n_s__CFTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_63, ((PyObject *)__pyx_kp_s_38)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_64, ((PyObject *)__pyx_kp_s_39)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_65, ((PyObject *)__pyx_n_s__KRYPTOLAN)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_66, ((PyObject *)__pyx_n_s__RVD)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_67, ((PyObject *)__pyx_n_s__IPPC)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_68, ((PyObject *)__pyx_kp_s_40)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_69, ((PyObject *)__pyx_kp_s_41)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_70, ((PyObject *)__pyx_n_s__VISA)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_71, ((PyObject *)__pyx_n_s__IPCV)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_72, ((PyObject *)__pyx_n_s__CPNX)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_73, ((PyObject *)__pyx_n_s__CPHB)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_74, ((PyObject *)__pyx_n_s__WSN)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_75, ((PyObject *)__pyx_n_s__PVP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_76, ((PyObject *)__pyx_kp_s_42)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_77, ((PyObject *)__pyx_kp_s_43)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_78, ((PyObject *)__pyx_kp_s_44)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_79, ((PyObject *)__pyx_kp_s_45)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_80, ((PyObject *)__pyx_kp_s_46)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_81, ((PyObject *)__pyx_n_s__VMTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_82, ((PyObject *)__pyx_kp_s_47)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_83, ((PyObject *)__pyx_n_s__VINES)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_84, ((PyObject *)__pyx_n_s__TTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_85, ((PyObject *)__pyx_kp_s_48)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_86, ((PyObject *)__pyx_n_s__DGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_87, ((PyObject *)__pyx_n_s__TCF)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_88, ((PyObject *)__pyx_n_s__EIGRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_89, ((PyObject *)__pyx_n_s__OSPFIGP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_90, ((PyObject *)__pyx_kp_s_49)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_91, ((PyObject *)__pyx_n_s__LARP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_92, ((PyObject *)__pyx_n_s__MTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_93, ((PyObject *)__pyx_kp_s_50)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_94, ((PyObject *)__pyx_n_s__IPIP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_95, ((PyObject *)__pyx_n_s__MICP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_96, ((PyObject *)__pyx_kp_s_51)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_97, ((PyObject *)__pyx_n_s__ETHERIP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_98, ((PyObject *)__pyx_n_s__ENCAP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_99, ((PyObject *)__pyx_kp_s_52)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_100, ((PyObject *)__pyx_n_s__GMTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_101, ((PyObject *)__pyx_n_s__IFMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_102, ((PyObject *)__pyx_n_s__PNNI)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_103, ((PyObject *)__pyx_n_s__PIM)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_104, ((PyObject *)__pyx_n_s__ARIS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_105, ((PyObject *)__pyx_n_s__SCPS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_106, ((PyObject *)__pyx_n_s__QNX)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_107, ((PyObject *)__pyx_kp_s_53)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_108, ((PyObject *)__pyx_n_s__IPComp)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_109, ((PyObject *)__pyx_n_s__SNP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_110, ((PyObject *)__pyx_kp_s_54)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_111, ((PyObject *)__pyx_kp_s_55)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_112, ((PyObject *)__pyx_n_s__VRRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_113, ((PyObject *)__pyx_n_s__PGM)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_114, ((PyObject *)__pyx_kp_s_56)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_115, ((PyObject *)__pyx_n_s__L2TP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_116, ((PyObject *)__pyx_n_s__DDX)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_117, ((PyObject *)__pyx_n_s__IATP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_118, ((PyObject *)__pyx_n_s__STP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_119, ((PyObject *)__pyx_n_s__SRP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_120, ((PyObject *)__pyx_n_s__UTI)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_121, ((PyObject *)__pyx_n_s__SMP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_122, ((PyObject *)__pyx_n_s__SM)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_123, ((PyObject *)__pyx_n_s__PTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_124, ((PyObject *)__pyx_n_s__ISIS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_125, ((PyObject *)__pyx_n_s__FIRE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_126, ((PyObject *)__pyx_n_s__CRTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_127, ((PyObject *)__pyx_n_s__CRUDP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_128, ((PyObject *)__pyx_n_s__SSCOPMCE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_129, ((PyObject *)__pyx_n_s__IPLT)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_130, ((PyObject *)__pyx_n_s__SPS)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_131, ((PyObject *)__pyx_n_s__PIPE)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_132, ((PyObject *)__pyx_n_s__SCTP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_133, ((PyObject *)__pyx_n_s__FC)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_134, ((PyObject *)__pyx_kp_s_57)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_135, ((PyObject *)__pyx_n_s__Mobility)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_136, ((PyObject *)__pyx_n_s__UDPLite)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_137, ((PyObject *)__pyx_kp_s_58)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_138, ((PyObject *)__pyx_n_s__manet)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_139, ((PyObject *)__pyx_n_s__HIP)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_140, ((PyObject *)__pyx_n_s__Shim6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_int_255, ((PyObject *)__pyx_n_s__Reserved)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PROTOCOLS, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; /* "netfilterqueue.pyx":1 - * ## cython: profile=True # <<<<<<<<<<<<<< - * # Constants for module users - * COPY_NONE = 1 + * """ # <<<<<<<<<<<<<< + * Bind to a Linux netfilter queue. Send packets to a user-specified callback + * function. */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); @@ -3990,7 +4078,7 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); if (__pyx_m) { - __Pyx_AddTraceback("init netfilterqueue"); + __Pyx_AddTraceback("init netfilterqueue", __pyx_clineno, __pyx_lineno, __pyx_filename); Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init netfilterqueue"); @@ -4006,11 +4094,34 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) /* Runtime support code */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif /* CYTHON_REFNANNY */ + static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { PyObject *result; result = PyObject_GetAttr(dict, name); - if (!result) - PyErr_SetObject(PyExc_NameError, name); + if (!result) { + if (dict != __pyx_b) { + PyErr_Clear(); + result = PyObject_GetAttr(__pyx_b, name); + } + if (!result) { + PyErr_SetObject(PyExc_NameError, name); + } + } return result; } @@ -4022,7 +4133,7 @@ static void __Pyx_RaiseArgtupleInvalid( Py_ssize_t num_found) { Py_ssize_t num_expected; - const char *number, *more_or_less; + const char *more_or_less; if (num_found < num_min) { num_expected = num_min; @@ -4034,14 +4145,10 @@ static void __Pyx_RaiseArgtupleInvalid( if (exact) { more_or_less = "exactly"; } - number = (num_expected == 1) ? "" : "s"; PyErr_Format(PyExc_TypeError, - #if PY_VERSION_HEX < 0x02050000 - "%s() takes %s %d positional argument%s (%d given)", - #else - "%s() takes %s %zd positional argument%s (%zd given)", - #endif - func_name, more_or_less, num_expected, number, num_found); + "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); } static CYTHON_INLINE int __Pyx_CheckKeywordStrings( @@ -4106,7 +4213,8 @@ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyOb #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + /* cause is unused */ Py_XINCREF(type); Py_XINCREF(value); Py_XINCREF(tb); @@ -4173,7 +4281,7 @@ raise_error: #else /* Python 3+ */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { @@ -4198,6 +4306,29 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { goto bad; } + if (cause) { + PyObject *fixed_cause; + if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } + else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } + else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + if (!value) { + value = PyObject_CallObject(type, NULL); + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); if (tb) { @@ -4307,26 +4438,6 @@ bad: return -1; } -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) -{ - if (!type) { - PyErr_Format(PyExc_SystemError, "Missing type object"); - return 0; - } - if (none_allowed && obj == Py_None) return 1; - else if (exact) { - if (Py_TYPE(obj) == type) return 1; - } - else { - if (PyObject_TypeCheck(obj, type)) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%s' has incorrect type (expected %s, got %s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} - static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_u_int32_t(u_int32_t val) { const u_int32_t neg_one = (u_int32_t)-1, const_zero = (u_int32_t)0; const int is_unsigned = const_zero < neg_one; @@ -4347,7 +4458,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_u_int32_t(u_int32_t val) { } else { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; - return _PyLong_FromByteArray(bytes, sizeof(u_int32_t), + return _PyLong_FromByteArray(bytes, sizeof(u_int32_t), little, !is_unsigned); } } @@ -4372,7 +4483,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_u_int16_t(u_int16_t val) { } else { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; - return _PyLong_FromByteArray(bytes, sizeof(u_int16_t), + return _PyLong_FromByteArray(bytes, sizeof(u_int16_t), little, !is_unsigned); } } @@ -4397,7 +4508,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_u_int8_t(u_int8_t val) { } else { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; - return _PyLong_FromByteArray(bytes, sizeof(u_int8_t), + return _PyLong_FromByteArray(bytes, sizeof(u_int8_t), little, !is_unsigned); } } @@ -4717,9 +4828,9 @@ static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { "can't convert negative value to unsigned long"); return (unsigned long)-1; } - return PyLong_AsUnsignedLong(x); + return (unsigned long)PyLong_AsUnsignedLong(x); } else { - return PyLong_AsLong(x); + return (unsigned long)PyLong_AsLong(x); } } else { unsigned long val; @@ -4752,9 +4863,9 @@ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObje "can't convert negative value to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG)-1; } - return PyLong_AsUnsignedLongLong(x); + return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { - return PyLong_AsLongLong(x); + return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); } } else { unsigned PY_LONG_LONG val; @@ -4787,9 +4898,9 @@ static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { "can't convert negative value to long"); return (long)-1; } - return PyLong_AsUnsignedLong(x); + return (long)PyLong_AsUnsignedLong(x); } else { - return PyLong_AsLong(x); + return (long)PyLong_AsLong(x); } } else { long val; @@ -4822,9 +4933,9 @@ static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { "can't convert negative value to PY_LONG_LONG"); return (PY_LONG_LONG)-1; } - return PyLong_AsUnsignedLongLong(x); + return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { - return PyLong_AsLongLong(x); + return (PY_LONG_LONG)PyLong_AsLongLong(x); } } else { PY_LONG_LONG val; @@ -4857,9 +4968,9 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { "can't convert negative value to signed long"); return (signed long)-1; } - return PyLong_AsUnsignedLong(x); + return (signed long)PyLong_AsUnsignedLong(x); } else { - return PyLong_AsLong(x); + return (signed long)PyLong_AsLong(x); } } else { signed long val; @@ -4892,9 +5003,9 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* "can't convert negative value to signed PY_LONG_LONG"); return (signed PY_LONG_LONG)-1; } - return PyLong_AsUnsignedLongLong(x); + return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { - return PyLong_AsLongLong(x); + return (signed PY_LONG_LONG)PyLong_AsLongLong(x); } } else { signed PY_LONG_LONG val; @@ -4906,7 +5017,8 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* } } -static void __Pyx_WriteUnraisable(const char *name) { +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); @@ -4976,6 +5088,25 @@ static CYTHON_INLINE u_int8_t __Pyx_PyInt_from_py_u_int8_t(PyObject* x) { } } +static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + #if PY_VERSION_HEX < 0x02050000 + return PyErr_Warn(NULL, message); + #else + return PyErr_WarnEx(NULL, message, 1); + #endif + } + return 0; +} + static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) PyObject *ob = PyCapsule_New(vtable, 0, 0); @@ -4997,7 +5128,8 @@ bad: #include "frameobject.h" #include "traceback.h" -static void __Pyx_AddTraceback(const char *funcname) { +static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno, + int __pyx_lineno, const char *__pyx_filename) { PyObject *py_srcfile = 0; PyObject *py_funcname = 0; PyObject *py_globals = 0; diff --git a/netfilterqueue.pxd b/netfilterqueue.pxd index 008b481..4916938 100644 --- a/netfilterqueue.pxd +++ b/netfilterqueue.pxd @@ -183,9 +183,10 @@ cdef class Packet: cpdef accept(self) cpdef drop(self) -cdef class QueueHandler: +cdef class NetfilterQueue: + cdef object user_callback # User callback cdef nfq_handle *h # Handle to NFQueue library cdef nfq_q_handle *qh # A handle to the queue cdef u_int16_t af # Address family cdef packet_copy_size # Amount of packet metadata + data copied to buffer - \ No newline at end of file + diff --git a/netfilterqueue.pyx b/netfilterqueue.pyx index bebf550..0bb769e 100644 --- a/netfilterqueue.pyx +++ b/netfilterqueue.pyx @@ -1,4 +1,12 @@ -## cython: profile=True +""" +Bind to a Linux netfilter queue. Send packets to a user-specified callback +function. + +Copyright: (c) 2011, Kerkhoff Technologies Inc. +License: MIT; see LICENSE.txt +""" +VERSION = (0, 3, 0) + # Constants for module users COPY_NONE = 1 COPY_META = 2 @@ -14,14 +22,17 @@ DEF MaxCopySize = BufferSize - MetadataSize cdef int global_callback(nfq_q_handle *qh, nfgenmsg *nfmsg, nfq_data *nfa, void *data) with gil: - """Create an Packet and pass it to appropriate Python/Cython callback.""" + """Create a Packet and pass it to appropriate callback.""" + cdef NetfilterQueue nfqueue = data + cdef object user_callback = nfqueue.user_callback + packet = Packet() packet.set_nfq_data(qh, nfa) - (data).handle(packet) + user_callback(packet) return 1 cdef class Packet: - """A packet received from QueueHandler.""" + """A packet received from NetfilterQueue.""" def __cinit__(self): self._verdict_is_set = False self._mark_is_set = False @@ -57,7 +68,8 @@ cdef class Packet: raise RuntimeWarning("Verdict already given for this packet.") if self._mark_is_set: - nfq_set_verdict_mark( # TODO: make this use nfq_set_verdict2 if available on system + nfq_set_verdict_mark( # TODO: make this use nfq_set_verdict2 if + # available on system self._qh, self.id, verdict, @@ -78,7 +90,8 @@ cdef class Packet: def get_payload(self): """Return payload as Python string.""" - cdef object py_string = PyString_FromStringAndSize(self.payload, self.payload_len) + cdef object py_string = PyString_FromStringAndSize(self.payload, + self.payload_len) return py_string cpdef Py_ssize_t get_payload_len(self): @@ -104,7 +117,7 @@ cdef class Packet: """Drop the packet.""" self.verdict(NF_DROP) -cdef class QueueHandler: +cdef class NetfilterQueue: """Handle a single numbered queue.""" def __cinit__(self, *args, **kwargs): self.af = kwargs.get("af", PF_INET) @@ -124,9 +137,14 @@ cdef class QueueHandler: # processes using this libnetfilter_queue on this protocol family! nfq_close(self.h) - def bind(self, int queue_num, u_int32_t max_len=DEFAULT_MAX_QUEUELEN, u_int8_t mode=NFQNL_COPY_PACKET, u_int32_t range=MaxPacketSize): + def bind(self, int queue_num, object user_callback, + u_int32_t max_len=DEFAULT_MAX_QUEUELEN, + u_int8_t mode=NFQNL_COPY_PACKET, + u_int32_t range=MaxPacketSize): """Create and bind to a new queue.""" - self.qh = nfq_create_queue(self.h, queue_num, global_callback, self) + self.user_callback = user_callback + self.qh = nfq_create_queue(self.h, queue_num, + global_callback, self) if self.qh == NULL: raise OSError("Failed to create queue %s." % queue_num) @@ -155,10 +173,6 @@ cdef class QueueHandler: with nogil: rv = recv(fd, buf, sizeof(buf), 0) - def handle(self, Packet packet): - """Handle a single packet. User-defined classes should override this.""" - packet.accept() - PROTOCOLS = { 0: "HOPOPT", 1: "ICMP", @@ -302,4 +316,4 @@ PROTOCOLS = { 139: "HIP", 140: "Shim6", 255: "Reserved", -} \ No newline at end of file +} diff --git a/setup.py b/setup.py index 66f043e..f0a56a4 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from distutils.core import setup, Extension -VERSION = "0.2" # Remember to change README.rst when version changes. +VERSION = "0.3" # Remember to change README.rst when version changes. try: # Use Cython