ParseSyncHeader checks for the SYNC magic and the given messagemagic and then returns the remainingBytes starting after the messagemagic so after 16 bytes, the clockRef, correlationID and an error is the packet is not SYNC or if the messagemagic is wrong
(data []byte, messagemagic uint32)
| 16 | //the remainingBytes starting after the messagemagic so after 16 bytes, the clockRef, correlationID and an error |
| 17 | //is the packet is not SYNC or if the messagemagic is wrong |
| 18 | func ParseSyncHeader(data []byte, messagemagic uint32) ([]byte, CFTypeID, uint64, error) { |
| 19 | remainingBytes, clockRef, err := parseHeader(data, SyncPacketMagic, messagemagic) |
| 20 | if err != nil { |
| 21 | return data, 0, 0, err |
| 22 | } |
| 23 | correlationID := binary.LittleEndian.Uint64(remainingBytes) |
| 24 | return remainingBytes[8:], clockRef, correlationID, err |
| 25 | } |
| 26 | |
| 27 | func parseHeader(data []byte, packetmagic uint32, messagemagic uint32) ([]byte, CFTypeID, error) { |
| 28 | magic := binary.LittleEndian.Uint32(data) |