nl 0.3.0 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Rakefile +7 -0
- data/lib/nl/async/dispatcher.rb +16 -16
- data/lib/nl/async/driver.rb +0 -2
- data/lib/nl/async/mailbox.rb +0 -2
- data/lib/nl/async/operation.rb +0 -2
- data/lib/nl/async.rb +0 -2
- data/lib/nl/attribute_set.rb +173 -0
- data/lib/nl/bitfield32.rb +86 -0
- data/lib/nl/blocking_transport.rb +12 -12
- data/lib/nl/connection.rb +7 -9
- data/lib/nl/datagram.rb +7 -9
- data/lib/nl/datatypes.rb +454 -0
- data/lib/nl/decoder.rb +4 -0
- data/lib/nl/endian.rb +10 -0
- data/lib/nl/exchange.rb +40 -18
- data/lib/nl/family.rb +18 -41
- data/lib/nl/genl/client.rb +104 -0
- data/lib/nl/genl/protocol.rb +59 -0
- data/lib/nl/genl/wire.rb +94 -0
- data/lib/nl/genl.rb +61 -61
- data/lib/nl/notification.rb +3 -6
- data/lib/nl/notification_router.rb +30 -23
- data/lib/nl/raw/client.rb +83 -0
- data/lib/nl/raw/protocol.rb +112 -0
- data/lib/nl/raw/wire.rb +146 -0
- data/lib/nl/raw.rb +104 -0
- data/lib/nl/sequence_allocator.rb +0 -2
- data/lib/nl/structured_payload.rb +61 -0
- data/lib/nl/sub_message.rb +94 -0
- data/lib/nl/version.rb +1 -1
- data/lib/nl.rb +5 -6
- data/sig/generated/nl/async/dispatcher.rbs +53 -0
- data/sig/generated/nl/async/driver.rbs +21 -0
- data/sig/generated/nl/async/mailbox.rbs +32 -0
- data/sig/generated/nl/async/operation.rbs +123 -0
- data/sig/generated/nl/async.rbs +9 -0
- data/sig/generated/nl/attribute_set.rbs +50 -0
- data/sig/generated/nl/bitfield32.rbs +41 -0
- data/sig/generated/nl/blocking_transport.rbs +33 -0
- data/sig/generated/nl/connection.rbs +26 -0
- data/sig/generated/nl/datagram.rbs +11 -0
- data/sig/generated/nl/datatypes.rbs +181 -0
- data/sig/generated/nl/decoder.rbs +38 -0
- data/sig/generated/nl/encoder.rbs +29 -0
- data/sig/generated/nl/endian.rbs +28 -0
- data/sig/generated/nl/error.rbs +27 -0
- data/sig/generated/nl/exchange.rbs +75 -0
- data/sig/generated/nl/family.rbs +71 -0
- data/sig/generated/nl/genl/client.rbs +74 -0
- data/sig/generated/nl/genl/protocol.rbs +37 -0
- data/sig/generated/nl/genl/wire.rbs +113 -0
- data/sig/generated/nl/genl.rbs +50 -0
- data/sig/generated/nl/notification.rbs +53 -0
- data/sig/generated/nl/notification_router.rbs +30 -0
- data/sig/generated/nl/raw/client.rbs +50 -0
- data/sig/generated/nl/raw/protocol.rbs +122 -0
- data/sig/generated/nl/raw/wire.rbs +151 -0
- data/sig/generated/nl/raw.rbs +70 -0
- data/sig/generated/nl/sequence_allocator.rbs +15 -0
- data/sig/generated/nl/socket.rbs +40 -0
- data/sig/generated/nl/structured_payload.rbs +25 -0
- data/sig/generated/nl/sub_message.rbs +74 -0
- data/sig/generated/nl/version.rbs +5 -0
- data/sig/generated/nl.rbs +2 -0
- metadata +48 -7
- data/lib/nl/core.rb +0 -94
- data/lib/nl/genl/connection.rb +0 -89
- data/lib/nl/protocols/genl.rb +0 -74
- data/lib/nl/protocols/raw.rb +0 -460
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Generated from lib/nl/exchange.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
# State machine for one Netlink request/reply exchange.
|
|
5
|
+
#
|
|
6
|
+
# Dump exchanges are known to be multipart from the request and remain open
|
|
7
|
+
# through NLMSG_DONE. Some Linux Generic Netlink dump handlers construct
|
|
8
|
+
# replies with genlmsg_iput(), which leaves NLM_F_MULTI unset despite that
|
|
9
|
+
# multipart lifetime. Dump mode therefore accepts data with or without the
|
|
10
|
+
# flag; reply mode still uses it to detect a multipart do response.
|
|
11
|
+
#
|
|
12
|
+
# Some operations also return multipart data for a do request, although YNL
|
|
13
|
+
# cannot declare such a reply. Reply mode handles this kernel behavior by
|
|
14
|
+
# retaining the first data message, draining the remainder, and completing
|
|
15
|
+
# on NLMSG_DONE instead of ACK.
|
|
16
|
+
class Exchange
|
|
17
|
+
class Item < Data
|
|
18
|
+
attr_reader value(): untyped
|
|
19
|
+
|
|
20
|
+
def self.new: (untyped value) -> instance
|
|
21
|
+
| (value: untyped) -> instance
|
|
22
|
+
|
|
23
|
+
def self.members: () -> [ :value ]
|
|
24
|
+
|
|
25
|
+
def members: () -> [ :value ]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class Complete < Data
|
|
29
|
+
def self.new: () -> instance
|
|
30
|
+
| () -> instance
|
|
31
|
+
|
|
32
|
+
def self.members: () -> [ ]
|
|
33
|
+
|
|
34
|
+
def members: () -> [ ]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
COMPLETE: untyped
|
|
38
|
+
|
|
39
|
+
class Failure < Data
|
|
40
|
+
attr_reader exception(): untyped
|
|
41
|
+
|
|
42
|
+
def self.new: (untyped exception) -> instance
|
|
43
|
+
| (exception: untyped) -> instance
|
|
44
|
+
|
|
45
|
+
def self.members: () -> [ :exception ]
|
|
46
|
+
|
|
47
|
+
def members: () -> [ :exception ]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
MODES: untyped
|
|
51
|
+
|
|
52
|
+
attr_reader mode: untyped
|
|
53
|
+
|
|
54
|
+
# @rbs (mode: :dump | :no_reply | :reply) -> void
|
|
55
|
+
def initialize: (mode: :dump | :no_reply | :reply) -> void
|
|
56
|
+
|
|
57
|
+
def accept: (untyped frame) -> untyped
|
|
58
|
+
|
|
59
|
+
def cancel: () -> untyped
|
|
60
|
+
|
|
61
|
+
def cancelled?: () -> untyped
|
|
62
|
+
|
|
63
|
+
def complete?: () -> untyped
|
|
64
|
+
|
|
65
|
+
def result: () -> untyped
|
|
66
|
+
|
|
67
|
+
private def accept_ack: () -> untyped
|
|
68
|
+
|
|
69
|
+
private def accept_reply: (untyped frame) -> untyped
|
|
70
|
+
|
|
71
|
+
private def complete: (untyped value) -> untyped
|
|
72
|
+
|
|
73
|
+
private def fail_with: (untyped exception) -> untyped
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Generated from lib/nl/family.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
type executor = :thread | :fiber
|
|
5
|
+
|
|
6
|
+
interface _Connection
|
|
7
|
+
def exchange: (Raw::Endpoint endpoint, Symbol kind, Class request_class, Class reply_class, Hash[Symbol, untyped] args) ?{ (untyped) -> void } -> untyped
|
|
8
|
+
|
|
9
|
+
def exchange_async: (Raw::Endpoint endpoint, Symbol kind, Class request_class, Class reply_class, Hash[Symbol, untyped] args, ?stream_capacity: Integer?) -> (Async::Future[untyped] | Async::Stream[untyped])
|
|
10
|
+
|
|
11
|
+
def async_capable?: () -> bool
|
|
12
|
+
|
|
13
|
+
def register_notifications: (Raw::Endpoint, Hash[Integer, Class]) -> NotificationChannel
|
|
14
|
+
|
|
15
|
+
def add_memberships: (Array[Integer]) -> nil
|
|
16
|
+
|
|
17
|
+
def drop_memberships: (Array[Integer]) -> nil
|
|
18
|
+
|
|
19
|
+
def receive_notification: (Raw::Endpoint, ?timeout: Numeric?) -> untyped
|
|
20
|
+
|
|
21
|
+
def close: () -> nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
interface _FamilyClass[out F]
|
|
25
|
+
def new: (_Connection, endpoint: Raw::Endpoint) -> F
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class Family
|
|
29
|
+
DEFAULT_NOTIFICATION_CAPACITY: untyped
|
|
30
|
+
|
|
31
|
+
module Session
|
|
32
|
+
def close: () -> nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# --
|
|
36
|
+
# @rbs connection: _Connection
|
|
37
|
+
# @rbs endpoint: Raw::Endpoint
|
|
38
|
+
# @rbs return: instance
|
|
39
|
+
def initialize: (_Connection connection, endpoint: Raw::Endpoint) -> instance
|
|
40
|
+
|
|
41
|
+
private def exchange_message: (untyped kind, untyped request_class, untyped reply_class, untyped args) ?{ (?) -> untyped } -> untyped
|
|
42
|
+
|
|
43
|
+
def async_capable?: () -> bool
|
|
44
|
+
|
|
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
|
|
61
|
+
private def build_async_facade: (Class operations_class, ?stream_capacity: Integer?) -> untyped
|
|
62
|
+
|
|
63
|
+
private def exchange_message_async: (untyped kind, untyped request_class, untyped reply_class, untyped args, ?stream_capacity: untyped) -> untyped
|
|
64
|
+
|
|
65
|
+
private def notification_classes: () -> untyped
|
|
66
|
+
|
|
67
|
+
private def multicast_groups: () -> untyped
|
|
68
|
+
|
|
69
|
+
private def multicast_group_ids: (untyped names) -> untyped
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Generated from lib/nl/genl/client.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
module Genl
|
|
5
|
+
# Dynamically resolved information for a generic Netlink family.
|
|
6
|
+
#
|
|
7
|
+
# @!attribute [r] id
|
|
8
|
+
# @return [Integer] the assigned family ID
|
|
9
|
+
# @!attribute [r] multicast_groups
|
|
10
|
+
# @return [Hash<String, Integer>] multicast group names mapped to their IDs
|
|
11
|
+
class FamilyInfo < Data
|
|
12
|
+
attr_reader id(): Integer
|
|
13
|
+
|
|
14
|
+
attr_reader multicast_groups(): Hash[String, Integer]
|
|
15
|
+
|
|
16
|
+
def self.new: (Integer id, Hash[String, Integer] multicast_groups) -> instance
|
|
17
|
+
| (id: Integer, multicast_groups: Hash[String, Integer]) -> instance
|
|
18
|
+
|
|
19
|
+
def self.members: () -> [ :id, :multicast_groups ]
|
|
20
|
+
|
|
21
|
+
def members: () -> [ :id, :multicast_groups ]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Owns one generic Netlink connection shared by compatible families.
|
|
25
|
+
class Client
|
|
26
|
+
# Opens a generic Netlink client.
|
|
27
|
+
#
|
|
28
|
+
# @overload open(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY)
|
|
29
|
+
# The caller is responsible for closing the client.
|
|
30
|
+
# @param [#call] resolver a callable that resolves a family name to {FamilyInfo}
|
|
31
|
+
# @param [:thread, :fiber, nil] executor the asynchronous executor, or `nil` for blocking operation
|
|
32
|
+
# @param [Integer] notification_capacity the maximum number of queued notifications
|
|
33
|
+
# @return [Client] the opened client
|
|
34
|
+
# @overload open(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY, &block)
|
|
35
|
+
# The client is automatically closed after the block returns.
|
|
36
|
+
# @param [#call] resolver a callable that resolves a family name to {FamilyInfo}
|
|
37
|
+
# @param [:thread, :fiber, nil] executor the asynchronous executor, or `nil` for blocking operation
|
|
38
|
+
# @param [Integer] notification_capacity the maximum number of queued notifications
|
|
39
|
+
# @yieldparam [Client] client the opened client
|
|
40
|
+
# @return [Object] the value returned from the block
|
|
41
|
+
# @rbs (resolver: ^(instance, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) -> instance
|
|
42
|
+
# | [R] (resolver: ^(instance, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
|
|
43
|
+
def self.open: (resolver: ^(instance, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) -> instance
|
|
44
|
+
| [R] (resolver: ^(instance, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
|
|
45
|
+
|
|
46
|
+
# @param [#call] resolver a callable that resolves a family name to {FamilyInfo}
|
|
47
|
+
# @param [:thread, :fiber, nil] executor the asynchronous executor, or `nil` for blocking operation
|
|
48
|
+
# @param [Integer] notification_capacity the maximum number of queued notifications
|
|
49
|
+
# @rbs (resolver: ^(instance, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) -> void
|
|
50
|
+
def initialize: (resolver: ^(instance, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) -> void
|
|
51
|
+
|
|
52
|
+
# Builds a family backed by this client's connection.
|
|
53
|
+
#
|
|
54
|
+
# @param [Class<Family>] family_class a generic Netlink family class
|
|
55
|
+
# @return [Family] an instance of `family_class`
|
|
56
|
+
# @raise [TypeError] if +family_class+ does not inherit from {Family}
|
|
57
|
+
# @rbs [F < Family] (_FamilyClass[F] family_class) -> F
|
|
58
|
+
def family: [F < Family] (_FamilyClass[F] family_class) -> F
|
|
59
|
+
|
|
60
|
+
# Closes the underlying Netlink connection.
|
|
61
|
+
#
|
|
62
|
+
# @return [void]
|
|
63
|
+
# @rbs () -> void
|
|
64
|
+
def close: () -> void
|
|
65
|
+
|
|
66
|
+
# Resolves and caches information for a family by name.
|
|
67
|
+
#
|
|
68
|
+
# @param [String] name the generic Netlink family name
|
|
69
|
+
# @return [FamilyInfo] the resolved family information
|
|
70
|
+
# @rbs (String name) -> FamilyInfo
|
|
71
|
+
private def family_info: (String name) -> FamilyInfo
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Generated from lib/nl/genl/protocol.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
module Genl
|
|
5
|
+
# A generated Generic Netlink family bound to nlctrl-provided information.
|
|
6
|
+
class Endpoint < Raw::Endpoint
|
|
7
|
+
attr_reader info: untyped
|
|
8
|
+
|
|
9
|
+
def initialize: (untyped definition, untyped info) -> untyped
|
|
10
|
+
|
|
11
|
+
def family_id: () -> untyped
|
|
12
|
+
|
|
13
|
+
def version: () -> untyped
|
|
14
|
+
|
|
15
|
+
def frame_type: (untyped _message_class) -> untyped
|
|
16
|
+
|
|
17
|
+
def multicast_group_id: (untyped name, untyped _value) -> untyped
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Socket-wide Generic Netlink wire behavior.
|
|
21
|
+
class Protocol < Raw::Protocol
|
|
22
|
+
def initialize: () -> untyped
|
|
23
|
+
|
|
24
|
+
def encode_message: (untyped encoder, untyped endpoint, untyped request, seq: untyped, pid: untyped) -> untyped
|
|
25
|
+
|
|
26
|
+
def notification_channel_key: (untyped endpoint) -> untyped
|
|
27
|
+
|
|
28
|
+
def notification_route_keys: (untyped endpoint, untyped _classes) -> untyped
|
|
29
|
+
|
|
30
|
+
def notification_frame_key: (untyped header) -> untyped
|
|
31
|
+
|
|
32
|
+
def notification_frame?: (untyped endpoint, untyped header, untyped _payload) -> untyped
|
|
33
|
+
|
|
34
|
+
def notification_class: (untyped endpoint, untyped header, untyped payload, untyped classes) -> untyped
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Generated from lib/nl/genl/wire.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
module Genl
|
|
5
|
+
# Constants from <linux/genetlink.h>
|
|
6
|
+
module Constants
|
|
7
|
+
GENL_NAMSIZ: ::Integer
|
|
8
|
+
|
|
9
|
+
GENL_MIN_ID: untyped
|
|
10
|
+
|
|
11
|
+
GENL_MAX_ID: ::Integer
|
|
12
|
+
|
|
13
|
+
GENL_HDRLEN: ::Integer
|
|
14
|
+
|
|
15
|
+
GENL_ID_GENERATE: ::Integer
|
|
16
|
+
|
|
17
|
+
GENL_ID_CTRL: untyped
|
|
18
|
+
|
|
19
|
+
GENL_ID_VFS_DQUOT: untyped
|
|
20
|
+
|
|
21
|
+
GENL_ID_PMCRAID: untyped
|
|
22
|
+
|
|
23
|
+
CTRL_CMD_UNSPEC: ::Integer
|
|
24
|
+
|
|
25
|
+
CTRL_CMD_NEWFAMILY: ::Integer
|
|
26
|
+
|
|
27
|
+
CTRL_CMD_DELFAMILY: ::Integer
|
|
28
|
+
|
|
29
|
+
CTRL_CMD_GETFAMILY: ::Integer
|
|
30
|
+
|
|
31
|
+
CTRL_CMD_NEWOPS: ::Integer
|
|
32
|
+
|
|
33
|
+
CTRL_CMD_DELOPS: ::Integer
|
|
34
|
+
|
|
35
|
+
CTRL_CMD_GETOPS: ::Integer
|
|
36
|
+
|
|
37
|
+
CTRL_CMD_NEWMCAST_GRP: ::Integer
|
|
38
|
+
|
|
39
|
+
CTRL_CMD_DELMCAST_GRP: ::Integer
|
|
40
|
+
|
|
41
|
+
CTRL_CMD_GETMCAST_GRP: ::Integer
|
|
42
|
+
|
|
43
|
+
CTRL_ATTR_UNSPEC: ::Integer
|
|
44
|
+
|
|
45
|
+
CTRL_ATTR_FAMILY_ID: ::Integer
|
|
46
|
+
|
|
47
|
+
CTRL_ATTR_FAMILY_NAME: ::Integer
|
|
48
|
+
|
|
49
|
+
CTRL_ATTR_VERSION: ::Integer
|
|
50
|
+
|
|
51
|
+
CTRL_ATTR_HDRSIZE: ::Integer
|
|
52
|
+
|
|
53
|
+
CTRL_ATTR_MAXATTR: ::Integer
|
|
54
|
+
|
|
55
|
+
CTRL_ATTR_OPS: ::Integer
|
|
56
|
+
|
|
57
|
+
CTRL_ATTR_MCAST_GROUPS: ::Integer
|
|
58
|
+
|
|
59
|
+
CTRL_ATTR_OP_UNSPEC: ::Integer
|
|
60
|
+
|
|
61
|
+
CTRL_ATTR_OP_ID: ::Integer
|
|
62
|
+
|
|
63
|
+
CTRL_ATTR_OP_FLAGS: ::Integer
|
|
64
|
+
|
|
65
|
+
CTRL_ATTR_MCAST_GRP_UNSPEC: ::Integer
|
|
66
|
+
|
|
67
|
+
CTRL_ATTR_MCAST_GRP_NAME: ::Integer
|
|
68
|
+
|
|
69
|
+
CTRL_ATTR_MCAST_GRP_ID: ::Integer
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
include Constants
|
|
73
|
+
|
|
74
|
+
# Header prepended to a Generic Netlink payload after the Netlink header.
|
|
75
|
+
#
|
|
76
|
+
# This corresponds to Linux's +struct genlmsghdr+.
|
|
77
|
+
#
|
|
78
|
+
# @!attribute [rw] cmd
|
|
79
|
+
# @return [Integer] family-specific command identifier
|
|
80
|
+
# @!attribute [rw] version
|
|
81
|
+
# @return [Integer] family-specific protocol version
|
|
82
|
+
# @!attribute [rw] reserved
|
|
83
|
+
# @return [Integer] reserved field, which must be zero
|
|
84
|
+
class GenlMsgHdr < Struct[Integer]
|
|
85
|
+
attr_accessor cmd(): Integer
|
|
86
|
+
|
|
87
|
+
attr_accessor version(): Integer
|
|
88
|
+
|
|
89
|
+
attr_accessor reserved(): Integer
|
|
90
|
+
|
|
91
|
+
def self.new: (?Integer cmd, ?Integer version, ?Integer reserved) -> instance
|
|
92
|
+
| (?cmd: Integer, ?version: Integer, ?reserved: Integer) -> instance
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class GenlMsgHdr
|
|
96
|
+
FORMAT: untyped
|
|
97
|
+
|
|
98
|
+
# Decodes a header from the decoder's current position.
|
|
99
|
+
#
|
|
100
|
+
# @param [Decoder] decoder the source decoder
|
|
101
|
+
# @return [GenlMsgHdr] the decoded header
|
|
102
|
+
# @rbs (Decoder decoder) -> instance
|
|
103
|
+
def self.decode: (Decoder decoder) -> instance
|
|
104
|
+
|
|
105
|
+
# Encodes this header at the encoder's current position.
|
|
106
|
+
#
|
|
107
|
+
# @param [Encoder] encoder the destination encoder
|
|
108
|
+
# @return [void]
|
|
109
|
+
# @rbs (Encoder encoder) -> void
|
|
110
|
+
def encode: (Encoder encoder) -> void
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Generated from lib/nl/genl.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
# Generic Netlink families.
|
|
5
|
+
module Genl
|
|
6
|
+
# Base class for Generic Netlink families.
|
|
7
|
+
class Family < Nl::Family
|
|
8
|
+
# Returns the family-specific protocol version.
|
|
9
|
+
#
|
|
10
|
+
# @return [Integer] the protocol version
|
|
11
|
+
# @rbs () -> Integer
|
|
12
|
+
def self.version: () -> Integer
|
|
13
|
+
|
|
14
|
+
# Opens a session for this Generic Netlink family.
|
|
15
|
+
#
|
|
16
|
+
# @overload open(resolver:, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY)
|
|
17
|
+
# The caller is responsible for closing the session.
|
|
18
|
+
# @param [#call] resolver a callable that resolves a family name to {FamilyInfo}
|
|
19
|
+
# @param [:thread, :fiber, nil] executor the asynchronous executor, or `nil` for blocking operation
|
|
20
|
+
# @param [Integer] notification_capacity the maximum number of queued notifications
|
|
21
|
+
# @return [Family] the opened family session
|
|
22
|
+
# @overload open(resolver:, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY, &block)
|
|
23
|
+
# The session is automatically closed after the block returns.
|
|
24
|
+
# @param [#call] resolver a callable that resolves a family name to {FamilyInfo}
|
|
25
|
+
# @param [:thread, :fiber, nil] executor the asynchronous executor, or `nil` for blocking operation
|
|
26
|
+
# @param [Integer] notification_capacity the maximum number of queued notifications
|
|
27
|
+
# @yieldparam [Family] session the opened family session
|
|
28
|
+
# @return [Object] the value returned from the block
|
|
29
|
+
# @rbs (resolver: ^(Client, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) -> (Nl::Family::Session & instance)
|
|
30
|
+
# | [R] (resolver: ^(Client, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
|
|
31
|
+
def self.open: (resolver: ^(Client, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) -> (Nl::Family::Session & instance)
|
|
32
|
+
| [R] (resolver: ^(Client, ::String) -> FamilyInfo, ?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
|
|
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
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Generated from lib/nl/notification.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
# A multicast group. `name` is the kernel-facing name.
|
|
5
|
+
# `id` is the fixed ID when the specification provides one.
|
|
6
|
+
class McastGroup < Data
|
|
7
|
+
attr_reader name(): untyped
|
|
8
|
+
|
|
9
|
+
attr_reader id(): untyped
|
|
10
|
+
|
|
11
|
+
def self.new: (untyped name, untyped id) -> instance
|
|
12
|
+
| (name: untyped, id: untyped) -> instance
|
|
13
|
+
|
|
14
|
+
def self.members: () -> [ :name, :id ]
|
|
15
|
+
|
|
16
|
+
def members: () -> [ :name, :id ]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Thread-safe queue shared by a family's blocking and asynchronous facades.
|
|
20
|
+
class NotificationChannel
|
|
21
|
+
def initialize: (capacity: untyped) -> untyped
|
|
22
|
+
|
|
23
|
+
# Adds a notification without ever blocking the socket receive loop.
|
|
24
|
+
# Returns false after the channel has been closed.
|
|
25
|
+
def push: (untyped notification) -> untyped
|
|
26
|
+
|
|
27
|
+
# Records a broken notification boundary while allowing later delivery to
|
|
28
|
+
# resume after the consumer observes the error and resynchronizes state.
|
|
29
|
+
def fail: (untyped error) -> untyped
|
|
30
|
+
|
|
31
|
+
def pop: (?timeout: untyped) -> untyped
|
|
32
|
+
|
|
33
|
+
def empty?: () -> untyped
|
|
34
|
+
|
|
35
|
+
def close: () -> untyped
|
|
36
|
+
|
|
37
|
+
private def lose!: (untyped error) -> untyped
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# An unbounded-in-time, single-family view of unsolicited messages.
|
|
41
|
+
class NotificationStream
|
|
42
|
+
include Enumerable[untyped]
|
|
43
|
+
|
|
44
|
+
def initialize: () ?{ (?) -> untyped } -> untyped
|
|
45
|
+
|
|
46
|
+
def next: (?timeout: untyped) -> untyped
|
|
47
|
+
|
|
48
|
+
# @rbs () -> Enumerator[untyped, void]
|
|
49
|
+
# | () { (untyped) -> void } -> void
|
|
50
|
+
def each: () -> Enumerator[untyped, void]
|
|
51
|
+
| () { (untyped) -> void } -> void
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Generated from lib/nl/notification_router.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
# Routes unsolicited frames to per-family notification channels.
|
|
5
|
+
class NotificationRouter
|
|
6
|
+
class Entry < Struct[untyped]
|
|
7
|
+
attr_accessor endpoint(): untyped
|
|
8
|
+
|
|
9
|
+
attr_accessor classes(): untyped
|
|
10
|
+
|
|
11
|
+
attr_accessor channel(): untyped
|
|
12
|
+
|
|
13
|
+
def self.new: (?untyped endpoint, ?untyped classes, ?untyped channel) -> instance
|
|
14
|
+
| (?endpoint: untyped, ?classes: untyped, ?channel: untyped) -> instance
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def initialize: (protocol: untyped, capacity: untyped) -> untyped
|
|
18
|
+
|
|
19
|
+
def register: (untyped endpoint, untyped classes) -> untyped
|
|
20
|
+
|
|
21
|
+
def channel: (untyped endpoint) -> untyped
|
|
22
|
+
|
|
23
|
+
# Returns true if the frame belongs to a registered notification family.
|
|
24
|
+
def route: (untyped header, untyped payload) -> untyped
|
|
25
|
+
|
|
26
|
+
def close: () -> untyped
|
|
27
|
+
|
|
28
|
+
def lose_all: (untyped error) -> untyped
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Generated from lib/nl/raw/client.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
module Raw
|
|
5
|
+
# Owns one raw Netlink connection shared by compatible families.
|
|
6
|
+
class Client
|
|
7
|
+
# Opens a client for a raw Netlink protocol.
|
|
8
|
+
#
|
|
9
|
+
# @overload open(protonum:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY)
|
|
10
|
+
# The caller is responsible for closing the client.
|
|
11
|
+
# @param [Integer] protonum the Netlink protocol number
|
|
12
|
+
# @param [:thread, :fiber, nil] executor the asynchronous executor, or `nil` for blocking operation
|
|
13
|
+
# @param [Integer] notification_capacity the maximum number of queued notifications
|
|
14
|
+
# @return [Client] the opened client
|
|
15
|
+
# @overload open(protonum:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY, &block)
|
|
16
|
+
# The client is automatically closed after the block returns.
|
|
17
|
+
# @param [Integer] protonum the Netlink protocol number
|
|
18
|
+
# @param [:thread, :fiber, nil] executor the asynchronous executor, or `nil` for blocking operation
|
|
19
|
+
# @param [Integer] notification_capacity the maximum number of queued notifications
|
|
20
|
+
# @yieldparam [Client] client the opened client
|
|
21
|
+
# @return [Object] the value returned from the block
|
|
22
|
+
# @rbs (protonum: Integer, ?executor: executor?, ?notification_capacity: Integer?) -> instance
|
|
23
|
+
# | [R] (protonum: Integer, ?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
|
|
24
|
+
def self.open: (protonum: Integer, ?executor: executor?, ?notification_capacity: Integer?) -> instance
|
|
25
|
+
| [R] (protonum: Integer, ?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
|
|
26
|
+
|
|
27
|
+
# @param [Integer] protonum the Netlink protocol number
|
|
28
|
+
# @param [:thread, :fiber, nil] executor the asynchronous executor, or `nil` for blocking operation
|
|
29
|
+
# @param [Integer] notification_capacity the maximum number of queued notifications
|
|
30
|
+
# @rbs (protonum: Integer, ?executor: executor?, ?notification_capacity: Integer?) -> void
|
|
31
|
+
def initialize: (protonum: Integer, ?executor: executor?, ?notification_capacity: Integer?) -> void
|
|
32
|
+
|
|
33
|
+
# Builds a family backed by this client's connection.
|
|
34
|
+
#
|
|
35
|
+
# @param [Class<Family>] family_class a raw Netlink family class
|
|
36
|
+
# @return [Family] an instance of `family_class`
|
|
37
|
+
# @raise [TypeError] if +family_class+ does not inherit from {Family}
|
|
38
|
+
# @raise [ArgumentError] if the family's protocol number differs from the client's protocol number
|
|
39
|
+
# @rbs [F < Family] (_FamilyClass[F] family_class) -> F
|
|
40
|
+
def family: [F < Family] (_FamilyClass[F] family_class) -> F
|
|
41
|
+
|
|
42
|
+
# Closes the underlying Netlink connection.
|
|
43
|
+
#
|
|
44
|
+
# @return [void]
|
|
45
|
+
# --
|
|
46
|
+
# @rbs () -> void
|
|
47
|
+
def close: () -> void
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Generated from lib/nl/raw/protocol.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
module Raw
|
|
5
|
+
class AckFrame < Data
|
|
6
|
+
attr_reader header(): untyped
|
|
7
|
+
|
|
8
|
+
def self.new: (untyped header) -> instance
|
|
9
|
+
| (header: untyped) -> instance
|
|
10
|
+
|
|
11
|
+
def self.members: () -> [ :header ]
|
|
12
|
+
|
|
13
|
+
def members: () -> [ :header ]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class ErrorFrame < Data
|
|
17
|
+
attr_reader header(): untyped
|
|
18
|
+
|
|
19
|
+
attr_reader errno(): untyped
|
|
20
|
+
|
|
21
|
+
def self.new: (untyped header, untyped errno) -> instance
|
|
22
|
+
| (header: untyped, errno: untyped) -> instance
|
|
23
|
+
|
|
24
|
+
def self.members: () -> [ :header, :errno ]
|
|
25
|
+
|
|
26
|
+
def members: () -> [ :header, :errno ]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class DoneFrame < Data
|
|
30
|
+
attr_reader header(): untyped
|
|
31
|
+
|
|
32
|
+
attr_reader errno(): untyped
|
|
33
|
+
|
|
34
|
+
def self.new: (untyped header, untyped errno) -> instance
|
|
35
|
+
| (header: untyped, errno: untyped) -> instance
|
|
36
|
+
|
|
37
|
+
def self.members: () -> [ :header, :errno ]
|
|
38
|
+
|
|
39
|
+
def members: () -> [ :header, :errno ]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class UnknownFrame < Data
|
|
43
|
+
attr_reader header(): untyped
|
|
44
|
+
|
|
45
|
+
def self.new: (untyped header) -> instance
|
|
46
|
+
| (header: untyped) -> instance
|
|
47
|
+
|
|
48
|
+
def self.members: () -> [ :header ]
|
|
49
|
+
|
|
50
|
+
def members: () -> [ :header ]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class DataFrame < Data
|
|
54
|
+
attr_reader header(): untyped
|
|
55
|
+
|
|
56
|
+
attr_reader message(): untyped
|
|
57
|
+
|
|
58
|
+
def self.new: (untyped header, untyped message) -> instance
|
|
59
|
+
| (header: untyped, message: untyped) -> instance
|
|
60
|
+
|
|
61
|
+
def self.members: () -> [ :header, :message ]
|
|
62
|
+
|
|
63
|
+
def members: () -> [ :header, :message ]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class Request < Data
|
|
67
|
+
attr_reader type(): untyped
|
|
68
|
+
|
|
69
|
+
attr_reader flags(): untyped
|
|
70
|
+
|
|
71
|
+
attr_reader message(): untyped
|
|
72
|
+
|
|
73
|
+
def self.new: (untyped type, untyped flags, untyped message) -> instance
|
|
74
|
+
| (type: untyped, flags: untyped, message: untyped) -> instance
|
|
75
|
+
|
|
76
|
+
def self.members: () -> [ :type, :flags, :message ]
|
|
77
|
+
|
|
78
|
+
def members: () -> [ :type, :flags, :message ]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# A generated raw Netlink family bound to its fixed wire identity.
|
|
82
|
+
class Endpoint
|
|
83
|
+
attr_reader definition: untyped
|
|
84
|
+
|
|
85
|
+
def initialize: (untyped definition) -> untyped
|
|
86
|
+
|
|
87
|
+
def name: () -> untyped
|
|
88
|
+
|
|
89
|
+
def frame_type: (untyped message_class) -> untyped
|
|
90
|
+
|
|
91
|
+
def multicast_group_id: (untyped name, untyped value) -> untyped
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Socket-wide wire behavior for a classic (netlink-raw) protocol.
|
|
95
|
+
class Protocol
|
|
96
|
+
attr_reader protonum: untyped
|
|
97
|
+
|
|
98
|
+
def initialize: (untyped protonum) -> untyped
|
|
99
|
+
|
|
100
|
+
def encode_message: (untyped encoder, untyped _endpoint, untyped request, seq: untyped, pid: untyped) -> untyped
|
|
101
|
+
|
|
102
|
+
# Decodes one frame using the reply class associated with its sequence.
|
|
103
|
+
def decode_frame: (untyped _endpoint, untyped header, untyped payload, untyped message_class) -> untyped
|
|
104
|
+
|
|
105
|
+
def send_message: (untyped socket, untyped endpoint, untyped request, seq: untyped, pid: untyped) -> untyped
|
|
106
|
+
|
|
107
|
+
def build_request: (untyped endpoint, untyped kind, untyped request_class, untyped args) -> untyped
|
|
108
|
+
|
|
109
|
+
def notification_channel_key: (untyped endpoint) -> untyped
|
|
110
|
+
|
|
111
|
+
def notification_route_keys: (untyped _endpoint, untyped classes) -> untyped
|
|
112
|
+
|
|
113
|
+
def notification_frame_key: (untyped header) -> untyped
|
|
114
|
+
|
|
115
|
+
def notification_frame?: (untyped _endpoint, untyped header, untyped _payload) -> untyped
|
|
116
|
+
|
|
117
|
+
def notification_class: (untyped _endpoint, untyped header, untyped _payload, untyped classes) -> untyped
|
|
118
|
+
|
|
119
|
+
def decode_notification: (untyped endpoint, untyped header, untyped payload, untyped message_class) -> untyped
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|