pespin submitted this change.
aaa_diameter_swx: Make tx timeout configurable and increase default to 10 seconds
Change-Id: I52c993b92da9979761b0c1526b5f253dff9d2e2f
---
M config/sys.config
M src/aaa_diameter_swx.erl
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/config/sys.config b/config/sys.config
index 8ed5ca6..a40fd23 100755
--- a/config/sys.config
+++ b/config/sys.config
@@ -14,6 +14,7 @@
{dia_swx_watchdog_config,
[{okay, 3},
{suspect, 1}]},
+ {dia_swx_transmit_timer, 10000},
{dia_swx_vendor_id, 0},
{dia_swx_origin_host, "epdg.localdomain"},
{dia_swx_origin_realm, "localdomain"},
diff --git a/src/aaa_diameter_swx.erl b/src/aaa_diameter_swx.erl
index c623b3e..be301f2 100644
--- a/src/aaa_diameter_swx.erl
+++ b/src/aaa_diameter_swx.erl
@@ -71,6 +71,7 @@
-define(ENV_DEFAULT_DIAMETER_CONNECT_TIMER_MS, 30000).
-define(ENV_DEFAULT_DIAMETER_WATCHDOG_TIMER_MS, 30000).
-define(ENV_DEFAULT_DIAMETER_WATCHDOG_CFG, [{okay, 3}, {suspect, 1}]).
+-define(ENV_DEFAULT_DIAMETER_TRANSMIT_TIMER_MS, 10000).
-define(VENDOR_ID_3GPP, 10415).
-define(VENDOR_ID_3GPP2, 5535).
@@ -96,7 +97,8 @@
{module, ?CALLBACK_MOD},
{answer_errors, callback}]}]).
--record(state, {
+-record(swx_state, {
+ tx_timeout :: non_neg_integer(),
handlers,
peers = #{}
}).
@@ -121,17 +123,18 @@
gen_server:cast(?SERVER, {peer_down, SvcName, Peer}),
ok.
-init(State) ->
+init([]) ->
Proto = application:get_env(?ENV_APP_NAME, dia_swx_proto, ?ENV_DEFAULT_DIAMETER_PROTO),
Ip = application:get_env(?ENV_APP_NAME, dia_swx_remote_ip, ?ENV_DEFAULT_DIAMETER_REMOTE_IP),
Port = application:get_env(?ENV_APP_NAME, dia_swx_remote_port, ?ENV_DEFAULT_DIAMETER_REMOTE_PORT),
ConnectTimer = application:get_env(?ENV_APP_NAME, dia_swx_connect_timer, ?ENV_DEFAULT_DIAMETER_CONNECT_TIMER_MS),
WatchdogTimer = application:get_env(?ENV_APP_NAME, dia_swx_watchdog_timer, ?ENV_DEFAULT_DIAMETER_WATCHDOG_TIMER_MS),
WatchdogConfig = application:get_env(?ENV_APP_NAME, dia_swx_watchdog_config, ?ENV_DEFAULT_DIAMETER_WATCHDOG_CFG),
+ TxTimer = application:get_env(?ENV_APP_NAME, dia_swx_transmit_timer, ?ENV_DEFAULT_DIAMETER_TRANSMIT_TIMER_MS),
ok = diameter:start_service(?MODULE, ?SERVICE),
% lager:info("DiaServices is ~p~n", [DiaServ]),
{ok, _} = connect({address, Proto, Ip, Port}, {timer, ConnectTimer, WatchdogTimer, WatchdogConfig}),
- {ok, State}.
+ {ok, #swx_state{tx_timeout = TxTimer}}.
test() ->
test("001011234567890").
@@ -223,7 +226,7 @@
'RAT-Type' = RAT
},
lager:debug("Swx Tx MAR: ~p~n", [MAR]),
- Ret = diameter:call(?SVC_NAME, ?APP_ALIAS, MAR, [{extra, [Pid]}, detach]),
+ Ret = diameter_call(MAR, Pid, State),
case Ret of
ok ->
{reply, ok, State};
@@ -244,7 +247,7 @@
'Server-Assignment-Type' = Type,
'Service-Selection' = [APN]
},
- Ret = diameter:call(?SVC_NAME, ?APP_ALIAS, SAR, [{extra, [Pid]}, detach]),
+ Ret = diameter_call(SAR, Pid, State),
case Ret of
ok ->
{reply, ok, State};
@@ -306,4 +309,9 @@
tmod(sctp) ->
diameter_sctp.
+diameter_call(Msg, Pid, State) ->
+ diameter:call(?SVC_NAME, ?APP_ALIAS, Msg, [{extra, [Pid]},
+ {timeout, State#swx_state.tx_timeout},
+ detach]).
+
To view, visit change 36118. To unsubscribe, or for help writing mail filters, visit settings.