1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #include <Ice/ProtocolInstance.h>
6 #include <Ice/Instance.h>
7 #include <Ice/Initialize.h>
8 #include <Ice/IPEndpointI.h>
9 #include <Ice/DefaultsAndOverrides.h>
10 #include <Ice/TraceLevels.h>
11 #include <Ice/EndpointFactoryManager.h>
12 
13 using namespace std;
14 using namespace Ice;
15 using namespace IceInternal;
16 
upCast(ProtocolInstance * p)17 IceUtil::Shared* IceInternal::upCast(ProtocolInstance* p) { return p; }
18 
~ProtocolInstance()19 IceInternal::ProtocolInstance::~ProtocolInstance()
20 {
21     // Out of line to avoid weak vtable
22 }
23 
ProtocolInstance(const CommunicatorPtr & com,Short type,const string & protocol,bool secure)24 IceInternal::ProtocolInstance::ProtocolInstance(const CommunicatorPtr& com, Short type, const string& protocol,
25                                                  bool secure) :
26     _instance(getInstance(com)),
27     _traceLevel(_instance->traceLevels()->network),
28     _traceCategory(_instance->traceLevels()->networkCat),
29     _properties(_instance->initializationData().properties),
30     _protocol(protocol),
31     _type(type),
32     _secure(secure)
33 {
34 }
35 
ProtocolInstance(const InstancePtr & instance,Short type,const string & protocol,bool secure)36 IceInternal::ProtocolInstance::ProtocolInstance(const InstancePtr& instance, Short type, const string& protocol,
37                                                 bool secure) :
38     _instance(instance),
39     _traceLevel(_instance->traceLevels()->network),
40     _traceCategory(_instance->traceLevels()->networkCat),
41     _properties(_instance->initializationData().properties),
42     _protocol(protocol),
43     _type(type),
44     _secure(secure)
45 {
46 }
47 
48 const LoggerPtr&
logger() const49 IceInternal::ProtocolInstance::logger() const
50 {
51     return _instance->initializationData().logger;
52 }
53 
54 EndpointFactoryPtr
getEndpointFactory(Ice::Short type) const55 IceInternal::ProtocolInstance::getEndpointFactory(Ice::Short type) const
56 {
57     return _instance->endpointFactoryManager()->get(type);
58 }
59 
60 BufSizeWarnInfo
getBufSizeWarn(Short type)61 IceInternal::ProtocolInstance::getBufSizeWarn(Short type)
62 {
63     return _instance->getBufSizeWarn(type);
64 }
65 
66 void
setSndBufSizeWarn(Short type,int size)67 IceInternal::ProtocolInstance::setSndBufSizeWarn(Short type, int size)
68 {
69     _instance->setSndBufSizeWarn(type, size);
70 }
71 
72 void
setRcvBufSizeWarn(Short type,int size)73 IceInternal::ProtocolInstance::setRcvBufSizeWarn(Short type, int size)
74 {
75     _instance->setRcvBufSizeWarn(type, size);
76 }
77 
78 bool
preferIPv6() const79 IceInternal::ProtocolInstance::preferIPv6() const
80 {
81     return _instance->preferIPv6();
82 }
83 
84 ProtocolSupport
protocolSupport() const85 IceInternal::ProtocolInstance::protocolSupport() const
86 {
87     return _instance->protocolSupport();
88 }
89 
90 const string&
defaultHost() const91 IceInternal::ProtocolInstance::defaultHost() const
92 {
93     return _instance->defaultsAndOverrides()->defaultHost;
94 }
95 
96 const Address&
defaultSourceAddress() const97 IceInternal::ProtocolInstance::defaultSourceAddress() const
98 {
99     return _instance->defaultsAndOverrides()->defaultSourceAddress;
100 }
101 
102 const EncodingVersion&
defaultEncoding() const103 IceInternal::ProtocolInstance::defaultEncoding() const
104 {
105     return _instance->defaultsAndOverrides()->defaultEncoding;
106 }
107 
108 int
defaultTimeout() const109 IceInternal::ProtocolInstance::defaultTimeout() const
110 {
111     return _instance->defaultsAndOverrides()->defaultTimeout;
112 }
113 
114 NetworkProxyPtr
networkProxy() const115 IceInternal::ProtocolInstance::networkProxy() const
116 {
117     return _instance->networkProxy();
118 }
119 
120 size_t
messageSizeMax() const121 IceInternal::ProtocolInstance::messageSizeMax() const
122 {
123     return _instance->messageSizeMax();
124 }
125 
126 void
resolve(const string & host,int port,EndpointSelectionType type,const IPEndpointIPtr & endpt,const EndpointI_connectorsPtr & cb) const127 IceInternal::ProtocolInstance::resolve(const string& host, int port, EndpointSelectionType type,
128                                        const IPEndpointIPtr& endpt, const EndpointI_connectorsPtr& cb) const
129 {
130     _instance->endpointHostResolver()->resolve(host, port, type, endpt, cb);
131 }
132