forked from erlang/signerl
TCO: make sure transaciton IDs are always converted from binary to int
This commit is contained in:
parent
67f6051009
commit
250b36f2d8
|
@ -179,6 +179,7 @@ behaviour_info(Other) ->
|
|||
gen_server:behaviour_info(Other).
|
||||
|
||||
-include("TCAPMessages.hrl").
|
||||
%-include("TR.hrl").
|
||||
-include("tcap.hrl").
|
||||
-include("sccp.hrl").
|
||||
|
||||
|
@ -268,12 +269,11 @@ handle_call(Request, From, State) ->
|
|||
% reference: Figure A.3/Q.774 (sheet 1 of 4)
|
||||
handle_cast({'N', 'UNITDATA', indication, UdataParams}, State)
|
||||
when is_record(UdataParams, 'N-UNITDATA') ->
|
||||
DecRes = 'TR':decode('TCMessage', UdataParams#'N-UNITDATA'.userData),
|
||||
io:format("Decoded TCMessage: ~p~n", [DecRes]),
|
||||
case DecRes of
|
||||
{ok, {unidirectional, TPDU}} ->
|
||||
case 'TR':decode('Unidirectional', TPDU) of
|
||||
{ok, Unidirectional} ->
|
||||
{ok, {Tag, ActRes}} = 'TR':decode('TCMessage', UdataParams#'N-UNITDATA'.userData),
|
||||
PpRes = {Tag, postproc_tcmessage(ActRes)},
|
||||
io:format("Decoded TCMessage: ~p~n", [PpRes]),
|
||||
case PpRes of
|
||||
{unidirectional, Unidirectional = #'Unidirectional'{}} ->
|
||||
% Create a Dialogue Handler (DHA)
|
||||
DialogueID = new_tid(),
|
||||
StartFunc = get_start(dialogue, DialogueID, State),
|
||||
|
@ -288,17 +288,15 @@ handle_cast({'N', 'UNITDATA', indication, UdataParams}, State)
|
|||
userData = UserData},
|
||||
gen_fsm:send_event(DHA, {'TR', 'UNI', indication, TrParams}),
|
||||
{noreply, State};
|
||||
{error, Reason} ->
|
||||
% Discard received message
|
||||
% reference: Figure A.3/Q/774 (sheet 4 of 4) label (3)
|
||||
error_logger:error_report(["Syntax error in received N-UNI", {error, Reason},
|
||||
{caller, UdataParams#'N-UNITDATA'.callingAddress},
|
||||
{called, UdataParams#'N-UNITDATA'.calledAddress}]),
|
||||
{noreply, State}
|
||||
end;
|
||||
{ok, {'begin', TPDU}} ->
|
||||
case 'TR':decode('Begin', TPDU) of
|
||||
{ok, Begin} ->
|
||||
% {error, Reason} ->
|
||||
% % Discard received message
|
||||
% % reference: Figure A.3/Q/774 (sheet 4 of 4) label (3)
|
||||
% error_logger:error_report(["Syntax error in received N-UNI", {error, Reason},
|
||||
% {caller, UdataParams#'N-UNITDATA'.callingAddress},
|
||||
% {called, UdataParams#'N-UNITDATA'.calledAddress}]),
|
||||
% {noreply, State}
|
||||
% end;
|
||||
{'begin', TPDU = #'Begin'{}} ->
|
||||
% Assign local transaction ID
|
||||
TransactionID = new_tid(),
|
||||
StartFunc = get_start(in_transaction, TransactionID, State),
|
||||
|
@ -313,7 +311,7 @@ handle_cast({'N', 'UNITDATA', indication, UdataParams}, State)
|
|||
% transaction handling needs to reflect tcap_transaction_sup
|
||||
{ok, TSM} ->
|
||||
% Created a Transaction State Machine (TSM)
|
||||
TsmParams = UdataParams#'N-UNITDATA'{userData = Begin},
|
||||
TsmParams = UdataParams#'N-UNITDATA'{userData = TPDU},
|
||||
% BEGIN received TSM <- TCO
|
||||
gen_fsm:send_event(TSM, {'BEGIN', received, TsmParams});
|
||||
_Other ->
|
||||
|
@ -334,21 +332,20 @@ handle_cast({'N', 'UNITDATA', indication, UdataParams}, State)
|
|||
{called, UdataParams#'N-UNITDATA'.calledAddress}])
|
||||
end,
|
||||
{noreply, State};
|
||||
{error, Reason} ->
|
||||
% {error, Reason} ->
|
||||
% TODO
|
||||
% is OTID derivable?
|
||||
% Build ABORT message with appropraite P-Abort Cause value
|
||||
% N-UNITDATA request TSL -> SCCP
|
||||
% Discard received message
|
||||
% reference: Figure A.3/Q/774 (sheet 4 of 4) label (4)
|
||||
error_logger:error_report(["Syntax error in received N-BEGIN", {error, Reason},
|
||||
{caller, UdataParams#'N-UNITDATA'.callingAddress},
|
||||
{called, UdataParams#'N-UNITDATA'.calledAddress}]),
|
||||
{noreply, State}
|
||||
end;
|
||||
{ok, {continue, TPDU = #'Continue'{dtid = Dtid}}} ->
|
||||
% % is OTID derivable?
|
||||
% % Build ABORT message with appropraite P-Abort Cause value
|
||||
% % N-UNITDATA request TSL -> SCCP
|
||||
% % Discard received message
|
||||
% % reference: Figure A.3/Q/774 (sheet 4 of 4) label (4)
|
||||
% error_logger:error_report(["Syntax error in received N-BEGIN", {error, Reason},
|
||||
% {caller, UdataParams#'N-UNITDATA'.callingAddress},
|
||||
% {called, UdataParams#'N-UNITDATA'.calledAddress}]),
|
||||
% {noreply, State}
|
||||
{continue, TPDU = #'Continue'{dtid = Dtid}} ->
|
||||
% DTID assigned?
|
||||
case ets:lookup_element(tcap_transaction, decode_tid(Dtid), 2) of
|
||||
case ets:lookup_element(tcap_transaction, Dtid, 2) of
|
||||
{error, _Reason} ->
|
||||
error_logger:error_report(["DTID not found in received N-CONTINUE",
|
||||
{dtid, Dtid},
|
||||
|
@ -380,9 +377,9 @@ handle_cast({'N', 'UNITDATA', indication, UdataParams}, State)
|
|||
% {called, UdataParams#'N-UNITDATA'.calledAddress}]),
|
||||
% {noreply, State}
|
||||
% end;
|
||||
{ok, {'end', TPDU = #'End'{dtid = Dtid}}} ->
|
||||
{'end', TPDU = #'End'{dtid = Dtid}} ->
|
||||
% DTID assigned?
|
||||
case ets:lookup_element(tcap_transaction, decode_tid(Dtid), 2) of
|
||||
case ets:lookup_element(tcap_transaction, Dtid, 2) of
|
||||
{error, _Reason} ->
|
||||
error_logger:error_report(["DTID not found in received N-END",
|
||||
{dtid, Dtid},
|
||||
|
@ -408,9 +405,7 @@ handle_cast({'N', 'UNITDATA', indication, UdataParams}, State)
|
|||
% {called, UdataParams#'N-UNITDATA'.calledAddress}]),
|
||||
% {noreply, State}
|
||||
% end;
|
||||
{ok, {abort, TPDU}} ->
|
||||
case 'TR':decode('Abort', TPDU) of
|
||||
{ok, Abort} ->
|
||||
{abort, TPDU = #'Abort'{}} ->
|
||||
% DTID assigned?
|
||||
case catch ets:lookup(tcap_transaction, TPDU#'Abort'.dtid, 2) of
|
||||
{error, _Reason} ->
|
||||
|
@ -422,23 +417,23 @@ handle_cast({'N', 'UNITDATA', indication, UdataParams}, State)
|
|||
% reference: Figure A.3/Q/774 (sheet 4 of 4) label (3)
|
||||
{noreply, State};
|
||||
TSM ->
|
||||
TsmParams = UdataParams#'N-UNITDATA'{userData = Abort},
|
||||
TsmParams = UdataParams#'N-UNITDATA'{userData = TPDU},
|
||||
% Abort received TSM <- TCO
|
||||
gen_fsm:send_event(TSM, {'ABORT', received, TsmParams}),
|
||||
{noreply, State}
|
||||
end;
|
||||
{error, Reason} ->
|
||||
% {error, Reason} ->
|
||||
% TODO
|
||||
% DTID assigned?
|
||||
% Local Abort TSM <- TCO
|
||||
% Discard received message
|
||||
% reference: Figure A.3/Q/774 (sheet 4 of 4) label (5)
|
||||
error_logger:error_report(["Syntax error in received N-ABORT", {error, Reason},
|
||||
{caller, UdataParams#'N-UNITDATA'.callingAddress},
|
||||
{called, UdataParams#'N-UNITDATA'.calledAddress}]),
|
||||
{noreply, State}
|
||||
end;
|
||||
{ok, {error, Reason}} ->
|
||||
% % DTID assigned?
|
||||
% % Local Abort TSM <- TCO
|
||||
% % Discard received message
|
||||
% % reference: Figure A.3/Q/774 (sheet 4 of 4) label (5)
|
||||
% error_logger:error_report(["Syntax error in received N-ABORT", {error, Reason},
|
||||
% {caller, UdataParams#'N-UNITDATA'.callingAddress},
|
||||
% {called, UdataParams#'N-UNITDATA'.calledAddress}]),
|
||||
% {noreply, State}
|
||||
% end;
|
||||
{error, Reason} ->
|
||||
% TODO
|
||||
% Message type unknown
|
||||
% OTID derivable?
|
||||
|
@ -739,3 +734,11 @@ decode_tid(Bin) when is_binary(Bin) ->
|
|||
binary:decode_unsigned(Bin);
|
||||
decode_tid(List) when is_list(List) ->
|
||||
decode_tid(list_to_binary(List)).
|
||||
|
||||
postproc_tcmessage(C=#'Continue'{otid = Otid, dtid = Dtid}) ->
|
||||
C#'Continue'{otid = decode_tid(Otid), dtid = decode_tid(Dtid)};
|
||||
postproc_tcmessage(E=#'End'{dtid = Dtid}) ->
|
||||
E#'End'{dtid = decode_tid(Dtid)};
|
||||
postproc_tcmessage(B=#'Begin'{otid = Otid}) ->
|
||||
B#'Begin'{otid = decode_tid(Otid)}.
|
||||
|
||||
|
|
Loading…
Reference in New Issue