LeiaSR SDK 720218b2 v1.32.7.6322 2025-02-13T14:55:38Z
Stable
packet.h
Go to the documentation of this file.
1
5#pragma once
6#include <stdint.h>
7#include <iostream>
8#include <iomanip>
9
10#define SR_packet_sizeOffset 0
11#define SR_packet_destinationOffset (sizeof(SR_packet::size))
12#define SR_packet_payloadOffset (sizeof(SR_packet::size) + sizeof(SR_packet::destination))
13#define SR_packet_headerSize SR_packet_payloadOffset
14
20typedef struct {
21 uint64_t size;
22 uint64_t destination;
23 uint64_t payload;
24} SR_packet;
25
31static void SR_packet_print(SR_packet& packet) {
32 uint64_t frameSize = packet.size - SR_packet_payloadOffset;
33 std::cout << "SR_packet {\n"
34 << "\tsize: " << packet.size << "\n"
35 << "\tdestination: " << packet.destination << "\n"
36 << "\tpayload: "
37 << std::setfill('0') << std::hex;
38 for (uint64_t i = frameSize; i > 0; --i) {
39 std::cout << std::setw(2) << (int)(((uint8_t*)&packet.payload)[i - 1]) << " ";
40 }
41 std::cout << std::dec << std::endl;
42}
#define SR_packet_payloadOffset
Definition: packet.h:12
static void SR_packet_print(SR_packet &packet)
Print raw contents of SR network packet.
Definition: packet.h:31
C-compatible struct for communication between SR applications.
Definition: packet.h:20
uint64_t destination
Definition: packet.h:22
uint64_t payload
Start of binary payload data.
Definition: packet.h:23
uint64_t size
Definition: packet.h:21