Class: Xlat::Protocols::Icmp::Echo
- 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
-
#dest_port ⇒ Object
Returns the value of attribute dest_port.
-
#src_port ⇒ Object
Returns the value of attribute src_port.
Attributes inherited from Base
Instance Method Summary collapse
- #_parse ⇒ Object
- #apply(cs_delta) ⇒ Object
-
#initialize(packet, is_req) ⇒ Echo
constructor
A new instance of Echo.
- #tuple ⇒ Object
Methods inherited from Base
Methods included from Common
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_port ⇒ Object
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_port ⇒ Object
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
#_parse ⇒ Object
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 |
#tuple ⇒ Object
58 59 60 |
# File 'lib/xlat/protocols/icmp/echo.rb', line 58 def tuple [src_port, dest_port].pack('n*') end |