aboutsummaryrefslogtreecommitdiffstats
path: root/src/mgw_nat_usr.erl
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-03-08 15:17:32 +0100
committerHarald Welte <laforge@gnumonks.org>2011-03-08 15:17:32 +0100
commit5df8338d70e7e3da7f5d7967b29372d39747255c (patch)
tree9cb47d353814c92a39ef59ce66f7a9eebd20a37f /src/mgw_nat_usr.erl
parent39b19ef69d940865d79f560eddfb79782f69f3c6 (diff)
Make MGW nat more flexible by introdicng actors an function references
Instead of a static configuration of rewrite/mangling/patching steps, we now introduce the concept of a 'rewrite_actor', which is a callback function that determines which rewrite/patching code to call at which particular layer of the protocol. The default rewrite actor "bow_onw" resembles the existing rewrite behavior. There is a stub new rewrite actore "vfuk_onw", which will be used for Camel phase rewriting.
Diffstat (limited to 'src/mgw_nat_usr.erl')
-rw-r--r--src/mgw_nat_usr.erl21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mgw_nat_usr.erl b/src/mgw_nat_usr.erl
index fb1392a..9dd3d65 100644
--- a/src/mgw_nat_usr.erl
+++ b/src/mgw_nat_usr.erl
@@ -42,10 +42,20 @@ sccp_masq_dump() ->
%% Callback functions of the OTP behavior
-init(Params) ->
+init(_Params) ->
sccp_masq:init(),
map_masq:config_update(),
- apply(sctp_handler, init, Params).
+ {ok, MscLocalIp} = application:get_env(msc_local_ip),
+ {ok, MscLocalPort} = application:get_env(msc_local_port),
+ {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]),
+ SctpHdlrArgs = [MscLocalIp, MscLocalPort, MscRemoteIp,
+ StpRemoteIp, StpRemotePort, HandleFn],
+ apply(sctp_handler, init, SctpHdlrArgs).
handle_cast(stop, LoopData) ->
{stop, normal, LoopData};
@@ -65,3 +75,10 @@ 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.