Skip to content

Instantly share code, notes, and snippets.

@TrevorS
Created September 9, 2014 00:07
Show Gist options
  • Save TrevorS/eeb328f014734ed682a7 to your computer and use it in GitHub Desktop.
Save TrevorS/eeb328f014734ed682a7 to your computer and use it in GitHub Desktop.
defmodule ZteCdmaCdr do
defstruct type: nil,
sequence_number: nil,
call_reference: nil
def parse(line) do
<< type :: size(11) - binary,
sequence_number :: size(12) - binary,
call_reference :: size(12) - binary,
partial_output_rec_num :: size(12) - binary,
served_imsi :: size(15) - binary,
served_imei :: size(16) - binary,
ton_original_called_number :: size(11) - binary,
original_called_number :: size(33) - binary,
ton_original_calling_number :: size(11) - binary,
original_calling_number :: size(17) - binary,
ton_calling_number :: size(12) - binary,
calling_number :: size(17) - binary,
ton_called_number :: size(11) - binary,
called_number :: size(33) - binary,
service_category :: size(6) - binary,
supplemental_service_code :: size(4) - binary,
starting_date :: size(11) - binary,
starting_time :: size(10) - binary,
end_time :: size(9) - binary,
duration :: size(10) - binary,
outgoing_route_number :: size(10) - binary,
incoming_route_number :: size(10) - binary,
party_to_be_billed :: size(10) - binary,
location_of_originating :: size(8) - binary,
cellid_of_originating :: size(8) - binary,
exit_cause :: size(10) - binary,
ton_roaming_number :: size(10) - binary,
roaming_number :: size(17) - binary,
ton_msc_in :: size(17) - binary,
time_for_alerting :: size(10) - binary,
lrn :: size(17) - binary,
mscid :: size(10) - binary,
mgwid :: size(10) - binary,
served_party_roaming_ind :: size(2) - binary,
service_option :: size(6) - binary,
last_cell_id :: size(12) - binary,
bypass_in_flag :: size(2) - binary,
is_win_subscriber :: size(2) - binary,
service_key :: size(10) - binary,
is_win_init_call_forward :: size(2) - binary,
win_destination_number :: size(19) - binary,
_rest :: binary >> = line
%ZteCdmaCdr{ type: String.strip(type),
sequence_number: String.strip(sequence_number),
call_reference: String.strip(call_reference) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment