aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test/diameter_util.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/diameter/test/diameter_util.erl')
-rw-r--r--lib/diameter/test/diameter_util.erl57
1 files changed, 22 insertions, 35 deletions
diff --git a/lib/diameter/test/diameter_util.erl b/lib/diameter/test/diameter_util.erl
index 7266d3678c..03f79096ac 100644
--- a/lib/diameter/test/diameter_util.erl
+++ b/lib/diameter/test/diameter_util.erl
@@ -32,8 +32,7 @@
foldl/3,
scramble/1,
unique_string/0,
- have_sctp/0,
- ip4/0]).
+ have_sctp/0]).
%% diameter-specific
-export([lport/2,
@@ -185,13 +184,19 @@ unique_string() ->
%% have_sctp/0
have_sctp() ->
+ have_sctp(erlang:system_info(system_architecture)).
+
+%% Don't run SCTP on platforms where it's either known to be flakey or
+%% isn't available.
+
+have_sctp("sparc-sun-solaris2.10") ->
+ false;
+
+have_sctp(_) ->
case gen_sctp:open() of
{ok, Sock} ->
- RC = gen_sctp:connect(Sock, ip4(), 3868, []),
gen_sctp:close(Sock),
- %% Connect has been seen to return eafnosupport on at least
- %% one SunOS 10 Sparc host, for reasons unknown.
- RC /= {error, eafnosupport};
+ true;
{error, E} when E == eprotonosupport;
E == esocktnosupport -> %% fail on any other reason
false
@@ -360,8 +365,7 @@ tmod(any) ->
opts([Prot | Opts], T) ->
tmo(T, lists:append([[{transport_module, M}, {transport_config, C ++ Opts}]
|| M <- tmod(Prot),
- C <- [buf(M,T) ++ [{ip, addr(M)}, {port, 0}]
- ++ remote(M,T)]]));
+ C <- [cfg(M,T) ++ cfg(M) ++ cfg(T)]]));
opts(Prot, T) ->
opts([Prot], T).
@@ -380,38 +384,21 @@ tmo([M, C | Opts]) ->
%% Listening SCTP socket need larger-than-default buffers to avoid
%% resends on some platforms (eg. SLES 11).
-buf(diameter_sctp, listen) ->
+cfg(diameter_sctp, listen) ->
[{recbuf, 1 bsl 16}, {sndbuf, 1 bsl 16}];
-buf(_, _) ->
+
+cfg(_, _) ->
[].
-addr(diameter_tcp) ->
- {127,0,0,1};
-addr(diameter_sctp) ->
- ip4().
+cfg(M)
+ when M == diameter_tcp;
+ M == diameter_sctp ->
+ [{ip, ?ADDR}, {port, 0}];
-remote(_, listen) ->
+cfg(listen) ->
[{accept, M} || M <- [{256,0,0,1}, ["256.0.0.1", ["^.+$"]]]];
-remote(Mod, PortNr) ->
- [{raddr, addr(Mod)}, {rport, PortNr}].
-
-%% Try to use something other than the loopback address where this
-%% address is known to be problematic for gen_sctp.
-ip4() ->
- try
- "sparc-sun-solaris2.10" = erlang:system_info(system_architecture),
- {ok, List} = inet:getifaddrs(),
- hd(lists:flatmap(fun ip4/1, List))
- catch
- error:_ ->
- ?ADDR
- end.
-
-ip4({_, Opts}) ->
- {flags, Flags} = lists:keyfind(flags, 1, Opts),
- [A || lists:member(up, Flags),
- not lists:member(loopback, Flags),
- {addr, {_,_,_,_} = A} <- Opts].
+cfg(PortNr) ->
+ [{raddr, ?ADDR}, {rport, PortNr}].
%% ---------------------------------------------------------------------------
%% info/0