Octets implements the addressing scheme for IP.

Header Definition

 Int8 :o1
 Int8 :o2
 Int8 :o3
 Int8 :o4
Methods
N
R
T
Included Modules
Class Public methods
new(args={})
# File lib/packetfu/protos/ip.rb, line 15
                def initialize(args={})
                        super(
                        Int8.new(args[:o1]),
                        Int8.new(args[:o2]),
                        Int8.new(args[:o3]),
                        Int8.new(args[:o4]))
                end
Instance Public methods
read(str)

Reads a string to populate the object.

# File lib/packetfu/protos/ip.rb, line 29
                def read(str)
                        force_binary(str)
                        return self if str.nil?
                        self[:o1].read str[0,1]
                        self[:o2].read str[1,1]
                        self[:o3].read str[2,1]
                        self[:o4].read str[3,1]
                        self
                end
read_quad(str)

Set the IP Address by reading a dotted-quad address.

# File lib/packetfu/protos/ip.rb, line 52
                def read_quad(str)
                        read([IPAddr.new(str).to_i].pack("N"))
                end
to_i()

Returns an address in numerical format.

# File lib/packetfu/protos/ip.rb, line 46
                def to_i
                        ip_str = [o1, o2, o3, o4].map {|x| x.to_i.to_s}.join('.')
                        IPAddr.new(ip_str).to_i
                end
to_s()

Returns the object in string form.

# File lib/packetfu/protos/ip.rb, line 24
                def to_s
                        self.to_a.map {|x| x.to_s}.join
                end
to_x()

Returns an address in dotted-quad format.

# File lib/packetfu/protos/ip.rb, line 40
                def to_x
                        ip_str = [o1, o2, o3, o4].map {|x| x.to_i.to_s}.join('.')
                        IPAddr.new(ip_str).to_s
                end