-
Notifications
You must be signed in to change notification settings - Fork 4
/
mpsock_buffer.h
60 lines (48 loc) · 1.38 KB
/
mpsock_buffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Multipath Multi-source HTTP (mHTTP)
*
* Developers: Juhoon Kim ([email protected]), Karl Fischer
*
*/
#ifndef __MPSOCK_BUFFER_H__
#define __MPSOCK_BUFFER_H__
#include "libmpsocket.h"
#include "mpsock_pool.h"
/*
* ringbuffer for chunk memory.
* This is works, as long as we have sequential requests with wget
* Later in Browser with parallel requests, we need another structure
*/
typedef struct mpsock_buffer
{
/* buffer pointers */
void *buffer_start;
void *buffer_end;
/* first element in buffer */
void *head;
/* last element in buffer */
void *tail;
/* free chunk structure list */
struct mpsock_chunk *free_chunk_structures;
} mpsock_buffer;
/*
* method that creates a ringbuffer of given size
*/
mpsock_buffer *create_buffer(size_t size);
/*
* store given data into given buffer with given offset
*/
void store_in_buffer(mpsock_buffer *buffer, void *dst, const void *orig, size_t offset, size_t len);
/*
* reads specified data from buffer with offset to given destination
*/
void read_from_buffer(mpsock_buffer *buffer, void *dst, void *orig, size_t offset, size_t len);
/*
* returns a chunk structure with given size allocated buffer memory
*/
struct mpsock_chunk *allocate_chunk_in_buffer(mpsock_buffer *buffer, size_t start_byte, size_t size);
/*
* frees the given chunk
*/
void free_chunk_in_buffer(mpsock_buffer *buffer, struct mpsock_chunk *chunk);
#endif