cprrt.pxd 5.33 KB
Newer Older
1
2
include "posix/time.pxd"

Andreas Schmidt's avatar
Andreas Schmidt committed
3
from libc.stdint cimport uint32_t, uint16_t, uint8_t, int32_t
Andreas Schmidt's avatar
Andreas Schmidt committed
4
from libc.string cimport const_char
5
6
7
8
9
10
11
12
13
14
15

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

    ctypedef struct pthread_mutex_t:
        pass

    ctypedef struct pthread_cond_t:
        pass

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

    ctypedef prrtCoder PrrtCoder

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

    ctypedef prrtChannelStateInformation PrrtChannelStateInformation

28
cdef extern from "proto/codingParams.h":
29
30
31
32
33
34
    ctypedef struct prrtCodingParams:
        uint8_t k
        uint8_t r
        uint8_t n
        uint8_t c
        uint8_t *n_cycle
35
36

    ctypedef prrtCodingParams PrrtCodingParams
37
38
39
40
    PrrtCodingParams *PrrtCodingParams_create()
    PrrtCodingParams *PrrtCodingParams_copy(PrrtCodingParams *cpar)
    bint PrrtCodingParams_update(PrrtCodingParams *cpar, uint8_t k, uint8_t n)
    bint PrrtCodingParams_destroy(PrrtCodingParams *cpar)
41

Andreas Schmidt's avatar
Andreas Schmidt committed
42
cdef extern from "util/list.h":
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    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)

61
cdef extern from "proto/block.h":
62
63
64
65
66
    cdef struct prrtBlock:
        uint32_t data_count
        uint32_t redundancy_count
        PrrtCodingParams coding_params
        uint32_t largest_data_length
67
        uint16_t baseSequenceNumber
68
69
70
71
72
73
        List* data_blocks
        List* redundancy_blocks
        uint8_t is_coded

    ctypedef prrtBlock PrrtBlock

74
cdef extern from "proto/packet.h":
75
76
77
    cdef struct prrtPacket:
        uint8_t type_priority;
        uint8_t index;
78
        uint16_t sequenceNumber;
79
        void* payload;
80
        uint32_t payloadLength;
81
82
83

    ctypedef prrtPacket PrrtPacket

84
85
    ctypedef uint32_t prrtTimedelta_t;

86
cdef extern from "proto/receiver.h":
87
88
89
90
    ctypedef struct PrrtReceiver:
        const char* host_name
        uint16_t port

Andreas Schmidt's avatar
Andreas Schmidt committed
91
92
93
94
    PrrtReceiver* PrrtReceiver_create(const char *host, uint16_t port)
    bint PrrtReceiver_destroy(PrrtReceiver* receiver)


95
cdef extern from "proto/socket.h":
96
97
98
99
100
    cdef struct prrtSocket:
        int dataSocketFd
        int feedbackSocketFd
        pthread_t receiveFeedbackThread

Andreas Schmidt's avatar
Andreas Schmidt committed
101
        pthread_t sendDataThread
102
103
        pthread_mutex_t outQueueFilledMutex
        pthread_cond_t outQueueFilledCv
Andreas Schmidt's avatar
Andreas Schmidt committed
104
        MPSCQueue* sendDataQueue
105
106
107
108

        pthread_t receiveDataThread
        pthread_mutex_t inQueueFilledMutex
        pthread_cond_t inQueueFilledMutexCv
109
        PrrtReceiveDataQueue *receiveDataQueue
110
111
112

        BPTreeNode* dataStore

113
        PrrtReceiver* receiver
114

115
116
117
118
119
120
121
122
        uint16_t packetsCount
        uint16_t sequenceNumberSource
        uint16_t sequenceNumberRepetition
        uint16_t sequenceNumberRedundancy
        uint16_t sequenceNumberFeedback

    ctypedef prrtSocket PrrtSocket

123
    cdef PrrtSocket* PrrtSocket_create(bint isSender, const uint32_t target_delay)
Andreas Schmidt's avatar
Andreas Schmidt committed
124
    bint PrrtSocket_bind(PrrtSocket *sock_ptr, const_char *ipAddress, const uint16_t port)
Andreas Schmidt's avatar
Andreas Schmidt committed
125
126
127
    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)
128

Andreas Schmidt's avatar
Andreas Schmidt committed
129
    int32_t PrrtSocket_recv(PrrtSocket *sock_ptr, void *buf_ptr) nogil
130
131
132
133
134
135
136
137
    int32_t PrrtSocket_receive_asap(PrrtSocket *s, void *buf_ptr) nogil
    int32_t PrrtSocket_receive_asap_wait(PrrtSocket *s, void *buf_ptr) nogil
    int32_t PrrtSocket_receive_asap_timedwait(PrrtSocket *s, void *buf_ptr, timespec* deadline) nogil

    int32_t PrrtSocket_receive_ordered(PrrtSocket *s, void *buf_ptr, prrtTimedelta_t time_window_us) nogil
    int32_t PrrtSocket_receive_ordered_wait(PrrtSocket *s, void *buf_ptr, prrtTimedelta_t time_window_us) nogil
    int32_t PrrtSocket_receive_ordered_timedwait(PrrtSocket *s, void *buf_ptr, prrtTimedelta_t time_window_us, timespec* deadline) nogil

Andreas Schmidt's avatar
Andreas Schmidt committed
138
    bint PrrtSocket_set_sock_opt(PrrtSocket *sock_ptr, const_char *name, const uint32_t value)
139
    uint32_t PrrtSocket_get_sock_opt(PrrtSocket *sock_ptr, const_char *name)
140
141
142
    bint PrrtSocket_set_coding_parameters(PrrtSocket *s, uint8_t k, uint8_t n)
    PrrtCodingParams *PrrtSocket_get_coding_parameters(PrrtSocket *s)
    bint PrrtSocket_uses_thread_pinning(PrrtSocket *socket)
143
    uint32_t PrrtSocket_get_rtprop(PrrtSocket *socket)
144

145
146
147
148
    bint PrrtSocket_uses_thread_pinning(PrrtSocket *socket)
    bint PrrtSocket_enable_thread_pinning(PrrtSocket *socket)


149
150
151
152
153

cdef extern from "proto/stores/receiveDataQueue.h":
    ctypedef struct PrrtReceiveDataQueue:
        pass

Andreas Schmidt's avatar
Andreas Schmidt committed
154
cdef extern from "util/bptree.h":
155
156
157
158
159
160
161
162
    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);
163
164
165
166


cdef extern from "util/pipe.h":
    ctypedef struct Pipe:
167
        pass
Andreas Schmidt's avatar
Andreas Schmidt committed
168
169
170
171

cdef extern from "util/mpsc_queue.h":
    ctypedef struct MPSCQueue:
        pass