2008-12-17 12:39:45 +01:00
|
|
|
/*
|
2009-08-28 09:15:49 +02:00
|
|
|
* Copyright 2009 Red Hat, Inc.
|
2008-12-17 12:39:45 +01:00
|
|
|
*
|
2009-08-28 09:15:49 +02:00
|
|
|
* Red Hat licenses this file to you under the Apache License, version 2.0
|
|
|
|
* (the "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at:
|
2008-12-17 12:39:45 +01:00
|
|
|
*
|
2009-08-28 09:15:49 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-12-17 12:39:45 +01:00
|
|
|
*
|
2009-08-28 09:15:49 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2008-12-17 12:39:45 +01:00
|
|
|
*/
|
|
|
|
package org.jboss.netty.handler.codec.frame;
|
|
|
|
|
|
|
|
import org.jboss.netty.buffer.ChannelBuffer;
|
|
|
|
import org.jboss.netty.channel.Channel;
|
|
|
|
import org.jboss.netty.channel.ChannelHandlerContext;
|
|
|
|
|
|
|
|
/**
|
2009-06-18 14:30:38 +02:00
|
|
|
* A decoder that splits the received {@link ChannelBuffer}s dynamically by the
|
|
|
|
* value of the length field in the message. It is particularly useful when you
|
|
|
|
* decode a binary message which has an integer header field that represents the
|
|
|
|
* length of the message body or the whole message.
|
2009-06-18 14:16:25 +02:00
|
|
|
* <p>
|
|
|
|
* {@link LengthFieldBasedFrameDecoder} has many configuration parameters so
|
|
|
|
* that it can decode any message with a length field, which is often seen in
|
2009-09-25 03:39:43 +02:00
|
|
|
* proprietary client-server protocols. Here are some example that will give
|
2009-06-18 14:16:25 +02:00
|
|
|
* you the basic idea on which option does what.
|
|
|
|
*
|
2009-06-18 14:19:59 +02:00
|
|
|
* <h3>2 bytes length field at offset 0, do not strip header</h3>
|
2009-09-25 03:39:43 +02:00
|
|
|
*
|
2009-09-25 03:50:49 +02:00
|
|
|
* The value of the length field in this example is <tt>12 (0x0C)</tt> which
|
2009-09-25 03:39:43 +02:00
|
|
|
* represents the length of "HELLO, WORLD". By default, the decoder assumes
|
|
|
|
* that the length field represents the number of the bytes that follows the
|
|
|
|
* length field. Therefore, it can be decoded with the simplistic parameter
|
|
|
|
* combination.
|
2009-06-18 14:16:25 +02:00
|
|
|
* <pre>
|
|
|
|
* <b>lengthFieldOffset</b> = <b>0</b>
|
|
|
|
* <b>lengthFieldLength</b> = <b>2</b>
|
2009-09-25 03:39:43 +02:00
|
|
|
* lengthAdjustment = 0
|
|
|
|
* initialBytesToStrip = 0 (= do not strip header)
|
2009-06-18 14:16:25 +02:00
|
|
|
*
|
|
|
|
* BEFORE DECODE (14 bytes) AFTER DECODE (14 bytes)
|
|
|
|
* +--------+----------------+ +--------+----------------+
|
|
|
|
* | Length | Actual Content |----->| Length | Actual Content |
|
|
|
|
* | 0x000C | "HELLO, WORLD" | | 0x000C | "HELLO, WORLD" |
|
|
|
|
* +--------+----------------+ +--------+----------------+
|
|
|
|
* </pre>
|
|
|
|
*
|
2009-06-18 14:21:46 +02:00
|
|
|
* <h3>2 bytes length field at offset 0, strip header</h3>
|
2009-09-25 03:39:43 +02:00
|
|
|
*
|
|
|
|
* Because we can get the length of the content by calling
|
|
|
|
* {@link ChannelBuffer#readableBytes()}, you might want to strip the length
|
|
|
|
* field by specifying <tt>initialBytesToStrip</tt>. In this example, we
|
2009-09-25 03:55:19 +02:00
|
|
|
* specified <tt>2</tt>, that is same with the length of the length field, to
|
|
|
|
* strip the first two bytes.
|
2009-06-18 14:21:46 +02:00
|
|
|
* <pre>
|
2009-09-25 03:39:43 +02:00
|
|
|
* lengthFieldOffset = 0
|
|
|
|
* lengthFieldLength = 2
|
|
|
|
* lengthAdjustment = 0
|
|
|
|
* <b>initialBytesToStrip</b> = <b>2</b> (= the length of the Length field)
|
2009-06-18 14:21:46 +02:00
|
|
|
*
|
|
|
|
* BEFORE DECODE (14 bytes) AFTER DECODE (12 bytes)
|
|
|
|
* +--------+----------------+ +----------------+
|
|
|
|
* | Length | Actual Content |----->| Actual Content |
|
|
|
|
* | 0x000C | "HELLO, WORLD" | | "HELLO, WORLD" |
|
|
|
|
* +--------+----------------+ +----------------+
|
|
|
|
* </pre>
|
|
|
|
*
|
2009-09-25 03:39:43 +02:00
|
|
|
* <h3>2 bytes length field at offset 0, do not strip header, the length field
|
|
|
|
* represents the length of the whole message</h3>
|
|
|
|
*
|
|
|
|
* In most cases, the length field represents the length of the message body
|
|
|
|
* only, as shown in the previous examples. However, in some protocols, the
|
|
|
|
* length field represents the length of the whole message, including the
|
|
|
|
* message header. In such a case, we specify a non-zero
|
|
|
|
* <tt>lengthAdjustment</tt>. Because the length value in this example message
|
|
|
|
* is always greater than the body length by <tt>2</tt>, we specify <tt>-2</tt>
|
|
|
|
* as <tt>lengthAdjustment</tt> for compensation.
|
|
|
|
* <pre>
|
|
|
|
* lengthFieldOffset = 0
|
|
|
|
* lengthFieldLength = 2
|
|
|
|
* <b>lengthAdjustment</b> = <b>-2</b> (= the length of the Length field)
|
|
|
|
* initialBytesToStrip = 0
|
|
|
|
*
|
|
|
|
* BEFORE DECODE (14 bytes) AFTER DECODE (14 bytes)
|
|
|
|
* +--------+----------------+ +--------+----------------+
|
|
|
|
* | Length | Actual Content |----->| Length | Actual Content |
|
|
|
|
* | 0x000E | "HELLO, WORLD" | | 0x000E | "HELLO, WORLD" |
|
|
|
|
* +--------+----------------+ +--------+----------------+
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* <h3>3 bytes length field at the end of 5 bytes header, do not strip header</h3>
|
|
|
|
*
|
|
|
|
* The following message is a simple variation of the first example. An extra
|
|
|
|
* header value is prepended to the message. <tt>lengthAdjustment</tt> is zero
|
2009-09-25 03:55:19 +02:00
|
|
|
* again because the decoder always takes the length of the prepended data into
|
|
|
|
* account during frame length calculation.
|
2009-06-18 14:16:25 +02:00
|
|
|
* <pre>
|
2009-09-25 03:39:43 +02:00
|
|
|
* <b>lengthFieldOffset</b> = <b>2</b> (= the length of Header 1)
|
2009-06-18 14:16:25 +02:00
|
|
|
* <b>lengthFieldLength</b> = <b>3</b>
|
2009-09-25 03:39:43 +02:00
|
|
|
* lengthAdjustment = 0
|
|
|
|
* initialBytesToStrip = 0
|
|
|
|
*
|
|
|
|
* BEFORE DECODE (17 bytes) AFTER DECODE (17 bytes)
|
|
|
|
* +----------+----------+----------------+ +----------+----------+----------------+
|
|
|
|
* | Header 1 | Length | Actual Content |----->| Header 1 | Length | Actual Content |
|
|
|
|
* | 0xCAFE | 0x00000C | "HELLO, WORLD" | | 0xCAFE | 0x00000C | "HELLO, WORLD" |
|
|
|
|
* +----------+----------+----------------+ +----------+----------+----------------+
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* <h3>3 bytes length field at the beginning of 5 bytes header, do not strip header</h3>
|
|
|
|
*
|
2009-09-25 03:55:19 +02:00
|
|
|
* This is an advanced example that shows the case where there is an extra
|
|
|
|
* header between the length field and the message body. You have to specify a
|
2009-09-25 03:39:43 +02:00
|
|
|
* positive <tt>lengthAdjustment</tt> so that the decoder counts the extra
|
|
|
|
* header into the frame length calculation.
|
|
|
|
* <pre>
|
|
|
|
* lengthFieldOffset = 0
|
|
|
|
* lengthFieldLength = 3
|
|
|
|
* <b>lengthAdjustment</b> = <b>2</b> (= the length of Header 1)
|
|
|
|
* initialBytesToStrip = 0
|
|
|
|
*
|
|
|
|
* BEFORE DECODE (17 bytes) AFTER DECODE (17 bytes)
|
|
|
|
* +----------+----------+----------------+ +----------+----------+----------------+
|
|
|
|
* | Length | Header 1 | Actual Content |----->| Length | Header 1 | Actual Content |
|
|
|
|
* | 0x00000C | 0xCAFE | "HELLO, WORLD" | | 0x00000C | 0xCAFE | "HELLO, WORLD" |
|
|
|
|
* +----------+----------+----------------+ +----------+----------+----------------+
|
2009-06-18 14:16:25 +02:00
|
|
|
* </pre>
|
|
|
|
*
|
2009-06-18 14:19:59 +02:00
|
|
|
* <h3>2 bytes length field at offset 1 in the middle of 4 bytes header,
|
2009-06-18 14:16:25 +02:00
|
|
|
* strip the first header field and the length field</h3>
|
2009-09-25 03:39:43 +02:00
|
|
|
*
|
|
|
|
* This is a combination of all the examples above. There are the prepended
|
|
|
|
* header before the length field and the extra header after the length field.
|
|
|
|
* The prepended header affects the <tt>lengthFieldOffset</tt> and the extra
|
|
|
|
* header affects the <tt>lengthAdjustment</tt>. We also specified a non-zero
|
|
|
|
* <tt>initialBytesToStrip</tt> to strip the length field and the prepended
|
|
|
|
* header from the frame. If you don't want to strip the prepended header, you
|
|
|
|
* could specify <tt>0</tt> for <tt>initialBytesToSkip</tt>.
|
2009-06-18 14:16:25 +02:00
|
|
|
* <pre>
|
2009-09-25 03:39:43 +02:00
|
|
|
* lengthFieldOffset</b> = 1 (= the length of HDR1)
|
|
|
|
* lengthFieldLength</b> = 2
|
2009-06-18 14:16:25 +02:00
|
|
|
* <b>lengthAdjustment</b> = <b>1</b> (= the length of HDR2)
|
|
|
|
* <b>initialBytesToStrip</b> = <b>3</b> (= the length of HDR1 + LEN)
|
|
|
|
*
|
|
|
|
* BEFORE DECODE (16 bytes) AFTER DECODE (13 bytes)
|
|
|
|
* +------+--------+------+----------------+ +------+----------------+
|
|
|
|
* | HDR1 | Length | HDR2 | Actual Content |----->| HDR2 | Actual Content |
|
|
|
|
* | 0xCA | 0x000C | 0xFE | "HELLO, WORLD" | | 0xFE | "HELLO, WORLD" |
|
|
|
|
* +------+--------+------+----------------+ +------+----------------+
|
|
|
|
* </pre>
|
|
|
|
*
|
2009-06-18 14:19:59 +02:00
|
|
|
* <h3>2 bytes length field at offset 1 in the middle of 4 bytes header,
|
2009-06-18 14:16:25 +02:00
|
|
|
* strip the first header field and the length field, the length field
|
2009-09-25 03:39:43 +02:00
|
|
|
* represents the length of the whole message</h3>
|
|
|
|
*
|
|
|
|
* Let's give another twist to the previous example. The only difference from
|
|
|
|
* the previous example is that the length field represents the length of the
|
|
|
|
* whole message instead of the message body, just like the third example.
|
|
|
|
* We have to count the length of HDR1 and Length into <tt>lengthAdjustment</tt>.
|
|
|
|
* Please note that we don't need to take the length of HDR2 into account
|
|
|
|
* because the length field already includes the whole header length.
|
2009-06-18 14:16:25 +02:00
|
|
|
* <pre>
|
2009-09-25 03:39:43 +02:00
|
|
|
* lengthFieldOffset = 1
|
|
|
|
* lengthFieldLength = 2
|
2009-06-18 14:16:25 +02:00
|
|
|
* <b>lengthAdjustment</b> = <b>-3</b> (= the length of HDR1 + LEN, negative)
|
2009-06-18 14:32:22 +02:00
|
|
|
* <b>initialBytesToStrip</b> = <b> 3</b>
|
2009-06-18 14:16:25 +02:00
|
|
|
*
|
|
|
|
* BEFORE DECODE (16 bytes) AFTER DECODE (13 bytes)
|
|
|
|
* +------+--------+------+----------------+ +------+----------------+
|
|
|
|
* | HDR1 | Length | HDR2 | Actual Content |----->| HDR2 | Actual Content |
|
|
|
|
* | 0xCA | 0x0010 | 0xFE | "HELLO, WORLD" | | 0xFE | "HELLO, WORLD" |
|
|
|
|
* +------+--------+------+----------------+ +------+----------------+
|
|
|
|
* </pre>
|
2008-12-17 12:39:45 +01:00
|
|
|
*
|
|
|
|
* @author The Netty Project (netty-dev@lists.jboss.org)
|
2009-10-14 07:46:40 +02:00
|
|
|
* @author Trustin Lee (trustin@gmail.com)
|
2008-12-17 12:39:45 +01:00
|
|
|
*
|
|
|
|
* @version $Rev:231 $, $Date:2008-06-12 16:44:50 +0900 (목, 12 6월 2008) $
|
|
|
|
*
|
2009-06-18 14:16:25 +02:00
|
|
|
* @see LengthFieldPrepender
|
2008-12-17 12:39:45 +01:00
|
|
|
*/
|
|
|
|
public class LengthFieldBasedFrameDecoder extends FrameDecoder {
|
|
|
|
|
|
|
|
private final int maxFrameLength;
|
|
|
|
private final int lengthFieldOffset;
|
2009-01-06 06:59:42 +01:00
|
|
|
private final int lengthFieldLength;
|
2008-12-17 12:39:45 +01:00
|
|
|
private final int lengthFieldEndOffset;
|
|
|
|
private final int lengthAdjustment;
|
2009-01-06 06:59:42 +01:00
|
|
|
private final int initialBytesToStrip;
|
2009-01-06 06:31:59 +01:00
|
|
|
private volatile boolean discardingTooLongFrame;
|
|
|
|
private volatile long tooLongFrameLength;
|
|
|
|
private volatile long bytesToDiscard;
|
2008-12-17 12:39:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new instance.
|
2009-06-18 14:16:25 +02:00
|
|
|
*
|
|
|
|
* @param maxFrameLength
|
|
|
|
* the maximum length of the frame. If the length of the frame is
|
|
|
|
* greater than this value, {@link TooLongFrameException} will be
|
|
|
|
* thrown.
|
|
|
|
* @param lengthFieldOffset
|
|
|
|
* the offset of the length field
|
|
|
|
* @param lengthFieldLength
|
|
|
|
* the length of the length field
|
|
|
|
*
|
2008-12-17 12:39:45 +01:00
|
|
|
*/
|
|
|
|
public LengthFieldBasedFrameDecoder(
|
|
|
|
int maxFrameLength,
|
|
|
|
int lengthFieldOffset, int lengthFieldLength) {
|
2009-01-06 06:59:42 +01:00
|
|
|
this(maxFrameLength, lengthFieldOffset, lengthFieldLength, 0, 0);
|
2008-12-17 12:39:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new instance.
|
2009-06-18 14:16:25 +02:00
|
|
|
*
|
|
|
|
* @param maxFrameLength
|
|
|
|
* the maximum length of the frame. If the length of the frame is
|
|
|
|
* greater than this value, {@link TooLongFrameException} will be
|
|
|
|
* thrown.
|
|
|
|
* @param lengthFieldOffset
|
|
|
|
* the offset of the length field
|
|
|
|
* @param lengthFieldLength
|
|
|
|
* the length of the length field
|
|
|
|
* @param lengthAdjustment
|
|
|
|
* the compensation value to add to the value of the length field
|
|
|
|
* @param initialBytesToStrip
|
|
|
|
* the number of first bytes to strip out from the decoded frame
|
2008-12-17 12:39:45 +01:00
|
|
|
*/
|
|
|
|
public LengthFieldBasedFrameDecoder(
|
|
|
|
int maxFrameLength,
|
2009-01-06 06:59:42 +01:00
|
|
|
int lengthFieldOffset, int lengthFieldLength,
|
|
|
|
int lengthAdjustment, int initialBytesToStrip) {
|
2008-12-17 12:39:45 +01:00
|
|
|
if (maxFrameLength <= 0) {
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
"maxFrameLength must be a positive integer: " +
|
|
|
|
maxFrameLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lengthFieldOffset < 0) {
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
"lengthFieldOffset must be a non-negative integer: " +
|
|
|
|
lengthFieldOffset);
|
|
|
|
}
|
|
|
|
|
2009-01-06 06:59:42 +01:00
|
|
|
if (initialBytesToStrip < 0) {
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
"initialBytesToStrip must be a non-negative integer: " +
|
|
|
|
initialBytesToStrip);
|
|
|
|
}
|
|
|
|
|
2008-12-17 12:39:45 +01:00
|
|
|
if (lengthFieldLength != 1 && lengthFieldLength != 2 &&
|
|
|
|
lengthFieldLength != 3 && lengthFieldLength != 4 &&
|
|
|
|
lengthFieldLength != 8) {
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
"lengthFieldLength must be either 1, 2, 3, 4, or 8: " +
|
|
|
|
lengthFieldLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lengthFieldOffset > maxFrameLength - lengthFieldLength) {
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
"maxFrameLength (" + maxFrameLength + ") " +
|
|
|
|
"must be equal to or greater than " +
|
|
|
|
"lengthFieldOffset (" + lengthFieldOffset + ") + " +
|
|
|
|
"lengthFieldLength (" + lengthFieldLength + ").");
|
|
|
|
}
|
|
|
|
|
|
|
|
this.maxFrameLength = maxFrameLength;
|
|
|
|
this.lengthFieldOffset = lengthFieldOffset;
|
|
|
|
this.lengthFieldLength = lengthFieldLength;
|
|
|
|
this.lengthAdjustment = lengthAdjustment;
|
|
|
|
lengthFieldEndOffset = lengthFieldOffset + lengthFieldLength;
|
2009-01-06 06:59:42 +01:00
|
|
|
this.initialBytesToStrip = initialBytesToStrip;
|
2008-12-17 12:39:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Object decode(
|
|
|
|
ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
|
2009-01-06 06:31:59 +01:00
|
|
|
|
|
|
|
if (discardingTooLongFrame) {
|
|
|
|
long bytesToDiscard = this.bytesToDiscard;
|
|
|
|
int localBytesToDiscard = (int) Math.min(bytesToDiscard, buffer.readableBytes());
|
|
|
|
buffer.skipBytes(localBytesToDiscard);
|
|
|
|
bytesToDiscard -= localBytesToDiscard;
|
|
|
|
this.bytesToDiscard = bytesToDiscard;
|
|
|
|
if (bytesToDiscard == 0) {
|
|
|
|
// Reset to the initial state and tell the handlers that
|
|
|
|
// the frame was too large.
|
|
|
|
discardingTooLongFrame = false;
|
|
|
|
long tooLongFrameLength = this.tooLongFrameLength;
|
|
|
|
this.tooLongFrameLength = 0;
|
|
|
|
throw new TooLongFrameException(
|
|
|
|
"Adjusted frame length exceeds " + maxFrameLength +
|
|
|
|
": " + tooLongFrameLength);
|
|
|
|
} else {
|
|
|
|
// Keep discarding.
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-17 12:39:45 +01:00
|
|
|
if (buffer.readableBytes() < lengthFieldEndOffset) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
int actualLengthFieldOffset = buffer.readerIndex() + lengthFieldOffset;
|
|
|
|
long frameLength;
|
|
|
|
switch (lengthFieldLength) {
|
|
|
|
case 1:
|
|
|
|
frameLength = buffer.getUnsignedByte(actualLengthFieldOffset);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
frameLength = buffer.getUnsignedShort(actualLengthFieldOffset);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
frameLength = buffer.getUnsignedMedium(actualLengthFieldOffset);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
frameLength = buffer.getUnsignedInt(actualLengthFieldOffset);
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
frameLength = buffer.getLong(actualLengthFieldOffset);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new Error("should not reach here");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frameLength < 0) {
|
2009-01-06 06:31:59 +01:00
|
|
|
buffer.skipBytes(lengthFieldEndOffset);
|
2008-12-17 12:39:45 +01:00
|
|
|
throw new CorruptedFrameException(
|
|
|
|
"negative pre-adjustment length field: " + frameLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
frameLength += lengthAdjustment + lengthFieldEndOffset;
|
|
|
|
if (frameLength < lengthFieldEndOffset) {
|
2009-01-06 06:31:59 +01:00
|
|
|
buffer.skipBytes(lengthFieldEndOffset);
|
2008-12-17 12:39:45 +01:00
|
|
|
throw new CorruptedFrameException(
|
2009-01-06 06:59:42 +01:00
|
|
|
"Adjusted frame length (" + frameLength + ") is less " +
|
|
|
|
"than lengthFieldEndOffset: " + lengthFieldEndOffset);
|
2009-01-06 06:32:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frameLength > maxFrameLength) {
|
2009-01-06 06:31:59 +01:00
|
|
|
// Enter the discard mode and discard everything received so far.
|
|
|
|
discardingTooLongFrame = true;
|
|
|
|
tooLongFrameLength = frameLength;
|
|
|
|
bytesToDiscard = frameLength - buffer.readableBytes();
|
|
|
|
buffer.skipBytes(buffer.readableBytes());
|
|
|
|
return null;
|
2008-12-17 12:39:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// never overflows because it's less than maxFrameLength
|
|
|
|
int frameLengthInt = (int) frameLength;
|
|
|
|
if (buffer.readableBytes() < frameLengthInt) {
|
|
|
|
return null;
|
|
|
|
}
|
2009-01-06 06:32:44 +01:00
|
|
|
|
2009-01-06 06:59:42 +01:00
|
|
|
if (initialBytesToStrip > frameLengthInt) {
|
|
|
|
buffer.skipBytes(frameLengthInt);
|
|
|
|
throw new CorruptedFrameException(
|
|
|
|
"Adjusted frame length (" + frameLength + ") is less " +
|
|
|
|
"than initialBytesToStrip: " + initialBytesToStrip);
|
|
|
|
}
|
2009-11-17 16:46:34 +01:00
|
|
|
buffer.skipBytes(initialBytesToStrip);
|
|
|
|
return buffer.readBytes(frameLengthInt - initialBytesToStrip);
|
2008-12-17 12:39:45 +01:00
|
|
|
}
|
|
|
|
}
|