Fragment now implements new version

This commit is contained in:
Frederick F. Kautz IV 2015-03-05 20:56:02 -08:00
parent 665af44c70
commit 1186c47603
2 changed files with 16 additions and 40 deletions

View File

@ -30,20 +30,17 @@ import (
DONUT v1 Spec
**********************
BlockStart [4]byte // Magic="MINI"=1229867341
VersionMajor uint16
VersionMinor uint16
VersionPatch uint16
VersionReserved uint16
BlockStart uint32 // Magic="MINI"=1229867341
VersionMajor uint32
Reserved uint64
DataLen uint64
HeaderCrc32c uint32
BlockData [4]byte // Magic="DATA"=1096040772
BlockData uint32 // Magic="DATA"=1096040772
Data io.Reader // matches length
HeaderCrc32c uint32
DataSha512 [64]byte
BlockLen uint64 // length of entire frame, inclusive of MINI and INIM
BlockEnd [4]byte // Magic="INIM"=1296649801
BlockEnd uint32 // Magic="INIM"=1296649801
*/
@ -55,10 +52,7 @@ var (
type DonutFrameHeader struct {
MagicMINI uint32
VersionMajor uint16
VersionMinor uint16
VersionPatch uint16
VersionReserved uint16
Version uint32
Reserved uint64
DataLength uint64
}
@ -78,10 +72,7 @@ func WriteFrame(target io.Writer, reader io.Reader, length uint64) error {
// write header
header := DonutFrameHeader{
MagicMINI: MagicMINI,
VersionMajor: 1,
VersionMinor: 0,
VersionPatch: 0,
VersionReserved: 0,
Version: 1,
Reserved: 0,
DataLength: length,
}

View File

@ -45,7 +45,7 @@ func (s *MySuite) TestSingleWrite(c *C) {
testBufferLength := uint64(testBuffer.Len())
// we test our crc here too
headerBytes := testBuffer.Bytes()[0:28]
headerBytes := testBuffer.Bytes()[:24]
expectedCrc := crc32c.Sum32(headerBytes)
// magic mini
@ -54,24 +54,9 @@ func (s *MySuite) TestSingleWrite(c *C) {
c.Assert(magicMini, DeepEquals, []byte{'M', 'I', 'N', 'I'})
// major version
majorVersion := make([]byte, 2)
testBuffer.Read(majorVersion)
c.Assert(binary.LittleEndian.Uint16(majorVersion), DeepEquals, uint16(1))
// minor version
minorVersion := make([]byte, 2)
testBuffer.Read(minorVersion)
c.Assert(binary.LittleEndian.Uint16(minorVersion), DeepEquals, uint16(0))
// patch version
patchVersion := make([]byte, 2)
testBuffer.Read(patchVersion)
c.Assert(binary.LittleEndian.Uint16(patchVersion), DeepEquals, uint16(0))
// reserved version
reservedVersion := make([]byte, 2)
testBuffer.Read(reservedVersion)
c.Assert(binary.LittleEndian.Uint16(reservedVersion), DeepEquals, uint16(0))
version := make([]byte, 4)
testBuffer.Read(version)
c.Assert(binary.LittleEndian.Uint32(version), DeepEquals, uint32(1))
// reserved
reserved := make([]byte, 8)