aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2014-02-19 13:38:10 +0100
committerAnders Svensson <[email protected]>2014-02-19 13:38:10 +0100
commit9fbb7a9a72a9b9f2bc12aebdbc89cac4bcd21873 (patch)
tree9ffeb92db6323746138ece1236d7152338eb910b
parentcbe9bc1f35d43dea31db8ea699f75d34a87649c8 (diff)
parent30d8dc3560974d94a9d8df7d6e4f267dccef804b (diff)
downloadotp-9fbb7a9a72a9b9f2bc12aebdbc89cac4bcd21873.tar.gz
otp-9fbb7a9a72a9b9f2bc12aebdbc89cac4bcd21873.tar.bz2
otp-9fbb7a9a72a9b9f2bc12aebdbc89cac4bcd21873.zip
Merge branch 'anders/diameter/sctp/OTP-11661'
* anders/diameter/sctp/OTP-11661: Use inet:{peer,sock}names/1 in diameter_sctp
-rw-r--r--lib/diameter/src/transport/diameter_sctp.erl23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/diameter/src/transport/diameter_sctp.erl b/lib/diameter/src/transport/diameter_sctp.erl
index f5275e66b5..d0a01351f3 100644
--- a/lib/diameter/src/transport/diameter_sctp.erl
+++ b/lib/diameter/src/transport/diameter_sctp.erl
@@ -171,18 +171,33 @@ start_link(T) ->
info({gen_sctp, Sock}) ->
lists:flatmap(fun(K) -> info(K, Sock) end,
- [{socket, sockname},
- {peer, peername},
+ [{socket, socknames},
+ {peer, peernames},
{statistics, getstat}]).
info({K,F}, Sock) ->
case inet:F(Sock) of
{ok, V} ->
- [{K,V}];
+ [{K, map(F,V)}];
_ ->
[]
end.
+%% inet:{sock,peer}names/1 returns [{Addr, Port}] but the port number
+%% should be the same in each tuple. Map to a {[Addr], Port} tuple if
+%% so.
+map(K, [{_, Port} | _] = APs)
+ when K == socknames;
+ K == peernames ->
+ try [A || {A,P} <- APs, P == Port orelse throw(?MODULE)] of
+ As -> {As, Port}
+ catch
+ ?MODULE -> APs
+ end;
+
+map(_, V) ->
+ V.
+
%% ---------------------------------------------------------------------------
%% # init/1
%% ---------------------------------------------------------------------------
@@ -549,7 +564,7 @@ accept_peer(_, []) ->
ok;
accept_peer(Sock, Matches) ->
- {RAddrs, _} = ok(inet:peername(Sock)),
+ RAddrs = [A || {A,_} <- ok(inet:peernames(Sock))],
diameter_peer:match(RAddrs, Matches)
orelse x({accept, RAddrs, Matches}),
ok.