From 48c07f08b1ee66c1006f980b0ad1ad782b362a40 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 8 Sep 2013 22:22:01 +0200 Subject: make use of local IP address of #sigtran_peer actually work --- src/sctp_core.erl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/sctp_core.erl') diff --git a/src/sctp_core.erl b/src/sctp_core.erl index ca3217d..1e9fc21 100644 --- a/src/sctp_core.erl +++ b/src/sctp_core.erl @@ -86,19 +86,21 @@ reconnect_sctp(L = #sctp_state{sctp_remote_ip = Ip, sctp_remote_port = Port, sct build_openopt({sctp_local_port, Port}) -> {port, Port}; +build_openopt({sctp_local_ip, undefined}) -> + []; build_openopt({sctp_local_ip, Ip}) -> {ip, Ip}; build_openopt(_) -> []. +build_openopts(PropList) -> + [{active, once}, {reuseaddr, true}] ++ + lists:flatten(lists:map(fun build_openopt/1, PropList)). init(InitOpts) -> - OpenOptsBase = [{active, once}, {reuseaddr, true}], Module = proplists:get_value(module, InitOpts), ModuleArgs = proplists:get_value(module_args, InitOpts), Role = proplists:get_value(sctp_role, InitOpts), - OpenOpts = OpenOptsBase ++ lists:map(fun build_openopt/1, InitOpts), - io:format("sctp_open(~p)~n", [OpenOpts]), - {ok, SctpSock} = gen_sctp:open(OpenOpts), + {ok, SctpSock} = gen_sctp:open(build_openopts(InitOpts)), case Module:init(ModuleArgs) of {ok, ExtState} -> LoopDat = #sctp_state{role = Role, sctp_sock = SctpSock, -- cgit v1.2.3