diff options
author | Michi Henning <michi@zeroc.com> | 2003-03-03 06:13:53 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2003-03-03 06:13:53 +0000 |
commit | 0609f08160e409bbba2d716cc05d01004d7de457 (patch) | |
tree | 7aa6e97d36845e448c9b6a877ee0bdac33ef65f7 /java/src/IceInternal/ThreadPool.java | |
parent | minor edit (diff) | |
download | ice-0609f08160e409bbba2d716cc05d01004d7de457.tar.bz2 ice-0609f08160e409bbba2d716cc05d01004d7de457.tar.xz ice-0609f08160e409bbba2d716cc05d01004d7de457.zip |
Added magic number and versioning to Ice protocol. Encapsulations are still
written with version number *outside* the encapsulation. Will probably
change that to inside soon.
Diffstat (limited to 'java/src/IceInternal/ThreadPool.java')
-rw-r--r-- | java/src/IceInternal/ThreadPool.java | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index 203eec0ffe2..6078c616a13 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -658,16 +658,42 @@ 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[] magic = new byte[4]; + magic[0] = stream.readByte(); + magic[1] = stream.readByte(); + magic[2] = stream.readByte(); + magic[3] = stream.readByte(); + if(magic[0] != 0x49 || magic[1] != 0x63 || magic[2] != 0x65 || magic[3] != 0x50) + { + Ice.BadMagicException ex = new Ice.BadMagicException(); + ex.badMagic = magic; + 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) |