aboutsummaryrefslogtreecommitdiffstats
path: root/src/mgw_nat_usr.erl
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-04-06 01:07:00 +0200
committerHarald Welte <laforge@gnumonks.org>2011-04-06 01:07:00 +0200
commita227e76dff7f1d4b13f422a3abe171a8d0b9b460 (patch)
tree1c7f6bef98584e9afb4e40252c0b3df373ab1d31 /src/mgw_nat_usr.erl
parenteea20e1e821e0300809c4a5ed652e9c3cd0d455b (diff)
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.
Diffstat (limited to 'src/mgw_nat_usr.erl')
-rw-r--r--src/mgw_nat_usr.erl20
1 files changed, 9 insertions, 11 deletions
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.