cprrt.pxd 3.47 KB
Newer Older
Andreas Schmidt's avatar
Andreas Schmidt committed
1
from libc.stdint cimport uint32_t, uint16_t, uint8_t, int32_t
Andreas Schmidt's avatar
Andreas Schmidt committed
2
from libc.string cimport const_char
3
4
5
6
7
8
9
10
11
12
13

cdef extern from "pthread.h" nogil:
    ctypedef struct pthread_t:
        pass

    ctypedef struct pthread_mutex_t:
        pass

    ctypedef struct pthread_cond_t:
        pass

Andreas Schmidt's avatar
Andreas Schmidt committed
14
cdef extern from "prrt/stores/forward_packet_table.h":
15
16
17
18
19
    cdef struct prrtForwardPacketTable:
        pass

    ctypedef prrtForwardPacketTable PrrtForwardPacketTable

Andreas Schmidt's avatar
Andreas Schmidt committed
20
cdef extern from "prrt/vdmcode/block_code.h":
21
22
23
24
25
    cdef struct prrtCoder:
        pass

    ctypedef prrtCoder PrrtCoder

Andreas Schmidt's avatar
Andreas Schmidt committed
26
cdef extern from "prrt/coding_params.h":
27
28
29
30
31
32
33
34
    cdef struct prrtCodingParams:
        uint8_t k;
        uint8_t r;
        uint8_t n;
        uint8_t n_p;

    ctypedef prrtCodingParams PrrtCodingParams

Andreas Schmidt's avatar
Andreas Schmidt committed
35
cdef extern from "util/list.h":
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    cdef struct list:
        pass

    ctypedef list List

    cdef struct listNode:
        pass

    ctypedef listNode ListNode

    void List_push(List *list, const void *value)
    void *List_pop(const List *list)

    void List_unshift(List *list, const void *value)
    void *List_shift(const List *list)

    void *List_remove(List *list, const ListNode *node)

Andreas Schmidt's avatar
Andreas Schmidt committed
54
cdef extern from "prrt/block.h":
55
56
57
58
59
60
61
62
63
64
65
66
    cdef struct prrtBlock:
        uint32_t data_count
        uint32_t redundancy_count
        PrrtCodingParams coding_params
        uint32_t largest_data_length
        uint16_t base_seqno
        List* data_blocks
        List* redundancy_blocks
        uint8_t is_coded

    ctypedef prrtBlock PrrtBlock

Andreas Schmidt's avatar
Andreas Schmidt committed
67
cdef extern from "prrt/packet.h":
68
69
70
71
72
73
74
75
76
    cdef struct prrtPacket:
        uint8_t type_priority;
        uint8_t index;
        uint16_t seqno;
        void* payload;
        uint32_t payload_len;

    ctypedef prrtPacket PrrtPacket

Andreas Schmidt's avatar
Andreas Schmidt committed
77
cdef extern from "prrt/socket.h":
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
    ctypedef struct PrrtReceiver:
        const char* host_name
        uint16_t port

    cdef struct prrtSocket:
        int dataSocketFd
        int feedbackSocketFd
        pthread_t receiveFeedbackThread

        pthread_t sendThread
        pthread_mutex_t outQueueFilledMutex
        pthread_cond_t outQueueFilledCv
        List* outQueue

        pthread_t receiveDataThread
        pthread_mutex_t inQueueFilledMutex
        pthread_cond_t inQueueFilledMutexCv
        List *inQueue

        BPTreeNode* dataStore

        BPTreeNode* blockStore

        PrrtForwardPacketTable* forwardPacketTable

        PrrtReceiver receivers[10]
        int receiverLength
        uint16_t packetsCount
        uint16_t sequenceNumberSource
        uint16_t sequenceNumberRepetition
        uint16_t sequenceNumberRedundancy
        uint16_t sequenceNumberFeedback

    ctypedef prrtSocket PrrtSocket

Andreas Schmidt's avatar
Andreas Schmidt committed
113
114
115
116
    cdef PrrtSocket* PrrtSocket_create(uint16_t port, uint8_t is_sender)
    int PrrtSocket_close(const PrrtSocket *sock_ptr)
    int PrrtSocket_connect(PrrtSocket *sock_ptr, const_char *host, const uint16_t port)
    int PrrtSocket_send(PrrtSocket *sock_ptr, const uint8_t *data, const size_t data_len)
Andreas Schmidt's avatar
Andreas Schmidt committed
117
    int32_t PrrtSocket_recv(PrrtSocket *sock_ptr, void *buf_ptr) nogil
Andreas Schmidt's avatar
Andreas Schmidt committed
118
    PrrtPacket *PrrtSocket_recv_feedback(const PrrtSocket *sock_ptr, void *bufin, const size_t length)
119

Andreas Schmidt's avatar
Andreas Schmidt committed
120
cdef extern from "util/bptree.h":
121
122
123
124
125
126
127
128
129
    ctypedef struct BPTreeNode:
        pass

    BPTreeNode *BPTree_insert(BPTreeNode *root, int key, void *value);
    BPTreeNode *BPTree_delete(BPTreeNode *root, int key);
    BPTreeNode *BPTree_destroy(BPTreeNode *root);
    void *BPTree_get(BPTreeNode *root, int key);
    void BPTree_get_range(BPTreeNode *root, List *list, int key_start, int key_end);