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.
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 @@
{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_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 @@
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.