summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-10-12 17:17:55 +0200
committerHarald Welte <laforge@gnumonks.org>2011-10-12 17:17:55 +0200
commit805fac48ee31434180aee476261cdcddb145ad92 (patch)
tree8d46d7bda1e18005130ef02944cc5becc93582a3
parent9c3b1bb25f37c0d9634a9460ac2d709ee81e20d6 (diff)
ss7_links: add get_opc_for_linkset/1, is_pc_local/1
the functions are related to determining the local point code of signalling links.
-rw-r--r--src/ss7_links.erl28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/ss7_links.erl b/src/ss7_links.erl
index 75617f5..c4e6a3c 100644
--- a/src/ss7_links.erl
+++ b/src/ss7_links.erl
@@ -35,7 +35,7 @@
-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, dump/0]).
+ get_linkset_for_dpc/1, get_opc_for_linkset/1, is_pc_local/1, dump/0]).
-record(slink, {
key, % {linkset_name, sls}
@@ -118,7 +118,7 @@ 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_pid_for_link(LinksetName, Sls) ->
+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}] ->
% FIXME: check the link state
@@ -128,7 +128,7 @@ get_pid_for_link(LinksetName, Sls) ->
end.
% Resolve linkset name directly connected to given point code
-get_linkset_for_dpc(Dpc) ->
+get_linkset_for_dpc(Dpc) when is_integer (Dpc) ->
Ret = ets:match_object(ss7_linksets,
#slinkset{remote_pc = Dpc, _ = '_'}),
case Ret of
@@ -139,7 +139,7 @@ get_linkset_for_dpc(Dpc) ->
end.
% resolve link-handler Pid for given (directly connected) point code/sls
-get_pid_for_dpc_sls(Dpc, Sls) ->
+get_pid_for_dpc_sls(Dpc, Sls) when is_integer(Dpc) and is_integer(Sls) ->
case get_linkset_for_dpc(Dpc) of
{error, Err} ->
{error, Err};
@@ -147,6 +147,26 @@ get_pid_for_dpc_sls(Dpc, Sls) ->
get_pid_for_link(LinksetName, Sls)
end.
+% the the local point code for a given linkset
+get_opc_for_linkset(LsName) when is_list(LsName) ->
+ case ets:lookup(ss7_linksets, LsName) of
+ [#slinkset{local_pc = Opc}|_Tail] ->
+ Opc;
+ _ ->
+ undefined
+ end.
+
+% determine if a given point code is local
+is_pc_local(Pc) when is_integer(Pc) ->
+ Ret = ets:match_object(ss7_linksets,
+ #slinkset{local_pc = Pc, _ = '_'}),
+ case Ret of
+ [#slinkset{}] ->
+ true;
+ _ ->
+ false
+ end.
+
% process a received message on an underlying link
mtp3_rx(Mtp3 = #mtp3_msg{service_ind = Serv}) ->
case ets:lookup(mtp3_services, Serv) of