def callback_recv_msg(msg, _): assert 16 == msg.nm_protocol assert 0 == msg.nm_flags assert 16 == msg.nm_src.nl_family assert 0 == msg.nm_src.nl_pid assert 0 == msg.nm_src.nl_groups assert 0 == msg.nm_dst.nl_family assert 0 == msg.nm_dst.nl_pid assert 0 == msg.nm_dst.nl_groups assert msg.nm_creds is None assert 16 == msg.nm_nlh.nlmsg_type assert 0 == msg.nm_nlh.nlmsg_flags assert 100 < msg.nm_nlh.nlmsg_pid assert 1000 < msg.nm_size assert 1 == msg.nm_refcnt dump_hex(logging.getLogger().debug, msg.nm_nlh.bytearray, nlmsg_datalen(msg.nm_nlh), 0) return NL_OK
def callback_send(sk, msg): assert 16 == msg.nm_protocol assert 0 == msg.nm_flags assert 0 == msg.nm_src.nl_family assert 0 == msg.nm_src.nl_pid assert 0 == msg.nm_src.nl_groups assert 0 == msg.nm_dst.nl_family assert 0 == msg.nm_dst.nl_pid assert 0 == msg.nm_dst.nl_groups assert msg.nm_creds is None assert 16 == msg.nm_nlh.nlmsg_type assert 5 == msg.nm_nlh.nlmsg_flags assert 100 < msg.nm_nlh.nlmsg_pid assert 1 == msg.nm_refcnt hdr = nlmsg_hdr(msg) iov = hdr.bytearray[:hdr.nlmsg_len] dump_hex(logging.getLogger().debug, iov, len(iov), 0) return nl_send_iovec(sk, msg, iov, 1)
def callback_recv(sk, nla, buf, creds): n = nl_recv(sk, nla, buf, creds) dump_hex(logging.getLogger().debug, buf, len(buf), 0) return n