Class: Scriptroute::Timestamp_option
- Inherits:
-
IPv4option
- Object
- IPv4option
- Scriptroute::Timestamp_option
- Defined in:
- lib/scriptroute/packets.rb
Overview
The IPv4 timestamp option, which can determine routers
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
- #routers ⇒ Array<IPaddress>? readonly
- #times ⇒ Array<Fixnum> readonly
- #ts_flag ⇒ Fixnum readonly
- #ts_overflow ⇒ Fixnum readonly
Attributes inherited from IPv4option
Instance Method Summary collapse
-
#initialize(flag_or_str) ⇒ Timestamp_option
constructor
A new instance of Timestamp_option.
-
#marshal ⇒ String
The option in string form.
Methods inherited from IPv4option
Constructor Details
#initialize(flag_or_str) ⇒ Timestamp_option
Returns a new instance of Timestamp_option.
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# 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 |
Instance Attribute Details
#routers ⇒ Array<IPaddress>? (readonly)
478 479 480 |
# File 'lib/scriptroute/packets.rb', line 478 def routers @routers end |
#times ⇒ Array<Fixnum> (readonly)
480 481 482 |
# File 'lib/scriptroute/packets.rb', line 480 def times @times end |
#ts_flag ⇒ Fixnum (readonly)
476 477 478 |
# File 'lib/scriptroute/packets.rb', line 476 def ts_flag @ts_flag end |
#ts_overflow ⇒ Fixnum (readonly)
476 477 478 |
# File 'lib/scriptroute/packets.rb', line 476 def ts_overflow @ts_overflow end |
Instance Method Details
#marshal ⇒ String
Returns the option in string form.
509 510 511 512 |
# 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 |