Class: Nl::Raw::NlMsgHdr
- Inherits:
-
Struct
- Object
- Struct
- Nl::Raw::NlMsgHdr
- Defined in:
- nl/lib/nl/raw/wire.rb,
nl/lib/nl/raw/wire.rb
Overview
Fixed-format metadata header prepended to every Netlink message.
This corresponds to Linux's struct nlmsghdr.
Instance Attribute Summary collapse
-
#flags ⇒ Integer
Bitwise combination of
NLM_F_flags. -
#len ⇒ Integer
Message length in bytes, including this header.
-
#pid ⇒ Integer
Sender's Netlink port ID.
-
#seq ⇒ Integer
Sequence number used to correlate requests and replies.
-
#type ⇒ Integer
Message content type.
Class Method Summary collapse
-
.decode(decoder) ⇒ NlMsgHdr
Decodes a header from the decoder's current position.
Instance Method Summary collapse
-
#encode(encoder) ⇒ void
Encodes this header at the encoder's current position.
Instance Attribute Details
#flags ⇒ Integer
Returns bitwise combination of NLM_F_ flags.
62 63 64 65 66 67 68 |
# File 'nl/lib/nl/raw/wire.rb', line 62 NlMsgHdr = Struct.new( :len, #: Integer :type, #: Integer :flags, #: Integer :seq, #: Integer :pid, #: Integer ) |
#len ⇒ Integer
Returns message length in bytes, including this header.
62 63 64 65 66 67 68 |
# File 'nl/lib/nl/raw/wire.rb', line 62 NlMsgHdr = Struct.new( :len, #: Integer :type, #: Integer :flags, #: Integer :seq, #: Integer :pid, #: Integer ) |
#pid ⇒ Integer
Returns sender's Netlink port ID.
62 63 64 65 66 67 68 |
# File 'nl/lib/nl/raw/wire.rb', line 62 NlMsgHdr = Struct.new( :len, #: Integer :type, #: Integer :flags, #: Integer :seq, #: Integer :pid, #: Integer ) |
#seq ⇒ Integer
Returns sequence number used to correlate requests and replies.
62 63 64 65 66 67 68 |
# File 'nl/lib/nl/raw/wire.rb', line 62 NlMsgHdr = Struct.new( :len, #: Integer :type, #: Integer :flags, #: Integer :seq, #: Integer :pid, #: Integer ) |
#type ⇒ Integer
Returns message content type.
62 63 64 65 66 67 68 |
# File 'nl/lib/nl/raw/wire.rb', line 62 NlMsgHdr = Struct.new( :len, #: Integer :type, #: Integer :flags, #: Integer :seq, #: Integer :pid, #: Integer ) |
Class Method Details
.decode(decoder) ⇒ NlMsgHdr
Decodes a header from the decoder's current position.
85 86 87 88 89 |
# File 'nl/lib/nl/raw/wire.rb', line 85 def self.decode(decoder) obj = new(*decoder.get_values(FORMAT)) decoder.align_to(Constants::NLMSG_ALIGNTO) obj end |
Instance Method Details
#encode(encoder) ⇒ void
This method returns an undefined value.
Encodes this header at the encoder's current position.
96 97 98 99 100 |
# File 'nl/lib/nl/raw/wire.rb', line 96 def encode(encoder) encoder.reserve(Constants::NLMSG_HDRLEN) encoder.put_values(FORMAT, to_a) encoder.align_to(Constants::NLMSG_ALIGNTO) end |