Class: Xlat::Protocols::Tcp

Inherits:
Tcpudp
  • Object
show all
Defined in:
lib/xlat/protocols/tcp.rb

Constant Summary collapse

PROTOCOL_ID =
6
DATA_OFFSET_OFFSET =
12
CHECKSUM_OFFSET =
16
OPTION_KIND_END =
0
OPTION_KIND_NOOP =
1
OPTION_KIND_MSS =
2
FLAG_FIN =
0x01
FLAG_SYN =
0x02
FLAG_RST =
0x04
FLAG_PST =
0x08
FLAG_ACK =
0x10
FLAG_URG =
0x20
FLAG_ECE =
0x40
FLAG_CWR =
0x80

Instance Method Summary collapse

Methods inherited from Tcpudp

#_adjust_checksum, #initialize, #tuple

Methods included from Common

sum16be

Constructor Details

This class inherits a constructor from Xlat::Protocols::Tcpudp

Instance Method Details

#apply(cs_delta) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/xlat/protocols/tcp.rb', line 56

def apply(cs_delta)
  return if cs_delta.zero?

  packet = @packet
  return if packet.l4_bytes_length < 18

  bytes = packet.l4_bytes
  offset = packet.l4_bytes_offset

  checksum = bytes.get_value(:U16, offset + 16)
  checksum = _adjust_checksum(checksum, cs_delta)
  bytes.set_value(:U16, offset + 16, checksum)
end

#parseObject



46
47
48
49
50
51
52
53
54
# File 'lib/xlat/protocols/tcp.rb', line 46

def parse
  packet = @packet
  return nil if packet.l4_bytes_length < (@icmp_payload ? 4 : 20)

  # bytes = packet.l4_bytes
  # offset = packet.l4_bytes_offset

  super
end