Class: Pcap::TCPPacket

Inherits:
IPPacket show all
Defined in:
lib/pcap/packet.rb,
ext/pcap/tcp_packet.c

Instance Method Summary collapse

Methods inherited from IPPacket

#dst, #dst=, #ip_data, #ip_df?, #ip_dst, #ip_dst=, #ip_flags, #ip_hlen, #ip_id, #ip_len, #ip_mf?, #ip_off, #ip_proto, #ip_src, #ip_src=, #ip_sum, #ip_sum_update!, #ip_sumok?, #ip_tos, #ip_truncated?, #ip_ttl, #ip_ver, #src, #src=

Methods inherited from Packet

#=~, #_dump, #_dump_to, _load, _load_from, #arp?, #caplen, #datalink, #dst_mac_address, #ethertype, #inspect, #ip?, #ipv6?, #lacp?, #length, #raw_data, #size, #src_mac_address, #tcp?, #time, #time_i, #time_i=, #udata, #udata=, #udp?, #unpack_hex_string

Instance Method Details

#dportObject

#dport=Object

Set TCP destination port and update checksum



267
268
269
# File 'ext/pcap/tcp_packet.c', line 267

static VALUE
tcpp_dport_set(self, val)
VALUE self, val;

#sportObject

#sport=Object

Set TCP source port and update checksum



235
236
237
# File 'ext/pcap/tcp_packet.c', line 235

static VALUE
tcpp_sport_set(self, val)
VALUE self, val;

#tcp_ackObject

#tcp_ack?Boolean

Returns:

  • (Boolean)

#tcp_csum_ok?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'ext/pcap/tcp_packet.c', line 109

static VALUE
tcpp_csumok(self)
VALUE self;

#tcp_csum_update!Object

Calculate TCP checksum and update it in packet



181
182
183
# File 'ext/pcap/tcp_packet.c', line 181

static VALUE
tcpp_csum_update(self)
VALUE self;

#tcp_dataObject

#tcp_data_lenObject



168
169
170
# File 'ext/pcap/tcp_packet.c', line 168

def tcp_data_len
  ip_len - 4 * (ip_hlen + tcp_hlen)
end

#tcp_dportObject

#tcp_dport=Object

Set TCP destination port and update checksum



267
268
269
# File 'ext/pcap/tcp_packet.c', line 267

static VALUE
tcpp_dport_set(self, val)
VALUE self, val;

#tcp_fin?Boolean

Returns:

  • (Boolean)

#tcp_flagsObject

#tcp_flags_sObject



44
45
46
47
48
49
50
51
52
# File 'lib/pcap/packet.rb', line 44

def tcp_flags_s
  return \
	(tcp_urg? ? 'U' : '.') +
	(tcp_ack? ? 'A' : '.') +
	(tcp_psh? ? 'P' : '.') +
	(tcp_rst? ? 'R' : '.') +
	(tcp_syn? ? 'S' : '.') +
    (tcp_fin? ? 'F' : '.')
end

#tcp_hlenObject

#tcp_offObject

#tcp_optionsObject



95
96
97
# File 'ext/pcap/tcp_packet.c', line 95

static VALUE
tcpp_options(self)
VALUE self;

#tcp_psh?Boolean

Returns:

  • (Boolean)

#tcp_rst?Boolean

Returns:

  • (Boolean)

#tcp_seqObject

#tcp_sportObject

define methods under IPv4

#tcp_sport=Object

Set TCP source port and update checksum



235
236
237
# File 'ext/pcap/tcp_packet.c', line 235

static VALUE
tcpp_sport_set(self, val)
VALUE self, val;

#tcp_sumObject

#tcp_syn?Boolean

Returns:

  • (Boolean)

#tcp_truncated?Boolean

Returns:

  • (Boolean)


153
154
155
# File 'ext/pcap/tcp_packet.c', line 153

static VALUE
tcpp_truncated(self)
VALUE self;

#tcp_urg?Boolean

Returns:

  • (Boolean)

#tcp_urpObject

#tcp_winObject

#to_sObject



54
55
56
# File 'lib/pcap/packet.rb', line 54

def to_s
  "#{src}:#{sport} > #{dst}:#{dport} #{tcp_flags_s}"
end