diff options
author | Benoit Foucher <benoit@zeroc.com> | 2007-12-19 22:06:38 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2007-12-19 22:06:38 +0100 |
commit | f6121ea342641eb36f7cd67c7c877a1c70ec3055 (patch) | |
tree | b545f3a2548b81fd8dd56a87a58f98b992c0066b /cpp/src/Ice/UdpEndpointI.cpp | |
parent | Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice (diff) | |
download | ice-f6121ea342641eb36f7cd67c7c877a1c70ec3055.tar.bz2 ice-f6121ea342641eb36f7cd67c7c877a1c70ec3055.tar.xz ice-f6121ea342641eb36f7cd67c7c877a1c70ec3055.zip |
- Merge IPv6 support from Dwayne's branch.
- Reviewed and fixed IPv6 bugs.
- Fixed bug in the outgoing connection factory where an assert could be
triggered if the proxy contained identical endpoints
Diffstat (limited to 'cpp/src/Ice/UdpEndpointI.cpp')
-rw-r--r-- | cpp/src/Ice/UdpEndpointI.cpp | 74 |
1 files changed, 44 insertions, 30 deletions
diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index b5f4588714c..217f9625528 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -39,7 +39,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin { } -IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const string& str, bool server) : +IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const string& str, bool oaEndpoint) : _instance(instance), _port(0), _mcastTtl(-1), @@ -88,6 +88,10 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin end = str.length(); } argument = str.substr(beg, end - beg); + if(argument[0] == '\"' && argument[argument.size() - 1] == '\"') + { + argument = argument.substr(1, argument.size() - 2); + } } if(option == "-v") @@ -267,21 +271,19 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin if(_host.empty()) { const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost; - if(_host.empty()) - { - if(server) - { - const_cast<string&>(_host) = "0.0.0.0"; - } - else - { - const_cast<string&>(_host) = "127.0.0.1"; - } - } } else if(_host == "*") { - const_cast<string&>(_host) = "0.0.0.0"; + if(oaEndpoint) + { + const_cast<string&>(_host) = string(); + } + else + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } } } @@ -372,7 +374,22 @@ IceInternal::UdpEndpointI::toString() const << static_cast<unsigned>(static_cast<unsigned char>(_encodingMinor)); } - s << " -h " << _host << " -p " << _port; + if(!_host.empty()) + { + s << " -h "; + bool addQuote = _host.find(':') != string::npos; + if(addQuote) + { + s << "\""; + } + s << _host; + if(addQuote) + { + s << "\""; + } + } + + s << " -p " << _port; if(_mcastInterface.length() > 0) { @@ -480,7 +497,7 @@ IceInternal::UdpEndpointI::transceiver(EndpointIPtr& endp) const vector<ConnectorPtr> IceInternal::UdpEndpointI::connectors() const { - return connectors(getAddresses(_host, _port)); + return connectors(getAddresses(_host, _port, _instance->protocolSupport(), true)); } void @@ -500,22 +517,19 @@ vector<EndpointIPtr> IceInternal::UdpEndpointI::expand() const { vector<EndpointIPtr> endps; - if(_host == "0.0.0.0") + vector<string> hosts = getHostsForEndpointExpand(_host, _instance->protocolSupport()); + if(hosts.empty()) { - vector<string> hosts = getLocalHosts(); - for(unsigned int i = 0; i < hosts.size(); ++i) - { - if(hosts.size() == 1 || hosts[i] != "127.0.0.1") - { - endps.push_back(new UdpEndpointI(_instance, hosts[i], _port, _mcastInterface, _mcastTtl, _protocolMajor, - _protocolMinor, _encodingMajor, _encodingMinor, _connect, - _connectionId, _compress)); - } - } + endps.push_back(const_cast<UdpEndpointI*>(this)); } else { - endps.push_back(const_cast<UdpEndpointI*>(this)); + for(vector<string>::const_iterator p = hosts.begin(); p != hosts.end(); ++p) + { + endps.push_back(new UdpEndpointI(_instance, *p, _port, _mcastInterface, _mcastTtl, _protocolMajor, + _protocolMinor, _encodingMajor, _encodingMinor, _connect, + _connectionId, _compress)); + } } return endps; } @@ -726,7 +740,7 @@ IceInternal::UdpEndpointI::operator<(const EndpointI& r) const } vector<ConnectorPtr> -IceInternal::UdpEndpointI::connectors(const vector<struct sockaddr_in>& addresses) const +IceInternal::UdpEndpointI::connectors(const vector<struct sockaddr_storage>& addresses) const { vector<ConnectorPtr> connectors; for(unsigned int i = 0; i < addresses.size(); ++i) @@ -759,9 +773,9 @@ IceInternal::UdpEndpointFactory::protocol() const } EndpointIPtr -IceInternal::UdpEndpointFactory::create(const std::string& str, bool server) const +IceInternal::UdpEndpointFactory::create(const std::string& str, bool oaEndpoint) const { - return new UdpEndpointI(_instance, str, server); + return new UdpEndpointI(_instance, str, oaEndpoint); } EndpointIPtr |