better error handling in case application config is insufficient
This commit is contained in:
parent
92acea9084
commit
3ae9813cb2
|
@ -8,7 +8,8 @@
|
||||||
{mod, {mgw_nat_app, []}},
|
{mod, {mgw_nat_app, []}},
|
||||||
{applications, []},
|
{applications, []},
|
||||||
{env, [
|
{env, [
|
||||||
{rewrite_act_mod, mgw_nat_act_bow_onw },
|
% Specify the rewrite actor module
|
||||||
|
%{rewrite_act_mod, mgw_nat_act_bow_onw },
|
||||||
|
|
||||||
% SCCP static rewrite rules
|
% SCCP static rewrite rules
|
||||||
{sccp_rewrite_tbl, [
|
{sccp_rewrite_tbl, [
|
||||||
|
@ -16,23 +17,23 @@
|
||||||
{ 12340001, 98760001, "VLR" }
|
{ 12340001, 98760001, "VLR" }
|
||||||
]},
|
]},
|
||||||
|
|
||||||
% SCCP source masquerading pool
|
% Example SCCP source masquerading pool
|
||||||
{sccp_masq_gt_base, 12340000},
|
{sccp_masq_gt_base, 12340000},
|
||||||
{sccp_masq_gt_max, 9999},
|
{sccp_masq_gt_max, 9999},
|
||||||
|
|
||||||
% ISUP rewrite
|
% Example ISUP rewrite
|
||||||
{msrn_pfx_msc, 35489099},
|
{msrn_pfx_msc, 35489099},
|
||||||
{msrn_pfx_stp, 6392994200},
|
{msrn_pfx_stp, 6392994200},
|
||||||
{intern_pfx, 63},
|
{intern_pfx, 63},
|
||||||
|
|
||||||
% SCTP / IP config
|
% Example SCTP / IP config
|
||||||
{msc_local_ip, any},
|
{msc_local_ip, any},
|
||||||
{msc_local_port, 2904},
|
{msc_local_port, 2904},
|
||||||
{msc_remote_ip, {172,16,1,81}},
|
{msc_remote_ip, {172,16,1,81}},
|
||||||
{stp_remote_ip, {172,16,249,20}},
|
{stp_remote_ip, {172,16,249,20}},
|
||||||
{stp_remote_port, 2904},
|
{stp_remote_port, 2904},
|
||||||
|
|
||||||
% MAP rewrite table
|
% Example MAP rewrite table
|
||||||
{map_rewrite_table, [
|
{map_rewrite_table, [
|
||||||
{ msc, 1234500070, 678980004014 },
|
{ msc, 1234500070, 678980004014 },
|
||||||
{ hlr, 1234500073, 678980004012 },
|
{ hlr, 1234500073, 678980004012 },
|
||||||
|
|
|
@ -48,12 +48,13 @@ reload_config() ->
|
||||||
init(_Params) ->
|
init(_Params) ->
|
||||||
sccp_masq:init(),
|
sccp_masq:init(),
|
||||||
map_masq:config_update(),
|
map_masq:config_update(),
|
||||||
{ok, MscLocalIp} = application:get_env(msc_local_ip),
|
MscLocalIp = get_app_config(msc_local_ip),
|
||||||
{ok, MscLocalPort} = application:get_env(msc_local_port),
|
MscLocalPort = get_app_config(msc_local_port),
|
||||||
{ok, MscRemoteIp} = application:get_env(msc_remote_ip),
|
MscRemoteIp = get_app_config(msc_remote_ip),
|
||||||
{ok, StpRemoteIp} = application:get_env(stp_remote_ip),
|
StpRemoteIp = get_app_config(stp_remote_ip),
|
||||||
{ok, StpRemotePort} = application:get_env(stp_remote_port),
|
StpRemotePort = get_app_config(stp_remote_port),
|
||||||
{ok, RewriteActMod} = application:get_env(rewrite_act_mod),
|
RewriteActMod = get_app_config(rewrite_act_mod),
|
||||||
|
RewriteActMod:reload_config(),
|
||||||
io:format("Starting mgw_nat_usr with rewrite actor module ~p~n", [RewriteActMod]),
|
io:format("Starting mgw_nat_usr with rewrite actor module ~p~n", [RewriteActMod]),
|
||||||
SctpHdlrArgs = [MscLocalIp, MscLocalPort, MscRemoteIp,
|
SctpHdlrArgs = [MscLocalIp, MscLocalPort, MscRemoteIp,
|
||||||
StpRemoteIp, StpRemotePort, RewriteActMod],
|
StpRemoteIp, StpRemotePort, RewriteActMod],
|
||||||
|
@ -71,7 +72,7 @@ handle_cast(sccp_masq_dump, LoopData) ->
|
||||||
{noreply, LoopData};
|
{noreply, LoopData};
|
||||||
|
|
||||||
handle_cast(reload_config, LoopData) ->
|
handle_cast(reload_config, LoopData) ->
|
||||||
{ok, RewriteActMod} = application:get_env(rewrite_act_mod),
|
RewriteActMod = get_app_config(rewrite_act_mod),
|
||||||
RewriteActMod:reload_config(),
|
RewriteActMod:reload_config(),
|
||||||
{noreply, LoopData}.
|
{noreply, LoopData}.
|
||||||
|
|
||||||
|
@ -83,3 +84,13 @@ terminate(_Reason, _LoopData) ->
|
||||||
handle_info({sctp, Sock, Ip, Port, Data}, LoopData) ->
|
handle_info({sctp, Sock, Ip, Port, Data}, LoopData) ->
|
||||||
NewL = sctp_handler:handle_sctp(LoopData, {sctp, Sock, Ip, Port, Data}),
|
NewL = sctp_handler:handle_sctp(LoopData, {sctp, Sock, Ip, Port, Data}),
|
||||||
{noreply, NewL}.
|
{noreply, NewL}.
|
||||||
|
|
||||||
|
get_app_config(Name) ->
|
||||||
|
case application:get_env(Name) of
|
||||||
|
undefined ->
|
||||||
|
error_logger:error_report([{error, app_cfg_missing},
|
||||||
|
{get_app_config, Name}]),
|
||||||
|
throw(app_cfg_missing);
|
||||||
|
{ok, Val} ->
|
||||||
|
Val
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue