nl 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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/lib/nl/async/dispatcher.rb +2 -2
  4. data/lib/nl/attribute_set.rb +19 -153
  5. data/lib/nl/attributes.rb +193 -0
  6. data/lib/nl/blocking_transport.rb +5 -5
  7. data/lib/nl/datagram.rb +4 -4
  8. data/lib/nl/datatypes/checked.rb +66 -0
  9. data/lib/nl/datatypes/defaults.rb +13 -0
  10. data/lib/nl/datatypes/scalar.rb +28 -0
  11. data/lib/nl/datatypes.rb +97 -125
  12. data/lib/nl/decoder.rb +79 -25
  13. data/lib/nl/encoder.rb +4 -6
  14. data/lib/nl/endian.rb +5 -4
  15. data/lib/nl/exchange.rb +18 -17
  16. data/lib/nl/family.rb +33 -15
  17. data/lib/nl/genl/client.rb +1 -0
  18. data/lib/nl/genl/protocol.rb +16 -3
  19. data/lib/nl/genl/wire.rb +10 -3
  20. data/lib/nl/genl.rb +0 -20
  21. data/lib/nl/message.rb +21 -0
  22. data/lib/nl/notification_router.rb +2 -5
  23. data/lib/nl/raw/client.rb +1 -1
  24. data/lib/nl/raw/protocol.rb +27 -21
  25. data/lib/nl/raw/wire.rb +21 -50
  26. data/lib/nl/raw.rb +1 -51
  27. data/lib/nl/{sub_message.rb → selector.rb} +13 -23
  28. data/lib/nl/socket.rb +21 -5
  29. data/lib/nl/version.rb +1 -1
  30. data/lib/nl.rb +2 -2
  31. data/sig/generated/nl/attribute_set.rbs +21 -29
  32. data/sig/generated/nl/attributes.rbs +51 -0
  33. data/sig/generated/nl/datagram.rbs +4 -4
  34. data/sig/generated/nl/datatypes/checked.rbs +31 -0
  35. data/sig/generated/nl/datatypes/defaults.rbs +11 -0
  36. data/sig/generated/nl/datatypes/scalar.rbs +11 -0
  37. data/sig/generated/nl/datatypes.rbs +38 -34
  38. data/sig/generated/nl/decoder.rbs +12 -4
  39. data/sig/generated/nl/encoder.rbs +1 -1
  40. data/sig/generated/nl/endian.rbs +1 -0
  41. data/sig/generated/nl/exchange.rbs +2 -2
  42. data/sig/generated/nl/family.rbs +40 -22
  43. data/sig/generated/nl/genl/protocol.rbs +3 -1
  44. data/sig/generated/nl/genl.rbs +0 -15
  45. data/sig/generated/nl/message.rbs +14 -0
  46. data/sig/generated/nl/raw/client.rbs +0 -1
  47. data/sig/generated/nl/raw/protocol.rbs +29 -43
  48. data/sig/generated/nl/raw/wire.rbs +0 -36
  49. data/sig/generated/nl/raw.rbs +0 -35
  50. data/sig/generated/nl/{sub_message.rbs → selector.rbs} +8 -19
  51. data/sig/generated/nl/socket.rbs +29 -10
  52. metadata +14 -6
  53. data/lib/nl/structured_payload.rb +0 -61
  54. data/sig/generated/nl/structured_payload.rbs +0 -25
data/lib/nl/socket.rb CHANGED
@@ -1,15 +1,15 @@
1
- # Netlink sockets
2
-
3
1
  require 'socket'
4
2
 
5
3
  module Nl
6
4
  # Netlink socket
7
5
  class Socket < ::Socket
8
6
  module Constants
9
- # From include/linux/socket.h
7
+ # From linux/socket.h
8
+ #-
10
9
  PF_NETLINK = AF_NETLINK = 16
11
10
 
12
- # From include/uapi/linux/netlink.h
11
+ # From linux/netlink.h
12
+ #-
13
13
  SOL_NETLINK = 270
14
14
  NETLINK_ADD_MEMBERSHIP = 1
15
15
  NETLINK_DROP_MEMBERSHIP = 2
@@ -17,17 +17,28 @@ module Nl
17
17
  include Constants
18
18
 
19
19
  class << self
20
+ # Packs Netlink socket address
21
+ #
22
+ # @rbs (Integer pid, Integer groups) -> String
20
23
  def pack_sockaddr_nl(pid, groups) = [Socket::AF_NETLINK, 0, pid, groups].pack('S!S!LL')
21
24
  alias sockaddr_nl pack_sockaddr_nl
22
25
 
26
+ # Unpacks Netlink socket address
27
+ #
28
+ # @rbs (String) -> [Integer, Integer]
23
29
  def unpack_sockaddr_nl(sockaddr) = sockaddr.unpack('S!S!LL')[2..3]
24
30
  end
25
31
 
26
- # @param protonum [Integer] Netlink protocol number
32
+ # @param [Integer] protonum Netlink protocol number
33
+ # @rbs (Integer) -> void
27
34
  def initialize(protonum)
28
35
  super(PF_NETLINK, SOCK_RAW, protonum)
29
36
  end
30
37
 
38
+ # Opens a Netlink socket for the specified protocol number.
39
+ #
40
+ # @rbs (Integer protonum) -> instance
41
+ # | [R] (Integer protonum) { (instance) -> R } -> R
31
42
  def self.open(protonum)
32
43
  return new(protonum) unless block_given?
33
44
  begin
@@ -39,16 +50,21 @@ module Nl
39
50
  end
40
51
 
41
52
  # @return [Integer] Local Netlink port ID assigned to this socket
53
+ # @rbs () -> Integer
42
54
  def local_port_id
43
55
  Socket.unpack_sockaddr_nl(local_address.to_sockaddr).first
44
56
  end
45
57
 
46
58
  # Adds this socket to a Netlink multicast group.
59
+ #
60
+ # @rbs (Integer group_id) -> void
47
61
  def add_membership(group_id)
48
62
  setsockopt(SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, group_id)
49
63
  end
50
64
 
51
65
  # Removes this socket from a Netlink multicast group.
66
+ #
67
+ # @rbs (Integer group_id) -> void
52
68
  def drop_membership(group_id)
53
69
  setsockopt(SOL_NETLINK, NETLINK_DROP_MEMBERSHIP, group_id)
54
70
  end
data/lib/nl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nl
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
data/lib/nl.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require_relative 'nl/error'
2
2
  require_relative 'nl/bitfield32'
3
3
  require_relative 'nl/raw/wire'
4
- require_relative 'nl/structured_payload'
5
- require_relative 'nl/sub_message'
4
+ require_relative 'nl/selector'
6
5
  require_relative 'nl/notification'
7
6
  require_relative 'nl/connection'
8
7
  require_relative 'nl/family'
8
+ require_relative 'nl/message'
9
9
  require_relative 'nl/raw'
10
10
  require_relative 'nl/genl'
11
11
  require_relative 'nl/socket'
@@ -1,50 +1,42 @@
1
1
  # Generated from lib/nl/attribute_set.rb with RBS::Inline
2
2
 
3
3
  module Nl
4
+ # A standalone nested attribute set. Messages share the same operations
5
+ # without allocating this wrapper.
4
6
  class AttributeSet
5
- class Attribute < Struct[untyped]
6
- attr_accessor value(): untyped
7
+ include Attributes
7
8
 
8
- def self.new: (?untyped value) -> instance
9
- | (?value: untyped) -> instance
10
- end
11
-
12
- class Attribute
13
- MULTI: bool
9
+ class Definition < Data
10
+ attr_reader id(): untyped
14
11
 
15
- ORDER: untyped
12
+ attr_reader name(): untyped
16
13
 
17
- SELECTOR_SLOT: untyped
14
+ attr_reader datatype(): untyped
18
15
 
19
- def self.multi?: () -> untyped
16
+ attr_reader multi(): untyped
20
17
 
21
- def self.decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
22
-
23
- def encode: (untyped encoder, ?context: untyped) -> untyped
24
- end
18
+ attr_reader order(): untyped
25
19
 
26
- def initialize: (untyped attributes) -> untyped
20
+ attr_reader selector_slot(): untyped
27
21
 
28
- def []: (untyped type) -> untyped
22
+ def self.new: (untyped id, untyped name, untyped datatype, untyped multi, untyped order, untyped selector_slot) -> instance
23
+ | (id: untyped, name: untyped, datatype: untyped, multi: untyped, order: untyped, selector_slot: untyped) -> instance
29
24
 
30
- def <<: (untyped attr) -> untyped
25
+ def self.members: () -> [ :id, :name, :datatype, :multi, :order, :selector_slot ]
31
26
 
32
- SELECTOR_NAMES: untyped
27
+ def members: () -> [ :id, :name, :datatype, :multi, :order, :selector_slot ]
28
+ end
33
29
 
34
- private def encode1: (untyped encoder, untyped attr, untyped context) -> untyped
30
+ def initialize: (?untyped attributes) -> untyped
35
31
 
36
32
  def encode: (untyped encoder, ?external_selectors: untyped) -> untyped
37
33
 
38
- private def selector_name: (untyped error) -> untyped
39
-
40
- private def self.decode1: (untyped decoder, untyped context) -> untyped
41
-
42
- def self.decode: (untyped decoder, ?external_selectors: untyped) -> untyped
43
-
44
- def self.build_attributes: (?untyped params, ?external_selectors: untyped, **untyped keywords) -> untyped
34
+ # Builds an attribute set from attribute names and values.
35
+ # @rbs (?Hash[Symbol, untyped] params) -> instance
36
+ def self.from_params: (?Hash[Symbol, untyped] params) -> instance
45
37
 
46
- private def self.coerce: (untyped datatype, untyped value, untyped context) -> untyped
38
+ def self.decode: (untyped decoder, untyped definitions, untyped local_selector_count, untyped external_selectors) -> untyped
47
39
 
48
- private def self.selector_name: (untyped error) -> untyped
40
+ def self.build_instance: (untyped params, ?external_selectors: untyped) -> untyped
49
41
  end
50
42
  end
@@ -0,0 +1,51 @@
1
+ # Generated from lib/nl/attributes.rb with RBS::Inline
2
+
3
+ module Nl
4
+ # An opaque attribute payload with the flags needed to re-encode it.
5
+ class RawAttributeValue
6
+ attr_reader payload: untyped
7
+
8
+ attr_reader nlattr_type_flags: untyped
9
+
10
+ def initialize: (untyped payload, nlattr_type_flags: untyped) -> untyped
11
+
12
+ def encode: (untyped encoder, ?external_selectors: untyped) -> untyped
13
+ end
14
+
15
+ # Ordered attribute operations shared by nested sets and generated payloads.
16
+ module Attributes
17
+ def self.included: (untyped base) -> untyped
18
+
19
+ def []: (untyped type) -> untyped
20
+
21
+ def append_attribute: (untyped type, untyped value) -> untyped
22
+
23
+ LOCAL_SELECTOR_NAMES: untyped
24
+
25
+ EXTERNAL_SELECTOR_NAMES: untyped
26
+
27
+ private def definition_for: (untyped type) -> untyped
28
+
29
+ private def encode1: (untyped encoder, untyped definition, untyped value, untyped context) -> untyped
30
+
31
+ private def encode_attributes: (untyped encoder, ?external_selectors: untyped) -> untyped
32
+
33
+ private def selector_name: (untyped error) -> untyped
34
+
35
+ module ClassMethods
36
+ def by_name: (untyped name) -> untyped
37
+
38
+ def by_type: (untyped type) -> untyped
39
+
40
+ private def decode1: (untyped decoder, untyped context, untyped attributes, untyped definitions) -> untyped
41
+
42
+ private def decode_attributes: (untyped decoder, untyped definitions, untyped local_selector_count, ?external_selectors: untyped) -> untyped
43
+
44
+ private def build_attributes: (untyped params, ?external_selectors: untyped) -> untyped
45
+
46
+ private def coerce: (untyped datatype, untyped value, untyped context) -> untyped
47
+
48
+ private def selector_name: (untyped error) -> untyped
49
+ end
50
+ end
51
+ end
@@ -3,9 +3,9 @@
3
3
  module Nl
4
4
  # Splits Netlink datagrams into aligned header/payload frames.
5
5
  module Datagram
6
- # @rbs (IO::Buffer buffer) { (Raw::NlMsgHdr, IO::Buffer) -> void } -> nil
7
- # | (IO::Buffer buffer) -> Enumerator[[Raw::NlMsgHdr, IO::Buffer], nil]
8
- def self.each_frame: (IO::Buffer buffer) { (Raw::NlMsgHdr, IO::Buffer) -> void } -> nil
9
- | (IO::Buffer buffer) -> Enumerator[[ Raw::NlMsgHdr, IO::Buffer ], nil]
6
+ # @rbs (IO::Buffer buffer) { (Raw::NlMsgHdr, Decoder) -> void } -> nil
7
+ # | (IO::Buffer buffer) -> Enumerator[[Raw::NlMsgHdr, Decoder], nil]
8
+ def self.each_frame: (IO::Buffer buffer) { (Raw::NlMsgHdr, Decoder) -> void } -> nil
9
+ | (IO::Buffer buffer) -> Enumerator[[ Raw::NlMsgHdr, Decoder ], nil]
10
10
  end
11
11
  end
@@ -0,0 +1,31 @@
1
+ # Generated from lib/nl/datatypes/checked.rb with RBS::Inline
2
+
3
+ module Nl
4
+ module DataTypes
5
+ # Validation applies to the decoded value, or the value being encoded.
6
+ class Checked
7
+ def initialize: (untyped datatype, check: untyped) -> untyped
8
+
9
+ def nlattr_type_flags: (?untyped value, ?context: untyped) -> untyped
10
+
11
+ def coerce: (untyped value, ?context: untyped) -> untyped
12
+
13
+ def encode: (untyped encoder, untyped value, ?context: untyped) -> untyped
14
+
15
+ def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
16
+ end
17
+
18
+ # Structured binary and packed arrays validate their encoded bytes.
19
+ class CheckedPayload
20
+ def initialize: (untyped datatype, check: untyped) -> untyped
21
+
22
+ def nlattr_type_flags: (?untyped value, ?context: untyped) -> untyped
23
+
24
+ def coerce: (untyped value, ?context: untyped) -> untyped
25
+
26
+ def encode: (untyped encoder, untyped value, ?context: untyped) -> untyped
27
+
28
+ def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,11 @@
1
+ # Generated from lib/nl/datatypes/defaults.rb with RBS::Inline
2
+
3
+ module Nl
4
+ module DataTypes
5
+ module Defaults
6
+ def nlattr_type_flags: (?untyped _value, ?context: untyped) -> untyped
7
+
8
+ def coerce: (untyped value, ?context: untyped) -> untyped
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # Generated from lib/nl/datatypes/scalar.rb with RBS::Inline
2
+
3
+ module Nl
4
+ module DataTypes
5
+ module Scalar
6
+ def self.[]: (untyped type) -> untyped
7
+
8
+ SPECIALIZATIONS: untyped
9
+ end
10
+ end
11
+ end
@@ -12,25 +12,9 @@ module Nl
12
12
  end
13
13
 
14
14
  module DataTypes
15
- class Base
16
- def initialize: (?check: untyped) -> untyped
15
+ class VariableInteger
16
+ include Defaults
17
17
 
18
- def nlattr_type_flags: (?untyped _value, ?context: untyped) -> untyped
19
-
20
- def coerce: (untyped value, ?context: untyped) -> untyped
21
-
22
- private def checked: (untyped value) -> untyped
23
- end
24
-
25
- class Scalar < Base
26
- def initialize: (untyped type, check: untyped) -> untyped
27
-
28
- def encode: (untyped encoder, untyped value, ?context: untyped) -> untyped
29
-
30
- def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
31
- end
32
-
33
- class VariableInteger < Base
34
18
  UINT32_RANGE: untyped
35
19
 
36
20
  UINT64_RANGE: untyped
@@ -39,23 +23,25 @@ module Nl
39
23
 
40
24
  SINT64_RANGE: untyped
41
25
 
42
- def initialize: (untyped byte_order, signed: untyped, check: untyped) -> untyped
26
+ def initialize: (untyped byte_order, signed: untyped) -> untyped
43
27
 
44
28
  def encode: (untyped encoder, untyped value, ?context: untyped) -> untyped
45
29
 
46
30
  def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
47
31
  end
48
32
 
49
- class String < Base
50
- def initialize: (check: untyped) -> untyped
33
+ class String
34
+ include Defaults
51
35
 
52
36
  def encode: (untyped encoder, untyped value, ?context: untyped) -> untyped
53
37
 
54
38
  def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
55
39
  end
56
40
 
57
- class Binary < Base
58
- def initialize: (check: untyped, ?length: untyped) -> untyped
41
+ class Binary
42
+ include Defaults
43
+
44
+ def initialize: (?length: untyped) -> untyped
59
45
 
60
46
  def encode: (untyped encoder, untyped value, ?context: untyped) -> untyped
61
47
 
@@ -64,8 +50,10 @@ module Nl
64
50
 
65
51
  # An array whose elements are packed consecutively without per-element
66
52
  # headers or alignment padding.
67
- class PackedArray < Base
68
- def initialize: (untyped sub_type, ?check: untyped) -> untyped
53
+ class PackedArray
54
+ include Defaults
55
+
56
+ def initialize: (untyped sub_type) -> untyped
69
57
 
70
58
  def encode: (untyped encoder, untyped values, ?context: untyped) -> untyped
71
59
 
@@ -74,8 +62,10 @@ module Nl
74
62
  def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
75
63
  end
76
64
 
77
- class Struct < Base
78
- def initialize: (untyped type, ?check: untyped, ?consume_remaining: untyped) -> untyped
65
+ class Struct
66
+ include Defaults
67
+
68
+ def initialize: (untyped type, ?consume_remaining: untyped) -> untyped
79
69
 
80
70
  def coerce: (untyped value, ?context: untyped) -> untyped
81
71
 
@@ -84,19 +74,25 @@ module Nl
84
74
  def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
85
75
  end
86
76
 
87
- class Flag < Base
77
+ class Flag
78
+ include Defaults
79
+
88
80
  def encode: (untyped encoder, untyped value, ?context: untyped) -> untyped
89
81
 
90
82
  def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
91
83
  end
92
84
 
93
- class Bitfield32 < Base
85
+ class Bitfield32
86
+ include Defaults
87
+
94
88
  def encode: (untyped encoder, untyped value, ?context: untyped) -> untyped
95
89
 
96
90
  def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
97
91
  end
98
92
 
99
- class Pad < Base
93
+ class Pad
94
+ include Defaults
95
+
100
96
  def initialize: (?untyped length) -> untyped
101
97
 
102
98
  def encode: (untyped encoder, untyped _value, ?context: untyped) -> untyped
@@ -104,7 +100,9 @@ module Nl
104
100
  def decode: (untyped decoder, ?context: untyped, ?nlattr_type_flags: untyped) -> untyped
105
101
  end
106
102
 
107
- class NestedAttributes < Base
103
+ class NestedAttributes
104
+ include Defaults
105
+
108
106
  def initialize: (untyped attribute_set, ?selector_bindings: untyped) -> untyped
109
107
 
110
108
  def nlattr_type_flags: (?untyped _value, ?context: untyped) -> untyped
@@ -118,7 +116,9 @@ module Nl
118
116
  private def selectors: (untyped context) -> untyped
119
117
  end
120
118
 
121
- class SubMessage < Base
119
+ class SubMessage
120
+ include Defaults
121
+
122
122
  class Format < Data
123
123
  attr_reader type(): untyped
124
124
 
@@ -150,7 +150,9 @@ module Nl
150
150
  # Nested attributes whose type numbers are keys rather than members of
151
151
  # an attribute set. Each level is returned as an Integer-keyed Hash;
152
152
  # values at the innermost level are decoded as @attribute_set.
153
- class NestTypeValue < Base
153
+ class NestTypeValue
154
+ include Defaults
155
+
154
156
  def initialize: (untyped attribute_set, untyped levels, ?selector_bindings: untyped) -> untyped
155
157
 
156
158
  def encode: (untyped encoder, untyped value, ?context: untyped) -> untyped
@@ -168,7 +170,9 @@ module Nl
168
170
  private def selectors: (untyped context) -> untyped
169
171
  end
170
172
 
171
- class IndexedArray < Base
173
+ class IndexedArray
174
+ include Defaults
175
+
172
176
  def initialize: (untyped sub_type) -> untyped
173
177
 
174
178
  def encode: (untyped encoder, untyped values, ?context: untyped) -> untyped
@@ -13,6 +13,14 @@ module Nl
13
13
  def initialize: (?untyped message) -> untyped
14
14
  end
15
15
 
16
+ VALUE_READERS: untyped
17
+
18
+ alias get_host_int get_host_sint
19
+
20
+ alias get_host_long get_host_slong
21
+
22
+ alias get_host_llong get_host_sllong
23
+
16
24
  def initialize: (untyped buffer, ?untyped offset, ?untyped length) -> untyped
17
25
 
18
26
  def available?: (?untyped size) -> untyped
@@ -21,18 +29,18 @@ module Nl
21
29
 
22
30
  def limit: (untyped size) -> untyped
23
31
 
32
+ def lookahead: () -> untyped
33
+
24
34
  def skip: (?untyped length) -> untyped
25
35
 
26
36
  def get_string: (?untyped length) -> untyped
27
37
 
28
- def get_buffer: (?untyped length) -> untyped
38
+ def slice: (?untyped length) -> untyped
29
39
 
30
40
  def get_zstring: (?unterminated_ok: untyped) -> untyped
31
41
 
32
- def get_value: (untyped type) -> untyped
33
-
34
42
  def get_values: (untyped types) -> untyped
35
43
 
36
- def align_to: (untyped alignment) -> untyped
44
+ def align_to_4: () -> untyped
37
45
  end
38
46
  end
@@ -16,7 +16,7 @@ module Nl
16
16
 
17
17
  def put_values: (untyped types, untyped values) -> untyped
18
18
 
19
- def align_to: (untyped alignment) -> untyped
19
+ def align_to_4: () -> untyped
20
20
 
21
21
  def put_value_at: (untyped offset, untyped type, untyped value) -> untyped
22
22
 
@@ -1,6 +1,7 @@
1
1
  # Generated from lib/nl/endian.rb with RBS::Inline
2
2
 
3
3
  module Nl
4
+ # Byte-order helpers
4
5
  module Endian
5
6
  # sizeof(int)
6
7
  SIZEOF_INT: untyped
@@ -54,7 +54,7 @@ module Nl
54
54
  # @rbs (mode: :dump | :no_reply | :reply) -> void
55
55
  def initialize: (mode: :dump | :no_reply | :reply) -> void
56
56
 
57
- def accept: (untyped frame) -> untyped
57
+ def accept: (untyped header, untyped message) -> untyped
58
58
 
59
59
  def cancel: () -> untyped
60
60
 
@@ -66,7 +66,7 @@ module Nl
66
66
 
67
67
  private def accept_ack: () -> untyped
68
68
 
69
- private def accept_reply: (untyped frame) -> untyped
69
+ private def accept_reply: (untyped header, untyped message) -> untyped
70
70
 
71
71
  private def complete: (untyped value) -> untyped
72
72
 
@@ -26,38 +26,56 @@ module Nl
26
26
  end
27
27
 
28
28
  class Family
29
- DEFAULT_NOTIFICATION_CAPACITY: untyped
29
+ DEFAULT_NOTIFICATION_CAPACITY: Integer
30
30
 
31
+ # Socket-owning family.
32
+ #
33
+ # {Family} instances that owns sockets are extended with this module.
31
34
  module Session
32
- def close: () -> nil
35
+ # Closes the Netlink socket owned by this {Family}.
36
+ # @rbs () -> void
37
+ def close: () -> void
33
38
  end
34
39
 
35
- # --
36
- # @rbs connection: _Connection
37
- # @rbs endpoint: Raw::Endpoint
38
- # @rbs return: instance
40
+ # @rbs (_Connection connection, endpoint: Raw::Endpoint) -> instance
39
41
  def initialize: (_Connection connection, endpoint: Raw::Endpoint) -> instance
40
42
 
41
43
  private def exchange_message: (untyped kind, untyped request_class, untyped reply_class, untyped args) ?{ (?) -> untyped } -> untyped
42
44
 
45
+ # Returns if this family supports asynchronous operations.
46
+ #
47
+ # @rbs () -> bool
43
48
  def async_capable?: () -> bool
44
49
 
45
- # Adds multicast memberships to the existing family socket. Membership is
46
- # additive and remains active until explicitly removed or the owner closes.
47
- def subscribe: (*untyped groups) -> untyped
48
-
49
- def unsubscribe: (*untyped groups) -> untyped
50
-
51
- def receive_notification: (?timeout: untyped) -> untyped
52
-
53
- def each_notification: () ?{ (?) -> untyped } -> untyped
54
-
55
- # Builds a generated asynchronous-operation facade with a narrowly scoped
56
- # callback, so the facade does not need access to Family's private API.
57
- # --
58
- # @rbs operations_class: Class
59
- # @rbs stream_capacity: Integer?
60
- # @rbs return: untyped
50
+ # Adds multicast memberships to the netlink socket.
51
+ #
52
+ # Membership is additive and remains active until explicitly removed or the owner closes.
53
+ #
54
+ # @param [Array<Symbol>] groups
55
+ # @return [Family] self
56
+ # @rbs (Symbol *groups) -> self
57
+ def subscribe:
58
+
59
+ # Removes multicast memberships from the netlink socket.
60
+ #
61
+ # @param [Array<Symbol>] groups
62
+ # @return [Family] self
63
+ # @rbs (Symbol *groups) -> self
64
+ def unsubscribe:
65
+
66
+ # Receives the next unsolicited message.
67
+ #
68
+ # @rbs (?timeout: Integer?) -> Message
69
+ def receive_notification: (?timeout: Integer?) -> Message
70
+
71
+ # Receives unsolicited messages.
72
+ #
73
+ # @rbs () { (Message) -> void } -> void
74
+ def each_notification: () { (Message) -> void } -> void
75
+
76
+ # Builds a asynchronous-operation facade.
77
+ #
78
+ # @rbs (Class operations_class, ?stream_capacity: Integer?) -> untyped
61
79
  private def build_async_facade: (Class operations_class, ?stream_capacity: Integer?) -> untyped
62
80
 
63
81
  private def exchange_message_async: (untyped kind, untyped request_class, untyped reply_class, untyped args, ?stream_capacity: untyped) -> untyped
@@ -21,6 +21,8 @@ module Nl
21
21
  class Protocol < Raw::Protocol
22
22
  def initialize: () -> untyped
23
23
 
24
+ private def decode_message: (untyped endpoint, untyped header, untyped decoder, untyped message_class) -> untyped
25
+
24
26
  def encode_message: (untyped encoder, untyped endpoint, untyped request, seq: untyped, pid: untyped) -> untyped
25
27
 
26
28
  def notification_channel_key: (untyped endpoint) -> untyped
@@ -31,7 +33,7 @@ module Nl
31
33
 
32
34
  def notification_frame?: (untyped endpoint, untyped header, untyped _payload) -> untyped
33
35
 
34
- def notification_class: (untyped endpoint, untyped header, untyped payload, untyped classes) -> untyped
36
+ def decode_notification: (untyped endpoint, untyped header, untyped payload, untyped classes) -> untyped
35
37
  end
36
38
  end
37
39
  end
@@ -31,20 +31,5 @@ module Nl
31
31
  def self.open: (resolver: ^(Client, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) -> (Nl::Family::Session & instance)
32
32
  | [R] (resolver: ^(Client, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
33
33
  end
34
-
35
- # Base class for Generic Netlink messages.
36
- #
37
- # A Generic Netlink message payload begins with a {GenlMsgHdr}, followed by
38
- # the optional fixed header and attributes handled by {Raw::Message}.
39
- class Message < Raw::Message
40
- # Decodes a Generic Netlink message payload.
41
- #
42
- # @param [Decoder] decoder the source decoder
43
- # @param [Integer] type the family ID from the Netlink message header
44
- # @return [Message] the decoded message
45
- # @raise [RuntimeError] if the command does not match the message class's type
46
- # @rbs (Decoder decoder, type: Integer) -> instance
47
- def self.decode: (Decoder decoder, type: Integer) -> instance
48
- end
49
34
  end
50
35
  end
@@ -0,0 +1,14 @@
1
+ # Generated from lib/nl/message.rb with RBS::Inline
2
+
3
+ module Nl
4
+ # Family payload with fixed-header fields and attribute values stored inline.
5
+ class Message
6
+ include Attributes
7
+
8
+ EMPTY_FIELD_NAMES: untyped
9
+
10
+ def self.from_params: (?untyped params) -> untyped
11
+
12
+ private def self.validate_params: (untyped params, untyped header_names, untyped attribute_names) -> untyped
13
+ end
14
+ end
@@ -42,7 +42,6 @@ module Nl
42
42
  # Closes the underlying Netlink connection.
43
43
  #
44
44
  # @return [void]
45
- # --
46
45
  # @rbs () -> void
47
46
  def close: () -> void
48
47
  end