lib/mu/scenario/pcap.rb in pcapr-local-0.1.13 vs lib/mu/scenario/pcap.rb in pcapr-local-0.2.0
- old
+ new
@@ -13,18 +13,26 @@
module Pcap
TSHARK_READ_TIMEOUT = 10.0 # seconds
TSHARK_LINES_PER_PACKET = 16384
TSHARK_OPTS = "-n -o tcp.desegment_tcp_streams:false"
+ TSHARK_OPTS_SUFFIX = TSHARK_OPTS
TSHARK_SIZE_OPTS = "-n -o 'column.format: cum_size, \"%B\"'"
TSHARK_PSML_OPTS = %Q{#{TSHARK_OPTS} -o 'column.format: "Protocol", "%p", "Info", "%i"'}
MAX_PCAP_SIZE = 102400 # 100KB
MAX_RAW_PCAP_SIZE_MB = 25
MAX_RAW_PCAP_SIZE = MAX_RAW_PCAP_SIZE_MB * 1024 * 1000
EXCLUDE_FROM_SIZE_CHECK = ['rtp'].freeze
class PcapTooLarge < StandardError; end
+
+ def self.reset_options options
+ return unless options
+ tshark_opts = options << ' ' << TSHARK_OPTS_SUFFIX
+ remove_const(:TSHARK_OPTS) if const_defined?(:TSHARK_OPTS)
+ const_set(:TSHARK_OPTS, tshark_opts)
+ end
def self.validate_pcap_size(path)
tshark_filter = EXCLUDE_FROM_SIZE_CHECK.map{ |proto| "not #{proto}" }.join " and "
io = ::IO.popen "tshark #{TSHARK_SIZE_OPTS} -r #{path} -R '#{tshark_filter}' | tail -1"
if ::IO.select [ io ], nil, nil, TSHARK_READ_TIMEOUT