Class: Nl::Raw::NlAttr
- Inherits:
-
Struct
- Object
- Struct
- Nl::Raw::NlAttr
- Defined in:
- nl/lib/nl/raw/wire.rb,
nl/lib/nl/raw/wire.rb
Overview
Fixed-format header prepended to every Netlink attribute.
This corresponds to Linux's struct nlattr.
Instance Attribute Summary collapse
-
#len ⇒ Integer
Attribute length in bytes, including this header but excluding trailing alignment padding.
-
#type ⇒ Integer
Attribute type combined with optional
NLA_F_flags.
Class Method Summary collapse
-
.decode(decoder) ⇒ NlAttr
Decodes an attribute header from the decoder's current position.
Instance Method Summary collapse
-
#encode(encoder) ⇒ void
Encodes this attribute header at the encoder's current position.
Instance Attribute Details
#len ⇒ Integer
Returns attribute length in bytes, including this header but excluding trailing alignment padding.
112 113 114 115 |
# File 'nl/lib/nl/raw/wire.rb', line 112 NlAttr = Struct.new( :len, #: Integer :type, #: Integer ) |
#type ⇒ Integer
Returns attribute type combined with optional NLA_F_ flags.
112 113 114 115 |
# File 'nl/lib/nl/raw/wire.rb', line 112 NlAttr = Struct.new( :len, #: Integer :type, #: Integer ) |
Class Method Details
.decode(decoder) ⇒ NlAttr
Decodes an attribute header from the decoder's current position.
129 130 131 132 133 |
# File 'nl/lib/nl/raw/wire.rb', line 129 def self.decode(decoder) obj = new(*decoder.get_values(FORMAT)) decoder.align_to(Constants::NLA_ALIGNTO) obj end |
Instance Method Details
#encode(encoder) ⇒ void
This method returns an undefined value.
Encodes this attribute header at the encoder's current position.
140 141 142 143 144 |
# File 'nl/lib/nl/raw/wire.rb', line 140 def encode(encoder) encoder.reserve(Constants::NLA_HDRLEN) encoder.put_values(FORMAT, to_a) encoder.align_to(Constants::NLA_ALIGNTO) end |