Class: Scriptroute::RecordRoute_option

Inherits:
IPv4option
  • Object
show all
Defined in:
lib/scriptroute/packets.rb

Constant Summary

Constants inherited from IPv4option

IPv4option::IPOPT_EOL, IPv4option::IPOPT_EOOL, IPv4option::IPOPT_NOOP, IPv4option::IPOPT_RR, IPv4option::IPOPT_TIMESTAMP, IPv4option::IPOPT_TS, IPv4option::IPOPT_TS_PRESPEC, IPv4option::IPOPT_TS_TSANDADDR, IPv4option::IPOPT_TS_TSONLY

Instance Attribute Summary collapse

Attributes inherited from IPv4option

#ipt_code, #ipt_len, #ipt_ptr

Instance Method Summary collapse

Methods inherited from IPv4option

creator

Constructor Details

#initialize(*rest) ⇒ RecordRoute_option

Returns a new instance of RecordRoute_option.



520
521
522
523
524
525
526
527
528
# File 'lib/scriptroute/packets.rb', line 520

def initialize(*rest)
  if(rest.length == 0) 
    super(IPOPT_RR, 39, 4) 
    @routers = Array.new((@ipt_len - 3 + 1)/4, 0)
  else
    super(rest[0]) 
    @routers = rest[0][3..@ipt_len].unpack("N*").map { |addr| IPaddress.new(addr) }
  end
end

Instance Attribute Details

#routersObject (readonly)

Returns the value of attribute routers.



516
517
518
# File 'lib/scriptroute/packets.rb', line 516

def routers
  @routers
end

Instance Method Details

#marshalString

Returns the option in string form.

Returns:

  • (String)

    the option in string form



530
531
532
# File 'lib/scriptroute/packets.rb', line 530

def marshal
  super + @routers.pack("N*")  + "\0"
end

#to_sString

Returns:

  • (String)


534
535
536
# File 'lib/scriptroute/packets.rb', line 534

def to_s
  super + ': RR: {' + @routers.join(", ") + '}'
end