class Spcap::Scopy
Constants
- CURRENT_OUT_FILENAME
- FILENAME_EXTENTION
Public Class Methods
new(istream,opt = {})
click to toggle source
Calls superclass method
# File lib/spcap/scopy.rb, line 5 def initialize(istream,opt = {}) @tmpname = CURRENT_OUT_FILENAME @wpath = opt[:wpath] || '' @prefix = opt[:prefix] || '' @limit = opt[:limit] || 10000 @counter = 0 @ostream = new_file super(istream) packing = @unpack_16 + @unpack_16 + @unpack_32 + @unpack_32 + @unpack_32 + @unpack_32 @header = @magic_number + [@major_version, @minor_version, 0, 0, @snapshot_length, @linklayer_header_type].pack(packing) end
Public Instance Methods
backup_name()
click to toggle source
# File lib/spcap/scopy.rb, line 26 def backup_name @prefix + Time.now.strftime("%Y%m%d%H%M%S%6N") + FILENAME_EXTENTION end
finalize()
click to toggle source
# File lib/spcap/scopy.rb, line 36 def finalize @ostream.close end
new_file()
click to toggle source
# File lib/spcap/scopy.rb, line 24 def new_file ; File.new(File.expand_path(backup_name,@wpath),"w") ; end
next()
click to toggle source
Calls superclass method
# File lib/spcap/scopy.rb, line 40 def next pkt = super @counter += 1 if @counter == @limit switch_out @counter = 0 end return pkt end
read(size)
click to toggle source
# File lib/spcap/scopy.rb, line 18 def read(size) buf = @istream.read(size) @ostream.write(buf) return buf end
switch_out()
click to toggle source
# File lib/spcap/scopy.rb, line 30 def switch_out @ostream.close @ostream = new_file @ostream.write(@header) end