TCO: fix generation of incoming tcap_transaction_sup tree

This moves the 'server' side of the TCAP code to generate a proper
tcap_transaction_sup sub-tree on an incoming BEGIN
This commit is contained in:
Harald Welte 2013-06-08 09:02:50 +02:00
parent f1803eabfb
commit db99b66859
1 changed files with 32 additions and 16 deletions

View File

@ -307,26 +307,35 @@ handle_cast({'N', 'UNITDATA', indication, UdataParams}, State)
% or that there are enough resources available. The real % or that there are enough resources available. The real
% test is in whether the start succeeds. % test is in whether the start succeeds.
case supervisor:start_child(State#state.supervisor, ChildSpec) of case supervisor:start_child(State#state.supervisor, ChildSpec) of
% FIXME: the entire mobile-termianted {ok, _TransSupPid} ->
% transaction handling needs to reflect tcap_transaction_sup
{ok, TSM} ->
% Created a Transaction State Machine (TSM) % Created a Transaction State Machine (TSM)
TsmParams = UdataParams#'N-UNITDATA'{userData = TPDU}, case ets:lookup_element(tcap_transaction, TransactionID, 2) of
% BEGIN received TSM <- TCO TSM ->
gen_fsm:send_event(TSM, {'BEGIN', received, TsmParams}); TsmParams = UdataParams#'N-UNITDATA'{userData = TPDU},
_Other -> % BEGIN received TSM <- TCO
gen_fsm:send_event(TSM, {'BEGIN', received, TsmParams});
{error, _Reason} ->
error_logger:error_report(["Unable to find TSM that was just started"])
end;
Other ->
error_logger:error_report(["Unable to start TSM", {childspec, ChildSpec}, {error, Other}]),
% TID = no TID % TID = no TID
% Build ABORT message (P-Abort Cause = Resource Limitation) % Build ABORT message (P-Abort Cause = Resource Limitation)
Abort = {abort, #'Abort'{dtid = TPDU#'Begin'.otid, Abort = {abort, #'Abort'{dtid = encode_tid(TPDU#'Begin'.otid),
reason = {'p-abortCause', resourceLimitation}}}, reason = {'p-abortCause', resourceLimitation}}},
NewTPDU = list_to_binary('TR':encode('TCMessage', Abort)), case 'TR':encode('TCMessage', Abort) of
SccpParams = #'N-UNITDATA'{calledAddress = UdataParams#'N-UNITDATA'.callingAddress, {ok, EncAbort} ->
callingAddress = UdataParams#'N-UNITDATA'.calledAddress, SccpParams = #'N-UNITDATA'{calledAddress = UdataParams#'N-UNITDATA'.callingAddress,
sequenceControl = false, returnOption = false, importance = none, callingAddress = UdataParams#'N-UNITDATA'.calledAddress,
userData = NewTPDU}, sequenceControl = false,
% TR-UNI request TSL -> SCCP returnOption = false, importance = none,
Module = State#state.module, userData = list_to_binary(EncAbort)},
Module:send_primitive({'N', 'UNITDATA', request, SccpParams}, State#state.ext_state), % TR-UNI request TSL -> SCCP
Module = State#state.module,
Module:send_primitive({'N', 'UNITDATA', request, SccpParams}, State#state.ext_state);
{error, Err} ->
error_logger:error_report(["Error generating ASN1", {abort, Abort}, {error, Err}])
end,
error_logger:error_report(["Unable to create TSM for received N-BEGIN", error_logger:error_report(["Unable to create TSM for received N-BEGIN",
{caller, UdataParams#'N-UNITDATA'.callingAddress}, {caller, UdataParams#'N-UNITDATA'.callingAddress},
{called, UdataParams#'N-UNITDATA'.calledAddress}]) {called, UdataParams#'N-UNITDATA'.calledAddress}])
@ -735,6 +744,13 @@ decode_tid(Bin) when is_binary(Bin) ->
decode_tid(List) when is_list(List) -> decode_tid(List) when is_list(List) ->
decode_tid(list_to_binary(List)). decode_tid(list_to_binary(List)).
encode_tid(In) when is_integer(In) ->
<<In:32/big>>;
encode_tid(In) when is_list(In) ->
list_to_binary(In);
encode_tid(In) when is_binary(In) ->
In.
postproc_tcmessage(C=#'Continue'{otid = Otid, dtid = Dtid}) -> postproc_tcmessage(C=#'Continue'{otid = Otid, dtid = Dtid}) ->
C#'Continue'{otid = decode_tid(Otid), dtid = decode_tid(Dtid)}; C#'Continue'{otid = decode_tid(Otid), dtid = decode_tid(Dtid)};
postproc_tcmessage(E=#'End'{dtid = Dtid}) -> postproc_tcmessage(E=#'End'{dtid = Dtid}) ->