diff options
author | Bart Polot <bart@net.in.tum.de> | 2016-09-20 01:21:59 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2016-09-20 01:21:59 +0000 |
commit | b4d5f474eef10017a470dccb01dae86c32bd5ddb (patch) | |
tree | 4b97bb46f4ab15c732e284ef0b275cc0dbc3173a /src/cadet/gnunet-service-cadet_peer.h | |
parent | 506899aa2be2b4d5dc09c1740969c28ddf43c82d (diff) | |
download | gnunet-b4d5f474eef10017a470dccb01dae86c32bd5ddb.tar.gz gnunet-b4d5f474eef10017a470dccb01dae86c32bd5ddb.zip |
Port CADET to CORE MQ API
Diffstat (limited to 'src/cadet/gnunet-service-cadet_peer.h')
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.h | 108 |
1 files changed, 26 insertions, 82 deletions
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h index 950c68fb6..093cfa21a 100644 --- a/src/cadet/gnunet-service-cadet_peer.h +++ b/src/cadet/gnunet-service-cadet_peer.h | |||
@@ -47,7 +47,7 @@ extern "C" | |||
47 | struct CadetPeer; | 47 | struct CadetPeer; |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Struct containing info about a queued transmission to this peer | 50 | * Handle to queued messages on a peer level. |
51 | */ | 51 | */ |
52 | struct CadetPeerQueue; | 52 | struct CadetPeerQueue; |
53 | 53 | ||
@@ -59,18 +59,19 @@ struct CadetPeerQueue; | |||
59 | * | 59 | * |
60 | * @param cls Closure. | 60 | * @param cls Closure. |
61 | * @param c Connection this message was on. | 61 | * @param c Connection this message was on. |
62 | * @param fwd Was this a FWD going message? | ||
62 | * @param sent Was it really sent? (Could have been canceled) | 63 | * @param sent Was it really sent? (Could have been canceled) |
63 | * @param type Type of message sent. | 64 | * @param type Type of message sent. |
64 | * @param pid Packet ID, or 0 if not applicable (create, destroy, etc). | 65 | * @param payload_type Type of payload, if applicable. |
65 | * @param fwd Was this a FWD going message? | 66 | * @param pid Message ID, or 0 if not applicable (create, destroy, etc). |
66 | * @param size Size of the message. | 67 | * @param size Size of the message. |
67 | * @param wait Time spent waiting for core (only the time for THIS message) | 68 | * @param wait Time spent waiting for core (only the time for THIS message) |
68 | * @return #GNUNET_YES if connection was destroyed, #GNUNET_NO otherwise. | ||
69 | */ | 69 | */ |
70 | typedef int | 70 | typedef void |
71 | (*GCP_sent) (void *cls, | 71 | (*GCP_sent) (void *cls, |
72 | struct CadetConnection *c, int sent, | 72 | struct CadetConnection *c, int fwd, int sent, |
73 | uint16_t type, uint32_t pid, int fwd, size_t size, | 73 | uint16_t type, uint16_t payload_type, uint32_t pid, |
74 | size_t size, | ||
74 | struct GNUNET_TIME_Relative wait); | 75 | struct GNUNET_TIME_Relative wait); |
75 | 76 | ||
76 | /** | 77 | /** |
@@ -146,97 +147,40 @@ void | |||
146 | GCP_connect (struct CadetPeer *peer); | 147 | GCP_connect (struct CadetPeer *peer); |
147 | 148 | ||
148 | /** | 149 | /** |
149 | * Free a transmission that was already queued with all resources | 150 | * @brief Send a message to another peer (using CORE). |
150 | * associated to the request. | ||
151 | * | ||
152 | * If connection was marked to be destroyed, and this was the last queued | ||
153 | * message on it, the connection will be free'd as a result. | ||
154 | * | ||
155 | * @param queue Queue handler to cancel. | ||
156 | * @param clear_cls Is it necessary to free associated cls? | ||
157 | * @param sent Was it really sent? (Could have been canceled) | ||
158 | * @param pid PID, if relevant (was sent and was a payload message). | ||
159 | * | ||
160 | * @return #GNUNET_YES if connection was destroyed as a result, | ||
161 | * #GNUNET_NO otherwise. | ||
162 | */ | ||
163 | int | ||
164 | GCP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls, | ||
165 | int sent, uint32_t pid); | ||
166 | |||
167 | /** | ||
168 | * @brief Queue and pass message to core when possible. | ||
169 | * | 151 | * |
170 | * @param peer Peer towards which to queue the message. | 152 | * @param peer Peer towards which to queue the message. |
171 | * @param cls Closure (@c type dependant). It will be used by queue_send to | 153 | * @param message Message to send. |
172 | * build the message to be sent if not already prebuilt. | 154 | * @param payload_type Type of the message's payload, for debug messages. |
173 | * @param type Type of the message. | ||
174 | * @param payload_type Type of the message's payload | ||
175 | * 0 if the message is a retransmission (unknown payload). | 155 | * 0 if the message is a retransmission (unknown payload). |
176 | * UINT16_MAX if the message does not have payload. | 156 | * UINT16_MAX if the message does not have payload. |
177 | * @param payload_id ID of the payload (MID, ACK #, etc) | 157 | * @param payload_id ID of the payload (MID, ACK #, etc) |
178 | * @param size Size of the message. | ||
179 | * @param c Connection this message belongs to (can be NULL). | 158 | * @param c Connection this message belongs to (can be NULL). |
180 | * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!) | 159 | * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!) |
181 | * @param cont Continuation to be called once CORE has taken the message. | 160 | * @param cont Continuation to be called once CORE has sent the message. |
182 | * @param cont_cls Closure for @c cont. | 161 | * @param cont_cls Closure for @c cont. |
183 | * | ||
184 | * @return Handle to cancel the message before it is sent. Once cont is called | ||
185 | * message has been sent and therefore the handle is no longer valid. | ||
186 | */ | 162 | */ |
187 | struct CadetPeerQueue * | 163 | struct CadetPeerQueue * |
188 | GCP_queue_add (struct CadetPeer *peer, | 164 | GCP_send (struct CadetPeer *peer, |
189 | void *cls, | 165 | const struct GNUNET_MessageHeader *message, |
190 | uint16_t type, | 166 | uint16_t payload_type, |
191 | uint16_t payload_type, | 167 | uint32_t payload_id, |
192 | uint32_t payload_id, | 168 | struct CadetConnection *c, |
193 | size_t size, | 169 | int fwd, |
194 | struct CadetConnection *c, | 170 | GCP_sent cont, |
195 | int fwd, | 171 | void *cont_cls); |
196 | GCP_sent cont, | ||
197 | void *cont_cls); | ||
198 | |||
199 | /** | ||
200 | * Cancel all queued messages to a peer that belong to a certain connection. | ||
201 | * | ||
202 | * @param peer Peer towards whom to cancel. | ||
203 | * @param c Connection whose queued messages to cancel. Might be destroyed by | ||
204 | * the sent continuation call. | ||
205 | */ | ||
206 | void | ||
207 | GCP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c); | ||
208 | |||
209 | /** | ||
210 | * Get the first message for a connection and unqueue it. | ||
211 | * | ||
212 | * Only tunnel (or higher) level messages are unqueued. Connection specific | ||
213 | * messages are silently destroyed upon encounter. | ||
214 | * | ||
215 | * @param peer Neighboring peer. | ||
216 | * @param c Connection. | ||
217 | * @param destroyed[in/out] Was the connection destroyed as a result?. | ||
218 | * Can NOT be NULL. | ||
219 | * | ||
220 | * | ||
221 | * @return First message for this connection. | ||
222 | */ | ||
223 | struct GNUNET_MessageHeader * | ||
224 | GCP_connection_pop (struct CadetPeer *peer, | ||
225 | struct CadetConnection *c, | ||
226 | int *destroyed); | ||
227 | 172 | ||
228 | /** | 173 | /** |
229 | * Unlock a possibly locked queue for a connection. | 174 | * Cancel sending a message. Message must have been sent with |
175 | * #GCP_send before. May not be called after the notify sent | ||
176 | * callback has been called. | ||
230 | * | 177 | * |
231 | * If there is a message that can be sent on this connection, call core for it. | 178 | * It does NOT call the continuation given to #GCP_send. |
232 | * Otherwise (if core transmit is already called or there is no sendable | ||
233 | * message) do nothing. | ||
234 | * | 179 | * |
235 | * @param peer Peer who keeps the queue. | 180 | * @param q Queue handle to cancel |
236 | * @param c Connection whose messages to unlock. | ||
237 | */ | 181 | */ |
238 | void | 182 | void |
239 | GCP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c); | 183 | GCP_send_cancel (struct CadetPeerQueue *q); |
240 | 184 | ||
241 | /** | 185 | /** |
242 | * Set tunnel. | 186 | * Set tunnel. |