aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2014-01-31 16:24:33 +0100
committerAnders Svensson <[email protected]>2014-02-19 13:37:49 +0100
commit30d8dc3560974d94a9d8df7d6e4f267dccef804b (patch)
tree7b8aedc33aba3276527f31d57c03aa7387f1a423 /lib/diameter/src
parentfdcdaca338849d7f63d4300e489318f6ee275d82 (diff)
downloadotp-30d8dc3560974d94a9d8df7d6e4f267dccef804b.tar.gz
otp-30d8dc3560974d94a9d8df7d6e4f267dccef804b.tar.bz2
otp-30d8dc3560974d94a9d8df7d6e4f267dccef804b.zip
Use inet:{peer,sock}names/1 in diameter_sctp
OTP-10229 (commit c4592b69) added these function to give access to all addresses on a multihomed endpoint, their singular siblings not returning anything useful in this case. This fixes {accept, Match} config, which matches peer addresses against configured addresses or regexps to decide whether or not a newly established association should be retained. The functionality was added in OTP-10893 (commit 9bbf27eb) but predated OTP-10229 by a few months. It also fixes the addresses shown for SCTP associations in diameter:service_info/2 output.
Diffstat (limited to 'lib/diameter/src')
-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.