Class: Netlink::NlMsgHdr
- Inherits:
-
Object
- Object
- Netlink::NlMsgHdr
- Defined in:
- lib/netlink/nlmsghdr.rb
Constant Summary collapse
- SIZE =
Size of a nlmsgheader
16- PACK_STR =
nlmsghdr pack string
'LSSLL'
Instance Attribute Summary collapse
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#length ⇒ Object
Returns the value of attribute length.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#seq ⇒ Object
readonly
Returns the value of attribute seq.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.from_string(str) ⇒ NlMsgHdr
Create a
nlmsghdrfrom a pack string.
Instance Method Summary collapse
-
#compute_length(mesg) ⇒ Integer
Compute
lengthfield frommesg. -
#initialize(length, type, flags, seq, pid) ⇒ NlMsgHdr
constructor
A new instance of NlMsgHdr.
- #to_s ⇒ String
Constructor Details
#initialize(length, type, flags, seq, pid) ⇒ NlMsgHdr
Returns a new instance of NlMsgHdr.
26 27 28 29 30 31 32 |
# File 'lib/netlink/nlmsghdr.rb', line 26 def initialize(length, type, flags, seq, pid) @length = length @type = type @flags = flags @seq = seq @pid = pid end |
Instance Attribute Details
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
6 7 8 |
# File 'lib/netlink/nlmsghdr.rb', line 6 def flags @flags end |
#length ⇒ Object
Returns the value of attribute length.
5 6 7 |
# File 'lib/netlink/nlmsghdr.rb', line 5 def length @length end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
6 7 8 |
# File 'lib/netlink/nlmsghdr.rb', line 6 def pid @pid end |
#seq ⇒ Object (readonly)
Returns the value of attribute seq.
6 7 8 |
# File 'lib/netlink/nlmsghdr.rb', line 6 def seq @seq end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/netlink/nlmsghdr.rb', line 6 def type @type end |
Class Method Details
.from_string(str) ⇒ NlMsgHdr
Create a nlmsghdr from a pack string
16 17 18 19 |
# File 'lib/netlink/nlmsghdr.rb', line 16 def self.from_string(str) ary = str.unpack(PACK_STR) new(*ary) end |
Instance Method Details
#compute_length(mesg) ⇒ Integer
Compute length field from mesg
42 43 44 |
# File 'lib/netlink/nlmsghdr.rb', line 42 def compute_length(mesg) @length = SIZE + mesg.size end |
#to_s ⇒ String
35 36 37 |
# File 'lib/netlink/nlmsghdr.rb', line 35 def to_s [@length, @type, @flags, @seq, @pid].pack(PACK_STR) end |