Class: Scriptroute::ICMP6echo
- Defined in:
- lib/scriptroute/packets.rb
Overview
Class for ping packets (echo and echo reply) much duplicated with ICMPecho
Constant Summary
Constants inherited from ICMP6
Scriptroute::ICMP6::ICMP6_DST_UNREACH, Scriptroute::ICMP6::ICMP6_ECHO, Scriptroute::ICMP6::ICMP6_ECHOREPLY, Scriptroute::ICMP6::ICMP6_PACKET_TOO_BIG, Scriptroute::ICMP6::ICMP6_PARAM_PROB, Scriptroute::ICMP6::ICMP6_TIME_EXCEEDED
Constants inherited from IPv6
Scriptroute::IPv6::IPPROTO_ICMP6
Constants inherited from IP
Scriptroute::IP::IPPROTO_TCP, Scriptroute::IP::IPPROTO_UDP
Instance Attribute Summary collapse
- #icmp_id ⇒ Fixnum readonly
- #icmp_seq ⇒ Fixnum
Attributes inherited from ICMP6
#icmp_cksum, #icmp_code, #icmp_type, #ip_payload_len
Attributes inherited from IPv6
#ip6_dst, #ip6_flow, #ip6_hlim, #ip6_src
Instance Method Summary collapse
-
#initialize(paylen_or_str = 0) ⇒ ICMP6echo
constructor
A new instance of ICMP6echo.
-
#marshal ⇒ String
The packet in string form.
- #to_s ⇒ String
Methods inherited from IPv6
creator, #ip_ttl=, #ipv6_unmarshal
Methods inherited from IP
Constructor Details
#initialize(paylen_or_str = 0) ⇒ ICMP6echo
Returns a new instance of ICMP6echo.
746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
# File 'lib/scriptroute/packets.rb', line 746 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 + 4 @icmp_id = 666 @icmp_seq = 1 super(ICMP6_ECHO) else # x is skip forward a character. @ip_payload_len = paylen_or_str.length - 8 @icmp_id, @icmp_seq = paylen_or_str.unpack("xxxxnn") super(paylen_or_str) end end |
Instance Attribute Details
#icmp_id ⇒ Fixnum (readonly)
740 741 742 |
# File 'lib/scriptroute/packets.rb', line 740 def icmp_id @icmp_id end |
#icmp_seq ⇒ Fixnum
740 741 742 |
# File 'lib/scriptroute/packets.rb', line 740 def icmp_seq @icmp_seq end |
Instance Method Details
#marshal ⇒ String
Returns The packet in string form.
761 762 763 |
# File 'lib/scriptroute/packets.rb', line 761 def marshal super + [ @icmp_id, @icmp_seq ].pack("nn") + "\0" * ( @ip_payload_len - 4 - 4 ) end |
#to_s ⇒ String
765 766 767 |
# File 'lib/scriptroute/packets.rb', line 765 def to_s super + ": ECHO6: id %d seq %d len %d" % [ @icmp_id, @icmp_seq, @ip_payload_len ] end |