1from ctypes import c_ubyte 2from ctypes import c_uint 3from ctypes import c_ushort 4from ctypes import Structure 5from enum import Enum 6 7 8class Nlmsghdr(Structure): 9 _fields_ = [ 10 ("nlmsg_len", c_uint), 11 ("nlmsg_type", c_ushort), 12 ("nlmsg_flags", c_ushort), 13 ("nlmsg_seq", c_uint), 14 ("nlmsg_pid", c_uint), 15 ] 16 17 18class NlMsgType(Enum): 19 NLMSG_NOOP = 1 20 NLMSG_ERROR = 2 21 NLMSG_DONE = 3 22 NLMSG_OVERRUN = 4 23 24 25class NlmBaseFlags(Enum): 26 NLM_F_REQUEST = 0x01 27 NLM_F_MULTI = 0x02 28 NLM_F_ACK = 0x04 29 NLM_F_ECHO = 0x08 30 NLM_F_DUMP_INTR = 0x10 31 NLM_F_DUMP_FILTERED = 0x20 32 33 34# XXX: in python3.8 it is possible to 35# class NlmGetFlags(Enum, NlmBaseFlags): 36 37 38class NlmGetFlags(Enum): 39 NLM_F_ROOT = 0x100 40 NLM_F_MATCH = 0x200 41 NLM_F_ATOMIC = 0x400 42 43 44class NlmNewFlags(Enum): 45 NLM_F_REPLACE = 0x100 46 NLM_F_EXCL = 0x200 47 NLM_F_CREATE = 0x400 48 NLM_F_APPEND = 0x800 49 50 51class NlmDeleteFlags(Enum): 52 NLM_F_NONREC = 0x100 53 54 55class NlmAckFlags(Enum): 56 NLM_F_CAPPED = 0x100 57 NLM_F_ACK_TLVS = 0x200 58 59 60class GenlMsgHdr(Structure): 61 _fields_ = [ 62 ("cmd", c_ubyte), 63 ("version", c_ubyte), 64 ("reserved", c_ushort), 65 ] 66