diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-07-23 18:37:48 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-07-23 18:37:48 +0000 |
commit | 778a92d48e8d642d78e0ee7420090d457472c9e8 (patch) | |
tree | e18164b2f60014e5c83ff93530628a7edb4ebf0b | |
parent | 87f78bbb75f670dec2bbbb33a876742ac1848367 (diff) | |
download | gnunet-778a92d48e8d642d78e0ee7420090d457472c9e8.tar.gz gnunet-778a92d48e8d642d78e0ee7420090d457472c9e8.zip |
- wip
-rw-r--r-- | src/mesh/gnunet-service-mesh-enc.c | 326 |
1 files changed, 177 insertions, 149 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c index 6ec206b82..93069ca34 100644 --- a/src/mesh/gnunet-service-mesh-enc.c +++ b/src/mesh/gnunet-service-mesh-enc.c | |||
@@ -91,6 +91,37 @@ if (0 < __count)\ | |||
91 | #define INTERVAL_SHOW | 91 | #define INTERVAL_SHOW |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | /** | ||
95 | * All the states a tunnel can be in. | ||
96 | */ | ||
97 | enum MeshTunnelState | ||
98 | { | ||
99 | /** | ||
100 | * Uninitialized status, should never appear in operation. | ||
101 | */ | ||
102 | MESH_TUNNEL_NEW, | ||
103 | |||
104 | /** | ||
105 | * Path to the peer not known yet | ||
106 | */ | ||
107 | MESH_TUNNEL_SEARCHING, | ||
108 | |||
109 | /** | ||
110 | * Request sent, not yet answered. | ||
111 | */ | ||
112 | MESH_TUNNEL_WAITING, | ||
113 | |||
114 | /** | ||
115 | * Peer connected and ready to accept data | ||
116 | */ | ||
117 | MESH_TUNNEL_READY, | ||
118 | |||
119 | /** | ||
120 | * Peer connected previosly but not responding | ||
121 | */ | ||
122 | MESH_TUNNEL_RECONNECTING | ||
123 | }; | ||
124 | |||
94 | /******************************************************************************/ | 125 | /******************************************************************************/ |
95 | /************************ DATA STRUCTURES ****************************/ | 126 | /************************ DATA STRUCTURES ****************************/ |
96 | /******************************************************************************/ | 127 | /******************************************************************************/ |
@@ -142,42 +173,6 @@ struct MeshPeerQueue | |||
142 | }; | 173 | }; |
143 | 174 | ||
144 | 175 | ||
145 | /** | ||
146 | * Data describing a tunnel to a peer. | ||
147 | */ | ||
148 | struct MeshPeerTunnel | ||
149 | { | ||
150 | /** | ||
151 | * State of the tunnel. | ||
152 | */ | ||
153 | enum MeshTunnelState state; | ||
154 | |||
155 | /** | ||
156 | * Local peer ephemeral private key | ||
157 | */ | ||
158 | struct GNUNET_CRYPTO_EccPrivateKey* my_eph_key; | ||
159 | |||
160 | /** | ||
161 | * Local peer ephemeral public key | ||
162 | */ | ||
163 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded* my_eph; | ||
164 | |||
165 | /** | ||
166 | * Remote peer's public key. | ||
167 | */ | ||
168 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded* peers_eph; | ||
169 | |||
170 | /** | ||
171 | * Encryption ("our") key. | ||
172 | */ | ||
173 | struct GNUNET_CRYPTO_AesSessionKey e_key; | ||
174 | |||
175 | /** | ||
176 | * Decryption ("their") key. | ||
177 | */ | ||
178 | struct GNUNET_CRYPTO_AesSessionKey d_key; | ||
179 | }; | ||
180 | |||
181 | 176 | ||
182 | /** | 177 | /** |
183 | * Struct containing all information regarding a given peer | 178 | * Struct containing all information regarding a given peer |
@@ -309,22 +304,21 @@ struct MeshFlowControl | |||
309 | struct MESH_TunnelID | 304 | struct MESH_TunnelID |
310 | { | 305 | { |
311 | /** | 306 | /** |
312 | * Node that owns the tunnel | 307 | * Tunnel Owner. |
313 | */ | 308 | */ |
314 | GNUNET_PEER_Id oid; | 309 | GNUNET_PEER_Id oid; |
315 | 310 | ||
316 | /** | 311 | /** |
317 | * Tunnel number to differentiate all the tunnels owned by the node oid | 312 | * Tunnel Destination. |
318 | * ( tid < GNUNET_MESH_LOCAL_TUNNEL_ID_CLI ) | ||
319 | */ | 313 | */ |
320 | MESH_TunnelNumber tid; | 314 | GNUNET_PEER_Id did; |
321 | }; | 315 | }; |
322 | 316 | ||
323 | 317 | ||
324 | /** | 318 | /** |
325 | * Data needed for reliable tunnel endpoint retransmission management. | 319 | * Data needed for reliable tunnel endpoint retransmission management. |
326 | */ | 320 | */ |
327 | struct MeshTunnelReliability; | 321 | struct MeshChannelReliability; |
328 | 322 | ||
329 | 323 | ||
330 | /** | 324 | /** |
@@ -341,7 +335,7 @@ struct MeshReliableMessage | |||
341 | /** | 335 | /** |
342 | * Tunnel Reliability queue this message is in. | 336 | * Tunnel Reliability queue this message is in. |
343 | */ | 337 | */ |
344 | struct MeshTunnelReliability *rel; | 338 | struct MeshChannelReliability *rel; |
345 | 339 | ||
346 | /** | 340 | /** |
347 | * ID of the message (ACK needed to free) | 341 | * ID of the message (ACK needed to free) |
@@ -357,7 +351,7 @@ struct MeshReliableMessage | |||
357 | }; | 351 | }; |
358 | 352 | ||
359 | 353 | ||
360 | struct MeshTunnelReliability | 354 | struct MeshChannelReliability |
361 | { | 355 | { |
362 | /** | 356 | /** |
363 | * Tunnel this is about. | 357 | * Tunnel this is about. |
@@ -409,40 +403,26 @@ struct MeshTunnelReliability | |||
409 | 403 | ||
410 | 404 | ||
411 | /** | 405 | /** |
412 | * Struct containing all information regarding a tunnel | 406 | * Struct containing all information regarding a channel to a remote client. |
413 | * For an intermediate node the improtant info used will be: | ||
414 | * - id Tunnel unique identification | ||
415 | * - paths[0] To know where to send it next | ||
416 | * - metainfo: ready, speeds, accounting | ||
417 | */ | 407 | */ |
418 | struct MeshChannel | 408 | struct MeshChannel |
419 | { | 409 | { |
420 | /** | 410 | /** |
421 | * Tunnel ID | 411 | * Port of the channel. |
422 | */ | ||
423 | struct MESH_TunnelID id; | ||
424 | |||
425 | /** | ||
426 | * Port of the tunnel. | ||
427 | */ | 412 | */ |
428 | uint32_t port; | 413 | uint32_t port; |
429 | 414 | ||
430 | /** | 415 | /** |
431 | * State of the tunnel. | 416 | * Local tunnel number ( >= GNUNET_MESH_LOCAL_CHANNEL_ID_CLI or 0 ) |
432 | */ | ||
433 | enum MeshTunnelState state; | ||
434 | |||
435 | /** | ||
436 | * Local tunnel number ( >= GNUNET_MESH_LOCAL_TUNNEL_ID_CLI or 0 ) | ||
437 | */ | 417 | */ |
438 | MESH_TunnelNumber local_tid; | 418 | MESH_ChannelNumber local_tid; |
439 | 419 | ||
440 | /** | 420 | /** |
441 | * Local tunnel number for local destination clients (incoming number) | 421 | * Local tunnel number for local destination clients (incoming number) |
442 | * ( >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV or 0). All clients share the same | 422 | * ( >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV or 0). All clients share the same |
443 | * number. | 423 | * number. |
444 | */ | 424 | */ |
445 | MESH_TunnelNumber local_tid_dest; | 425 | MESH_ChannelNumber local_tid_dest; |
446 | 426 | ||
447 | /** | 427 | /** |
448 | * Is the tunnel bufferless (minimum latency)? | 428 | * Is the tunnel bufferless (minimum latency)? |
@@ -505,31 +485,14 @@ struct MeshChannel | |||
505 | struct MeshClient *client; | 485 | struct MeshClient *client; |
506 | 486 | ||
507 | /** | 487 | /** |
508 | * Task to keep the used paths alive at the owner, | 488 | * Flag to signal the destruction of the channel. |
509 | * time tunnel out on all the other peers. | 489 | * If this is set GNUNET_YES the channel will be destroyed |
510 | */ | ||
511 | GNUNET_SCHEDULER_TaskIdentifier fwd_maintenance_task; | ||
512 | |||
513 | /** | ||
514 | * Task to keep the used paths alive at the destination, | ||
515 | * time tunnel out on all the other peers. | ||
516 | */ | ||
517 | GNUNET_SCHEDULER_TaskIdentifier bck_maintenance_task; | ||
518 | |||
519 | /** | ||
520 | * Path being used for the tunnel. | ||
521 | */ | ||
522 | struct MeshPeerPath *path; | ||
523 | |||
524 | /** | ||
525 | * Flag to signal the destruction of the tunnel. | ||
526 | * If this is set GNUNET_YES the tunnel will be destroyed | ||
527 | * when the queue is empty. | 490 | * when the queue is empty. |
528 | */ | 491 | */ |
529 | int destroy; | 492 | int destroy; |
530 | 493 | ||
531 | /** | 494 | /** |
532 | * Total messages pending for this tunnels, payload or not. | 495 | * Total messages pending for this channel, payload or not. |
533 | */ | 496 | */ |
534 | unsigned int pending_messages; | 497 | unsigned int pending_messages; |
535 | 498 | ||
@@ -537,17 +500,82 @@ struct MeshChannel | |||
537 | * Reliability data. | 500 | * Reliability data. |
538 | * Only present (non-NULL) at the owner of a tunnel. | 501 | * Only present (non-NULL) at the owner of a tunnel. |
539 | */ | 502 | */ |
540 | struct MeshTunnelReliability *fwd_rel; | 503 | struct MeshChannelReliability *fwd_rel; |
541 | 504 | ||
542 | /** | 505 | /** |
543 | * Reliability data. | 506 | * Reliability data. |
544 | * Only present (non-NULL) at the destination of a tunnel. | 507 | * Only present (non-NULL) at the destination of a tunnel. |
545 | */ | 508 | */ |
546 | struct MeshTunnelReliability *bck_rel; | 509 | struct MeshChannelReliability *bck_rel; |
510 | }; | ||
511 | |||
512 | |||
513 | struct MeshPath | ||
514 | { | ||
515 | /** | ||
516 | * Path being used for the tunnel. | ||
517 | */ | ||
518 | struct MeshPeerPath *path; | ||
519 | |||
520 | /** | ||
521 | * Task to keep the used paths alive at the owner, | ||
522 | * time tunnel out on all the other peers. | ||
523 | */ | ||
524 | GNUNET_SCHEDULER_TaskIdentifier fwd_maintenance_task; | ||
525 | |||
526 | /** | ||
527 | * Task to keep the used paths alive at the destination, | ||
528 | * time tunnel out on all the other peers. | ||
529 | */ | ||
530 | GNUNET_SCHEDULER_TaskIdentifier bck_maintenance_task; | ||
547 | }; | 531 | }; |
548 | 532 | ||
549 | 533 | ||
550 | /** | 534 | /** |
535 | * Struct containing all information regarding a tunnel to a peer. | ||
536 | */ | ||
537 | struct MeshTunnel | ||
538 | { | ||
539 | /** | ||
540 | * Tunnel ID (owner, destination) | ||
541 | */ | ||
542 | struct MESH_TunnelID id; | ||
543 | |||
544 | /** | ||
545 | * State of the tunnel. | ||
546 | */ | ||
547 | enum MeshTunnelState state; | ||
548 | |||
549 | /** | ||
550 | * Local peer ephemeral private key | ||
551 | */ | ||
552 | struct GNUNET_CRYPTO_EccPrivateKey* my_eph_key; | ||
553 | |||
554 | /** | ||
555 | * Local peer ephemeral public key | ||
556 | */ | ||
557 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded* my_eph; | ||
558 | |||
559 | /** | ||
560 | * Remote peer's public key. | ||
561 | */ | ||
562 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded* peers_eph; | ||
563 | |||
564 | /** | ||
565 | * Encryption ("our") key. | ||
566 | */ | ||
567 | struct GNUNET_CRYPTO_AesSessionKey e_key; | ||
568 | |||
569 | /** | ||
570 | * Decryption ("their") key. | ||
571 | */ | ||
572 | struct GNUNET_CRYPTO_AesSessionKey d_key; | ||
573 | |||
574 | } | ||
575 | |||
576 | |||
577 | |||
578 | /** | ||
551 | * Struct containing information about a client of the service | 579 | * Struct containing information about a client of the service |
552 | * | 580 | * |
553 | * TODO: add a list of 'waiting' ports | 581 | * TODO: add a list of 'waiting' ports |
@@ -702,8 +730,8 @@ static struct GNUNET_CONTAINER_MultiHashMap *tunnels; | |||
702 | static unsigned long long n_tunnels; | 730 | static unsigned long long n_tunnels; |
703 | 731 | ||
704 | /** | 732 | /** |
705 | * Tunnels incoming, indexed by MESH_TunnelNumber | 733 | * Tunnels incoming, indexed by MESH_ChannelNumber |
706 | * (which is greater than GNUNET_MESH_LOCAL_TUNNEL_ID_SERV). | 734 | * (which is greater than GNUNET_MESH_LOCAL_CHANNEL_ID_SERV). |
707 | */ | 735 | */ |
708 | static struct GNUNET_CONTAINER_MultiHashMap32 *incoming_tunnels; | 736 | static struct GNUNET_CONTAINER_MultiHashMap32 *incoming_tunnels; |
709 | 737 | ||
@@ -765,12 +793,12 @@ static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; | |||
765 | /** | 793 | /** |
766 | * Tunnel ID for the next created tunnel (global tunnel number). | 794 | * Tunnel ID for the next created tunnel (global tunnel number). |
767 | */ | 795 | */ |
768 | static MESH_TunnelNumber next_tid; | 796 | static MESH_ChannelNumber next_tid; |
769 | 797 | ||
770 | /** | 798 | /** |
771 | * Tunnel ID for the next incoming tunnel (local tunnel number). | 799 | * Tunnel ID for the next incoming tunnel (local tunnel number). |
772 | */ | 800 | */ |
773 | static MESH_TunnelNumber next_local_tid; | 801 | static MESH_ChannelNumber next_local_tid; |
774 | 802 | ||
775 | /** | 803 | /** |
776 | * All ports clients of this peer have opened. | 804 | * All ports clients of this peer have opened. |
@@ -871,7 +899,7 @@ path_add_to_peers (struct MeshPeerPath *p, int confirmed); | |||
871 | * @return tunnel handler, NULL if doesn't exist. | 899 | * @return tunnel handler, NULL if doesn't exist. |
872 | */ | 900 | */ |
873 | static struct MeshTunnel * | 901 | static struct MeshTunnel * |
874 | tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_TunnelNumber tid); | 902 | tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_ChannelNumber tid); |
875 | 903 | ||
876 | 904 | ||
877 | /** | 905 | /** |
@@ -1162,7 +1190,7 @@ client_delete_tunnel (struct MeshClient *c, struct MeshTunnel *t) | |||
1162 | static void | 1190 | static void |
1163 | send_local_tunnel_create (struct MeshTunnel *t) | 1191 | send_local_tunnel_create (struct MeshTunnel *t) |
1164 | { | 1192 | { |
1165 | struct GNUNET_MESH_TunnelMessage msg; | 1193 | struct GNUNET_MESH_ChannelMessage msg; |
1166 | 1194 | ||
1167 | if (NULL == t->client) | 1195 | if (NULL == t->client) |
1168 | return; | 1196 | return; |
@@ -1189,7 +1217,7 @@ send_local_tunnel_create (struct MeshTunnel *t) | |||
1189 | static void | 1217 | static void |
1190 | send_local_tunnel_destroy (struct MeshTunnel *t, int fwd) | 1218 | send_local_tunnel_destroy (struct MeshTunnel *t, int fwd) |
1191 | { | 1219 | { |
1192 | struct GNUNET_MESH_TunnelMessage msg; | 1220 | struct GNUNET_MESH_ChannelMessage msg; |
1193 | struct MeshClient *c; | 1221 | struct MeshClient *c; |
1194 | 1222 | ||
1195 | c = fwd ? t->client : t->owner; | 1223 | c = fwd ? t->client : t->owner; |
@@ -2217,9 +2245,9 @@ path_add_to_peers (struct MeshPeerPath *p, int confirmed) | |||
2217 | * @return tunnel handler, NULL if doesn't exist | 2245 | * @return tunnel handler, NULL if doesn't exist |
2218 | */ | 2246 | */ |
2219 | static struct MeshTunnel * | 2247 | static struct MeshTunnel * |
2220 | tunnel_get_incoming (MESH_TunnelNumber tid) | 2248 | tunnel_get_incoming (MESH_ChannelNumber tid) |
2221 | { | 2249 | { |
2222 | GNUNET_assert (tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV); | 2250 | GNUNET_assert (tid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV); |
2223 | return GNUNET_CONTAINER_multihashmap32_get (incoming_tunnels, tid); | 2251 | return GNUNET_CONTAINER_multihashmap32_get (incoming_tunnels, tid); |
2224 | } | 2252 | } |
2225 | 2253 | ||
@@ -2233,15 +2261,15 @@ tunnel_get_incoming (MESH_TunnelNumber tid) | |||
2233 | * @return tunnel handler, NULL if doesn't exist | 2261 | * @return tunnel handler, NULL if doesn't exist |
2234 | */ | 2262 | */ |
2235 | static struct MeshTunnel * | 2263 | static struct MeshTunnel * |
2236 | tunnel_get_by_local_id (struct MeshClient *c, MESH_TunnelNumber tid) | 2264 | tunnel_get_by_local_id (struct MeshClient *c, MESH_ChannelNumber tid) |
2237 | { | 2265 | { |
2238 | if (0 == (tid & GNUNET_MESH_LOCAL_TUNNEL_ID_CLI)) | 2266 | if (0 == (tid & GNUNET_MESH_LOCAL_CHANNEL_ID_CLI)) |
2239 | { | 2267 | { |
2240 | GNUNET_break_op (0); | 2268 | GNUNET_break_op (0); |
2241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TID %X not a local tid\n", tid); | 2269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TID %X not a local tid\n", tid); |
2242 | return NULL; | 2270 | return NULL; |
2243 | } | 2271 | } |
2244 | if (tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) | 2272 | if (tid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) |
2245 | { | 2273 | { |
2246 | return tunnel_get_incoming (tid); | 2274 | return tunnel_get_incoming (tid); |
2247 | } | 2275 | } |
@@ -2261,7 +2289,7 @@ tunnel_get_by_local_id (struct MeshClient *c, MESH_TunnelNumber tid) | |||
2261 | * @return tunnel handler, NULL if doesn't exist | 2289 | * @return tunnel handler, NULL if doesn't exist |
2262 | */ | 2290 | */ |
2263 | static struct MeshTunnel * | 2291 | static struct MeshTunnel * |
2264 | tunnel_get_by_pi (GNUNET_PEER_Id pi, MESH_TunnelNumber tid) | 2292 | tunnel_get_by_pi (GNUNET_PEER_Id pi, MESH_ChannelNumber tid) |
2265 | { | 2293 | { |
2266 | struct MESH_TunnelID id; | 2294 | struct MESH_TunnelID id; |
2267 | struct GNUNET_HashCode hash; | 2295 | struct GNUNET_HashCode hash; |
@@ -2283,7 +2311,7 @@ tunnel_get_by_pi (GNUNET_PEER_Id pi, MESH_TunnelNumber tid) | |||
2283 | * @return tunnel handler, NULL if doesn't exist | 2311 | * @return tunnel handler, NULL if doesn't exist |
2284 | */ | 2312 | */ |
2285 | static struct MeshTunnel * | 2313 | static struct MeshTunnel * |
2286 | tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_TunnelNumber tid) | 2314 | tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_ChannelNumber tid) |
2287 | { | 2315 | { |
2288 | return tunnel_get_by_pi (GNUNET_PEER_search (oid), tid); | 2316 | return tunnel_get_by_pi (GNUNET_PEER_search (oid), tid); |
2289 | } | 2317 | } |
@@ -2437,7 +2465,7 @@ static void | |||
2437 | tunnel_send_data_ack (struct MeshTunnel *t, int fwd) | 2465 | tunnel_send_data_ack (struct MeshTunnel *t, int fwd) |
2438 | { | 2466 | { |
2439 | struct GNUNET_MESH_DataACK msg; | 2467 | struct GNUNET_MESH_DataACK msg; |
2440 | struct MeshTunnelReliability *rel; | 2468 | struct MeshChannelReliability *rel; |
2441 | struct MeshReliableMessage *copy; | 2469 | struct MeshReliableMessage *copy; |
2442 | GNUNET_PEER_Id hop; | 2470 | GNUNET_PEER_Id hop; |
2443 | uint64_t mask; | 2471 | uint64_t mask; |
@@ -2494,7 +2522,7 @@ tunnel_send_data_ack (struct MeshTunnel *t, int fwd) | |||
2494 | static void | 2522 | static void |
2495 | tunnel_send_ack (struct MeshTunnel *t, uint16_t type, int fwd) | 2523 | tunnel_send_ack (struct MeshTunnel *t, uint16_t type, int fwd) |
2496 | { | 2524 | { |
2497 | struct MeshTunnelReliability *rel; | 2525 | struct MeshChannelReliability *rel; |
2498 | struct MeshFlowControl *next_fc; | 2526 | struct MeshFlowControl *next_fc; |
2499 | struct MeshFlowControl *prev_fc; | 2527 | struct MeshFlowControl *prev_fc; |
2500 | struct MeshClient *c; | 2528 | struct MeshClient *c; |
@@ -2597,7 +2625,7 @@ tunnel_send_ack (struct MeshTunnel *t, uint16_t type, int fwd) | |||
2597 | static void | 2625 | static void |
2598 | tunnel_send_client_to_tid (struct MeshTunnel *t, | 2626 | tunnel_send_client_to_tid (struct MeshTunnel *t, |
2599 | const struct GNUNET_MESH_Data *msg, | 2627 | const struct GNUNET_MESH_Data *msg, |
2600 | struct MeshClient *c, MESH_TunnelNumber tid) | 2628 | struct MeshClient *c, MESH_ChannelNumber tid) |
2601 | { | 2629 | { |
2602 | struct GNUNET_MESH_LocalData *copy; | 2630 | struct GNUNET_MESH_LocalData *copy; |
2603 | uint16_t size = ntohs (msg->header.size) - sizeof (struct GNUNET_MESH_Data); | 2631 | uint16_t size = ntohs (msg->header.size) - sizeof (struct GNUNET_MESH_Data); |
@@ -2651,7 +2679,7 @@ tunnel_send_client_data (struct MeshTunnel *t, | |||
2651 | */ | 2679 | */ |
2652 | static void | 2680 | static void |
2653 | tunnel_send_client_buffered_data (struct MeshTunnel *t, struct MeshClient *c, | 2681 | tunnel_send_client_buffered_data (struct MeshTunnel *t, struct MeshClient *c, |
2654 | struct MeshTunnelReliability *rel) | 2682 | struct MeshChannelReliability *rel) |
2655 | { | 2683 | { |
2656 | ; | 2684 | ; |
2657 | struct MeshReliableMessage *copy; | 2685 | struct MeshReliableMessage *copy; |
@@ -2697,7 +2725,7 @@ tunnel_send_client_buffered_data (struct MeshTunnel *t, struct MeshClient *c, | |||
2697 | static void | 2725 | static void |
2698 | tunnel_add_buffered_data (struct MeshTunnel *t, | 2726 | tunnel_add_buffered_data (struct MeshTunnel *t, |
2699 | const struct GNUNET_MESH_Data *msg, | 2727 | const struct GNUNET_MESH_Data *msg, |
2700 | struct MeshTunnelReliability *rel) | 2728 | struct MeshChannelReliability *rel) |
2701 | { | 2729 | { |
2702 | struct MeshReliableMessage *copy; | 2730 | struct MeshReliableMessage *copy; |
2703 | struct MeshReliableMessage *prev; | 2731 | struct MeshReliableMessage *prev; |
@@ -2742,7 +2770,7 @@ tunnel_add_buffered_data (struct MeshTunnel *t, | |||
2742 | static void | 2770 | static void |
2743 | tunnel_free_reliable_message (struct MeshReliableMessage *copy) | 2771 | tunnel_free_reliable_message (struct MeshReliableMessage *copy) |
2744 | { | 2772 | { |
2745 | struct MeshTunnelReliability *rel; | 2773 | struct MeshChannelReliability *rel; |
2746 | struct GNUNET_TIME_Relative time; | 2774 | struct GNUNET_TIME_Relative time; |
2747 | 2775 | ||
2748 | rel = copy->rel; | 2776 | rel = copy->rel; |
@@ -2772,7 +2800,7 @@ tunnel_free_reliable_message (struct MeshReliableMessage *copy) | |||
2772 | * @param rel Reliability data for a tunnel. | 2800 | * @param rel Reliability data for a tunnel. |
2773 | */ | 2801 | */ |
2774 | static void | 2802 | static void |
2775 | tunnel_free_reliable_all (struct MeshTunnelReliability *rel) | 2803 | tunnel_free_reliable_all (struct MeshChannelReliability *rel) |
2776 | { | 2804 | { |
2777 | struct MeshReliableMessage *copy; | 2805 | struct MeshReliableMessage *copy; |
2778 | struct MeshReliableMessage *next; | 2806 | struct MeshReliableMessage *next; |
@@ -2808,7 +2836,7 @@ tunnel_free_reliable_all (struct MeshTunnelReliability *rel) | |||
2808 | static void | 2836 | static void |
2809 | tunnel_free_sent_reliable (struct MeshTunnel *t, | 2837 | tunnel_free_sent_reliable (struct MeshTunnel *t, |
2810 | const struct GNUNET_MESH_DataACK *msg, | 2838 | const struct GNUNET_MESH_DataACK *msg, |
2811 | struct MeshTunnelReliability *rel) | 2839 | struct MeshChannelReliability *rel) |
2812 | { | 2840 | { |
2813 | struct MeshReliableMessage *copy; | 2841 | struct MeshReliableMessage *copy; |
2814 | struct MeshReliableMessage *next; | 2842 | struct MeshReliableMessage *next; |
@@ -2881,7 +2909,7 @@ static void | |||
2881 | tunnel_retransmit_message (void *cls, | 2909 | tunnel_retransmit_message (void *cls, |
2882 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 2910 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
2883 | { | 2911 | { |
2884 | struct MeshTunnelReliability *rel = cls; | 2912 | struct MeshChannelReliability *rel = cls; |
2885 | struct MeshReliableMessage *copy; | 2913 | struct MeshReliableMessage *copy; |
2886 | struct MeshFlowControl *fc; | 2914 | struct MeshFlowControl *fc; |
2887 | struct MeshPeerQueue *q; | 2915 | struct MeshPeerQueue *q; |
@@ -3258,9 +3286,9 @@ fc_init (struct MeshFlowControl *fc) | |||
3258 | */ | 3286 | */ |
3259 | static struct MeshTunnel * | 3287 | static struct MeshTunnel * |
3260 | tunnel_new (GNUNET_PEER_Id owner, | 3288 | tunnel_new (GNUNET_PEER_Id owner, |
3261 | MESH_TunnelNumber tid, | 3289 | MESH_ChannelNumber tid, |
3262 | struct MeshClient *client, | 3290 | struct MeshClient *client, |
3263 | MESH_TunnelNumber local) | 3291 | MESH_ChannelNumber local) |
3264 | { | 3292 | { |
3265 | struct MeshTunnel *t; | 3293 | struct MeshTunnel *t; |
3266 | struct GNUNET_HashCode hash; | 3294 | struct GNUNET_HashCode hash; |
@@ -3953,7 +3981,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3953 | unsigned int own_pos; | 3981 | unsigned int own_pos; |
3954 | uint16_t size; | 3982 | uint16_t size; |
3955 | uint16_t i; | 3983 | uint16_t i; |
3956 | MESH_TunnelNumber tid; | 3984 | MESH_ChannelNumber tid; |
3957 | struct GNUNET_MESH_CreateTunnel *msg; | 3985 | struct GNUNET_MESH_CreateTunnel *msg; |
3958 | struct GNUNET_PeerIdentity *pi; | 3986 | struct GNUNET_PeerIdentity *pi; |
3959 | struct MeshPeerPath *path; | 3987 | struct MeshPeerPath *path; |
@@ -4085,14 +4113,14 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4085 | { | 4113 | { |
4086 | /* Assign local tid */ | 4114 | /* Assign local tid */ |
4087 | while (NULL != tunnel_get_incoming (next_local_tid)) | 4115 | while (NULL != tunnel_get_incoming (next_local_tid)) |
4088 | next_local_tid = (next_local_tid + 1) | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV; | 4116 | next_local_tid = (next_local_tid + 1) | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; |
4089 | t->local_tid_dest = next_local_tid++; | 4117 | t->local_tid_dest = next_local_tid++; |
4090 | next_local_tid = next_local_tid | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV; | 4118 | next_local_tid = next_local_tid | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; |
4091 | 4119 | ||
4092 | if (GNUNET_YES == t->reliable) | 4120 | if (GNUNET_YES == t->reliable) |
4093 | { | 4121 | { |
4094 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); | 4122 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); |
4095 | t->bck_rel = GNUNET_malloc (sizeof (struct MeshTunnelReliability)); | 4123 | t->bck_rel = GNUNET_malloc (sizeof (struct MeshChannelReliability)); |
4096 | t->bck_rel->t = t; | 4124 | t->bck_rel->t = t; |
4097 | t->bck_rel->expected_delay = MESH_RETRANSMIT_TIME; | 4125 | t->bck_rel->expected_delay = MESH_RETRANSMIT_TIME; |
4098 | } | 4126 | } |
@@ -4278,7 +4306,7 @@ handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4278 | 1, GNUNET_NO); | 4306 | 1, GNUNET_NO); |
4279 | return GNUNET_OK; | 4307 | return GNUNET_OK; |
4280 | } | 4308 | } |
4281 | if (t->local_tid_dest >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) | 4309 | if (t->local_tid_dest >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) |
4282 | { | 4310 | { |
4283 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "INCOMING TUNNEL %X %X\n", | 4311 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "INCOMING TUNNEL %X %X\n", |
4284 | t->local_tid, t->local_tid_dest); | 4312 | t->local_tid, t->local_tid_dest); |
@@ -4330,7 +4358,7 @@ handle_mesh_data (const struct GNUNET_PeerIdentity *peer, | |||
4330 | { | 4358 | { |
4331 | struct GNUNET_MESH_Data *msg; | 4359 | struct GNUNET_MESH_Data *msg; |
4332 | struct MeshFlowControl *fc; | 4360 | struct MeshFlowControl *fc; |
4333 | struct MeshTunnelReliability *rel; | 4361 | struct MeshChannelReliability *rel; |
4334 | struct MeshTunnel *t; | 4362 | struct MeshTunnel *t; |
4335 | struct MeshClient *c; | 4363 | struct MeshClient *c; |
4336 | GNUNET_PEER_Id hop; | 4364 | GNUNET_PEER_Id hop; |
@@ -4517,7 +4545,7 @@ handle_mesh_data_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4517 | const struct GNUNET_MessageHeader *message) | 4545 | const struct GNUNET_MessageHeader *message) |
4518 | { | 4546 | { |
4519 | struct GNUNET_MESH_DataACK *msg; | 4547 | struct GNUNET_MESH_DataACK *msg; |
4520 | struct MeshTunnelReliability *rel; | 4548 | struct MeshChannelReliability *rel; |
4521 | struct MeshReliableMessage *copy; | 4549 | struct MeshReliableMessage *copy; |
4522 | struct MeshReliableMessage *next; | 4550 | struct MeshReliableMessage *next; |
4523 | struct MeshTunnel *t; | 4551 | struct MeshTunnel *t; |
@@ -5064,11 +5092,11 @@ static void | |||
5064 | handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, | 5092 | handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, |
5065 | const struct GNUNET_MessageHeader *message) | 5093 | const struct GNUNET_MessageHeader *message) |
5066 | { | 5094 | { |
5067 | struct GNUNET_MESH_TunnelMessage *t_msg; | 5095 | struct GNUNET_MESH_ChannelMessage *t_msg; |
5068 | struct MeshPeer *peer_info; | 5096 | struct MeshPeer *peer_info; |
5069 | struct MeshTunnel *t; | 5097 | struct MeshTunnel *t; |
5070 | struct MeshClient *c; | 5098 | struct MeshClient *c; |
5071 | MESH_TunnelNumber tid; | 5099 | MESH_ChannelNumber tid; |
5072 | 5100 | ||
5073 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new tunnel requested\n"); | 5101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new tunnel requested\n"); |
5074 | 5102 | ||
@@ -5082,17 +5110,17 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, | |||
5082 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id); | 5110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id); |
5083 | 5111 | ||
5084 | /* Message size sanity check */ | 5112 | /* Message size sanity check */ |
5085 | if (sizeof (struct GNUNET_MESH_TunnelMessage) != ntohs (message->size)) | 5113 | if (sizeof (struct GNUNET_MESH_ChannelMessage) != ntohs (message->size)) |
5086 | { | 5114 | { |
5087 | GNUNET_break (0); | 5115 | GNUNET_break (0); |
5088 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 5116 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
5089 | return; | 5117 | return; |
5090 | } | 5118 | } |
5091 | 5119 | ||
5092 | t_msg = (struct GNUNET_MESH_TunnelMessage *) message; | 5120 | t_msg = (struct GNUNET_MESH_ChannelMessage *) message; |
5093 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n", | 5121 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n", |
5094 | GNUNET_i2s (&t_msg->peer), ntohl (t_msg->port)); | 5122 | GNUNET_i2s (&t_msg->peer), ntohl (t_msg->port)); |
5095 | tid = ntohl (t_msg->tunnel_id); | 5123 | tid = ntohl (t_msg->channel_id); |
5096 | /* Sanity check for duplicate tunnel IDs */ | 5124 | /* Sanity check for duplicate tunnel IDs */ |
5097 | if (NULL != tunnel_get_by_local_id (c, tid)) | 5125 | if (NULL != tunnel_get_by_local_id (c, tid)) |
5098 | { | 5126 | { |
@@ -5103,9 +5131,9 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, | |||
5103 | 5131 | ||
5104 | /* Create tunnel */ | 5132 | /* Create tunnel */ |
5105 | while (NULL != tunnel_get_by_pi (myid, next_tid)) | 5133 | while (NULL != tunnel_get_by_pi (myid, next_tid)) |
5106 | next_tid = (next_tid + 1) & ~GNUNET_MESH_LOCAL_TUNNEL_ID_CLI; | 5134 | next_tid = (next_tid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; |
5107 | t = tunnel_new (myid, next_tid, c, tid); | 5135 | t = tunnel_new (myid, next_tid, c, tid); |
5108 | next_tid = (next_tid + 1) & ~GNUNET_MESH_LOCAL_TUNNEL_ID_CLI; | 5136 | next_tid = (next_tid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; |
5109 | if (NULL == t) | 5137 | if (NULL == t) |
5110 | { | 5138 | { |
5111 | GNUNET_break (0); | 5139 | GNUNET_break (0); |
@@ -5117,7 +5145,7 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, | |||
5117 | if (GNUNET_YES == t->reliable) | 5145 | if (GNUNET_YES == t->reliable) |
5118 | { | 5146 | { |
5119 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); | 5147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); |
5120 | t->fwd_rel = GNUNET_malloc (sizeof (struct MeshTunnelReliability)); | 5148 | t->fwd_rel = GNUNET_malloc (sizeof (struct MeshChannelReliability)); |
5121 | t->fwd_rel->t = t; | 5149 | t->fwd_rel->t = t; |
5122 | t->fwd_rel->expected_delay = MESH_RETRANSMIT_TIME; | 5150 | t->fwd_rel->expected_delay = MESH_RETRANSMIT_TIME; |
5123 | } | 5151 | } |
@@ -5145,10 +5173,10 @@ static void | |||
5145 | handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, | 5173 | handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, |
5146 | const struct GNUNET_MessageHeader *message) | 5174 | const struct GNUNET_MessageHeader *message) |
5147 | { | 5175 | { |
5148 | struct GNUNET_MESH_TunnelMessage *tunnel_msg; | 5176 | struct GNUNET_MESH_ChannelMessage *tunnel_msg; |
5149 | struct MeshClient *c; | 5177 | struct MeshClient *c; |
5150 | struct MeshTunnel *t; | 5178 | struct MeshTunnel *t; |
5151 | MESH_TunnelNumber tid; | 5179 | MESH_ChannelNumber tid; |
5152 | 5180 | ||
5153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5154 | "Got a DESTROY TUNNEL from client!\n"); | 5182 | "Got a DESTROY TUNNEL from client!\n"); |
@@ -5163,17 +5191,17 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, | |||
5163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id); | 5191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id); |
5164 | 5192 | ||
5165 | /* Message sanity check */ | 5193 | /* Message sanity check */ |
5166 | if (sizeof (struct GNUNET_MESH_TunnelMessage) != ntohs (message->size)) | 5194 | if (sizeof (struct GNUNET_MESH_ChannelMessage) != ntohs (message->size)) |
5167 | { | 5195 | { |
5168 | GNUNET_break (0); | 5196 | GNUNET_break (0); |
5169 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 5197 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
5170 | return; | 5198 | return; |
5171 | } | 5199 | } |
5172 | 5200 | ||
5173 | tunnel_msg = (struct GNUNET_MESH_TunnelMessage *) message; | 5201 | tunnel_msg = (struct GNUNET_MESH_ChannelMessage *) message; |
5174 | 5202 | ||
5175 | /* Retrieve tunnel */ | 5203 | /* Retrieve tunnel */ |
5176 | tid = ntohl (tunnel_msg->tunnel_id); | 5204 | tid = ntohl (tunnel_msg->channel_id); |
5177 | t = tunnel_get_by_local_id (c, tid); | 5205 | t = tunnel_get_by_local_id (c, tid); |
5178 | if (NULL == t) | 5206 | if (NULL == t) |
5179 | { | 5207 | { |
@@ -5185,11 +5213,11 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, | |||
5185 | 5213 | ||
5186 | /* Cleanup after the tunnel */ | 5214 | /* Cleanup after the tunnel */ |
5187 | client_delete_tunnel (c, t); | 5215 | client_delete_tunnel (c, t); |
5188 | if (c == t->client && GNUNET_MESH_LOCAL_TUNNEL_ID_SERV <= tid) | 5216 | if (c == t->client && GNUNET_MESH_LOCAL_CHANNEL_ID_SERV <= tid) |
5189 | { | 5217 | { |
5190 | t->client = NULL; | 5218 | t->client = NULL; |
5191 | } | 5219 | } |
5192 | else if (c == t->owner && GNUNET_MESH_LOCAL_TUNNEL_ID_SERV > tid) | 5220 | else if (c == t->owner && GNUNET_MESH_LOCAL_CHANNEL_ID_SERV > tid) |
5193 | { | 5221 | { |
5194 | peer_remove_tunnel (peer_get_short (t->dest), t); | 5222 | peer_remove_tunnel (peer_get_short (t->dest), t); |
5195 | t->owner = NULL; | 5223 | t->owner = NULL; |
@@ -5225,7 +5253,7 @@ handle_local_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
5225 | struct MeshClient *c; | 5253 | struct MeshClient *c; |
5226 | struct MeshTunnel *t; | 5254 | struct MeshTunnel *t; |
5227 | struct MeshFlowControl *fc; | 5255 | struct MeshFlowControl *fc; |
5228 | MESH_TunnelNumber tid; | 5256 | MESH_ChannelNumber tid; |
5229 | size_t size; | 5257 | size_t size; |
5230 | 5258 | ||
5231 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5259 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -5262,11 +5290,11 @@ handle_local_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
5262 | } | 5290 | } |
5263 | 5291 | ||
5264 | /* Is the client in the tunnel? */ | 5292 | /* Is the client in the tunnel? */ |
5265 | if ( !( (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV && | 5293 | if ( !( (tid < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV && |
5266 | t->owner && | 5294 | t->owner && |
5267 | t->owner->handle == client) | 5295 | t->owner->handle == client) |
5268 | || | 5296 | || |
5269 | (tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV && | 5297 | (tid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV && |
5270 | t->client && | 5298 | t->client && |
5271 | t->client->handle == client) ) ) | 5299 | t->client->handle == client) ) ) |
5272 | { | 5300 | { |
@@ -5282,13 +5310,13 @@ handle_local_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
5282 | struct GNUNET_MESH_Data *payload; | 5310 | struct GNUNET_MESH_Data *payload; |
5283 | char cbuf[sizeof(struct GNUNET_MESH_Data) + size]; | 5311 | char cbuf[sizeof(struct GNUNET_MESH_Data) + size]; |
5284 | 5312 | ||
5285 | fc = tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV ? &t->prev_fc : &t->next_fc; | 5313 | fc = tid < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV ? &t->prev_fc : &t->next_fc; |
5286 | if (GNUNET_YES == t->reliable) | 5314 | if (GNUNET_YES == t->reliable) |
5287 | { | 5315 | { |
5288 | struct MeshTunnelReliability *rel; | 5316 | struct MeshChannelReliability *rel; |
5289 | struct MeshReliableMessage *copy; | 5317 | struct MeshReliableMessage *copy; |
5290 | 5318 | ||
5291 | rel = (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) ? t->fwd_rel : t->bck_rel; | 5319 | rel = (tid < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) ? t->fwd_rel : t->bck_rel; |
5292 | copy = GNUNET_malloc (sizeof (struct MeshReliableMessage) | 5320 | copy = GNUNET_malloc (sizeof (struct MeshReliableMessage) |
5293 | + sizeof(struct GNUNET_MESH_Data) | 5321 | + sizeof(struct GNUNET_MESH_Data) |
5294 | + size); | 5322 | + size); |
@@ -5319,7 +5347,7 @@ handle_local_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
5319 | } | 5347 | } |
5320 | memcpy (&payload[1], &data_msg[1], size); | 5348 | memcpy (&payload[1], &data_msg[1], size); |
5321 | payload->header.size = htons (sizeof (struct GNUNET_MESH_Data) + size); | 5349 | payload->header.size = htons (sizeof (struct GNUNET_MESH_Data) + size); |
5322 | payload->header.type = htons (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV ? | 5350 | payload->header.type = htons (tid < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV ? |
5323 | GNUNET_MESSAGE_TYPE_MESH_UNICAST : | 5351 | GNUNET_MESSAGE_TYPE_MESH_UNICAST : |
5324 | GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN); | 5352 | GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN); |
5325 | GNUNET_PEER_resolve(t->id.oid, &payload->oid);; | 5353 | GNUNET_PEER_resolve(t->id.oid, &payload->oid);; |
@@ -5328,7 +5356,7 @@ handle_local_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
5328 | payload->pid = htonl (fc->last_pid_recv + 1); | 5356 | payload->pid = htonl (fc->last_pid_recv + 1); |
5329 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5330 | " calling generic handler...\n"); | 5358 | " calling generic handler...\n"); |
5331 | if (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) | 5359 | if (tid < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) |
5332 | handle_mesh_unicast (NULL, &my_full_id, &payload->header); | 5360 | handle_mesh_unicast (NULL, &my_full_id, &payload->header); |
5333 | else | 5361 | else |
5334 | handle_mesh_to_orig (NULL, &my_full_id, &payload->header); | 5362 | handle_mesh_to_orig (NULL, &my_full_id, &payload->header); |
@@ -5354,7 +5382,7 @@ handle_local_ack (void *cls, struct GNUNET_SERVER_Client *client, | |||
5354 | struct GNUNET_MESH_LocalAck *msg; | 5382 | struct GNUNET_MESH_LocalAck *msg; |
5355 | struct MeshTunnel *t; | 5383 | struct MeshTunnel *t; |
5356 | struct MeshClient *c; | 5384 | struct MeshClient *c; |
5357 | MESH_TunnelNumber tid; | 5385 | MESH_ChannelNumber tid; |
5358 | 5386 | ||
5359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a local ACK\n"); | 5387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a local ACK\n"); |
5360 | /* Sanity check for client registration */ | 5388 | /* Sanity check for client registration */ |
@@ -5369,7 +5397,7 @@ handle_local_ack (void *cls, struct GNUNET_SERVER_Client *client, | |||
5369 | msg = (struct GNUNET_MESH_LocalAck *) message; | 5397 | msg = (struct GNUNET_MESH_LocalAck *) message; |
5370 | 5398 | ||
5371 | /* Tunnel exists? */ | 5399 | /* Tunnel exists? */ |
5372 | tid = ntohl (msg->tunnel_id); | 5400 | tid = ntohl (msg->channel_id); |
5373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " on tunnel %X\n", tid); | 5401 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " on tunnel %X\n", tid); |
5374 | t = tunnel_get_by_local_id (c, tid); | 5402 | t = tunnel_get_by_local_id (c, tid); |
5375 | if (NULL == t) | 5403 | if (NULL == t) |
@@ -5382,7 +5410,7 @@ handle_local_ack (void *cls, struct GNUNET_SERVER_Client *client, | |||
5382 | } | 5410 | } |
5383 | 5411 | ||
5384 | /* Does client own tunnel? I.E: Is this an ACK for BCK traffic? */ | 5412 | /* Does client own tunnel? I.E: Is this an ACK for BCK traffic? */ |
5385 | if (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) | 5413 | if (tid < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) |
5386 | { | 5414 | { |
5387 | /* The client owns the tunnel, ACK is for data to_origin, send BCK ACK. */ | 5415 | /* The client owns the tunnel, ACK is for data to_origin, send BCK ACK. */ |
5388 | t->prev_fc.last_ack_recv++; | 5416 | t->prev_fc.last_ack_recv++; |
@@ -5422,7 +5450,7 @@ monitor_all_tunnels_iterator (void *cls, | |||
5422 | 5450 | ||
5423 | msg = GNUNET_malloc (sizeof(struct GNUNET_MESH_LocalMonitor)); | 5451 | msg = GNUNET_malloc (sizeof(struct GNUNET_MESH_LocalMonitor)); |
5424 | GNUNET_PEER_resolve(t->id.oid, &msg->owner); | 5452 | GNUNET_PEER_resolve(t->id.oid, &msg->owner); |
5425 | msg->tunnel_id = htonl (t->id.tid); | 5453 | msg->channel_id = htonl (t->id.tid); |
5426 | msg->header.size = htons (sizeof (struct GNUNET_MESH_LocalMonitor)); | 5454 | msg->header.size = htons (sizeof (struct GNUNET_MESH_LocalMonitor)); |
5427 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS); | 5455 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS); |
5428 | GNUNET_PEER_resolve (t->dest, &msg->destination); | 5456 | GNUNET_PEER_resolve (t->dest, &msg->destination); |
@@ -5500,8 +5528,8 @@ handle_local_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, | |||
5500 | "Received tunnel info request from client %u for tunnel %s[%X]\n", | 5528 | "Received tunnel info request from client %u for tunnel %s[%X]\n", |
5501 | c->id, | 5529 | c->id, |
5502 | &msg->owner, | 5530 | &msg->owner, |
5503 | ntohl (msg->tunnel_id)); | 5531 | ntohl (msg->channel_id)); |
5504 | t = tunnel_get (&msg->owner, ntohl (msg->tunnel_id)); | 5532 | t = tunnel_get (&msg->owner, ntohl (msg->channel_id)); |
5505 | if (NULL == t) | 5533 | if (NULL == t) |
5506 | { | 5534 | { |
5507 | /* We don't know the tunnel FIXME */ | 5535 | /* We don't know the tunnel FIXME */ |
@@ -5539,10 +5567,10 @@ static struct GNUNET_SERVER_MessageHandler client_handlers[] = { | |||
5539 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0}, | 5567 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0}, |
5540 | {&handle_local_tunnel_create, NULL, | 5568 | {&handle_local_tunnel_create, NULL, |
5541 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE, | 5569 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE, |
5542 | sizeof (struct GNUNET_MESH_TunnelMessage)}, | 5570 | sizeof (struct GNUNET_MESH_ChannelMessage)}, |
5543 | {&handle_local_tunnel_destroy, NULL, | 5571 | {&handle_local_tunnel_destroy, NULL, |
5544 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY, | 5572 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY, |
5545 | sizeof (struct GNUNET_MESH_TunnelMessage)}, | 5573 | sizeof (struct GNUNET_MESH_ChannelMessage)}, |
5546 | {&handle_local_data, NULL, | 5574 | {&handle_local_data, NULL, |
5547 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0}, | 5575 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0}, |
5548 | {&handle_local_ack, NULL, | 5576 | {&handle_local_ack, NULL, |
@@ -5971,7 +5999,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
5971 | return; | 5999 | return; |
5972 | } | 6000 | } |
5973 | next_tid = 0; | 6001 | next_tid = 0; |
5974 | next_local_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_SERV; | 6002 | next_local_tid = GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; |
5975 | announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, cls); | 6003 | announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, cls); |
5976 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mesh service running\n"); | 6004 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mesh service running\n"); |
5977 | } | 6005 | } |