From 15f05d70a0d2c33778dfd06c971c4f67039f1ec9 Mon Sep 17 00:00:00 2001 From: Frederik Kriewitz Date: Mon, 7 May 2012 13:00:05 +0200 Subject: [PATCH 1/2] fix undefined symbol: iptc_init (libiptc compatibilitly) --- iptc/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/iptc/__init__.py b/iptc/__init__.py index 400111c..3d25f29 100644 --- a/iptc/__init__.py +++ b/iptc/__init__.py @@ -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.""" From fe8f6660ba01f9df0b142c4d7fa0e5fd5959ed24 Mon Sep 17 00:00:00 2001 From: Frederik Kriewitz Date: Mon, 7 May 2012 13:14:10 +0200 Subject: [PATCH 2/2] add get_counters() for rules --- iptc/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iptc/__init__.py b/iptc/__init__.py index 3d25f29..3f6c19f 100644 --- a/iptc/__init__.py +++ b/iptc/__init__.py @@ -944,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