Class: Nl::Protocols::Genl
Overview
The Generic Netlink protocol
Defined Under Namespace
Classes: GenlMsgHdr, Message
Instance Attribute Summary
Attributes inherited from Raw
Instance Method Summary collapse
- #encode_message(encoder, message) ⇒ Object
- #family_id ⇒ Object
-
#initialize(name, family_id: nil) ⇒ Genl
constructor
A new instance of Genl.
Methods inherited from Raw
#decode_message, #exchange_message, #recv_message, #send_message
Constructor Details
#initialize(name, family_id: nil) ⇒ Genl
Returns a new instance of Genl.
22 23 24 25 |
# File 'lib/nl/protocols/genl.rb', line 22 def initialize(name, family_id: nil) super(name, Core::NETLINK_GENERIC) @family_id = family_id || default_family_id(name) end |
Instance Method Details
#encode_message(encoder, message) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nl/protocols/genl.rb', line 31 def (encoder, ) cmd = .nlmsg_header.type encoder.measure(Endian::Host::U16) do .nlmsg_header.type = family_id .nlmsg_header.encode(encoder) .nlmsg_header.type = cmd GenlMsgHdr.new(cmd, 1, 0).encode(encoder) .fixed_header&.encode(encoder) .attributes.encode(encoder) end end |
#family_id ⇒ Object
27 28 29 |
# File 'lib/nl/protocols/genl.rb', line 27 def family_id @family_id or raise NotImplementedError, "Genetlink family ID for '#{name}' must be resolved via nlctrl" end |