Class: PcapTools::TcpStream
- Inherits:
-
Array
- Object
- Array
- PcapTools::TcpStream
- Defined in:
- lib/pcap_tools.rb
Instance Method Summary collapse
Instance Method Details
#insert_tcp(sym, packet) ⇒ Object
28 29 30 31 32 |
# File 'lib/pcap_tools.rb', line 28 def insert_tcp sym, packet data = packet.payload return if data.size == 0 self << {:type => sym, :data => data, :from => packet.ip_saddr, :to => packet.ip_daddr, :from_port => packet.tcp_src, :to_port => packet.tcp_dst} end |
#rebuild_packets ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pcap_tools.rb', line 34 def rebuild_packets out = TcpStream.new current = nil self.each do |packet| if current if packet[:type] == current[:type] current[:data] += packet[:data] else out << current current = packet.clone end else current = packet.clone end end out << current if current out end |