Class: Scriptroute::ICMPtstamp

Inherits:
ICMP show all
Defined in:
lib/scriptroute/packets.rb

Constant Summary

Constants inherited from ICMP

Scriptroute::ICMP::ICMP_ECHO, Scriptroute::ICMP::ICMP_ECHOREPLY, Scriptroute::ICMP::ICMP_MASKREPLY, Scriptroute::ICMP::ICMP_MASKREQ, Scriptroute::ICMP::ICMP_PARAMETERPROB, Scriptroute::ICMP::ICMP_TIMESTAMP, Scriptroute::ICMP::ICMP_TIMESTAMPREPLY, Scriptroute::ICMP::ICMP_TIMXCEED, Scriptroute::ICMP::ICMP_UNREACH, Scriptroute::ICMP::ICMP_UNREACH_FILTER_PROHIB, Scriptroute::ICMP::ICMP_UNREACH_HOST, Scriptroute::ICMP::ICMP_UNREACH_HOST_PRECEDENCE, Scriptroute::ICMP::ICMP_UNREACH_HOST_PROHIB, Scriptroute::ICMP::ICMP_UNREACH_HOST_UNKNOWN, Scriptroute::ICMP::ICMP_UNREACH_ISOLATED, Scriptroute::ICMP::ICMP_UNREACH_NEEDFRAG, Scriptroute::ICMP::ICMP_UNREACH_NET, Scriptroute::ICMP::ICMP_UNREACH_NET_PROHIB, Scriptroute::ICMP::ICMP_UNREACH_NET_UNKNOWN, Scriptroute::ICMP::ICMP_UNREACH_PORT, Scriptroute::ICMP::ICMP_UNREACH_PRECEDENCE_CUTOFF, Scriptroute::ICMP::ICMP_UNREACH_PROTOCOL, Scriptroute::ICMP::ICMP_UNREACH_SRCFAIL, Scriptroute::ICMP::ICMP_UNREACH_TOSHOST, Scriptroute::ICMP::ICMP_UNREACH_TOSNET

Constants inherited from IPv4

Scriptroute::IPv4::IPPROTO_ICMP

Constants inherited from IP

Scriptroute::IP::IPPROTO_TCP, Scriptroute::IP::IPPROTO_UDP

Instance Attribute Summary collapse

Attributes inherited from ICMP

#icmp_cksum, #icmp_code, #icmp_type, #ip_p, #ip_payload_len

Attributes inherited from IPv4

#ip_dst, #ip_hl, #ip_id, #ip_len, #ip_off, #ip_options, #ip_p, #ip_src, #ip_sum, #ip_tos, #ip_ttl, #ip_v

Instance Method Summary collapse

Methods inherited from ICMP

#to_s

Methods inherited from IPv4

#add_option, #calculate_header_len, #calculate_packet_len, creator, #ip_payload_len, #ipv4_unmarshal, #to_s

Methods inherited from IP

creator, #to_bytes

Constructor Details

#initialize(paylen_or_str = 0) ⇒ ICMPtstamp

Returns a new instance of ICMPtstamp.



779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
# File 'lib/scriptroute/packets.rb', line 779

def initialize(paylen_or_str = 0)
  if(paylen_or_str.is_a?(Fixnum)) then
    if( paylen_or_str < 0) then raise "payload length must be >= 0" end
    @ip_payload_len = paylen_or_str + 4 + 16
    @icmp_id = 666
    @icmp_seq = 1
    @icmp_otime = 0 # one of these three should probably be nonzero by the client, but I forget which.
    @icmp_rtime = 0
    @icmp_ttime = 0 
    super(ICMP_TIMESTAMP)
  else
    # x is skip forward a character.
    @ip_payload_len = paylen_or_str.length - 20
    @icmp_id, @icmp_seq, @icmp_otime, @icmp_rtime, @icmp_ttime = paylen_or_str.unpack("xxxxnnNNN")
    super(paylen_or_str)
  end
end

Instance Attribute Details

#icmp_idFixnum (readonly)

Returns:

  • (Fixnum)


772
773
774
# File 'lib/scriptroute/packets.rb', line 772

def icmp_id
  @icmp_id
end

#icmp_otimeObject (readonly)

Returns the value of attribute icmp_otime.



773
774
775
# File 'lib/scriptroute/packets.rb', line 773

def icmp_otime
  @icmp_otime
end

#icmp_rtimeObject (readonly)

Returns the value of attribute icmp_rtime.



773
774
775
# File 'lib/scriptroute/packets.rb', line 773

def icmp_rtime
  @icmp_rtime
end

#icmp_seqFixnum

Returns:

  • (Fixnum)


772
773
774
# File 'lib/scriptroute/packets.rb', line 772

def icmp_seq
  @icmp_seq
end

#icmp_ttimeObject (readonly)

Returns the value of attribute icmp_ttime.



773
774
775
# File 'lib/scriptroute/packets.rb', line 773

def icmp_ttime
  @icmp_ttime
end

Instance Method Details

#marshalString

Returns The packet in string form.

Returns:

  • (String)

    The packet in string form



797
798
799
800
801
# File 'lib/scriptroute/packets.rb', line 797

def marshal
  array_of_elements = [ @icmp_id, @icmp_seq, @icmp_otime, @icmp_rtime, @icmp_ttime ]
  raise "an ICMP timestamp field #{array_of_elements.index(nil)} was unset" if array_of_elements.include?(nil)
  super + array_of_elements.pack("nnNNN")
end