diff options
author | Michi Henning <michi@zeroc.com> | 2003-03-05 04:44:06 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2003-03-05 04:44:06 +0000 |
commit | cbf6716868fd679530dc38be5b956ede9fbea612 (patch) | |
tree | beaed87efc62a11ecdaae0778923176d6c00e31b /java/src | |
parent | use depend tag (diff) | |
download | ice-cbf6716868fd679530dc38be5b956ede9fbea612.tar.bz2 ice-cbf6716868fd679530dc38be5b956ede9fbea612.tar.xz ice-cbf6716868fd679530dc38be5b956ede9fbea612.zip |
Merged in changes for protocol versioning.
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceInternal/BasicStream.java | 65 | ||||
-rw-r--r-- | java/src/IceInternal/Connection.java | 159 | ||||
-rw-r--r-- | java/src/IceInternal/Protocol.java | 20 | ||||
-rw-r--r-- | java/src/IceInternal/ThreadPool.java | 47 | ||||
-rw-r--r-- | java/src/IceInternal/TraceUtil.java | 18 | ||||
-rw-r--r-- | java/src/IceInternal/UdpEndpoint.java | 189 |
6 files changed, 430 insertions, 68 deletions
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index 50b96d75c22..2b399956b60 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -171,8 +171,9 @@ public class BasicStream public void startWriteEncaps() { - writeByte((byte)0); // Encoding writeInt(0); // Placeholder for the encapsulation length + writeByte(Protocol.encodingMajor); + writeByte(Protocol.encodingMinor); WriteEncaps curr = _writeEncapsCache; if(curr != null) { @@ -182,7 +183,6 @@ public class BasicStream { curr = new WriteEncaps(); } - curr.encoding = 0; curr.start = _buf.position(); curr.next = _writeEncapsStack; _writeEncapsStack = curr; @@ -201,18 +201,13 @@ public class BasicStream { _writeEncapsCache.objectsWritten.clear(); } - final int sz = _buf.position() - start; - _buf.putInt(start - 4, sz); + final int sz = _buf.position() - start + 6; // size includes size and version bytes + _buf.putInt(start - 6, sz); } public void startReadEncaps() { - byte encoding = readByte(); - if(encoding != 0) - { - throw new Ice.UnsupportedEncodingException(); - } // // I don't use readSize() and writeSize() for encapsulations, // because when creating an encapsulation, I must know in @@ -225,6 +220,19 @@ public class BasicStream { throw new Ice.NegativeSizeException(); } + + byte eMajor = readByte(); + byte eMinor = readByte(); + if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor) + { + Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); + e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor; + e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor; + e.major = Protocol.encodingMajor; + e.minor = Protocol.encodingMinor; + throw e; + } + ReadEncaps curr = _readEncapsCache; if(curr != null) { @@ -235,7 +243,8 @@ public class BasicStream { curr = new ReadEncaps(); } - curr.encoding = encoding; + curr.encodingMajor = eMajor; + curr.encodingMinor = eMinor; curr.start = _buf.position(); curr.next = _readEncapsStack; _readEncapsStack = curr; @@ -269,14 +278,14 @@ public class BasicStream { _readEncapsCache.objectsRead.clear(); } - final int sz = _buf.getInt(start - 4); + final int sz = _buf.getInt(start - 6); // - 4 bytes for size, - 2 bytes for version if(sz < 0) { throw new Ice.NegativeSizeException(); } try { - _buf.position(start + sz); + _buf.position(start + sz - 6); } catch(IllegalArgumentException ex) { @@ -288,12 +297,12 @@ public class BasicStream checkReadEncaps() { assert(_readEncapsStack != null); - final int sz = _buf.getInt(_readEncapsStack.start - 4); + final int sz = _buf.getInt(_readEncapsStack.start - 6); // - 4 bytes for size, - 2 bytes for version if(sz < 0) { throw new Ice.NegativeSizeException(); } - if(sz != _buf.position() - _readEncapsStack.start) + if(sz != _buf.position() - _readEncapsStack.start + 6) { throw new Ice.EncapsulationException(); } @@ -303,22 +312,30 @@ public class BasicStream getReadEncapsSize() { assert(_readEncapsStack != null); - int sz = _buf.getInt(_readEncapsStack.start - 4); + int sz = _buf.getInt(_readEncapsStack.start - 6); // - 4 bytes for size, - 2 bytes for version if(sz < 0) { throw new Ice.NegativeSizeException(); } - return sz; + + byte eMajor = readByte(); + byte eMinor = readByte(); + if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor) + { + Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); + e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor; + e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor; + e.major = Protocol.encodingMajor; + e.minor = Protocol.encodingMinor; + throw e; + } + + return sz - 6; // - 4 bytes for size, - 2 bytes for version } public void skipEncaps() { - byte encoding = readByte(); - if(encoding != 0) - { - throw new Ice.UnsupportedEncodingException(); - } int sz = readInt(); if(sz < 0) { @@ -326,7 +343,7 @@ public class BasicStream } try { - _buf.position(_buf.position() + sz); + _buf.position(_buf.position() + sz - 4); } catch(IllegalArgumentException ex) { @@ -1323,7 +1340,8 @@ public class BasicStream private static final class ReadEncaps { int start; - byte encoding; + byte encodingMajor; + byte encodingMinor; java.util.ArrayList objectsRead; ReadEncaps next; } @@ -1331,7 +1349,6 @@ public class BasicStream private static final class WriteEncaps { int start; - byte encoding; java.util.IdentityHashMap objectsWritten; WriteEncaps next; } diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java index 35ae3e5ce69..035a54a2205 100644 --- a/java/src/IceInternal/Connection.java +++ b/java/src/IceInternal/Connection.java @@ -158,8 +158,14 @@ public final class Connection extends EventHandler // respect to connection validation. // BasicStream os = new BasicStream(_instance); - os.writeByte(Protocol.protocolVersion); - os.writeByte(Protocol.encodingVersion); + os.writeByte(Protocol.magic[0]); + os.writeByte(Protocol.magic[1]); + os.writeByte(Protocol.magic[2]); + os.writeByte(Protocol.magic[3]); + os.writeByte(Protocol.protocolMajor); + os.writeByte(Protocol.protocolMinor); + os.writeByte(Protocol.encodingMajor); + os.writeByte(Protocol.encodingMinor); os.writeByte(Protocol.validateConnectionMsg); os.writeInt(Protocol.headerSize); // Message size. TraceUtil.traceHeader("sending validate connection", os, _logger, _traceLevels); @@ -178,16 +184,61 @@ public final class Connection extends EventHandler int pos = is.pos(); assert(pos >= Protocol.headerSize); is.pos(0); - byte protVer = is.readByte(); - if(protVer != Protocol.protocolVersion) + byte[] m = new byte[4]; + m[0] = is.readByte(); + m[1] = is.readByte(); + m[2] = is.readByte(); + m[3] = is.readByte(); + if(m[0] != Protocol.magic[0] || m[1] != Protocol.magic[1] + || m[2] != Protocol.magic[2] || m[3] != Protocol.magic[3]) { - throw new Ice.UnsupportedProtocolException(); + Ice.BadMagicException ex = new Ice.BadMagicException(); + ex.badMagic = m; + throw ex; } - byte encVer = is.readByte(); - if(encVer != Protocol.encodingVersion) + byte pMajor = is.readByte(); + byte pMinor = is.readByte(); + + // + // We only check the major version number here. The minor version + // number is irrelevant -- no matter what minor version number is offered + // by the server, we can be certain that the server supports at least minor version 0. + // As the client, we are obliged to never produce a message with a minor + // version number that is larger than what the server can understand, but we don't + // care if the server understands more than we do. + // + // Note: Once we add minor versions, we need to modify the client side to never produce + // a message with a minor number that is greater than what the server can handle. Similarly, + // the server side will have to be modified so it never replies with a minor version that is + // greater than what the client can handle. + // + if(pMajor != Protocol.protocolMajor) + { + Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); + e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor; + e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor; + e.major = Protocol.protocolMajor; + e.minor = Protocol.protocolMinor; + throw e; + } + + byte eMajor = is.readByte(); + byte eMinor = is.readByte(); + + // + // The same applies here as above -- only the major version number + // of the encoding is relevant. + // + if(eMajor != Protocol.encodingMajor) { - throw new Ice.UnsupportedEncodingException(); + Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); + e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor; + e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor; + e.major = Protocol.encodingMajor; + e.minor = Protocol.encodingMinor; + throw e; } + byte messageType = is.readByte(); if(messageType != Protocol.validateConnectionMsg) { @@ -263,8 +314,14 @@ public final class Connection extends EventHandler private final static byte[] _requestHdr = { - Protocol.protocolVersion, - Protocol.encodingVersion, + Protocol.magic[0], + Protocol.magic[1], + Protocol.magic[2], + Protocol.magic[3], + Protocol.protocolMajor, + Protocol.protocolMinor, + Protocol.encodingMajor, + Protocol.encodingMinor, Protocol.requestMsg, (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). (byte)0, (byte)0, (byte)0, (byte)0 // Request ID (placeholder). @@ -290,7 +347,7 @@ public final class Connection extends EventHandler try { BasicStream os = out.os(); - os.pos(3); + os.pos(9); // // Fill in the message size and request ID. @@ -349,7 +406,7 @@ public final class Connection extends EventHandler try { BasicStream os = out.__os(); - os.pos(3); + os.pos(9); // // Fill in the message size and request ID. @@ -389,8 +446,14 @@ public final class Connection extends EventHandler private final static byte[] _requestBatchHdr = { - Protocol.protocolVersion, - Protocol.encodingVersion, + Protocol.magic[0], + Protocol.magic[1], + Protocol.magic[2], + Protocol.magic[3], + Protocol.protocolMajor, + Protocol.protocolMinor, + Protocol.encodingMajor, + Protocol.encodingMinor, Protocol.requestBatchMsg, (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). (byte)0, (byte)0, (byte)0, (byte)0 // Number of requests in batch (placeholder). @@ -498,7 +561,7 @@ public final class Connection extends EventHandler try { - _batchStream.pos(3); + _batchStream.pos(9); // // Fill in the message size. @@ -554,7 +617,7 @@ public final class Connection extends EventHandler // // Fill in the message size. // - os.pos(3); + os.pos(9); final int sz = os.size(); os.writeInt(sz); @@ -686,8 +749,14 @@ public final class Connection extends EventHandler private final static byte[] _replyHdr = { - Protocol.protocolVersion, - Protocol.encodingVersion, + Protocol.magic[0], + Protocol.magic[1], + Protocol.magic[2], + Protocol.magic[3], + Protocol.protocolMajor, + Protocol.protocolMinor, + Protocol.encodingMajor, + Protocol.encodingMinor, Protocol.replyMsg, (byte)0, (byte)0, (byte)0, (byte)0 // Message size (placeholder). }; @@ -718,7 +787,45 @@ public final class Connection extends EventHandler try { assert(stream.pos() == stream.size()); - stream.pos(2); + stream.pos(0); + + byte[] m = new byte[4]; + m[0] = stream.readByte(); + m[1] = stream.readByte(); + m[2] = stream.readByte(); + m[3] = stream.readByte(); + if(m[0] != Protocol.magic[0] || m[1] != Protocol.magic[1] + || m[2] != Protocol.magic[2] || m[3] != Protocol.magic[3]) + { + Ice.BadMagicException ex = new Ice.BadMagicException(); + ex.badMagic = m; + throw ex; + } + + byte pMajor = stream.readByte(); + byte pMinor = stream.readByte(); + if(pMajor != Protocol.protocolMajor || pMinor > Protocol.protocolMinor) + { + Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); + e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor; + e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor; + e.major = Protocol.protocolMajor; + e.minor = Protocol.protocolMinor; + throw e; + } + + byte eMajor = stream.readByte(); + byte eMinor = stream.readByte(); + if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor) + { + Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); + e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor; + e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor; + e.major = Protocol.encodingMajor; + e.minor = Protocol.encodingMinor; + throw e; + } + byte messageType = stream.readByte(); stream.pos(Protocol.headerSize); @@ -956,8 +1063,8 @@ public final class Connection extends EventHandler _transceiver = transceiver; _endpoint = endpoint; _adapter = adapter; - _logger = instance.logger(); // Chached for better performance. - _traceLevels = instance.traceLevels(); // Chached for better performance. + _logger = instance.logger(); // Cached for better performance. + _traceLevels = instance.traceLevels(); // Cached for better performance. _registeredWithPool = false; _warn = false; _acmTimeout = 0; @@ -1172,8 +1279,14 @@ public final class Connection extends EventHandler // message. // BasicStream os = new BasicStream(_instance); - os.writeByte(Protocol.protocolVersion); - os.writeByte(Protocol.encodingVersion); + os.writeByte(Protocol.magic[0]); + os.writeByte(Protocol.magic[1]); + os.writeByte(Protocol.magic[2]); + os.writeByte(Protocol.magic[3]); + os.writeByte(Protocol.protocolMajor); + os.writeByte(Protocol.protocolMinor); + os.writeByte(Protocol.encodingMajor); + os.writeByte(Protocol.encodingMinor); os.writeByte(Protocol.closeConnectionMsg); os.writeInt(Protocol.headerSize); // Message size. _transceiver.write(os, _endpoint.timeout()); diff --git a/java/src/IceInternal/Protocol.java b/java/src/IceInternal/Protocol.java index c38f47fc06c..35a9c57a702 100644 --- a/java/src/IceInternal/Protocol.java +++ b/java/src/IceInternal/Protocol.java @@ -19,18 +19,28 @@ final class Protocol // // Size of the Ice protocol header // - // Protocol version (Byte) - // Encoding version (Byte) + // Magic number (4 bytes) + // Protocol version major (Byte) + // Protocol version minor (Byte) + // Encoding version major (Byte) + // Encoding version minor (Byte) // Message type (Byte) // Message size (Int) // - final static int headerSize = 7; + final static int headerSize = 13; + + // + // The magic number at the front of each message + // + final static byte magic[] = { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P' // // The current Ice protocol and encoding version // - final static byte protocolVersion = 0; - final static byte encodingVersion = 0; + final static byte protocolMajor = 1; + final static byte protocolMinor = 0; + final static byte encodingMajor = 1; + final static byte encodingMinor = 0; // // The Ice protocol message types diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index 203eec0ffe2..666d607e417 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -658,16 +658,43 @@ public final class ThreadPool int pos = stream.pos(); assert(pos >= Protocol.headerSize); stream.pos(0); - byte protVer = stream.readByte(); - if(protVer != Protocol.protocolVersion) - { - throw new Ice.UnsupportedProtocolException(); - } - byte encVer = stream.readByte(); - if(encVer != Protocol.encodingVersion) - { - throw new Ice.UnsupportedEncodingException(); - } + byte[] m = new byte[4]; + m[0] = stream.readByte(); + m[1] = stream.readByte(); + m[2] = stream.readByte(); + m[3] = stream.readByte(); + if(m[0] != Protocol.magic[0] || m[1] != Protocol.magic[1] + || m[2] != Protocol.magic[2] || m[3] != Protocol.magic[3]) + { + Ice.BadMagicException ex = new Ice.BadMagicException(); + ex.badMagic = m; + throw ex; + } + + byte pMajor = stream.readByte(); + byte pMinor = stream.readByte(); + if(pMajor != Protocol.protocolMajor || pMinor > Protocol.protocolMinor) + { + Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); + e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor; + e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor; + e.major = Protocol.protocolMajor; + e.minor = Protocol.protocolMinor; + throw e; + } + + byte eMajor = stream.readByte(); + byte eMinor = stream.readByte(); + if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor) + { + Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); + e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor; + e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor; + e.major = Protocol.encodingMajor; + e.minor = Protocol.encodingMinor; + throw e; + } + byte messageType = stream.readByte(); int size = stream.readInt(); if(size < Protocol.headerSize) diff --git a/java/src/IceInternal/TraceUtil.java b/java/src/IceInternal/TraceUtil.java index 8ce03d4b7ec..e2a8dc016db 100644 --- a/java/src/IceInternal/TraceUtil.java +++ b/java/src/IceInternal/TraceUtil.java @@ -333,11 +333,19 @@ final class TraceUtil { try { - byte protVer = stream.readByte(); -// out.write("\nprotocol version = " + (int)protVer); - - byte encVer = stream.readByte(); -// out.write("\nencoding version = " + (int)encVer); + byte magic; + magic = stream.readByte(); // Don't bother printing the magic number + magic = stream.readByte(); + magic = stream.readByte(); + magic = stream.readByte(); + + byte pMajor = stream.readByte(); + byte pMinor = stream.readByte(); +// out.write("\nprotocol version = " + (int)pMajor + "." + (int)pMinor); + + byte eMajor = stream.readByte(); + byte eMinor = stream.readByte(); +// out.write("\nencoding version = " + (int)eMajor + "." + (int)eMinor); byte type = stream.readByte(); out.write("\nmessage type = " + (int)type + ' '); diff --git a/java/src/IceInternal/UdpEndpoint.java b/java/src/IceInternal/UdpEndpoint.java index b9c5c953c41..ce9bc3d71e2 100644 --- a/java/src/IceInternal/UdpEndpoint.java +++ b/java/src/IceInternal/UdpEndpoint.java @@ -24,6 +24,10 @@ final class UdpEndpoint implements Endpoint _instance = instance; _host = ho; _port = po; + _protocolMajor = Protocol.protocolMajor; + _protocolMinor = Protocol.protocolMinor; + _encodingMajor = Protocol.encodingMajor; + _encodingMinor = Protocol.encodingMinor; _connect = false; _compress = co; calcHashValue(); @@ -65,6 +69,118 @@ final class UdpEndpoint implements Endpoint switch(option.charAt(1)) { + case 'v': + { + if(argument == null) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "udp " + str; + throw e; + } + + int pos = argument.indexOf('.'); + if(pos == -1) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "udp " + str; + throw e; + } + + String majStr = argument.substring(0, pos); + String minStr = argument.substring(pos + 1, argument.length()); + int majVersion; + int minVersion; + try + { + majVersion = Integer.parseInt(majStr); + minVersion = Integer.parseInt(minStr); + } + catch(NumberFormatException ex) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "udp " + str; + throw e; + } + + if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "udp " + str; + throw e; + } + + if(majVersion != Protocol.protocolMajor) + { + Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); + e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion; + e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion; + e.major = Protocol.protocolMajor; + e.minor = Protocol.protocolMinor; + throw e; + } + + _protocolMajor = (byte)majVersion; + _protocolMinor = (byte)minVersion; + + break; + } + + case 'e': + { + if(argument == null) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "udp " + str; + throw e; + } + + int pos = argument.indexOf('.'); + if(pos == -1) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "udp " + str; + throw e; + } + + String majStr = argument.substring(0, pos); + String minStr = argument.substring(pos + 1, argument.length()); + int majVersion; + int minVersion; + try + { + majVersion = Integer.parseInt(majStr); + minVersion = Integer.parseInt(minStr); + } + catch(NumberFormatException ex) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "udp " + str; + throw e; + } + + if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "udp " + str; + throw e; + } + + if(majVersion != Protocol.encodingMajor) + { + Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); + e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion; + e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion; + e.major = Protocol.encodingMajor; + e.minor = Protocol.encodingMinor; + throw e; + } + + _encodingMajor = (byte)majVersion; + _encodingMinor = (byte)minVersion; + + break; + } + case 'h': { if(argument == null) @@ -151,6 +267,28 @@ final class UdpEndpoint implements Endpoint s.startReadEncaps(); _host = s.readString(); _port = s.readInt(); + _protocolMajor = s.readByte(); + _protocolMinor = s.readByte(); + _encodingMajor = s.readByte(); + _encodingMinor = s.readByte(); + if(_protocolMajor != Protocol.protocolMajor) + { + Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); + e.badMajor = _protocolMajor < 0 ? _protocolMajor + 255 : _protocolMajor; + e.badMinor = _protocolMinor < 0 ? _protocolMinor + 255 : _protocolMinor; + e.major = Protocol.protocolMajor; + e.minor = Protocol.protocolMinor; + throw e; + } + if(_encodingMajor != Protocol.encodingMajor) + { + Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); + e.badMajor = _encodingMajor < 0 ? _encodingMajor + 255 : _encodingMajor; + e.badMinor = _encodingMinor < 0 ? _encodingMinor + 255 : _encodingMinor; + e.major = Protocol.encodingMajor; + e.minor = Protocol.encodingMinor; + throw e; + } // Not transmitted. //_connect = s.readBool(); _connect = false; @@ -169,6 +307,10 @@ final class UdpEndpoint implements Endpoint s.startWriteEncaps(); s.writeString(_host); s.writeInt(_port); + s.writeByte(_protocolMajor); + s.writeByte(_protocolMinor); + s.writeByte(_encodingMajor); + s.writeByte(_encodingMinor); // Not transmitted. //s.writeBool(_connect); s.writeBool(_compress); @@ -181,7 +323,12 @@ final class UdpEndpoint implements Endpoint public String toString() { - String s = "udp -h " + _host + " -p " + _port; + String s = "udp"; + s += " -v " + (_protocolMajor < 0 ? (int)_protocolMajor + 255 : _protocolMajor) + + "." + (_protocolMinor < 0 ? (int)_protocolMinor + 255 : _protocolMinor); + s += " -e " + (_encodingMajor < 0 ? (int)_encodingMajor + 255 : _encodingMajor) + + "." + (_encodingMinor < 0 ? (int)_encodingMinor + 255 : _encodingMinor); + s += " -h " + _host + " -p " + _port; if(_connect) { s += " -c"; @@ -413,6 +560,42 @@ final class UdpEndpoint implements Endpoint return 1; } + if(_protocolMajor < p._protocolMajor) + { + return -1; + } + else if(p._protocolMajor < _protocolMajor) + { + return 1; + } + + if(_protocolMinor < p._protocolMinor) + { + return -1; + } + else if(p._protocolMinor < _protocolMinor) + { + return 1; + } + + if(_encodingMajor < p._encodingMajor) + { + return -1; + } + else if(p._encodingMajor < _encodingMajor) + { + return 1; + } + + if(_encodingMinor < p._encodingMinor) + { + return -1; + } + else if(p._encodingMinor < _encodingMinor) + { + return 1; + } + if(!_host.equals(p._host)) { // @@ -453,6 +636,10 @@ final class UdpEndpoint implements Endpoint private Instance _instance; private String _host; private int _port; + private byte _protocolMajor; + private byte _protocolMinor; + private byte _encodingMajor; + private byte _encodingMinor; private boolean _connect; private boolean _compress; private int _hashCode; |