summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-10-19 13:40:39 +0200
committerHarald Welte <laforge@gnumonks.org>2011-10-19 13:40:39 +0200
commit7dadde8c70131b14b14445246e2f68c7331e26e8 (patch)
treef7a182f969dfbca091733c0c8f305be662e41d3a
parent805fac48ee31434180aee476261cdcddb145ad92 (diff)
Make sure an incoming M3UA message is actually sent to registered service Pid
-rw-r--r--include/sccp.hrl9
-rw-r--r--src/m3ua_core.erl2
-rw-r--r--src/ss7_link_m3ua.erl8
-rw-r--r--src/ss7_links.erl21
4 files changed, 32 insertions, 8 deletions
diff --git a/include/sccp.hrl b/include/sccp.hrl
index c19e512..83386cc 100644
--- a/include/sccp.hrl
+++ b/include/sccp.hrl
@@ -112,6 +112,15 @@
-define(SCCP_CAUSE_REF_NO_GTT_FOR_NATURE, 2#00010010).
-define(SCCP_CAUSE_REF_UNEQUIPPED_USER, 2#00010011).
+% SCCP sub-system numbers
+-define(SCCP_SSN_MAP_HLR, 6).
+-define(SCCP_SSN_MAP_VLR, 7).
+-define(SCCP_SSN_MAP_MSC, 8).
+-define(SCCP_SSN_MAP_EIR, 9).
+-define(SCCP_SSN_MAP_GMLC, 145).
+-define(SCCP_SSN_MAP_gsmSCF, 147).
+-define(SCCP_SSN_MAP_SGSN, 149).
+-define(SCCP_SSN_MAP_GGSN, 150).
% a single parsed SCCP message
diff --git a/src/m3ua_core.erl b/src/m3ua_core.erl
index 3211bfa..3986305 100644
--- a/src/m3ua_core.erl
+++ b/src/m3ua_core.erl
@@ -277,7 +277,7 @@ asp_active(#m3ua_msg{version = 1, msg_class = ?M3UA_MSGC_TRANSFER,
msg_type = ?M3UA_MSGT_XFR_DATA, payload = Params}, LoopDat) ->
% Data transfer from remote entity: Send MTP-TRANSFER.ind primitive to the user
Mtp3 = proplists:get_value(?M3UA_IEI_PROTOCOL_DATA, Params),
- send_prim_to_user(LoopDat, osmo_util:make_prim('MTP','TRANSFER',indication,[Mtp3])),
+ send_prim_to_user(LoopDat, osmo_util:make_prim('MTP','TRANSFER',indication,Mtp3)),
{next_state, asp_active, LoopDat};
asp_active(#m3ua_msg{msg_class = ?M3UA_MSGC_ASPTM,
msg_type = ?M3UA_MSGT_ASPTM_ASPIA_ACK}, LoopDat) ->
diff --git a/src/ss7_link_m3ua.erl b/src/ss7_link_m3ua.erl
index 7b35617..95fba70 100644
--- a/src/ss7_link_m3ua.erl
+++ b/src/ss7_link_m3ua.erl
@@ -65,9 +65,13 @@ scrc_tx_to_mtp(Prim, Args) ->
% Callback that we pass to the m3ua_core, which it will call when it wants to
% send a primitive up the stack to SCCP
-m3ua_tx_to_user(Prim, Args) ->
+m3ua_tx_to_user(P=#primitive{subsystem = 'MTP'}, Args) ->
+ % send it directly to the 'service' that has bound
+ ss7_links:mtp3_rx(P);
+m3ua_tx_to_user(P=#primitive{subsystem = 'M'}, Args) ->
+ % send management primitives into the m3ua_link process
UserPid = Args,
- gen_server:cast(UserPid, Prim).
+ gen_server:cast(UserPid, P).
handle_cast(P = #primitive{subsystem = 'MTP', gen_name = 'TRANSFER', spec_name = request}, L) ->
scrc_tx_to_mtp(P, L#loop_dat.m3ua_pid),
diff --git a/src/ss7_links.erl b/src/ss7_links.erl
index c4e6a3c..aa91330 100644
--- a/src/ss7_links.erl
+++ b/src/ss7_links.erl
@@ -21,6 +21,7 @@
-behaviour(gen_server).
-include_lib("osmo_ss7/include/mtp3.hrl").
+-include_lib("osmo_ss7/include/osmo_util.hrl").
% gen_fsm callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
@@ -35,7 +36,8 @@
-export([bind_service/2, unbind_service/1]).
-export([get_pid_for_link/2, get_pid_for_dpc_sls/2, mtp3_tx/1,
- get_linkset_for_dpc/1, get_opc_for_linkset/1, is_pc_local/1, dump/0]).
+ get_linkset_for_dpc/1, get_opc_for_linkset/1, is_pc_local/1,
+ get_user_pid_for_service/1, mtp3_rx/1, dump/0]).
-record(slink, {
key, % {linkset_name, sls}
@@ -118,6 +120,14 @@ unbind_service(ServiceNum) ->
% the lookup functions can directly use the ets named_table from within
% the client process, no need to go through a synchronous IPC
+get_user_pid_for_service(Service) when is_integer(Service) ->
+ case ets:lookup(mtp3_services, Service) of
+ [#service{user_pid=Pid}] ->
+ {ok, Pid};
+ [] ->
+ {error, no_such_service}
+ end.
+
get_pid_for_link(LinksetName, Sls) when is_list(LinksetName), is_integer(Sls) ->
case ets:lookup(ss7_link_table, {LinksetName, Sls}) of
[#slink{user_pid = Pid}] ->
@@ -168,12 +178,13 @@ is_pc_local(Pc) when is_integer(Pc) ->
end.
% process a received message on an underlying link
-mtp3_rx(Mtp3 = #mtp3_msg{service_ind = Serv}) ->
+mtp3_rx(Mtp3 = #mtp3_msg{}) ->
+ mtp3_rx(osmo_util:make_prim('MTP', 'TRANSFER',
+ indication, Mtp3));
+mtp3_rx(P = #primitive{parameters=#mtp3_msg{service_ind=Serv}}) ->
case ets:lookup(mtp3_services, Serv) of
[#service{user_pid = Pid}] ->
- gen_server:cast(Pid,
- osmo_util:make_prim('MTP', 'TRANSFER',
- indication, Mtp3));
+ gen_server:cast(Pid, P);
_ ->
% FIXME: send back some error message on MTP level
ok