From a227e76dff7f1d4b13f422a3abe171a8d0b9b460 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 6 Apr 2011 01:07:00 +0200 Subject: MGW NAT: Store a reference to the actor module, not the rewrite_actor/5 function By keeping a module reference, we can call multiple functions inside the module, and not just one. This will allow us to propagate a 'reload_config' function call into the rewrite actors. --- src/mgw_nat_usr.erl | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/mgw_nat_usr.erl') diff --git a/src/mgw_nat_usr.erl b/src/mgw_nat_usr.erl index 9dd3d65..8f1f68f 100644 --- a/src/mgw_nat_usr.erl +++ b/src/mgw_nat_usr.erl @@ -50,11 +50,10 @@ init(_Params) -> {ok, MscRemoteIp} = application:get_env(msc_remote_ip), {ok, StpRemoteIp} = application:get_env(stp_remote_ip), {ok, StpRemotePort} = application:get_env(stp_remote_port), - {ok, RewriteActor} = application:get_env(rewrite_actor), - HandleFn = get_handle_fn(RewriteActor), - io:format("Starting mgw_nat_usr with rewrite actor ~p~n", [RewriteActor]), + {ok, RewriteActMod} = application:get_env(rewrite_act_mod), + io:format("Starting mgw_nat_usr with rewrite actor module ~p~n", [RewriteActMod]), SctpHdlrArgs = [MscLocalIp, MscLocalPort, MscRemoteIp, - StpRemoteIp, StpRemotePort, HandleFn], + StpRemoteIp, StpRemotePort, RewriteActMod], apply(sctp_handler, init, SctpHdlrArgs). handle_cast(stop, LoopData) -> @@ -66,8 +65,14 @@ handle_cast(sccp_masq_reset, LoopData) -> handle_cast(sccp_masq_dump, LoopData) -> sccp_masq:dump(), + {noreply, LoopData}; + +handle_cast(reload_config, LoopData) -> + {ok, RewriteActMod} = application:get_env(rewrite_act_mod), + RewriteActMod:reload_config(), {noreply, LoopData}. + terminate(_Reason, _LoopData) -> ok. @@ -75,10 +80,3 @@ terminate(_Reason, _LoopData) -> handle_info({sctp, Sock, Ip, Port, Data}, LoopData) -> NewL = sctp_handler:handle_sctp(LoopData, {sctp, Sock, Ip, Port, Data}), {noreply, NewL}. - - -% return rewrite_actor function reference -get_handle_fn(bow_onw) -> - fun mgw_nat_act_bow_onw:rewrite_actor/5; -get_handle_fn(vfuk_onw) -> - fun mgw_nat_act_vfuk_onw:rewrite_actor/5. -- cgit v1.2.3