nl-linux 0.4.1 → 0.5.0

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/NLSPEC_VERSION +1 -1
  4. data/generated/nl/linux/binder.rb +103 -187
  5. data/generated/nl/linux/conntrack.rb +1053 -1649
  6. data/generated/nl/linux/dev_energymodel.rb +303 -265
  7. data/generated/nl/linux/devlink.rb +4904 -5576
  8. data/generated/nl/linux/dpll.rb +1097 -1467
  9. data/generated/nl/linux/drm_ras.rb +235 -195
  10. data/generated/nl/linux/ethtool.rb +6652 -7415
  11. data/generated/nl/linux/fou.rb +234 -255
  12. data/generated/nl/linux/handshake.rb +208 -280
  13. data/generated/nl/linux/lockd.rb +99 -73
  14. data/generated/nl/linux/mptcp_pm.rb +589 -687
  15. data/generated/nl/linux/net_shaper.rb +520 -615
  16. data/generated/nl/linux/netdev.rb +1640 -1987
  17. data/generated/nl/linux/nfsd.rb +1341 -1215
  18. data/generated/nl/linux/nftables.rb +5143 -4870
  19. data/generated/nl/linux/nl80211.rb +2542 -6316
  20. data/generated/nl/linux/nlctrl.rb +338 -483
  21. data/generated/nl/linux/ovpn.rb +1006 -1522
  22. data/generated/nl/linux/ovs_datapath.rb +291 -186
  23. data/generated/nl/linux/ovs_flow.rb +1393 -2065
  24. data/generated/nl/linux/ovs_packet.rb +186 -223
  25. data/generated/nl/linux/ovs_vport.rb +328 -285
  26. data/generated/nl/linux/psp.rb +812 -717
  27. data/generated/nl/linux/rt_addr.rb +513 -243
  28. data/generated/nl/linux/rt_link.rb +4504 -7238
  29. data/generated/nl/linux/rt_neigh.rb +935 -847
  30. data/generated/nl/linux/rt_route.rb +1198 -871
  31. data/generated/nl/linux/rt_rule.rb +680 -659
  32. data/generated/nl/linux/sunrpc_cache.rb +323 -321
  33. data/generated/nl/linux/tc.rb +9058 -10454
  34. data/generated/nl/linux/tcp_metrics.rb +258 -367
  35. data/generated/nl/linux/team.rb +327 -345
  36. data/generated/nl/linux/wireguard.rb +270 -434
  37. data/lib/nl/linux/nlctrl_resolver.rb +1 -1
  38. data/lib/nl/linux/version.rb +1 -1
  39. data/linux/conntrack.yaml +18 -3
  40. data/linux/devlink.yaml +26 -4
  41. data/linux/dpll.yaml +19 -0
  42. data/linux/netdev.yaml +21 -0
  43. data/linux/nfsd.yaml +111 -0
  44. data/linux/nl80211.yaml +2 -2
  45. data/linux/rt-addr.yaml +4 -0
  46. data/linux/rt-link.yaml +7 -0
  47. data/linux/rt-neigh.yaml +3 -0
  48. data/linux/rt-route.yaml +83 -2
  49. data/sig/generated/nl/linux/binder.rbs +77 -220
  50. data/sig/generated/nl/linux/conntrack.rbs +770 -1954
  51. data/sig/generated/nl/linux/dev_energymodel.rbs +207 -291
  52. data/sig/generated/nl/linux/devlink.rbs +3318 -6068
  53. data/sig/generated/nl/linux/dpll.rbs +791 -1589
  54. data/sig/generated/nl/linux/drm_ras.rbs +160 -208
  55. data/sig/generated/nl/linux/ethtool.rbs +4205 -7581
  56. data/sig/generated/nl/linux/fou.rbs +139 -254
  57. data/sig/generated/nl/linux/handshake.rbs +144 -319
  58. data/sig/generated/nl/linux/lockd.rbs +64 -74
  59. data/sig/generated/nl/linux/mptcp_pm.rbs +426 -835
  60. data/sig/generated/nl/linux/net_shaper.rbs +351 -644
  61. data/sig/generated/nl/linux/netdev.rbs +1151 -2146
  62. data/sig/generated/nl/linux/nfsd.rbs +1047 -1409
  63. data/sig/generated/nl/linux/nftables.rbs +2907 -5030
  64. data/sig/generated/nl/linux/nl80211.rbs +1807 -7964
  65. data/sig/generated/nl/linux/nlctrl.rbs +220 -544
  66. data/sig/generated/nl/linux/ovpn.rbs +835 -1859
  67. data/sig/generated/nl/linux/ovs_datapath.rbs +141 -181
  68. data/sig/generated/nl/linux/ovs_flow.rbs +817 -2332
  69. data/sig/generated/nl/linux/ovs_packet.rbs +110 -237
  70. data/sig/generated/nl/linux/ovs_vport.rbs +174 -294
  71. data/sig/generated/nl/linux/psp.rbs +550 -741
  72. data/sig/generated/nl/linux/rt_addr.rbs +188 -226
  73. data/sig/generated/nl/linux/rt_link.rbs +2687 -8370
  74. data/sig/generated/nl/linux/rt_neigh.rbs +471 -1005
  75. data/sig/generated/nl/linux/rt_route.rbs +632 -862
  76. data/sig/generated/nl/linux/rt_rule.rbs +217 -639
  77. data/sig/generated/nl/linux/sunrpc_cache.rbs +233 -369
  78. data/sig/generated/nl/linux/tc.rbs +6199 -13391
  79. data/sig/generated/nl/linux/tcp_metrics.rbs +179 -421
  80. data/sig/generated/nl/linux/team.rbs +232 -391
  81. data/sig/generated/nl/linux/wireguard.rbs +197 -502
  82. metadata +6 -6
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2
2
  #
3
- # This file is based on Documentation/netlink/specs/wireguard.yaml from Linux v7.2.
3
+ # This file is based on Documentation/netlink/specs/wireguard.yaml from Linux v7.3.
4
4
  #--
5
5
  # frozen_string_literal: true
6
6
  # This code is generated by Ynl::Generator. DO NOT EDIT.
@@ -34,7 +34,7 @@ class Wireguard < ::Nl::Genl::Family
34
34
  super
35
35
  end
36
36
  # @private
37
- MCAST_GROUPS = Ractor.make_shareable({}) #: Hash[::Symbol, ::Nl::McastGroup]
37
+ MCAST_GROUPS = {}.freeze #: Hash[::Symbol, ::Nl::McastGroup]
38
38
  module Constants
39
39
  WG_KEY_LEN = 32
40
40
  end
@@ -64,14 +64,27 @@ class Wireguard < ::Nl::Genl::Family
64
64
  # Number of nanoseconds, after the second began.
65
65
  # @return [Integer]
66
66
  # @private
67
- MEMBERS = Ractor.make_shareable({sec: ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil), nsec: ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)}) #: Hash[::Symbol, ::Nl::_DataType]
67
+ MEMBERS = {sec: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U64].new, nsec: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U64].new}.freeze #: Hash[::Symbol, ::Nl::_DataType]
68
+ Ractor.make_shareable(MEMBERS) if defined?(Ractor)
69
+ # @private
70
+ # @rbs (Hash[Symbol, untyped] params, ?context: untyped) -> instance
71
+ def self.from_params(params, context: nil)
72
+ unknown = params.keys - members
73
+ raise ArgumentError, "unknown struct members: #{unknown.join(', ')}" unless unknown.empty?
74
+ self.new(
75
+ MEMBERS[:"sec"].coerce(params.fetch(:"sec", 0), context:),
76
+ MEMBERS[:"nsec"].coerce(params.fetch(:"nsec", 0), context:),
77
+ )
78
+ end
68
79
  # Decodes the struct.
69
80
  # @rbs decoder: ::Nl::Decoder
70
81
  # @rbs return: instance
71
82
  # @param [Nl::Decoder] decoder
72
83
  # @return [self]
73
84
  def self.decode(decoder)
74
- self.new(*MEMBERS.map {|name, datatype| datatype.decode(decoder) })
85
+ value_0 = decoder.get_host_u64
86
+ value_1 = decoder.get_host_u64
87
+ self.new(value_0, value_1)
75
88
  end
76
89
  # Encodes the struct.
77
90
  # @rbs encoder: ::Nl::Encoder
@@ -79,412 +92,196 @@ class Wireguard < ::Nl::Genl::Family
79
92
  # @param [Nl::Encoder] encoder
80
93
  # @return [void]
81
94
  def encode(encoder)
82
- MEMBERS.each {|name, datatype| datatype.encode(encoder, self.public_send(name)) }
95
+ MEMBERS[:"sec"].encode(encoder, public_send(:"sec"))
96
+ MEMBERS[:"nsec"].encode(encoder, public_send(:"nsec"))
83
97
  end
84
98
  end
85
99
  end
86
100
  module AttributeSets
87
101
  class Wgdevice < ::Nl::AttributeSet
88
- # Abstract class
89
- class Attribute < ::Nl::AttributeSet::Attribute
90
- end
91
- class Ifindex < Attribute
92
- TYPE = 1
93
- NAME = :"ifindex"
94
- # @private
95
- ORDER = 0
96
- # @private
97
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
98
- end
99
- class Ifname < Attribute
100
- TYPE = 2
101
- NAME = :"ifname"
102
- # @private
103
- ORDER = 1
104
- # @private
105
- DATATYPE = ::Nl::DataTypes::String.new(check: -> { raise ArgumentError, "Value #{it.inspect} is longer than maximum length 15" unless it.bytesize <= 15 })
106
- end
107
- # Set to all zeros to remove.
108
- class PrivateKey < Attribute
109
- TYPE = 3
110
- NAME = :"private_key"
111
- # @private
112
- ORDER = 2
113
- # @private
114
- DATATYPE = ::Nl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length #{Constants::WG_KEY_LEN}" unless it.bytesize == Constants::WG_KEY_LEN })
115
- end
116
- class PublicKey < Attribute
117
- TYPE = 4
118
- NAME = :"public_key"
119
- # @private
120
- ORDER = 3
121
- # @private
122
- DATATYPE = ::Nl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length #{Constants::WG_KEY_LEN}" unless it.bytesize == Constants::WG_KEY_LEN })
123
- end
124
- # ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers should be
125
- # removed prior to adding the list below.
126
- #
127
- #
128
- # Known flags are defined in {Flags::WgdeviceFlags}.
129
- class Flags < Attribute
130
- TYPE = 5
131
- NAME = :"flags"
132
- # @private
133
- ORDER = 4
134
- # @private
135
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
136
- end
137
- # Set as ``0`` to choose randomly.
138
- class ListenPort < Attribute
139
- TYPE = 6
140
- NAME = :"listen_port"
141
- # @private
142
- ORDER = 5
143
- # @private
144
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U16, check: nil)
102
+ module Definitions
103
+ # @rbs return: ::Integer
104
+ # @return [Integer]
105
+ def ifindex; self[:"ifindex"]; end
106
+ # @rbs return: ::String
107
+ # @return [String]
108
+ def ifname; self[:"ifname"]; end
109
+ # Set to all zeros to remove.
110
+ # @rbs return: ::String
111
+ # @return [String]
112
+ def private_key; self[:"private_key"]; end
113
+ # @rbs return: ::String
114
+ # @return [String]
115
+ def public_key; self[:"public_key"]; end
116
+ # ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers should be
117
+ # removed prior to adding the list below.
118
+ #
119
+ #
120
+ # Known flags are defined in {Flags::WgdeviceFlags}.
121
+ # @rbs return: ::Integer
122
+ # @return [Integer]
123
+ def flags; self[:"flags"]; end
124
+ # Set as ``0`` to choose randomly.
125
+ # @rbs return: ::Integer
126
+ # @return [Integer]
127
+ def listen_port; self[:"listen_port"]; end
128
+ # Set as ``0`` to disable.
129
+ # @rbs return: ::Integer
130
+ # @return [Integer]
131
+ def fwmark; self[:"fwmark"]; end
132
+ # The index/type parameter is unused on ``SET_DEVICE`` operations and is
133
+ # zero on ``GET_DEVICE`` operations.
134
+ # @rbs return: ::Array[AttributeSets::Wgpeer]
135
+ # @return [Array<AttributeSets::Wgpeer>]
136
+ def peers; self[:"peers"]; end
145
137
  end
146
- # Set as ``0`` to disable.
147
- class Fwmark < Attribute
148
- TYPE = 7
149
- NAME = :"fwmark"
150
- # @private
151
- ORDER = 6
152
- # @private
153
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
154
- end
155
- # The index/type parameter is unused on ``SET_DEVICE`` operations and is
156
- # zero on ``GET_DEVICE`` operations.
157
- class Peers < Attribute
158
- TYPE = 8
159
- NAME = :"peers"
160
- # @private
161
- ORDER = 7
162
- end
163
- # @private
164
- BY_NAME = Ractor.make_shareable({:"ifindex" => Ifindex, :"ifname" => Ifname, :"private_key" => PrivateKey, :"public_key" => PublicKey, :"flags" => Flags, :"listen_port" => ListenPort, :"fwmark" => Fwmark, :"peers" => Peers}) #: Hash[::Symbol, Attribute]
165
- # @private
166
- BY_TYPE = Ractor.make_shareable({1 => Ifindex, 2 => Ifname, 3 => PrivateKey, 4 => PublicKey, 5 => Flags, 6 => ListenPort, 7 => Fwmark, 8 => Peers}) #: Hash[::Integer, Attribute]
167
- # @rbs return: ::Integer
168
- # @return [Integer]
169
- # @see Ifindex
170
- def ifindex; self[:"ifindex"]&.value; end
171
- # @rbs return: ::String
172
- # @return [String]
173
- # @see Ifname
174
- def ifname; self[:"ifname"]&.value; end
175
- # Set to all zeros to remove.
176
- # @rbs return: ::String
177
- # @return [String]
178
- # @see PrivateKey
179
- def private_key; self[:"private_key"]&.value; end
180
- # @rbs return: ::String
181
- # @return [String]
182
- # @see PublicKey
183
- def public_key; self[:"public_key"]&.value; end
184
- # ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers should be
185
- # removed prior to adding the list below.
186
- #
187
- #
188
- # Known flags are defined in {Flags::WgdeviceFlags}.
189
- # @rbs return: ::Integer
190
- # @return [Integer]
191
- # @see Flags
192
- def flags; self[:"flags"]&.value; end
193
- # Set as ``0`` to choose randomly.
194
- # @rbs return: ::Integer
195
- # @return [Integer]
196
- # @see ListenPort
197
- def listen_port; self[:"listen_port"]&.value; end
198
- # Set as ``0`` to disable.
199
- # @rbs return: ::Integer
200
- # @return [Integer]
201
- # @see Fwmark
202
- def fwmark; self[:"fwmark"]&.value; end
203
- # The index/type parameter is unused on ``SET_DEVICE`` operations and is
204
- # zero on ``GET_DEVICE`` operations.
205
- # @rbs return: ::Array[AttributeSets::Wgpeer]
206
- # @return [Array<AttributeSets::Wgpeer>]
207
- # @see Peers
208
- def peers; self[:"peers"]&.value; end
209
- class << self
210
- # Looks up Attribute class by name.
211
- # @rbs name: Symbol
212
- # @rbs return: Attribute
213
- # @param [Symbol] name
214
- # @return [Attribute]
215
- def by_name(name); BY_NAME.fetch(name); end
216
- # Looks up Attribute class by type value.
217
- # @rbs type: Integer
218
- # @rbs return: Attribute
219
- # @param [Integer] type
220
- # @return [Attribute]
221
- def by_type(type); BY_TYPE.fetch(type); end
138
+ include Definitions
139
+ # Decodes attributes from the decoder into a new attribute set.
140
+ # @rbs (::Nl::Decoder decoder, ?external_selectors: ::Array[untyped]) -> instance
141
+ def self.decode(decoder, external_selectors: ::Nl::Selector::EMPTY_VALUES)
142
+ super(decoder, BY_TYPE, 0, external_selectors)
222
143
  end
223
144
  end
224
145
  class Wgpeer < ::Nl::AttributeSet
225
- # Abstract class
226
- class Attribute < ::Nl::AttributeSet::Attribute
227
- end
228
- class PublicKey < Attribute
229
- TYPE = 1
230
- NAME = :"public_key"
231
- # @private
232
- ORDER = 0
233
- # @private
234
- DATATYPE = ::Nl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length #{Constants::WG_KEY_LEN}" unless it.bytesize == Constants::WG_KEY_LEN })
235
- end
236
- # Set as all zeros to remove.
237
- class PresharedKey < Attribute
238
- TYPE = 2
239
- NAME = :"preshared_key"
240
- # @private
241
- ORDER = 1
242
- # @private
243
- DATATYPE = ::Nl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length #{Constants::WG_KEY_LEN}" unless it.bytesize == Constants::WG_KEY_LEN })
244
- end
245
- # ``0`` and/or ``WGPEER_F_REMOVE_ME`` if the specified peer should not
246
- # exist at the end of the operation, rather than added/updated and/or
247
- # ``WGPEER_F_REPLACE_ALLOWEDIPS`` if all current allowed IPs of this
248
- # peer should be removed prior to adding the list below and/or
249
- # ``WGPEER_F_UPDATE_ONLY`` if the peer should only be set if it already
250
- # exists.
251
- #
252
- #
253
- # Known flags are defined in {Flags::WgpeerFlags}.
254
- class Flags < Attribute
255
- TYPE = 3
256
- NAME = :"flags"
257
- # @private
258
- ORDER = 2
259
- # @private
260
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
261
- end
262
- # struct sockaddr_in or struct sockaddr_in6
263
- class Endpoint < Attribute
264
- TYPE = 4
265
- NAME = :"endpoint"
266
- # @private
267
- ORDER = 3
268
- # @private
269
- DATATYPE = ::Nl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is shorter than minimum length 16" unless it.bytesize >= 16 })
270
- end
271
- # Set as ``0`` to disable.
272
- class PersistentKeepaliveInterval < Attribute
273
- TYPE = 5
274
- NAME = :"persistent_keepalive_interval"
275
- # @private
276
- ORDER = 4
277
- # @private
278
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U16, check: nil)
279
- end
280
- class LastHandshakeTime < Attribute
281
- TYPE = 6
282
- NAME = :"last_handshake_time"
283
- # @private
284
- ORDER = 5
285
- # @private
286
- DATATYPE = ::Nl::DataTypes::Struct.new(Structs::KernelTimespec, check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length 16" unless it.bytesize == 16 }, consume_remaining: true)
146
+ module Definitions
147
+ # @rbs return: ::String
148
+ # @return [String]
149
+ def public_key; self[:"public_key"]; end
150
+ # Set as all zeros to remove.
151
+ # @rbs return: ::String
152
+ # @return [String]
153
+ def preshared_key; self[:"preshared_key"]; end
154
+ # ``0`` and/or ``WGPEER_F_REMOVE_ME`` if the specified peer should not
155
+ # exist at the end of the operation, rather than added/updated and/or
156
+ # ``WGPEER_F_REPLACE_ALLOWEDIPS`` if all current allowed IPs of this
157
+ # peer should be removed prior to adding the list below and/or
158
+ # ``WGPEER_F_UPDATE_ONLY`` if the peer should only be set if it already
159
+ # exists.
160
+ #
161
+ #
162
+ # Known flags are defined in {Flags::WgpeerFlags}.
163
+ # @rbs return: ::Integer
164
+ # @return [Integer]
165
+ def flags; self[:"flags"]; end
166
+ # struct sockaddr_in or struct sockaddr_in6
167
+ # @rbs return: ::String
168
+ # @return [String]
169
+ def endpoint; self[:"endpoint"]; end
170
+ # Set as ``0`` to disable.
171
+ # @rbs return: ::Integer
172
+ # @return [Integer]
173
+ def persistent_keepalive_interval; self[:"persistent_keepalive_interval"]; end
174
+ # @rbs return: Structs::KernelTimespec
175
+ # @return [Structs::KernelTimespec]
176
+ def last_handshake_time; self[:"last_handshake_time"]; end
177
+ # @rbs return: ::Integer
178
+ # @return [Integer]
179
+ def rx_bytes; self[:"rx_bytes"]; end
180
+ # @rbs return: ::Integer
181
+ # @return [Integer]
182
+ def tx_bytes; self[:"tx_bytes"]; end
183
+ # The index/type parameter is unused on ``SET_DEVICE`` operations and is
184
+ # zero on ``GET_DEVICE`` operations.
185
+ # @rbs return: ::Array[AttributeSets::Wgallowedip]
186
+ # @return [Array<AttributeSets::Wgallowedip>]
187
+ def allowedips; self[:"allowedips"]; end
188
+ # Should not be set or used at all by most users of this API, as the
189
+ # most recent protocol will be used when this is unset. Otherwise,
190
+ # must be set to ``1``.
191
+ # @rbs return: ::Integer
192
+ # @return [Integer]
193
+ def protocol_version; self[:"protocol_version"]; end
287
194
  end
288
- class RxBytes < Attribute
289
- TYPE = 7
290
- NAME = :"rx_bytes"
291
- # @private
292
- ORDER = 6
293
- # @private
294
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)
295
- end
296
- class TxBytes < Attribute
297
- TYPE = 8
298
- NAME = :"tx_bytes"
299
- # @private
300
- ORDER = 7
301
- # @private
302
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)
303
- end
304
- # The index/type parameter is unused on ``SET_DEVICE`` operations and is
305
- # zero on ``GET_DEVICE`` operations.
306
- class Allowedips < Attribute
307
- TYPE = 9
308
- NAME = :"allowedips"
309
- # @private
310
- ORDER = 8
311
- end
312
- # Should not be set or used at all by most users of this API, as the
313
- # most recent protocol will be used when this is unset. Otherwise,
314
- # must be set to ``1``.
315
- class ProtocolVersion < Attribute
316
- TYPE = 10
317
- NAME = :"protocol_version"
318
- # @private
319
- ORDER = 9
320
- # @private
321
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
322
- end
323
- # @private
324
- BY_NAME = Ractor.make_shareable({:"public_key" => PublicKey, :"preshared_key" => PresharedKey, :"flags" => Flags, :"endpoint" => Endpoint, :"persistent_keepalive_interval" => PersistentKeepaliveInterval, :"last_handshake_time" => LastHandshakeTime, :"rx_bytes" => RxBytes, :"tx_bytes" => TxBytes, :"allowedips" => Allowedips, :"protocol_version" => ProtocolVersion}) #: Hash[::Symbol, Attribute]
325
- # @private
326
- BY_TYPE = Ractor.make_shareable({1 => PublicKey, 2 => PresharedKey, 3 => Flags, 4 => Endpoint, 5 => PersistentKeepaliveInterval, 6 => LastHandshakeTime, 7 => RxBytes, 8 => TxBytes, 9 => Allowedips, 10 => ProtocolVersion}) #: Hash[::Integer, Attribute]
327
- # @rbs return: ::String
328
- # @return [String]
329
- # @see PublicKey
330
- def public_key; self[:"public_key"]&.value; end
331
- # Set as all zeros to remove.
332
- # @rbs return: ::String
333
- # @return [String]
334
- # @see PresharedKey
335
- def preshared_key; self[:"preshared_key"]&.value; end
336
- # ``0`` and/or ``WGPEER_F_REMOVE_ME`` if the specified peer should not
337
- # exist at the end of the operation, rather than added/updated and/or
338
- # ``WGPEER_F_REPLACE_ALLOWEDIPS`` if all current allowed IPs of this
339
- # peer should be removed prior to adding the list below and/or
340
- # ``WGPEER_F_UPDATE_ONLY`` if the peer should only be set if it already
341
- # exists.
342
- #
343
- #
344
- # Known flags are defined in {Flags::WgpeerFlags}.
345
- # @rbs return: ::Integer
346
- # @return [Integer]
347
- # @see Flags
348
- def flags; self[:"flags"]&.value; end
349
- # struct sockaddr_in or struct sockaddr_in6
350
- # @rbs return: ::String
351
- # @return [String]
352
- # @see Endpoint
353
- def endpoint; self[:"endpoint"]&.value; end
354
- # Set as ``0`` to disable.
355
- # @rbs return: ::Integer
356
- # @return [Integer]
357
- # @see PersistentKeepaliveInterval
358
- def persistent_keepalive_interval; self[:"persistent_keepalive_interval"]&.value; end
359
- # @rbs return: Structs::KernelTimespec
360
- # @return [Structs::KernelTimespec]
361
- # @see LastHandshakeTime
362
- def last_handshake_time; self[:"last_handshake_time"]&.value; end
363
- # @rbs return: ::Integer
364
- # @return [Integer]
365
- # @see RxBytes
366
- def rx_bytes; self[:"rx_bytes"]&.value; end
367
- # @rbs return: ::Integer
368
- # @return [Integer]
369
- # @see TxBytes
370
- def tx_bytes; self[:"tx_bytes"]&.value; end
371
- # The index/type parameter is unused on ``SET_DEVICE`` operations and is
372
- # zero on ``GET_DEVICE`` operations.
373
- # @rbs return: ::Array[AttributeSets::Wgallowedip]
374
- # @return [Array<AttributeSets::Wgallowedip>]
375
- # @see Allowedips
376
- def allowedips; self[:"allowedips"]&.value; end
377
- # Should not be set or used at all by most users of this API, as the
378
- # most recent protocol will be used when this is unset. Otherwise,
379
- # must be set to ``1``.
380
- # @rbs return: ::Integer
381
- # @return [Integer]
382
- # @see ProtocolVersion
383
- def protocol_version; self[:"protocol_version"]&.value; end
384
- class << self
385
- # Looks up Attribute class by name.
386
- # @rbs name: Symbol
387
- # @rbs return: Attribute
388
- # @param [Symbol] name
389
- # @return [Attribute]
390
- def by_name(name); BY_NAME.fetch(name); end
391
- # Looks up Attribute class by type value.
392
- # @rbs type: Integer
393
- # @rbs return: Attribute
394
- # @param [Integer] type
395
- # @return [Attribute]
396
- def by_type(type); BY_TYPE.fetch(type); end
195
+ include Definitions
196
+ # Decodes attributes from the decoder into a new attribute set.
197
+ # @rbs (::Nl::Decoder decoder, ?external_selectors: ::Array[untyped]) -> instance
198
+ def self.decode(decoder, external_selectors: ::Nl::Selector::EMPTY_VALUES)
199
+ super(decoder, BY_TYPE, 0, external_selectors)
397
200
  end
398
201
  end
399
202
  class Wgallowedip < ::Nl::AttributeSet
400
- # Abstract class
401
- class Attribute < ::Nl::AttributeSet::Attribute
402
- end
403
- # IP family, either ``AF_INET`` or ``AF_INET6``.
404
- class Family < Attribute
405
- TYPE = 1
406
- NAME = :"family"
407
- # @private
408
- ORDER = 0
409
- # @private
410
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U16, check: nil)
203
+ module Definitions
204
+ # IP family, either ``AF_INET`` or ``AF_INET6``.
205
+ # @rbs return: ::Integer
206
+ # @return [Integer]
207
+ def family; self[:"family"]; end
208
+ # Either ``struct in_addr`` or ``struct in6_addr``.
209
+ # @rbs return: ::String
210
+ # @return [String]
211
+ def ipaddr; self[:"ipaddr"]; end
212
+ # @rbs return: ::Integer
213
+ # @return [Integer]
214
+ def cidr_mask; self[:"cidr_mask"]; end
215
+ # ``WGALLOWEDIP_F_REMOVE_ME`` if the specified IP should be removed;
216
+ # otherwise, this IP will be added if it is not already present.
217
+ #
218
+ #
219
+ # Known flags are defined in {Flags::WgallowedipFlags}.
220
+ # @rbs return: ::Integer
221
+ # @return [Integer]
222
+ def flags; self[:"flags"]; end
411
223
  end
412
- # Either ``struct in_addr`` or ``struct in6_addr``.
413
- class Ipaddr < Attribute
414
- TYPE = 2
415
- NAME = :"ipaddr"
416
- # @private
417
- ORDER = 1
418
- # @private
419
- DATATYPE = ::Nl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is shorter than minimum length 4" unless it.bytesize >= 4 })
224
+ include Definitions
225
+ # Decodes attributes from the decoder into a new attribute set.
226
+ # @rbs (::Nl::Decoder decoder, ?external_selectors: ::Array[untyped]) -> instance
227
+ def self.decode(decoder, external_selectors: ::Nl::Selector::EMPTY_VALUES)
228
+ super(decoder, BY_TYPE, 0, external_selectors)
420
229
  end
421
- class CidrMask < Attribute
422
- TYPE = 3
423
- NAME = :"cidr_mask"
424
- # @private
425
- ORDER = 2
426
- # @private
427
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U8, check: nil)
230
+ end
231
+ end
232
+ module AttributeSets
233
+ class Wgdevice
234
+ module Definitions
235
+ # @private
236
+ BY_TYPE = ::Array.new(9).tap do |definitions|
237
+ definitions[1] = ::Nl::AttributeSet::Definition.new(id: 1, name: :"ifindex", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U32].new, multi: false, order: 0, selector_slot: nil)
238
+ definitions[2] = ::Nl::AttributeSet::Definition.new(id: 2, name: :"ifname", datatype: ::Nl::DataTypes::Checked.new(::Nl::DataTypes::String.new, check: nil.instance_exec { -> { raise ArgumentError, "Value #{it.inspect} is longer than maximum length 15" unless it.bytesize <= 15 } }), multi: false, order: 1, selector_slot: nil)
239
+ definitions[3] = ::Nl::AttributeSet::Definition.new(id: 3, name: :"private_key", datatype: ::Nl::DataTypes::Checked.new(::Nl::DataTypes::Binary.new, check: nil.instance_exec { -> { raise ArgumentError, "Value #{it.inspect} is not equal to length #{Constants::WG_KEY_LEN}" unless it.bytesize == Constants::WG_KEY_LEN } }), multi: false, order: 2, selector_slot: nil)
240
+ definitions[4] = ::Nl::AttributeSet::Definition.new(id: 4, name: :"public_key", datatype: ::Nl::DataTypes::Checked.new(::Nl::DataTypes::Binary.new, check: nil.instance_exec { -> { raise ArgumentError, "Value #{it.inspect} is not equal to length #{Constants::WG_KEY_LEN}" unless it.bytesize == Constants::WG_KEY_LEN } }), multi: false, order: 3, selector_slot: nil)
241
+ definitions[5] = ::Nl::AttributeSet::Definition.new(id: 5, name: :"flags", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U32].new, multi: false, order: 4, selector_slot: nil)
242
+ definitions[6] = ::Nl::AttributeSet::Definition.new(id: 6, name: :"listen_port", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U16].new, multi: false, order: 5, selector_slot: nil)
243
+ definitions[7] = ::Nl::AttributeSet::Definition.new(id: 7, name: :"fwmark", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U32].new, multi: false, order: 6, selector_slot: nil)
244
+ definitions[8] = ::Nl::AttributeSet::Definition.new(id: 8, name: :"peers", datatype: ::Nl::DataTypes::IndexedArray.new(::Nl::DataTypes::NestedAttributes.new(AttributeSets::Wgpeer, selector_bindings: [])), multi: false, order: 7, selector_slot: nil)
245
+ end.freeze #: Array[::Nl::AttributeSet::Definition?]
246
+ Ractor.make_shareable(BY_TYPE) if defined?(Ractor)
247
+ # @private
248
+ BY_NAME = BY_TYPE.compact.to_h { [it.name, it] }.freeze #: Hash[::Symbol, ::Nl::AttributeSet::Definition]
428
249
  end
429
- # ``WGALLOWEDIP_F_REMOVE_ME`` if the specified IP should be removed;
430
- # otherwise, this IP will be added if it is not already present.
431
- #
432
- #
433
- # Known flags are defined in {Flags::WgallowedipFlags}.
434
- class Flags < Attribute
435
- TYPE = 4
436
- NAME = :"flags"
437
- # @private
438
- ORDER = 3
439
- # @private
440
- DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
250
+ end
251
+ class Wgpeer
252
+ module Definitions
253
+ # @private
254
+ BY_TYPE = ::Array.new(11).tap do |definitions|
255
+ definitions[1] = ::Nl::AttributeSet::Definition.new(id: 1, name: :"public_key", datatype: ::Nl::DataTypes::Checked.new(::Nl::DataTypes::Binary.new, check: nil.instance_exec { -> { raise ArgumentError, "Value #{it.inspect} is not equal to length #{Constants::WG_KEY_LEN}" unless it.bytesize == Constants::WG_KEY_LEN } }), multi: false, order: 0, selector_slot: nil)
256
+ definitions[2] = ::Nl::AttributeSet::Definition.new(id: 2, name: :"preshared_key", datatype: ::Nl::DataTypes::Checked.new(::Nl::DataTypes::Binary.new, check: nil.instance_exec { -> { raise ArgumentError, "Value #{it.inspect} is not equal to length #{Constants::WG_KEY_LEN}" unless it.bytesize == Constants::WG_KEY_LEN } }), multi: false, order: 1, selector_slot: nil)
257
+ definitions[3] = ::Nl::AttributeSet::Definition.new(id: 3, name: :"flags", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U32].new, multi: false, order: 2, selector_slot: nil)
258
+ definitions[4] = ::Nl::AttributeSet::Definition.new(id: 4, name: :"endpoint", datatype: ::Nl::DataTypes::Checked.new(::Nl::DataTypes::Binary.new, check: nil.instance_exec { -> { raise ArgumentError, "Value #{it.inspect} is shorter than minimum length 16" unless it.bytesize >= 16 } }), multi: false, order: 3, selector_slot: nil)
259
+ definitions[5] = ::Nl::AttributeSet::Definition.new(id: 5, name: :"persistent_keepalive_interval", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U16].new, multi: false, order: 4, selector_slot: nil)
260
+ definitions[6] = ::Nl::AttributeSet::Definition.new(id: 6, name: :"last_handshake_time", datatype: ::Nl::DataTypes::CheckedPayload.new(::Nl::DataTypes::Struct.new(Structs::KernelTimespec, consume_remaining: true), check: nil.instance_exec { -> { raise ArgumentError, "Value #{it.inspect} is not equal to length 16" unless it.bytesize == 16 } }), multi: false, order: 5, selector_slot: nil)
261
+ definitions[7] = ::Nl::AttributeSet::Definition.new(id: 7, name: :"rx_bytes", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U64].new, multi: false, order: 6, selector_slot: nil)
262
+ definitions[8] = ::Nl::AttributeSet::Definition.new(id: 8, name: :"tx_bytes", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U64].new, multi: false, order: 7, selector_slot: nil)
263
+ definitions[9] = ::Nl::AttributeSet::Definition.new(id: 9, name: :"allowedips", datatype: ::Nl::DataTypes::IndexedArray.new(::Nl::DataTypes::NestedAttributes.new(AttributeSets::Wgallowedip, selector_bindings: [])), multi: false, order: 8, selector_slot: nil)
264
+ definitions[10] = ::Nl::AttributeSet::Definition.new(id: 10, name: :"protocol_version", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U32].new, multi: false, order: 9, selector_slot: nil)
265
+ end.freeze #: Array[::Nl::AttributeSet::Definition?]
266
+ Ractor.make_shareable(BY_TYPE) if defined?(Ractor)
267
+ # @private
268
+ BY_NAME = BY_TYPE.compact.to_h { [it.name, it] }.freeze #: Hash[::Symbol, ::Nl::AttributeSet::Definition]
441
269
  end
442
- # @private
443
- BY_NAME = Ractor.make_shareable({:"family" => Family, :"ipaddr" => Ipaddr, :"cidr_mask" => CidrMask, :"flags" => Flags}) #: Hash[::Symbol, Attribute]
444
- # @private
445
- BY_TYPE = Ractor.make_shareable({1 => Family, 2 => Ipaddr, 3 => CidrMask, 4 => Flags}) #: Hash[::Integer, Attribute]
446
- # IP family, either ``AF_INET`` or ``AF_INET6``.
447
- # @rbs return: ::Integer
448
- # @return [Integer]
449
- # @see Family
450
- def family; self[:"family"]&.value; end
451
- # Either ``struct in_addr`` or ``struct in6_addr``.
452
- # @rbs return: ::String
453
- # @return [String]
454
- # @see Ipaddr
455
- def ipaddr; self[:"ipaddr"]&.value; end
456
- # @rbs return: ::Integer
457
- # @return [Integer]
458
- # @see CidrMask
459
- def cidr_mask; self[:"cidr_mask"]&.value; end
460
- # ``WGALLOWEDIP_F_REMOVE_ME`` if the specified IP should be removed;
461
- # otherwise, this IP will be added if it is not already present.
462
- #
463
- #
464
- # Known flags are defined in {Flags::WgallowedipFlags}.
465
- # @rbs return: ::Integer
466
- # @return [Integer]
467
- # @see Flags
468
- def flags; self[:"flags"]&.value; end
469
- class << self
470
- # Looks up Attribute class by name.
471
- # @rbs name: Symbol
472
- # @rbs return: Attribute
473
- # @param [Symbol] name
474
- # @return [Attribute]
475
- def by_name(name); BY_NAME.fetch(name); end
476
- # Looks up Attribute class by type value.
477
- # @rbs type: Integer
478
- # @rbs return: Attribute
479
- # @param [Integer] type
480
- # @return [Attribute]
481
- def by_type(type); BY_TYPE.fetch(type); end
270
+ end
271
+ class Wgallowedip
272
+ module Definitions
273
+ # @private
274
+ BY_TYPE = ::Array.new(5).tap do |definitions|
275
+ definitions[1] = ::Nl::AttributeSet::Definition.new(id: 1, name: :"family", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U16].new, multi: false, order: 0, selector_slot: nil)
276
+ definitions[2] = ::Nl::AttributeSet::Definition.new(id: 2, name: :"ipaddr", datatype: ::Nl::DataTypes::Checked.new(::Nl::DataTypes::Binary.new, check: nil.instance_exec { -> { raise ArgumentError, "Value #{it.inspect} is shorter than minimum length 4" unless it.bytesize >= 4 } }), multi: false, order: 1, selector_slot: nil)
277
+ definitions[3] = ::Nl::AttributeSet::Definition.new(id: 3, name: :"cidr_mask", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U8].new, multi: false, order: 2, selector_slot: nil)
278
+ definitions[4] = ::Nl::AttributeSet::Definition.new(id: 4, name: :"flags", datatype: ::Nl::DataTypes::Scalar[::Nl::Endian::Host::U32].new, multi: false, order: 3, selector_slot: nil)
279
+ end.freeze #: Array[::Nl::AttributeSet::Definition?]
280
+ Ractor.make_shareable(BY_TYPE) if defined?(Ractor)
281
+ # @private
282
+ BY_NAME = BY_TYPE.compact.to_h { [it.name, it] }.freeze #: Hash[::Symbol, ::Nl::AttributeSet::Definition]
482
283
  end
483
284
  end
484
- # @private
485
- Wgdevice::Peers::DATATYPE = ::Nl::DataTypes::IndexedArray.new(::Nl::DataTypes::NestedAttributes.new(AttributeSets::Wgpeer, selector_bindings: Ractor.make_shareable([])))
486
- # @private
487
- Wgpeer::Allowedips::DATATYPE = ::Nl::DataTypes::IndexedArray.new(::Nl::DataTypes::NestedAttributes.new(AttributeSets::Wgallowedip, selector_bindings: Ractor.make_shareable([])))
488
285
  end
489
286
  module Messages
490
287
  # Retrieve WireGuard device
@@ -514,19 +311,36 @@ class Wireguard < ::Nl::Genl::Family
514
311
  #
515
312
  #
516
313
  # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
517
- class DumpGetDeviceRequest < ::Nl::Genl::Message
314
+ class DumpGetDeviceRequest < ::Nl::Message
518
315
  TYPE = 0
519
316
  FIXED_HEADER = nil
520
317
  ATTRIBUTE_SET = AttributeSets::Wgdevice
521
- ATTRIBUTES = Ractor.make_shareable(%i[ifindex ifname])
318
+ ATTRIBUTES = %i[ifindex ifname].freeze
319
+ include ATTRIBUTE_SET::Definitions
320
+ def initialize(attributes = [])
321
+ @attributes = attributes
322
+ end
323
+ # @private
324
+ def self.build_instance(params, external_selectors: ::Nl::Selector::EMPTY_VALUES)
325
+ validate_params(params, ::Nl::Message::EMPTY_FIELD_NAMES, ATTRIBUTES)
326
+ new(
327
+ build_attributes(params.slice(*ATTRIBUTES), external_selectors:),
328
+ )
329
+ end
330
+ # Decodes a message payload from the decoder into a new instance.
331
+ # @rbs (::Nl::Decoder decoder) -> instance
332
+ def self.decode(decoder)
333
+ new(decode_attributes(decoder, BY_TYPE, 0))
334
+ end
335
+ def encode(encoder, external_selectors: ::Nl::Selector::EMPTY_VALUES)
336
+ encode_attributes(encoder, external_selectors:)
337
+ end
522
338
  # @rbs return: ::Integer
523
339
  # @return [Integer]
524
- # @see AttributeSets::Wgdevice::Ifindex
525
- def ifindex; attributes[:"ifindex"]&.value; end
340
+ def ifindex; self[:"ifindex"]; end
526
341
  # @rbs return: ::String
527
342
  # @return [String]
528
- # @see AttributeSets::Wgdevice::Ifname
529
- def ifname; attributes[:"ifname"]&.value; end
343
+ def ifname; self[:"ifname"]; end
530
344
  end
531
345
  # Retrieve WireGuard device
532
346
  # ~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -555,28 +369,43 @@ class Wireguard < ::Nl::Genl::Family
555
369
  #
556
370
  #
557
371
  # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
558
- class DumpGetDeviceReply < ::Nl::Genl::Message
372
+ class DumpGetDeviceReply < ::Nl::Message
559
373
  TYPE = 0
560
374
  FIXED_HEADER = nil
561
375
  ATTRIBUTE_SET = AttributeSets::Wgdevice
562
- ATTRIBUTES = Ractor.make_shareable(%i[ifindex ifname private_key public_key flags listen_port fwmark peers])
376
+ ATTRIBUTES = %i[ifindex ifname private_key public_key flags listen_port fwmark peers].freeze
377
+ include ATTRIBUTE_SET::Definitions
378
+ def initialize(attributes = [])
379
+ @attributes = attributes
380
+ end
381
+ # @private
382
+ def self.build_instance(params, external_selectors: ::Nl::Selector::EMPTY_VALUES)
383
+ validate_params(params, ::Nl::Message::EMPTY_FIELD_NAMES, ATTRIBUTES)
384
+ new(
385
+ build_attributes(params.slice(*ATTRIBUTES), external_selectors:),
386
+ )
387
+ end
388
+ # Decodes a message payload from the decoder into a new instance.
389
+ # @rbs (::Nl::Decoder decoder) -> instance
390
+ def self.decode(decoder)
391
+ new(decode_attributes(decoder, BY_TYPE, 0))
392
+ end
393
+ def encode(encoder, external_selectors: ::Nl::Selector::EMPTY_VALUES)
394
+ encode_attributes(encoder, external_selectors:)
395
+ end
563
396
  # @rbs return: ::Integer
564
397
  # @return [Integer]
565
- # @see AttributeSets::Wgdevice::Ifindex
566
- def ifindex; attributes[:"ifindex"]&.value; end
398
+ def ifindex; self[:"ifindex"]; end
567
399
  # @rbs return: ::String
568
400
  # @return [String]
569
- # @see AttributeSets::Wgdevice::Ifname
570
- def ifname; attributes[:"ifname"]&.value; end
401
+ def ifname; self[:"ifname"]; end
571
402
  # Set to all zeros to remove.
572
403
  # @rbs return: ::String
573
404
  # @return [String]
574
- # @see AttributeSets::Wgdevice::PrivateKey
575
- def private_key; attributes[:"private_key"]&.value; end
405
+ def private_key; self[:"private_key"]; end
576
406
  # @rbs return: ::String
577
407
  # @return [String]
578
- # @see AttributeSets::Wgdevice::PublicKey
579
- def public_key; attributes[:"public_key"]&.value; end
408
+ def public_key; self[:"public_key"]; end
580
409
  # ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers should be
581
410
  # removed prior to adding the list below.
582
411
  #
@@ -584,24 +413,20 @@ class Wireguard < ::Nl::Genl::Family
584
413
  # Known flags are defined in {Flags::WgdeviceFlags}.
585
414
  # @rbs return: ::Integer
586
415
  # @return [Integer]
587
- # @see AttributeSets::Wgdevice::Flags
588
- def flags; attributes[:"flags"]&.value; end
416
+ def flags; self[:"flags"]; end
589
417
  # Set as ``0`` to choose randomly.
590
418
  # @rbs return: ::Integer
591
419
  # @return [Integer]
592
- # @see AttributeSets::Wgdevice::ListenPort
593
- def listen_port; attributes[:"listen_port"]&.value; end
420
+ def listen_port; self[:"listen_port"]; end
594
421
  # Set as ``0`` to disable.
595
422
  # @rbs return: ::Integer
596
423
  # @return [Integer]
597
- # @see AttributeSets::Wgdevice::Fwmark
598
- def fwmark; attributes[:"fwmark"]&.value; end
424
+ def fwmark; self[:"fwmark"]; end
599
425
  # The index/type parameter is unused on ``SET_DEVICE`` operations and is
600
426
  # zero on ``GET_DEVICE`` operations.
601
427
  # @rbs return: ::Array[AttributeSets::Wgpeer]
602
428
  # @return [Array<AttributeSets::Wgpeer>]
603
- # @see AttributeSets::Wgdevice::Peers
604
- def peers; attributes[:"peers"]&.value; end
429
+ def peers; self[:"peers"]; end
605
430
  end
606
431
  # Set WireGuard device
607
432
  # ~~~~~~~~~~~~~~~~~~~~
@@ -624,28 +449,43 @@ class Wireguard < ::Nl::Genl::Family
624
449
  #
625
450
  #
626
451
  # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
627
- class DoSetDeviceRequest < ::Nl::Genl::Message
452
+ class DoSetDeviceRequest < ::Nl::Message
628
453
  TYPE = 1
629
454
  FIXED_HEADER = nil
630
455
  ATTRIBUTE_SET = AttributeSets::Wgdevice
631
- ATTRIBUTES = Ractor.make_shareable(%i[ifindex ifname private_key public_key flags listen_port fwmark peers])
456
+ ATTRIBUTES = %i[ifindex ifname private_key public_key flags listen_port fwmark peers].freeze
457
+ include ATTRIBUTE_SET::Definitions
458
+ def initialize(attributes = [])
459
+ @attributes = attributes
460
+ end
461
+ # @private
462
+ def self.build_instance(params, external_selectors: ::Nl::Selector::EMPTY_VALUES)
463
+ validate_params(params, ::Nl::Message::EMPTY_FIELD_NAMES, ATTRIBUTES)
464
+ new(
465
+ build_attributes(params.slice(*ATTRIBUTES), external_selectors:),
466
+ )
467
+ end
468
+ # Decodes a message payload from the decoder into a new instance.
469
+ # @rbs (::Nl::Decoder decoder) -> instance
470
+ def self.decode(decoder)
471
+ new(decode_attributes(decoder, BY_TYPE, 0))
472
+ end
473
+ def encode(encoder, external_selectors: ::Nl::Selector::EMPTY_VALUES)
474
+ encode_attributes(encoder, external_selectors:)
475
+ end
632
476
  # @rbs return: ::Integer
633
477
  # @return [Integer]
634
- # @see AttributeSets::Wgdevice::Ifindex
635
- def ifindex; attributes[:"ifindex"]&.value; end
478
+ def ifindex; self[:"ifindex"]; end
636
479
  # @rbs return: ::String
637
480
  # @return [String]
638
- # @see AttributeSets::Wgdevice::Ifname
639
- def ifname; attributes[:"ifname"]&.value; end
481
+ def ifname; self[:"ifname"]; end
640
482
  # Set to all zeros to remove.
641
483
  # @rbs return: ::String
642
484
  # @return [String]
643
- # @see AttributeSets::Wgdevice::PrivateKey
644
- def private_key; attributes[:"private_key"]&.value; end
485
+ def private_key; self[:"private_key"]; end
645
486
  # @rbs return: ::String
646
487
  # @return [String]
647
- # @see AttributeSets::Wgdevice::PublicKey
648
- def public_key; attributes[:"public_key"]&.value; end
488
+ def public_key; self[:"public_key"]; end
649
489
  # ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers should be
650
490
  # removed prior to adding the list below.
651
491
  #
@@ -653,30 +493,26 @@ class Wireguard < ::Nl::Genl::Family
653
493
  # Known flags are defined in {Flags::WgdeviceFlags}.
654
494
  # @rbs return: ::Integer
655
495
  # @return [Integer]
656
- # @see AttributeSets::Wgdevice::Flags
657
- def flags; attributes[:"flags"]&.value; end
496
+ def flags; self[:"flags"]; end
658
497
  # Set as ``0`` to choose randomly.
659
498
  # @rbs return: ::Integer
660
499
  # @return [Integer]
661
- # @see AttributeSets::Wgdevice::ListenPort
662
- def listen_port; attributes[:"listen_port"]&.value; end
500
+ def listen_port; self[:"listen_port"]; end
663
501
  # Set as ``0`` to disable.
664
502
  # @rbs return: ::Integer
665
503
  # @return [Integer]
666
- # @see AttributeSets::Wgdevice::Fwmark
667
- def fwmark; attributes[:"fwmark"]&.value; end
504
+ def fwmark; self[:"fwmark"]; end
668
505
  # The index/type parameter is unused on ``SET_DEVICE`` operations and is
669
506
  # zero on ``GET_DEVICE`` operations.
670
507
  # @rbs return: ::Array[AttributeSets::Wgpeer]
671
508
  # @return [Array<AttributeSets::Wgpeer>]
672
- # @see AttributeSets::Wgdevice::Peers
673
- def peers; attributes[:"peers"]&.value; end
509
+ def peers; self[:"peers"]; end
674
510
  end
675
511
  end
676
512
  module Notifications
677
513
  end
678
514
  # @private
679
- NOTIFICATIONS = Ractor.make_shareable({}) #: Hash[::Integer, ::Class]
515
+ NOTIFICATIONS = {}.freeze #: Hash[::Integer, ::Class]
680
516
  # Retrieve WireGuard device
681
517
  # ~~~~~~~~~~~~~~~~~~~~~~~~~
682
518
  #