예제 #1
0
 def commit(self):
     with self._write_lock:
         msg = nfgen_msg()
         msg['res_id'] = NFNL_SUBSYS_NFTABLES
         msg['header']['type'] = 0x11
         msg['header']['flags'] = NLM_F_REQUEST
         msg['header']['sequence_number'] = self._ts.seqnum[2]
         msg.encode()
         self._ts.data += msg.data
         self.sendto(self._ts.data, (0, 0))
         for seqnum in self._ts.seqnum:
             self.addr_pool.free(seqnum, ban=10)
         del self._ts.data
예제 #2
0
    def begin(self):
        with self._write_lock:
            if hasattr(self._ts, 'data'):
                # transaction is already started
                return False

            self._ts.data = b''
            self._ts.seqnum = (self.addr_pool.alloc(),  # begin
                               self.addr_pool.alloc(),  # tx
                               self.addr_pool.alloc())  # commit
            msg = nfgen_msg()
            msg['res_id'] = NFNL_SUBSYS_NFTABLES
            msg['header']['type'] = 0x10
            msg['header']['flags'] = NLM_F_REQUEST
            msg['header']['sequence_number'] = self._ts.seqnum[0]
            msg.encode()
            self._ts.data += msg.data
            return True
예제 #3
0
 def get_sets(self):
     return self.request_get(nfgen_msg(), NFT_MSG_GETSET)
예제 #4
0
 def get_rules(self):
     return self.request_get(nfgen_msg(), NFT_MSG_GETRULE)
예제 #5
0
 def get_chains(self):
     return self.request_get(nfgen_msg(), NFT_MSG_GETCHAIN)
예제 #6
0
 def get_tables(self):
     return self.request_get(nfgen_msg(), NFT_MSG_GETTABLE)