tor_multipath_voip/src/utils.h

29 lines
762 B
C
Raw Normal View History

2019-02-12 10:17:37 +00:00
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
2019-02-13 13:17:06 +00:00
// 1500 = internet MTU
2019-02-14 10:16:38 +00:00
#define RING_BUFFER_SIZE 1500*10
2019-02-12 10:17:37 +00:00
struct ring_buffer {
char buffer[RING_BUFFER_SIZE];
int head;
int tail;
};
int ring_buffer_read(struct ring_buffer* rb, char* dest, int size);
void ring_buffer_ack_read(struct ring_buffer* rb, int size);
int ring_buffer_write(struct ring_buffer* rb, char* source, int size);
int ring_buffer_free_space(struct ring_buffer* rb);
int ring_buffer_used_space(struct ring_buffer* rb);
2019-03-18 16:58:40 +00:00
int ring_gt(uint16_t v1, uint16_t v2);
int ring_ge(uint16_t v1, uint16_t v2);
int ring_lt(uint16_t v1, uint16_t v2);
int ring_le(uint16_t v1, uint16_t v2);
2019-04-01 17:27:40 +00:00
uint64_t elapsed_micros(struct timespec* t1, struct timespec* t2);
2019-05-07 17:18:27 +00:00