aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_cadet_service.h
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2016-07-20 12:07:02 +0000
committerBart Polot <bart@net.in.tum.de>2016-07-20 12:07:02 +0000
commitcaa4196867da8684c5b1fd2e747ecb9d21cbba8b (patch)
treea8d2ab68b81df8040c013118b7197209c70fa4c2 /src/include/gnunet_cadet_service.h
parenta603aaacbb3e786ab50644ca6fb49add439c8d8b (diff)
downloadgnunet-caa4196867da8684c5b1fd2e747ecb9d21cbba8b.tar.gz
gnunet-caa4196867da8684c5b1fd2e747ecb9d21cbba8b.zip
Change CADET ports from uint32 to HashCode
Diffstat (limited to 'src/include/gnunet_cadet_service.h')
-rw-r--r--src/include/gnunet_cadet_service.h66
1 files changed, 51 insertions, 15 deletions
diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h
index 264bc3154..1c440fc46 100644
--- a/src/include/gnunet_cadet_service.h
+++ b/src/include/gnunet_cadet_service.h
@@ -49,7 +49,7 @@ extern "C"
49/** 49/**
50 * Version number of GNUnet-cadet API. 50 * Version number of GNUnet-cadet API.
51 */ 51 */
52#define GNUNET_CADET_VERSION 0x00000003 52#define GNUNET_CADET_VERSION 0x00000004
53 53
54 54
55/** 55/**
@@ -63,6 +63,11 @@ struct GNUNET_CADET_Handle;
63struct GNUNET_CADET_Channel; 63struct GNUNET_CADET_Channel;
64 64
65/** 65/**
66 * Opaque handle to a port.
67 */
68struct GNUNET_CADET_Port;
69
70/**
66 * Hash to be used in Cadet communication. Only 256 bits needed, 71 * Hash to be used in Cadet communication. Only 256 bits needed,
67 * instead of the 512 from `struct GNUNET_HashCode`. 72 * instead of the 512 from `struct GNUNET_HashCode`.
68 */ 73 */
@@ -180,7 +185,7 @@ typedef void *
180(GNUNET_CADET_InboundChannelNotificationHandler) (void *cls, 185(GNUNET_CADET_InboundChannelNotificationHandler) (void *cls,
181 struct GNUNET_CADET_Channel *channel, 186 struct GNUNET_CADET_Channel *channel,
182 const struct GNUNET_PeerIdentity *initiator, 187 const struct GNUNET_PeerIdentity *initiator,
183 uint32_t port, 188 const struct GNUNET_HashCode *port,
184 enum GNUNET_CADET_ChannelOption options); 189 enum GNUNET_CADET_ChannelOption options);
185 190
186 191
@@ -208,9 +213,6 @@ typedef void
208 * @param cfg Configuration to use. 213 * @param cfg Configuration to use.
209 * @param cls Closure for the various callbacks that follow (including 214 * @param cls Closure for the various callbacks that follow (including
210 * handlers in the handlers array). 215 * handlers in the handlers array).
211 * @param new_channel Function called when an *incoming* channel is created.
212 * Can be NULL if no inbound channels are desired.
213 * See @a ports.
214 * @param cleaner Function called when a channel is destroyed. 216 * @param cleaner Function called when a channel is destroyed.
215 * It is called immediately if #GNUNET_CADET_channel_destroy 217 * It is called immediately if #GNUNET_CADET_channel_destroy
216 * is called on the channel. 218 * is called on the channel.
@@ -218,8 +220,6 @@ typedef void
218 * one must call #GNUNET_CADET_receive_done on the channel to 220 * one must call #GNUNET_CADET_receive_done on the channel to
219 * receive the next message. Messages of a type that is not 221 * receive the next message. Messages of a type that is not
220 * in the handlers array are ignored if received. 222 * in the handlers array are ignored if received.
221 * @param ports NULL or 0-terminated array of port numbers for incoming channels.
222 * See @a new_channel.
223 * 223 *
224 * @return handle to the cadet service NULL on error 224 * @return handle to the cadet service NULL on error
225 * (in this case, init is never called) 225 * (in this case, init is never called)
@@ -227,10 +227,8 @@ typedef void
227struct GNUNET_CADET_Handle * 227struct GNUNET_CADET_Handle *
228GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 228GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
229 void *cls, 229 void *cls,
230 GNUNET_CADET_InboundChannelNotificationHandler new_channel,
231 GNUNET_CADET_ChannelEndHandler cleaner, 230 GNUNET_CADET_ChannelEndHandler cleaner,
232 const struct GNUNET_CADET_MessageHandler *handlers, 231 const struct GNUNET_CADET_MessageHandler *handlers);
233 const uint32_t *ports);
234 232
235 233
236/** 234/**
@@ -244,6 +242,31 @@ GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
244void 242void
245GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle); 243GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle);
246 244
245/**
246 * Open a port to receive incomming channels.
247 *
248 * @param h CADET handle.
249 * @param port Hash representing the port number.
250 * @param new_channel Function called when an channel is received.
251 * @param new_channel_cls Closure for @a new_channel.
252 *
253 * @return Port handle.
254 */
255struct GNUNET_CADET_Port *
256GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
257 const struct GNUNET_HashCode *port,
258 GNUNET_CADET_InboundChannelNotificationHandler
259 new_channel,
260 void *new_channel_cls);
261
262/**
263 * Close a port opened with @a GNUNET_CADET_open_port.
264 * The @a new_channel callback will no longer be called.
265 *
266 * @param p Port handle.
267 */
268void
269GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p);
247 270
248/** 271/**
249 * Create a new channel towards a remote peer. 272 * Create a new channel towards a remote peer.
@@ -255,17 +278,17 @@ GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle);
255 * @param h cadet handle 278 * @param h cadet handle
256 * @param channel_ctx client's channel context to associate with the channel 279 * @param channel_ctx client's channel context to associate with the channel
257 * @param peer peer identity the channel should go to 280 * @param peer peer identity the channel should go to
258 * @param port Port number. 281 * @param port Port hash (port number).
259 * @param options CadetOption flag field, with all desired option bits set to 1. 282 * @param options CadetOption flag field, with all desired option bits set to 1.
260 * 283 *
261 * @return handle to the channel 284 * @return handle to the channel
262 */ 285 */
263struct GNUNET_CADET_Channel * 286struct GNUNET_CADET_Channel *
264GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h, 287GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h,
265 void *channel_ctx, 288 void *channel_ctx,
266 const struct GNUNET_PeerIdentity *peer, 289 const struct GNUNET_PeerIdentity *peer,
267 uint32_t port, 290 const struct GNUNET_HashCode *port,
268 enum GNUNET_CADET_ChannelOption options); 291 enum GNUNET_CADET_ChannelOption options);
269 292
270 293
271/** 294/**
@@ -634,6 +657,19 @@ struct GNUNET_MQ_Handle *
634GNUNET_CADET_mq_create (struct GNUNET_CADET_Channel *channel); 657GNUNET_CADET_mq_create (struct GNUNET_CADET_Channel *channel);
635 658
636 659
660/**
661 * Transitional function to convert an unsigned int port to a hash value.
662 * WARNING: local static value returned, NOT reentrant!
663 * WARNING: do not use this function for new code!
664 *
665 * @param port Numerical port (unsigned int format).
666 *
667 * @return A GNUNET_HashCode usable for the new CADET API.
668 */
669const struct GNUNET_HashCode *
670GC_u2h (uint32_t port);
671
672
637#if 0 /* keep Emacsens' auto-indent happy */ 673#if 0 /* keep Emacsens' auto-indent happy */
638{ 674{
639#endif 675#endif