Debian Codegraph @

abi/linux/netlink.go

raw symbols SCIP
1 // Copyright 2018 The gVisor Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package linux
16
17 // Netlink protocols, from uapi/linux/netlink.h.
18 const (
19 NETLINK_ROUTE = 0
20 NETLINK_UNUSED = 1
21 NETLINK_USERSOCK = 2
22 NETLINK_FIREWALL = 3
23 NETLINK_SOCK_DIAG = 4
24 NETLINK_NFLOG = 5
25 NETLINK_XFRM = 6
26 NETLINK_SELINUX = 7
27 NETLINK_ISCSI = 8
28 NETLINK_AUDIT = 9
29 NETLINK_FIB_LOOKUP = 10
30 NETLINK_CONNECTOR = 11
31 NETLINK_NETFILTER = 12
32 NETLINK_IP6_FW = 13
33 NETLINK_DNRTMSG = 14
34 NETLINK_KOBJECT_UEVENT = 15
35 NETLINK_GENERIC = 16
36 NETLINK_SCSITRANSPORT = 18
37 NETLINK_ECRYPTFS = 19
38 NETLINK_RDMA = 20
39 NETLINK_CRYPTO = 21
40 )
41
42 // SockAddrNetlink is struct sockaddr_nl, from uapi/linux/netlink.h.
43 //
44 // +marshal
45 type SockAddrNetlink struct {
46 Family uint16
47 _ uint16
48 PortID uint32
49 Groups uint32
50 }
51
52 // SockAddrNetlinkSize is the size of SockAddrNetlink.
53 const SockAddrNetlinkSize = 12
54
55 // NetlinkMessageHeader is struct nlmsghdr, from uapi/linux/netlink.h.
56 //
57 // +marshal
58 type NetlinkMessageHeader struct {
59 Length uint32
60 Type uint16
61 Flags uint16
62 Seq uint32
63 PortID uint32
64 }
65
66 // NetlinkMessageHeaderSize is the size of NetlinkMessageHeader.
67 const NetlinkMessageHeaderSize = 16
68
69 // Netlink message header flags, from uapi/linux/netlink.h.
70 const (
71 NLM_F_REQUEST = 0x1
72 NLM_F_MULTI = 0x2
73 NLM_F_ACK = 0x4
74 NLM_F_ECHO = 0x8
75 NLM_F_DUMP_INTR = 0x10
76 NLM_F_ROOT = 0x100
77 NLM_F_MATCH = 0x200
78 NLM_F_ATOMIC = 0x400
79 NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH
80 NLM_F_REPLACE = 0x100
81 NLM_F_EXCL = 0x200
82 NLM_F_CREATE = 0x400
83 NLM_F_APPEND = 0x800
84 )
85
86 // Standard netlink message types, from uapi/linux/netlink.h.
87 const (
88 NLMSG_NOOP = 0x1
89 NLMSG_ERROR = 0x2
90 NLMSG_DONE = 0x3
91 NLMSG_OVERRUN = 0x4
92
93 // NLMSG_MIN_TYPE is the first value for protocol-level types.
94 NLMSG_MIN_TYPE = 0x10
95 )
96
97 // NLMSG_ALIGNTO is the alignment of netlink messages, from
98 // uapi/linux/netlink.h.
99 const NLMSG_ALIGNTO = 4
100
101 // NetlinkAttrHeader is the header of a netlink attribute, followed by payload.
102 //
103 // This is struct nlattr, from uapi/linux/netlink.h.
104 //
105 // +marshal
106 type NetlinkAttrHeader struct {
107 Length uint16
108 Type uint16
109 }
110
111 // NetlinkAttrHeaderSize is the size of NetlinkAttrHeader.
112 const NetlinkAttrHeaderSize = 4
113
114 // NLA_ALIGNTO is the alignment of netlink attributes, from
115 // uapi/linux/netlink.h.
116 const NLA_ALIGNTO = 4
117
118 // Socket options, from uapi/linux/netlink.h.
119 const (
120 NETLINK_ADD_MEMBERSHIP = 1
121 NETLINK_DROP_MEMBERSHIP = 2
122 NETLINK_PKTINFO = 3
123 NETLINK_BROADCAST_ERROR = 4
124 NETLINK_NO_ENOBUFS = 5
125 NETLINK_LISTEN_ALL_NSID = 8
126 NETLINK_LIST_MEMBERSHIPS = 9
127 NETLINK_CAP_ACK = 10
128 NETLINK_EXT_ACK = 11
129 NETLINK_DUMP_STRICT_CHK = 12
130 )
131
132 // NetlinkErrorMessage is struct nlmsgerr, from uapi/linux/netlink.h.
133 //
134 // +marshal
135 type NetlinkErrorMessage struct {
136 Error int32
137 Header NetlinkMessageHeader
138 }