Class: PcapParser::Proto::ICMP

Inherits:
Object
  • Object
show all
Defined in:
lib/pcap_parser/proto/icmp.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(bin_header) ⇒ ICMP


6
7
8
# File 'lib/pcap_parser/proto/icmp.rb', line 6

def initialize(bin_header)
  @binhdr = bin_header
end

Instance Method Details

#chsumInteger

Checksum (16 bits)


25
26
27
# File 'lib/pcap_parser/proto/icmp.rb', line 25

def chsum
  @binhdr[2, 2].unpack("n").pop
end

#codeInteger

ICMP subtype


19
20
21
# File 'lib/pcap_parser/proto/icmp.rb', line 19

def code
  @binhdr[1].unpack("C").pop
end

#typeInteger


13
14
15
# File 'lib/pcap_parser/proto/icmp.rb', line 13

def type
  @binhdr[0].unpack("C").pop
end

#valid?true, false

Error checking calculated from the ICMP header and data.


31
32
33
# File 'lib/pcap_parser/proto/icmp.rb', line 31

def valid?
  0xffff == Proto::sum_pack_16int(@binhdr.unpack("n*"))
end