Harald Welte | c6e466e | 2011-10-10 14:03:50 +0200 | [diff] [blame] | 1 | % OTP Supervisor for Osmocom SCCP |
| 2 | |
| 3 | % (C) 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 License |
| 18 | % along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | -module(osmo_ss7_sup). |
| 21 | -behavior(supervisor). |
| 22 | |
| 23 | -export([start_link/0, add_mtp_link/1]). |
| 24 | -export([init/1]). |
| 25 | |
| 26 | -include_lib("osmo_ss7/include/osmo_ss7.hrl"). |
| 27 | |
| 28 | start_link() -> |
| 29 | supervisor:start_link({local, ?MODULE}, ?MODULE, [{debug, [trace]}]). |
| 30 | |
| 31 | init(Args) -> |
| 32 | LinksChild = {ss7_links, {ss7_links, start_link, []}, |
| 33 | permanent, 2000, worker, [ss7_links]}, |
Harald Welte | b8bfc4e | 2011-10-11 18:49:59 +0200 | [diff] [blame] | 34 | RouteChild = {ss7_routes, {ss7_routes, start_link, []}, |
| 35 | permanent, 2000, worker, [ss7_routes]}, |
| 36 | {ok,{{one_for_one,60,600}, [LinksChild, RouteChild]}}. |
Harald Welte | c6e466e | 2011-10-10 14:03:50 +0200 | [diff] [blame] | 37 | |
| 38 | % Add a m3ua link to this supervisor |
| 39 | add_mtp_link(L=#sigtran_link{type = m3ua, name = Name, |
| 40 | local = Local, remote = Remote}) -> |
| 41 | ChildName = list_to_atom("ss7_link_m3ua_" ++ Name), |
| 42 | ChildSpec = {ChildName, {ss7_link_m3ua, start_link, [L]}, |
Harald Welte | 8fa297d | 2011-10-10 19:32:13 +0200 | [diff] [blame] | 43 | permanent, 2000, worker, [ss7_link_m3ua]}, |
Harald Welte | c6e466e | 2011-10-10 14:03:50 +0200 | [diff] [blame] | 44 | supervisor:start_child(?MODULE, ChildSpec); |
Harald Welte | 5cde762 | 2012-01-23 23:18:28 +0100 | [diff] [blame^] | 45 | add_mtp_link(L=#sigtran_link{type = ipa_client, name = Name}) -> |
| 46 | ChildName = list_to_atom("ss7_link_ipa_client_" ++ Name), |
| 47 | ChildSpec = {ChildName, {ss7_link_ipa_client, start_link, [L]}, |
| 48 | permanent, 2000, worker, [ss7_link_ipa_client]}, |
| 49 | supervisor:start_child(?MODULE, ChildSpec); |
Harald Welte | c6e466e | 2011-10-10 14:03:50 +0200 | [diff] [blame] | 50 | add_mtp_link([]) -> |
| 51 | ok; |
| 52 | add_mtp_link([Head|Tail]) -> |
| 53 | add_mtp_link(Head, Tail). |
| 54 | add_mtp_link(Head, Tail) -> |
| 55 | {ok, _Child} = add_mtp_link(Head), |
| 56 | add_mtp_link(Tail). |