class Spcap::TCPPacket
Public Class Methods
new(time,data,len,datalink)
click to toggle source
Calls superclass method
Spcap::IPPacket::new
# File lib/spcap/tcppacket.rb, line 4 def initialize(time,data,len,datalink) super(time,data,len,datalink) end
Public Instance Methods
channel()
click to toggle source
# File lib/spcap/tcppacket.rb, line 8 def channel ; [[src,sport],[dst,dport]] ; end
direction()
click to toggle source
# File lib/spcap/tcppacket.rb, line 11 def direction ; full_session == channel ; end
dport()
click to toggle source
# File lib/spcap/tcppacket.rb, line 28 def dport ; tcp_dport ; end
full_session()
click to toggle source
# File lib/spcap/tcppacket.rb, line 9 def full_session ; channel.sort ; end
session()
click to toggle source
# File lib/spcap/tcppacket.rb, line 10 def session ; full_session.hash ; end
sport()
click to toggle source
# File lib/spcap/tcppacket.rb, line 24 def sport ; tcp_sport ; end
tcp_ack()
click to toggle source
Return acknowledgement number.
# File lib/spcap/tcppacket.rb, line 14 def tcp_ack ; ip_data[8,4].unpack("N").first ; end
tcp_ack?()
click to toggle source
# File lib/spcap/tcppacket.rb, line 46 def tcp_ack? ; flag?(3) ; end
tcp_data()
click to toggle source
Return data part as String.
# File lib/spcap/tcppacket.rb, line 17 def tcp_data ; ip_data[tcp_off*4,tcp_data_len] ; end
tcp_data_len()
click to toggle source
Return length of data part.
# File lib/spcap/tcppacket.rb, line 20 def tcp_data_len ; ip_len - ( ip_hlen * 4 ) - (tcp_hlen * 4) ; end
tcp_dport()
click to toggle source
Return destination port number.
# File lib/spcap/tcppacket.rb, line 27 def tcp_dport ; ip_data[2,2].unpack("n").first ; end
tcp_fin?()
click to toggle source
Return true if flag is set.
# File lib/spcap/tcppacket.rb, line 42 def tcp_fin? ; flag?(7) ; end
tcp_flags()
click to toggle source
Return the value of 6-bits flag field.
# File lib/spcap/tcppacket.rb, line 31 def tcp_flags ; ( ip_data.getbyte(13) & 0x3F ) ; end
tcp_flags_s()
click to toggle source
Return the value of 6-bits flag field as string like “.A…F”.
# File lib/spcap/tcppacket.rb, line 34 def tcp_flags_s ip_data[13].unpack("B*").first[2,6]. chars.zip(TCP_FLAGS.chars).collect { |flag,flag_s| (flag == '0' ? '.' : flag_s) }.join end
tcp_hlen()
click to toggle source
Return TCP data offset (header length). (Unit: 4-octets)
# File lib/spcap/tcppacket.rb, line 50 def tcp_hlen ; ( ( ip_data.getbyte(12) & 0XF0) / 16 ) ; end
tcp_off()
click to toggle source
# File lib/spcap/tcppacket.rb, line 51 def tcp_off ; tcp_hlen ; end
tcp_psh?()
click to toggle source
# File lib/spcap/tcppacket.rb, line 45 def tcp_psh? ; flag?(4) ; end
tcp_rst?()
click to toggle source
# File lib/spcap/tcppacket.rb, line 44 def tcp_rst? ; flag?(5) ; end
tcp_seq()
click to toggle source
Return sequence number.
# File lib/spcap/tcppacket.rb, line 54 def tcp_seq ; ( ip_data[4,4].unpack("N").first ) ; end
tcp_sport()
click to toggle source
Return destination port number.
# File lib/spcap/tcppacket.rb, line 23 def tcp_sport ; ip_data[0,2].unpack("n").first ; end
tcp_sum()
click to toggle source
Return the value of checksum field.
# File lib/spcap/tcppacket.rb, line 57 def tcp_sum ; ( ip_data[16,2].unpack("n").first ) ; end
tcp_syn?()
click to toggle source
# File lib/spcap/tcppacket.rb, line 43 def tcp_syn? ; flag?(6) ; end
tcp_urg?()
click to toggle source
# File lib/spcap/tcppacket.rb, line 47 def tcp_urg? ; flag?(2) ; end
tcp_urp()
click to toggle source
Return urgent pointer.
# File lib/spcap/tcppacket.rb, line 60 def tcp_urp ; ( ip_data[18,2].unpack("n").first ) ; end
tcp_win()
click to toggle source
Return window size.
# File lib/spcap/tcppacket.rb, line 63 def tcp_win ; ( ip_data[14,2].unpack("n").first ) ; end
to_s()
click to toggle source
Return string representation.
# File lib/spcap/tcppacket.rb, line 66 def to_s ; "TODO" ; end
Private Instance Methods
flag?(i)
click to toggle source
# File lib/spcap/tcppacket.rb, line 69 def flag?(i) ; ip_data[13].unpack("B*").first[i] == '1'; end