Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions iptc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,15 @@ class ipt_entry_match(xt_entry_match):

ipt_align = xt_align

try:
_libiptc = ct.CDLL(ctypes.util.find_library("ip4tc"), use_errno = True)
except:
_libiptc = ct.CDLL(ctypes.util.find_library("iptc"), use_errno = True)
_libiptc_file = ctypes.util.find_library("ip4tc")

if not _libiptc_file:
_libiptc_file = ctypes.util.find_library("iptc")

if not _libiptc_file:
raise IPTCError("error: libiptc/libip4tc not found")

_libiptc = ct.CDLL(_libiptc_file, use_errno = True)

class iptc(object):
"""This class contains all libiptc API calls."""
Expand Down Expand Up @@ -939,6 +944,12 @@ def set_protocol(self, proto):
protocol = property(get_protocol, set_protocol)
"""This is the transport layer protocol."""

def get_counters(self):
"""This method returns a tuple pair of the packet and byte counters of
the rule."""
counters = self.entry.counters
return counters.pcnt, counters.bcnt

def _get_rule(self):
if not self.entry or not self._target or not self._target.target:
return None
Expand Down