Exemple #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
Exemple #2
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
Exemple #3
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
Exemple #4
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
Exemple #5
0
 def get_sets(self):
     return self.request(nfgen_msg(), NFT_MSG_GETSET)
Exemple #6
0
 def get_rules(self):
     return self.request(nfgen_msg(), NFT_MSG_GETRULE)
Exemple #7
0
 def get_chains(self):
     return self.request(nfgen_msg(), NFT_MSG_GETCHAIN)
Exemple #8
0
 def get_tables(self):
     return self.request(nfgen_msg(), NFT_MSG_GETTABLE)
Exemple #9
0
 def get_sets(self):
     return self.request_get(nfgen_msg(), NFT_MSG_GETSET)
Exemple #10
0
 def get_rules(self):
     return self.request_get(nfgen_msg(), NFT_MSG_GETRULE)
Exemple #11
0
 def get_chains(self):
     return self.request_get(nfgen_msg(), NFT_MSG_GETCHAIN)
Exemple #12
0
 def get_tables(self):
     return self.request_get(nfgen_msg(), NFT_MSG_GETTABLE)