Class: Pcap::TCPPacket
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_ttl, #ip_ver, #src, #src=
Methods inherited from Packet
#=~, #_dump, #_dump_to, _load, _load_from, #caplen, #datalink, #inspect, #ip?, #length, #raw_data, #size, #tcp?, #time, #time_i, #time_i=, #udata, #udata=, #udp?
Instance Method Details
#dport ⇒ Object
#dst_mac_address ⇒ Object
42
43
44
|
# File 'lib/pcap_misc.rb', line 42
def dst_mac_address
return unpack_hex_string(raw_data[0, 6])
end
|
#sport ⇒ Object
#src_mac_address ⇒ Object
38
39
40
|
# File 'lib/pcap_misc.rb', line 38
def src_mac_address
return unpack_hex_string(raw_data[6, 12])
end
|
#tcp_ack ⇒ Object
#tcp_data ⇒ Object
#tcp_data_len ⇒ Object
20
21
22
|
# File 'lib/pcap_misc.rb', line 20
def tcp_data_len
ip_len - 4 * (ip_hlen + tcp_hlen)
end
|
#tcp_dport ⇒ Object
#tcp_flags ⇒ Object
#tcp_flags_s ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/pcap_misc.rb', line 24
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_hlen ⇒ Object
#tcp_off ⇒ Object
#tcp_seq ⇒ Object
#tcp_sport ⇒ Object
#tcp_sum ⇒ Object
#tcp_urp ⇒ Object
#tcp_win ⇒ Object
#to_s ⇒ Object
34
35
36
|
# File 'lib/pcap_misc.rb', line 34
def to_s
"#{src}:#{sport} > #{dst}:#{dport} #{tcp_flags_s}"
end
|
#unpack_hex_string(hex) ⇒ Object
46
47
48
|
# File 'lib/pcap_misc.rb', line 46
def unpack_hex_string(hex)
return hex.unpack('H2H2H2H2H2H2').join('')
end
|