diff options
Diffstat (limited to 'lib/diameter/test/diameter_transport_SUITE.erl')
-rw-r--r-- | lib/diameter/test/diameter_transport_SUITE.erl | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/lib/diameter/test/diameter_transport_SUITE.erl b/lib/diameter/test/diameter_transport_SUITE.erl index c94f46b7a5..ac65cbe618 100644 --- a/lib/diameter/test/diameter_transport_SUITE.erl +++ b/lib/diameter/test/diameter_transport_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2016. All Rights Reserved. +%% Copyright Ericsson AB 2010-2017. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -56,8 +56,10 @@ -define(RECV(Pat, Ret), receive Pat -> Ret end). -define(RECV(Pat), ?RECV(Pat, diameter_lib:now())). -%% Sockets are opened on the loopback address. --define(ADDR, {127,0,0,1}). +%% Address to open sockets on. +-define(ADDR(Prot), if sctp == Prot -> diameter_util:ip4(); + true -> {127,0,0,1} + end). %% diameter_tcp doesn't use anything but host_ip_address, and that %% only is a local address isn't configured as at transport start. @@ -351,13 +353,14 @@ rand_bytes(N, Bin) -> %% start_connect/3 start_connect(Prot, PortNr, Ref) -> - {ok, TPid, [?ADDR]} = start_connect(Prot, - {connect, Ref}, - ?SVC([]), - [{raddr, ?ADDR}, - {rport, PortNr}, - {ip, ?ADDR}, - {port, 0}]), + Addr = ?ADDR(Prot), + {ok, TPid, [_]} = start_connect(Prot, + {connect, Ref}, + ?SVC([]), + [{raddr, Addr}, + {rport, PortNr}, + {ip, Addr}, + {port, 0}]), ?RECV(?TMSG({TPid, connected, _})), TPid. @@ -370,9 +373,9 @@ start_connect(tcp, T, Svc, Opts) -> start_accept(Prot, Ref) -> {Mod, Opts} = tmod(Prot), - {ok, TPid, [?ADDR]} = Mod:start({accept, Ref}, - ?SVC([?ADDR]), - [{port, 0} | Opts]), + {ok, TPid, [_]} = Mod:start({accept, Ref}, + ?SVC([?ADDR(Prot)]), + [{port, 0} | Opts]), ?RECV(?TMSG({TPid, connected})), TPid. @@ -386,19 +389,20 @@ tmod(tcp) -> %% gen_connect/2 gen_connect(sctp = P, PortNr) -> - {ok, Sock} = Ok = gen_sctp:open([{ip, ?ADDR}, {port, 0} | ?SCTP_OPTS]), - ok = gen_sctp:connect_init(Sock, ?ADDR, PortNr, []), + Addr = ?ADDR(P), + {ok, Sock} = Ok = gen_sctp:open([{ip, Addr}, {port, 0} | ?SCTP_OPTS]), + ok = gen_sctp:connect_init(Sock, Addr, PortNr, []), Ok = gen_accept(P, Sock); -gen_connect(tcp, PortNr) -> - gen_tcp:connect(?ADDR, PortNr, ?TCP_OPTS). +gen_connect(tcp = P, PortNr) -> + gen_tcp:connect(?ADDR(P), PortNr, ?TCP_OPTS). %% gen_listen/1 -gen_listen(sctp) -> - {ok, Sock} = gen_sctp:open([{ip, ?ADDR}, {port, 0} | ?SCTP_OPTS]), +gen_listen(sctp = P) -> + {ok, Sock} = gen_sctp:open([{ip, ?ADDR(P)}, {port, 0} | ?SCTP_OPTS]), {gen_sctp:listen(Sock, true), Sock}; -gen_listen(tcp) -> - gen_tcp:listen(0, [{ip, ?ADDR} | ?TCP_OPTS]). +gen_listen(tcp = P) -> + gen_tcp:listen(0, [{ip, ?ADDR(P)} | ?TCP_OPTS]). %% gen_accept/2 |