nl-linux 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,389 @@
1
+ # SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2
+ #--
3
+ # frozen_string_literal: true
4
+ # rbs_inline: enabled
5
+ # This code is generated by Ynl::Generator. DO NOT EDIT.
6
+ require 'nl'
7
+ # OVS vport configuration over generic netlink.
8
+ class Nl::Linux::OvsVport < ::Nl::Family
9
+ NAME = "ovs_vport"
10
+ PROTOCOL = Ractor.make_shareable(::Nl::Protocols::Genl.new("ovs_vport"))
11
+ module Structs
12
+ OvsHeader = Struct.new(
13
+ :"dp_ifindex", #: ::Integer
14
+ )
15
+ class OvsHeader
16
+ # :nodoc:
17
+ MEMBERS = Ractor.make_shareable({dp_ifindex: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)}) #: Hash[::Symbol, ::Nl::_DataType]
18
+ # Decodes the struct.
19
+ #--
20
+ # @rbs decoder: ::Nl::Decoder
21
+ # @rbs return: instance
22
+ def self.decode(decoder)
23
+ self.new(*MEMBERS.map {|name, datatype| datatype.decode(decoder) })
24
+ end
25
+ # Encodes the struct.
26
+ #--
27
+ # @rbs encoder: ::Nl::Encoder
28
+ # @rbs return: void
29
+ def encode(encoder)
30
+ MEMBERS.each {|name, datatype| datatype.encode(encoder, self.public_send(name)) }
31
+ end
32
+ end
33
+ OvsVportStats = Struct.new(
34
+ :"rx_packets", #: ::Integer
35
+ :"tx_packets", #: ::Integer
36
+ :"rx_bytes", #: ::Integer
37
+ :"tx_bytes", #: ::Integer
38
+ :"rx_errors", #: ::Integer
39
+ :"tx_errors", #: ::Integer
40
+ :"rx_dropped", #: ::Integer
41
+ :"tx_dropped", #: ::Integer
42
+ )
43
+ class OvsVportStats
44
+ # :nodoc:
45
+ MEMBERS = Ractor.make_shareable({rx_packets: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil), tx_packets: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil), rx_bytes: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil), tx_bytes: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil), rx_errors: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil), tx_errors: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil), rx_dropped: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil), tx_dropped: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)}) #: Hash[::Symbol, ::Nl::_DataType]
46
+ # Decodes the struct.
47
+ #--
48
+ # @rbs decoder: ::Nl::Decoder
49
+ # @rbs return: instance
50
+ def self.decode(decoder)
51
+ self.new(*MEMBERS.map {|name, datatype| datatype.decode(decoder) })
52
+ end
53
+ # Encodes the struct.
54
+ #--
55
+ # @rbs encoder: ::Nl::Encoder
56
+ # @rbs return: void
57
+ def encode(encoder)
58
+ MEMBERS.each {|name, datatype| datatype.encode(encoder, self.public_send(name)) }
59
+ end
60
+ end
61
+ end
62
+ module AttributeSets
63
+ class VportOptions < ::Nl::Protocols::Genl::AttributeSet
64
+ # Abstract class
65
+ class Attribute < ::Nl::Protocols::Genl::AttributeSet::Attribute
66
+ end
67
+ class DstPort < Attribute
68
+ TYPE = 1
69
+ NAME = :"dst_port"
70
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
71
+ end
72
+ class Extension < Attribute
73
+ TYPE = 2
74
+ NAME = :"extension"
75
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
76
+ end
77
+ # :nodoc:
78
+ BY_NAME = Ractor.make_shareable({:"dst_port" => DstPort, :"extension" => Extension}) #: Hash[::Symbol, Attribute]
79
+ # :nodoc:
80
+ BY_TYPE = Ractor.make_shareable({1 => DstPort, 2 => Extension}) #: Hash[::Integer, Attribute]
81
+ class << self
82
+ # Looks up Attribute class by name.
83
+ #--
84
+ # @rbs name: Symbol
85
+ # @rbs return: Attribute
86
+ def by_name(name); BY_NAME.fetch(name); end
87
+ # Looks up Attribute class by type value.
88
+ #--
89
+ # @rbs type: Integer
90
+ # @rbs return: Attribute
91
+ def by_type(type); BY_TYPE.fetch(type); end
92
+ end
93
+ end
94
+ class UpcallStats < ::Nl::Protocols::Genl::AttributeSet
95
+ # Abstract class
96
+ class Attribute < ::Nl::Protocols::Genl::AttributeSet::Attribute
97
+ end
98
+ class Success < Attribute
99
+ TYPE = 0
100
+ NAME = :"success"
101
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)
102
+ end
103
+ class Fail < Attribute
104
+ TYPE = 1
105
+ NAME = :"fail"
106
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)
107
+ end
108
+ # :nodoc:
109
+ BY_NAME = Ractor.make_shareable({:"success" => Success, :"fail" => Fail}) #: Hash[::Symbol, Attribute]
110
+ # :nodoc:
111
+ BY_TYPE = Ractor.make_shareable({0 => Success, 1 => Fail}) #: Hash[::Integer, Attribute]
112
+ class << self
113
+ # Looks up Attribute class by name.
114
+ #--
115
+ # @rbs name: Symbol
116
+ # @rbs return: Attribute
117
+ def by_name(name); BY_NAME.fetch(name); end
118
+ # Looks up Attribute class by type value.
119
+ #--
120
+ # @rbs type: Integer
121
+ # @rbs return: Attribute
122
+ def by_type(type); BY_TYPE.fetch(type); end
123
+ end
124
+ end
125
+ class Vport < ::Nl::Protocols::Genl::AttributeSet
126
+ # Abstract class
127
+ class Attribute < ::Nl::Protocols::Genl::AttributeSet::Attribute
128
+ end
129
+ class PortNo < Attribute
130
+ TYPE = 1
131
+ NAME = :"port_no"
132
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
133
+ end
134
+ class Type < Attribute
135
+ TYPE = 2
136
+ NAME = :"type"
137
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
138
+ end
139
+ class Name < Attribute
140
+ TYPE = 3
141
+ NAME = :"name"
142
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::String.new(check: nil)
143
+ end
144
+ class Options < Attribute
145
+ TYPE = 4
146
+ NAME = :"options"
147
+ end
148
+ class UpcallPid < Attribute
149
+ TYPE = 5
150
+ NAME = :"upcall_pid"
151
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Binary.new(check: nil)
152
+ end
153
+ class Stats < Attribute
154
+ TYPE = 6
155
+ NAME = :"stats"
156
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Binary.new(check: nil)
157
+ end
158
+ class Ifindex < Attribute
159
+ TYPE = 7
160
+ NAME = :"ifindex"
161
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
162
+ end
163
+ class Netnsid < Attribute
164
+ TYPE = 8
165
+ NAME = :"netnsid"
166
+ DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
167
+ end
168
+ class UpcallStats < Attribute
169
+ TYPE = 9
170
+ NAME = :"upcall_stats"
171
+ end
172
+ # :nodoc:
173
+ BY_NAME = Ractor.make_shareable({:"port_no" => PortNo, :"type" => Type, :"name" => Name, :"options" => Options, :"upcall_pid" => UpcallPid, :"stats" => Stats, :"ifindex" => Ifindex, :"netnsid" => Netnsid, :"upcall_stats" => UpcallStats}) #: Hash[::Symbol, Attribute]
174
+ # :nodoc:
175
+ BY_TYPE = Ractor.make_shareable({1 => PortNo, 2 => Type, 3 => Name, 4 => Options, 5 => UpcallPid, 6 => Stats, 7 => Ifindex, 8 => Netnsid, 9 => UpcallStats}) #: Hash[::Integer, Attribute]
176
+ class << self
177
+ # Looks up Attribute class by name.
178
+ #--
179
+ # @rbs name: Symbol
180
+ # @rbs return: Attribute
181
+ def by_name(name); BY_NAME.fetch(name); end
182
+ # Looks up Attribute class by type value.
183
+ #--
184
+ # @rbs type: Integer
185
+ # @rbs return: Attribute
186
+ def by_type(type); BY_TYPE.fetch(type); end
187
+ end
188
+ end
189
+ Vport::Options::DATATYPE = ::Nl::Protocols::Genl::DataTypes::NestedAttributes.new(VportOptions)
190
+ Vport::UpcallStats::DATATYPE = ::Nl::Protocols::Genl::DataTypes::NestedAttributes.new(UpcallStats)
191
+ end
192
+ module Messages
193
+ # Create a new OVS vport
194
+ class DoNewRequest < ::Nl::Protocols::Genl::Message
195
+ TYPE = 1
196
+ FIXED_HEADER = Structs::OvsHeader
197
+ ATTRIBUTE_SET = AttributeSets::Vport
198
+ ATTRIBUTES = Ractor.make_shareable(%i[type name options upcall_pid ifindex])
199
+ # Gets the value of `dp-ifindex` field in the message's fixed header.
200
+ #--
201
+ # @rbs return: ::Integer
202
+ def dp_ifindex; fixed_header.dp_ifindex; end
203
+ # Gets the value of `type` attribute in the message.
204
+ #--
205
+ # @rbs return: ::Integer
206
+ def type; attributes[:"type"]&.value; end
207
+ # Gets the value of `name` attribute in the message.
208
+ #--
209
+ # @rbs return: ::String
210
+ def name; attributes[:"name"]&.value; end
211
+ # Gets the value of `options` attribute in the message.
212
+ #--
213
+ # @rbs return: AttributeSets::VportOptions
214
+ def options; attributes[:"options"]&.value; end
215
+ # Gets the value of `upcall-pid` attribute in the message.
216
+ #--
217
+ # @rbs return: untyped
218
+ def upcall_pid; attributes[:"upcall_pid"]&.value; end
219
+ # Gets the value of `ifindex` attribute in the message.
220
+ #--
221
+ # @rbs return: ::Integer
222
+ def ifindex; attributes[:"ifindex"]&.value; end
223
+ end
224
+ # Delete existing OVS vport from a data path
225
+ class DoDelRequest < ::Nl::Protocols::Genl::Message
226
+ TYPE = 2
227
+ FIXED_HEADER = Structs::OvsHeader
228
+ ATTRIBUTE_SET = AttributeSets::Vport
229
+ ATTRIBUTES = Ractor.make_shareable(%i[port_no type name])
230
+ # Gets the value of `dp-ifindex` field in the message's fixed header.
231
+ #--
232
+ # @rbs return: ::Integer
233
+ def dp_ifindex; fixed_header.dp_ifindex; end
234
+ # Gets the value of `port-no` attribute in the message.
235
+ #--
236
+ # @rbs return: ::Integer
237
+ def port_no; attributes[:"port_no"]&.value; end
238
+ # Gets the value of `type` attribute in the message.
239
+ #--
240
+ # @rbs return: ::Integer
241
+ def type; attributes[:"type"]&.value; end
242
+ # Gets the value of `name` attribute in the message.
243
+ #--
244
+ # @rbs return: ::String
245
+ def name; attributes[:"name"]&.value; end
246
+ end
247
+ # Get / dump OVS vport configuration and state
248
+ class DoGetRequest < ::Nl::Protocols::Genl::Message
249
+ TYPE = 3
250
+ FIXED_HEADER = Structs::OvsHeader
251
+ ATTRIBUTE_SET = AttributeSets::Vport
252
+ ATTRIBUTES = Ractor.make_shareable(%i[name])
253
+ # Gets the value of `dp-ifindex` field in the message's fixed header.
254
+ #--
255
+ # @rbs return: ::Integer
256
+ def dp_ifindex; fixed_header.dp_ifindex; end
257
+ # Gets the value of `name` attribute in the message.
258
+ #--
259
+ # @rbs return: ::String
260
+ def name; attributes[:"name"]&.value; end
261
+ end
262
+ # Get / dump OVS vport configuration and state
263
+ class DoGetReply < ::Nl::Protocols::Genl::Message
264
+ TYPE = 3
265
+ FIXED_HEADER = Structs::OvsHeader
266
+ ATTRIBUTE_SET = AttributeSets::Vport
267
+ ATTRIBUTES = Ractor.make_shareable(%i[port_no type name upcall_pid stats ifindex netnsid upcall_stats])
268
+ # Gets the value of `dp-ifindex` field in the message's fixed header.
269
+ #--
270
+ # @rbs return: ::Integer
271
+ def dp_ifindex; fixed_header.dp_ifindex; end
272
+ # Gets the value of `port-no` attribute in the message.
273
+ #--
274
+ # @rbs return: ::Integer
275
+ def port_no; attributes[:"port_no"]&.value; end
276
+ # Gets the value of `type` attribute in the message.
277
+ #--
278
+ # @rbs return: ::Integer
279
+ def type; attributes[:"type"]&.value; end
280
+ # Gets the value of `name` attribute in the message.
281
+ #--
282
+ # @rbs return: ::String
283
+ def name; attributes[:"name"]&.value; end
284
+ # Gets the value of `upcall-pid` attribute in the message.
285
+ #--
286
+ # @rbs return: untyped
287
+ def upcall_pid; attributes[:"upcall_pid"]&.value; end
288
+ # Gets the value of `stats` attribute in the message.
289
+ #--
290
+ # @rbs return: untyped
291
+ def stats; attributes[:"stats"]&.value; end
292
+ # Gets the value of `ifindex` attribute in the message.
293
+ #--
294
+ # @rbs return: ::Integer
295
+ def ifindex; attributes[:"ifindex"]&.value; end
296
+ # Gets the value of `netnsid` attribute in the message.
297
+ #--
298
+ # @rbs return: ::Integer
299
+ def netnsid; attributes[:"netnsid"]&.value; end
300
+ # Gets the value of `upcall-stats` attribute in the message.
301
+ #--
302
+ # @rbs return: AttributeSets::UpcallStats
303
+ def upcall_stats; attributes[:"upcall_stats"]&.value; end
304
+ end
305
+ # Get / dump OVS vport configuration and state
306
+ class DumpGetRequest < ::Nl::Protocols::Genl::Message
307
+ TYPE = 3
308
+ FIXED_HEADER = Structs::OvsHeader
309
+ ATTRIBUTE_SET = AttributeSets::Vport
310
+ ATTRIBUTES = Ractor.make_shareable(%i[name])
311
+ # Gets the value of `dp-ifindex` field in the message's fixed header.
312
+ #--
313
+ # @rbs return: ::Integer
314
+ def dp_ifindex; fixed_header.dp_ifindex; end
315
+ # Gets the value of `name` attribute in the message.
316
+ #--
317
+ # @rbs return: ::String
318
+ def name; attributes[:"name"]&.value; end
319
+ end
320
+ # Get / dump OVS vport configuration and state
321
+ class DumpGetReply < ::Nl::Protocols::Genl::Message
322
+ TYPE = 3
323
+ FIXED_HEADER = Structs::OvsHeader
324
+ ATTRIBUTE_SET = AttributeSets::Vport
325
+ ATTRIBUTES = Ractor.make_shareable(%i[port_no type name upcall_pid stats ifindex netnsid upcall_stats])
326
+ # Gets the value of `dp-ifindex` field in the message's fixed header.
327
+ #--
328
+ # @rbs return: ::Integer
329
+ def dp_ifindex; fixed_header.dp_ifindex; end
330
+ # Gets the value of `port-no` attribute in the message.
331
+ #--
332
+ # @rbs return: ::Integer
333
+ def port_no; attributes[:"port_no"]&.value; end
334
+ # Gets the value of `type` attribute in the message.
335
+ #--
336
+ # @rbs return: ::Integer
337
+ def type; attributes[:"type"]&.value; end
338
+ # Gets the value of `name` attribute in the message.
339
+ #--
340
+ # @rbs return: ::String
341
+ def name; attributes[:"name"]&.value; end
342
+ # Gets the value of `upcall-pid` attribute in the message.
343
+ #--
344
+ # @rbs return: untyped
345
+ def upcall_pid; attributes[:"upcall_pid"]&.value; end
346
+ # Gets the value of `stats` attribute in the message.
347
+ #--
348
+ # @rbs return: untyped
349
+ def stats; attributes[:"stats"]&.value; end
350
+ # Gets the value of `ifindex` attribute in the message.
351
+ #--
352
+ # @rbs return: ::Integer
353
+ def ifindex; attributes[:"ifindex"]&.value; end
354
+ # Gets the value of `netnsid` attribute in the message.
355
+ #--
356
+ # @rbs return: ::Integer
357
+ def netnsid; attributes[:"netnsid"]&.value; end
358
+ # Gets the value of `upcall-stats` attribute in the message.
359
+ #--
360
+ # @rbs return: AttributeSets::UpcallStats
361
+ def upcall_stats; attributes[:"upcall_stats"]&.value; end
362
+ end
363
+ end
364
+ # Create a new OVS vport
365
+ #--
366
+ # @rbs (?dp_ifindex: ::Integer, ?type: ::Integer, ?name: ::String, ?options: AttributeSets::VportOptions, ?upcall_pid: untyped, ?ifindex: ::Integer) -> void
367
+ def do_new(**args)
368
+ exchange_message(:"do", Messages::DoNewRequest, nil, args)
369
+ end
370
+ # Delete existing OVS vport from a data path
371
+ #--
372
+ # @rbs (?dp_ifindex: ::Integer, ?port_no: ::Integer, ?type: ::Integer, ?name: ::String) -> void
373
+ def do_del(**args)
374
+ exchange_message(:"do", Messages::DoDelRequest, nil, args)
375
+ end
376
+ # Get / dump OVS vport configuration and state
377
+ #--
378
+ # @rbs (?dp_ifindex: ::Integer, ?name: ::String) -> Messages::DoGetReply
379
+ def do_get(**args)
380
+ exchange_message(:"do", Messages::DoGetRequest, Messages::DoGetReply, args)
381
+ end
382
+ # Get / dump OVS vport configuration and state
383
+ #--
384
+ # @rbs (?dp_ifindex: ::Integer, ?name: ::String) -> Enumerable[Messages::DumpGetReply]
385
+ # | (?dp_ifindex: ::Integer, ?name: ::String) { (Messages::DumpGetReply) -> void } -> void
386
+ def dump_get(**args, &block)
387
+ exchange_message(:"dump", Messages::DumpGetRequest, Messages::DumpGetReply, args, &block)
388
+ end
389
+ end