diff options
author | Björn Gustavsson <[email protected]> | 2010-09-07 10:54:31 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-09-07 10:54:35 +0200 |
commit | 1d3297b5fa8b444beaef3a0decafe3e4d6dcc664 (patch) | |
tree | 0df66ca7f0300c2abd41509609e3a597c7162268 /lib/kernel/src/gen_sctp.erl | |
parent | 0c6a6de22e6cc1b90445815623ec54d86f505f4c (diff) | |
parent | 296b3ae4d88c87cdf9638a1dd9cab622c748c5e6 (diff) | |
download | otp-1d3297b5fa8b444beaef3a0decafe3e4d6dcc664.tar.gz otp-1d3297b5fa8b444beaef3a0decafe3e4d6dcc664.tar.bz2 otp-1d3297b5fa8b444beaef3a0decafe3e4d6dcc664.zip |
Merge branch 'ph/auto_recognize_ipv6' into dev
* ph/auto_recognize_ipv6:
Add tests
Let an 8-tuple given as ip_address() for gen_tcp/gen_udp/gen_sctp imply 'inet6'
OTP-8822
Diffstat (limited to 'lib/kernel/src/gen_sctp.erl')
-rw-r--r-- | lib/kernel/src/gen_sctp.erl | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl index a1542ab507..cccfa75005 100644 --- a/lib/kernel/src/gen_sctp.erl +++ b/lib/kernel/src/gen_sctp.erl @@ -39,7 +39,7 @@ open() -> open([]). open(Opts) when is_list(Opts) -> - Mod = mod(Opts), + Mod = mod(Opts, undefined), case Mod:open(Opts) of {error,badarg} -> erlang:error(badarg, [Opts]); @@ -234,17 +234,27 @@ controlling_process(S, Pid) -> %% Utilites %% -%% Get the SCTP moudule -mod() -> inet_db:sctp_module(). +%% Get the SCTP module, but IPv6 address overrides default IPv4 +mod(Address) -> + case inet_db:sctp_module() of + inet_sctp when tuple_size(Address) =:= 8 -> + inet6_sctp; + Mod -> + Mod + end. %% Get the SCTP module, but option sctp_module|inet|inet6 overrides -mod([{sctp_module,Mod}|_]) -> +mod([{sctp_module,Mod}|_], _Address) -> Mod; -mod([inet|_]) -> +mod([inet|_], _Address) -> inet_sctp; -mod([inet6|_]) -> +mod([inet6|_], _Address) -> inet6_sctp; -mod([_|Opts]) -> - mod(Opts); -mod([]) -> - mod(). +mod([{ip, Address}|Opts], _) -> + mod(Opts, Address); +mod([{ifaddr, Address}|Opts], _) -> + mod(Opts, Address); +mod([_|Opts], Address) -> + mod(Opts, Address); +mod([], Address) -> + mod(Address). |