Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/atf_python/sys/netlink/base_headers.py
39553 views
1
from ctypes import c_ubyte
2
from ctypes import c_uint
3
from ctypes import c_ushort
4
from ctypes import Structure
5
from enum import Enum
6
7
8
class 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
18
class Nlattr(Structure):
19
_fields_ = [
20
("nla_len", c_ushort),
21
("nla_type", c_ushort),
22
]
23
24
25
class NlMsgType(Enum):
26
NLMSG_NOOP = 1
27
NLMSG_ERROR = 2
28
NLMSG_DONE = 3
29
NLMSG_OVERRUN = 4
30
31
32
class 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
45
class NlmGetFlags(Enum):
46
NLM_F_ROOT = 0x100
47
NLM_F_MATCH = 0x200
48
NLM_F_ATOMIC = 0x400
49
50
51
class NlmNewFlags(Enum):
52
NLM_F_REPLACE = 0x100
53
NLM_F_EXCL = 0x200
54
NLM_F_CREATE = 0x400
55
NLM_F_APPEND = 0x800
56
57
58
class NlmDeleteFlags(Enum):
59
NLM_F_NONREC = 0x100
60
61
62
class NlmAckFlags(Enum):
63
NLM_F_CAPPED = 0x100
64
NLM_F_ACK_TLVS = 0x200
65
66
67
class GenlMsgHdr(Structure):
68
_fields_ = [
69
("cmd", c_ubyte),
70
("version", c_ubyte),
71
("reserved", c_ushort),
72
]
73
74