diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-10-11 09:33:36 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-10-11 09:33:36 +0000 |
commit | d254743f5668e69b13b0d82b373699562f3a0738 (patch) | |
tree | 5e86150433fe8041547361c04c4791076a620242 /src/mesh | |
parent | 393dcdaaa4739e764eecb5ba55ef96edcf1061dd (diff) | |
download | gnunet-d254743f5668e69b13b0d82b373699562f3a0738.tar.gz gnunet-d254743f5668e69b13b0d82b373699562f3a0738.zip |
- sync
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh_channel.c | 56 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_channel.h | 18 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_local.c | 33 |
3 files changed, 69 insertions, 38 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index 3607ae56c..2f1fc13f4 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c | |||
@@ -684,13 +684,12 @@ channel_save_copy (struct MeshChannel *ch, | |||
684 | * | 684 | * |
685 | * @param ch Channel on which to empty the message buffer. | 685 | * @param ch Channel on which to empty the message buffer. |
686 | * @param c Client to send to. | 686 | * @param c Client to send to. |
687 | * @param rel Reliability structure to corresponding peer. | 687 | * @param fwd Is this to send FWD data?. |
688 | * If rel == bck_rel, this is FWD data. | ||
689 | */ | 688 | */ |
690 | static void | 689 | static void |
691 | send_client_buffered_data (struct MeshChannel *ch, | 690 | send_client_buffered_data (struct MeshChannel *ch, |
692 | struct MeshClient *c, | 691 | struct MeshClient *c, |
693 | int fwd) | 692 | int fwd) |
694 | { | 693 | { |
695 | struct MeshReliableMessage *copy; | 694 | struct MeshReliableMessage *copy; |
696 | struct MeshChannelReliability *rel; | 695 | struct MeshChannelReliability *rel; |
@@ -1186,6 +1185,55 @@ GMCH_debug (struct MeshChannel *ch) | |||
1186 | 1185 | ||
1187 | 1186 | ||
1188 | /** | 1187 | /** |
1188 | * Handle an ACK given by a client. | ||
1189 | * | ||
1190 | * Mark client as ready and send him any buffered data we could have for him. | ||
1191 | * | ||
1192 | * @param ch Channel. | ||
1193 | * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by root and go BCK) | ||
1194 | */ | ||
1195 | void | ||
1196 | GMCH_handle_local_ack (struct MeshChannel *ch, int fwd) | ||
1197 | { | ||
1198 | struct MeshChannelReliability *rel; | ||
1199 | struct MeshClient *c; | ||
1200 | |||
1201 | rel = fwd ? ch->dest_rel : ch->root_rel; | ||
1202 | c = fwd ? ch->dest : ch->root; | ||
1203 | |||
1204 | rel->client_ready = GNUNET_YES; | ||
1205 | send_client_buffered_data (ch, c, fwd); | ||
1206 | send_ack (NULL, ch, fwd); | ||
1207 | |||
1208 | } | ||
1209 | |||
1210 | |||
1211 | /** | ||
1212 | * Handle data given by a client. | ||
1213 | * | ||
1214 | * @param ch Channel. | ||
1215 | * @param fwd Is this a FWD data? | ||
1216 | */ | ||
1217 | void | ||
1218 | GMCH_handle_local_data (struct MeshChannel *ch, | ||
1219 | struct MeshClient *c, | ||
1220 | int fwd) | ||
1221 | { | ||
1222 | /* Is the client in the channel? */ | ||
1223 | if ( !( (fwd && | ||
1224 | ch->root == c) | ||
1225 | || | ||
1226 | (!fwd && | ||
1227 | ch->dest == c) ) ) | ||
1228 | { | ||
1229 | GNUNET_break (0); | ||
1230 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1231 | return; | ||
1232 | } | ||
1233 | } | ||
1234 | |||
1235 | |||
1236 | /** | ||
1189 | * Handler for mesh network payload traffic. | 1237 | * Handler for mesh network payload traffic. |
1190 | * | 1238 | * |
1191 | * @param ch Channel for the message. | 1239 | * @param ch Channel for the message. |
diff --git a/src/mesh/gnunet-service-mesh_channel.h b/src/mesh/gnunet-service-mesh_channel.h index 1ea8c6d94..622a8deef 100644 --- a/src/mesh/gnunet-service-mesh_channel.h +++ b/src/mesh/gnunet-service-mesh_channel.h | |||
@@ -139,7 +139,6 @@ GMCH_send_data (struct MeshChannel *ch, | |||
139 | void | 139 | void |
140 | GMCH_send_create (struct MeshChannel *ch); | 140 | GMCH_send_create (struct MeshChannel *ch); |
141 | 141 | ||
142 | |||
143 | /** | 142 | /** |
144 | * Notify a client that the channel is no longer valid. | 143 | * Notify a client that the channel is no longer valid. |
145 | * | 144 | * |
@@ -148,7 +147,6 @@ GMCH_send_create (struct MeshChannel *ch); | |||
148 | void | 147 | void |
149 | GMCH_send_destroy (struct MeshChannel *ch); | 148 | GMCH_send_destroy (struct MeshChannel *ch); |
150 | 149 | ||
151 | |||
152 | /** | 150 | /** |
153 | * Log channel info. | 151 | * Log channel info. |
154 | * | 152 | * |
@@ -157,6 +155,16 @@ GMCH_send_destroy (struct MeshChannel *ch); | |||
157 | void | 155 | void |
158 | GMCH_debug (struct MeshChannel *ch); | 156 | GMCH_debug (struct MeshChannel *ch); |
159 | 157 | ||
158 | /** | ||
159 | * Handle an ACK given by a client. | ||
160 | * | ||
161 | * Mark client as ready and send him any buffered data we could have for him. | ||
162 | * | ||
163 | * @param ch Channel. | ||
164 | * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by root and go BCK) | ||
165 | */ | ||
166 | void | ||
167 | GMCH_handle_local_ack (struct MeshChannel *ch, int fwd); | ||
160 | 168 | ||
161 | /** | 169 | /** |
162 | * Handler for mesh network payload traffic. | 170 | * Handler for mesh network payload traffic. |
@@ -170,7 +178,6 @@ GMCH_handle_data (struct MeshChannel *ch, | |||
170 | const struct GNUNET_MESH_Data *msg, | 178 | const struct GNUNET_MESH_Data *msg, |
171 | int fwd); | 179 | int fwd); |
172 | 180 | ||
173 | |||
174 | /** | 181 | /** |
175 | * Handler for mesh network traffic end-to-end ACKs. | 182 | * Handler for mesh network traffic end-to-end ACKs. |
176 | * | 183 | * |
@@ -183,7 +190,6 @@ GMCH_handle_data_ack (struct MeshChannel *ch, | |||
183 | const struct GNUNET_MESH_DataACK *msg, | 190 | const struct GNUNET_MESH_DataACK *msg, |
184 | int fwd); | 191 | int fwd); |
185 | 192 | ||
186 | |||
187 | /** | 193 | /** |
188 | * Handler for channel create messages. | 194 | * Handler for channel create messages. |
189 | * | 195 | * |
@@ -195,7 +201,6 @@ struct MeshChannel * | |||
195 | GMCH_handle_create (const struct GNUNET_MESH_ChannelCreate *msg, | 201 | GMCH_handle_create (const struct GNUNET_MESH_ChannelCreate *msg, |
196 | int fwd); | 202 | int fwd); |
197 | 203 | ||
198 | |||
199 | /** | 204 | /** |
200 | * Handler for channel ack messages. | 205 | * Handler for channel ack messages. |
201 | * | 206 | * |
@@ -208,7 +213,6 @@ GMCH_handle_ack (struct MeshChannel *ch, | |||
208 | const struct GNUNET_MESH_ChannelManage *msg, | 213 | const struct GNUNET_MESH_ChannelManage *msg, |
209 | int fwd); | 214 | int fwd); |
210 | 215 | ||
211 | |||
212 | /** | 216 | /** |
213 | * Handler for channel destroy messages. | 217 | * Handler for channel destroy messages. |
214 | * | 218 | * |
@@ -221,8 +225,6 @@ GMCH_handle_destroy (struct MeshChannel *ch, | |||
221 | const struct GNUNET_MESH_ChannelManage *msg, | 225 | const struct GNUNET_MESH_ChannelManage *msg, |
222 | int fwd); | 226 | int fwd); |
223 | 227 | ||
224 | |||
225 | |||
226 | /** | 228 | /** |
227 | * Sends an already built message on a channel, properly registering | 229 | * Sends an already built message on a channel, properly registering |
228 | * all used resources and encrypting the message with the tunnel's key. | 230 | * all used resources and encrypting the message with the tunnel's key. |
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c index 2d6214d3e..eba5b88de 100644 --- a/src/mesh/gnunet-service-mesh_local.c +++ b/src/mesh/gnunet-service-mesh_local.c | |||
@@ -521,7 +521,7 @@ handle_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
521 | "Got data from a client!\n"); | 521 | "Got data from a client!\n"); |
522 | 522 | ||
523 | /* Sanity check for client registration */ | 523 | /* Sanity check for client registration */ |
524 | if (NULL == (c = client_get (client))) | 524 | if (NULL == (c = GML_client_get (client))) |
525 | { | 525 | { |
526 | GNUNET_break (0); | 526 | GNUNET_break (0); |
527 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 527 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -543,7 +543,7 @@ handle_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
543 | /* Channel exists? */ | 543 | /* Channel exists? */ |
544 | chid = ntohl (msg->id); | 544 | chid = ntohl (msg->id); |
545 | fwd = chid < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; | 545 | fwd = chid < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; |
546 | ch = channel_get_by_local_id (c, chid); | 546 | ch = GML_channel_get (c, chid); |
547 | if (NULL == ch) | 547 | if (NULL == ch) |
548 | { | 548 | { |
549 | GNUNET_break (0); | 549 | GNUNET_break (0); |
@@ -551,20 +551,6 @@ handle_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
551 | return; | 551 | return; |
552 | } | 552 | } |
553 | 553 | ||
554 | /* Is the client in the channel? */ | ||
555 | if ( !( (fwd && | ||
556 | ch->root && | ||
557 | ch->root->handle == client) | ||
558 | || | ||
559 | (!fwd && | ||
560 | ch->dest && | ||
561 | ch->dest->handle == client) ) ) | ||
562 | { | ||
563 | GNUNET_break (0); | ||
564 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
565 | return; | ||
566 | } | ||
567 | |||
568 | rel = fwd ? ch->root_rel : ch->dest_rel; | 554 | rel = fwd ? ch->root_rel : ch->dest_rel; |
569 | rel->client_ready = GNUNET_NO; | 555 | rel->client_ready = GNUNET_NO; |
570 | 556 | ||
@@ -608,7 +594,6 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client, | |||
608 | const struct GNUNET_MessageHeader *message) | 594 | const struct GNUNET_MessageHeader *message) |
609 | { | 595 | { |
610 | struct GNUNET_MESH_LocalAck *msg; | 596 | struct GNUNET_MESH_LocalAck *msg; |
611 | struct MeshChannelReliability *rel; | ||
612 | struct MeshChannel *ch; | 597 | struct MeshChannel *ch; |
613 | struct MeshClient *c; | 598 | struct MeshClient *c; |
614 | MESH_ChannelNumber chid; | 599 | MESH_ChannelNumber chid; |
@@ -617,7 +602,7 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client, | |||
617 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Got a local ACK\n"); | 602 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Got a local ACK\n"); |
618 | 603 | ||
619 | /* Sanity check for client registration */ | 604 | /* Sanity check for client registration */ |
620 | if (NULL == (c = client_get (client))) | 605 | if (NULL == (c = GML_client_get (client))) |
621 | { | 606 | { |
622 | GNUNET_break (0); | 607 | GNUNET_break (0); |
623 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 608 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -630,7 +615,7 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client, | |||
630 | /* Channel exists? */ | 615 | /* Channel exists? */ |
631 | chid = ntohl (msg->channel_id); | 616 | chid = ntohl (msg->channel_id); |
632 | LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n", chid); | 617 | LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n", chid); |
633 | ch = channel_get_by_local_id (c, chid); | 618 | ch = GML_channel_get (c, chid); |
634 | LOG (GNUNET_ERROR_TYPE_DEBUG, " -- ch %p\n", ch); | 619 | LOG (GNUNET_ERROR_TYPE_DEBUG, " -- ch %p\n", ch); |
635 | if (NULL == ch) | 620 | if (NULL == ch) |
636 | { | 621 | { |
@@ -644,13 +629,9 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client, | |||
644 | /* If client is root, the ACK is going FWD, therefore this is "BCK". */ | 629 | /* If client is root, the ACK is going FWD, therefore this is "BCK". */ |
645 | /* If client is dest, the ACK is going BCK, therefore this is "FWD" */ | 630 | /* If client is dest, the ACK is going BCK, therefore this is "FWD" */ |
646 | fwd = chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; | 631 | fwd = chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; |
647 | rel = fwd ? ch->dest_rel : ch->root_rel; | ||
648 | |||
649 | rel->client_ready = GNUNET_YES; | ||
650 | channel_send_client_buffered_data (ch, c, fwd); | ||
651 | send_ack (NULL, ch, fwd); | ||
652 | 632 | ||
653 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 633 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
634 | GMCH_handle_local_ack (ch, fwd); | ||
654 | 635 | ||
655 | return; | 636 | return; |
656 | } | 637 | } |
@@ -703,7 +684,7 @@ handle_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client, | |||
703 | struct MeshClient *c; | 684 | struct MeshClient *c; |
704 | 685 | ||
705 | /* Sanity check for client registration */ | 686 | /* Sanity check for client registration */ |
706 | if (NULL == (c = client_get (client))) | 687 | if (NULL == (c = GML_client_get (client))) |
707 | { | 688 | { |
708 | GNUNET_break (0); | 689 | GNUNET_break (0); |
709 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 690 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -740,7 +721,7 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, | |||
740 | struct MeshChannel *ch; | 721 | struct MeshChannel *ch; |
741 | 722 | ||
742 | /* Sanity check for client registration */ | 723 | /* Sanity check for client registration */ |
743 | if (NULL == (c = client_get (client))) | 724 | if (NULL == (c = GML_client_get (client))) |
744 | { | 725 | { |
745 | GNUNET_break (0); | 726 | GNUNET_break (0); |
746 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 727 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |