diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-10-09 11:07:32 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-10-09 11:07:32 +0100 |
commit | 7d7ef42995aee8c14cdc2b7c93e7f60c85e69f48 (patch) | |
tree | 3da6360fb34c2f33ee54cc10f880cd7e6caafab4 /src/protocol.h | |
download | OSCDRP-7d7ef42995aee8c14cdc2b7c93e7f60c85e69f48.tar.gz OSCDRP-7d7ef42995aee8c14cdc2b7c93e7f60c85e69f48.tar.bz2 OSCDRP-7d7ef42995aee8c14cdc2b7c93e7f60c85e69f48.zip |
Diffstat (limited to 'src/protocol.h')
-rw-r--r-- | src/protocol.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/protocol.h b/src/protocol.h new file mode 100644 index 0000000..f506d7f --- /dev/null +++ b/src/protocol.h @@ -0,0 +1,35 @@ +#ifndef _PROTOCOL_H_ +#define _PROTOCOL_H_ + +#include <stdlib.h> +#include <stdint.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <time.h> +#include <pthread.h> +#include <assert.h> +#include <errno.h> + +#define PACKET_MAGIC 0xC0C0AF00 + +typedef struct __attribute__((packed)) +{ + uint64_t checksum; + uint64_t magic; + uint64_t id; + uint64_t type; + uint64_t data_size; + uint8_t* data; +} Packet_t; + +#include <utils.h> + +Packet_t* generate_packet(uint64_t type, const uint8_t* data, uint64_t data_size); +int handle_packet(const Packet_t* packet); +int is_packet_valid(const Packet_t* packet); +uint64_t get_packet_checksum(const Packet_t* packet); +size_t get_packet_size_without_data(); +void print_packet(const Packet_t* packet); + +#endif |