cprrt.pxd 3.52 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

14
cdef extern from "proto/vdmcode/block_code.h":
15
16
17
18
19
    cdef struct prrtCoder:
        pass

    ctypedef prrtCoder PrrtCoder

20
cdef extern from "proto/channelStateInformation.h":
Andreas Schmidt's avatar
Andreas Schmidt committed
21
22
23
24
25
    cdef struct prrtChannelStateInformation:
        pass

    ctypedef prrtChannelStateInformation PrrtChannelStateInformation

26
cdef extern from "proto/codingParams.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)

54
cdef extern from "proto/block.h":
55
56
57
58
59
    cdef struct prrtBlock:
        uint32_t data_count
        uint32_t redundancy_count
        PrrtCodingParams coding_params
        uint32_t largest_data_length
60
        uint16_t baseSequenceNumber
61
62
63
64
65
66
        List* data_blocks
        List* redundancy_blocks
        uint8_t is_coded

    ctypedef prrtBlock PrrtBlock

67
cdef extern from "proto/packet.h":
68
69
70
    cdef struct prrtPacket:
        uint8_t type_priority;
        uint8_t index;
71
        uint16_t sequenceNumber;
72
        void* payload;
73
        uint32_t payloadLength;
74
75
76

    ctypedef prrtPacket PrrtPacket

77
cdef extern from "proto/receiver.h":
78
79
80
81
    ctypedef struct PrrtReceiver:
        const char* host_name
        uint16_t port

Andreas Schmidt's avatar
Andreas Schmidt committed
82
83
84
85
    PrrtReceiver* PrrtReceiver_create(const char *host, uint16_t port)
    bint PrrtReceiver_destroy(PrrtReceiver* receiver)


86
cdef extern from "proto/socket.h":
87
88
89
90
91
    cdef struct prrtSocket:
        int dataSocketFd
        int feedbackSocketFd
        pthread_t receiveFeedbackThread

Andreas Schmidt's avatar
Andreas Schmidt committed
92
        pthread_t sendDataThread
93
94
95
96
97
98
99
100
101
102
103
        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

104
105
        List* receivers

106
107
108
109
110
111
112
113
        uint16_t packetsCount
        uint16_t sequenceNumberSource
        uint16_t sequenceNumberRepetition
        uint16_t sequenceNumberRedundancy
        uint16_t sequenceNumberFeedback

    ctypedef prrtSocket PrrtSocket

114
    cdef PrrtSocket* PrrtSocket_create(bint isSender)
Andreas Schmidt's avatar
Andreas Schmidt committed
115
    bint PrrtSocket_bind(PrrtSocket *sock_ptr, const_char *ipAddress, const uint16_t port)
Andreas Schmidt's avatar
Andreas Schmidt committed
116
117
118
    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
119
    int32_t PrrtSocket_recv(PrrtSocket *sock_ptr, void *buf_ptr) nogil
120

Andreas Schmidt's avatar
Andreas Schmidt committed
121
cdef extern from "util/bptree.h":
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);