/usr/include/Ice/Protocol.h is in libzeroc-ice35-dev 3.5.1-5.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | // **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef ICE_PROTOCOL_H
#define ICE_PROTOCOL_H
#include <Ice/Config.h>
#include <Ice/Version.h>
namespace IceInternal
{
//
// Size of the Ice protocol header
//
// Magic number (4 Bytes)
// Protocol version major (Byte)
// Protocol version minor (Byte)
// Encoding version major (Byte)
// Encoding version minor (Byte)
// Message type (Byte)
// Compression status (Byte)
// Message size (Int)
//
const ::Ice::Int headerSize = 14;
//
// The magic number at the front of each message
//
extern const ::Ice::Byte magic[4];
//
// The current Ice protocol, protocol encoding and encoding version
//
const ::Ice::Byte protocolMajor = 1;
const ::Ice::Byte protocolMinor = 0;
const ::Ice::Byte protocolEncodingMajor = 1;
const ::Ice::Byte protocolEncodingMinor = 0;
const ::Ice::Byte encodingMajor = 1;
const ::Ice::Byte encodingMinor = 1;
//
// The Ice protocol message types
//
const ::Ice::Byte requestMsg = 0;
const ::Ice::Byte requestBatchMsg = 1;
const ::Ice::Byte replyMsg = 2;
const ::Ice::Byte validateConnectionMsg = 3;
const ::Ice::Byte closeConnectionMsg = 4;
//
// The request header, batch request header and reply header.
//
extern const ::Ice::Byte requestHdr[headerSize + sizeof(Ice::Int)];
extern const ::Ice::Byte requestBatchHdr[headerSize + sizeof(Ice::Int)];
extern const ::Ice::Byte replyHdr[headerSize];
//
// IPv4/IPv6 support enumeration.
//
enum ProtocolSupport
{
EnableIPv4,
EnableIPv6,
EnableBoth
};
// Forward declaration
class BasicStream;
ICE_API void stringToMajorMinor(const ::std::string&, Ice::Byte&, Ice::Byte&);
template<typename T> std::string
versionToString(const T& v)
{
std::ostringstream os;
os << v;
return os.str();
}
template<typename T> T
stringToVersion(const ::std::string& str)
{
T v;
stringToMajorMinor(str, v.major, v.minor);
return v;
}
template<typename T> bool
isSupported(const T& version, const T& supported)
{
return version.major == supported.major && version.minor <= supported.minor;
}
ICE_API void throwUnsupportedProtocolException(const char*, int, const Ice::ProtocolVersion&,
const Ice::ProtocolVersion&);
ICE_API void throwUnsupportedEncodingException(const char*, int, const Ice::EncodingVersion&,
const Ice::EncodingVersion&);
}
namespace Ice
{
ICE_API extern const ProtocolVersion Protocol_1_0;
ICE_API extern const EncodingVersion Encoding_1_0;
ICE_API extern const EncodingVersion Encoding_1_1;
ICE_API extern const ProtocolVersion currentProtocol;
ICE_API extern const EncodingVersion currentProtocolEncoding;
ICE_API extern const EncodingVersion currentEncoding;
inline ::std::string
protocolVersionToString(const Ice::ProtocolVersion& v)
{
return IceInternal::versionToString<ProtocolVersion>(v);
}
inline ::Ice::ProtocolVersion
stringToProtocolVersion(const ::std::string& v)
{
return IceInternal::stringToVersion<ProtocolVersion>(v);
}
inline ::std::string
encodingVersionToString(const Ice::EncodingVersion& v)
{
return IceInternal::versionToString<EncodingVersion>(v);
}
inline ::Ice::EncodingVersion
stringToEncodingVersion(const ::std::string& v)
{
return IceInternal::stringToVersion<EncodingVersion>(v);
}
inline std::ostream&
operator<<(std::ostream& out, const ProtocolVersion& version)
{
return out << static_cast<int>(version.major) << "." << static_cast<int>(version.minor);
}
inline std::ostream&
operator<<(std::ostream& out, const EncodingVersion& version)
{
return out << static_cast<int>(version.major) << "." << static_cast<int>(version.minor);
}
}
namespace IceInternal
{
inline void
checkSupportedProtocol(const Ice::ProtocolVersion& v)
{
if(!isSupported(v, Ice::currentProtocol))
{
throwUnsupportedProtocolException(__FILE__, __LINE__, v, Ice::currentProtocol);
}
}
inline void
checkSupportedProtocolEncoding(const Ice::EncodingVersion& v)
{
if(!isSupported(v, Ice::currentProtocolEncoding))
{
throwUnsupportedEncodingException(__FILE__, __LINE__, v, Ice::currentProtocolEncoding);
}
}
inline void
checkSupportedEncoding(const Ice::EncodingVersion& v)
{
if(!isSupported(v, Ice::currentEncoding))
{
throwUnsupportedEncodingException(__FILE__, __LINE__, v, Ice::currentEncoding);
}
}
//
// Either return the given protocol if not compatible, or the greatest
// supported protocol otherwise.
//
inline const Ice::ProtocolVersion
getCompatibleProtocol(const Ice::ProtocolVersion& v)
{
if(v.major != Ice::currentProtocol.major)
{
return v; // Unsupported protocol, return as is.
}
else if(v.minor < Ice::currentProtocol.minor)
{
return v; // Supported protocol.
}
else
{
//
// Unsupported but compatible, use the currently supported
// protocol, that's the best we can do.
//
return Ice::currentProtocol;
}
}
//
// Either return the given encoding if not compatible, or the greatest
// supported encoding otherwise.
//
inline const Ice::EncodingVersion&
getCompatibleEncoding(const Ice::EncodingVersion& v)
{
if(v.major != Ice::currentEncoding.major)
{
return v; // Unsupported encoding, return as is.
}
else if(v.minor < Ice::currentEncoding.minor)
{
return v; // Supported encoding.
}
else
{
//
// Unsupported but compatible, use the currently supported
// encoding, that's the best we can do.
//
return Ice::currentEncoding;
}
}
}
#endif
|