work on new packet

This commit is contained in:
dowright 2021-08-23 21:23:35 -07:00 committed by DOWRIGHT
parent 58b08ebcdc
commit f0f68aff24
2 changed files with 5 additions and 5 deletions

View File

@ -193,5 +193,5 @@ cdef class CPacket:
cdef int nf_callback(self, nfq_q_handle *qh, nfgenmsg *nfmsg, nfq_data *nfa, void *data)
cdef parse(self, nfq_q_handle *qh, nfq_data *nfa) nogil
cdef _parse(self)
cdef _parse(self, unsigned char *data)
cdef void verdict(self, u_int32_t verdict)

View File

@ -88,7 +88,7 @@ cdef class CPacket:
# with gil:
# callback(self)
cdef _parse(self, readonly unsigned char *data):
cdef _parse(self, unsigned char *data):
'''Index tcp/ip packet layers 3 & 4 for use as instance objects.
the before_exit method will be called before returning, which can be used to create
subclass specific objects like namedtuples or application layer data.'''
@ -103,19 +103,19 @@ cdef class CPacket:
if (ip_header.protocol == IPPROTO_TCP):
*tcp_header = <tcphdr*>data[iphdr_len:]
tcp_header[0] = <tcphdr*>data[iphdr_len:]
self.tcp_header = tcp_header
if (ip_header.protocol == IPPROTO_UDP):
*udp_header = <udphdr*>data[iphdr_len:]
udp_header[0] = <udphdr*>data[iphdr_len:]
self.udp_header = udp_header
if (ip_header.protocol == IPPROTO_ICMP):
*icmp_header = <icmphdr*>data[iphdr_len:]
icmp_header[0] = <icmphdr*>data[iphdr_len:]
self.icmp_header = icmp_header