packet.h 1.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#ifndef PRRT_FRAME_H
#define PRRT_FRAME_H

#include <stdint.h>

#define PACKET_TYPE_SOURCE 0
#define PACKET_TYPE_REPETITION 1
#define PACKET_TYPE_PARITY 2
#define PACKET_TYPE_FEEDBACK 3

11
#define PRRT_PACKET_GENERAL_HEADER_SIZE 4
12
13
14
15
16
17
18
19
typedef struct {
    uint8_t type_priority;
    uint8_t index;
    uint16_t seqno;
    void* payload;
    uint32_t payload_len;
} prrt_packet;

20
#define PRRT_PACKET_SOURCE_HEADER_SIZE 12
21
22
23
24
25
26
27
28
29
30
31
typedef struct {
    uint32_t timestamp;
    uint16_t rtt;
    uint16_t packet_timeout;
    uint16_t decoding_timeout;
    uint16_t feedback_timer;
} prrt_packet_source_payload;

uint8_t packet_type(prrt_packet *packet_ptr);
uint8_t packet_priority(prrt_packet *packet_ptr);
uint16_t packet_size(prrt_packet *packet_ptr);
32
int print_packet(prrt_packet *packet_ptr);
33
34
35

int create_packet_source(prrt_packet *packet_ptr, uint8_t priority, const void * data_ptr, unsigned long data_len);
int encode_packet_source(void* buf_ptr, uint16_t buf_size, prrt_packet *packet_ptr);
36
int decode_packet_source(void* buf_ptr, uint16_t buf_size, prrt_packet *packet_ptr);
37
38
39
40
41
42

int create_packet_repetition(prrt_packet packet, uint8_t priority);
int create_packet_parity(prrt_packet packet, uint8_t priority);
int create_packet_feedback(prrt_packet packet, uint8_t priority);

#endif //PRRT_FRAME_H