forked from erlang/signerl
add new tcap_user module
This is what a user process will call in order to initiate TCAP transactions.
This commit is contained in:
parent
efd9ab0344
commit
6f1e72c678
|
@ -5,7 +5,7 @@ EBIN = ../ebin
|
||||||
ERL = erl
|
ERL = erl
|
||||||
ERLC = erlc
|
ERLC = erlc
|
||||||
EMULATOR = beam
|
EMULATOR = beam
|
||||||
ERLCFLAGS = -b $(EMULATOR) -o $(EBIN) -W -v +warn_unused_vars
|
ERLCFLAGS = -b $(EMULATOR) -o $(EBIN) -W -v +warn_unused_vars -I../include
|
||||||
|
|
||||||
$(EBIN)/%.$(EMULATOR):%.erl
|
$(EBIN)/%.$(EMULATOR):%.erl
|
||||||
$(ERLC) $(ERLCFLAGS) $<
|
$(ERLC) $(ERLCFLAGS) $<
|
||||||
|
@ -16,7 +16,8 @@ BEAMS = $(EBIN)/tcap.$(EMULATOR) $(EBIN)/tcap_app.$(EMULATOR) \
|
||||||
$(EBIN)/tcap_transaction_sup.$(EMULATOR) \
|
$(EBIN)/tcap_transaction_sup.$(EMULATOR) \
|
||||||
$(EBIN)/tcap_dialogue_sup.$(EMULATOR) \
|
$(EBIN)/tcap_dialogue_sup.$(EMULATOR) \
|
||||||
$(EBIN)/tcap_components_sup.$(EMULATOR) \
|
$(EBIN)/tcap_components_sup.$(EMULATOR) \
|
||||||
$(EBIN)/tcap_invocation_sup.$(EMULATOR)
|
$(EBIN)/tcap_invocation_sup.$(EMULATOR) \
|
||||||
|
$(EBIN)/tcap_user.$(EMULATOR)
|
||||||
|
|
||||||
.PHONY: default
|
.PHONY: default
|
||||||
default: all
|
default: all
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
-module(tcap_user).
|
||||||
|
|
||||||
|
-export([send_prim/2]).
|
||||||
|
|
||||||
|
-include("tcap.hrl").
|
||||||
|
|
||||||
|
% the user (TCU) sends us a primitive. We decide where to route it
|
||||||
|
send_prim(TCO, P={'TC', 'INVOKE', request, Param}) when
|
||||||
|
is_record(Param, 'TC-INVOKE') ->
|
||||||
|
DialgId = Param#'TC-INVOKE'.dialogueID,
|
||||||
|
case ets:lookup(tcap_dha, DialgId) of
|
||||||
|
[] ->
|
||||||
|
% start new DHA FSM for this dialogue; it will start CCO
|
||||||
|
DHA = start_new_dha(TCO, DialgId);
|
||||||
|
[DHA] ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
|
% resolve CCO from DHA
|
||||||
|
CCO = tcap_dha_fsm:get_cco_pid(DHA),
|
||||||
|
gen_server:cast(CCO, P);
|
||||||
|
send_prim(TCO, P={'TC', 'BEGIN', request, Param}) when
|
||||||
|
is_record(Param, 'TC-BEGIN') ->
|
||||||
|
DialgId = Param#'TC-BEGIN'.dialogueID,
|
||||||
|
case ets:lookup(tcap_dha, DialgId) of
|
||||||
|
[] ->
|
||||||
|
% start new DHA FSM for this dialogue; it will start CCO
|
||||||
|
DHA = start_new_dha(TCO, DialgId);
|
||||||
|
[DHA] ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
|
gen_fsm:send_event(DHA, P);
|
||||||
|
send_prim(_TCO, P) ->
|
||||||
|
{errror, {unknown_prim, P}}.
|
||||||
|
|
||||||
|
|
||||||
|
%% local functions
|
||||||
|
|
||||||
|
start_new_dha(TCO, LocalTID) ->
|
||||||
|
Args = [self(), LocalTID, TCO],
|
||||||
|
{ok, Pid} = supervisor:start_link(tcap_dialogue_sup, Args),
|
||||||
|
Pid.
|
||||||
|
|
Loading…
Reference in New Issue