* @return the object representations of the DTLS records
*/
public static List<Record> fromByteArray(byte[] byteArray) {
List<Record> records = new ArrayList<Record>();
DatagramReader reader = new DatagramReader(byteArray);
while (reader.bytesAvailable()) {
int type = reader.read(CONTENT_TYPE_BITS);
ContentType contentType = ContentType.getTypeByValue(type);
if (contentType==null) {
LOGGER.warning(String.format("Received illegal record content type: %s", type));
break;
}
int major = reader.read(VERSION_BITS);
int minor = reader.read(VERSION_BITS);
ProtocolVersion version = new ProtocolVersion(major, minor);
int epoch = reader.read(EPOCH_BITS);
long sequenceNumber = reader.readLong(SEQUENCE_NUMBER_BITS);
int length = reader.read(LENGTH_BITS);
// delay decryption/interpretation of fragment
byte[] fragmentBytes = reader.readBytes(length);
records.add(new Record(contentType, version, epoch, sequenceNumber, length, fragmentBytes));
}
return records;