diff --git a/netfilterqueue.c b/netfilterqueue.c index 744c733..b52ab2f 100644 --- a/netfilterqueue.c +++ b/netfilterqueue.c @@ -529,7 +529,7 @@ enum { __pyx_e_14netfilterqueue_IPPROTO_MAX }; -/* "netfilterqueue.pxd":135 +/* "netfilterqueue.pxd":136 * * # Dummy defines from linux/socket.h: * cdef enum: # Protocol families, same as address families. # <<<<<<<<<<<<<< @@ -541,7 +541,7 @@ enum { __pyx_e_14netfilterqueue_PF_INET6 = 10 }; -/* "netfilterqueue.pxd":143 +/* "netfilterqueue.pxd":144 * * # Dummy defines from linux/netfilter.h * cdef enum: # <<<<<<<<<<<<<< @@ -550,7 +550,7 @@ enum { */ enum { - /* "netfilterqueue.pxd":150 + /* "netfilterqueue.pxd":151 * NF_REPEAT * NF_STOP * NF_MAX_VERDICT = NF_STOP # <<<<<<<<<<<<<< @@ -566,7 +566,7 @@ enum { __pyx_e_14netfilterqueue_NF_MAX_VERDICT = __pyx_e_14netfilterqueue_NF_STOP }; -/* "netfilterqueue.pxd":152 +/* "netfilterqueue.pxd":153 * NF_MAX_VERDICT = NF_STOP * * cdef class Packet: # <<<<<<<<<<<<<< @@ -593,7 +593,7 @@ struct __pyx_obj_14netfilterqueue_Packet { }; -/* "netfilterqueue.pxd":191 +/* "netfilterqueue.pxd":192 * cpdef repeat(self) * * cdef class NetfilterQueue: # <<<<<<<<<<<<<< @@ -611,7 +611,7 @@ struct __pyx_obj_14netfilterqueue_NetfilterQueue { -/* "netfilterqueue.pyx":34 +/* "netfilterqueue.pyx":36 * return 1 * * cdef class Packet: # <<<<<<<<<<<<<< @@ -869,6 +869,10 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14netf static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_14netfilterqueue_6Packet_repeat(struct __pyx_obj_14netfilterqueue_Packet *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +/* Module declarations from 'cpython.version' */ + +/* Module declarations from 'cpython' */ + /* Module declarations from 'netfilterqueue' */ static PyTypeObject *__pyx_ptype_14netfilterqueue_Packet = 0; static PyTypeObject *__pyx_ptype_14netfilterqueue_NetfilterQueue = 0; @@ -1052,7 +1056,7 @@ static const char __pyx_k_any_host_internal_protocol[] = "any host internal prot static const char __pyx_k_any_distributed_file_system[] = "any distributed file system"; static const char __pyx_k_any_private_encryption_scheme[] = "any private encryption scheme"; static const char __pyx_k_Failed_to_set_packet_copy_mode[] = "Failed to set packet copy mode."; -static const char __pyx_k_Bind_to_a_Linux_netfilter_queue[] = "\nBind to a Linux netfilter queue. Send packets to a user-specified callback \nfunction.\n\nCopyright: (c) 2011, Kerkhoff Technologies Inc.\nLicense: MIT; see LICENSE.txt\n"; +static const char __pyx_k_Bind_to_a_Linux_netfilter_queue[] = "\nBind to a Linux netfilter queue. Send packets to a user-specified callback\nfunction.\n\nCopyright: (c) 2011, Kerkhoff Technologies Inc.\nLicense: MIT; see LICENSE.txt\n"; static const char __pyx_k_Failed_to_bind_family_s_Are_you[] = "Failed to bind family %s. Are you root?"; static const char __pyx_k_Failed_to_get_payload_of_packet[] = "Failed to get payload of packet."; static const char __pyx_k_Verdict_already_given_for_this_p[] = "Verdict already given for this packet."; @@ -1406,8 +1410,8 @@ static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; -/* "netfilterqueue.pyx":23 - * DEF MaxCopySize = BufferSize - MetadataSize +/* "netfilterqueue.pyx":25 + * cimport cpython.version * * cdef int global_callback(nfq_q_handle *qh, nfgenmsg *nfmsg, # <<<<<<<<<<<<<< * nfq_data *nfa, void *data) with gil: @@ -1429,7 +1433,7 @@ static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_v #endif __Pyx_RefNannySetupContext("global_callback", 0); - /* "netfilterqueue.pyx":26 + /* "netfilterqueue.pyx":28 * nfq_data *nfa, void *data) with gil: * """Create a Packet and pass it to appropriate callback.""" * cdef NetfilterQueue nfqueue = data # <<<<<<<<<<<<<< @@ -1441,7 +1445,7 @@ static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_v __pyx_v_nfqueue = ((struct __pyx_obj_14netfilterqueue_NetfilterQueue *)__pyx_t_1); __pyx_t_1 = 0; - /* "netfilterqueue.pyx":27 + /* "netfilterqueue.pyx":29 * """Create a Packet and pass it to appropriate callback.""" * cdef NetfilterQueue nfqueue = data * cdef object user_callback = nfqueue.user_callback # <<<<<<<<<<<<<< @@ -1453,30 +1457,30 @@ static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_v __pyx_v_user_callback = __pyx_t_1; __pyx_t_1 = 0; - /* "netfilterqueue.pyx":29 + /* "netfilterqueue.pyx":31 * cdef object user_callback = nfqueue.user_callback * * packet = Packet() # <<<<<<<<<<<<<< * packet.set_nfq_data(qh, nfa) * user_callback(packet) */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_14netfilterqueue_Packet), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_14netfilterqueue_Packet), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_packet = ((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_t_1); __pyx_t_1 = 0; - /* "netfilterqueue.pyx":30 + /* "netfilterqueue.pyx":32 * * packet = Packet() * packet.set_nfq_data(qh, nfa) # <<<<<<<<<<<<<< * 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_ERR(0, 30, __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_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "netfilterqueue.pyx":31 + /* "netfilterqueue.pyx":33 * packet = Packet() * packet.set_nfq_data(qh, nfa) * user_callback(packet) # <<<<<<<<<<<<<< @@ -1495,23 +1499,23 @@ static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_v } } if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_packet)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_packet)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 31, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_packet)); __Pyx_GIVEREF(((PyObject *)__pyx_v_packet)); PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_packet)); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "netfilterqueue.pyx":32 + /* "netfilterqueue.pyx":34 * packet.set_nfq_data(qh, nfa) * user_callback(packet) * return 1 # <<<<<<<<<<<<<< @@ -1521,8 +1525,8 @@ static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_v __pyx_r = 1; goto __pyx_L0; - /* "netfilterqueue.pyx":23 - * DEF MaxCopySize = BufferSize - MetadataSize + /* "netfilterqueue.pyx":25 + * cimport cpython.version * * cdef int global_callback(nfq_q_handle *qh, nfgenmsg *nfmsg, # <<<<<<<<<<<<<< * nfq_data *nfa, void *data) with gil: @@ -1548,7 +1552,7 @@ static int __pyx_f_14netfilterqueue_global_callback(struct nfq_q_handle *__pyx_v return __pyx_r; } -/* "netfilterqueue.pyx":36 +/* "netfilterqueue.pyx":38 * cdef class Packet: * """A packet received from NetfilterQueue.""" * def __cinit__(self): # <<<<<<<<<<<<<< @@ -1577,7 +1581,7 @@ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(struct __pyx_obj_14netfil __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0); - /* "netfilterqueue.pyx":37 + /* "netfilterqueue.pyx":39 * """A packet received from NetfilterQueue.""" * def __cinit__(self): * self._verdict_is_set = False # <<<<<<<<<<<<<< @@ -1586,7 +1590,7 @@ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(struct __pyx_obj_14netfil */ __pyx_v_self->_verdict_is_set = 0; - /* "netfilterqueue.pyx":38 + /* "netfilterqueue.pyx":40 * def __cinit__(self): * self._verdict_is_set = False * self._mark_is_set = False # <<<<<<<<<<<<<< @@ -1595,7 +1599,7 @@ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(struct __pyx_obj_14netfil */ __pyx_v_self->_mark_is_set = 0; - /* "netfilterqueue.pyx":39 + /* "netfilterqueue.pyx":41 * self._verdict_is_set = False * self._mark_is_set = False * self._given_payload = None # <<<<<<<<<<<<<< @@ -1608,7 +1612,7 @@ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(struct __pyx_obj_14netfil __Pyx_DECREF(__pyx_v_self->_given_payload); __pyx_v_self->_given_payload = ((PyObject*)Py_None); - /* "netfilterqueue.pyx":36 + /* "netfilterqueue.pyx":38 * cdef class Packet: * """A packet received from NetfilterQueue.""" * def __cinit__(self): # <<<<<<<<<<<<<< @@ -1622,7 +1626,7 @@ static int __pyx_pf_14netfilterqueue_6Packet___cinit__(struct __pyx_obj_14netfil return __pyx_r; } -/* "netfilterqueue.pyx":41 +/* "netfilterqueue.pyx":43 * self._given_payload = None * * def __str__(self): # <<<<<<<<<<<<<< @@ -1656,7 +1660,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2__str__(struct __pyx_obj_14n PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("__str__", 0); - /* "netfilterqueue.pyx":42 + /* "netfilterqueue.pyx":44 * * def __str__(self): * cdef iphdr *hdr = self.payload # <<<<<<<<<<<<<< @@ -1665,19 +1669,19 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2__str__(struct __pyx_obj_14n */ __pyx_v_hdr = ((struct iphdr *)__pyx_v_self->payload); - /* "netfilterqueue.pyx":43 + /* "netfilterqueue.pyx":45 * 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_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PROTOCOLS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PROTOCOLS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_u_int8_t(__pyx_v_hdr->protocol); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_u_int8_t(__pyx_v_hdr->protocol); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; @@ -1691,7 +1695,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2__str__(struct __pyx_obj_14n __pyx_t_5 = 1; } } - __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 43, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; @@ -1702,14 +1706,14 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2__str__(struct __pyx_obj_14n __Pyx_GIVEREF(__pyx_kp_s_Unknown_protocol); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_kp_s_Unknown_protocol); __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_protocol = __pyx_t_1; __pyx_t_1 = 0; - /* "netfilterqueue.pyx":44 + /* "netfilterqueue.pyx":46 * cdef iphdr *hdr = self.payload * protocol = PROTOCOLS.get(hdr.protocol, "Unknown protocol") * return "%s packet, %s bytes" % (protocol, self.payload_len) # <<<<<<<<<<<<<< @@ -1717,9 +1721,9 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2__str__(struct __pyx_obj_14n * cdef set_nfq_data(self, nfq_q_handle *qh, nfq_data *nfa): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->payload_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->payload_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_protocol); __Pyx_GIVEREF(__pyx_v_protocol); @@ -1727,14 +1731,14 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2__str__(struct __pyx_obj_14n __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_packet_s_bytes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_packet_s_bytes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "netfilterqueue.pyx":41 + /* "netfilterqueue.pyx":43 * self._given_payload = None * * def __str__(self): # <<<<<<<<<<<<<< @@ -1758,7 +1762,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2__str__(struct __pyx_obj_14n return __pyx_r; } -/* "netfilterqueue.pyx":46 +/* "netfilterqueue.pyx":48 * return "%s packet, %s bytes" % (protocol, self.payload_len) * * cdef set_nfq_data(self, nfq_q_handle *qh, nfq_data *nfa): # <<<<<<<<<<<<<< @@ -1774,7 +1778,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_ PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("set_nfq_data", 0); - /* "netfilterqueue.pyx":51 + /* "netfilterqueue.pyx":53 * local values. * """ * self._qh = qh # <<<<<<<<<<<<<< @@ -1783,7 +1787,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_ */ __pyx_v_self->_qh = __pyx_v_qh; - /* "netfilterqueue.pyx":52 + /* "netfilterqueue.pyx":54 * """ * self._qh = qh * self._nfa = nfa # <<<<<<<<<<<<<< @@ -1792,7 +1796,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_ */ __pyx_v_self->_nfa = __pyx_v_nfa; - /* "netfilterqueue.pyx":53 + /* "netfilterqueue.pyx":55 * self._qh = qh * self._nfa = nfa * self._hdr = nfq_get_msg_packet_hdr(nfa) # <<<<<<<<<<<<<< @@ -1801,7 +1805,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":55 + /* "netfilterqueue.pyx":57 * self._hdr = nfq_get_msg_packet_hdr(nfa) * * self.id = ntohl(self._hdr.packet_id) # <<<<<<<<<<<<<< @@ -1810,7 +1814,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":56 + /* "netfilterqueue.pyx":58 * * self.id = ntohl(self._hdr.packet_id) * self.hw_protocol = ntohs(self._hdr.hw_protocol) # <<<<<<<<<<<<<< @@ -1819,7 +1823,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":57 + /* "netfilterqueue.pyx":59 * self.id = ntohl(self._hdr.packet_id) * self.hw_protocol = ntohs(self._hdr.hw_protocol) * self.hook = self._hdr.hook # <<<<<<<<<<<<<< @@ -1829,7 +1833,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_ __pyx_t_1 = __pyx_v_self->_hdr->hook; __pyx_v_self->hook = __pyx_t_1; - /* "netfilterqueue.pyx":59 + /* "netfilterqueue.pyx":61 * self.hook = self._hdr.hook * * self.payload_len = nfq_get_payload(self._nfa, &self.payload) # <<<<<<<<<<<<<< @@ -1838,7 +1842,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":60 + /* "netfilterqueue.pyx":62 * * self.payload_len = nfq_get_payload(self._nfa, &self.payload) * if self.payload_len < 0: # <<<<<<<<<<<<<< @@ -1848,20 +1852,20 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_ __pyx_t_2 = ((__pyx_v_self->payload_len < 0) != 0); if (__pyx_t_2) { - /* "netfilterqueue.pyx":61 + /* "netfilterqueue.pyx":63 * 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_3 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 61, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 61, __pyx_L1_error) + __PYX_ERR(0, 63, __pyx_L1_error) - /* "netfilterqueue.pyx":60 + /* "netfilterqueue.pyx":62 * * self.payload_len = nfq_get_payload(self._nfa, &self.payload) * if self.payload_len < 0: # <<<<<<<<<<<<<< @@ -1870,7 +1874,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_ */ } - /* "netfilterqueue.pyx":63 + /* "netfilterqueue.pyx":65 * raise OSError("Failed to get payload of packet.") * * nfq_get_timestamp(self._nfa, &self.timestamp) # <<<<<<<<<<<<<< @@ -1879,7 +1883,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_ */ nfq_get_timestamp(__pyx_v_self->_nfa, (&__pyx_v_self->timestamp)); - /* "netfilterqueue.pyx":64 + /* "netfilterqueue.pyx":66 * * nfq_get_timestamp(self._nfa, &self.timestamp) * self.mark = nfq_get_nfmark(nfa) # <<<<<<<<<<<<<< @@ -1888,7 +1892,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_ */ __pyx_v_self->mark = nfq_get_nfmark(__pyx_v_nfa); - /* "netfilterqueue.pyx":46 + /* "netfilterqueue.pyx":48 * return "%s packet, %s bytes" % (protocol, self.payload_len) * * cdef set_nfq_data(self, nfq_q_handle *qh, nfq_data *nfa): # <<<<<<<<<<<<<< @@ -1909,7 +1913,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_nfq_data(struct __pyx_obj_ return __pyx_r; } -/* "netfilterqueue.pyx":66 +/* "netfilterqueue.pyx":68 * self.mark = nfq_get_nfmark(nfa) * * cdef void verdict(self, u_int8_t verdict): # <<<<<<<<<<<<<< @@ -1927,7 +1931,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte unsigned char *__pyx_t_4; __Pyx_RefNannySetupContext("verdict", 0); - /* "netfilterqueue.pyx":68 + /* "netfilterqueue.pyx":70 * cdef void verdict(self, u_int8_t verdict): * """Call appropriate set_verdict... function on packet.""" * if self._verdict_is_set: # <<<<<<<<<<<<<< @@ -1937,20 +1941,20 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte __pyx_t_1 = (__pyx_v_self->_verdict_is_set != 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":69 + /* "netfilterqueue.pyx":71 * """Call appropriate set_verdict... function on packet.""" * if self._verdict_is_set: * raise RuntimeWarning("Verdict already given for this packet.") # <<<<<<<<<<<<<< * * cdef u_int32_t modified_payload_len = 0 */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeWarning, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeWarning, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 69, __pyx_L1_error) + __PYX_ERR(0, 71, __pyx_L1_error) - /* "netfilterqueue.pyx":68 + /* "netfilterqueue.pyx":70 * cdef void verdict(self, u_int8_t verdict): * """Call appropriate set_verdict... function on packet.""" * if self._verdict_is_set: # <<<<<<<<<<<<<< @@ -1959,7 +1963,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte */ } - /* "netfilterqueue.pyx":71 + /* "netfilterqueue.pyx":73 * raise RuntimeWarning("Verdict already given for this packet.") * * cdef u_int32_t modified_payload_len = 0 # <<<<<<<<<<<<<< @@ -1968,7 +1972,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte */ __pyx_v_modified_payload_len = 0; - /* "netfilterqueue.pyx":72 + /* "netfilterqueue.pyx":74 * * cdef u_int32_t modified_payload_len = 0 * cdef unsigned char *modified_payload = NULL # <<<<<<<<<<<<<< @@ -1977,7 +1981,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte */ __pyx_v_modified_payload = NULL; - /* "netfilterqueue.pyx":73 + /* "netfilterqueue.pyx":75 * cdef u_int32_t modified_payload_len = 0 * cdef unsigned char *modified_payload = NULL * if self._given_payload: # <<<<<<<<<<<<<< @@ -1987,7 +1991,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte __pyx_t_1 = (__pyx_v_self->_given_payload != Py_None) && (PyBytes_GET_SIZE(__pyx_v_self->_given_payload) != 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":74 + /* "netfilterqueue.pyx":76 * cdef unsigned char *modified_payload = NULL * if self._given_payload: * modified_payload_len = len(self._given_payload) # <<<<<<<<<<<<<< @@ -1998,23 +2002,23 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte __Pyx_INCREF(__pyx_t_2); if (unlikely(__pyx_t_2 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 74, __pyx_L1_error) + __PYX_ERR(0, 76, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 74, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_modified_payload_len = __pyx_t_3; - /* "netfilterqueue.pyx":75 + /* "netfilterqueue.pyx":77 * if self._given_payload: * modified_payload_len = len(self._given_payload) * modified_payload = self._given_payload # <<<<<<<<<<<<<< * if self._mark_is_set: * nfq_set_verdict_mark( */ - __pyx_t_4 = __Pyx_PyObject_AsUString(__pyx_v_self->_given_payload); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 75, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_AsUString(__pyx_v_self->_given_payload); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 77, __pyx_L1_error) __pyx_v_modified_payload = __pyx_t_4; - /* "netfilterqueue.pyx":73 + /* "netfilterqueue.pyx":75 * cdef u_int32_t modified_payload_len = 0 * cdef unsigned char *modified_payload = NULL * if self._given_payload: # <<<<<<<<<<<<<< @@ -2023,7 +2027,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte */ } - /* "netfilterqueue.pyx":76 + /* "netfilterqueue.pyx":78 * modified_payload_len = len(self._given_payload) * modified_payload = self._given_payload * if self._mark_is_set: # <<<<<<<<<<<<<< @@ -2033,7 +2037,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte __pyx_t_1 = (__pyx_v_self->_mark_is_set != 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":77 + /* "netfilterqueue.pyx":79 * modified_payload = self._given_payload * if self._mark_is_set: * nfq_set_verdict_mark( # <<<<<<<<<<<<<< @@ -2042,7 +2046,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte */ nfq_set_verdict_mark(__pyx_v_self->_qh, __pyx_v_self->id, __pyx_v_verdict, htonl(__pyx_v_self->_given_mark), __pyx_v_modified_payload_len, __pyx_v_modified_payload); - /* "netfilterqueue.pyx":76 + /* "netfilterqueue.pyx":78 * modified_payload_len = len(self._given_payload) * modified_payload = self._given_payload * if self._mark_is_set: # <<<<<<<<<<<<<< @@ -2052,7 +2056,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte goto __pyx_L5; } - /* "netfilterqueue.pyx":85 + /* "netfilterqueue.pyx":87 * modified_payload) * else: * nfq_set_verdict( # <<<<<<<<<<<<<< @@ -2061,7 +2065,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte */ /*else*/ { - /* "netfilterqueue.pyx":90 + /* "netfilterqueue.pyx":92 * verdict, * modified_payload_len, * modified_payload) # <<<<<<<<<<<<<< @@ -2072,7 +2076,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte } __pyx_L5:; - /* "netfilterqueue.pyx":92 + /* "netfilterqueue.pyx":94 * modified_payload) * * self._verdict_is_set = True # <<<<<<<<<<<<<< @@ -2081,7 +2085,7 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte */ __pyx_v_self->_verdict_is_set = 1; - /* "netfilterqueue.pyx":66 + /* "netfilterqueue.pyx":68 * self.mark = nfq_get_nfmark(nfa) * * cdef void verdict(self, u_int8_t verdict): # <<<<<<<<<<<<<< @@ -2098,12 +2102,12 @@ static void __pyx_f_14netfilterqueue_6Packet_verdict(struct __pyx_obj_14netfilte __Pyx_RefNannyFinishContext(); } -/* "netfilterqueue.pyx":94 +/* "netfilterqueue.pyx":96 * self._verdict_is_set = True * * def get_payload(self): # <<<<<<<<<<<<<< * """Return payload as Python string.""" - * cdef object py_string = PyString_FromStringAndSize(self.payload, + * cdef object py_string */ /* Python wrapper */ @@ -2124,24 +2128,68 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4get_payload(struct __pyx_obj PyObject *__pyx_v_py_string = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("get_payload", 0); - /* "netfilterqueue.pyx":96 - * def get_payload(self): + /* "netfilterqueue.pyx":99 * """Return payload as Python string.""" - * cdef object py_string = PyString_FromStringAndSize(self.payload, # <<<<<<<<<<<<<< - * self.payload_len) + * cdef object py_string + * if cpython.version.PY_MAJOR_VERSION >= 3: # <<<<<<<<<<<<<< + * py_string = PyBytes_FromStringAndSize( + * self.payload, self.payload_len) + */ + __pyx_t_1 = ((PY_MAJOR_VERSION >= 3) != 0); + if (__pyx_t_1) { + + /* "netfilterqueue.pyx":100 + * cdef object py_string + * if cpython.version.PY_MAJOR_VERSION >= 3: + * py_string = PyBytes_FromStringAndSize( # <<<<<<<<<<<<<< + * self.payload, self.payload_len) + * else: + */ + __pyx_t_2 = PyBytes_FromStringAndSize(__pyx_v_self->payload, __pyx_v_self->payload_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_py_string = __pyx_t_2; + __pyx_t_2 = 0; + + /* "netfilterqueue.pyx":99 + * """Return payload as Python string.""" + * cdef object py_string + * if cpython.version.PY_MAJOR_VERSION >= 3: # <<<<<<<<<<<<<< + * py_string = PyBytes_FromStringAndSize( + * self.payload, self.payload_len) + */ + goto __pyx_L3; + } + + /* "netfilterqueue.pyx":103 + * self.payload, self.payload_len) + * else: + * py_string = PyString_FromStringAndSize( # <<<<<<<<<<<<<< + * self.payload, self.payload_len) * return py_string */ - __pyx_t_1 = PyString_FromStringAndSize(__pyx_v_self->payload, __pyx_v_self->payload_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_py_string = __pyx_t_1; - __pyx_t_1 = 0; + /*else*/ { - /* "netfilterqueue.pyx":98 - * cdef object py_string = PyString_FromStringAndSize(self.payload, - * self.payload_len) + /* "netfilterqueue.pyx":104 + * else: + * py_string = PyString_FromStringAndSize( + * self.payload, self.payload_len) # <<<<<<<<<<<<<< + * return py_string + * + */ + __pyx_t_2 = PyString_FromStringAndSize(__pyx_v_self->payload, __pyx_v_self->payload_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_py_string = __pyx_t_2; + __pyx_t_2 = 0; + } + __pyx_L3:; + + /* "netfilterqueue.pyx":105 + * py_string = PyString_FromStringAndSize( + * self.payload, self.payload_len) * return py_string # <<<<<<<<<<<<<< * * cpdef Py_ssize_t get_payload_len(self): @@ -2151,17 +2199,17 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4get_payload(struct __pyx_obj __pyx_r = __pyx_v_py_string; goto __pyx_L0; - /* "netfilterqueue.pyx":94 + /* "netfilterqueue.pyx":96 * self._verdict_is_set = True * * def get_payload(self): # <<<<<<<<<<<<<< * """Return payload as Python string.""" - * cdef object py_string = PyString_FromStringAndSize(self.payload, + * cdef object py_string */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("netfilterqueue.Packet.get_payload", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -2171,7 +2219,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4get_payload(struct __pyx_obj return __pyx_r; } -/* "netfilterqueue.pyx":100 +/* "netfilterqueue.pyx":107 * return py_string * * cpdef Py_ssize_t get_payload_len(self): # <<<<<<<<<<<<<< @@ -2193,7 +2241,7 @@ static Py_ssize_t __pyx_f_14netfilterqueue_6Packet_get_payload_len(struct __pyx_ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_payload_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_payload_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_14netfilterqueue_6Packet_7get_payload_len)) { __Pyx_INCREF(__pyx_t_1); @@ -2208,14 +2256,14 @@ static Py_ssize_t __pyx_f_14netfilterqueue_6Packet_get_payload_len(struct __pyx_ } } if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2224,7 +2272,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":101 + /* "netfilterqueue.pyx":108 * * cpdef Py_ssize_t get_payload_len(self): * return self.payload_len # <<<<<<<<<<<<<< @@ -2234,7 +2282,7 @@ static Py_ssize_t __pyx_f_14netfilterqueue_6Packet_get_payload_len(struct __pyx_ __pyx_r = __pyx_v_self->payload_len; goto __pyx_L0; - /* "netfilterqueue.pyx":100 + /* "netfilterqueue.pyx":107 * return py_string * * cpdef Py_ssize_t get_payload_len(self): # <<<<<<<<<<<<<< @@ -2274,7 +2322,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_6get_payload_len(struct __pyx PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("get_payload_len", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromSsize_t(__pyx_f_14netfilterqueue_6Packet_get_payload_len(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_f_14netfilterqueue_6Packet_get_payload_len(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2291,7 +2339,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_6get_payload_len(struct __pyx return __pyx_r; } -/* "netfilterqueue.pyx":103 +/* "netfilterqueue.pyx":110 * return self.payload_len * * cpdef double get_timestamp(self): # <<<<<<<<<<<<<< @@ -2313,7 +2361,7 @@ static double __pyx_f_14netfilterqueue_6Packet_get_timestamp(struct __pyx_obj_14 if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_14netfilterqueue_6Packet_9get_timestamp)) { __Pyx_INCREF(__pyx_t_1); @@ -2328,14 +2376,14 @@ static double __pyx_f_14netfilterqueue_6Packet_get_timestamp(struct __pyx_obj_14 } } if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 103, __pyx_L1_error) + __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2344,7 +2392,7 @@ static double __pyx_f_14netfilterqueue_6Packet_get_timestamp(struct __pyx_obj_14 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":104 + /* "netfilterqueue.pyx":111 * * cpdef double get_timestamp(self): * return self.timestamp.tv_sec + (self.timestamp.tv_usec/1000000.0) # <<<<<<<<<<<<<< @@ -2354,7 +2402,7 @@ static double __pyx_f_14netfilterqueue_6Packet_get_timestamp(struct __pyx_obj_14 __pyx_r = (__pyx_v_self->timestamp.tv_sec + (__pyx_v_self->timestamp.tv_usec / 1000000.0)); goto __pyx_L0; - /* "netfilterqueue.pyx":103 + /* "netfilterqueue.pyx":110 * return self.payload_len * * cpdef double get_timestamp(self): # <<<<<<<<<<<<<< @@ -2394,7 +2442,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_8get_timestamp(struct __pyx_o PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("get_timestamp", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_f_14netfilterqueue_6Packet_get_timestamp(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_f_14netfilterqueue_6Packet_get_timestamp(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2411,7 +2459,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_8get_timestamp(struct __pyx_o return __pyx_r; } -/* "netfilterqueue.pyx":106 +/* "netfilterqueue.pyx":113 * return self.timestamp.tv_sec + (self.timestamp.tv_usec/1000000.0) * * cpdef set_payload(self, bytes payload): # <<<<<<<<<<<<<< @@ -2433,7 +2481,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_payload(struct __pyx_obj_1 if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_payload); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_payload); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_14netfilterqueue_6Packet_11set_payload)) { __Pyx_XDECREF(__pyx_r); @@ -2449,16 +2497,16 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_payload(struct __pyx_obj_1 } } if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_payload); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_payload); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_payload); __Pyx_GIVEREF(__pyx_v_payload); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_payload); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } @@ -2471,7 +2519,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_payload(struct __pyx_obj_1 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":108 + /* "netfilterqueue.pyx":115 * cpdef set_payload(self, bytes payload): * """Set the new payload of this packet.""" * self._given_payload = payload # <<<<<<<<<<<<<< @@ -2484,7 +2532,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_payload(struct __pyx_obj_1 __Pyx_DECREF(__pyx_v_self->_given_payload); __pyx_v_self->_given_payload = __pyx_v_payload; - /* "netfilterqueue.pyx":106 + /* "netfilterqueue.pyx":113 * return self.timestamp.tv_sec + (self.timestamp.tv_usec/1000000.0) * * cpdef set_payload(self, bytes payload): # <<<<<<<<<<<<<< @@ -2516,7 +2564,7 @@ static PyObject *__pyx_pw_14netfilterqueue_6Packet_11set_payload(PyObject *__pyx PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_payload (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_payload), (&PyBytes_Type), 1, "payload", 1))) __PYX_ERR(0, 106, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_payload), (&PyBytes_Type), 1, "payload", 1))) __PYX_ERR(0, 113, __pyx_L1_error) __pyx_r = __pyx_pf_14netfilterqueue_6Packet_10set_payload(((struct __pyx_obj_14netfilterqueue_Packet *)__pyx_v_self), ((PyObject*)__pyx_v_payload)); /* function exit code */ @@ -2534,7 +2582,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_10set_payload(struct __pyx_ob PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("set_payload", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_set_payload(__pyx_v_self, __pyx_v_payload, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_set_payload(__pyx_v_self, __pyx_v_payload, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2551,7 +2599,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_10set_payload(struct __pyx_ob return __pyx_r; } -/* "netfilterqueue.pyx":110 +/* "netfilterqueue.pyx":117 * self._given_payload = payload * * cpdef set_mark(self, u_int32_t mark): # <<<<<<<<<<<<<< @@ -2574,11 +2622,11 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14ne if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_14netfilterqueue_6Packet_13set_mark)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyInt_From_u_int32_t(__pyx_v_mark); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_u_int32_t(__pyx_v_mark); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; @@ -2592,17 +2640,17 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14ne } } if (!__pyx_t_5) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 110, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } @@ -2615,7 +2663,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14ne __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":111 + /* "netfilterqueue.pyx":118 * * cpdef set_mark(self, u_int32_t mark): * self._given_mark = mark # <<<<<<<<<<<<<< @@ -2624,7 +2672,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14ne */ __pyx_v_self->_given_mark = __pyx_v_mark; - /* "netfilterqueue.pyx":112 + /* "netfilterqueue.pyx":119 * cpdef set_mark(self, u_int32_t mark): * self._given_mark = mark * self._mark_is_set = True # <<<<<<<<<<<<<< @@ -2633,7 +2681,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_set_mark(struct __pyx_obj_14ne */ __pyx_v_self->_mark_is_set = 1; - /* "netfilterqueue.pyx":110 + /* "netfilterqueue.pyx":117 * self._given_payload = payload * * cpdef set_mark(self, u_int32_t mark): # <<<<<<<<<<<<<< @@ -2667,7 +2715,7 @@ static PyObject *__pyx_pw_14netfilterqueue_6Packet_13set_mark(PyObject *__pyx_v_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_mark (wrapper)", 0); assert(__pyx_arg_mark); { - __pyx_v_mark = __Pyx_PyInt_As_u_int32_t(__pyx_arg_mark); if (unlikely((__pyx_v_mark == (u_int32_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L3_error) + __pyx_v_mark = __Pyx_PyInt_As_u_int32_t(__pyx_arg_mark); if (unlikely((__pyx_v_mark == (u_int32_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 117, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2688,7 +2736,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_12set_mark(struct __pyx_obj_1 PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("set_mark", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_set_mark(__pyx_v_self, __pyx_v_mark, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) + __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_set_mark(__pyx_v_self, __pyx_v_mark, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2705,7 +2753,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_12set_mark(struct __pyx_obj_1 return __pyx_r; } -/* "netfilterqueue.pyx":114 +/* "netfilterqueue.pyx":121 * self._mark_is_set = True * * cpdef get_mark(self): # <<<<<<<<<<<<<< @@ -2727,7 +2775,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_get_mark(struct __pyx_obj_14ne if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_14netfilterqueue_6Packet_15get_mark)) { __Pyx_XDECREF(__pyx_r); @@ -2743,10 +2791,10 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_get_mark(struct __pyx_obj_14ne } } if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -2758,7 +2806,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_get_mark(struct __pyx_obj_14ne __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":115 + /* "netfilterqueue.pyx":122 * * cpdef get_mark(self): * if self._mark_is_set: # <<<<<<<<<<<<<< @@ -2768,7 +2816,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_get_mark(struct __pyx_obj_14ne __pyx_t_5 = (__pyx_v_self->_mark_is_set != 0); if (__pyx_t_5) { - /* "netfilterqueue.pyx":116 + /* "netfilterqueue.pyx":123 * cpdef get_mark(self): * if self._mark_is_set: * return self._given_mark # <<<<<<<<<<<<<< @@ -2776,13 +2824,13 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_get_mark(struct __pyx_obj_14ne * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_u_int32_t(__pyx_v_self->_given_mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_u_int32_t(__pyx_v_self->_given_mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "netfilterqueue.pyx":115 + /* "netfilterqueue.pyx":122 * * cpdef get_mark(self): * if self._mark_is_set: # <<<<<<<<<<<<<< @@ -2791,7 +2839,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_get_mark(struct __pyx_obj_14ne */ } - /* "netfilterqueue.pyx":117 + /* "netfilterqueue.pyx":124 * if self._mark_is_set: * return self._given_mark * return self.mark # <<<<<<<<<<<<<< @@ -2799,13 +2847,13 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_get_mark(struct __pyx_obj_14ne * cpdef accept(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_u_int32_t(__pyx_v_self->mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_u_int32_t(__pyx_v_self->mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "netfilterqueue.pyx":114 + /* "netfilterqueue.pyx":121 * self._mark_is_set = True * * cpdef get_mark(self): # <<<<<<<<<<<<<< @@ -2846,7 +2894,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_14get_mark(struct __pyx_obj_1 PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("get_mark", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_get_mark(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_get_mark(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2863,7 +2911,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_14get_mark(struct __pyx_obj_1 return __pyx_r; } -/* "netfilterqueue.pyx":119 +/* "netfilterqueue.pyx":126 * return self.mark * * cpdef accept(self): # <<<<<<<<<<<<<< @@ -2884,7 +2932,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14netf if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_accept); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_accept); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_14netfilterqueue_6Packet_17accept)) { __Pyx_XDECREF(__pyx_r); @@ -2900,10 +2948,10 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14netf } } if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -2915,7 +2963,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14netf __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":121 + /* "netfilterqueue.pyx":128 * cpdef accept(self): * """Accept the packet.""" * self.verdict(NF_ACCEPT) # <<<<<<<<<<<<<< @@ -2924,7 +2972,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_accept(struct __pyx_obj_14netf */ ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)__pyx_v_self->__pyx_vtab)->verdict(__pyx_v_self, __pyx_e_14netfilterqueue_NF_ACCEPT); - /* "netfilterqueue.pyx":119 + /* "netfilterqueue.pyx":126 * return self.mark * * cpdef accept(self): # <<<<<<<<<<<<<< @@ -2968,7 +3016,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_16accept(struct __pyx_obj_14n PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("accept", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_accept(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) + __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_accept(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2985,7 +3033,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_16accept(struct __pyx_obj_14n return __pyx_r; } -/* "netfilterqueue.pyx":123 +/* "netfilterqueue.pyx":130 * self.verdict(NF_ACCEPT) * * cpdef drop(self): # <<<<<<<<<<<<<< @@ -3006,7 +3054,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfil if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_drop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_drop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_14netfilterqueue_6Packet_19drop)) { __Pyx_XDECREF(__pyx_r); @@ -3022,10 +3070,10 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfil } } if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -3037,7 +3085,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfil __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":125 + /* "netfilterqueue.pyx":132 * cpdef drop(self): * """Drop the packet.""" * self.verdict(NF_DROP) # <<<<<<<<<<<<<< @@ -3046,7 +3094,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_drop(struct __pyx_obj_14netfil */ ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)__pyx_v_self->__pyx_vtab)->verdict(__pyx_v_self, __pyx_e_14netfilterqueue_NF_DROP); - /* "netfilterqueue.pyx":123 + /* "netfilterqueue.pyx":130 * self.verdict(NF_ACCEPT) * * cpdef drop(self): # <<<<<<<<<<<<<< @@ -3090,7 +3138,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_18drop(struct __pyx_obj_14net PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("drop", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_drop(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_drop(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3107,7 +3155,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_18drop(struct __pyx_obj_14net return __pyx_r; } -/* "netfilterqueue.pyx":127 +/* "netfilterqueue.pyx":134 * self.verdict(NF_DROP) * * cpdef repeat(self): # <<<<<<<<<<<<<< @@ -3128,7 +3176,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_repeat(struct __pyx_obj_14netf if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_repeat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_repeat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_14netfilterqueue_6Packet_21repeat)) { __Pyx_XDECREF(__pyx_r); @@ -3144,10 +3192,10 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_repeat(struct __pyx_obj_14netf } } if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -3159,7 +3207,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_repeat(struct __pyx_obj_14netf __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "netfilterqueue.pyx":129 + /* "netfilterqueue.pyx":136 * cpdef repeat(self): * """Repeat the packet.""" * self.verdict(NF_REPEAT) # <<<<<<<<<<<<<< @@ -3168,7 +3216,7 @@ static PyObject *__pyx_f_14netfilterqueue_6Packet_repeat(struct __pyx_obj_14netf */ ((struct __pyx_vtabstruct_14netfilterqueue_Packet *)__pyx_v_self->__pyx_vtab)->verdict(__pyx_v_self, __pyx_e_14netfilterqueue_NF_REPEAT); - /* "netfilterqueue.pyx":127 + /* "netfilterqueue.pyx":134 * self.verdict(NF_DROP) * * cpdef repeat(self): # <<<<<<<<<<<<<< @@ -3212,7 +3260,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_20repeat(struct __pyx_obj_14n PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("repeat", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_repeat(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) + __pyx_t_1 = __pyx_f_14netfilterqueue_6Packet_repeat(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3229,7 +3277,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_20repeat(struct __pyx_obj_14n return __pyx_r; } -/* "netfilterqueue.pxd":163 +/* "netfilterqueue.pxd":164 * * # From NFQ packet header: * cdef readonly u_int32_t id # <<<<<<<<<<<<<< @@ -3256,7 +3304,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2id___get__(struct __pyx_obj_ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_u_int32_t(__pyx_v_self->id); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 163, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_u_int32_t(__pyx_v_self->id); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3273,7 +3321,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_2id___get__(struct __pyx_obj_ return __pyx_r; } -/* "netfilterqueue.pxd":164 +/* "netfilterqueue.pxd":165 * # From NFQ packet header: * cdef readonly u_int32_t id * cdef readonly u_int16_t hw_protocol # <<<<<<<<<<<<<< @@ -3300,7 +3348,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_11hw_protocol___get__(struct PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_u_int16_t(__pyx_v_self->hw_protocol); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 164, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_u_int16_t(__pyx_v_self->hw_protocol); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3317,7 +3365,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_11hw_protocol___get__(struct return __pyx_r; } -/* "netfilterqueue.pxd":165 +/* "netfilterqueue.pxd":166 * cdef readonly u_int32_t id * cdef readonly u_int16_t hw_protocol * cdef readonly u_int8_t hook # <<<<<<<<<<<<<< @@ -3344,7 +3392,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4hook___get__(struct __pyx_ob PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_u_int8_t(__pyx_v_self->hook); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 165, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_u_int8_t(__pyx_v_self->hook); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3361,7 +3409,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4hook___get__(struct __pyx_ob return __pyx_r; } -/* "netfilterqueue.pxd":166 +/* "netfilterqueue.pxd":167 * cdef readonly u_int16_t hw_protocol * cdef readonly u_int8_t hook * cdef readonly u_int32_t mark # <<<<<<<<<<<<<< @@ -3388,7 +3436,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4mark___get__(struct __pyx_ob PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_u_int32_t(__pyx_v_self->mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 166, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_u_int32_t(__pyx_v_self->mark); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3405,7 +3453,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_4mark___get__(struct __pyx_ob return __pyx_r; } -/* "netfilterqueue.pxd":170 +/* "netfilterqueue.pxd":171 * # Packet details: * cdef Py_ssize_t payload_len * cdef readonly char *payload # <<<<<<<<<<<<<< @@ -3432,7 +3480,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_7payload___get__(struct __pyx PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->payload); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 170, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->payload); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3449,7 +3497,7 @@ static PyObject *__pyx_pf_14netfilterqueue_6Packet_7payload___get__(struct __pyx return __pyx_r; } -/* "netfilterqueue.pyx":133 +/* "netfilterqueue.pyx":140 * cdef class NetfilterQueue: * """Handle a single numbered queue.""" * def __cinit__(self, *args, **kwargs): # <<<<<<<<<<<<<< @@ -3488,23 +3536,23 @@ static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(struct __pyx_obj int __pyx_t_4; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "netfilterqueue.pyx":134 + /* "netfilterqueue.pyx":141 * """Handle a single numbered queue.""" * def __cinit__(self, *args, **kwargs): * self.af = kwargs.get("af", PF_INET) # <<<<<<<<<<<<<< * * self.h = nfq_open() */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_14netfilterqueue_PF_INET); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_14netfilterqueue_PF_INET); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_kwargs, __pyx_n_s_af, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_kwargs, __pyx_n_s_af, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyInt_As_u_int16_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (u_int16_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 134, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_As_u_int16_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (u_int16_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_self->af = __pyx_t_3; - /* "netfilterqueue.pyx":136 + /* "netfilterqueue.pyx":143 * self.af = kwargs.get("af", PF_INET) * * self.h = nfq_open() # <<<<<<<<<<<<<< @@ -3513,7 +3561,7 @@ static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(struct __pyx_obj */ __pyx_v_self->h = nfq_open(); - /* "netfilterqueue.pyx":137 + /* "netfilterqueue.pyx":144 * * self.h = nfq_open() * if self.h == NULL: # <<<<<<<<<<<<<< @@ -3523,20 +3571,20 @@ static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(struct __pyx_obj __pyx_t_4 = ((__pyx_v_self->h == NULL) != 0); if (__pyx_t_4) { - /* "netfilterqueue.pyx":138 + /* "netfilterqueue.pyx":145 * 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 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 138, __pyx_L1_error) + __PYX_ERR(0, 145, __pyx_L1_error) - /* "netfilterqueue.pyx":137 + /* "netfilterqueue.pyx":144 * * self.h = nfq_open() * if self.h == NULL: # <<<<<<<<<<<<<< @@ -3545,7 +3593,7 @@ static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(struct __pyx_obj */ } - /* "netfilterqueue.pyx":139 + /* "netfilterqueue.pyx":146 * if self.h == NULL: * raise OSError("Failed to open NFQueue.") * nfq_unbind_pf(self.h, self.af) # This does NOT kick out previous # <<<<<<<<<<<<<< @@ -3554,7 +3602,7 @@ static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(struct __pyx_obj */ nfq_unbind_pf(__pyx_v_self->h, __pyx_v_self->af); - /* "netfilterqueue.pyx":141 + /* "netfilterqueue.pyx":148 * nfq_unbind_pf(self.h, self.af) # This does NOT kick out previous * # running queues * if nfq_bind_pf(self.h, self.af) < 0: # <<<<<<<<<<<<<< @@ -3564,31 +3612,31 @@ static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(struct __pyx_obj __pyx_t_4 = ((nfq_bind_pf(__pyx_v_self->h, __pyx_v_self->af) < 0) != 0); if (__pyx_t_4) { - /* "netfilterqueue.pyx":142 + /* "netfilterqueue.pyx":149 * # 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_From_u_int16_t(__pyx_v_self->af); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_u_int16_t(__pyx_v_self->af); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_bind_family_s_Are_you, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_bind_family_s_Are_you, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 142, __pyx_L1_error) + __PYX_ERR(0, 149, __pyx_L1_error) - /* "netfilterqueue.pyx":141 + /* "netfilterqueue.pyx":148 * nfq_unbind_pf(self.h, self.af) # This does NOT kick out previous * # running queues * if nfq_bind_pf(self.h, self.af) < 0: # <<<<<<<<<<<<<< @@ -3597,7 +3645,7 @@ static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(struct __pyx_obj */ } - /* "netfilterqueue.pyx":133 + /* "netfilterqueue.pyx":140 * cdef class NetfilterQueue: * """Handle a single numbered queue.""" * def __cinit__(self, *args, **kwargs): # <<<<<<<<<<<<<< @@ -3618,7 +3666,7 @@ static int __pyx_pf_14netfilterqueue_14NetfilterQueue___cinit__(struct __pyx_obj return __pyx_r; } -/* "netfilterqueue.pyx":144 +/* "netfilterqueue.pyx":151 * raise OSError("Failed to bind family %s. Are you root?" % self.af) * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -3642,7 +3690,7 @@ static void __pyx_pf_14netfilterqueue_14NetfilterQueue_2__dealloc__(struct __pyx int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "netfilterqueue.pyx":145 + /* "netfilterqueue.pyx":152 * * def __dealloc__(self): * if self.qh != NULL: # <<<<<<<<<<<<<< @@ -3652,7 +3700,7 @@ static void __pyx_pf_14netfilterqueue_14NetfilterQueue_2__dealloc__(struct __pyx __pyx_t_1 = ((__pyx_v_self->qh != NULL) != 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":146 + /* "netfilterqueue.pyx":153 * def __dealloc__(self): * if self.qh != NULL: * nfq_destroy_queue(self.qh) # <<<<<<<<<<<<<< @@ -3661,7 +3709,7 @@ static void __pyx_pf_14netfilterqueue_14NetfilterQueue_2__dealloc__(struct __pyx */ nfq_destroy_queue(__pyx_v_self->qh); - /* "netfilterqueue.pyx":145 + /* "netfilterqueue.pyx":152 * * def __dealloc__(self): * if self.qh != NULL: # <<<<<<<<<<<<<< @@ -3670,7 +3718,7 @@ static void __pyx_pf_14netfilterqueue_14NetfilterQueue_2__dealloc__(struct __pyx */ } - /* "netfilterqueue.pyx":149 + /* "netfilterqueue.pyx":156 * # 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) # <<<<<<<<<<<<<< @@ -3679,7 +3727,7 @@ static void __pyx_pf_14netfilterqueue_14NetfilterQueue_2__dealloc__(struct __pyx */ nfq_close(__pyx_v_self->h); - /* "netfilterqueue.pyx":144 + /* "netfilterqueue.pyx":151 * raise OSError("Failed to bind family %s. Are you root?" % self.af) * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -3691,7 +3739,7 @@ static void __pyx_pf_14netfilterqueue_14NetfilterQueue_2__dealloc__(struct __pyx __Pyx_RefNannyFinishContext(); } -/* "netfilterqueue.pyx":151 +/* "netfilterqueue.pyx":158 * nfq_close(self.h) * * def bind(self, int queue_num, object user_callback, # <<<<<<<<<<<<<< @@ -3734,7 +3782,7 @@ static PyObject *__pyx_pw_14netfilterqueue_14NetfilterQueue_5bind(PyObject *__py case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_user_callback)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("bind", 0, 2, 5, 1); __PYX_ERR(0, 151, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("bind", 0, 2, 5, 1); __PYX_ERR(0, 158, __pyx_L3_error) } case 2: if (kw_args > 0) { @@ -3753,7 +3801,7 @@ static PyObject *__pyx_pw_14netfilterqueue_14NetfilterQueue_5bind(PyObject *__py } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bind") < 0)) __PYX_ERR(0, 151, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bind") < 0)) __PYX_ERR(0, 158, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3766,27 +3814,27 @@ static PyObject *__pyx_pw_14netfilterqueue_14NetfilterQueue_5bind(PyObject *__py default: goto __pyx_L5_argtuple_error; } } - __pyx_v_queue_num = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_queue_num == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L3_error) + __pyx_v_queue_num = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_queue_num == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 158, __pyx_L3_error) __pyx_v_user_callback = values[1]; if (values[2]) { - __pyx_v_max_len = __Pyx_PyInt_As_u_int32_t(values[2]); if (unlikely((__pyx_v_max_len == (u_int32_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L3_error) + __pyx_v_max_len = __Pyx_PyInt_As_u_int32_t(values[2]); if (unlikely((__pyx_v_max_len == (u_int32_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 159, __pyx_L3_error) } else { __pyx_v_max_len = __pyx_k__4; } if (values[3]) { - __pyx_v_mode = __Pyx_PyInt_As_u_int8_t(values[3]); if (unlikely((__pyx_v_mode == (u_int8_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L3_error) + __pyx_v_mode = __Pyx_PyInt_As_u_int8_t(values[3]); if (unlikely((__pyx_v_mode == (u_int8_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 160, __pyx_L3_error) } else { __pyx_v_mode = __pyx_k__5; } if (values[4]) { - __pyx_v_range = __Pyx_PyInt_As_u_int32_t(values[4]); if (unlikely((__pyx_v_range == (u_int32_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L3_error) + __pyx_v_range = __Pyx_PyInt_As_u_int32_t(values[4]); if (unlikely((__pyx_v_range == (u_int32_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 161, __pyx_L3_error) } else { __pyx_v_range = ((u_int32_t)0xFFFF); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("bind", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 151, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("bind", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 158, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("netfilterqueue.NetfilterQueue.bind", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3807,7 +3855,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("bind", 0); - /* "netfilterqueue.pyx":156 + /* "netfilterqueue.pyx":163 * u_int32_t range=MaxPacketSize): * """Create and bind to a new queue.""" * self.user_callback = user_callback # <<<<<<<<<<<<<< @@ -3820,7 +3868,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o __Pyx_DECREF(__pyx_v_self->user_callback); __pyx_v_self->user_callback = __pyx_v_user_callback; - /* "netfilterqueue.pyx":157 + /* "netfilterqueue.pyx":164 * """Create and bind to a new queue.""" * self.user_callback = user_callback * self.qh = nfq_create_queue(self.h, queue_num, # <<<<<<<<<<<<<< @@ -3829,7 +3877,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o */ __pyx_v_self->qh = nfq_create_queue(__pyx_v_self->h, __pyx_v_queue_num, ((nfq_callback *)__pyx_f_14netfilterqueue_global_callback), ((void *)__pyx_v_self)); - /* "netfilterqueue.pyx":159 + /* "netfilterqueue.pyx":166 * self.qh = nfq_create_queue(self.h, queue_num, * global_callback, self) * if self.qh == NULL: # <<<<<<<<<<<<<< @@ -3839,31 +3887,31 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o __pyx_t_1 = ((__pyx_v_self->qh == NULL) != 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":160 + /* "netfilterqueue.pyx":167 * global_callback, self) * if self.qh == NULL: * raise OSError("Failed to create queue %s." % queue_num) # <<<<<<<<<<<<<< * * if range > MaxCopySize: */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_queue_num); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_queue_num); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_create_queue_s, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_create_queue_s, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 160, __pyx_L1_error) + __PYX_ERR(0, 167, __pyx_L1_error) - /* "netfilterqueue.pyx":159 + /* "netfilterqueue.pyx":166 * self.qh = nfq_create_queue(self.h, queue_num, * global_callback, self) * if self.qh == NULL: # <<<<<<<<<<<<<< @@ -3872,7 +3920,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o */ } - /* "netfilterqueue.pyx":162 + /* "netfilterqueue.pyx":169 * raise OSError("Failed to create queue %s." % queue_num) * * if range > MaxCopySize: # <<<<<<<<<<<<<< @@ -3882,7 +3930,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o __pyx_t_1 = ((__pyx_v_range > 0xFB0) != 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":163 + /* "netfilterqueue.pyx":170 * * if range > MaxCopySize: * range = MaxCopySize # <<<<<<<<<<<<<< @@ -3891,7 +3939,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o */ __pyx_v_range = 0xFB0; - /* "netfilterqueue.pyx":162 + /* "netfilterqueue.pyx":169 * raise OSError("Failed to create queue %s." % queue_num) * * if range > MaxCopySize: # <<<<<<<<<<<<<< @@ -3900,7 +3948,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o */ } - /* "netfilterqueue.pyx":164 + /* "netfilterqueue.pyx":171 * if range > MaxCopySize: * range = MaxCopySize * if nfq_set_mode(self.qh, mode, range) < 0: # <<<<<<<<<<<<<< @@ -3910,20 +3958,20 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o __pyx_t_1 = ((nfq_set_mode(__pyx_v_self->qh, __pyx_v_mode, __pyx_v_range) < 0) != 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":165 + /* "netfilterqueue.pyx":172 * 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 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 165, __pyx_L1_error) + __PYX_ERR(0, 172, __pyx_L1_error) - /* "netfilterqueue.pyx":164 + /* "netfilterqueue.pyx":171 * if range > MaxCopySize: * range = MaxCopySize * if nfq_set_mode(self.qh, mode, range) < 0: # <<<<<<<<<<<<<< @@ -3932,7 +3980,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o */ } - /* "netfilterqueue.pyx":167 + /* "netfilterqueue.pyx":174 * raise OSError("Failed to set packet copy mode.") * * nfq_set_queue_maxlen(self.qh, max_len) # <<<<<<<<<<<<<< @@ -3941,7 +3989,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o */ nfq_set_queue_maxlen(__pyx_v_self->qh, __pyx_v_max_len); - /* "netfilterqueue.pyx":151 + /* "netfilterqueue.pyx":158 * nfq_close(self.h) * * def bind(self, int queue_num, object user_callback, # <<<<<<<<<<<<<< @@ -3963,7 +4011,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_4bind(struct __pyx_o return __pyx_r; } -/* "netfilterqueue.pyx":169 +/* "netfilterqueue.pyx":176 * nfq_set_queue_maxlen(self.qh, max_len) * * def unbind(self): # <<<<<<<<<<<<<< @@ -3991,7 +4039,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_6unbind(struct __pyx int __pyx_t_1; __Pyx_RefNannySetupContext("unbind", 0); - /* "netfilterqueue.pyx":171 + /* "netfilterqueue.pyx":178 * def unbind(self): * """Destroy the queue.""" * if self.qh != NULL: # <<<<<<<<<<<<<< @@ -4001,7 +4049,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_6unbind(struct __pyx __pyx_t_1 = ((__pyx_v_self->qh != NULL) != 0); if (__pyx_t_1) { - /* "netfilterqueue.pyx":172 + /* "netfilterqueue.pyx":179 * """Destroy the queue.""" * if self.qh != NULL: * nfq_destroy_queue(self.qh) # <<<<<<<<<<<<<< @@ -4010,7 +4058,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_6unbind(struct __pyx */ nfq_destroy_queue(__pyx_v_self->qh); - /* "netfilterqueue.pyx":171 + /* "netfilterqueue.pyx":178 * def unbind(self): * """Destroy the queue.""" * if self.qh != NULL: # <<<<<<<<<<<<<< @@ -4019,7 +4067,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_6unbind(struct __pyx */ } - /* "netfilterqueue.pyx":173 + /* "netfilterqueue.pyx":180 * if self.qh != NULL: * nfq_destroy_queue(self.qh) * self.qh = NULL # <<<<<<<<<<<<<< @@ -4028,7 +4076,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_6unbind(struct __pyx */ __pyx_v_self->qh = NULL; - /* "netfilterqueue.pyx":169 + /* "netfilterqueue.pyx":176 * nfq_set_queue_maxlen(self.qh, max_len) * * def unbind(self): # <<<<<<<<<<<<<< @@ -4043,7 +4091,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_6unbind(struct __pyx return __pyx_r; } -/* "netfilterqueue.pyx":176 +/* "netfilterqueue.pyx":183 * # See warning about nfq_unbind_pf in __dealloc__ above. * * def run(self): # <<<<<<<<<<<<<< @@ -4074,7 +4122,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob int __pyx_t_1; __Pyx_RefNannySetupContext("run", 0); - /* "netfilterqueue.pyx":178 + /* "netfilterqueue.pyx":185 * def run(self): * """Begin accepting packets.""" * cdef int fd = nfq_fd(self.h) # <<<<<<<<<<<<<< @@ -4083,7 +4131,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob */ __pyx_v_fd = nfq_fd(__pyx_v_self->h); - /* "netfilterqueue.pyx":181 + /* "netfilterqueue.pyx":188 * cdef char buf[BufferSize] * cdef int rv * with nogil: # <<<<<<<<<<<<<< @@ -4097,7 +4145,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob #endif /*try:*/ { - /* "netfilterqueue.pyx":182 + /* "netfilterqueue.pyx":189 * cdef int rv * with nogil: * rv = recv(fd, buf, sizeof(buf), 0) # <<<<<<<<<<<<<< @@ -4107,7 +4155,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob __pyx_v_rv = recv(__pyx_v_fd, __pyx_v_buf, (sizeof(__pyx_v_buf)), 0); } - /* "netfilterqueue.pyx":181 + /* "netfilterqueue.pyx":188 * cdef char buf[BufferSize] * cdef int rv * with nogil: # <<<<<<<<<<<<<< @@ -4125,7 +4173,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob } } - /* "netfilterqueue.pyx":183 + /* "netfilterqueue.pyx":190 * with nogil: * rv = recv(fd, buf, sizeof(buf), 0) * while rv >= 0: # <<<<<<<<<<<<<< @@ -4136,7 +4184,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob __pyx_t_1 = ((__pyx_v_rv >= 0) != 0); if (!__pyx_t_1) break; - /* "netfilterqueue.pyx":184 + /* "netfilterqueue.pyx":191 * rv = recv(fd, buf, sizeof(buf), 0) * while rv >= 0: * nfq_handle_packet(self.h, buf, rv) # <<<<<<<<<<<<<< @@ -4145,7 +4193,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob */ nfq_handle_packet(__pyx_v_self->h, __pyx_v_buf, __pyx_v_rv); - /* "netfilterqueue.pyx":185 + /* "netfilterqueue.pyx":192 * while rv >= 0: * nfq_handle_packet(self.h, buf, rv) * with nogil: # <<<<<<<<<<<<<< @@ -4159,7 +4207,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob #endif /*try:*/ { - /* "netfilterqueue.pyx":186 + /* "netfilterqueue.pyx":193 * nfq_handle_packet(self.h, buf, rv) * with nogil: * rv = recv(fd, buf, sizeof(buf), 0) # <<<<<<<<<<<<<< @@ -4169,7 +4217,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob __pyx_v_rv = recv(__pyx_v_fd, __pyx_v_buf, (sizeof(__pyx_v_buf)), 0); } - /* "netfilterqueue.pyx":185 + /* "netfilterqueue.pyx":192 * while rv >= 0: * nfq_handle_packet(self.h, buf, rv) * with nogil: # <<<<<<<<<<<<<< @@ -4188,7 +4236,7 @@ static PyObject *__pyx_pf_14netfilterqueue_14NetfilterQueue_8run(struct __pyx_ob } } - /* "netfilterqueue.pyx":176 + /* "netfilterqueue.pyx":183 * # See warning about nfq_unbind_pf in __dealloc__ above. * * def run(self): # <<<<<<<<<<<<<< @@ -4663,8 +4711,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_OSError = __Pyx_GetBuiltinName(__pyx_n_s_OSError); if (!__pyx_builtin_OSError) __PYX_ERR(0, 61, __pyx_L1_error) - __pyx_builtin_RuntimeWarning = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeWarning); if (!__pyx_builtin_RuntimeWarning) __PYX_ERR(0, 69, __pyx_L1_error) + __pyx_builtin_OSError = __Pyx_GetBuiltinName(__pyx_n_s_OSError); if (!__pyx_builtin_OSError) __PYX_ERR(0, 63, __pyx_L1_error) + __pyx_builtin_RuntimeWarning = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeWarning); if (!__pyx_builtin_RuntimeWarning) __PYX_ERR(0, 71, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -4674,47 +4722,47 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "netfilterqueue.pyx":61 + /* "netfilterqueue.pyx":63 * 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_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Failed_to_get_payload_of_packet); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 61, __pyx_L1_error) + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Failed_to_get_payload_of_packet); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "netfilterqueue.pyx":69 + /* "netfilterqueue.pyx":71 * """Call appropriate set_verdict... function on packet.""" * if self._verdict_is_set: * raise RuntimeWarning("Verdict already given for this packet.") # <<<<<<<<<<<<<< * * cdef u_int32_t modified_payload_len = 0 */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Verdict_already_given_for_this_p); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 69, __pyx_L1_error) + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Verdict_already_given_for_this_p); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "netfilterqueue.pyx":138 + /* "netfilterqueue.pyx":145 * 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_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_open_NFQueue); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_open_NFQueue); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); - /* "netfilterqueue.pyx":165 + /* "netfilterqueue.pyx":172 * 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_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_set_packet_copy_mode); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_set_packet_copy_mode); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); @@ -4981,14 +5029,14 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) __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; __pyx_vtable_14netfilterqueue_Packet.repeat = (PyObject *(*)(struct __pyx_obj_14netfilterqueue_Packet *, int __pyx_skip_dispatch))__pyx_f_14netfilterqueue_6Packet_repeat; - if (PyType_Ready(&__pyx_type_14netfilterqueue_Packet) < 0) __PYX_ERR(0, 34, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_14netfilterqueue_Packet) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __pyx_type_14netfilterqueue_Packet.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_14netfilterqueue_Packet.tp_dict, __pyx_vtabptr_14netfilterqueue_Packet) < 0) __PYX_ERR(0, 34, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "Packet", (PyObject *)&__pyx_type_14netfilterqueue_Packet) < 0) __PYX_ERR(0, 34, __pyx_L1_error) + if (__Pyx_SetVtable(__pyx_type_14netfilterqueue_Packet.tp_dict, __pyx_vtabptr_14netfilterqueue_Packet) < 0) __PYX_ERR(0, 36, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "Packet", (PyObject *)&__pyx_type_14netfilterqueue_Packet) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __pyx_ptype_14netfilterqueue_Packet = &__pyx_type_14netfilterqueue_Packet; - if (PyType_Ready(&__pyx_type_14netfilterqueue_NetfilterQueue) < 0) __PYX_ERR(0, 131, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_14netfilterqueue_NetfilterQueue) < 0) __PYX_ERR(0, 138, __pyx_L1_error) __pyx_type_14netfilterqueue_NetfilterQueue.tp_print = 0; - if (PyObject_SetAttrString(__pyx_m, "NetfilterQueue", (PyObject *)&__pyx_type_14netfilterqueue_NetfilterQueue) < 0) __PYX_ERR(0, 131, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "NetfilterQueue", (PyObject *)&__pyx_type_14netfilterqueue_NetfilterQueue) < 0) __PYX_ERR(0, 138, __pyx_L1_error) __pyx_ptype_14netfilterqueue_NetfilterQueue = &__pyx_type_14netfilterqueue_NetfilterQueue; /*--- Type import code ---*/ /*--- Variable import code ---*/ @@ -5043,20 +5091,20 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEFAULT_MAX_QUEUELEN, __pyx_int_1024) < 0) __PYX_ERR(0, 15, __pyx_L1_error) - /* "netfilterqueue.pyx":152 + /* "netfilterqueue.pyx":159 * * 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): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEFAULT_MAX_QUEUELEN); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEFAULT_MAX_QUEUELEN); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_As_u_int32_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (u_int32_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_As_u_int32_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (u_int32_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_k__4 = __pyx_t_2; - /* "netfilterqueue.pyx":153 + /* "netfilterqueue.pyx":160 * def bind(self, int queue_num, object user_callback, * u_int32_t max_len=DEFAULT_MAX_QUEUELEN, * u_int8_t mode=NFQNL_COPY_PACKET, # <<<<<<<<<<<<<< @@ -5065,158 +5113,158 @@ PyMODINIT_FUNC PyInit_netfilterqueue(void) */ __pyx_k__5 = NFQNL_COPY_PACKET; - /* "netfilterqueue.pyx":189 + /* "netfilterqueue.pyx":196 * * PROTOCOLS = { * 0: "HOPOPT", # <<<<<<<<<<<<<< * 1: "ICMP", * 2: "IGMP", */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_int_0, __pyx_n_s_HOPOPT) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_1, __pyx_n_s_ICMP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_2, __pyx_n_s_IGMP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_3, __pyx_n_s_GGP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_4, __pyx_n_s_IP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_5, __pyx_n_s_ST) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_6, __pyx_n_s_TCP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_7, __pyx_n_s_CBT) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_8, __pyx_n_s_EGP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_9, __pyx_n_s_IGP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_10, __pyx_kp_s_BBN_RCC_MON) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_11, __pyx_kp_s_NVP_II) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_12, __pyx_n_s_PUP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_13, __pyx_n_s_ARGUS) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_14, __pyx_n_s_EMCON) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_15, __pyx_n_s_XNET) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_16, __pyx_n_s_CHAOS) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_17, __pyx_n_s_UDP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_18, __pyx_n_s_MUX) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_19, __pyx_kp_s_DCN_MEAS) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_20, __pyx_n_s_HMP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_21, __pyx_n_s_PRM) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_22, __pyx_kp_s_XNS_IDP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_23, __pyx_kp_s_TRUNK_1) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_24, __pyx_kp_s_TRUNK_2) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_25, __pyx_kp_s_LEAF_1) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_26, __pyx_kp_s_LEAF_2) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_27, __pyx_n_s_RDP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_28, __pyx_n_s_IRTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_29, __pyx_kp_s_ISO_TP4) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_30, __pyx_n_s_NETBLT) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_31, __pyx_kp_s_MFE_NSP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_32, __pyx_kp_s_MERIT_INP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_33, __pyx_n_s_DCCP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_34, __pyx_kp_s_3PC) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_35, __pyx_n_s_IDPR) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_36, __pyx_n_s_XTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_37, __pyx_n_s_DDP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_38, __pyx_kp_s_IDPR_CMTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_39, __pyx_kp_s_TP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_40, __pyx_n_s_IL) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_41, __pyx_n_s_IPv6) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_42, __pyx_n_s_SDRP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_43, __pyx_kp_s_IPv6_Route) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_44, __pyx_kp_s_IPv6_Frag) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_45, __pyx_n_s_IDRP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_46, __pyx_n_s_RSVP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_47, __pyx_n_s_GRE) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_48, __pyx_n_s_DSR) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_49, __pyx_n_s_BNA) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_50, __pyx_n_s_ESP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_51, __pyx_n_s_AH) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_52, __pyx_kp_s_I_NLSP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_53, __pyx_n_s_SWIPE) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_54, __pyx_n_s_NARP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_55, __pyx_n_s_MOBILE) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_56, __pyx_n_s_TLSP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_57, __pyx_n_s_SKIP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_58, __pyx_kp_s_IPv6_ICMP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_59, __pyx_kp_s_IPv6_NoNxt) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_60, __pyx_kp_s_IPv6_Opts) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_61, __pyx_kp_s_any_host_internal_protocol) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_62, __pyx_n_s_CFTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_63, __pyx_kp_s_any_local_network) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_64, __pyx_kp_s_SAT_EXPAK) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_65, __pyx_n_s_KRYPTOLAN) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_66, __pyx_n_s_RVD) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_67, __pyx_n_s_IPPC) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_68, __pyx_kp_s_any_distributed_file_system) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_69, __pyx_kp_s_SAT_MON) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_70, __pyx_n_s_VISA) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_71, __pyx_n_s_IPCV) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_72, __pyx_n_s_CPNX) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_73, __pyx_n_s_CPHB) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_74, __pyx_n_s_WSN) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_75, __pyx_n_s_PVP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_76, __pyx_kp_s_BR_SAT_MON) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_77, __pyx_kp_s_SUN_ND) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_78, __pyx_kp_s_WB_MON) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_79, __pyx_kp_s_WB_EXPAK) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_80, __pyx_kp_s_ISO_IP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_81, __pyx_n_s_VMTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_82, __pyx_kp_s_SECURE_VMTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_83, __pyx_n_s_VINES) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_84, __pyx_n_s_TTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_85, __pyx_kp_s_NSFNET_IGP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_86, __pyx_n_s_DGP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_87, __pyx_n_s_TCF) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_88, __pyx_n_s_EIGRP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_89, __pyx_n_s_OSPFIGP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_90, __pyx_kp_s_Sprite_RPC) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_91, __pyx_n_s_LARP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_92, __pyx_n_s_MTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_93, __pyx_kp_s_AX_25) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_94, __pyx_n_s_IPIP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_95, __pyx_n_s_MICP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_96, __pyx_kp_s_SCC_SP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_97, __pyx_n_s_ETHERIP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_98, __pyx_n_s_ENCAP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_99, __pyx_kp_s_any_private_encryption_scheme) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_100, __pyx_n_s_GMTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_101, __pyx_n_s_IFMP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_102, __pyx_n_s_PNNI) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_103, __pyx_n_s_PIM) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_104, __pyx_n_s_ARIS) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_105, __pyx_n_s_SCPS) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_106, __pyx_n_s_QNX) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_107, __pyx_kp_s_A_N) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_108, __pyx_n_s_IPComp) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_109, __pyx_n_s_SNP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_110, __pyx_kp_s_Compaq_Peer) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_111, __pyx_kp_s_IPX_in_IP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_112, __pyx_n_s_VRRP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_113, __pyx_n_s_PGM) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_114, __pyx_kp_s_any_0_hop_protocol) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_115, __pyx_n_s_L2TP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_116, __pyx_n_s_DDX) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_117, __pyx_n_s_IATP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_118, __pyx_n_s_STP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_119, __pyx_n_s_SRP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_120, __pyx_n_s_UTI) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_121, __pyx_n_s_SMP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_122, __pyx_n_s_SM) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_123, __pyx_n_s_PTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_124, __pyx_n_s_ISIS) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_125, __pyx_n_s_FIRE) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_126, __pyx_n_s_CRTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_127, __pyx_n_s_CRUDP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_128, __pyx_n_s_SSCOPMCE) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_129, __pyx_n_s_IPLT) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_130, __pyx_n_s_SPS) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_131, __pyx_n_s_PIPE) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_132, __pyx_n_s_SCTP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_133, __pyx_n_s_FC) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_134, __pyx_kp_s_RSVP_E2E_IGNORE) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_135, __pyx_n_s_Mobility) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_136, __pyx_n_s_UDPLite) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_137, __pyx_kp_s_MPLS_in_IP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_138, __pyx_n_s_manet) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_139, __pyx_n_s_HIP) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_140, __pyx_n_s_Shim6) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_int_255, __pyx_n_s_Reserved) < 0) __PYX_ERR(0, 189, __pyx_L1_error) - if (PyDict_SetItem(__pyx_d, __pyx_n_s_PROTOCOLS, __pyx_t_1) < 0) __PYX_ERR(0, 188, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_0, __pyx_n_s_HOPOPT) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_1, __pyx_n_s_ICMP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_2, __pyx_n_s_IGMP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_3, __pyx_n_s_GGP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_4, __pyx_n_s_IP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_5, __pyx_n_s_ST) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_6, __pyx_n_s_TCP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_7, __pyx_n_s_CBT) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_8, __pyx_n_s_EGP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_9, __pyx_n_s_IGP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_10, __pyx_kp_s_BBN_RCC_MON) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_11, __pyx_kp_s_NVP_II) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_12, __pyx_n_s_PUP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_13, __pyx_n_s_ARGUS) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_14, __pyx_n_s_EMCON) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_15, __pyx_n_s_XNET) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_16, __pyx_n_s_CHAOS) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_17, __pyx_n_s_UDP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_18, __pyx_n_s_MUX) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_19, __pyx_kp_s_DCN_MEAS) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_20, __pyx_n_s_HMP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_21, __pyx_n_s_PRM) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_22, __pyx_kp_s_XNS_IDP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_23, __pyx_kp_s_TRUNK_1) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_24, __pyx_kp_s_TRUNK_2) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_25, __pyx_kp_s_LEAF_1) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_26, __pyx_kp_s_LEAF_2) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_27, __pyx_n_s_RDP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_28, __pyx_n_s_IRTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_29, __pyx_kp_s_ISO_TP4) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_30, __pyx_n_s_NETBLT) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_31, __pyx_kp_s_MFE_NSP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_32, __pyx_kp_s_MERIT_INP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_33, __pyx_n_s_DCCP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_34, __pyx_kp_s_3PC) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_35, __pyx_n_s_IDPR) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_36, __pyx_n_s_XTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_37, __pyx_n_s_DDP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_38, __pyx_kp_s_IDPR_CMTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_39, __pyx_kp_s_TP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_40, __pyx_n_s_IL) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_41, __pyx_n_s_IPv6) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_42, __pyx_n_s_SDRP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_43, __pyx_kp_s_IPv6_Route) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_44, __pyx_kp_s_IPv6_Frag) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_45, __pyx_n_s_IDRP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_46, __pyx_n_s_RSVP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_47, __pyx_n_s_GRE) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_48, __pyx_n_s_DSR) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_49, __pyx_n_s_BNA) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_50, __pyx_n_s_ESP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_51, __pyx_n_s_AH) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_52, __pyx_kp_s_I_NLSP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_53, __pyx_n_s_SWIPE) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_54, __pyx_n_s_NARP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_55, __pyx_n_s_MOBILE) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_56, __pyx_n_s_TLSP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_57, __pyx_n_s_SKIP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_58, __pyx_kp_s_IPv6_ICMP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_59, __pyx_kp_s_IPv6_NoNxt) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_60, __pyx_kp_s_IPv6_Opts) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_61, __pyx_kp_s_any_host_internal_protocol) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_62, __pyx_n_s_CFTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_63, __pyx_kp_s_any_local_network) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_64, __pyx_kp_s_SAT_EXPAK) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_65, __pyx_n_s_KRYPTOLAN) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_66, __pyx_n_s_RVD) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_67, __pyx_n_s_IPPC) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_68, __pyx_kp_s_any_distributed_file_system) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_69, __pyx_kp_s_SAT_MON) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_70, __pyx_n_s_VISA) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_71, __pyx_n_s_IPCV) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_72, __pyx_n_s_CPNX) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_73, __pyx_n_s_CPHB) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_74, __pyx_n_s_WSN) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_75, __pyx_n_s_PVP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_76, __pyx_kp_s_BR_SAT_MON) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_77, __pyx_kp_s_SUN_ND) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_78, __pyx_kp_s_WB_MON) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_79, __pyx_kp_s_WB_EXPAK) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_80, __pyx_kp_s_ISO_IP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_81, __pyx_n_s_VMTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_82, __pyx_kp_s_SECURE_VMTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_83, __pyx_n_s_VINES) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_84, __pyx_n_s_TTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_85, __pyx_kp_s_NSFNET_IGP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_86, __pyx_n_s_DGP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_87, __pyx_n_s_TCF) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_88, __pyx_n_s_EIGRP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_89, __pyx_n_s_OSPFIGP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_90, __pyx_kp_s_Sprite_RPC) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_91, __pyx_n_s_LARP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_92, __pyx_n_s_MTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_93, __pyx_kp_s_AX_25) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_94, __pyx_n_s_IPIP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_95, __pyx_n_s_MICP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_96, __pyx_kp_s_SCC_SP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_97, __pyx_n_s_ETHERIP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_98, __pyx_n_s_ENCAP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_99, __pyx_kp_s_any_private_encryption_scheme) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_100, __pyx_n_s_GMTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_101, __pyx_n_s_IFMP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_102, __pyx_n_s_PNNI) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_103, __pyx_n_s_PIM) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_104, __pyx_n_s_ARIS) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_105, __pyx_n_s_SCPS) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_106, __pyx_n_s_QNX) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_107, __pyx_kp_s_A_N) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_108, __pyx_n_s_IPComp) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_109, __pyx_n_s_SNP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_110, __pyx_kp_s_Compaq_Peer) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_111, __pyx_kp_s_IPX_in_IP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_112, __pyx_n_s_VRRP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_113, __pyx_n_s_PGM) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_114, __pyx_kp_s_any_0_hop_protocol) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_115, __pyx_n_s_L2TP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_116, __pyx_n_s_DDX) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_117, __pyx_n_s_IATP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_118, __pyx_n_s_STP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_119, __pyx_n_s_SRP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_120, __pyx_n_s_UTI) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_121, __pyx_n_s_SMP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_122, __pyx_n_s_SM) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_123, __pyx_n_s_PTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_124, __pyx_n_s_ISIS) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_125, __pyx_n_s_FIRE) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_126, __pyx_n_s_CRTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_127, __pyx_n_s_CRUDP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_128, __pyx_n_s_SSCOPMCE) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_129, __pyx_n_s_IPLT) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_130, __pyx_n_s_SPS) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_131, __pyx_n_s_PIPE) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_132, __pyx_n_s_SCTP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_133, __pyx_n_s_FC) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_134, __pyx_kp_s_RSVP_E2E_IGNORE) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_135, __pyx_n_s_Mobility) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_136, __pyx_n_s_UDPLite) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_137, __pyx_kp_s_MPLS_in_IP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_138, __pyx_n_s_manet) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_139, __pyx_n_s_HIP) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_140, __pyx_n_s_Shim6) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_int_255, __pyx_n_s_Reserved) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_PROTOCOLS, __pyx_t_1) < 0) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "netfilterqueue.pyx":1 diff --git a/netfilterqueue.pxd b/netfilterqueue.pxd index 4e0f831..cacd38b 100644 --- a/netfilterqueue.pxd +++ b/netfilterqueue.pxd @@ -47,6 +47,7 @@ cdef enum: IPPROTO_MAX cdef extern from "Python.h": + object PyBytes_FromStringAndSize(char *s, Py_ssize_t len) object PyString_FromStringAndSize(char *s, Py_ssize_t len) cdef extern from "sys/time.h": @@ -78,7 +79,7 @@ cdef extern from "libnetfilter_queue/linux_nfnetlink_queue.h": u_int32_t packet_id u_int16_t hw_protocol u_int8_t hook - + cdef extern from "libnetfilter_queue/libnetfilter_queue.h": struct nfq_handle: pass @@ -88,10 +89,10 @@ cdef extern from "libnetfilter_queue/libnetfilter_queue.h": pass struct nfqnl_msg_packet_hw: u_int8_t hw_addr[8] - + nfq_handle *nfq_open() int nfq_close(nfq_handle *h) - + int nfq_bind_pf(nfq_handle *h, u_int16_t pf) int nfq_unbind_pf(nfq_handle *h, u_int16_t pf) ctypedef int *nfq_callback(nfq_q_handle *gh, nfgenmsg *nfmsg, @@ -101,21 +102,21 @@ cdef extern from "libnetfilter_queue/libnetfilter_queue.h": nfq_callback *cb, void *data) int nfq_destroy_queue(nfq_q_handle *qh) - + int nfq_handle_packet(nfq_handle *h, char *buf, int len) - + int nfq_set_mode(nfq_q_handle *qh, u_int8_t mode, unsigned int len) - + q_set_queue_maxlen(nfq_q_handle *qh, u_int32_t queuelen) - + int nfq_set_verdict(nfq_q_handle *qh, u_int32_t id, u_int32_t verdict, u_int32_t data_len, unsigned char *buf) nogil - + int nfq_set_verdict_mark(nfq_q_handle *qh, u_int32_t id, u_int32_t verdict, @@ -130,7 +131,7 @@ cdef extern from "libnetfilter_queue/libnetfilter_queue.h": int nfq_get_timestamp(nfq_data *nfad, timeval *tv) nfqnl_msg_packet_hw *nfq_get_packet_hw(nfq_data *nfad) int nfq_get_nfmark (nfq_data *nfad) - + # Dummy defines from linux/socket.h: cdef enum: # Protocol families, same as address families. PF_INET = 2 @@ -138,7 +139,7 @@ cdef enum: # Protocol families, same as address families. cdef extern from "sys/socket.h": ssize_t recv(int __fd, void *__buf, size_t __n, int __flags) nogil - + # Dummy defines from linux/netfilter.h cdef enum: NF_DROP @@ -153,18 +154,18 @@ cdef class Packet: cdef nfq_q_handle *_qh cdef nfq_data *_nfa cdef nfqnl_msg_packet_hdr *_hdr - cdef bint _verdict_is_set # True if verdict has been issued, + cdef bint _verdict_is_set # True if verdict has been issued, # false otherwise cdef bint _mark_is_set # True if a mark has been given, false otherwise cdef u_int32_t _given_mark # Mark given to packet cdef bytes _given_payload # New payload of packet, or null - + # From NFQ packet header: cdef readonly u_int32_t id cdef readonly u_int16_t hw_protocol cdef readonly u_int8_t hook cdef readonly u_int32_t mark - + # Packet details: cdef Py_ssize_t payload_len cdef readonly char *payload @@ -176,7 +177,7 @@ cdef class Packet: #cdef readonly u_int32_t physindev #cdef readonly u_int32_t outdev #cdef readonly u_int32_t physoutdev - + cdef set_nfq_data(self, nfq_q_handle *qh, nfq_data *nfa) cdef void verdict(self, u_int8_t verdict) cpdef Py_ssize_t get_payload_len(self) @@ -187,11 +188,11 @@ cdef class Packet: cpdef accept(self) cpdef drop(self) cpdef repeat(self) - + 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 - + diff --git a/netfilterqueue.pyx b/netfilterqueue.pyx index 756654a..abc2c80 100644 --- a/netfilterqueue.pyx +++ b/netfilterqueue.pyx @@ -1,5 +1,5 @@ """ -Bind to a Linux netfilter queue. Send packets to a user-specified callback +Bind to a Linux netfilter queue. Send packets to a user-specified callback function. Copyright: (c) 2011, Kerkhoff Technologies Inc. @@ -20,7 +20,9 @@ DEF BufferSize = 4096 DEF MetadataSize = 80 DEF MaxCopySize = BufferSize - MetadataSize -cdef int global_callback(nfq_q_handle *qh, nfgenmsg *nfmsg, +cimport cpython.version + +cdef int global_callback(nfq_q_handle *qh, nfgenmsg *nfmsg, nfq_data *nfa, void *data) with gil: """Create a Packet and pass it to appropriate callback.""" cdef NetfilterQueue nfqueue = data @@ -37,29 +39,29 @@ cdef class Packet: self._verdict_is_set = False self._mark_is_set = False self._given_payload = None - + def __str__(self): cdef iphdr *hdr = self.payload protocol = PROTOCOLS.get(hdr.protocol, "Unknown protocol") return "%s packet, %s bytes" % (protocol, self.payload_len) - + cdef set_nfq_data(self, nfq_q_handle *qh, nfq_data *nfa): """ - Assign a packet from NFQ to this object. Parse the header and load + Assign a packet from NFQ to this object. Parse the header and load local values. """ self._qh = qh self._nfa = nfa self._hdr = nfq_get_msg_packet_hdr(nfa) - + self.id = ntohl(self._hdr.packet_id) self.hw_protocol = ntohs(self._hdr.hw_protocol) self.hook = self._hdr.hook - + 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) self.mark = nfq_get_nfmark(nfa) @@ -69,7 +71,7 @@ cdef class Packet: raise RuntimeWarning("Verdict already given for this packet.") cdef u_int32_t modified_payload_len = 0 - cdef unsigned char *modified_payload = NULL + cdef unsigned char *modified_payload = NULL if self._given_payload: modified_payload_len = len(self._given_payload) modified_payload = self._given_payload @@ -90,23 +92,28 @@ cdef class Packet: modified_payload) self._verdict_is_set = True - + def get_payload(self): """Return payload as Python string.""" - cdef object py_string = PyString_FromStringAndSize(self.payload, - self.payload_len) + cdef object py_string + if cpython.version.PY_MAJOR_VERSION >= 3: + py_string = PyBytes_FromStringAndSize( + self.payload, self.payload_len) + else: + py_string = PyString_FromStringAndSize( + self.payload, self.payload_len) return py_string - + cpdef Py_ssize_t get_payload_len(self): return self.payload_len - + cpdef double get_timestamp(self): return self.timestamp.tv_sec + (self.timestamp.tv_usec/1000000.0) - + cpdef set_payload(self, bytes payload): """Set the new payload of this packet.""" self._given_payload = payload - + cpdef set_mark(self, u_int32_t mark): self._given_mark = mark self._mark_is_set = True @@ -115,11 +122,11 @@ cdef class Packet: if self._mark_is_set: return self._given_mark return self.mark - + cpdef accept(self): """Accept the packet.""" self.verdict(NF_ACCEPT) - + cpdef drop(self): """Drop the packet.""" self.verdict(NF_DROP) @@ -136,20 +143,20 @@ cdef class NetfilterQueue: 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 + 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) - + 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 + # 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, object user_callback, - u_int32_t max_len=DEFAULT_MAX_QUEUELEN, + 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.""" @@ -158,21 +165,21 @@ cdef class NetfilterQueue: global_callback, self) if self.qh == NULL: raise OSError("Failed to create queue %s." % queue_num) - + if range > MaxCopySize: 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) - + def unbind(self): """Destroy the queue.""" if self.qh != NULL: nfq_destroy_queue(self.qh) self.qh = NULL # See warning about nfq_unbind_pf in __dealloc__ above. - + def run(self): """Begin accepting packets.""" cdef int fd = nfq_fd(self.h) diff --git a/setup.py b/setup.py index cab7d6b..0656291 100644 --- a/setup.py +++ b/setup.py @@ -42,5 +42,6 @@ setup( "Intended Audience :: Telecommunications Industry", "Programming Language :: Cython", "Programming Language :: Python :: 2", + "Programming Language :: Python :: 3", ] )