class PacketFu::TcpHlen
Implements the Header Length for TCPHeader.
Header Definition
Fixnum (4 bits) :hlen
Public Class Methods
new(args={})
click to toggle source
Calls superclass method
# File lib/packetfu/protos/tcp/hlen.rb, line 11 def initialize(args={}) super(args[:hlen]) end
Public Instance Methods
read(str)
click to toggle source
Reads a string to populate the object.
# File lib/packetfu/protos/tcp/hlen.rb, line 23 def read(str) force_binary(str) return self if str.nil? || str.size.zero? if 1.respond_to? :ord self[:hlen] = (str[0].ord & 0b11110000) >> 4 else self[:hlen] = (str[0] & 0b11110000) >> 4 end self end
to_i()
click to toggle source
Returns the TcpHlen field as an integer. Note these will become the high bits at the TCP header's offset, even though the lower 4 bits will be further chopped up.
# File lib/packetfu/protos/tcp/hlen.rb, line 18 def to_i hlen.to_i & 0b1111 end
to_s()
click to toggle source
Returns the object in string form.
# File lib/packetfu/protos/tcp/hlen.rb, line 35 def to_s [self.to_i].pack("C") end