requestEncodingVersion = buf.get(5);
buf.put(4, (byte) 0x01);
buf.put(5, (byte) 0x02);
}
GIOPVersion orbVersion = orb.getORBData().getGIOPVersion();
if (orb.giopDebugFlag) {
dprint(".readGIOPHeader: Message GIOP version: "
+ buf.get(4) + '.' + buf.get(5));
dprint(".readGIOPHeader: ORB Max GIOP Version: "
+ orbVersion);
}
if ( (buf.get(4) > orbVersion.getMajor()) ||
( (buf.get(4) == orbVersion.getMajor()) && (buf.get(5) > orbVersion.getMinor()) )
) {
// For requests, sending ORB should use the version info
// published in the IOR or may choose to use a <= version
// for requests. If the version is greater than published version,
// it is an error.
// For replies, the ORB should always receive a version it supports
// or less, but never greater (except for MessageError)
// ACTION : Send back a MessageError() with the the highest version
// the server ORB supports, and close the connection.
if ( buf.get(7) != GIOPMessageError ) {
throw wrapper.giopVersionError( CompletionStatus.COMPLETED_MAYBE);
}
}
AreFragmentsAllowed(buf.get(4), buf.get(5), buf.get(6), buf.get(7));
// create appropriate messages types
switch (buf.get(7)) {
case GIOPRequest:
if (orb.giopDebugFlag) {
dprint(".readGIOPHeader: creating RequestMessage");
}
//msg = new RequestMessage(orb.giopDebugFlag);
if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x00) ) { // 1.0
msg = new RequestMessage_1_0(orb);
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x01) ) { // 1.1
msg = new RequestMessage_1_1(orb);
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x02) ) { // 1.2
msg = new RequestMessage_1_2(orb);
} else {
throw wrapper.giopVersionError(
CompletionStatus.COMPLETED_MAYBE);
}
break;
case GIOPLocateRequest:
if (orb.giopDebugFlag) {
dprint(".readGIOPHeader: creating LocateRequestMessage");
}
//msg = new LocateRequestMessage(orb.giopDebugFlag);
if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x00) ) { // 1.0
msg = new LocateRequestMessage_1_0(orb);
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x01) ) { // 1.1
msg = new LocateRequestMessage_1_1(orb);
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x02) ) { // 1.2
msg = new LocateRequestMessage_1_2(orb);
} else {
throw wrapper.giopVersionError(
CompletionStatus.COMPLETED_MAYBE);
}
break;
case GIOPCancelRequest:
if (orb.giopDebugFlag) {
dprint(".readGIOPHeader: creating CancelRequestMessage");
}
//msg = new CancelRequestMessage(orb.giopDebugFlag);
if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x00) ) { // 1.0
msg = new CancelRequestMessage_1_0();
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x01) ) { // 1.1
msg = new CancelRequestMessage_1_1();
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x02) ) { // 1.2
msg = new CancelRequestMessage_1_2();
} else {
throw wrapper.giopVersionError(
CompletionStatus.COMPLETED_MAYBE);
}
break;
case GIOPReply:
if (orb.giopDebugFlag) {
dprint(".readGIOPHeader: creating ReplyMessage");
}
//msg = new ReplyMessage(orb.giopDebugFlag);
if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x00) ) { // 1.0
msg = new ReplyMessage_1_0(orb);
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x01) ) { // 1.1
msg = new ReplyMessage_1_1(orb);
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x02) ) { // 1.2
msg = new ReplyMessage_1_2(orb);
} else {
throw wrapper.giopVersionError(
CompletionStatus.COMPLETED_MAYBE);
}
break;
case GIOPLocateReply:
if (orb.giopDebugFlag) {
dprint(".readGIOPHeader: creating LocateReplyMessage");
}
//msg = new LocateReplyMessage(orb.giopDebugFlag);
if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x00) ) { // 1.0
msg = new LocateReplyMessage_1_0(orb);
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x01) ) { // 1.1
msg = new LocateReplyMessage_1_1(orb);
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x02) ) { // 1.2
msg = new LocateReplyMessage_1_2(orb);
} else {
throw wrapper.giopVersionError(
CompletionStatus.COMPLETED_MAYBE);
}
break;
case GIOPCloseConnection:
case GIOPMessageError:
if (orb.giopDebugFlag) {
dprint(".readGIOPHeader: creating Message for CloseConnection or MessageError");
}
// REVISIT a MessageError may contain the highest version server
// can support. In such a case, a new request may be made with the
// correct version or the connection be simply closed. Note the
// connection may have been closed by the server.
//msg = new Message(orb.giopDebugFlag);
if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x00) ) { // 1.0
msg = new Message_1_0();
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x01) ) { // 1.1
msg = new Message_1_1();
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x02) ) { // 1.2
msg = new Message_1_1();
} else {
throw wrapper.giopVersionError(
CompletionStatus.COMPLETED_MAYBE);
}
break;
case GIOPFragment:
if (orb.giopDebugFlag) {
dprint(".readGIOPHeader: creating FragmentMessage");
}
//msg = new FragmentMessage(orb.giopDebugFlag);
if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x00) ) { // 1.0
// not possible (error checking done already)
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x01) ) { // 1.1
msg = new FragmentMessage_1_1();
} else if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x02) ) { // 1.2
msg = new FragmentMessage_1_2();
} else {
throw wrapper.giopVersionError(
CompletionStatus.COMPLETED_MAYBE);
}
break;
default:
if (orb.giopDebugFlag)
dprint(".readGIOPHeader: UNKNOWN MESSAGE TYPE: "
+ buf.get(7));
// unknown message type ?
// ACTION : send MessageError and close the connection
throw wrapper.giopVersionError(
CompletionStatus.COMPLETED_MAYBE);
}
//
// Initialize the generic GIOP header instance variables.
//
if ( (buf.get(4) == 0x01) && (buf.get(5) == 0x00) ) { // 1.0
Message_1_0 msg10 = (Message_1_0) msg;
msg10.magic = magic;
msg10.GIOP_version = new GIOPVersion(buf.get(4), buf.get(5));
msg10.byte_order = (buf.get(6) == LITTLE_ENDIAN_BIT);
// 'request partitioning' not supported on GIOP version 1.0
// so just use the default thread pool, 0.
msg.threadPoolToUse = 0;
msg10.message_type = buf.get(7);
msg10.message_size = readSize(buf.get(8), buf.get(9), buf.get(10), buf.get(11),
msg10.isLittleEndian()) +
GIOPMessageHeaderLength;
} else { // 1.1 & 1.2
Message_1_1 msg11 = (Message_1_1) msg;
msg11.magic = magic;
msg11.GIOP_version = new GIOPVersion(buf.get(4), buf.get(5));
msg11.flags = (byte)(buf.get(6) & TRAILING_TWO_BIT_BYTE_MASK);
// IMPORTANT: For 'request partitioning', the thread pool to use
// information is stored in the leading 6 bits of byte 6.
//
// IMPORTANT: Request partitioning is a PROPRIETARY EXTENSION !!!