pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35588?usp=email )


Change subject: diameter: Allow configuring (re)connect timer in s6b and swx
......................................................................

diameter: Allow configuring (re)connect timer in s6b and swx

TTCN3 tests will require lower values to avoid timing out.

Change-Id: I7d280f83f4f375eaf34ea3b69a421372af54ffdb
---
M config/sys.config
M src/aaa_diameter_s6b.erl
M src/epdg_diameter_swx.erl
3 files changed, 33 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-epdg 
refs/changes/88/35588/1

diff --git a/config/sys.config b/config/sys.config
index 630a057..699df4f 100755
--- a/config/sys.config
+++ b/config/sys.config
@@ -9,6 +9,8 @@
    {diameter_remote_ip, "127.0.0.1"},
    {diameter_remote_port, 3868},
    {diameter_proto, sctp},
+   {diameter_connect_timer, 30000},
+   {diameter_watchdog_timer, 30000},
    {vendor_id, 0},
    {origin_host, "epdg.localdomain"},
    {origin_realm, "localdomain"},
@@ -17,6 +19,7 @@
    {dia_s6b_local_ip, "127.0.0.10"},
    {dia_s6b_local_port, 3868},
    {dia_s6b_proto, sctp},
+   {dia_s6b_connect_timer, 30000},
    {dia_s6b_vendor_id, 0},
    {dia_s6b_origin_host, "aaa.localdomain"},
    {dia_s6b_origin_realm, "localdomain"},
diff --git a/src/aaa_diameter_s6b.erl b/src/aaa_diameter_s6b.erl
index 4ee0219..fd83bde 100644
--- a/src/aaa_diameter_s6b.erl
+++ b/src/aaa_diameter_s6b.erl
@@ -121,9 +121,10 @@
     Proto = application:get_env(?ENV_APP_NAME, dia_s6b_proto, 
?ENV_DEFAULT_DIAMETER_PROTO),
     Ip = application:get_env(?ENV_APP_NAME, dia_s6b_local_ip, 
?ENV_DEFAULT_DIAMETER_REMOTE_IP),
     Port = application:get_env(?ENV_APP_NAME, dia_s6b_local_port, 
?ENV_DEFAULT_DIAMETER_REMOTE_PORT),
+    ConnectTimer = application:get_env(osmo_dia2gsup, dia_s6b_connect_timer, 
30000),
     ok = diameter:start_service(?MODULE, ?SERVICE),
     % lager:info("DiaServices is ~p~n", [DiaServ]),
-    {ok, _} = listen({address, Proto, Ip, Port}),
+    {ok, _} = listen({address, Proto, Ip, Port}, {timer, ConnectTimer}),
     {ok, State}.

 test() ->
@@ -176,8 +177,7 @@
 %% Internal Function Definitions
 %% ------------------------------------------------------------------

-%% connect/2
-listen(Name, {address, Protocol, IPAddr, Port}) ->
+listen(Name, {address, Protocol, IPAddr, Port}, {timer, ConnectTimer}) ->
     lager:notice("~s Listening on IP ~s port ~p~n", [Name, IPAddr, Port]),
     {ok, IP} = inet_parse:address(IPAddr),
     TransportOpts =
@@ -188,11 +188,12 @@
            {port, Port}
            %%{raddr, IP},
            %%{rport, Port}
-          ]}],
-    diameter:add_transport(Name, {listen, [{reconnect_timer, 1000} | 
TransportOpts]}).
+          ]},
+         {connect_timer, ConnectTimer}],
+    diameter:add_transport(Name, {listen, TransportOpts}).

-listen(Address) ->
-    listen(?SVC_NAME, Address).
+listen(Address, {timer, ConnectTimer}) ->
+    listen(?SVC_NAME, Address, {timer, ConnectTimer}).

 %% Convert connection type
 tmod(tcp) ->
diff --git a/src/epdg_diameter_swx.erl b/src/epdg_diameter_swx.erl
index c278206..d7bea93 100644
--- a/src/epdg_diameter_swx.erl
+++ b/src/epdg_diameter_swx.erl
@@ -121,9 +121,11 @@
     Proto = application:get_env(?ENV_APP_NAME, diameter_proto, 
?ENV_DEFAULT_DIAMETER_PROTO),
     Ip = application:get_env(?ENV_APP_NAME, diameter_remote_ip, 
?ENV_DEFAULT_DIAMETER_REMOTE_IP),
     Port = application:get_env(?ENV_APP_NAME, diameter_remote_port, 
?ENV_DEFAULT_DIAMETER_REMOTE_PORT),
+    ConnectTimer = application:get_env(?ENV_APP_NAME, diameter_connect_timer, 
30000),
+    WatchdogTimer = application:get_env(?ENV_APP_NAME, 
diameter_watchdog_timer, 30000),
     ok = diameter:start_service(?MODULE, ?SERVICE),
     % lager:info("DiaServices is ~p~n", [DiaServ]),
-    {ok, _} = connect({address, Proto, Ip, Port}),
+    {ok, _} = connect({address, Proto, Ip, Port}, {timer, ConnectTimer, 
WatchdogTimer}),
     {ok, State}.

 test() ->
@@ -256,8 +258,8 @@
 %% Internal Function Definitions
 %% ------------------------------------------------------------------

-%% connect/2
-connect(Name, {address, Protocol, IPAddr, Port}) ->
+%% connect/3
+connect(Name, {address, Protocol, IPAddr, Port}, {timer, ConnectTimer, 
WatchdogTimer}) ->
     lager:notice("~s connecting to IP ~s port ~p~n", [Name, IPAddr, Port]),
     {ok, IP} = inet_parse:address(IPAddr),
     TransportOpts =
@@ -265,11 +267,13 @@
          {transport_config,
           [{reuseaddr, true},
            {raddr, IP},
-           {rport, Port}]}],
-    diameter:add_transport(Name, {connect, [{reconnect_timer, 1000} | 
TransportOpts]}).
+           {rport, Port}]},
+         {connect_timer, ConnectTimer},
+         {watchdog_timer, WatchdogTimer}],
+    diameter:add_transport(Name, {connect, TransportOpts}).

-connect(Address) ->
-    connect(?SVC_NAME, Address).
+connect(Address, Timers) ->
+    connect(?SVC_NAME, Address, Timers).

 %% Convert connection type
 tmod(tcp) ->

--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35588?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: erlang/osmo-epdg
Gerrit-Branch: master
Gerrit-Change-Id: I7d280f83f4f375eaf34ea3b69a421372af54ffdb
Gerrit-Change-Number: 35588
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to