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
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
def get_sets(self): return self.request_get(nfgen_msg(), NFT_MSG_GETSET)
def get_rules(self): return self.request_get(nfgen_msg(), NFT_MSG_GETRULE)
def get_chains(self): return self.request_get(nfgen_msg(), NFT_MSG_GETCHAIN)
def get_tables(self): return self.request_get(nfgen_msg(), NFT_MSG_GETTABLE)