Class: Nl::Genl::Protocol
Overview
Socket-wide Generic Netlink wire behavior.
Instance Attribute Summary
#protonum
Instance Method Summary
collapse
-
#encode_message(encoder, endpoint, request, seq:, pid:) ⇒ Object
-
#initialize ⇒ Protocol
constructor
A new instance of Protocol.
-
#notification_channel_key(endpoint) ⇒ Object
-
#notification_class(endpoint, header, payload, classes) ⇒ Object
-
#notification_frame?(endpoint, header, _payload) ⇒ Boolean
-
#notification_frame_key(header) ⇒ Object
-
#notification_route_keys(endpoint, _classes) ⇒ Object
#build_request, #decode_frame, #decode_notification, #send_message
Constructor Details
Returns a new instance of Protocol.
29
30
31
|
# File 'nl/lib/nl/genl/protocol.rb', line 29
def initialize
super(Raw::NETLINK_GENERIC)
end
|
Instance Method Details
#encode_message(encoder, endpoint, request, seq:, pid:) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'nl/lib/nl/genl/protocol.rb', line 33
def encode_message(encoder, endpoint, request, seq:, pid:)
message = request.message
= Raw::NlMsgHdr.new(0, request.type, request.flags, seq, pid)
encoder.measure(Endian::Host::U16) do
.encode(encoder)
Nl::Genl::GenlMsgHdr.new(message.class::TYPE, endpoint.version, 0).encode(encoder)
message.encode(encoder)
end
end
|
#notification_channel_key(endpoint) ⇒ Object
43
|
# File 'nl/lib/nl/genl/protocol.rb', line 43
def notification_channel_key(endpoint) = endpoint.family_id
|
#notification_class(endpoint, header, payload, classes) ⇒ Object
51
52
53
54
55
56
|
# File 'nl/lib/nl/genl/protocol.rb', line 51
def notification_class(endpoint, , payload, classes)
return unless notification_frame?(endpoint, , payload)
command = Nl::Genl::GenlMsgHdr.decode(Decoder.new(payload)).cmd
classes[command]
end
|
#notification_frame?(endpoint, header, _payload) ⇒ Boolean
47
48
49
|
# File 'nl/lib/nl/genl/protocol.rb', line 47
def notification_frame?(endpoint, , _payload)
.type == endpoint.family_id
end
|
#notification_frame_key(header) ⇒ Object
45
|
# File 'nl/lib/nl/genl/protocol.rb', line 45
def notification_frame_key() = .type
|
#notification_route_keys(endpoint, _classes) ⇒ Object
44
|
# File 'nl/lib/nl/genl/protocol.rb', line 44
def notification_route_keys(endpoint, _classes) = [endpoint.family_id]
|