Example #1
0
 def catch(self, callback):
     """
     Catch all Netfilter expect events: call specified callback for
     each event. See register_callback() method for callback details.
     """
     self.register_callback(callback)
     ret = nfexp_catch(self.handle)
     if ret != 0:
         raise RuntimeError("nfexp_catch() failure: %s" % strerror(get_errno()))
Example #2
0
    def query(self, command, argument):
        """
        Do query libnetfilter_conntrack:
         - command: NFCT_Q_CREATE, NFCT_Q_UPDATE, ...
         - argument (optional): value depends on command

        May raise a RuntimeError.
        """
        ret = nfexp_query(self.handle, command, argument)
        if ret != 0:
            raise RuntimeError("nfct_query() failure: %s" % strerror(get_errno()))
 def _error(self, func_name):
     errno = get_errno()
     err_msg = strerror(errno)
     raise RuntimeError("%s() failure: %s" % (func_name, err_msg))