diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-05-14 11:05:09 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-05-14 11:05:09 +0000 |
commit | f5204922a35901fb54077ea2418d75614b01e1f4 (patch) | |
tree | 830e81c48c891abca0954ab431797f67f89235bb /src | |
parent | 2817eb187b6ad9eb2288808213e774cbf6a68273 (diff) | |
download | gnunet-f5204922a35901fb54077ea2418d75614b01e1f4.tar.gz gnunet-f5204922a35901fb54077ea2418d75614b01e1f4.zip |
- remove transmission descriptor, simple cls is enough
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh-new.c | 429 |
1 files changed, 180 insertions, 249 deletions
diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c index 4c43fb4d1..63a8f25d0 100644 --- a/src/mesh/gnunet-service-mesh-new.c +++ b/src/mesh/gnunet-service-mesh-new.c | |||
@@ -151,32 +151,6 @@ struct MeshPeerQueue | |||
151 | 151 | ||
152 | 152 | ||
153 | /** | 153 | /** |
154 | * Struct containing all info possibly needed to build a package when called | ||
155 | * back by core. | ||
156 | */ | ||
157 | struct MeshTransmissionDescriptor | ||
158 | { | ||
159 | /** ID of the tunnel this packet travels in */ | ||
160 | struct MESH_TunnelID *origin; | ||
161 | |||
162 | /** Who was this message being sent to */ | ||
163 | struct MeshPeerInfo *peer; | ||
164 | |||
165 | /** Ultimate destination of the packet */ | ||
166 | GNUNET_PEER_Id destination; | ||
167 | |||
168 | /** Tunnel it belongs to. */ | ||
169 | struct MeshTunnel *t; | ||
170 | |||
171 | /** Size of the data. */ | ||
172 | size_t data_len; | ||
173 | |||
174 | /** Data itself */ | ||
175 | void *data; | ||
176 | }; | ||
177 | |||
178 | |||
179 | /** | ||
180 | * Struct containing all information regarding a given peer | 154 | * Struct containing all information regarding a given peer |
181 | */ | 155 | */ |
182 | struct MeshPeerInfo | 156 | struct MeshPeerInfo |
@@ -240,7 +214,7 @@ struct MeshPeerInfo | |||
240 | unsigned int queue_n; | 214 | unsigned int queue_n; |
241 | 215 | ||
242 | /** | 216 | /** |
243 | * Handle to for queued transmissions | 217 | * Handle for queued transmissions |
244 | */ | 218 | */ |
245 | struct GNUNET_CORE_TransmitHandle *core_transmit; | 219 | struct GNUNET_CORE_TransmitHandle *core_transmit; |
246 | }; | 220 | }; |
@@ -1108,12 +1082,10 @@ peer_remove_tunnel (struct MeshPeerInfo *peer, struct MeshTunnel *t) | |||
1108 | static size_t | 1082 | static size_t |
1109 | send_core_data_raw (void *cls, size_t size, void *buf) | 1083 | send_core_data_raw (void *cls, size_t size, void *buf) |
1110 | { | 1084 | { |
1111 | struct MeshTransmissionDescriptor *info = cls; | 1085 | struct GNUNET_MessageHeader *msg = cls; |
1112 | struct GNUNET_MessageHeader *msg; | ||
1113 | size_t total_size; | 1086 | size_t total_size; |
1114 | 1087 | ||
1115 | GNUNET_assert (NULL != info); | 1088 | GNUNET_assert (NULL != msg); |
1116 | msg = (struct GNUNET_MessageHeader *) info->data; | ||
1117 | total_size = ntohs (msg->size); | 1089 | total_size = ntohs (msg->size); |
1118 | 1090 | ||
1119 | if (total_size > size) | 1091 | if (total_size > size) |
@@ -1122,8 +1094,7 @@ send_core_data_raw (void *cls, size_t size, void *buf) | |||
1122 | return 0; | 1094 | return 0; |
1123 | } | 1095 | } |
1124 | memcpy (buf, msg, total_size); | 1096 | memcpy (buf, msg, total_size); |
1125 | GNUNET_free (info->data); | 1097 | GNUNET_free (cls); |
1126 | GNUNET_free (info); | ||
1127 | return total_size; | 1098 | return total_size; |
1128 | } | 1099 | } |
1129 | 1100 | ||
@@ -1141,10 +1112,10 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
1141 | GNUNET_PEER_Id peer, | 1112 | GNUNET_PEER_Id peer, |
1142 | struct MeshTunnel *t) | 1113 | struct MeshTunnel *t) |
1143 | { | 1114 | { |
1144 | struct MeshTransmissionDescriptor *info; | ||
1145 | struct GNUNET_PeerIdentity id; | 1115 | struct GNUNET_PeerIdentity id; |
1146 | struct MeshPeerInfo *neighbor; | 1116 | struct MeshPeerInfo *neighbor; |
1147 | struct MeshPeerPath *p; | 1117 | struct MeshPeerPath *p; |
1118 | void *data; | ||
1148 | size_t size; | 1119 | size_t size; |
1149 | uint16_t type; | 1120 | uint16_t type; |
1150 | 1121 | ||
@@ -1154,25 +1125,23 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
1154 | return; | 1125 | return; |
1155 | 1126 | ||
1156 | size = ntohs (message->size); | 1127 | size = ntohs (message->size); |
1157 | info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor)); | 1128 | data = GNUNET_malloc (size); |
1158 | info->data = GNUNET_malloc (size); | 1129 | memcpy (data, message, size); |
1159 | memcpy (info->data, message, size); | ||
1160 | type = ntohs(message->type); | 1130 | type = ntohs(message->type); |
1161 | switch (type) | 1131 | switch (type) |
1162 | { | 1132 | { |
1163 | struct GNUNET_MESH_Unicast *m; | 1133 | struct GNUNET_MESH_Unicast *u; |
1164 | struct GNUNET_MESH_ToOrigin *to; | 1134 | struct GNUNET_MESH_ToOrigin *to; |
1165 | 1135 | ||
1166 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: | 1136 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: |
1167 | m = (struct GNUNET_MESH_Unicast *) info->data; | 1137 | u = (struct GNUNET_MESH_Unicast *) data; |
1168 | m->ttl = htonl (ntohl (m->ttl) - 1); | 1138 | u->ttl = htonl (ntohl (u->ttl) - 1); |
1169 | break; | 1139 | break; |
1170 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: | 1140 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: |
1171 | to = (struct GNUNET_MESH_ToOrigin *) info->data; | 1141 | to = (struct GNUNET_MESH_ToOrigin *) data; |
1172 | t->prev_fc.last_pid_sent++; /* FIXME per hop? */ | 1142 | t->prev_fc.last_pid_sent++; /* FIXME per hop? */ |
1173 | to->pid = htonl (t->prev_fc.last_pid_sent); | 1143 | to->pid = htonl (t->prev_fc.last_pid_sent); |
1174 | } | 1144 | } |
1175 | info->data_len = size; | ||
1176 | GNUNET_PEER_resolve (peer, &id); | 1145 | GNUNET_PEER_resolve (peer, &id); |
1177 | neighbor = peer_get (&id); | 1146 | neighbor = peer_get (&id); |
1178 | for (p = neighbor->path_head; NULL != p; p = p->next) | 1147 | for (p = neighbor->path_head; NULL != p; p = p->next) |
@@ -1209,17 +1178,15 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
1209 | } | 1178 | } |
1210 | #endif | 1179 | #endif |
1211 | GNUNET_break (0); // FIXME sometimes fails (testing disconnect?) | 1180 | GNUNET_break (0); // FIXME sometimes fails (testing disconnect?) |
1212 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1181 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1213 | " no direct connection to %s\n", | 1182 | " no direct connection to %s\n", |
1214 | GNUNET_i2s (&id)); | 1183 | GNUNET_i2s (&id)); |
1215 | GNUNET_free (info->data); | 1184 | GNUNET_free (data); |
1216 | GNUNET_free (info); | ||
1217 | return; | 1185 | return; |
1218 | } | 1186 | } |
1219 | info->peer = neighbor; | ||
1220 | if (GNUNET_MESSAGE_TYPE_MESH_PATH_ACK == type) | 1187 | if (GNUNET_MESSAGE_TYPE_MESH_PATH_ACK == type) |
1221 | type = 0; | 1188 | type = 0; |
1222 | queue_add (info, | 1189 | queue_add (data, |
1223 | type, | 1190 | type, |
1224 | size, | 1191 | size, |
1225 | neighbor, | 1192 | neighbor, |
@@ -1265,19 +1232,20 @@ send_create_path (struct MeshPeerInfo *peer, struct MeshPeerPath *p, | |||
1265 | static void | 1232 | static void |
1266 | send_path_ack (struct MeshTunnel *t) | 1233 | send_path_ack (struct MeshTunnel *t) |
1267 | { | 1234 | { |
1268 | struct MeshTransmissionDescriptor *info; | 1235 | struct MeshPeerInfo *peer; |
1269 | struct GNUNET_PeerIdentity id; | 1236 | |
1237 | if (0 == t->prev_hop) | ||
1238 | { | ||
1239 | GNUNET_break (0); | ||
1240 | return; | ||
1241 | } | ||
1270 | 1242 | ||
1271 | GNUNET_PEER_resolve (t->prev_hop, &id); | 1243 | peer = peer_get_short (t->prev_hop); |
1272 | info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor)); | ||
1273 | info->origin = &t->id; | ||
1274 | info->peer = GNUNET_CONTAINER_multihashmap_get (peers, &id.hashPubKey); | ||
1275 | GNUNET_assert (NULL != info->peer); | ||
1276 | 1244 | ||
1277 | queue_add (info, | 1245 | queue_add (&t->id, |
1278 | GNUNET_MESSAGE_TYPE_MESH_PATH_ACK, | 1246 | GNUNET_MESSAGE_TYPE_MESH_PATH_ACK, |
1279 | sizeof (struct GNUNET_MESH_PathACK), | 1247 | sizeof (struct GNUNET_MESH_PathACK), |
1280 | info->peer, | 1248 | peer, |
1281 | t); | 1249 | t); |
1282 | } | 1250 | } |
1283 | 1251 | ||
@@ -2515,10 +2483,10 @@ send_core_path_create (void *cls, size_t size, void *buf) | |||
2515 | static size_t | 2483 | static size_t |
2516 | send_core_path_ack (void *cls, size_t size, void *buf) | 2484 | send_core_path_ack (void *cls, size_t size, void *buf) |
2517 | { | 2485 | { |
2518 | struct MeshTransmissionDescriptor *info = cls; | 2486 | struct MESH_TunnelID *id = cls; |
2519 | struct GNUNET_MESH_PathACK *msg = buf; | 2487 | struct GNUNET_MESH_PathACK *msg = buf; |
2520 | 2488 | ||
2521 | GNUNET_assert (NULL != info); | 2489 | GNUNET_assert (NULL != id); |
2522 | if (sizeof (struct GNUNET_MESH_PathACK) > size) | 2490 | if (sizeof (struct GNUNET_MESH_PathACK) > size) |
2523 | { | 2491 | { |
2524 | GNUNET_break (0); | 2492 | GNUNET_break (0); |
@@ -2526,11 +2494,10 @@ send_core_path_ack (void *cls, size_t size, void *buf) | |||
2526 | } | 2494 | } |
2527 | msg->header.size = htons (sizeof (struct GNUNET_MESH_PathACK)); | 2495 | msg->header.size = htons (sizeof (struct GNUNET_MESH_PathACK)); |
2528 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_ACK); | 2496 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_ACK); |
2529 | GNUNET_PEER_resolve (info->origin->oid, &msg->oid); | 2497 | GNUNET_PEER_resolve (id->oid, &msg->oid); |
2530 | msg->tid = htonl (info->origin->tid); | 2498 | msg->tid = htonl (id->tid); |
2531 | msg->peer_id = my_full_id; | 2499 | msg->peer_id = my_full_id; |
2532 | 2500 | ||
2533 | GNUNET_free (info); | ||
2534 | /* TODO add signature */ | 2501 | /* TODO add signature */ |
2535 | 2502 | ||
2536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH ACK sent!\n"); | 2503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH ACK sent!\n"); |
@@ -2548,8 +2515,7 @@ send_core_path_ack (void *cls, size_t size, void *buf) | |||
2548 | static void | 2515 | static void |
2549 | queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | 2516 | queue_destroy (struct MeshPeerQueue *queue, int clear_cls) |
2550 | { | 2517 | { |
2551 | struct MeshTransmissionDescriptor *dd; | 2518 | struct MeshFlowControl *fc; |
2552 | // unsigned int max; | ||
2553 | 2519 | ||
2554 | if (GNUNET_YES == clear_cls) | 2520 | if (GNUNET_YES == clear_cls) |
2555 | { | 2521 | { |
@@ -2568,9 +2534,7 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | |||
2568 | " prebuilt message\n"); | 2534 | " prebuilt message\n"); |
2569 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2570 | " type %s\n", | 2536 | " type %s\n", |
2571 | GNUNET_MESH_DEBUG_M2S(queue->type)); | 2537 | GNUNET_MESH_DEBUG_M2S (queue->type)); |
2572 | dd = queue->cls; | ||
2573 | GNUNET_free (dd->data); | ||
2574 | break; | 2538 | break; |
2575 | case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE: | 2539 | case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE: |
2576 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type create path\n"); | 2540 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type create path\n"); |
@@ -2579,7 +2543,7 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | |||
2579 | GNUNET_break (0); | 2543 | GNUNET_break (0); |
2580 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2544 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2581 | " type %s unknown!\n", | 2545 | " type %s unknown!\n", |
2582 | GNUNET_MESH_DEBUG_M2S(queue->type)); | 2546 | GNUNET_MESH_DEBUG_M2S (queue->type)); |
2583 | } | 2547 | } |
2584 | GNUNET_free_non_null (queue->cls); | 2548 | GNUNET_free_non_null (queue->cls); |
2585 | } | 2549 | } |
@@ -2587,33 +2551,17 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | |||
2587 | queue->peer->queue_tail, | 2551 | queue->peer->queue_tail, |
2588 | queue); | 2552 | queue); |
2589 | 2553 | ||
2590 | /* Delete from child_fc in the appropiate tunnel */ | 2554 | /* Delete from appropiate fc in the tunnel */ |
2591 | // max = queue->tunnel->fwd_queue_max; | 2555 | if (queue->peer->id == queue->tunnel->next_hop) |
2592 | // GNUNET_PEER_resolve (queue->peer->id, &id); | 2556 | fc = &queue->tunnel->next_fc; |
2593 | // if (NULL != cinfo) | 2557 | else if (queue->peer->id == queue->tunnel->next_hop) |
2594 | // { FIXME | 2558 | fc = &queue->tunnel->next_fc; |
2595 | // for (i = 0; i < cinfo->send_buffer_n; i++) | 2559 | else |
2596 | // { | 2560 | { |
2597 | // i2 = (cinfo->send_buffer_start + i) % max; | 2561 | GNUNET_break (0); |
2598 | // if (cinfo->send_buffer[i2] == queue) | 2562 | return; |
2599 | // { | 2563 | } |
2600 | // /* Found corresponding entry in the send_buffer. Move all others back. */ | 2564 | fc->queue_n--; |
2601 | // unsigned int j; | ||
2602 | // | ||
2603 | // | ||
2604 | // for (j = i, j2 = 0, j3 = 0; j < cinfo->send_buffer_n - 1; j++) | ||
2605 | // { | ||
2606 | // j2 = (cinfo->send_buffer_start + j) % max; | ||
2607 | // j3 = (cinfo->send_buffer_start + j + 1) % max; | ||
2608 | // cinfo->send_buffer[j2] = cinfo->send_buffer[j3]; | ||
2609 | // } | ||
2610 | // | ||
2611 | // cinfo->send_buffer[j3] = NULL; | ||
2612 | // cinfo->send_buffer_n--; | ||
2613 | // } | ||
2614 | // } | ||
2615 | // } | ||
2616 | |||
2617 | GNUNET_free (queue); | 2565 | GNUNET_free (queue); |
2618 | } | 2566 | } |
2619 | 2567 | ||
@@ -2634,7 +2582,6 @@ queue_get_next (const struct MeshPeerInfo *peer) | |||
2634 | { | 2582 | { |
2635 | struct MeshPeerQueue *q; | 2583 | struct MeshPeerQueue *q; |
2636 | 2584 | ||
2637 | struct MeshTransmissionDescriptor *info; | ||
2638 | struct GNUNET_MESH_Unicast *ucast; | 2585 | struct GNUNET_MESH_Unicast *ucast; |
2639 | struct GNUNET_MESH_ToOrigin *to_orig; | 2586 | struct GNUNET_MESH_ToOrigin *to_orig; |
2640 | struct MeshTunnel* t; | 2587 | struct MeshTunnel* t; |
@@ -2645,19 +2592,18 @@ queue_get_next (const struct MeshPeerInfo *peer) | |||
2645 | for (q = peer->queue_head; NULL != q; q = q->next) | 2592 | for (q = peer->queue_head; NULL != q; q = q->next) |
2646 | { | 2593 | { |
2647 | t = q->tunnel; | 2594 | t = q->tunnel; |
2648 | info = q->cls; | ||
2649 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2595 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2650 | "********* %s\n", | 2596 | "********* %s\n", |
2651 | GNUNET_MESH_DEBUG_M2S(q->type)); | 2597 | GNUNET_MESH_DEBUG_M2S(q->type)); |
2652 | switch (q->type) | 2598 | switch (q->type) |
2653 | { | 2599 | { |
2654 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: | 2600 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: |
2655 | ucast = (struct GNUNET_MESH_Unicast *) info->data; | 2601 | ucast = (struct GNUNET_MESH_Unicast *) q->cls; |
2656 | pid = ntohl (ucast->pid); | 2602 | pid = ntohl (ucast->pid); |
2657 | ack = t->next_fc.last_ack_recv; | 2603 | ack = t->next_fc.last_ack_recv; |
2658 | break; | 2604 | break; |
2659 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: | 2605 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: |
2660 | to_orig = (struct GNUNET_MESH_ToOrigin *) info->data; | 2606 | to_orig = (struct GNUNET_MESH_ToOrigin *) q->cls; |
2661 | pid = ntohl (to_orig->pid); | 2607 | pid = ntohl (to_orig->pid); |
2662 | ack = t->prev_fc.last_ack_recv; | 2608 | ack = t->prev_fc.last_ack_recv; |
2663 | break; | 2609 | break; |
@@ -2690,118 +2636,104 @@ queue_get_next (const struct MeshPeerInfo *peer) | |||
2690 | static size_t | 2636 | static size_t |
2691 | queue_send (void *cls, size_t size, void *buf) | 2637 | queue_send (void *cls, size_t size, void *buf) |
2692 | { | 2638 | { |
2693 | struct MeshPeerInfo *peer = cls; | 2639 | struct MeshPeerInfo *peer = cls; |
2694 | struct GNUNET_MessageHeader *msg; | 2640 | struct GNUNET_MessageHeader *msg; |
2695 | struct MeshPeerQueue *queue; | 2641 | struct MeshPeerQueue *queue; |
2696 | struct MeshTunnel *t; | 2642 | struct MeshTunnel *t; |
2697 | struct GNUNET_PeerIdentity dst_id; | 2643 | struct GNUNET_PeerIdentity dst_id; |
2698 | struct MeshFlowControl *fc; | 2644 | struct MeshFlowControl *fc; |
2699 | size_t data_size; | 2645 | size_t data_size; |
2700 | 2646 | ||
2701 | peer->core_transmit = NULL; | 2647 | peer->core_transmit = NULL; |
2702 | 2648 | ||
2703 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* Queue send\n"); | 2649 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* Queue send\n"); |
2704 | queue = queue_get_next (peer); | 2650 | queue = queue_get_next (peer); |
2705 | 2651 | ||
2706 | /* Queue has no internal mesh traffic nor sendable payload */ | 2652 | /* Queue has no internal mesh traffic nor sendable payload */ |
2707 | if (NULL == queue) | 2653 | if (NULL == queue) |
2708 | { | 2654 | { |
2709 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not ready, return\n"); | 2655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not ready, return\n"); |
2710 | if (NULL == peer->queue_head) | 2656 | if (NULL == peer->queue_head) |
2711 | GNUNET_break (0); /* Core tmt_rdy should've been canceled */ | 2657 | GNUNET_break (0); /* Core tmt_rdy should've been canceled */ |
2658 | return 0; | ||
2659 | } | ||
2660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not empty\n"); | ||
2661 | |||
2662 | GNUNET_PEER_resolve (peer->id, &dst_id); | ||
2663 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2664 | "********* towards %s\n", | ||
2665 | GNUNET_i2s (&dst_id)); | ||
2666 | /* Check if buffer size is enough for the message */ | ||
2667 | if (queue->size > size) | ||
2668 | { | ||
2669 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2670 | "********* not enough room, reissue\n"); | ||
2671 | peer->core_transmit = | ||
2672 | GNUNET_CORE_notify_transmit_ready (core_handle, | ||
2673 | GNUNET_NO, | ||
2674 | 0, | ||
2675 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
2676 | &dst_id, | ||
2677 | queue->size, | ||
2678 | &queue_send, | ||
2679 | peer); | ||
2712 | return 0; | 2680 | return 0; |
2713 | } | 2681 | } |
2714 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not empty\n"); | 2682 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* size ok\n"); |
2715 | 2683 | ||
2716 | GNUNET_PEER_resolve (peer->id, &dst_id); | 2684 | t = queue->tunnel; |
2717 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2685 | GNUNET_assert (0 < t->pending_messages); |
2718 | "********* towards %s\n", | 2686 | t->pending_messages--; |
2719 | GNUNET_i2s(&dst_id)); | ||
2720 | /* Check if buffer size is enough for the message */ | ||
2721 | if (queue->size > size) | ||
2722 | { | ||
2723 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2724 | "********* not enough room, reissue\n"); | ||
2725 | peer->core_transmit = | ||
2726 | GNUNET_CORE_notify_transmit_ready (core_handle, | ||
2727 | 0, | ||
2728 | 0, | ||
2729 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
2730 | &dst_id, | ||
2731 | queue->size, | ||
2732 | &queue_send, | ||
2733 | peer); | ||
2734 | return 0; | ||
2735 | } | ||
2736 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* size ok\n"); | ||
2737 | 2687 | ||
2738 | t = queue->tunnel; | 2688 | /* Fill buf */ |
2739 | GNUNET_assert (0 < t->pending_messages); | 2689 | switch (queue->type) |
2740 | t->pending_messages--; | 2690 | { |
2741 | if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == queue->type) | 2691 | case 0: |
2742 | { | 2692 | case GNUNET_MESSAGE_TYPE_MESH_ACK: |
2743 | t->next_fc.queue_n--; | 2693 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
2744 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2694 | case GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN: |
2745 | "********* unicast: t->q (%u/%u)\n", | 2695 | case GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY: |
2746 | t->next_fc.queue_n, t->queue_max); | 2696 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: |
2747 | } | 2697 | case GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE: |
2748 | else if (GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == queue->type) | ||
2749 | { | ||
2750 | t->prev_fc.queue_n--; | ||
2751 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2698 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2752 | "********* to orig: t->q (%u/%u)\n", | 2699 | "********* raw: %s\n", |
2753 | t->prev_fc.queue_n, t->queue_max); | 2700 | GNUNET_MESH_DEBUG_M2S (queue->type)); |
2754 | } | 2701 | /* Fall through */ |
2755 | 2702 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: | |
2756 | /* Fill buf */ | 2703 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: |
2757 | switch (queue->type) | 2704 | data_size = send_core_data_raw (queue->cls, size, buf); |
2758 | { | 2705 | msg = (struct GNUNET_MessageHeader *) buf; |
2759 | case 0: | 2706 | switch (ntohs (msg->type)) // Type of preconstructed message |
2760 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | 2707 | { |
2761 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 2708 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: |
2762 | case GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN: | 2709 | tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST); |
2763 | case GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY: | 2710 | break; |
2764 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: | 2711 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: |
2765 | case GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE: | 2712 | tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN); |
2766 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2713 | break; |
2767 | "********* raw: %s\n", | 2714 | default: |
2768 | GNUNET_MESH_DEBUG_M2S (queue->type)); | ||
2769 | /* Fall through */ | ||
2770 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: | ||
2771 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: | ||
2772 | data_size = send_core_data_raw (queue->cls, size, buf); | ||
2773 | msg = (struct GNUNET_MessageHeader *) buf; | ||
2774 | switch (ntohs (msg->type)) // Type of preconstructed message | ||
2775 | { | ||
2776 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: | ||
2777 | tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST); | ||
2778 | break; | ||
2779 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: | ||
2780 | tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN); | ||
2781 | break; | 2715 | break; |
2782 | default: | 2716 | } |
2783 | break; | 2717 | break; |
2784 | } | 2718 | case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE: |
2785 | break; | 2719 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path create\n"); |
2786 | case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE: | 2720 | data_size = send_core_path_create (queue->cls, size, buf); |
2787 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path create\n"); | 2721 | break; |
2788 | data_size = send_core_path_create (queue->cls, size, buf); | 2722 | case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK: |
2789 | break; | 2723 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path ack\n"); |
2790 | case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK: | 2724 | data_size = send_core_path_ack (queue->cls, size, buf); |
2791 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path ack\n"); | 2725 | break; |
2792 | data_size = send_core_path_ack (queue->cls, size, buf); | 2726 | default: |
2793 | break; | 2727 | GNUNET_break (0); |
2794 | default: | 2728 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2795 | GNUNET_break (0); | 2729 | "********* type unknown: %u\n", |
2796 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2730 | queue->type); |
2797 | "********* type unknown: %u\n", | 2731 | data_size = 0; |
2798 | queue->type); | 2732 | } |
2799 | data_size = 0; | 2733 | switch (queue->type) |
2800 | } | 2734 | { |
2801 | switch (queue->type) | 2735 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: |
2802 | { | 2736 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: |
2803 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: | ||
2804 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: | ||
2805 | // if (cinfo->send_buffer[cinfo->send_buffer_start] != queue) | 2737 | // if (cinfo->send_buffer[cinfo->send_buffer_start] != queue) |
2806 | // { FIXME | 2738 | // { FIXME |
2807 | // GNUNET_break (0); | 2739 | // GNUNET_break (0); |
@@ -2822,59 +2754,59 @@ queue_send (void *cls, size_t size, void *buf) | |||
2822 | // { | 2754 | // { |
2823 | // GNUNET_break (0); | 2755 | // GNUNET_break (0); |
2824 | // } | 2756 | // } |
2825 | break; | 2757 | break; |
2826 | default: | 2758 | default: |
2827 | break; | 2759 | break; |
2828 | } | 2760 | } |
2829 | 2761 | ||
2830 | /* Free queue, but cls was freed by send_core_* */ | 2762 | /* Free queue, but cls was freed by send_core_* */ |
2831 | queue_destroy (queue, GNUNET_NO); | 2763 | queue_destroy (queue, GNUNET_NO); |
2832 | 2764 | ||
2833 | if (GNUNET_YES == t->destroy && 0 == t->pending_messages) | 2765 | if (GNUNET_YES == t->destroy && 0 == t->pending_messages) |
2834 | { | 2766 | { |
2835 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* destroying tunnel!\n"); | 2767 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* destroying tunnel!\n"); |
2836 | tunnel_destroy (t); | 2768 | tunnel_destroy (t); |
2837 | } | 2769 | } |
2838 | 2770 | ||
2839 | /* If more data in queue, send next */ | 2771 | /* If more data in queue, send next */ |
2840 | queue = queue_get_next (peer); | 2772 | queue = queue_get_next (peer); |
2841 | if (NULL != queue) | 2773 | if (NULL != queue) |
2842 | { | 2774 | { |
2843 | struct GNUNET_PeerIdentity id; | 2775 | struct GNUNET_PeerIdentity id; |
2844 | 2776 | ||
2845 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* more data!\n"); | 2777 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* more data!\n"); |
2846 | GNUNET_PEER_resolve (peer->id, &id); | 2778 | GNUNET_PEER_resolve (peer->id, &id); |
2847 | peer->core_transmit = | 2779 | peer->core_transmit = |
2848 | GNUNET_CORE_notify_transmit_ready(core_handle, | 2780 | GNUNET_CORE_notify_transmit_ready(core_handle, |
2849 | 0, | 2781 | 0, |
2850 | 0, | 2782 | 0, |
2851 | GNUNET_TIME_UNIT_FOREVER_REL, | 2783 | GNUNET_TIME_UNIT_FOREVER_REL, |
2852 | &id, | 2784 | &id, |
2853 | queue->size, | 2785 | queue->size, |
2854 | &queue_send, | 2786 | &queue_send, |
2855 | peer); | 2787 | peer); |
2856 | } | 2788 | } |
2857 | else | 2789 | else |
2790 | { | ||
2791 | if (NULL != peer->queue_head) | ||
2858 | { | 2792 | { |
2859 | if (NULL != peer->queue_head) | 2793 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2794 | "********* %s stalled\n", | ||
2795 | GNUNET_i2s(&my_full_id)); | ||
2796 | if (peer->id == t->next_hop) | ||
2797 | fc = &t->next_fc; | ||
2798 | else | ||
2799 | fc = &t->prev_fc; | ||
2800 | if (GNUNET_SCHEDULER_NO_TASK == fc->poll_task) | ||
2860 | { | 2801 | { |
2861 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2802 | fc->t = t; |
2862 | "********* %s stalled\n", | 2803 | fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, |
2863 | GNUNET_i2s(&my_full_id)); | 2804 | &tunnel_poll, fc); |
2864 | if (peer->id == t->next_hop) | ||
2865 | fc = &t->next_fc; | ||
2866 | else | ||
2867 | fc = &t->prev_fc; | ||
2868 | if (GNUNET_SCHEDULER_NO_TASK == fc->poll_task) | ||
2869 | { | ||
2870 | fc->t = t; | ||
2871 | fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, | ||
2872 | &tunnel_poll, fc); | ||
2873 | } | ||
2874 | } | 2805 | } |
2875 | } | 2806 | } |
2876 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* return %d\n", data_size); | 2807 | } |
2877 | return data_size; | 2808 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* return %d\n", data_size); |
2809 | return data_size; | ||
2878 | } | 2810 | } |
2879 | 2811 | ||
2880 | 2812 | ||
@@ -3266,7 +3198,6 @@ handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3266 | " for tunnel %s [%u]\n", | 3198 | " for tunnel %s [%u]\n", |
3267 | GNUNET_i2s (&msg->oid), ntohl (msg->tid)); | 3199 | GNUNET_i2s (&msg->oid), ntohl (msg->tid)); |
3268 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); | 3200 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); |
3269 | /* Check signature */ | ||
3270 | if (NULL == t) | 3201 | if (NULL == t) |
3271 | { | 3202 | { |
3272 | /* Probably already got the message from another path, | 3203 | /* Probably already got the message from another path, |