From cf87074f2b5d520124fc51f1aec693847aa6b91c Mon Sep 17 00:00:00 2001
From: dowright <dowright@nationofnobodies.com>
Date: Mon, 30 Aug 2021 21:56:59 -0700
Subject: [PATCH] implementing ctuples.

---
 netfilterqueue/_impl.pxd | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/netfilterqueue/_impl.pxd b/netfilterqueue/_impl.pxd
index 4d47456..faa3306 100644
--- a/netfilterqueue/_impl.pxd
+++ b/netfilterqueue/_impl.pxd
@@ -6,6 +6,17 @@ cdef extern from "sys/types.h":
 cdef extern from "<errno.h>":
     int errno
 
+cdef extern from "time.h" nogil:
+    ctypedef long time_t
+    time_t time(time_t*)
+
+    struct timeval:
+        time_t tv_sec
+        time_t tv_usec
+
+    struct timezone:
+        pass
+
 # dummy defines from asm-generic/errno.h:
 cdef enum:
     EAGAIN = 11           # Try again
@@ -48,6 +59,7 @@ cdef struct udphdr:
 
 cdef struct icmphdr:
     u_int8_t type
+    u_int8_t code
 
 # from netinet/in.h:
 cdef enum:
@@ -59,15 +71,6 @@ cdef enum:
 cdef extern from "Python.h":
     object PyBytes_FromStringAndSize(char *s, Py_ssize_t len)
 
-cdef extern from "sys/time.h":
-    ctypedef long time_t
-    struct timeval:
-        time_t tv_sec
-        time_t tv_usec
-
-    struct timezone:
-        pass
-
 cdef extern from "netinet/in.h":
     u_int32_t ntohl (u_int32_t __netlong) nogil
     u_int16_t ntohs (u_int16_t __netshort) nogil
@@ -174,16 +177,15 @@ cdef class CPacket:
     cdef bint _verdict_is_set
     cdef u_int32_t _mark
 
-    # Packet details:
+    # Packet details
     cdef Py_ssize_t data_len
     cdef readonly unsigned char *data
     cdef readonly unsigned char *payload
-    cdef timeval timestamp
+    cdef time_t timestamp
 
     cdef u_int32_t parse(self, nfq_q_handle *qh, nfq_data *nfa) nogil
     cdef void _parse(self) nogil
     cdef void verdict(self, u_int32_t verdict)
-    cdef double get_timestamp(self)
     cpdef update_mark(self, u_int32_t mark)
     cpdef accept(self)
     cpdef drop(self)
@@ -194,4 +196,4 @@ cdef class NetfilterQueue:
     cdef nfq_handle *h # Handle to NFQueue library
     cdef nfq_q_handle *qh # A handle to the queue
     cdef u_int16_t af # Address family
-    cdef packet_copy_size # Amount of packet metadata + data copied to buffer
\ No newline at end of file
+    cdef packet_copy_size # Amount of packet metadata + data copied to buffer