cprrt.pxd 5.79 KB
Newer Older
1
include "posix/time.pxd"
2
include "sockets.pxd"
3

Andreas Schmidt's avatar
Andreas Schmidt committed
4
from libc.stdint cimport uint32_t, uint16_t, uint8_t, int32_t
Andreas Schmidt's avatar
Andreas Schmidt committed
5
from libc.string cimport const_char
6

7

8
9
10
11
12
13
14
15
16
17
cdef extern from "pthread.h" nogil:
    ctypedef struct pthread_t:
        pass

    ctypedef struct pthread_mutex_t:
        pass

    ctypedef struct pthread_cond_t:
        pass

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

    ctypedef prrtCoder PrrtCoder

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

    ctypedef prrtChannelStateInformation PrrtChannelStateInformation

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

38
39
40
41
    ctypedef prrtCodingConfiguration PrrtCodingConfiguration
    PrrtCodingConfiguration *PrrtCodingConfiguration_create()
    PrrtCodingConfiguration *PrrtCodingConfiguration_copy(PrrtCodingConfiguration *cpar)
    bint PrrtCodingConfiguration_destroy(PrrtCodingConfiguration *cpar)
42

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

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

    ctypedef prrtBlock PrrtBlock

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

    ctypedef prrtPacket PrrtPacket

85
86
    ctypedef uint32_t prrtTimedelta_t;

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

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


96
cdef extern from "proto/socket.h":
97
    cdef struct prrtSocket:
Andreas Schmidt's avatar
Andreas Schmidt committed
98
        int socketFd
99

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

        pthread_t receiveDataThread
        pthread_mutex_t inQueueFilledMutex
        pthread_cond_t inQueueFilledMutexCv
108
        PrrtPacketDeliveryStore *packetDeliveryStore
109
110
111

        BPTreeNode* dataStore

112
        PrrtReceiver* receiver
113

114
115
116
117
118
119
120
121
        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
122
    cdef PrrtSocket* PrrtSocket_create(const uint32_t target_delay)
Andreas Schmidt's avatar
Andreas Schmidt committed
123
    bint PrrtSocket_bind(PrrtSocket *sock_ptr, const_char *ipAddress, const uint16_t port)
Andreas Schmidt's avatar
Andreas Schmidt committed
124
125
126
    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)
127

128
129
130
131
    int32_t PrrtSocket_recv(PrrtSocket *sock_ptr, void *buf_ptr, sockaddr* addr) nogil
    int32_t PrrtSocket_receive_asap(PrrtSocket *s, void *buf_ptr, sockaddr* addr) nogil
    int32_t PrrtSocket_receive_asap_wait(PrrtSocket *s, void *buf_ptr, sockaddr* addr) nogil
    int32_t PrrtSocket_receive_asap_timedwait(PrrtSocket *s, void *buf_ptr, sockaddr* addr, timespec* deadline) nogil
132

133
134
135
    int32_t PrrtSocket_receive_ordered(PrrtSocket *s, void *buf_ptr, sockaddr* addr, prrtTimedelta_t time_window_us) nogil
    int32_t PrrtSocket_receive_ordered_wait(PrrtSocket *s, void *buf_ptr, sockaddr* addr, prrtTimedelta_t time_window_us) nogil
    int32_t PrrtSocket_receive_ordered_timedwait(PrrtSocket *s, void *buf_ptr, sockaddr* addr, prrtTimedelta_t time_window_us, timespec* deadline) nogil
136

Andreas Schmidt's avatar
Andreas Schmidt committed
137
    bint PrrtSocket_set_sock_opt(PrrtSocket *sock_ptr, const_char *name, const uint32_t value)
138
    uint32_t PrrtSocket_get_sock_opt(PrrtSocket *sock_ptr, const_char *name)
rna's avatar
rna committed
139
    bint PrrtSocket_set_coding_parameters(PrrtSocket *s, uint8_t k, uint8_t n, uint8_t c, uint8_t *n_cycle)
140
    PrrtCodingConfiguration *PrrtSocket_get_coding_parameters(PrrtSocket *s)
141
    bint PrrtSocket_uses_thread_pinning(PrrtSocket *socket)
142

143
    bint PrrtSocket_uses_thread_pinning(PrrtSocket *socket)
Andreas Schmidt's avatar
Andreas Schmidt committed
144
145
146
147
148
149
150
    uint32_t PrrtSocket_get_rtprop_fwd(PrrtSocket *socket)
    float PrrtSocket_get_plr_fwd(PrrtSocket *socket)
    uint32_t PrrtSocket_get_delivery_rate_fwd(PrrtSocket *socket)

    uint32_t PrrtSocket_get_btlbw_fwd(PrrtSocket *s);
    uint32_t PrrtSocket_get_btlbw_back(PrrtSocket *s);

151
    bint PrrtSocket_get_app_limited(PrrtSocket *socket)
152
153
    bint PrrtSocket_enable_thread_pinning(PrrtSocket *socket)

154
155
156
    char *PrrtSocket_inet_ntoa(in_addr*)
    uint16_t PrrtSocket_ntohs(uint16_t v)

157
158
cdef extern from "proto/stores/packetDeliveryStore.h":
    ctypedef struct PrrtPacketDeliveryStore:
159
160
        pass

Andreas Schmidt's avatar
Andreas Schmidt committed
161
cdef extern from "util/bptree.h":
162
163
164
165
166
167
168
169
    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);
170
171
172
173


cdef extern from "util/pipe.h":
    ctypedef struct Pipe:
174
        pass
Andreas Schmidt's avatar
Andreas Schmidt committed
175
176
177
178

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