Class: Xlat::Protocols::Icmp::Echo

Inherits:
Base
  • Object
show all
Defined in:
lib/xlat/protocols/icmp/echo.rb

Constant Summary collapse

V4_TYPE_REQUEST =
8
V4_TYPE_REPLY =
0
V6_TYPE_REQUEST =
128
V6_TYPE_REPLY =
129

Constants inherited from Base

Base::V4_PROTOCOL_ID, Base::V6_PROTOCOL_ID

Instance Attribute Summary collapse

Attributes inherited from Base

#code, #type

Instance Method Summary collapse

Methods inherited from Base

parse, recalculate_checksum

Methods included from Common

sum16be

Constructor Details

#initialize(packet, is_req) ⇒ Echo

Returns a new instance of Echo.



38
39
40
41
# File 'lib/xlat/protocols/icmp/echo.rb', line 38

def initialize(packet, is_req)
  super(packet)
  @is_req = is_req
end

Instance Attribute Details

#dest_portObject

Returns the value of attribute dest_port.



36
37
38
# File 'lib/xlat/protocols/icmp/echo.rb', line 36

def dest_port
  @dest_port
end

#src_portObject

Returns the value of attribute src_port.



36
37
38
# File 'lib/xlat/protocols/icmp/echo.rb', line 36

def src_port
  @src_port
end

Instance Method Details

#_parseObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/xlat/protocols/icmp/echo.rb', line 43

def _parse
  super

  port = @packet.bytes.get_value(:U16, @packet.l4_start + 4)
  if @is_req
    @src_port = port
    @dest_port = 0
  else
    @src_port = 0
    @dest_port = port
  end

  self
end

#apply(cs_delta) ⇒ Object



62
63
64
65
# File 'lib/xlat/protocols/icmp/echo.rb', line 62

def apply(cs_delta)
  #string_set16be(@packet.bytes,@packet.l4_start + 4, @is_req ? @src_port : @dest_port)
  #Base.recalculate_checksum(@packet)
end

#tupleObject



58
59
60
# File 'lib/xlat/protocols/icmp/echo.rb', line 58

def tuple
  [src_port, dest_port].pack('n*')
end