nl 0.3.0 → 0.4.2
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 +15 -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 +9 -0
- data/lib/nl/exchange.rb +40 -18
- data/lib/nl/family.rb +50 -55
- data/lib/nl/genl/client.rb +105 -0
- data/lib/nl/genl/protocol.rb +59 -0
- data/lib/nl/genl/wire.rb +95 -0
- data/lib/nl/genl.rb +60 -62
- 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 +147 -0
- data/lib/nl/raw.rb +104 -0
- data/lib/nl/sequence_allocator.rb +0 -2
- data/lib/nl/socket.rb +21 -5
- 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 +29 -0
- data/sig/generated/nl/error.rbs +27 -0
- data/sig/generated/nl/exchange.rbs +75 -0
- data/sig/generated/nl/family.rbs +89 -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 +49 -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 +59 -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,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,49 @@
|
|
|
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
|
+
# @rbs () -> void
|
|
46
|
+
def close: () -> void
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
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
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Generated from lib/nl/raw/wire.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
module Raw
|
|
5
|
+
# Constants from <linux/netlink.h>
|
|
6
|
+
module Constants
|
|
7
|
+
NETLINK_ROUTE: ::Integer
|
|
8
|
+
|
|
9
|
+
NETLINK_NETFILTER: ::Integer
|
|
10
|
+
|
|
11
|
+
NETLINK_GENERIC: ::Integer
|
|
12
|
+
|
|
13
|
+
NLM_F_REQUEST: ::Integer
|
|
14
|
+
|
|
15
|
+
NLM_F_MULTI: ::Integer
|
|
16
|
+
|
|
17
|
+
NLM_F_ACK: ::Integer
|
|
18
|
+
|
|
19
|
+
NLM_F_ECHO: ::Integer
|
|
20
|
+
|
|
21
|
+
NLM_F_DUMP_INTR: ::Integer
|
|
22
|
+
|
|
23
|
+
NLM_F_DUMP_FILTERED: ::Integer
|
|
24
|
+
|
|
25
|
+
NLM_F_ROOT: ::Integer
|
|
26
|
+
|
|
27
|
+
NLM_F_MATCH: ::Integer
|
|
28
|
+
|
|
29
|
+
NLM_F_ATOMIC: ::Integer
|
|
30
|
+
|
|
31
|
+
NLM_F_DUMP: untyped
|
|
32
|
+
|
|
33
|
+
NLM_F_REPLACE: ::Integer
|
|
34
|
+
|
|
35
|
+
NLM_F_EXCL: ::Integer
|
|
36
|
+
|
|
37
|
+
NLM_F_CREATE: ::Integer
|
|
38
|
+
|
|
39
|
+
NLM_F_APPEND: ::Integer
|
|
40
|
+
|
|
41
|
+
NLMSG_ALIGNTO: ::Integer
|
|
42
|
+
|
|
43
|
+
NLMSG_HDRLEN: ::Integer
|
|
44
|
+
|
|
45
|
+
NLMSG_NOOP: ::Integer
|
|
46
|
+
|
|
47
|
+
NLMSG_ERROR: ::Integer
|
|
48
|
+
|
|
49
|
+
NLMSG_DONE: ::Integer
|
|
50
|
+
|
|
51
|
+
NLMSG_OVERRUN: ::Integer
|
|
52
|
+
|
|
53
|
+
NLMSG_MIN_TYPE: ::Integer
|
|
54
|
+
|
|
55
|
+
NLA_F_NESTED: untyped
|
|
56
|
+
|
|
57
|
+
NLA_F_NET_BYTEORDER: untyped
|
|
58
|
+
|
|
59
|
+
NLA_TYPE_MASK: untyped
|
|
60
|
+
|
|
61
|
+
NLA_ALIGNTO: ::Integer
|
|
62
|
+
|
|
63
|
+
NLA_HDRLEN: ::Integer
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
include Constants
|
|
67
|
+
|
|
68
|
+
# Fixed-format metadata header prepended to every Netlink message.
|
|
69
|
+
#
|
|
70
|
+
# This corresponds to Linux's +struct nlmsghdr+.
|
|
71
|
+
#
|
|
72
|
+
# @!attribute [rw] len
|
|
73
|
+
# @return [Integer] message length in bytes, including this header
|
|
74
|
+
# @!attribute [rw] type
|
|
75
|
+
# @return [Integer] message content type
|
|
76
|
+
# @!attribute [rw] flags
|
|
77
|
+
# @return [Integer] bitwise combination of +NLM_F_+ flags
|
|
78
|
+
# @!attribute [rw] seq
|
|
79
|
+
# @return [Integer] sequence number used to correlate requests and replies
|
|
80
|
+
# @!attribute [rw] pid
|
|
81
|
+
# @return [Integer] sender's Netlink port ID
|
|
82
|
+
class NlMsgHdr < Struct[Integer]
|
|
83
|
+
attr_accessor len(): Integer
|
|
84
|
+
|
|
85
|
+
attr_accessor type(): Integer
|
|
86
|
+
|
|
87
|
+
attr_accessor flags(): Integer
|
|
88
|
+
|
|
89
|
+
attr_accessor seq(): Integer
|
|
90
|
+
|
|
91
|
+
attr_accessor pid(): Integer
|
|
92
|
+
|
|
93
|
+
def self.new: (?Integer len, ?Integer type, ?Integer flags, ?Integer seq, ?Integer pid) -> instance
|
|
94
|
+
| (?len: Integer, ?type: Integer, ?flags: Integer, ?seq: Integer, ?pid: Integer) -> instance
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
class NlMsgHdr
|
|
98
|
+
FORMAT: untyped
|
|
99
|
+
|
|
100
|
+
# Decodes a header from the decoder's current position.
|
|
101
|
+
#
|
|
102
|
+
# @param [Decoder] decoder the source decoder
|
|
103
|
+
# @return [NlMsgHdr] the decoded header
|
|
104
|
+
# @rbs (Decoder decoder) -> instance
|
|
105
|
+
def self.decode: (Decoder decoder) -> instance
|
|
106
|
+
|
|
107
|
+
# Encodes this header at the encoder's current position.
|
|
108
|
+
#
|
|
109
|
+
# @param [Encoder] encoder the destination encoder
|
|
110
|
+
# @return [void]
|
|
111
|
+
# @rbs (Encoder encoder) -> void
|
|
112
|
+
def encode: (Encoder encoder) -> void
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Fixed-format header prepended to every Netlink attribute.
|
|
116
|
+
#
|
|
117
|
+
# This corresponds to Linux's +struct nlattr+.
|
|
118
|
+
#
|
|
119
|
+
# @!attribute [rw] len
|
|
120
|
+
# @return [Integer] attribute length in bytes, including this header but
|
|
121
|
+
# excluding trailing alignment padding
|
|
122
|
+
# @!attribute [rw] type
|
|
123
|
+
# @return [Integer] attribute type combined with optional +NLA_F_+ flags
|
|
124
|
+
class NlAttr < Struct[Integer]
|
|
125
|
+
attr_accessor len(): Integer
|
|
126
|
+
|
|
127
|
+
attr_accessor type(): Integer
|
|
128
|
+
|
|
129
|
+
def self.new: (?Integer len, ?Integer type) -> instance
|
|
130
|
+
| (?len: Integer, ?type: Integer) -> instance
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
class NlAttr
|
|
134
|
+
FORMAT: untyped
|
|
135
|
+
|
|
136
|
+
# Decodes an attribute header from the decoder's current position.
|
|
137
|
+
#
|
|
138
|
+
# @param [Decoder] decoder the source decoder
|
|
139
|
+
# @return [NlAttr] the decoded header
|
|
140
|
+
# @rbs (Decoder decoder) -> instance
|
|
141
|
+
def self.decode: (Decoder decoder) -> instance
|
|
142
|
+
|
|
143
|
+
# Encodes this attribute header at the encoder's current position.
|
|
144
|
+
#
|
|
145
|
+
# @param [Encoder] encoder the destination encoder
|
|
146
|
+
# @return [void]
|
|
147
|
+
# @rbs (Encoder encoder) -> void
|
|
148
|
+
def encode: (Encoder encoder) -> void
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Generated from lib/nl/raw.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
# Classic (Raw) Netlink families.
|
|
5
|
+
module Raw
|
|
6
|
+
# Base class for Raw Netlink families.
|
|
7
|
+
class Family < Nl::Family
|
|
8
|
+
# Opens a session for this raw Netlink family.
|
|
9
|
+
#
|
|
10
|
+
# @overload open(executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY)
|
|
11
|
+
# The caller is responsible for closing the session.
|
|
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 [Family] the opened family session
|
|
15
|
+
# @overload open(executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY, &block)
|
|
16
|
+
# The session is automatically closed after the block returns.
|
|
17
|
+
# @param [:thread, :fiber, nil] executor the asynchronous executor, or `nil` for blocking operation
|
|
18
|
+
# @param [Integer] notification_capacity the maximum number of queued notifications
|
|
19
|
+
# @yieldparam [Family] session the opened family session
|
|
20
|
+
# @return [Object] the value returned from the block
|
|
21
|
+
# @rbs (?executor: executor?, ?notification_capacity: Integer?) -> (Nl::Family::Session & instance)
|
|
22
|
+
# | [R] (?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
|
|
23
|
+
def self.open: (?executor: executor?, ?notification_capacity: Integer?) -> (Nl::Family::Session & instance)
|
|
24
|
+
| [R] (?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
|
|
25
|
+
|
|
26
|
+
# Builds a session that owns its underlying client.
|
|
27
|
+
#
|
|
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
|
+
# @return [Family] the opened family session
|
|
31
|
+
# @rbs (executor: executor?, notification_capacity: Integer) -> (Nl::Family::Session & instance)
|
|
32
|
+
private def self.build_session: (executor: executor?, notification_capacity: Integer) -> (Nl::Family::Session & instance)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Base class for raw Netlink messages.
|
|
36
|
+
#
|
|
37
|
+
# A message may contain a fixed header followed by a set of Netlink
|
|
38
|
+
# attributes.
|
|
39
|
+
class Message
|
|
40
|
+
include Nl::StructuredPayload
|
|
41
|
+
|
|
42
|
+
# @param [Object, nil] fixed_header the family-specific fixed header
|
|
43
|
+
# @param [AttributeSet, nil] attributes the message's attributes
|
|
44
|
+
# @rbs (?untyped fixed_header, ?AttributeSet? attributes) -> void
|
|
45
|
+
def initialize: (?untyped fixed_header, ?AttributeSet? attributes) -> void
|
|
46
|
+
|
|
47
|
+
# Appends an attribute to the message.
|
|
48
|
+
#
|
|
49
|
+
# @param [AttributeSet::Attribute] attribute the attribute to append
|
|
50
|
+
# @return [void]
|
|
51
|
+
# @rbs (AttributeSet::Attribute attribute) -> void
|
|
52
|
+
def append_attribute: (AttributeSet::Attribute attribute) -> void
|
|
53
|
+
|
|
54
|
+
# Decodes a raw Netlink message payload.
|
|
55
|
+
#
|
|
56
|
+
# @param [Decoder] decoder the source decoder
|
|
57
|
+
# @param [Integer] type the message type from its Netlink header
|
|
58
|
+
# @return [Message] the decoded message
|
|
59
|
+
# @raise [RuntimeError] if +type+ does not match the message class's type
|
|
60
|
+
# @rbs (Decoder decoder, type: Integer) -> instance
|
|
61
|
+
def self.decode: (Decoder decoder, type: Integer) -> instance
|
|
62
|
+
|
|
63
|
+
# Returns the attribute names accepted by this message.
|
|
64
|
+
#
|
|
65
|
+
# @return [Array<Symbol>] the attribute names
|
|
66
|
+
# @rbs () -> Array[Symbol]
|
|
67
|
+
private def self.attribute_names: () -> Array[Symbol]
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Generated from lib/nl/sequence_allocator.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
# Allocates nonzero 32-bit Netlink sequence numbers.
|
|
5
|
+
class SequenceAllocator
|
|
6
|
+
MAX: ::Integer
|
|
7
|
+
|
|
8
|
+
def initialize: () -> untyped
|
|
9
|
+
|
|
10
|
+
# Returns the next sequence number not rejected by the optional block.
|
|
11
|
+
def next: () -> untyped
|
|
12
|
+
|
|
13
|
+
private def advance: () -> untyped
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Generated from lib/nl/socket.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
# Netlink socket
|
|
5
|
+
class Socket < ::Socket
|
|
6
|
+
module Constants
|
|
7
|
+
# From linux/socket.h
|
|
8
|
+
# -
|
|
9
|
+
PF_NETLINK: untyped
|
|
10
|
+
|
|
11
|
+
# From linux/netlink.h
|
|
12
|
+
# -
|
|
13
|
+
SOL_NETLINK: ::Integer
|
|
14
|
+
|
|
15
|
+
NETLINK_ADD_MEMBERSHIP: ::Integer
|
|
16
|
+
|
|
17
|
+
NETLINK_DROP_MEMBERSHIP: ::Integer
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
include Constants
|
|
21
|
+
|
|
22
|
+
# Packs Netlink socket address
|
|
23
|
+
#
|
|
24
|
+
# @rbs (Integer pid, Integer groups) -> String
|
|
25
|
+
def self.pack_sockaddr_nl: (Integer pid, Integer groups) -> String
|
|
26
|
+
|
|
27
|
+
alias self.sockaddr_nl self.pack_sockaddr_nl
|
|
28
|
+
|
|
29
|
+
# Unpacks Netlink socket address
|
|
30
|
+
#
|
|
31
|
+
# @rbs (String) -> [Integer, Integer]
|
|
32
|
+
def self.unpack_sockaddr_nl: (String) -> [ Integer, Integer ]
|
|
33
|
+
|
|
34
|
+
# @param [Integer] protonum Netlink protocol number
|
|
35
|
+
# @rbs (Integer) -> void
|
|
36
|
+
def initialize: (Integer) -> void
|
|
37
|
+
|
|
38
|
+
# Opens a Netlink socket for the specified protocol number.
|
|
39
|
+
#
|
|
40
|
+
# @rbs (Integer protonum) -> instance
|
|
41
|
+
# | [R] (Integer protonum) { (instance) -> R } -> R
|
|
42
|
+
def self.open: (Integer protonum) -> instance
|
|
43
|
+
| [R] (Integer protonum) { (instance) -> R } -> R
|
|
44
|
+
|
|
45
|
+
# @return [Integer] Local Netlink port ID assigned to this socket
|
|
46
|
+
# @rbs () -> Integer
|
|
47
|
+
def local_port_id: () -> Integer
|
|
48
|
+
|
|
49
|
+
# Adds this socket to a Netlink multicast group.
|
|
50
|
+
#
|
|
51
|
+
# @rbs (Integer group_id) -> void
|
|
52
|
+
def add_membership: (Integer group_id) -> void
|
|
53
|
+
|
|
54
|
+
# Removes this socket from a Netlink multicast group.
|
|
55
|
+
#
|
|
56
|
+
# @rbs (Integer group_id) -> void
|
|
57
|
+
def drop_membership: (Integer group_id) -> void
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Generated from lib/nl/structured_payload.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
# Shared handling for a payload containing an optional fixed header followed
|
|
5
|
+
# by an optional attribute set.
|
|
6
|
+
module StructuredPayload
|
|
7
|
+
def self.included: (untyped base) -> untyped
|
|
8
|
+
|
|
9
|
+
attr_accessor fixed_header: untyped
|
|
10
|
+
|
|
11
|
+
attr_accessor attributes: untyped
|
|
12
|
+
|
|
13
|
+
def initialize: (?untyped fixed_header, ?untyped attributes) -> untyped
|
|
14
|
+
|
|
15
|
+
module ClassMethods
|
|
16
|
+
def from_params: (?untyped params, ?external_selectors: untyped, **untyped keywords) -> untyped
|
|
17
|
+
|
|
18
|
+
def decode: (untyped decoder, ?external_selectors: untyped) -> untyped
|
|
19
|
+
|
|
20
|
+
private def attribute_names: () -> untyped
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def encode: (untyped encoder, ?external_selectors: untyped) -> untyped
|
|
24
|
+
end
|
|
25
|
+
end
|