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 Nlattr(Structure): 19 _fields_ = [ 20 ("nla_len", c_ushort), 21 ("nla_type", c_ushort), 22 ] 23 24 25class NlMsgType(Enum): 26 NLMSG_NOOP = 1 27 NLMSG_ERROR = 2 28 NLMSG_DONE = 3 29 NLMSG_OVERRUN = 4 30 31 32class NlmBaseFlags(Enum): 33 NLM_F_REQUEST = 0x01 34 NLM_F_MULTI = 0x02 35 NLM_F_ACK = 0x04 36 NLM_F_ECHO = 0x08 37 NLM_F_DUMP_INTR = 0x10 38 NLM_F_DUMP_FILTERED = 0x20 39 40 41# XXX: in python3.8 it is possible to 42# class NlmGetFlags(Enum, NlmBaseFlags): 43 44 45class NlmGetFlags(Enum): 46 NLM_F_ROOT = 0x100 47 NLM_F_MATCH = 0x200 48 NLM_F_ATOMIC = 0x400 49 50 51class NlmNewFlags(Enum): 52 NLM_F_REPLACE = 0x100 53 NLM_F_EXCL = 0x200 54 NLM_F_CREATE = 0x400 55 NLM_F_APPEND = 0x800 56 57 58class NlmDeleteFlags(Enum): 59 NLM_F_NONREC = 0x100 60 61 62class NlmAckFlags(Enum): 63 NLM_F_CAPPED = 0x100 64 NLM_F_ACK_TLVS = 0x200 65 66 67class GenlMsgHdr(Structure): 68 _fields_ = [ 69 ("cmd", c_ubyte), 70 ("version", c_ubyte), 71 ("reserved", c_ushort), 72 ] 73