class Scriptroute::Timestamp_option
The IPv4
timestamp option, which can determine routers
Attributes
routers[R]
@return [Array<IPaddress>,nil]
times[R]
@return [Array<Fixnum>]
ts_flag[R]
@return [Fixnum]
ts_overflow[R]
@return [Fixnum]
Public Class Methods
new(flag_or_str)
click to toggle source
Calls superclass method
Scriptroute::IPv4option::new
# File lib/scriptroute/packets.rb, line 484 def initialize(flag_or_str) if(flag_or_str.is_a?(Fixnum)) then @routers = Array.new @times = Array.new @ts_flag = flag_or_str super(IPOPT_TS, 36, 5) # maximum length is 40, but tcpdump whines. else ipt_code, ipt_len, ipt_ptr, ipt_of_fl = flag_or_str.unpack("CCCC"); @ts_flag = ipt_of_fl & 0x0f @ts_overflow = (ipt_of_fl & 0xf0) >> 4 @routers, @times = case @ts_flag when IPOPT_TS_TSONLY [ nil, flag_or_str.unpack("xxxxN*") ] when IPOPT_TS_TSANDADDR, IPOPT_TS_PRESPEC all = flag_or_str.unpack("xxxxN*") [ all.even_subscripts[0...ipt_len/8].map { |rtr| IPaddress.new(rtr) }, all.odd_subscripts[0...(ipt_len/8)] ] else raise "bad timestamp flag: #{@ts_flag} (code: #{ipt_code}, len: #{ipt_len}, ptr: #{ipt_ptr})" end super( flag_or_str ) end end
Public Instance Methods
marshal()
click to toggle source
@return [String] the option in string form
Calls superclass method
Scriptroute::IPv4option#marshal
# File lib/scriptroute/packets.rb, line 509 def marshal super + [ @ts_flag ].pack("c") + # oflw will be init'd to zero Array.new(@ipt_len - 4, 0).pack("c*") end