aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/gen_sctp.erl
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2011-09-02 10:29:58 +0200
committerRaimo Niskanen <[email protected]>2011-11-17 12:11:02 +0100
commit1cc7485467b1b4e9efd15259b58e1182d2e9723c (patch)
tree50335d97ee93ca653e6dcdb1f6712d4cd05d79f4 /lib/kernel/src/gen_sctp.erl
parent3b81d47f7f4415661d4371989637374567e2ab2a (diff)
downloadotp-1cc7485467b1b4e9efd15259b58e1182d2e9723c.tar.gz
otp-1cc7485467b1b4e9efd15259b58e1182d2e9723c.tar.bz2
otp-1cc7485467b1b4e9efd15259b58e1182d2e9723c.zip
erts,kernel: Implement gen_sctp:peeloff/2
Diffstat (limited to 'lib/kernel/src/gen_sctp.erl')
-rw-r--r--lib/kernel/src/gen_sctp.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl
index 3351796481..77ca26b845 100644
--- a/lib/kernel/src/gen_sctp.erl
+++ b/lib/kernel/src/gen_sctp.erl
@@ -27,7 +27,8 @@
-include("inet_sctp.hrl").
-export([open/0,open/1,open/2,close/1]).
--export([listen/2,connect/4,connect/5,connect_init/4,connect_init/5]).
+-export([listen/2,peeloff/2]).
+-export([connect/4,connect/5,connect_init/4,connect_init/5]).
-export([eof/2,abort/2]).
-export([send/3,send/4,recv/1,recv/2]).
-export([error_string/1]).
@@ -182,6 +183,21 @@ listen(S, Backlog)
listen(S, Flag) ->
erlang:error(badarg, [S,Flag]).
+-spec peeloff(Socket, Assoc) -> {ok, NewSocket} | {error, Reason} when
+ Socket :: sctp_socket(),
+ Assoc :: #sctp_assoc_change{} | assoc_id(),
+ NewSocket :: sctp_socket(),
+ Reason :: term().
+
+peeloff(S, #sctp_assoc_change{assoc_id=AssocId}) when is_port(S) ->
+ peeloff(S, AssocId);
+peeloff(S, AssocId) when is_port(S), is_integer(AssocId) ->
+ case inet_db:lookup_socket(S) of
+ {ok,Mod} ->
+ Mod:peeloff(S, AssocId);
+ Error -> Error
+ end.
+
-spec connect(Socket, Addr, Port, Opts) -> {ok, Assoc} | {error, inet:posix()} when
Socket :: sctp_socket(),
Addr :: inet:ip_address() | inet:hostname(),