nl-linux 0.2.4 → 0.4.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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -0
  3. data/.yardopts +5 -0
  4. data/CHANGELOG.md +8 -0
  5. data/Rakefile +27 -5
  6. data/generated/nl/linux/binder.rb +227 -19
  7. data/generated/nl/linux/conntrack.rb +1325 -365
  8. data/generated/nl/linux/dev_energymodel.rb +357 -66
  9. data/generated/nl/linux/devlink.rb +6310 -1859
  10. data/generated/nl/linux/dpll.rb +2202 -376
  11. data/generated/nl/linux/drm_ras.rb +312 -63
  12. data/generated/nl/linux/ethtool.rb +7555 -2447
  13. data/generated/nl/linux/fou.rb +381 -133
  14. data/generated/nl/linux/handshake.rb +340 -70
  15. data/generated/nl/linux/lockd.rb +132 -27
  16. data/generated/nl/linux/mptcp_pm.rb +773 -161
  17. data/generated/nl/linux/net_shaper.rb +892 -211
  18. data/generated/nl/linux/netdev.rb +2366 -518
  19. data/generated/nl/linux/nfsd.rb +1299 -317
  20. data/generated/nl/linux/nftables.rb +5351 -1533
  21. data/generated/nl/linux/nl80211.rb +4601 -882
  22. data/generated/nl/linux/nlctrl.rb +460 -117
  23. data/generated/nl/linux/ovpn.rb +1360 -262
  24. data/generated/nl/linux/ovs_datapath.rb +312 -98
  25. data/generated/nl/linux/ovs_flow.rb +1866 -358
  26. data/generated/nl/linux/ovs_packet.rb +331 -45
  27. data/generated/nl/linux/ovs_vport.rb +374 -123
  28. data/generated/nl/linux/psp.rb +1093 -201
  29. data/generated/nl/linux/rt_addr.rb +423 -165
  30. data/generated/nl/linux/rt_link.rb +6928 -1336
  31. data/generated/nl/linux/rt_neigh.rb +1063 -297
  32. data/generated/nl/linux/rt_route.rb +1112 -483
  33. data/generated/nl/linux/rt_rule.rb +931 -262
  34. data/generated/nl/linux/sunrpc_cache.rb +407 -82
  35. data/generated/nl/linux/tc.rb +10081 -1763
  36. data/generated/nl/linux/tcp_metrics.rb +388 -109
  37. data/generated/nl/linux/team.rb +350 -84
  38. data/generated/nl/linux/wireguard.rb +525 -96
  39. data/generated/nl/linux.rb +1 -0
  40. data/lib/nl/linux/nlctrl_resolver.rb +31 -0
  41. data/lib/nl/linux/version.rb +1 -1
  42. data/sig/generated/nl/linux/binder.rbs +366 -0
  43. data/sig/generated/nl/linux/conntrack.rbs +2787 -0
  44. data/sig/generated/nl/linux/dev_energymodel.rbs +636 -0
  45. data/sig/generated/nl/linux/devlink.rbs +12496 -0
  46. data/sig/generated/nl/linux/dpll.rbs +3461 -0
  47. data/sig/generated/nl/linux/drm_ras.rbs +553 -0
  48. data/sig/generated/nl/linux/ethtool.rbs +15291 -0
  49. data/sig/generated/nl/linux/fou.rbs +702 -0
  50. data/sig/generated/nl/linux/handshake.rbs +622 -0
  51. data/sig/generated/nl/linux/lockd.rbs +234 -0
  52. data/sig/generated/nl/linux/mptcp_pm.rbs +1511 -0
  53. data/sig/generated/nl/linux/net_shaper.rbs +1645 -0
  54. data/sig/generated/nl/linux/netdev.rbs +4187 -0
  55. data/sig/generated/nl/linux/nfsd.rbs +2520 -0
  56. data/sig/generated/nl/linux/nftables.rbs +10304 -0
  57. data/sig/generated/nl/linux/nl80211.rbs +9786 -0
  58. data/sig/generated/nl/linux/nlctrl.rbs +944 -0
  59. data/sig/generated/nl/linux/nlctrl_resolver.rbs +20 -0
  60. data/sig/generated/nl/linux/ovpn.rbs +2564 -0
  61. data/sig/generated/nl/linux/ovs_datapath.rbs +640 -0
  62. data/sig/generated/nl/linux/ovs_flow.rbs +3659 -0
  63. data/sig/generated/nl/linux/ovs_packet.rbs +540 -0
  64. data/sig/generated/nl/linux/ovs_vport.rbs +777 -0
  65. data/sig/generated/nl/linux/psp.rbs +1846 -0
  66. data/sig/generated/nl/linux/rt_addr.rbs +866 -0
  67. data/sig/generated/nl/linux/rt_link.rbs +13438 -0
  68. data/sig/generated/nl/linux/rt_neigh.rbs +2124 -0
  69. data/sig/generated/nl/linux/rt_route.rbs +2218 -0
  70. data/sig/generated/nl/linux/rt_rule.rbs +1726 -0
  71. data/sig/generated/nl/linux/sunrpc_cache.rbs +739 -0
  72. data/sig/generated/nl/linux/tc.rbs +19931 -0
  73. data/sig/generated/nl/linux/tcp_metrics.rbs +740 -0
  74. data/sig/generated/nl/linux/team.rbs +733 -0
  75. data/sig/generated/nl/linux/version.rbs +7 -0
  76. data/sig/generated/nl/linux/wireguard.rbs +1006 -0
  77. data/sig/generated/nl/linux.rbs +6 -0
  78. data/sig/generated/nl-linux.rbs +2 -0
  79. metadata +51 -10
@@ -1,7 +1,8 @@
1
1
  # SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2
+ #
3
+ # This file is based on Documentation/netlink/specs/wireguard.yaml from Linux v7.2.
2
4
  #--
3
5
  # frozen_string_literal: true
4
- # rbs_inline: enabled
5
6
  # This code is generated by Ynl::Generator. DO NOT EDIT.
6
7
  require 'nl'
7
8
  module Nl; module Linux
@@ -13,207 +14,477 @@ module Nl; module Linux
13
14
  # attributes, these two commands actually accept a slightly different set of
14
15
  # inputs and outputs. These differences are noted under the individual
15
16
  # attributes.
16
- class Wireguard < ::Nl::Family
17
+ class Wireguard < ::Nl::Genl::Family
17
18
  NAME = "wireguard"
18
- PROTOCOL = Ractor.make_shareable(::Nl::Protocols::Genl.new("wireguard"))
19
+ VERSION = 1
20
+ # @rbs (?resolver: ^(::Nl::Genl::Client, ::String) -> ::Nl::Genl::FamilyInfo, ?executor: executor?, ?notification_capacity: ::Integer?) -> (::Nl::Family::Session & instance)
21
+ # @rbs | [R] (?resolver: ^(::Nl::Genl::Client, ::String) -> ::Nl::Genl::FamilyInfo, ?executor: executor?, ?notification_capacity: ::Integer?) { (instance) -> R } -> R
22
+ # @overload open(resolver: ::Nl::Linux::DEFAULT_RESOLVER, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY)
23
+ # @param [#call] resolver
24
+ # @param [Symbol, nil] executor
25
+ # @param [Integer, nil] notification_capacity
26
+ # @return [Wireguard]
27
+ # @overload open(resolver: ::Nl::Linux::DEFAULT_RESOLVER, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY, &block)
28
+ # @param [#call] resolver
29
+ # @param [Symbol, nil] executor
30
+ # @param [Integer, nil] notification_capacity
31
+ # @yieldparam [Wireguard] family
32
+ # @return [Object] the result of the block
33
+ def self.open(resolver: ::Nl::Linux::DEFAULT_RESOLVER, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY)
34
+ super
35
+ end
36
+ # @private
37
+ MCAST_GROUPS = Ractor.make_shareable({}) #: Hash[::Symbol, ::Nl::McastGroup]
38
+ module Constants
39
+ WG_KEY_LEN = 32
40
+ end
41
+ module Flags
42
+ module WgdeviceFlags
43
+ ReplacePeers = 1
44
+ end
45
+ module WgpeerFlags
46
+ RemoveMe = 1
47
+ ReplaceAllowedips = 2
48
+ UpdateOnly = 4
49
+ end
50
+ module WgallowedipFlags
51
+ RemoveMe = 1
52
+ end
53
+ end
19
54
  module Structs
20
55
  KernelTimespec = Struct.new(
21
56
  :"sec", #: ::Integer
22
57
  :"nsec", #: ::Integer
23
58
  )
24
59
  class KernelTimespec
25
- # :nodoc:
26
- MEMBERS = Ractor.make_shareable({sec: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil), nsec: ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)}) #: Hash[::Symbol, ::Nl::_DataType]
60
+ # @!attribute [rw] sec
61
+ # Number of seconds, since UNIX epoch.
62
+ # @return [Integer]
63
+ # @!attribute [rw] nsec
64
+ # Number of nanoseconds, after the second began.
65
+ # @return [Integer]
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]
27
68
  # Decodes the struct.
28
- #--
29
69
  # @rbs decoder: ::Nl::Decoder
30
70
  # @rbs return: instance
71
+ # @param [Nl::Decoder] decoder
72
+ # @return [self]
31
73
  def self.decode(decoder)
32
74
  self.new(*MEMBERS.map {|name, datatype| datatype.decode(decoder) })
33
75
  end
34
76
  # Encodes the struct.
35
- #--
36
77
  # @rbs encoder: ::Nl::Encoder
37
78
  # @rbs return: void
79
+ # @param [Nl::Encoder] encoder
80
+ # @return [void]
38
81
  def encode(encoder)
39
82
  MEMBERS.each {|name, datatype| datatype.encode(encoder, self.public_send(name)) }
40
83
  end
41
84
  end
42
85
  end
43
86
  module AttributeSets
44
- class Wgdevice < ::Nl::Protocols::Genl::AttributeSet
87
+ class Wgdevice < ::Nl::AttributeSet
45
88
  # Abstract class
46
- class Attribute < ::Nl::Protocols::Genl::AttributeSet::Attribute
89
+ class Attribute < ::Nl::AttributeSet::Attribute
47
90
  end
48
91
  class Ifindex < Attribute
49
92
  TYPE = 1
50
93
  NAME = :"ifindex"
51
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
94
+ # @private
95
+ ORDER = 0
96
+ # @private
97
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
52
98
  end
53
99
  class Ifname < Attribute
54
100
  TYPE = 2
55
101
  NAME = :"ifname"
56
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::String.new(check: -> { raise ArgumentError, "Value #{it.inspect} is longer than maximum length 15" unless it.bytesize <= 15 })
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 })
57
106
  end
107
+ # Set to all zeros to remove.
58
108
  class PrivateKey < Attribute
59
109
  TYPE = 3
60
110
  NAME = :"private_key"
61
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length 32" unless it.bytesize == 32 })
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 })
62
115
  end
63
116
  class PublicKey < Attribute
64
117
  TYPE = 4
65
118
  NAME = :"public_key"
66
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length 32" unless it.bytesize == 32 })
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 })
67
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}.
68
129
  class Flags < Attribute
69
130
  TYPE = 5
70
131
  NAME = :"flags"
71
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
132
+ # @private
133
+ ORDER = 4
134
+ # @private
135
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
72
136
  end
137
+ # Set as ``0`` to choose randomly.
73
138
  class ListenPort < Attribute
74
139
  TYPE = 6
75
140
  NAME = :"listen_port"
76
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U16, check: nil)
141
+ # @private
142
+ ORDER = 5
143
+ # @private
144
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U16, check: nil)
77
145
  end
146
+ # Set as ``0`` to disable.
78
147
  class Fwmark < Attribute
79
148
  TYPE = 7
80
149
  NAME = :"fwmark"
81
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
150
+ # @private
151
+ ORDER = 6
152
+ # @private
153
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
82
154
  end
155
+ # The index/type parameter is unused on ``SET_DEVICE`` operations and is
156
+ # zero on ``GET_DEVICE`` operations.
83
157
  class Peers < Attribute
84
158
  TYPE = 8
85
159
  NAME = :"peers"
160
+ # @private
161
+ ORDER = 7
86
162
  end
87
- # :nodoc:
163
+ # @private
88
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]
89
- # :nodoc:
165
+ # @private
90
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
91
209
  class << self
92
210
  # Looks up Attribute class by name.
93
- #--
94
211
  # @rbs name: Symbol
95
212
  # @rbs return: Attribute
213
+ # @param [Symbol] name
214
+ # @return [Attribute]
96
215
  def by_name(name); BY_NAME.fetch(name); end
97
216
  # Looks up Attribute class by type value.
98
- #--
99
217
  # @rbs type: Integer
100
218
  # @rbs return: Attribute
219
+ # @param [Integer] type
220
+ # @return [Attribute]
101
221
  def by_type(type); BY_TYPE.fetch(type); end
102
222
  end
103
223
  end
104
- class Wgpeer < ::Nl::Protocols::Genl::AttributeSet
224
+ class Wgpeer < ::Nl::AttributeSet
105
225
  # Abstract class
106
- class Attribute < ::Nl::Protocols::Genl::AttributeSet::Attribute
226
+ class Attribute < ::Nl::AttributeSet::Attribute
107
227
  end
108
228
  class PublicKey < Attribute
109
229
  TYPE = 1
110
230
  NAME = :"public_key"
111
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length 32" unless it.bytesize == 32 })
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 })
112
235
  end
236
+ # Set as all zeros to remove.
113
237
  class PresharedKey < Attribute
114
238
  TYPE = 2
115
239
  NAME = :"preshared_key"
116
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length 32" unless it.bytesize == 32 })
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 })
117
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}.
118
254
  class Flags < Attribute
119
255
  TYPE = 3
120
256
  NAME = :"flags"
121
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
257
+ # @private
258
+ ORDER = 2
259
+ # @private
260
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
122
261
  end
262
+ # struct sockaddr_in or struct sockaddr_in6
123
263
  class Endpoint < Attribute
124
264
  TYPE = 4
125
265
  NAME = :"endpoint"
126
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is shorter than minimum length 16" unless it.bytesize >= 16 })
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 })
127
270
  end
271
+ # Set as ``0`` to disable.
128
272
  class PersistentKeepaliveInterval < Attribute
129
273
  TYPE = 5
130
274
  NAME = :"persistent_keepalive_interval"
131
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U16, check: nil)
275
+ # @private
276
+ ORDER = 4
277
+ # @private
278
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U16, check: nil)
132
279
  end
133
280
  class LastHandshakeTime < Attribute
134
281
  TYPE = 6
135
282
  NAME = :"last_handshake_time"
136
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is not equal to length 16" unless it.bytesize == 16 })
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)
137
287
  end
138
288
  class RxBytes < Attribute
139
289
  TYPE = 7
140
290
  NAME = :"rx_bytes"
141
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)
291
+ # @private
292
+ ORDER = 6
293
+ # @private
294
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)
142
295
  end
143
296
  class TxBytes < Attribute
144
297
  TYPE = 8
145
298
  NAME = :"tx_bytes"
146
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)
299
+ # @private
300
+ ORDER = 7
301
+ # @private
302
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U64, check: nil)
147
303
  end
304
+ # The index/type parameter is unused on ``SET_DEVICE`` operations and is
305
+ # zero on ``GET_DEVICE`` operations.
148
306
  class Allowedips < Attribute
149
307
  TYPE = 9
150
308
  NAME = :"allowedips"
309
+ # @private
310
+ ORDER = 8
151
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``.
152
315
  class ProtocolVersion < Attribute
153
316
  TYPE = 10
154
317
  NAME = :"protocol_version"
155
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
318
+ # @private
319
+ ORDER = 9
320
+ # @private
321
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
156
322
  end
157
- # :nodoc:
323
+ # @private
158
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]
159
- # :nodoc:
325
+ # @private
160
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
161
384
  class << self
162
385
  # Looks up Attribute class by name.
163
- #--
164
386
  # @rbs name: Symbol
165
387
  # @rbs return: Attribute
388
+ # @param [Symbol] name
389
+ # @return [Attribute]
166
390
  def by_name(name); BY_NAME.fetch(name); end
167
391
  # Looks up Attribute class by type value.
168
- #--
169
392
  # @rbs type: Integer
170
393
  # @rbs return: Attribute
394
+ # @param [Integer] type
395
+ # @return [Attribute]
171
396
  def by_type(type); BY_TYPE.fetch(type); end
172
397
  end
173
398
  end
174
- class Wgallowedip < ::Nl::Protocols::Genl::AttributeSet
399
+ class Wgallowedip < ::Nl::AttributeSet
175
400
  # Abstract class
176
- class Attribute < ::Nl::Protocols::Genl::AttributeSet::Attribute
401
+ class Attribute < ::Nl::AttributeSet::Attribute
177
402
  end
403
+ # IP family, either ``AF_INET`` or ``AF_INET6``.
178
404
  class Family < Attribute
179
405
  TYPE = 1
180
406
  NAME = :"family"
181
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U16, check: nil)
407
+ # @private
408
+ ORDER = 0
409
+ # @private
410
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U16, check: nil)
182
411
  end
412
+ # Either ``struct in_addr`` or ``struct in6_addr``.
183
413
  class Ipaddr < Attribute
184
414
  TYPE = 2
185
415
  NAME = :"ipaddr"
186
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Binary.new(check: -> { raise ArgumentError, "Value #{it.inspect} is shorter than minimum length 4" unless it.bytesize >= 4 })
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 })
187
420
  end
188
421
  class CidrMask < Attribute
189
422
  TYPE = 3
190
423
  NAME = :"cidr_mask"
191
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U8, check: nil)
424
+ # @private
425
+ ORDER = 2
426
+ # @private
427
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U8, check: nil)
192
428
  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}.
193
434
  class Flags < Attribute
194
435
  TYPE = 4
195
436
  NAME = :"flags"
196
- DATATYPE = ::Nl::Protocols::Genl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
437
+ # @private
438
+ ORDER = 3
439
+ # @private
440
+ DATATYPE = ::Nl::DataTypes::Scalar.new(::Nl::Endian::Host::U32, check: nil)
197
441
  end
198
- # :nodoc:
442
+ # @private
199
443
  BY_NAME = Ractor.make_shareable({:"family" => Family, :"ipaddr" => Ipaddr, :"cidr_mask" => CidrMask, :"flags" => Flags}) #: Hash[::Symbol, Attribute]
200
- # :nodoc:
444
+ # @private
201
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
202
469
  class << self
203
470
  # Looks up Attribute class by name.
204
- #--
205
471
  # @rbs name: Symbol
206
472
  # @rbs return: Attribute
473
+ # @param [Symbol] name
474
+ # @return [Attribute]
207
475
  def by_name(name); BY_NAME.fetch(name); end
208
476
  # Looks up Attribute class by type value.
209
- #--
210
477
  # @rbs type: Integer
211
478
  # @rbs return: Attribute
479
+ # @param [Integer] type
480
+ # @return [Attribute]
212
481
  def by_type(type); BY_TYPE.fetch(type); end
213
482
  end
214
483
  end
215
- Wgdevice::Peers::DATATYPE = ::Nl::Protocols::Genl::DataTypes::IndexedArray.new(::Nl::Protocols::Genl::DataTypes::NestedAttributes.new(Wgpeer))
216
- Wgpeer::Allowedips::DATATYPE = ::Nl::Protocols::Genl::DataTypes::IndexedArray.new(::Nl::Protocols::Genl::DataTypes::NestedAttributes.new(Wgallowedip))
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([])))
217
488
  end
218
489
  module Messages
219
490
  # Retrieve WireGuard device
@@ -240,18 +511,21 @@ class Wireguard < ::Nl::Family
240
511
  # be ``NLMSG_DONE``, even if an error occurs. However, this ``NLMSG_DONE``
241
512
  # message contains an integer error code. It is either zero or a negative
242
513
  # error code corresponding to the errno.
243
- class DumpGetDeviceRequest < ::Nl::Protocols::Genl::Message
514
+ #
515
+ #
516
+ # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
517
+ class DumpGetDeviceRequest < ::Nl::Genl::Message
244
518
  TYPE = 0
245
519
  FIXED_HEADER = nil
246
520
  ATTRIBUTE_SET = AttributeSets::Wgdevice
247
521
  ATTRIBUTES = Ractor.make_shareable(%i[ifindex ifname])
248
- # Gets the value of `ifindex` attribute in the message.
249
- #--
250
522
  # @rbs return: ::Integer
523
+ # @return [Integer]
524
+ # @see AttributeSets::Wgdevice::Ifindex
251
525
  def ifindex; attributes[:"ifindex"]&.value; end
252
- # Gets the value of `ifname` attribute in the message.
253
- #--
254
526
  # @rbs return: ::String
527
+ # @return [String]
528
+ # @see AttributeSets::Wgdevice::Ifname
255
529
  def ifname; attributes[:"ifname"]&.value; end
256
530
  end
257
531
  # Retrieve WireGuard device
@@ -278,42 +552,55 @@ class Wireguard < ::Nl::Family
278
552
  # be ``NLMSG_DONE``, even if an error occurs. However, this ``NLMSG_DONE``
279
553
  # message contains an integer error code. It is either zero or a negative
280
554
  # error code corresponding to the errno.
281
- class DumpGetDeviceReply < ::Nl::Protocols::Genl::Message
555
+ #
556
+ #
557
+ # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
558
+ class DumpGetDeviceReply < ::Nl::Genl::Message
282
559
  TYPE = 0
283
560
  FIXED_HEADER = nil
284
561
  ATTRIBUTE_SET = AttributeSets::Wgdevice
285
562
  ATTRIBUTES = Ractor.make_shareable(%i[ifindex ifname private_key public_key flags listen_port fwmark peers])
286
- # Gets the value of `ifindex` attribute in the message.
287
- #--
288
563
  # @rbs return: ::Integer
564
+ # @return [Integer]
565
+ # @see AttributeSets::Wgdevice::Ifindex
289
566
  def ifindex; attributes[:"ifindex"]&.value; end
290
- # Gets the value of `ifname` attribute in the message.
291
- #--
292
567
  # @rbs return: ::String
568
+ # @return [String]
569
+ # @see AttributeSets::Wgdevice::Ifname
293
570
  def ifname; attributes[:"ifname"]&.value; end
294
- # Gets the value of `private-key` attribute in the message.
295
- #--
296
- # @rbs return: untyped
571
+ # Set to all zeros to remove.
572
+ # @rbs return: ::String
573
+ # @return [String]
574
+ # @see AttributeSets::Wgdevice::PrivateKey
297
575
  def private_key; attributes[:"private_key"]&.value; end
298
- # Gets the value of `public-key` attribute in the message.
299
- #--
300
- # @rbs return: untyped
576
+ # @rbs return: ::String
577
+ # @return [String]
578
+ # @see AttributeSets::Wgdevice::PublicKey
301
579
  def public_key; attributes[:"public_key"]&.value; end
302
- # Gets the value of `flags` attribute in the message.
303
- #--
580
+ # ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers should be
581
+ # removed prior to adding the list below.
582
+ #
583
+ #
584
+ # Known flags are defined in {Flags::WgdeviceFlags}.
304
585
  # @rbs return: ::Integer
586
+ # @return [Integer]
587
+ # @see AttributeSets::Wgdevice::Flags
305
588
  def flags; attributes[:"flags"]&.value; end
306
- # Gets the value of `listen-port` attribute in the message.
307
- #--
589
+ # Set as ``0`` to choose randomly.
308
590
  # @rbs return: ::Integer
591
+ # @return [Integer]
592
+ # @see AttributeSets::Wgdevice::ListenPort
309
593
  def listen_port; attributes[:"listen_port"]&.value; end
310
- # Gets the value of `fwmark` attribute in the message.
311
- #--
594
+ # Set as ``0`` to disable.
312
595
  # @rbs return: ::Integer
596
+ # @return [Integer]
597
+ # @see AttributeSets::Wgdevice::Fwmark
313
598
  def fwmark; attributes[:"fwmark"]&.value; end
314
- # Gets the value of `peers` attribute in the message.
315
- #--
316
- # @rbs return: untyped
599
+ # The index/type parameter is unused on ``SET_DEVICE`` operations and is
600
+ # zero on ``GET_DEVICE`` operations.
601
+ # @rbs return: ::Array[AttributeSets::Wgpeer]
602
+ # @return [Array<AttributeSets::Wgpeer>]
603
+ # @see AttributeSets::Wgdevice::Peers
317
604
  def peers; attributes[:"peers"]&.value; end
318
605
  end
319
606
  # Set WireGuard device
@@ -334,45 +621,62 @@ class Wireguard < ::Nl::Family
334
621
  # subsequent fragments.
335
622
  #
336
623
  # If an error occurs, ``NLMSG_ERROR`` will reply containing an errno.
337
- class DoSetDeviceRequest < ::Nl::Protocols::Genl::Message
624
+ #
625
+ #
626
+ # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
627
+ class DoSetDeviceRequest < ::Nl::Genl::Message
338
628
  TYPE = 1
339
629
  FIXED_HEADER = nil
340
630
  ATTRIBUTE_SET = AttributeSets::Wgdevice
341
631
  ATTRIBUTES = Ractor.make_shareable(%i[ifindex ifname private_key public_key flags listen_port fwmark peers])
342
- # Gets the value of `ifindex` attribute in the message.
343
- #--
344
632
  # @rbs return: ::Integer
633
+ # @return [Integer]
634
+ # @see AttributeSets::Wgdevice::Ifindex
345
635
  def ifindex; attributes[:"ifindex"]&.value; end
346
- # Gets the value of `ifname` attribute in the message.
347
- #--
348
636
  # @rbs return: ::String
637
+ # @return [String]
638
+ # @see AttributeSets::Wgdevice::Ifname
349
639
  def ifname; attributes[:"ifname"]&.value; end
350
- # Gets the value of `private-key` attribute in the message.
351
- #--
352
- # @rbs return: untyped
640
+ # Set to all zeros to remove.
641
+ # @rbs return: ::String
642
+ # @return [String]
643
+ # @see AttributeSets::Wgdevice::PrivateKey
353
644
  def private_key; attributes[:"private_key"]&.value; end
354
- # Gets the value of `public-key` attribute in the message.
355
- #--
356
- # @rbs return: untyped
645
+ # @rbs return: ::String
646
+ # @return [String]
647
+ # @see AttributeSets::Wgdevice::PublicKey
357
648
  def public_key; attributes[:"public_key"]&.value; end
358
- # Gets the value of `flags` attribute in the message.
359
- #--
649
+ # ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers should be
650
+ # removed prior to adding the list below.
651
+ #
652
+ #
653
+ # Known flags are defined in {Flags::WgdeviceFlags}.
360
654
  # @rbs return: ::Integer
655
+ # @return [Integer]
656
+ # @see AttributeSets::Wgdevice::Flags
361
657
  def flags; attributes[:"flags"]&.value; end
362
- # Gets the value of `listen-port` attribute in the message.
363
- #--
658
+ # Set as ``0`` to choose randomly.
364
659
  # @rbs return: ::Integer
660
+ # @return [Integer]
661
+ # @see AttributeSets::Wgdevice::ListenPort
365
662
  def listen_port; attributes[:"listen_port"]&.value; end
366
- # Gets the value of `fwmark` attribute in the message.
367
- #--
663
+ # Set as ``0`` to disable.
368
664
  # @rbs return: ::Integer
665
+ # @return [Integer]
666
+ # @see AttributeSets::Wgdevice::Fwmark
369
667
  def fwmark; attributes[:"fwmark"]&.value; end
370
- # Gets the value of `peers` attribute in the message.
371
- #--
372
- # @rbs return: untyped
668
+ # The index/type parameter is unused on ``SET_DEVICE`` operations and is
669
+ # zero on ``GET_DEVICE`` operations.
670
+ # @rbs return: ::Array[AttributeSets::Wgpeer]
671
+ # @return [Array<AttributeSets::Wgpeer>]
672
+ # @see AttributeSets::Wgdevice::Peers
373
673
  def peers; attributes[:"peers"]&.value; end
374
674
  end
375
675
  end
676
+ module Notifications
677
+ end
678
+ # @private
679
+ NOTIFICATIONS = Ractor.make_shareable({}) #: Hash[::Integer, ::Class]
376
680
  # Retrieve WireGuard device
377
681
  # ~~~~~~~~~~~~~~~~~~~~~~~~~
378
682
  #
@@ -397,9 +701,25 @@ class Wireguard < ::Nl::Family
397
701
  # be ``NLMSG_DONE``, even if an error occurs. However, this ``NLMSG_DONE``
398
702
  # message contains an integer error code. It is either zero or a negative
399
703
  # error code corresponding to the errno.
400
- #--
401
- # @rbs (?ifindex: ::Integer, ?ifname: ::String) -> Enumerable[Messages::DumpGetDeviceReply]
704
+ #
705
+ #
706
+ # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
707
+ # @rbs (?ifindex: ::Integer, ?ifname: ::String) -> Array[Messages::DumpGetDeviceReply]
402
708
  # | (?ifindex: ::Integer, ?ifname: ::String) { (Messages::DumpGetDeviceReply) -> void } -> void
709
+ # @overload dump_get_device(**args)
710
+ # Returns an array when no block is given.
711
+ # @param [Hash] args
712
+ # @option args [Integer] ifindex
713
+ # @option args [String] ifname
714
+ # @return [Array<Messages::DumpGetDeviceReply>]
715
+ # @overload dump_get_device(**args, &block)
716
+ # Yields each reply when a block is given.
717
+ # @param [Hash] args
718
+ # @option args [Integer] ifindex
719
+ # @option args [String] ifname
720
+ # @yieldparam [Messages::DumpGetDeviceReply] reply
721
+ # @return [void]
722
+ # @see Messages::DumpGetDeviceRequest
403
723
  def dump_get_device(**args, &block)
404
724
  exchange_message(:"dump", Messages::DumpGetDeviceRequest, Messages::DumpGetDeviceReply, args, &block)
405
725
  end
@@ -421,10 +741,119 @@ class Wireguard < ::Nl::Family
421
741
  # subsequent fragments.
422
742
  #
423
743
  # If an error occurs, ``NLMSG_ERROR`` will reply containing an errno.
424
- #--
425
- # @rbs (?ifindex: ::Integer, ?ifname: ::String, ?private_key: untyped, ?public_key: untyped, ?flags: ::Integer, ?listen_port: ::Integer, ?fwmark: ::Integer, ?peers: untyped) -> void
744
+ #
745
+ #
746
+ # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
747
+ # @rbs (?ifindex: ::Integer, ?ifname: ::String, ?private_key: ::String, ?public_key: ::String, ?flags: ::Integer, ?listen_port: ::Integer, ?fwmark: ::Integer, ?peers: ::Array[(AttributeSets::Wgpeer | ::Hash[::Symbol, untyped])]) -> void
748
+ # @param [Hash] args
749
+ # @option args [Integer] ifindex
750
+ # @option args [String] ifname
751
+ # @option args [String] private_key Set to all zeros to remove.
752
+ # @option args [String] public_key
753
+ # @option args [Integer] flags ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers should be
754
+ # removed prior to adding the list below.
755
+ #
756
+ #
757
+ # Known flags are defined in {Flags::WgdeviceFlags}.
758
+ # @option args [Integer] listen_port Set as ``0`` to choose randomly.
759
+ # @option args [Integer] fwmark Set as ``0`` to disable.
760
+ # @option args [Array<AttributeSets::Wgpeer, Hash<Symbol, Object>>] peers The index/type parameter is unused on ``SET_DEVICE`` operations and is
761
+ # zero on ``GET_DEVICE`` operations.
762
+ # @return [void]
763
+ # @see Messages::DoSetDeviceRequest
426
764
  def do_set_device(**args)
427
765
  exchange_message(:"do", Messages::DoSetDeviceRequest, nil, args)
428
766
  end
767
+ class AsyncOperations
768
+ # @private
769
+ def initialize(&exchange)
770
+ @exchange = exchange
771
+ end
772
+ # Retrieve WireGuard device
773
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~
774
+ #
775
+ # The command should be called with one but not both of:
776
+ #
777
+ # - ``WGDEVICE_A_IFINDEX``
778
+ # - ``WGDEVICE_A_IFNAME``
779
+ #
780
+ # The kernel will then return several messages (``NLM_F_MULTI``). It is
781
+ # possible that all of the allowed IPs of a single peer will not fit
782
+ # within a single netlink message. In that case, the same peer will be
783
+ # written in the following message, except it will only contain
784
+ # ``WGPEER_A_PUBLIC_KEY`` and ``WGPEER_A_ALLOWEDIPS``. This may occur
785
+ # several times in a row for the same peer. It is then up to the receiver
786
+ # to coalesce adjacent peers. Likewise, it is possible that all peers will
787
+ # not fit within a single message. So, subsequent peers will be sent in
788
+ # following messages, except those will only contain ``WGDEVICE_A_IFNAME``
789
+ # and ``WGDEVICE_A_PEERS``. It is then up to the receiver to coalesce
790
+ # these messages to form the complete list of peers.
791
+ #
792
+ # Since this is an ``NLA_F_DUMP`` command, the final message will always
793
+ # be ``NLMSG_DONE``, even if an error occurs. However, this ``NLMSG_DONE``
794
+ # message contains an integer error code. It is either zero or a negative
795
+ # error code corresponding to the errno.
796
+ #
797
+ #
798
+ # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
799
+ # @rbs (?ifindex: ::Integer, ?ifname: ::String) -> ::Nl::Async::Stream[Messages::DumpGetDeviceReply]
800
+ # @param [Hash] args
801
+ # @option args [Integer] ifindex
802
+ # @option args [String] ifname
803
+ # @return [Nl::Async::Stream<Messages::DumpGetDeviceReply>]
804
+ # @see Messages::DumpGetDeviceRequest
805
+ def dump_get_device(**args)
806
+ @exchange.call(:"dump", Messages::DumpGetDeviceRequest, Messages::DumpGetDeviceReply, args)
807
+ end
808
+ # Set WireGuard device
809
+ # ~~~~~~~~~~~~~~~~~~~~
810
+ #
811
+ # This command should be called with a wgdevice set, containing one but
812
+ # not both of ``WGDEVICE_A_IFINDEX`` and ``WGDEVICE_A_IFNAME``.
813
+ #
814
+ # It is possible that the amount of configuration data exceeds that of the
815
+ # maximum message length accepted by the kernel. In that case, several
816
+ # messages should be sent one after another, with each successive one
817
+ # filling in information not contained in the prior. Note that if
818
+ # ``WGDEVICE_F_REPLACE_PEERS`` is specified in the first message, it
819
+ # probably should not be specified in fragments that come after, so that
820
+ # the list of peers is only cleared the first time but appended after.
821
+ # Likewise for peers, if ``WGPEER_F_REPLACE_ALLOWEDIPS`` is specified in
822
+ # the first message of a peer, it likely should not be specified in
823
+ # subsequent fragments.
824
+ #
825
+ # If an error occurs, ``NLMSG_ERROR`` will reply containing an errno.
826
+ #
827
+ #
828
+ # Requires CAP_NET_ADMIN in the user namespace owning the network namespace.
829
+ # @rbs (?ifindex: ::Integer, ?ifname: ::String, ?private_key: ::String, ?public_key: ::String, ?flags: ::Integer, ?listen_port: ::Integer, ?fwmark: ::Integer, ?peers: ::Array[(AttributeSets::Wgpeer | ::Hash[::Symbol, untyped])]) -> ::Nl::Async::Future[void]
830
+ # @param [Hash] args
831
+ # @option args [Integer] ifindex
832
+ # @option args [String] ifname
833
+ # @option args [String] private_key Set to all zeros to remove.
834
+ # @option args [String] public_key
835
+ # @option args [Integer] flags ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers should be
836
+ # removed prior to adding the list below.
837
+ #
838
+ #
839
+ # Known flags are defined in {Flags::WgdeviceFlags}.
840
+ # @option args [Integer] listen_port Set as ``0`` to choose randomly.
841
+ # @option args [Integer] fwmark Set as ``0`` to disable.
842
+ # @option args [Array<AttributeSets::Wgpeer, Hash<Symbol, Object>>] peers The index/type parameter is unused on ``SET_DEVICE`` operations and is
843
+ # zero on ``GET_DEVICE`` operations.
844
+ # @return [Nl::Async::Future<void>]
845
+ # @see Messages::DoSetDeviceRequest
846
+ def do_set_device(**args)
847
+ @exchange.call(:"do", Messages::DoSetDeviceRequest, nil, args)
848
+ end
849
+ end
850
+ # Returns the asynchronous operation facade for this family.
851
+ # @rbs (?stream_capacity: ::Integer?) -> AsyncOperations
852
+ # @param [::Integer, nil] stream_capacity
853
+ # @return [AsyncOperations]
854
+ def async(stream_capacity: nil)
855
+ return @async_operations ||= build_async_facade(AsyncOperations) if stream_capacity.nil?
856
+ build_async_facade(AsyncOperations, stream_capacity:)
857
+ end
429
858
  end
430
859
  end; end