PCEP sucessfull connection now implemented. Fixed minor bug in parsing.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / PCEPMessageFactory.java
index 788e982fe646305311eb5cdf6682d127e765a8fe..b4f38ccd72bf6505a406377a1ebc1cd86313d0a0 100644 (file)
@@ -137,11 +137,11 @@ public class PCEPMessageFactory implements ProtocolMessageFactory {
 
                logger.trace("Attempt to parse message from bytes: {}", ByteArray.bytesToHexString(bytes));
 
-               final int type = UnsignedBytes.toInt(bytes[0]);
+               final int type = UnsignedBytes.toInt(bytes[1]);
 
-               final int msgLength = ByteArray.bytesToInt(ByteArray.subByte(bytes, TYPE_SIZE, LENGTH_SIZE));
+               final int msgLength = ByteArray.bytesToInt(ByteArray.subByte(bytes, TYPE_SIZE + 1, LENGTH_SIZE));
 
-               final byte[] msgBody = ByteArray.cutBytes(bytes, TYPE_SIZE + LENGTH_SIZE);
+               final byte[] msgBody = ByteArray.cutBytes(bytes, TYPE_SIZE + 1 + LENGTH_SIZE);
 
                if (msgBody.length != (msgLength - COMMON_HEADER_LENGTH))
                        throw new DeserializerException("Size don't match size specified in header. Passed: " + msgBody.length + "; Expected: "