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,74 @@
|
|
|
1
|
+
# Generated from lib/nl/sub_message.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nl
|
|
4
|
+
module Selector
|
|
5
|
+
class MissingSelectorValueError < StandardError
|
|
6
|
+
attr_reader scope: untyped
|
|
7
|
+
|
|
8
|
+
attr_reader index: untyped
|
|
9
|
+
|
|
10
|
+
def initialize: (untyped scope, untyped index) -> untyped
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class UnknownSelectorValueError < StandardError
|
|
14
|
+
attr_reader value: untyped
|
|
15
|
+
|
|
16
|
+
def initialize: (untyped value) -> untyped
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module Reference
|
|
20
|
+
def select: (untyped context, untyped formats) -> untyped
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class Local < Data
|
|
24
|
+
attr_reader index(): untyped
|
|
25
|
+
|
|
26
|
+
def self.new: (untyped index) -> instance
|
|
27
|
+
| (index: untyped) -> instance
|
|
28
|
+
|
|
29
|
+
def self.members: () -> [ :index ]
|
|
30
|
+
|
|
31
|
+
def members: () -> [ :index ]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class External < Data
|
|
35
|
+
attr_reader index(): untyped
|
|
36
|
+
|
|
37
|
+
def self.new: (untyped index) -> instance
|
|
38
|
+
| (index: untyped) -> instance
|
|
39
|
+
|
|
40
|
+
def self.members: () -> [ :index ]
|
|
41
|
+
|
|
42
|
+
def members: () -> [ :index ]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class State
|
|
46
|
+
def initialize: (untyped local_count, untyped external) -> untyped
|
|
47
|
+
|
|
48
|
+
def set_local: (untyped index, untyped value) -> untyped
|
|
49
|
+
|
|
50
|
+
def fetch_local: (untyped index) -> untyped
|
|
51
|
+
|
|
52
|
+
def fetch_external: (untyped index) -> untyped
|
|
53
|
+
|
|
54
|
+
def fetch: (untyped values, untyped key) -> untyped
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# A selector-specific payload containing an optional fixed header followed by
|
|
59
|
+
# an optional set of Netlink attributes.
|
|
60
|
+
class SubMessage
|
|
61
|
+
include StructuredPayload
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# An unrecognized selector-specific payload retained without interpretation.
|
|
65
|
+
class RawSubMessage < SubMessage
|
|
66
|
+
attr_reader payload: untyped
|
|
67
|
+
|
|
68
|
+
attr_reader nlattr_type_flags: untyped
|
|
69
|
+
|
|
70
|
+
def initialize: (untyped payload, nlattr_type_flags: untyped) -> untyped
|
|
71
|
+
|
|
72
|
+
def encode: (untyped encoder, ?external_selectors: untyped) -> untyped
|
|
73
|
+
end
|
|
74
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kasumi Hanazuki
|
|
@@ -28,10 +28,12 @@ files:
|
|
|
28
28
|
- lib/nl/async/driver.rb
|
|
29
29
|
- lib/nl/async/mailbox.rb
|
|
30
30
|
- lib/nl/async/operation.rb
|
|
31
|
+
- lib/nl/attribute_set.rb
|
|
32
|
+
- lib/nl/bitfield32.rb
|
|
31
33
|
- lib/nl/blocking_transport.rb
|
|
32
34
|
- lib/nl/connection.rb
|
|
33
|
-
- lib/nl/core.rb
|
|
34
35
|
- lib/nl/datagram.rb
|
|
36
|
+
- lib/nl/datatypes.rb
|
|
35
37
|
- lib/nl/decoder.rb
|
|
36
38
|
- lib/nl/encoder.rb
|
|
37
39
|
- lib/nl/endian.rb
|
|
@@ -39,20 +41,59 @@ files:
|
|
|
39
41
|
- lib/nl/exchange.rb
|
|
40
42
|
- lib/nl/family.rb
|
|
41
43
|
- lib/nl/genl.rb
|
|
42
|
-
- lib/nl/genl/
|
|
44
|
+
- lib/nl/genl/client.rb
|
|
45
|
+
- lib/nl/genl/protocol.rb
|
|
46
|
+
- lib/nl/genl/wire.rb
|
|
43
47
|
- lib/nl/notification.rb
|
|
44
48
|
- lib/nl/notification_router.rb
|
|
45
|
-
- lib/nl/
|
|
46
|
-
- lib/nl/
|
|
49
|
+
- lib/nl/raw.rb
|
|
50
|
+
- lib/nl/raw/client.rb
|
|
51
|
+
- lib/nl/raw/protocol.rb
|
|
52
|
+
- lib/nl/raw/wire.rb
|
|
47
53
|
- lib/nl/sequence_allocator.rb
|
|
48
54
|
- lib/nl/socket.rb
|
|
55
|
+
- lib/nl/structured_payload.rb
|
|
56
|
+
- lib/nl/sub_message.rb
|
|
49
57
|
- lib/nl/version.rb
|
|
58
|
+
- sig/generated/nl.rbs
|
|
59
|
+
- sig/generated/nl/async.rbs
|
|
60
|
+
- sig/generated/nl/async/dispatcher.rbs
|
|
61
|
+
- sig/generated/nl/async/driver.rbs
|
|
62
|
+
- sig/generated/nl/async/mailbox.rbs
|
|
63
|
+
- sig/generated/nl/async/operation.rbs
|
|
64
|
+
- sig/generated/nl/attribute_set.rbs
|
|
65
|
+
- sig/generated/nl/bitfield32.rbs
|
|
66
|
+
- sig/generated/nl/blocking_transport.rbs
|
|
67
|
+
- sig/generated/nl/connection.rbs
|
|
68
|
+
- sig/generated/nl/datagram.rbs
|
|
69
|
+
- sig/generated/nl/datatypes.rbs
|
|
70
|
+
- sig/generated/nl/decoder.rbs
|
|
71
|
+
- sig/generated/nl/encoder.rbs
|
|
72
|
+
- sig/generated/nl/endian.rbs
|
|
73
|
+
- sig/generated/nl/error.rbs
|
|
74
|
+
- sig/generated/nl/exchange.rbs
|
|
75
|
+
- sig/generated/nl/family.rbs
|
|
76
|
+
- sig/generated/nl/genl.rbs
|
|
77
|
+
- sig/generated/nl/genl/client.rbs
|
|
78
|
+
- sig/generated/nl/genl/protocol.rbs
|
|
79
|
+
- sig/generated/nl/genl/wire.rbs
|
|
80
|
+
- sig/generated/nl/notification.rbs
|
|
81
|
+
- sig/generated/nl/notification_router.rbs
|
|
82
|
+
- sig/generated/nl/raw.rbs
|
|
83
|
+
- sig/generated/nl/raw/client.rbs
|
|
84
|
+
- sig/generated/nl/raw/protocol.rbs
|
|
85
|
+
- sig/generated/nl/raw/wire.rbs
|
|
86
|
+
- sig/generated/nl/sequence_allocator.rbs
|
|
87
|
+
- sig/generated/nl/socket.rbs
|
|
88
|
+
- sig/generated/nl/structured_payload.rbs
|
|
89
|
+
- sig/generated/nl/sub_message.rbs
|
|
90
|
+
- sig/generated/nl/version.rbs
|
|
50
91
|
homepage: https://github.com/hanazuki/nl
|
|
51
92
|
licenses:
|
|
52
93
|
- MIT
|
|
53
94
|
metadata:
|
|
54
95
|
homepage_uri: https://github.com/hanazuki/nl
|
|
55
|
-
source_code_uri: https://github.com/hanazuki/nl/tree/v0.
|
|
96
|
+
source_code_uri: https://github.com/hanazuki/nl/tree/v0.4.2
|
|
56
97
|
changelog_uri: https://github.com/hanazuki/nl/blob/master/CHANGELOG.md
|
|
57
98
|
rdoc_options: []
|
|
58
99
|
require_paths:
|
|
@@ -68,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
68
109
|
- !ruby/object:Gem::Version
|
|
69
110
|
version: '0'
|
|
70
111
|
requirements: []
|
|
71
|
-
rubygems_version: 4.0.
|
|
112
|
+
rubygems_version: 4.0.16
|
|
72
113
|
specification_version: 4
|
|
73
114
|
summary: Netlink protocol support for Ruby
|
|
74
115
|
test_files: []
|
data/lib/nl/core.rb
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# Netlink wire definitions
|
|
2
|
-
|
|
3
|
-
require_relative 'endian'
|
|
4
|
-
|
|
5
|
-
module Nl
|
|
6
|
-
module Core
|
|
7
|
-
module Constants
|
|
8
|
-
# From include/uapi/linux/netlink.h
|
|
9
|
-
NETLINK_ROUTE = 0
|
|
10
|
-
NETLINK_NETFILTER = 12
|
|
11
|
-
NETLINK_GENERIC = 16
|
|
12
|
-
|
|
13
|
-
NLM_F_REQUEST = 1
|
|
14
|
-
NLM_F_MULTI = 2
|
|
15
|
-
NLM_F_ACK = 4
|
|
16
|
-
NLM_F_ECHO = 8
|
|
17
|
-
NLM_F_DUMP_INTR = 16
|
|
18
|
-
NLM_F_DUMP_FILTERED = 32
|
|
19
|
-
NLM_F_ROOT = 0x100
|
|
20
|
-
NLM_F_MATCH = 0x200
|
|
21
|
-
NLM_F_ATOMIC = 0x400
|
|
22
|
-
NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH
|
|
23
|
-
NLM_F_REPLACE = 0x100
|
|
24
|
-
NLM_F_EXCL = 0x200
|
|
25
|
-
NLM_F_CREATE = 0x400
|
|
26
|
-
NLM_F_APPEND = 0x800
|
|
27
|
-
|
|
28
|
-
NLMSG_ALIGNTO = 4
|
|
29
|
-
NLMSG_HDRLEN = 16
|
|
30
|
-
|
|
31
|
-
NLMSG_NOOP = 0x1
|
|
32
|
-
NLMSG_ERROR = 0x2
|
|
33
|
-
NLMSG_DONE = 0x3
|
|
34
|
-
NLMSG_OVERRUN = 0x4
|
|
35
|
-
|
|
36
|
-
NLMSG_MIN_TYPE = 0x10
|
|
37
|
-
|
|
38
|
-
NLA_F_NESTED = 1 << 15
|
|
39
|
-
NLA_F_NET_BYTEORDER = 1 << 14
|
|
40
|
-
NLA_TYPE_MASK = ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER)
|
|
41
|
-
|
|
42
|
-
NLA_ALIGNTO = 4
|
|
43
|
-
NLA_HDRLEN = 4
|
|
44
|
-
end
|
|
45
|
-
include Constants
|
|
46
|
-
|
|
47
|
-
NlMsgHdr = Struct.new(:len, :type, :flags, :seq, :pid)
|
|
48
|
-
# Message header
|
|
49
|
-
class NlMsgHdr
|
|
50
|
-
FORMAT = Ractor.make_shareable([
|
|
51
|
-
Endian::Host::U32,
|
|
52
|
-
Endian::Host::U16,
|
|
53
|
-
Endian::Host::U16,
|
|
54
|
-
Endian::Host::U32,
|
|
55
|
-
Endian::Host::U32,
|
|
56
|
-
])
|
|
57
|
-
private_constant :FORMAT
|
|
58
|
-
|
|
59
|
-
def self.decode(decoder)
|
|
60
|
-
obj = new(*decoder.get_values(FORMAT))
|
|
61
|
-
decoder.align_to(Constants::NLMSG_ALIGNTO)
|
|
62
|
-
obj
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def encode(encoder)
|
|
66
|
-
encoder.reserve(Constants::NLMSG_HDRLEN)
|
|
67
|
-
encoder.put_values(FORMAT, to_a)
|
|
68
|
-
encoder.align_to(Constants::NLMSG_ALIGNTO)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
NlAttr = Struct.new(:len, :type)
|
|
73
|
-
# Attribute header
|
|
74
|
-
class NlAttr
|
|
75
|
-
FORMAT = Ractor.make_shareable([
|
|
76
|
-
Endian::Host::U16,
|
|
77
|
-
Endian::Host::U16,
|
|
78
|
-
])
|
|
79
|
-
private_constant :FORMAT
|
|
80
|
-
|
|
81
|
-
def self.decode(decoder)
|
|
82
|
-
obj = new(*decoder.get_values(FORMAT))
|
|
83
|
-
decoder.align_to(Constants::NLA_ALIGNTO)
|
|
84
|
-
obj
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def encode(encoder)
|
|
88
|
-
encoder.reserve(Constants::NLA_HDRLEN)
|
|
89
|
-
encoder.put_values(FORMAT, to_a)
|
|
90
|
-
encoder.align_to(Constants::NLA_ALIGNTO)
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
data/lib/nl/genl/connection.rb
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# Generic Netlink connection handling
|
|
2
|
-
#--
|
|
3
|
-
# rbs_inline: enabled
|
|
4
|
-
|
|
5
|
-
require_relative '../connection'
|
|
6
|
-
require_relative '../core'
|
|
7
|
-
require_relative '../protocols/genl'
|
|
8
|
-
|
|
9
|
-
module Nl
|
|
10
|
-
module Genl
|
|
11
|
-
FamilyInfo = Data.define(:id, :multicast_groups) do
|
|
12
|
-
def self.from_reply(reply)
|
|
13
|
-
groups = (reply.mcast_groups || []).to_h do |attributes|
|
|
14
|
-
[attributes[:name].value.to_sym, attributes[:id].value]
|
|
15
|
-
end
|
|
16
|
-
new(id: reply.family_id, multicast_groups: groups.freeze)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
class Connection
|
|
21
|
-
#--
|
|
22
|
-
# @rbs (resolver: ^(instance, ::String) -> (Integer | FamilyInfo | untyped), ?executor: executor?, ?notification_capacity: Integer?) -> instance
|
|
23
|
-
# | [R] (resolver: ^(instance, ::String) -> (Integer | FamilyInfo | untyped), ?executor: executor?, ?notification_capacity: Integer?) { (instance) -> R } -> R
|
|
24
|
-
def self.open(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY)
|
|
25
|
-
conn = new(resolver:, executor:, notification_capacity:)
|
|
26
|
-
if block_given?
|
|
27
|
-
begin
|
|
28
|
-
yield conn
|
|
29
|
-
ensure
|
|
30
|
-
conn.close
|
|
31
|
-
end
|
|
32
|
-
else
|
|
33
|
-
conn
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
#--
|
|
38
|
-
# @rbs resolver: ^(instance, ::String) -> (Integer | FamilyInfo | untyped)
|
|
39
|
-
# @rbs executor: executor?
|
|
40
|
-
# @rbs return: instance
|
|
41
|
-
def initialize(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY)
|
|
42
|
-
@resolver = resolver
|
|
43
|
-
@family_cache = {}
|
|
44
|
-
@family_cache_mutex = Mutex.new
|
|
45
|
-
@connection = Nl::Connection.new(
|
|
46
|
-
protocol: Protocols::Genl,
|
|
47
|
-
executor:,
|
|
48
|
-
notification_capacity:,
|
|
49
|
-
)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def family(family_class)
|
|
53
|
-
proto = family_class::PROTOCOL
|
|
54
|
-
info = family_info(proto)
|
|
55
|
-
family_class.new(
|
|
56
|
-
@connection,
|
|
57
|
-
protocol: Protocols::Genl.new(
|
|
58
|
-
proto.name,
|
|
59
|
-
family_id: info.id,
|
|
60
|
-
multicast_groups: info.multicast_groups,
|
|
61
|
-
),
|
|
62
|
-
)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def close
|
|
66
|
-
@connection.close
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
private def family_info(protocol)
|
|
70
|
-
id = protocol.family_id
|
|
71
|
-
FamilyInfo.new(id:, multicast_groups: {}.freeze)
|
|
72
|
-
rescue NotImplementedError
|
|
73
|
-
cached_info = @family_cache_mutex.synchronize { @family_cache[protocol.name] }
|
|
74
|
-
return cached_info if cached_info
|
|
75
|
-
|
|
76
|
-
resolved = @resolver.call(self, protocol.name)
|
|
77
|
-
info = case resolved
|
|
78
|
-
when Integer
|
|
79
|
-
FamilyInfo.new(id: resolved, multicast_groups: {}.freeze)
|
|
80
|
-
when FamilyInfo
|
|
81
|
-
resolved
|
|
82
|
-
else
|
|
83
|
-
FamilyInfo.from_reply(resolved)
|
|
84
|
-
end
|
|
85
|
-
@family_cache_mutex.synchronize { @family_cache[protocol.name] ||= info }
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
data/lib/nl/protocols/genl.rb
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
require_relative '../genl'
|
|
2
|
-
require_relative 'raw'
|
|
3
|
-
|
|
4
|
-
module Nl
|
|
5
|
-
module Protocols
|
|
6
|
-
# The Generic Netlink protocol
|
|
7
|
-
class Genl < Raw
|
|
8
|
-
class NotificationRouting
|
|
9
|
-
def family_key(protocol) = protocol.family_key
|
|
10
|
-
def frame_key(header) = header.type
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
NOTIFICATION_ROUTING = NotificationRouting.new.freeze
|
|
14
|
-
|
|
15
|
-
def self.protonum = Core::NETLINK_GENERIC
|
|
16
|
-
|
|
17
|
-
def initialize(name, family_id: nil, multicast_groups: {})
|
|
18
|
-
super(name, self.class.protonum)
|
|
19
|
-
@family_id = family_id || default_family_id(name)
|
|
20
|
-
@multicast_groups = multicast_groups.transform_keys(&:to_sym).freeze
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def family_id
|
|
24
|
-
@family_id or raise NotImplementedError, "Genetlink family ID for '#{name}' must be resolved via nlctrl"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def encode_message(encoder, request, seq:, pid:)
|
|
28
|
-
message = request.message
|
|
29
|
-
header = Core::NlMsgHdr.new(0, request.type, request.flags, seq, pid)
|
|
30
|
-
encoder.measure(Endian::Host::U16) do
|
|
31
|
-
header.encode(encoder)
|
|
32
|
-
Nl::Genl::GenlMsgHdr.new(message.class::TYPE, 1, 0).encode(encoder)
|
|
33
|
-
message.encode(encoder)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
class Message < Raw::Message
|
|
38
|
-
def self.decode(decoder, type:)
|
|
39
|
-
genlhdr = Nl::Genl::GenlMsgHdr.decode(decoder)
|
|
40
|
-
super(decoder, type: genlhdr.cmd)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def family_key = family_id
|
|
45
|
-
|
|
46
|
-
def self.notification_routing = NOTIFICATION_ROUTING
|
|
47
|
-
def notification_routing = self.class.notification_routing
|
|
48
|
-
|
|
49
|
-
def notification_frame?(header, _payload)
|
|
50
|
-
header.type == family_id
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def notification_class(header, payload, classes)
|
|
54
|
-
return unless notification_frame?(header, payload)
|
|
55
|
-
|
|
56
|
-
command = Nl::Genl::GenlMsgHdr.decode(Decoder.new(payload)).cmd
|
|
57
|
-
classes[command]
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def multicast_group_id(name, _value)
|
|
61
|
-
@multicast_groups.fetch(name.to_sym) do
|
|
62
|
-
raise UnresolvedMulticastGroupError,
|
|
63
|
-
"Generic Netlink multicast group #{name.inspect} was not resolved"
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
private def frame_type(_message_class) = family_id
|
|
68
|
-
|
|
69
|
-
private def default_family_id(name)
|
|
70
|
-
Nl::Genl::GENL_ID_CTRL if name == 'nlctrl'
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|