diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-29 18:43:35 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-29 18:43:35 +0100 |
commit | 81f9e9e971e615e9f1f18d1509168b56bb7360c0 (patch) | |
tree | 84bf2b1e3240ee9190bf1ea7f2dfca63c19dafe1 /src/cadet | |
parent | dc430a9d23f8fd76f700d6836d4f4748429d70cd (diff) | |
download | gnunet-81f9e9e971e615e9f1f18d1509168b56bb7360c0.tar.gz gnunet-81f9e9e971e615e9f1f18d1509168b56bb7360c0.zip |
introduce buffering options on the route level
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/cadet_protocol.h | 7 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_connection.c | 15 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_connection.h | 4 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_core.c | 10 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_tunnels.c | 4 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_tunnels.h | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 2 |
7 files changed, 41 insertions, 3 deletions
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 | |||
67 | struct GNUNET_MessageHeader header; | 67 | struct GNUNET_MessageHeader header; |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * For alignment. | 70 | * Connection options in network byte order. |
71 | * #GNUNET_CADET_OPTION_DEFAULT for buffered; | ||
72 | * #GNUNET_CADET_OPTION_NOBUFFER for unbuffered. | ||
73 | * Other flags are ignored and should not be set at this level. | ||
71 | */ | 74 | */ |
72 | uint32_t reserved GNUNET_PACKED; | 75 | uint32_t options GNUNET_PACKED; |
73 | 76 | ||
74 | /** | 77 | /** |
75 | * ID of the connection | 78 | * 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 | |||
@@ -146,6 +146,11 @@ struct CadetConnection | |||
146 | enum CadetConnectionState state; | 146 | enum CadetConnectionState state; |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * Options for the route, control buffering. | ||
150 | */ | ||
151 | enum GNUNET_CADET_ChannelOption options; | ||
152 | |||
153 | /** | ||
149 | * Offset of our @e destination in @e path. | 154 | * Offset of our @e destination in @e path. |
150 | */ | 155 | */ |
151 | unsigned int off; | 156 | unsigned int off; |
@@ -490,6 +495,7 @@ send_create (void *cls) | |||
490 | env = GNUNET_MQ_msg_extra (create_msg, | 495 | env = GNUNET_MQ_msg_extra (create_msg, |
491 | (1 + path_length) * sizeof (struct GNUNET_PeerIdentity), | 496 | (1 + path_length) * sizeof (struct GNUNET_PeerIdentity), |
492 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); | 497 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); |
498 | create_msg->options = htonl ((uint32_t) cc->options); | ||
493 | create_msg->cid = cc->cid; | 499 | create_msg->cid = cc->cid; |
494 | pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; | 500 | pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; |
495 | pids[0] = my_full_id; | 501 | pids[0] = my_full_id; |
@@ -666,6 +672,7 @@ manage_first_hop_mq (void *cls, | |||
666 | * | 672 | * |
667 | * @param destination where to go | 673 | * @param destination where to go |
668 | * @param path which path to take (may not be the full path) | 674 | * @param path which path to take (may not be the full path) |
675 | * @param options options for the connection | ||
669 | * @param ct which tunnel uses this connection | 676 | * @param ct which tunnel uses this connection |
670 | * @param init_state initial state for the connection | 677 | * @param init_state initial state for the connection |
671 | * @param ready_cb function to call when ready to transmit | 678 | * @param ready_cb function to call when ready to transmit |
@@ -675,6 +682,7 @@ manage_first_hop_mq (void *cls, | |||
675 | static struct CadetConnection * | 682 | static struct CadetConnection * |
676 | connection_create (struct CadetPeer *destination, | 683 | connection_create (struct CadetPeer *destination, |
677 | struct CadetPeerPath *path, | 684 | struct CadetPeerPath *path, |
685 | enum GNUNET_CADET_ChannelOption options, | ||
678 | struct CadetTConnection *ct, | 686 | struct CadetTConnection *ct, |
679 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 687 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
680 | enum CadetConnectionState init_state, | 688 | enum CadetConnectionState init_state, |
@@ -689,6 +697,7 @@ connection_create (struct CadetPeer *destination, | |||
689 | destination); | 697 | destination); |
690 | GNUNET_assert (UINT_MAX > off); | 698 | GNUNET_assert (UINT_MAX > off); |
691 | cc = GNUNET_new (struct CadetConnection); | 699 | cc = GNUNET_new (struct CadetConnection); |
700 | cc->options = options; | ||
692 | cc->state = init_state; | 701 | cc->state = init_state; |
693 | cc->ct = ct; | 702 | cc->ct = ct; |
694 | cc->cid = *cid; | 703 | cc->cid = *cid; |
@@ -729,6 +738,7 @@ connection_create (struct CadetPeer *destination, | |||
729 | * | 738 | * |
730 | * @param destination where to go | 739 | * @param destination where to go |
731 | * @param path which path to take (may not be the full path) | 740 | * @param path which path to take (may not be the full path) |
741 | * @param options options for the connection | ||
732 | * @param ct which tunnel uses this connection | 742 | * @param ct which tunnel uses this connection |
733 | * @param ready_cb function to call when ready to transmit | 743 | * @param ready_cb function to call when ready to transmit |
734 | * @param ready_cb_cls closure for @a cb | 744 | * @param ready_cb_cls closure for @a cb |
@@ -738,6 +748,7 @@ connection_create (struct CadetPeer *destination, | |||
738 | struct CadetConnection * | 748 | struct CadetConnection * |
739 | GCC_create_inbound (struct CadetPeer *destination, | 749 | GCC_create_inbound (struct CadetPeer *destination, |
740 | struct CadetPeerPath *path, | 750 | struct CadetPeerPath *path, |
751 | enum GNUNET_CADET_ChannelOption options, | ||
741 | struct CadetTConnection *ct, | 752 | struct CadetTConnection *ct, |
742 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 753 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
743 | GCC_ReadyCallback ready_cb, | 754 | GCC_ReadyCallback ready_cb, |
@@ -793,6 +804,7 @@ GCC_create_inbound (struct CadetPeer *destination, | |||
793 | 804 | ||
794 | return connection_create (destination, | 805 | return connection_create (destination, |
795 | path, | 806 | path, |
807 | options, | ||
796 | ct, | 808 | ct, |
797 | cid, | 809 | cid, |
798 | CADET_CONNECTION_CREATE_RECEIVED, | 810 | CADET_CONNECTION_CREATE_RECEIVED, |
@@ -807,6 +819,7 @@ GCC_create_inbound (struct CadetPeer *destination, | |||
807 | * | 819 | * |
808 | * @param destination where to go | 820 | * @param destination where to go |
809 | * @param path which path to take (may not be the full path) | 821 | * @param path which path to take (may not be the full path) |
822 | * @param options options for the connection | ||
810 | * @param ct tunnel that uses the connection | 823 | * @param ct tunnel that uses the connection |
811 | * @param ready_cb function to call when ready to transmit | 824 | * @param ready_cb function to call when ready to transmit |
812 | * @param ready_cb_cls closure for @a cb | 825 | * @param ready_cb_cls closure for @a cb |
@@ -815,6 +828,7 @@ GCC_create_inbound (struct CadetPeer *destination, | |||
815 | struct CadetConnection * | 828 | struct CadetConnection * |
816 | GCC_create (struct CadetPeer *destination, | 829 | GCC_create (struct CadetPeer *destination, |
817 | struct CadetPeerPath *path, | 830 | struct CadetPeerPath *path, |
831 | enum GNUNET_CADET_ChannelOption options, | ||
818 | struct CadetTConnection *ct, | 832 | struct CadetTConnection *ct, |
819 | GCC_ReadyCallback ready_cb, | 833 | GCC_ReadyCallback ready_cb, |
820 | void *ready_cb_cls) | 834 | void *ready_cb_cls) |
@@ -826,6 +840,7 @@ GCC_create (struct CadetPeer *destination, | |||
826 | sizeof (cid)); | 840 | sizeof (cid)); |
827 | return connection_create (destination, | 841 | return connection_create (destination, |
828 | path, | 842 | path, |
843 | options, | ||
829 | ct, | 844 | ct, |
830 | &cid, | 845 | &cid, |
831 | CADET_CONNECTION_NEW, | 846 | 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); | |||
75 | * | 75 | * |
76 | * @param destination where to go | 76 | * @param destination where to go |
77 | * @param path which path to take (may not be the full path) | 77 | * @param path which path to take (may not be the full path) |
78 | * @param options options for the connection | ||
78 | * @param ct which tunnel uses this connection | 79 | * @param ct which tunnel uses this connection |
79 | * @param ready_cb function to call when ready to transmit | 80 | * @param ready_cb function to call when ready to transmit |
80 | * @param ready_cb_cls closure for @a cb | 81 | * @param ready_cb_cls closure for @a cb |
@@ -83,6 +84,7 @@ GCC_destroy_without_tunnel (struct CadetConnection *cc); | |||
83 | struct CadetConnection * | 84 | struct CadetConnection * |
84 | GCC_create (struct CadetPeer *destination, | 85 | GCC_create (struct CadetPeer *destination, |
85 | struct CadetPeerPath *path, | 86 | struct CadetPeerPath *path, |
87 | enum GNUNET_CADET_ChannelOption options, | ||
86 | struct CadetTConnection *ct, | 88 | struct CadetTConnection *ct, |
87 | GCC_ReadyCallback ready_cb, | 89 | GCC_ReadyCallback ready_cb, |
88 | void *ready_cb_cls); | 90 | void *ready_cb_cls); |
@@ -95,6 +97,7 @@ GCC_create (struct CadetPeer *destination, | |||
95 | * | 97 | * |
96 | * @param destination where to go | 98 | * @param destination where to go |
97 | * @param path which path to take (may not be the full path) | 99 | * @param path which path to take (may not be the full path) |
100 | * @param options options for the connection | ||
98 | * @param ct which tunnel uses this connection | 101 | * @param ct which tunnel uses this connection |
99 | * @param ready_cb function to call when ready to transmit | 102 | * @param ready_cb function to call when ready to transmit |
100 | * @param ready_cb_cls closure for @a cb | 103 | * @param ready_cb_cls closure for @a cb |
@@ -104,6 +107,7 @@ GCC_create (struct CadetPeer *destination, | |||
104 | struct CadetConnection * | 107 | struct CadetConnection * |
105 | GCC_create_inbound (struct CadetPeer *destination, | 108 | GCC_create_inbound (struct CadetPeer *destination, |
106 | struct CadetPeerPath *path, | 109 | struct CadetPeerPath *path, |
110 | enum GNUNET_CADET_ChannelOption options, | ||
107 | struct CadetTConnection *ct, | 111 | struct CadetTConnection *ct, |
108 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 112 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
109 | GCC_ReadyCallback ready_cb, | 113 | 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 @@ | |||
28 | * | 28 | * |
29 | * TODO: | 29 | * TODO: |
30 | * - properly implement GLOBAL message buffer, instead of per-route buffers | 30 | * - properly implement GLOBAL message buffer, instead of per-route buffers |
31 | * - do NOT use buffering if the route options say no buffer! | ||
31 | * - Optimization: given BROKEN messages, destroy paths (?) | 32 | * - Optimization: given BROKEN messages, destroy paths (?) |
32 | */ | 33 | */ |
33 | #include "platform.h" | 34 | #include "platform.h" |
@@ -128,6 +129,11 @@ struct CadetRoute | |||
128 | * Position of this route in the #route_heap. | 129 | * Position of this route in the #route_heap. |
129 | */ | 130 | */ |
130 | struct GNUNET_CONTAINER_HeapNode *hn; | 131 | struct GNUNET_CONTAINER_HeapNode *hn; |
132 | |||
133 | /** | ||
134 | * Options for the route, control buffering. | ||
135 | */ | ||
136 | enum GNUNET_CADET_ChannelOption options; | ||
131 | }; | 137 | }; |
132 | 138 | ||
133 | 139 | ||
@@ -521,7 +527,9 @@ handle_connection_create (void *cls, | |||
521 | uint16_t size = ntohs (msg->header.size) - sizeof (*msg); | 527 | uint16_t size = ntohs (msg->header.size) - sizeof (*msg); |
522 | unsigned int path_length; | 528 | unsigned int path_length; |
523 | unsigned int off; | 529 | unsigned int off; |
530 | enum GNUNET_CADET_ChannelOption options; | ||
524 | 531 | ||
532 | options = (enum GNUNET_CADET_ChannelOption) ntohl (msg->options); | ||
525 | path_length = size / sizeof (struct GNUNET_PeerIdentity); | 533 | path_length = size / sizeof (struct GNUNET_PeerIdentity); |
526 | /* Initiator is at offset 0. */ | 534 | /* Initiator is at offset 0. */ |
527 | for (off=1;off<path_length;off++) | 535 | for (off=1;off<path_length;off++) |
@@ -585,6 +593,7 @@ handle_connection_create (void *cls, | |||
585 | GCT_add_inbound_connection (GCP_get_tunnel (origin, | 593 | GCT_add_inbound_connection (GCP_get_tunnel (origin, |
586 | GNUNET_YES), | 594 | GNUNET_YES), |
587 | &msg->cid, | 595 | &msg->cid, |
596 | (enum GNUNET_CADET_ChannelOption) ntohl (msg->options), | ||
588 | path)) | 597 | path)) |
589 | { | 598 | { |
590 | /* Send back BROKEN: duplicate connection on the same path, | 599 | /* Send back BROKEN: duplicate connection on the same path, |
@@ -639,6 +648,7 @@ handle_connection_create (void *cls, | |||
639 | GNUNET_i2s (&pids[off + 1]), | 648 | GNUNET_i2s (&pids[off + 1]), |
640 | off + 1); | 649 | off + 1); |
641 | route = GNUNET_new (struct CadetRoute); | 650 | route = GNUNET_new (struct CadetRoute); |
651 | route->options = options; | ||
642 | route->cid = msg->cid; | 652 | route->cid = msg->cid; |
643 | route->last_use = GNUNET_TIME_absolute_get (); | 653 | route->last_use = GNUNET_TIME_absolute_get (); |
644 | dir_init (&route->prev, | 654 | 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, | |||
2444 | ct->t = t; | 2444 | ct->t = t; |
2445 | ct->cc = GCC_create (t->destination, | 2445 | ct->cc = GCC_create (t->destination, |
2446 | path, | 2446 | path, |
2447 | GNUNET_CADET_OPTION_DEFAULT, /* FIXME: set based on what channels want/need! */ | ||
2447 | ct, | 2448 | ct, |
2448 | &connection_ready_cb, | 2449 | &connection_ready_cb, |
2449 | ct); | 2450 | ct); |
@@ -2888,6 +2889,7 @@ GCT_create_tunnel (struct CadetPeer *destination) | |||
2888 | * | 2889 | * |
2889 | * @param t a tunnel | 2890 | * @param t a tunnel |
2890 | * @param cid connection identifer to use for the connection | 2891 | * @param cid connection identifer to use for the connection |
2892 | * @param options options for the connection | ||
2891 | * @param path path to use for the connection | 2893 | * @param path path to use for the connection |
2892 | * @return #GNUNET_OK on success, | 2894 | * @return #GNUNET_OK on success, |
2893 | * #GNUNET_SYSERR on failure (duplicate connection) | 2895 | * #GNUNET_SYSERR on failure (duplicate connection) |
@@ -2895,6 +2897,7 @@ GCT_create_tunnel (struct CadetPeer *destination) | |||
2895 | int | 2897 | int |
2896 | GCT_add_inbound_connection (struct CadetTunnel *t, | 2898 | GCT_add_inbound_connection (struct CadetTunnel *t, |
2897 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 2899 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
2900 | enum GNUNET_CADET_ChannelOption options, | ||
2898 | struct CadetPeerPath *path) | 2901 | struct CadetPeerPath *path) |
2899 | { | 2902 | { |
2900 | struct CadetTConnection *ct; | 2903 | struct CadetTConnection *ct; |
@@ -2904,6 +2907,7 @@ GCT_add_inbound_connection (struct CadetTunnel *t, | |||
2904 | ct->t = t; | 2907 | ct->t = t; |
2905 | ct->cc = GCC_create_inbound (t->destination, | 2908 | ct->cc = GCC_create_inbound (t->destination, |
2906 | path, | 2909 | path, |
2910 | options, | ||
2907 | ct, | 2911 | ct, |
2908 | cid, | 2912 | cid, |
2909 | &connection_ready_cb, | 2913 | &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); | |||
119 | * | 119 | * |
120 | * @param t a tunnel | 120 | * @param t a tunnel |
121 | * @param cid connection identifer to use for the connection | 121 | * @param cid connection identifer to use for the connection |
122 | * @param options options for the connection | ||
122 | * @param path path to use for the connection | 123 | * @param path path to use for the connection |
123 | * @return #GNUNET_OK on success, | 124 | * @return #GNUNET_OK on success, |
124 | * #GNUNET_SYSERR on failure (duplicate connection) | 125 | * #GNUNET_SYSERR on failure (duplicate connection) |
@@ -126,6 +127,7 @@ GCT_destroy_tunnel_now (struct CadetTunnel *t); | |||
126 | int | 127 | int |
127 | GCT_add_inbound_connection (struct CadetTunnel *t, | 128 | GCT_add_inbound_connection (struct CadetTunnel *t, |
128 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | 129 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
130 | enum GNUNET_CADET_ChannelOption options, | ||
129 | struct CadetPeerPath *path); | 131 | struct CadetPeerPath *path); |
130 | 132 | ||
131 | 133 | ||
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) | |||
3425 | msg = (struct GNUNET_CADET_ConnectionCreateMessage *) cbuf; | 3425 | msg = (struct GNUNET_CADET_ConnectionCreateMessage *) cbuf; |
3426 | msg->header.size = htons (size); | 3426 | msg->header.size = htons (size); |
3427 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); | 3427 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); |
3428 | msg->reserved = htonl (0); | 3428 | msg->options = htonl (0); |
3429 | msg->cid = *GCC_get_id (c); | 3429 | msg->cid = *GCC_get_id (c); |
3430 | peers = (struct GNUNET_PeerIdentity *) &msg[1]; | 3430 | peers = (struct GNUNET_PeerIdentity *) &msg[1]; |
3431 | for (int i = 0; i < c->path->length; i++) | 3431 | for (int i = 0; i < c->path->length; i++) |