[Yunq] Check identify byte and ensure users check status code.
This commit is contained in:
parent
7d9f9a7ae9
commit
3eba0bd9d8
21 changed files with 142 additions and 67 deletions
|
|
@ -1,9 +1,16 @@
|
|||
#include "serialize.h"
|
||||
|
||||
namespace yunq {
|
||||
namespace {
|
||||
|
||||
glcr::Status CheckHeader(const glcr::ByteBuffer& buffer) {
|
||||
// TODO: Check ident.
|
||||
const uint64_t kIdentByte = 0x33441122;
|
||||
|
||||
} // namespace
|
||||
|
||||
glcr::Status CheckHeader(const glcr::ByteBuffer& buffer, uint64_t offset) {
|
||||
if (buffer.At<uint32_t>(offset + 0) != kIdentByte) {
|
||||
return glcr::InvalidArgument("Trying to parse an invalid yunq message.");
|
||||
}
|
||||
// TODO: Parse core size.
|
||||
// TODO: Parse extension size.
|
||||
// TODO: Check CRC32
|
||||
|
|
@ -13,8 +20,7 @@ glcr::Status CheckHeader(const glcr::ByteBuffer& buffer) {
|
|||
|
||||
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size,
|
||||
uint32_t extension_size) {
|
||||
bytes.WriteAt<uint32_t>(
|
||||
offset + 0, 0xDEADBEEF); // TODO: Chose a more unique ident sequence.
|
||||
bytes.WriteAt<uint32_t>(offset + 0, kIdentByte);
|
||||
bytes.WriteAt<uint32_t>(offset + 4, core_size);
|
||||
bytes.WriteAt<uint32_t>(offset + 8, extension_size);
|
||||
bytes.WriteAt<uint32_t>(offset + 12, 0); // TODO: Calculate CRC32.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue