blob: acff501111db48d0a42483df417c1c5bf13b96a7 [file] [log] [blame]
Harald Weltee2bbbb32011-10-10 21:43:57 +02001% SCCP subsystem for dumping SCCP messages (testing)
2
3% (C) 2010-2011 by Harald Welte <laforge@gnumonks.org>
4%
5% All Rights Reserved
6%
7% This program is free software; you can redistribute it and/or modify
8% it under the terms of the GNU Affero General Public License as
9% published by the Free Software Foundation; either version 3 of the
10% License, or (at your option) any later version.
11%
12% This program is distributed in the hope that it will be useful,
13% but WITHOUT ANY WARRANTY; without even the implied warranty of
14% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15% GNU General Public License for more details.
16%
17% You should have received a copy of the GNU Affero General Public
18% License
19% along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21-module(sccp_ssn_dump).
22-behaviour(gen_server).
23-export([start_link/1, init/1, handle_info/2]).
24
25-include_lib("osmo_ss7/include/osmo_util.hrl").
26-include_lib("osmo_ss7/include/sccp.hrl").
27
28-record(loop_dat, {
29 ssns
30}).
31
32start_link(Ssns) ->
33 gen_server:start_link(sccp_ssn_dump, [Ssns], []).
34
Harald Welteb94e8fc2012-01-28 14:44:25 +010035init([Ssn]) when is_tuple(Ssn) ->
Harald Weltee2bbbb32011-10-10 21:43:57 +020036 init([Ssn]);
Harald Welteb94e8fc2012-01-28 14:44:25 +010037init([Ssns]) when is_list(Ssns) ->
Harald Weltee2bbbb32011-10-10 21:43:57 +020038 bind_ssns(Ssns),
39 {ok, idle, #loop_dat{ssns = Ssns}}.
40
41bind_ssns([]) ->
42 ok;
43bind_ssns([{Ssn, Pc}|Tail]) ->
44 io:format("binding ~p ~p~n", [Ssn, Pc]),
45 ok = sccp_user:bind_ssn(Ssn, Pc),
46 bind_ssns(Tail).
47
48
49handle_info({sccp, Prim}, LoopDat) ->
50 io:format("sccp_ssn_dump in: ~p~n", [Prim]),
51 {noreply, LoopDat}.