From: Christian Grothoff Date: Sun, 29 Jan 2017 17:43:35 +0000 (+0100) Subject: introduce buffering options on the route level X-Git-Tag: taler-0.2.1~256 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=81f9e9e971e615e9f1f18d1509168b56bb7360c0;p=oweals%2Fgnunet.git introduce buffering options on the route level --- diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h index e2d6f9d0b..d2426addb 100644 --- a/src/cadet/cadet_protocol.h +++ b/src/cadet/cadet_protocol.h @@ -67,9 +67,12 @@ struct GNUNET_CADET_ConnectionCreateMessage struct GNUNET_MessageHeader header; /** - * For alignment. + * Connection options in network byte order. + * #GNUNET_CADET_OPTION_DEFAULT for buffered; + * #GNUNET_CADET_OPTION_NOBUFFER for unbuffered. + * Other flags are ignored and should not be set at this level. */ - uint32_t reserved GNUNET_PACKED; + uint32_t options GNUNET_PACKED; /** * ID of the connection diff --git a/src/cadet/gnunet-service-cadet-new_connection.c b/src/cadet/gnunet-service-cadet-new_connection.c index fdc6de620..13d4c4a0c 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.c +++ b/src/cadet/gnunet-service-cadet-new_connection.c @@ -145,6 +145,11 @@ struct CadetConnection */ enum CadetConnectionState state; + /** + * Options for the route, control buffering. + */ + enum GNUNET_CADET_ChannelOption options; + /** * Offset of our @e destination in @e path. */ @@ -490,6 +495,7 @@ send_create (void *cls) env = GNUNET_MQ_msg_extra (create_msg, (1 + path_length) * sizeof (struct GNUNET_PeerIdentity), GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); + create_msg->options = htonl ((uint32_t) cc->options); create_msg->cid = cc->cid; pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; pids[0] = my_full_id; @@ -666,6 +672,7 @@ manage_first_hop_mq (void *cls, * * @param destination where to go * @param path which path to take (may not be the full path) + * @param options options for the connection * @param ct which tunnel uses this connection * @param init_state initial state for the connection * @param ready_cb function to call when ready to transmit @@ -675,6 +682,7 @@ manage_first_hop_mq (void *cls, static struct CadetConnection * connection_create (struct CadetPeer *destination, struct CadetPeerPath *path, + enum GNUNET_CADET_ChannelOption options, struct CadetTConnection *ct, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, enum CadetConnectionState init_state, @@ -689,6 +697,7 @@ connection_create (struct CadetPeer *destination, destination); GNUNET_assert (UINT_MAX > off); cc = GNUNET_new (struct CadetConnection); + cc->options = options; cc->state = init_state; cc->ct = ct; cc->cid = *cid; @@ -729,6 +738,7 @@ connection_create (struct CadetPeer *destination, * * @param destination where to go * @param path which path to take (may not be the full path) + * @param options options for the connection * @param ct which tunnel uses this connection * @param ready_cb function to call when ready to transmit * @param ready_cb_cls closure for @a cb @@ -738,6 +748,7 @@ connection_create (struct CadetPeer *destination, struct CadetConnection * GCC_create_inbound (struct CadetPeer *destination, struct CadetPeerPath *path, + enum GNUNET_CADET_ChannelOption options, struct CadetTConnection *ct, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, GCC_ReadyCallback ready_cb, @@ -793,6 +804,7 @@ GCC_create_inbound (struct CadetPeer *destination, return connection_create (destination, path, + options, ct, cid, CADET_CONNECTION_CREATE_RECEIVED, @@ -807,6 +819,7 @@ GCC_create_inbound (struct CadetPeer *destination, * * @param destination where to go * @param path which path to take (may not be the full path) + * @param options options for the connection * @param ct tunnel that uses the connection * @param ready_cb function to call when ready to transmit * @param ready_cb_cls closure for @a cb @@ -815,6 +828,7 @@ GCC_create_inbound (struct CadetPeer *destination, struct CadetConnection * GCC_create (struct CadetPeer *destination, struct CadetPeerPath *path, + enum GNUNET_CADET_ChannelOption options, struct CadetTConnection *ct, GCC_ReadyCallback ready_cb, void *ready_cb_cls) @@ -826,6 +840,7 @@ GCC_create (struct CadetPeer *destination, sizeof (cid)); return connection_create (destination, path, + options, ct, &cid, CADET_CONNECTION_NEW, diff --git a/src/cadet/gnunet-service-cadet-new_connection.h b/src/cadet/gnunet-service-cadet-new_connection.h index cea1e8024..1302b0060 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.h +++ b/src/cadet/gnunet-service-cadet-new_connection.h @@ -75,6 +75,7 @@ GCC_destroy_without_tunnel (struct CadetConnection *cc); * * @param destination where to go * @param path which path to take (may not be the full path) + * @param options options for the connection * @param ct which tunnel uses this connection * @param ready_cb function to call when ready to transmit * @param ready_cb_cls closure for @a cb @@ -83,6 +84,7 @@ GCC_destroy_without_tunnel (struct CadetConnection *cc); struct CadetConnection * GCC_create (struct CadetPeer *destination, struct CadetPeerPath *path, + enum GNUNET_CADET_ChannelOption options, struct CadetTConnection *ct, GCC_ReadyCallback ready_cb, void *ready_cb_cls); @@ -95,6 +97,7 @@ GCC_create (struct CadetPeer *destination, * * @param destination where to go * @param path which path to take (may not be the full path) + * @param options options for the connection * @param ct which tunnel uses this connection * @param ready_cb function to call when ready to transmit * @param ready_cb_cls closure for @a cb @@ -104,6 +107,7 @@ GCC_create (struct CadetPeer *destination, struct CadetConnection * GCC_create_inbound (struct CadetPeer *destination, struct CadetPeerPath *path, + enum GNUNET_CADET_ChannelOption options, struct CadetTConnection *ct, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, GCC_ReadyCallback ready_cb, diff --git a/src/cadet/gnunet-service-cadet-new_core.c b/src/cadet/gnunet-service-cadet-new_core.c index 25ffcb3ce..75a94119c 100644 --- a/src/cadet/gnunet-service-cadet-new_core.c +++ b/src/cadet/gnunet-service-cadet-new_core.c @@ -28,6 +28,7 @@ * * TODO: * - properly implement GLOBAL message buffer, instead of per-route buffers + * - do NOT use buffering if the route options say no buffer! * - Optimization: given BROKEN messages, destroy paths (?) */ #include "platform.h" @@ -128,6 +129,11 @@ struct CadetRoute * Position of this route in the #route_heap. */ struct GNUNET_CONTAINER_HeapNode *hn; + + /** + * Options for the route, control buffering. + */ + enum GNUNET_CADET_ChannelOption options; }; @@ -521,7 +527,9 @@ handle_connection_create (void *cls, uint16_t size = ntohs (msg->header.size) - sizeof (*msg); unsigned int path_length; unsigned int off; + enum GNUNET_CADET_ChannelOption options; + options = (enum GNUNET_CADET_ChannelOption) ntohl (msg->options); path_length = size / sizeof (struct GNUNET_PeerIdentity); /* Initiator is at offset 0. */ for (off=1;offcid, + (enum GNUNET_CADET_ChannelOption) ntohl (msg->options), path)) { /* Send back BROKEN: duplicate connection on the same path, @@ -639,6 +648,7 @@ handle_connection_create (void *cls, GNUNET_i2s (&pids[off + 1]), off + 1); route = GNUNET_new (struct CadetRoute); + route->options = options; route->cid = msg->cid; route->last_use = GNUNET_TIME_absolute_get (); dir_init (&route->prev, diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c b/src/cadet/gnunet-service-cadet-new_tunnels.c index 3c0271c71..e41164220 100644 --- a/src/cadet/gnunet-service-cadet-new_tunnels.c +++ b/src/cadet/gnunet-service-cadet-new_tunnels.c @@ -2444,6 +2444,7 @@ consider_path_cb (void *cls, ct->t = t; ct->cc = GCC_create (t->destination, path, + GNUNET_CADET_OPTION_DEFAULT, /* FIXME: set based on what channels want/need! */ ct, &connection_ready_cb, ct); @@ -2888,6 +2889,7 @@ GCT_create_tunnel (struct CadetPeer *destination) * * @param t a tunnel * @param cid connection identifer to use for the connection + * @param options options for the connection * @param path path to use for the connection * @return #GNUNET_OK on success, * #GNUNET_SYSERR on failure (duplicate connection) @@ -2895,6 +2897,7 @@ GCT_create_tunnel (struct CadetPeer *destination) int GCT_add_inbound_connection (struct CadetTunnel *t, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, + enum GNUNET_CADET_ChannelOption options, struct CadetPeerPath *path) { struct CadetTConnection *ct; @@ -2904,6 +2907,7 @@ GCT_add_inbound_connection (struct CadetTunnel *t, ct->t = t; ct->cc = GCC_create_inbound (t->destination, path, + options, ct, cid, &connection_ready_cb, diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.h b/src/cadet/gnunet-service-cadet-new_tunnels.h index d18abeb3c..f8613d236 100644 --- a/src/cadet/gnunet-service-cadet-new_tunnels.h +++ b/src/cadet/gnunet-service-cadet-new_tunnels.h @@ -119,6 +119,7 @@ GCT_destroy_tunnel_now (struct CadetTunnel *t); * * @param t a tunnel * @param cid connection identifer to use for the connection + * @param options options for the connection * @param path path to use for the connection * @return #GNUNET_OK on success, * #GNUNET_SYSERR on failure (duplicate connection) @@ -126,6 +127,7 @@ GCT_destroy_tunnel_now (struct CadetTunnel *t); int GCT_add_inbound_connection (struct CadetTunnel *t, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, + enum GNUNET_CADET_ChannelOption options, struct CadetPeerPath *path); diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index af27647b3..2d5087f81 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -3425,7 +3425,7 @@ GCC_send_create (struct CadetConnection *c) msg = (struct GNUNET_CADET_ConnectionCreateMessage *) cbuf; msg->header.size = htons (size); msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); - msg->reserved = htonl (0); + msg->options = htonl (0); msg->cid = *GCC_get_id (c); peers = (struct GNUNET_PeerIdentity *) &msg[1]; for (int i = 0; i < c->path->length; i++)