diff options
author | Erlang/OTP <[email protected]> | 2014-08-07 17:36:24 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2014-08-07 17:36:24 +0200 |
commit | f68b689662dcfba7f6e82bad03938eeb3a48a300 (patch) | |
tree | 7f81f133ec0c8f439083239aec468cc5351f8055 /lib/orber/src/orber_iiop_net.erl | |
parent | 934b6de4d2ab6c31c5217e1ba4779ade9e37cc83 (diff) | |
parent | b1d3fd0943df21a4928ace4101404be97609556d (diff) | |
download | otp-f68b689662dcfba7f6e82bad03938eeb3a48a300.tar.gz otp-f68b689662dcfba7f6e82bad03938eeb3a48a300.tar.bz2 otp-f68b689662dcfba7f6e82bad03938eeb3a48a300.zip |
Merge branch 'lars/orber/dual_ipv6_and_ipv4' into maint-17
* lars/orber/dual_ipv6_and_ipv4:
[orber] Fix bug in testcase
[orber] Fix malformed macros
[orber] Add test suite for ORB with dual ipv4/ipv6 configuration
[orber] Update documentation and fix testcase for IPv4/IPv6
[orber] Update testcases and fixed some minor faults
[orber] Remove unused file corba_request.erl
[orber] Remove a define of ORBVSN when compiling orbers erlang modules
[orber] Add possibilty to configure orber to run in both IPv4 and IPv6
Diffstat (limited to 'lib/orber/src/orber_iiop_net.erl')
-rw-r--r-- | lib/orber/src/orber_iiop_net.erl | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/lib/orber/src/orber_iiop_net.erl b/lib/orber/src/orber_iiop_net.erl index 33e02e3c04..1bfc6b7d58 100644 --- a/lib/orber/src/orber_iiop_net.erl +++ b/lib/orber/src/orber_iiop_net.erl @@ -157,7 +157,7 @@ terminate(_Reason, _State) -> ok. %%----------------------------------------------------------------- -%% Func: parse_options/2 +%% Func: get_options/2 %%----------------------------------------------------------------- get_options(normal, _Options) -> []; @@ -212,14 +212,21 @@ get_options(ssl, Options) -> %%----------------------------------------------------------------- parse_options([{port, Type, Port} | Rest], State) -> Options = get_options(Type, []), - Options2 = case orber_env:ip_address_variable_defined() of - false -> - Options; - Host -> - IPVersion = orber:ip_version(), - {ok, IP} = inet:getaddr(Host, IPVersion), - [{ip, IP} | Options] - end, + Family = orber_env:ip_version(), + IPFamilyOptions = + case Family of + inet -> [inet]; + inet6 -> [inet6, {ipv6_v6only, true}] + end, + Options2 = + case orber_env:ip_address_variable_defined() of + false -> + IPFamilyOptions ++ Options; + Host -> + {ok, IP} = inet:getaddr(Host, Family), + IPFamilyOptions ++ [{ip, IP} |Options] + end, + {ok, Listen, NewPort} = orber_socket:listen(Type, Port, Options2, true), {ok, Pid} = orber_iiop_socketsup:start_accept(Type, Listen, 0), link(Pid), @@ -283,28 +290,33 @@ handle_call({remove, Ref}, _From, State) -> {reply, ok, State} end; handle_call({add, IP, Type, Port, AllOptions}, _From, State) -> - Family = orber_env:ip_version(), + Family = orber_tb:keysearch(ip_family, AllOptions, orber_env:ip_version()), + IPFamilyOptions = + case Family of + inet -> [inet]; + inet6 -> [inet6, {ipv6_v6only, true}] + end, case inet:getaddr(IP, Family) of {ok, IPTuple} -> - try [{ip, IPTuple} |get_options(Type, AllOptions)] of - Options -> - Ref = make_ref(), - ProxyOptions = filter_options(AllOptions, []), - case orber_socket:listen(Type, Port, Options, false) of - {ok, Listen, NewPort} -> - {ok, Pid} = orber_iiop_socketsup:start_accept(Type, Listen, Ref, - ProxyOptions), - link(Pid), - ets:insert(?CONNECTION_DB, #listen{pid = Pid, - socket = Listen, - port = NewPort, - type = Type, ref = Ref, - options = Options, - proxy_options = ProxyOptions}), - {reply, {ok, Ref}, State}; - Error -> - {reply, Error, State} - end + try + Options = IPFamilyOptions ++ [{ip, IPTuple} |get_options(Type, AllOptions)], + Ref = make_ref(), + ProxyOptions = filter_options(AllOptions, []), + case orber_socket:listen(Type, Port, Options, false) of + {ok, Listen, NewPort} -> + {ok, Pid} = orber_iiop_socketsup:start_accept(Type, Listen, Ref, + ProxyOptions), + link(Pid), + ets:insert(?CONNECTION_DB, #listen{pid = Pid, + socket = Listen, + port = NewPort, + type = Type, ref = Ref, + options = Options, + proxy_options = ProxyOptions}), + {reply, {ok, Ref}, State}; + Error -> + {reply, Error, State} + end catch error:Reason -> {reply, {error, Reason}, State} |