Package org.onlab.packet
Class PacketUtils
- java.lang.Object
-
- org.onlab.packet.PacketUtils
-
public final class PacketUtils extends java.lang.Object
Utilities for working with packet headers.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkBufferLength(int byteLength, int offset, int length)
Check the length of the input buffer is appropriate given the offset and length parameters.static void
checkHeaderLength(int givenLength, int requiredLength)
Check that there are enough bytes in the buffer to read some number of bytes that we need to read a full header.static void
checkInput(byte[] data, int offset, int length, int requiredLength)
Check the input parameters are sane and there's enough bytes to read the required length.
-
-
-
Method Detail
-
checkBufferLength
public static void checkBufferLength(int byteLength, int offset, int length) throws DeserializationException
Check the length of the input buffer is appropriate given the offset and length parameters.- Parameters:
byteLength
- length of the input buffer arrayoffset
- offset given to begin reading bytes fromlength
- length given to read up until- Throws:
DeserializationException
- if the input parameters don't match up (i.e we can't read that many bytes from the buffer at the given offest)
-
checkHeaderLength
public static void checkHeaderLength(int givenLength, int requiredLength) throws DeserializationException
Check that there are enough bytes in the buffer to read some number of bytes that we need to read a full header.- Parameters:
givenLength
- given size of the bufferrequiredLength
- number of bytes we need to read some header fully- Throws:
DeserializationException
- if there aren't enough bytes
-
checkInput
public static void checkInput(byte[] data, int offset, int length, int requiredLength) throws DeserializationException
Check the input parameters are sane and there's enough bytes to read the required length.- Parameters:
data
- input byte bufferoffset
- offset of the start of the headerlength
- length given to deserialize the headerrequiredLength
- length needed to deserialize header- Throws:
DeserializationException
- if we're unable to deserialize the packet based on the input parameters
-
-