add get_mark

This commit is contained in:
Fen Qin 2013-04-15 11:30:35 +08:00
parent 26ff0e7844
commit 6b8be8a5ec
5 changed files with 556 additions and 340 deletions

View File

@ -1,3 +1,6 @@
v0.6, 15 Apr 2013
Add get_mark.
v0.5, 3 Apr 2013
Add repeat.

File diff suppressed because it is too large Load Diff

View File

@ -129,6 +129,7 @@ cdef extern from "libnetfilter_queue/libnetfilter_queue.h":
int nfq_get_payload(nfq_data *nfad, char **data)
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.
@ -162,6 +163,7 @@ cdef class Packet:
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
@ -181,6 +183,7 @@ cdef class Packet:
cpdef double get_timestamp(self)
cpdef set_payload(self, bytes payload)
cpdef set_mark(self, u_int32_t mark)
cpdef get_mark(self)
cpdef accept(self)
cpdef drop(self)
cpdef repeat(self)

View File

@ -5,7 +5,7 @@ function.
Copyright: (c) 2011, Kerkhoff Technologies Inc.
License: MIT; see LICENSE.txt
"""
VERSION = (0, 5, 0)
VERSION = (0, 6, 0)
# Constants for module users
COPY_NONE = 1
@ -61,6 +61,7 @@ cdef class Packet:
raise OSError("Failed to get payload of packet.")
nfq_get_timestamp(self._nfa, &self.timestamp)
self.mark = nfq_get_nfmark(nfa)
cdef void verdict(self, u_int8_t verdict):
"""Call appropriate set_verdict... function on packet."""
@ -109,6 +110,11 @@ cdef class Packet:
cpdef set_mark(self, u_int32_t mark):
self._given_mark = mark
self._mark_is_set = True
cpdef get_mark(self):
if self._mark_is_set:
return self._given_mark
return self.mark
cpdef accept(self):
"""Accept the packet."""

View File

@ -1,6 +1,6 @@
from distutils.core import setup, Extension
VERSION = "0.5" # Remember to change README.rst when version changes.
VERSION = "0.6" # Remember to change README.rst when version changes.
try:
# Use Cython