Harald Welte | e2bbbb3 | 2011-10-10 21:43:57 +0200 | [diff] [blame] | 1 | % 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 | |
| 32 | start_link(Ssns) -> |
| 33 | gen_server:start_link(sccp_ssn_dump, [Ssns], []). |
| 34 | |
Harald Welte | b94e8fc | 2012-01-28 14:44:25 +0100 | [diff] [blame^] | 35 | init([Ssn]) when is_tuple(Ssn) -> |
Harald Welte | e2bbbb3 | 2011-10-10 21:43:57 +0200 | [diff] [blame] | 36 | init([Ssn]); |
Harald Welte | b94e8fc | 2012-01-28 14:44:25 +0100 | [diff] [blame^] | 37 | init([Ssns]) when is_list(Ssns) -> |
Harald Welte | e2bbbb3 | 2011-10-10 21:43:57 +0200 | [diff] [blame] | 38 | bind_ssns(Ssns), |
| 39 | {ok, idle, #loop_dat{ssns = Ssns}}. |
| 40 | |
| 41 | bind_ssns([]) -> |
| 42 | ok; |
| 43 | bind_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 | |
| 49 | handle_info({sccp, Prim}, LoopDat) -> |
| 50 | io:format("sccp_ssn_dump in: ~p~n", [Prim]), |
| 51 | {noreply, LoopDat}. |