aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_tunnel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/gnunet-service-mesh_tunnel.c')
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c612
1 files changed, 306 insertions, 306 deletions
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c
index ffe4bd624..f2be27bf5 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.c
+++ b/src/mesh/gnunet-service-mesh_tunnel.c
@@ -24,15 +24,15 @@
24#include "gnunet_signatures.h" 24#include "gnunet_signatures.h"
25#include "gnunet_statistics_service.h" 25#include "gnunet_statistics_service.h"
26 26
27#include "mesh_protocol.h" 27#include "cadet_protocol.h"
28#include "mesh_path.h" 28#include "cadet_path.h"
29 29
30#include "gnunet-service-mesh_tunnel.h" 30#include "gnunet-service-cadet_tunnel.h"
31#include "gnunet-service-mesh_connection.h" 31#include "gnunet-service-cadet_connection.h"
32#include "gnunet-service-mesh_channel.h" 32#include "gnunet-service-cadet_channel.h"
33#include "gnunet-service-mesh_peer.h" 33#include "gnunet-service-cadet_peer.h"
34 34
35#define LOG(level, ...) GNUNET_log_from(level,"mesh-tun",__VA_ARGS__) 35#define LOG(level, ...) GNUNET_log_from(level,"cadet-tun",__VA_ARGS__)
36 36
37#define REKEY_WAIT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) 37#define REKEY_WAIT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
38 38
@@ -42,33 +42,33 @@
42/******************************** STRUCTS **********************************/ 42/******************************** STRUCTS **********************************/
43/******************************************************************************/ 43/******************************************************************************/
44 44
45struct MeshTChannel 45struct CadetTChannel
46{ 46{
47 struct MeshTChannel *next; 47 struct CadetTChannel *next;
48 struct MeshTChannel *prev; 48 struct CadetTChannel *prev;
49 struct MeshChannel *ch; 49 struct CadetChannel *ch;
50}; 50};
51 51
52 52
53/** 53/**
54 * Connection list and metadata. 54 * Connection list and metadata.
55 */ 55 */
56struct MeshTConnection 56struct CadetTConnection
57{ 57{
58 /** 58 /**
59 * Next in DLL. 59 * Next in DLL.
60 */ 60 */
61 struct MeshTConnection *next; 61 struct CadetTConnection *next;
62 62
63 /** 63 /**
64 * Prev in DLL. 64 * Prev in DLL.
65 */ 65 */
66 struct MeshTConnection *prev; 66 struct CadetTConnection *prev;
67 67
68 /** 68 /**
69 * Connection handle. 69 * Connection handle.
70 */ 70 */
71 struct MeshConnection *c; 71 struct CadetConnection *c;
72 72
73 /** 73 /**
74 * Creation time, to keep oldest connection alive. 74 * Creation time, to keep oldest connection alive.
@@ -84,7 +84,7 @@ struct MeshTConnection
84/** 84/**
85 * Structure used during a Key eXchange. 85 * Structure used during a Key eXchange.
86 */ 86 */
87struct MeshTunnelKXCtx 87struct CadetTunnelKXCtx
88{ 88{
89 /** 89 /**
90 * Decryption ("their") old key, for decrypting traffic sent by the 90 * Decryption ("their") old key, for decrypting traffic sent by the
@@ -101,27 +101,27 @@ struct MeshTunnelKXCtx
101/** 101/**
102 * Struct containing all information regarding a tunnel to a peer. 102 * Struct containing all information regarding a tunnel to a peer.
103 */ 103 */
104struct MeshTunnel3 104struct CadetTunnel3
105{ 105{
106 /** 106 /**
107 * Endpoint of the tunnel. 107 * Endpoint of the tunnel.
108 */ 108 */
109 struct MeshPeer *peer; 109 struct CadetPeer *peer;
110 110
111 /** 111 /**
112 * State of the tunnel connectivity. 112 * State of the tunnel connectivity.
113 */ 113 */
114 enum MeshTunnel3CState cstate; 114 enum CadetTunnel3CState cstate;
115 115
116 /** 116 /**
117 * State of the tunnel encryption. 117 * State of the tunnel encryption.
118 */ 118 */
119 enum MeshTunnel3EState estate; 119 enum CadetTunnel3EState estate;
120 120
121 /** 121 /**
122 * Key eXchange context. 122 * Key eXchange context.
123 */ 123 */
124 struct MeshTunnelKXCtx *kx_ctx; 124 struct CadetTunnelKXCtx *kx_ctx;
125 125
126 /** 126 /**
127 * Encryption ("our") key. 127 * Encryption ("our") key.
@@ -141,8 +141,8 @@ struct MeshTunnel3
141 /** 141 /**
142 * Paths that are actively used to reach the destination peer. 142 * Paths that are actively used to reach the destination peer.
143 */ 143 */
144 struct MeshTConnection *connection_head; 144 struct CadetTConnection *connection_head;
145 struct MeshTConnection *connection_tail; 145 struct CadetTConnection *connection_tail;
146 146
147 /** 147 /**
148 * Next connection number. 148 * Next connection number.
@@ -152,13 +152,13 @@ struct MeshTunnel3
152 /** 152 /**
153 * Channels inside this tunnel. 153 * Channels inside this tunnel.
154 */ 154 */
155 struct MeshTChannel *channel_head; 155 struct CadetTChannel *channel_head;
156 struct MeshTChannel *channel_tail; 156 struct CadetTChannel *channel_tail;
157 157
158 /** 158 /**
159 * Channel ID for the next created channel. 159 * Channel ID for the next created channel.
160 */ 160 */
161 MESH_ChannelNumber next_chid; 161 CADET_ChannelNumber next_chid;
162 162
163 /** 163 /**
164 * Destroy flag: if true, destroy on last message. 164 * Destroy flag: if true, destroy on last message.
@@ -168,31 +168,31 @@ struct MeshTunnel3
168 /** 168 /**
169 * Queued messages, to transmit once tunnel gets connected. 169 * Queued messages, to transmit once tunnel gets connected.
170 */ 170 */
171 struct MeshTunnelDelayed *tq_head; 171 struct CadetTunnelDelayed *tq_head;
172 struct MeshTunnelDelayed *tq_tail; 172 struct CadetTunnelDelayed *tq_tail;
173}; 173};
174 174
175 175
176/** 176/**
177 * Struct used to save messages in a non-ready tunnel to send once connected. 177 * Struct used to save messages in a non-ready tunnel to send once connected.
178 */ 178 */
179struct MeshTunnelDelayed 179struct CadetTunnelDelayed
180{ 180{
181 /** 181 /**
182 * DLL 182 * DLL
183 */ 183 */
184 struct MeshTunnelDelayed *next; 184 struct CadetTunnelDelayed *next;
185 struct MeshTunnelDelayed *prev; 185 struct CadetTunnelDelayed *prev;
186 186
187 /** 187 /**
188 * Tunnel. 188 * Tunnel.
189 */ 189 */
190 struct MeshTunnel3 *t; 190 struct CadetTunnel3 *t;
191 191
192 /** 192 /**
193 * Tunnel queue given to the channel to cancel request. Update on send_queued. 193 * Tunnel queue given to the channel to cancel request. Update on send_queued.
194 */ 194 */
195 struct MeshTunnel3Queue *tq; 195 struct CadetTunnel3Queue *tq;
196 196
197 /** 197 /**
198 * Message to send. 198 * Message to send.
@@ -204,17 +204,17 @@ struct MeshTunnelDelayed
204/** 204/**
205 * Handle for messages queued but not yet sent. 205 * Handle for messages queued but not yet sent.
206 */ 206 */
207struct MeshTunnel3Queue 207struct CadetTunnel3Queue
208{ 208{
209 /** 209 /**
210 * Connection queue handle, to cancel if necessary. 210 * Connection queue handle, to cancel if necessary.
211 */ 211 */
212 struct MeshConnectionQueue *cq; 212 struct CadetConnectionQueue *cq;
213 213
214 /** 214 /**
215 * Handle in case message hasn't been given to a connection yet. 215 * Handle in case message hasn't been given to a connection yet.
216 */ 216 */
217 struct MeshTunnelDelayed *tqd; 217 struct CadetTunnelDelayed *tqd;
218 218
219 /** 219 /**
220 * Continuation to call once sent. 220 * Continuation to call once sent.
@@ -278,7 +278,7 @@ static struct GNUNET_CRYPTO_EcdhePrivateKey *my_ephemeral_key;
278/** 278/**
279 * Cached message used to perform a key exchange. 279 * Cached message used to perform a key exchange.
280 */ 280 */
281static struct GNUNET_MESH_KX_Ephemeral kx_msg; 281static struct GNUNET_CADET_KX_Ephemeral kx_msg;
282 282
283/** 283/**
284 * Task to generate a new ephemeral key. 284 * Task to generate a new ephemeral key.
@@ -302,20 +302,20 @@ static struct GNUNET_TIME_Relative rekey_period;
302 * @return String representation. 302 * @return String representation.
303 */ 303 */
304static const char * 304static const char *
305cstate2s (enum MeshTunnel3CState cs) 305cstate2s (enum CadetTunnel3CState cs)
306{ 306{
307 static char buf[128]; 307 static char buf[128];
308 308
309 switch (cs) 309 switch (cs)
310 { 310 {
311 case MESH_TUNNEL3_NEW: 311 case CADET_TUNNEL3_NEW:
312 return "MESH_TUNNEL3_NEW"; 312 return "CADET_TUNNEL3_NEW";
313 case MESH_TUNNEL3_SEARCHING: 313 case CADET_TUNNEL3_SEARCHING:
314 return "MESH_TUNNEL3_SEARCHING"; 314 return "CADET_TUNNEL3_SEARCHING";
315 case MESH_TUNNEL3_WAITING: 315 case CADET_TUNNEL3_WAITING:
316 return "MESH_TUNNEL3_WAITING"; 316 return "CADET_TUNNEL3_WAITING";
317 case MESH_TUNNEL3_READY: 317 case CADET_TUNNEL3_READY:
318 return "MESH_TUNNEL3_READY"; 318 return "CADET_TUNNEL3_READY";
319 319
320 default: 320 default:
321 sprintf (buf, "%u (UNKNOWN STATE)", cs); 321 sprintf (buf, "%u (UNKNOWN STATE)", cs);
@@ -333,20 +333,20 @@ cstate2s (enum MeshTunnel3CState cs)
333 * @return String representation. 333 * @return String representation.
334 */ 334 */
335static const char * 335static const char *
336estate2s (enum MeshTunnel3EState es) 336estate2s (enum CadetTunnel3EState es)
337{ 337{
338 static char buf[128]; 338 static char buf[128];
339 339
340 switch (es) 340 switch (es)
341 { 341 {
342 case MESH_TUNNEL3_KEY_UNINITIALIZED: 342 case CADET_TUNNEL3_KEY_UNINITIALIZED:
343 return "MESH_TUNNEL3_KEY_UNINITIALIZED"; 343 return "CADET_TUNNEL3_KEY_UNINITIALIZED";
344 case MESH_TUNNEL3_KEY_SENT: 344 case CADET_TUNNEL3_KEY_SENT:
345 return "MESH_TUNNEL3_KEY_SENT"; 345 return "CADET_TUNNEL3_KEY_SENT";
346 case MESH_TUNNEL3_KEY_PING: 346 case CADET_TUNNEL3_KEY_PING:
347 return "MESH_TUNNEL3_KEY_PING"; 347 return "CADET_TUNNEL3_KEY_PING";
348 case MESH_TUNNEL3_KEY_OK: 348 case CADET_TUNNEL3_KEY_OK:
349 return "MESH_TUNNEL3_KEY_OK"; 349 return "CADET_TUNNEL3_KEY_OK";
350 350
351 default: 351 default:
352 sprintf (buf, "%u (UNKNOWN STATE)", es); 352 sprintf (buf, "%u (UNKNOWN STATE)", es);
@@ -366,12 +366,12 @@ estate2s (enum MeshTunnel3EState es)
366 * @return #GNUNET_YES if ready, #GNUNET_NO otherwise 366 * @return #GNUNET_YES if ready, #GNUNET_NO otherwise
367 */ 367 */
368static int 368static int
369is_ready (struct MeshTunnel3 *t) 369is_ready (struct CadetTunnel3 *t)
370{ 370{
371 int ready; 371 int ready;
372 372
373 GMT_debug (t); 373 GMT_debug (t);
374 ready = (MESH_TUNNEL3_READY == t->cstate && MESH_TUNNEL3_KEY_OK == t->estate); 374 ready = (CADET_TUNNEL3_READY == t->cstate && CADET_TUNNEL3_KEY_OK == t->estate);
375 ready = ready || GMT_is_loopback (t); 375 ready = ready || GMT_is_loopback (t);
376 return ready; 376 return ready;
377} 377}
@@ -413,7 +413,7 @@ ping_encryption_size (void)
413 * @return Amount of messages the channel can still buffer towards the client. 413 * @return Amount of messages the channel can still buffer towards the client.
414 */ 414 */
415static unsigned int 415static unsigned int
416get_channel_buffer (const struct MeshTChannel *tch) 416get_channel_buffer (const struct CadetTChannel *tch)
417{ 417{
418 int fwd; 418 int fwd;
419 419
@@ -432,7 +432,7 @@ get_channel_buffer (const struct MeshTChannel *tch)
432 * @return #GNUNET_YES if we allowed the client to send data to us. 432 * @return #GNUNET_YES if we allowed the client to send data to us.
433 */ 433 */
434static int 434static int
435get_channel_allowed (const struct MeshTChannel *tch) 435get_channel_allowed (const struct CadetTChannel *tch)
436{ 436{
437 int fwd; 437 int fwd;
438 438
@@ -451,7 +451,7 @@ get_channel_allowed (const struct MeshTChannel *tch)
451 * @return Amount of messages the connection can still buffer. 451 * @return Amount of messages the connection can still buffer.
452 */ 452 */
453static unsigned int 453static unsigned int
454get_connection_buffer (const struct MeshTConnection *tc) 454get_connection_buffer (const struct CadetTConnection *tc)
455{ 455{
456 int fwd; 456 int fwd;
457 457
@@ -470,7 +470,7 @@ get_connection_buffer (const struct MeshTConnection *tc)
470 * @return Amount of messages we have allowed the next peer to send us. 470 * @return Amount of messages we have allowed the next peer to send us.
471 */ 471 */
472static unsigned int 472static unsigned int
473get_connection_allowed (const struct MeshTConnection *tc) 473get_connection_allowed (const struct CadetTConnection *tc)
474{ 474{
475 int fwd; 475 int fwd;
476 476
@@ -490,11 +490,11 @@ get_connection_allowed (const struct MeshTConnection *tc)
490 * @return GNUNET_OK if message is fine, GNUNET_SYSERR otherwise. 490 * @return GNUNET_OK if message is fine, GNUNET_SYSERR otherwise.
491 */ 491 */
492int 492int
493check_ephemeral (struct MeshTunnel3 *t, 493check_ephemeral (struct CadetTunnel3 *t,
494 const struct GNUNET_MESH_KX_Ephemeral *msg) 494 const struct GNUNET_CADET_KX_Ephemeral *msg)
495{ 495{
496 /* Check message size */ 496 /* Check message size */
497 if (ntohs (msg->header.size) != sizeof (struct GNUNET_MESH_KX_Ephemeral)) 497 if (ntohs (msg->header.size) != sizeof (struct GNUNET_CADET_KX_Ephemeral))
498 return GNUNET_SYSERR; 498 return GNUNET_SYSERR;
499 499
500 /* Check signature size */ 500 /* Check signature size */
@@ -509,7 +509,7 @@ check_ephemeral (struct MeshTunnel3 *t,
509 509
510 /* Check signature */ 510 /* Check signature */
511 if (GNUNET_OK != 511 if (GNUNET_OK !=
512 GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_MESH_KX, 512 GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_CADET_KX,
513 &msg->purpose, 513 &msg->purpose,
514 &msg->signature, 514 &msg->signature,
515 &msg->origin_identity.public_key)) 515 &msg->origin_identity.public_key))
@@ -529,7 +529,7 @@ check_ephemeral (struct MeshTunnel3 *t,
529 * @param iv Initialization Vector to use. 529 * @param iv Initialization Vector to use.
530 */ 530 */
531static int 531static int
532t_encrypt (struct MeshTunnel3 *t, 532t_encrypt (struct CadetTunnel3 *t,
533 void *dst, const void *src, 533 void *dst, const void *src,
534 size_t size, uint32_t iv) 534 size_t size, uint32_t iv)
535{ 535{
@@ -556,7 +556,7 @@ t_encrypt (struct MeshTunnel3 *t,
556 * @param iv Initialization Vector to use. 556 * @param iv Initialization Vector to use.
557 */ 557 */
558static int 558static int
559t_decrypt (struct MeshTunnel3 *t, 559t_decrypt (struct CadetTunnel3 *t,
560 void *dst, const void *src, 560 void *dst, const void *src,
561 size_t size, uint32_t iv) 561 size_t size, uint32_t iv)
562{ 562{
@@ -565,7 +565,7 @@ t_decrypt (struct MeshTunnel3 *t,
565 size_t out_size; 565 size_t out_size;
566 566
567 LOG (GNUNET_ERROR_TYPE_DEBUG, " t_decrypt start\n"); 567 LOG (GNUNET_ERROR_TYPE_DEBUG, " t_decrypt start\n");
568 if (t->estate == MESH_TUNNEL3_KEY_OK || t->estate == MESH_TUNNEL3_KEY_PING) 568 if (t->estate == CADET_TUNNEL3_KEY_OK || t->estate == CADET_TUNNEL3_KEY_PING)
569 { 569 {
570 key = &t->d_key; 570 key = &t->d_key;
571 } 571 }
@@ -627,7 +627,7 @@ derive_symmertic (struct GNUNET_CRYPTO_SymmetricSessionKey *key,
627 const struct GNUNET_PeerIdentity *receiver, 627 const struct GNUNET_PeerIdentity *receiver,
628 const struct GNUNET_HashCode *key_material) 628 const struct GNUNET_HashCode *key_material)
629{ 629{
630 const char salt[] = "MESH kx salt"; 630 const char salt[] = "CADET kx salt";
631 631
632 GNUNET_CRYPTO_kdf (key, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey), 632 GNUNET_CRYPTO_kdf (key, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
633 salt, sizeof (salt), 633 salt, sizeof (salt),
@@ -644,11 +644,11 @@ derive_symmertic (struct GNUNET_CRYPTO_SymmetricSessionKey *key,
644 * 644 *
645 * @return The connection on which to send the next message. 645 * @return The connection on which to send the next message.
646 */ 646 */
647static struct MeshConnection * 647static struct CadetConnection *
648tunnel_get_connection (struct MeshTunnel3 *t) 648tunnel_get_connection (struct CadetTunnel3 *t)
649{ 649{
650 struct MeshTConnection *iter; 650 struct CadetTConnection *iter;
651 struct MeshConnection *best; 651 struct CadetConnection *best;
652 unsigned int qn; 652 unsigned int qn;
653 unsigned int lowest_q; 653 unsigned int lowest_q;
654 654
@@ -659,7 +659,7 @@ tunnel_get_connection (struct MeshTunnel3 *t)
659 { 659 {
660 LOG (GNUNET_ERROR_TYPE_DEBUG, " connection %s: %u\n", 660 LOG (GNUNET_ERROR_TYPE_DEBUG, " connection %s: %u\n",
661 GMC_2s (iter->c), GMC_get_state (iter->c)); 661 GMC_2s (iter->c), GMC_get_state (iter->c));
662 if (MESH_CONNECTION_READY == GMC_get_state (iter->c)) 662 if (CADET_CONNECTION_READY == GMC_get_state (iter->c))
663 { 663 {
664 qn = GMC_get_qn (iter->c, GMC_is_origin (iter->c, GNUNET_YES)); 664 qn = GMC_get_qn (iter->c, GMC_is_origin (iter->c, GNUNET_YES));
665 LOG (GNUNET_ERROR_TYPE_DEBUG, " q_n %u, \n", qn); 665 LOG (GNUNET_ERROR_TYPE_DEBUG, " q_n %u, \n", qn);
@@ -689,12 +689,12 @@ tunnel_get_connection (struct MeshTunnel3 *t)
689 */ 689 */
690static void 690static void
691tun_message_sent (void *cls, 691tun_message_sent (void *cls,
692 struct MeshConnection *c, 692 struct CadetConnection *c,
693 struct MeshConnectionQueue *q, 693 struct CadetConnectionQueue *q,
694 uint16_t type, int fwd, size_t size) 694 uint16_t type, int fwd, size_t size)
695{ 695{
696 struct MeshTunnel3Queue *qt = cls; 696 struct CadetTunnel3Queue *qt = cls;
697 struct MeshTunnel3 *t; 697 struct CadetTunnel3 *t;
698 698
699 LOG (GNUNET_ERROR_TYPE_DEBUG, "tun_message_sent\n"); 699 LOG (GNUNET_ERROR_TYPE_DEBUG, "tun_message_sent\n");
700 700
@@ -712,7 +712,7 @@ tun_message_sent (void *cls,
712 * @param tqd Delayed queue handle. 712 * @param tqd Delayed queue handle.
713 */ 713 */
714static void 714static void
715unqueue_data (struct MeshTunnelDelayed *tqd) 715unqueue_data (struct CadetTunnelDelayed *tqd)
716{ 716{
717 GNUNET_CONTAINER_DLL_remove (tqd->t->tq_head, tqd->t->tq_tail, tqd); 717 GNUNET_CONTAINER_DLL_remove (tqd->t->tq_head, tqd->t->tq_tail, tqd);
718 GNUNET_free (tqd); 718 GNUNET_free (tqd);
@@ -725,10 +725,10 @@ unqueue_data (struct MeshTunnelDelayed *tqd)
725 * @param t Tunnel to hold the message. 725 * @param t Tunnel to hold the message.
726 * @param msg Message itself (copy will be made). 726 * @param msg Message itself (copy will be made).
727 */ 727 */
728static struct MeshTunnelDelayed * 728static struct CadetTunnelDelayed *
729queue_data (struct MeshTunnel3 *t, const struct GNUNET_MessageHeader *msg) 729queue_data (struct CadetTunnel3 *t, const struct GNUNET_MessageHeader *msg)
730{ 730{
731 struct MeshTunnelDelayed *tqd; 731 struct CadetTunnelDelayed *tqd;
732 uint16_t size = ntohs (msg->size); 732 uint16_t size = ntohs (msg->size);
733 733
734 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue data on Tunnel %s\n", GMT_2s (t)); 734 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue data on Tunnel %s\n", GMT_2s (t));
@@ -739,7 +739,7 @@ queue_data (struct MeshTunnel3 *t, const struct GNUNET_MessageHeader *msg)
739 return NULL; 739 return NULL;
740 } 740 }
741 741
742 tqd = GNUNET_malloc (sizeof (struct MeshTunnelDelayed) + size); 742 tqd = GNUNET_malloc (sizeof (struct CadetTunnelDelayed) + size);
743 743
744 tqd->t = t; 744 tqd->t = t;
745 memcpy (&tqd[1], msg, size); 745 memcpy (&tqd[1], msg, size);
@@ -759,11 +759,11 @@ queue_data (struct MeshTunnel3 *t, const struct GNUNET_MessageHeader *msg)
759 * @param hmac Destination to store the HMAC. 759 * @param hmac Destination to store the HMAC.
760 */ 760 */
761static void 761static void
762t_hmac (struct MeshTunnel3 *t, const void *plaintext, size_t size, uint32_t iv, 762t_hmac (struct CadetTunnel3 *t, const void *plaintext, size_t size, uint32_t iv,
763 int outgoing, struct GNUNET_MESH_Hash *hmac) 763 int outgoing, struct GNUNET_CADET_Hash *hmac)
764{ 764{
765 struct GNUNET_CRYPTO_AuthKey auth_key; 765 struct GNUNET_CRYPTO_AuthKey auth_key;
766 static const char ctx[] = "mesh authentication key"; 766 static const char ctx[] = "cadet authentication key";
767 struct GNUNET_CRYPTO_SymmetricSessionKey *key; 767 struct GNUNET_CRYPTO_SymmetricSessionKey *key;
768 struct GNUNET_HashCode hash; 768 struct GNUNET_HashCode hash;
769 769
@@ -794,16 +794,16 @@ t_hmac (struct MeshTunnel3 *t, const void *plaintext, size_t size, uint32_t iv,
794 * 794 *
795 * @return Handle to cancel message. NULL if @c cont is NULL. 795 * @return Handle to cancel message. NULL if @c cont is NULL.
796 */ 796 */
797static struct MeshTunnel3Queue * 797static struct CadetTunnel3Queue *
798send_prebuilt_message (const struct GNUNET_MessageHeader *message, 798send_prebuilt_message (const struct GNUNET_MessageHeader *message,
799 struct MeshTunnel3 *t, struct MeshConnection *c, 799 struct CadetTunnel3 *t, struct CadetConnection *c,
800 int force, GMT_sent cont, void *cont_cls, 800 int force, GMT_sent cont, void *cont_cls,
801 struct MeshTunnel3Queue *existing_q) 801 struct CadetTunnel3Queue *existing_q)
802{ 802{
803 struct MeshTunnel3Queue *tq; 803 struct CadetTunnel3Queue *tq;
804 struct GNUNET_MESH_Encrypted *msg; 804 struct GNUNET_CADET_Encrypted *msg;
805 size_t size = ntohs (message->size); 805 size_t size = ntohs (message->size);
806 char cbuf[sizeof (struct GNUNET_MESH_Encrypted) + size]; 806 char cbuf[sizeof (struct GNUNET_CADET_Encrypted) + size];
807 uint32_t mid; 807 uint32_t mid;
808 uint32_t iv; 808 uint32_t iv;
809 uint16_t type; 809 uint16_t type;
@@ -813,7 +813,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
813 813
814 if (GNUNET_NO == is_ready (t)) 814 if (GNUNET_NO == is_ready (t))
815 { 815 {
816 struct MeshTunnelDelayed *tqd; 816 struct CadetTunnelDelayed *tqd;
817 /* A non null existing_q indicates sending of queued data. 817 /* A non null existing_q indicates sending of queued data.
818 * Should only happen after tunnel becomes ready. 818 * Should only happen after tunnel becomes ready.
819 */ 819 */
@@ -821,7 +821,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
821 tqd = queue_data (t, message); 821 tqd = queue_data (t, message);
822 if (NULL == cont) 822 if (NULL == cont)
823 return NULL; 823 return NULL;
824 tq = GNUNET_new (struct MeshTunnel3Queue); 824 tq = GNUNET_new (struct CadetTunnel3Queue);
825 tq->tqd = tqd; 825 tq->tqd = tqd;
826 tqd->tq = tq; 826 tqd->tq = tq;
827 tq->cont = cont; 827 tq->cont = cont;
@@ -832,19 +832,19 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
832 GNUNET_assert (GNUNET_NO == GMT_is_loopback (t)); 832 GNUNET_assert (GNUNET_NO == GMT_is_loopback (t));
833 833
834 iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 834 iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
835 msg = (struct GNUNET_MESH_Encrypted *) cbuf; 835 msg = (struct GNUNET_CADET_Encrypted *) cbuf;
836 msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED); 836 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED);
837 msg->iv = iv; 837 msg->iv = iv;
838 GNUNET_assert (t_encrypt (t, &msg[1], message, size, iv) == size); 838 GNUNET_assert (t_encrypt (t, &msg[1], message, size, iv) == size);
839 t_hmac (t, &msg[1], size, iv, GNUNET_YES, &msg->hmac); 839 t_hmac (t, &msg[1], size, iv, GNUNET_YES, &msg->hmac);
840 msg->header.size = htons (sizeof (struct GNUNET_MESH_Encrypted) + size); 840 msg->header.size = htons (sizeof (struct GNUNET_CADET_Encrypted) + size);
841 841
842 if (NULL == c) 842 if (NULL == c)
843 c = tunnel_get_connection (t); 843 c = tunnel_get_connection (t);
844 if (NULL == c) 844 if (NULL == c)
845 { 845 {
846 if (GNUNET_SCHEDULER_NO_TASK != t->destroy_task 846 if (GNUNET_SCHEDULER_NO_TASK != t->destroy_task
847 || MESH_TUNNEL3_SEARCHING != t->cstate) 847 || CADET_TUNNEL3_SEARCHING != t->cstate)
848 { 848 {
849 GNUNET_break (0); 849 GNUNET_break (0);
850 GMT_debug (t); 850 GMT_debug (t);
@@ -856,18 +856,18 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
856 type = ntohs (message->type); 856 type = ntohs (message->type);
857 switch (type) 857 switch (type)
858 { 858 {
859 case GNUNET_MESSAGE_TYPE_MESH_DATA: 859 case GNUNET_MESSAGE_TYPE_CADET_DATA:
860 case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK: 860 case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK:
861 if (GNUNET_MESSAGE_TYPE_MESH_DATA == type) 861 if (GNUNET_MESSAGE_TYPE_CADET_DATA == type)
862 mid = ntohl (((struct GNUNET_MESH_Data *) message)->mid); 862 mid = ntohl (((struct GNUNET_CADET_Data *) message)->mid);
863 else 863 else
864 mid = ntohl (((struct GNUNET_MESH_DataACK *) message)->mid); 864 mid = ntohl (((struct GNUNET_CADET_DataACK *) message)->mid);
865 /* Fall thru */ 865 /* Fall thru */
866 case GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE: 866 case GNUNET_MESSAGE_TYPE_CADET_KEEPALIVE:
867 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE: 867 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE:
868 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY: 868 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY:
869 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK: 869 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK:
870 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_NACK: 870 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK:
871 msg->cid = *GMC_get_id (c); 871 msg->cid = *GMC_get_id (c);
872 msg->ttl = htonl (default_ttl); 872 msg->ttl = htonl (default_ttl);
873 break; 873 break;
@@ -887,7 +887,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
887 } 887 }
888 if (NULL == existing_q) 888 if (NULL == existing_q)
889 { 889 {
890 tq = GNUNET_new (struct MeshTunnel3Queue); /* FIXME valgrind: leak*/ 890 tq = GNUNET_new (struct CadetTunnel3Queue); /* FIXME valgrind: leak*/
891 } 891 }
892 else 892 else
893 { 893 {
@@ -909,10 +909,10 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
909 * @param t Tunnel that holds the messages. Cannot be loopback. 909 * @param t Tunnel that holds the messages. Cannot be loopback.
910 */ 910 */
911static void 911static void
912send_queued_data (struct MeshTunnel3 *t) 912send_queued_data (struct CadetTunnel3 *t)
913{ 913{
914 struct MeshTunnelDelayed *tqd; 914 struct CadetTunnelDelayed *tqd;
915 struct MeshTunnelDelayed *next; 915 struct CadetTunnelDelayed *next;
916 unsigned int room; 916 unsigned int room;
917 917
918 LOG (GNUNET_ERROR_TYPE_DEBUG, 918 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -959,13 +959,13 @@ send_queued_data (struct MeshTunnel3 *t)
959 * @param message Message to send. Function modifies it. 959 * @param message Message to send. Function modifies it.
960 */ 960 */
961static void 961static void
962send_kx (struct MeshTunnel3 *t, 962send_kx (struct CadetTunnel3 *t,
963 const struct GNUNET_MessageHeader *message) 963 const struct GNUNET_MessageHeader *message)
964{ 964{
965 struct MeshConnection *c; 965 struct CadetConnection *c;
966 struct GNUNET_MESH_KX *msg; 966 struct GNUNET_CADET_KX *msg;
967 size_t size = ntohs (message->size); 967 size_t size = ntohs (message->size);
968 char cbuf[sizeof (struct GNUNET_MESH_KX) + size]; 968 char cbuf[sizeof (struct GNUNET_CADET_KX) + size];
969 uint16_t type; 969 uint16_t type;
970 int fwd; 970 int fwd;
971 971
@@ -988,28 +988,28 @@ send_kx (struct MeshTunnel3 *t,
988 /* Must have a connection. */ 988 /* Must have a connection. */
989 if (NULL == t->connection_head) 989 if (NULL == t->connection_head)
990 { 990 {
991 GNUNET_break (MESH_TUNNEL3_SEARCHING == t->cstate); 991 GNUNET_break (CADET_TUNNEL3_SEARCHING == t->cstate);
992 GMT_debug (t); 992 GMT_debug (t);
993 return; 993 return;
994 } 994 }
995 995
996 msg = (struct GNUNET_MESH_KX *) cbuf; 996 msg = (struct GNUNET_CADET_KX *) cbuf;
997 msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_KX); 997 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX);
998 msg->header.size = htons (sizeof (struct GNUNET_MESH_KX) + size); 998 msg->header.size = htons (sizeof (struct GNUNET_CADET_KX) + size);
999 c = tunnel_get_connection (t); 999 c = tunnel_get_connection (t);
1000 if (NULL == c) 1000 if (NULL == c)
1001 { 1001 {
1002 GNUNET_break (GNUNET_SCHEDULER_NO_TASK != t->destroy_task 1002 GNUNET_break (GNUNET_SCHEDULER_NO_TASK != t->destroy_task
1003 || MESH_TUNNEL3_READY != t->cstate); 1003 || CADET_TUNNEL3_READY != t->cstate);
1004 GMT_debug (t); 1004 GMT_debug (t);
1005 return; 1005 return;
1006 } 1006 }
1007 type = ntohs (message->type); 1007 type = ntohs (message->type);
1008 switch (type) 1008 switch (type)
1009 { 1009 {
1010 case GNUNET_MESSAGE_TYPE_MESH_KX_EPHEMERAL: 1010 case GNUNET_MESSAGE_TYPE_CADET_KX_EPHEMERAL:
1011 case GNUNET_MESSAGE_TYPE_MESH_KX_PING: 1011 case GNUNET_MESSAGE_TYPE_CADET_KX_PING:
1012 case GNUNET_MESSAGE_TYPE_MESH_KX_PONG: 1012 case GNUNET_MESSAGE_TYPE_CADET_KX_PONG:
1013 memcpy (&msg[1], message, size); 1013 memcpy (&msg[1], message, size);
1014 break; 1014 break;
1015 default: 1015 default:
@@ -1020,7 +1020,7 @@ send_kx (struct MeshTunnel3 *t,
1020 1020
1021 fwd = GMC_is_origin (t->connection_head->c, GNUNET_YES); 1021 fwd = GMC_is_origin (t->connection_head->c, GNUNET_YES);
1022 /* TODO save handle and cancel in case of a unneeded retransmission */ 1022 /* TODO save handle and cancel in case of a unneeded retransmission */
1023 GMC_send_prebuilt_message (&msg->header, GNUNET_MESSAGE_TYPE_MESH_KX, 1023 GMC_send_prebuilt_message (&msg->header, GNUNET_MESSAGE_TYPE_CADET_KX,
1024 message->type, c, fwd, GNUNET_YES, NULL, NULL); 1024 message->type, c, fwd, GNUNET_YES, NULL, NULL);
1025} 1025}
1026 1026
@@ -1031,7 +1031,7 @@ send_kx (struct MeshTunnel3 *t,
1031 * @param t Tunnel on which to send the key. 1031 * @param t Tunnel on which to send the key.
1032 */ 1032 */
1033static void 1033static void
1034send_ephemeral (struct MeshTunnel3 *t) 1034send_ephemeral (struct CadetTunnel3 *t)
1035{ 1035{
1036 LOG (GNUNET_ERROR_TYPE_INFO, "=> EPHM for %s\n", GMT_2s (t)); 1036 LOG (GNUNET_ERROR_TYPE_INFO, "=> EPHM for %s\n", GMT_2s (t));
1037 1037
@@ -1045,13 +1045,13 @@ send_ephemeral (struct MeshTunnel3 *t)
1045 * @param t Tunnel on which to send the ping. 1045 * @param t Tunnel on which to send the ping.
1046 */ 1046 */
1047static void 1047static void
1048send_ping (struct MeshTunnel3 *t) 1048send_ping (struct CadetTunnel3 *t)
1049{ 1049{
1050 struct GNUNET_MESH_KX_Ping msg; 1050 struct GNUNET_CADET_KX_Ping msg;
1051 1051
1052 LOG (GNUNET_ERROR_TYPE_INFO, "=> PING for %s\n", GMT_2s (t)); 1052 LOG (GNUNET_ERROR_TYPE_INFO, "=> PING for %s\n", GMT_2s (t));
1053 msg.header.size = htons (sizeof (msg)); 1053 msg.header.size = htons (sizeof (msg));
1054 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_KX_PING); 1054 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX_PING);
1055 msg.iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 1055 msg.iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
1056 msg.target = *GMP_get_id (t->peer); 1056 msg.target = *GMP_get_id (t->peer);
1057 msg.nonce = t->kx_ctx->challenge; 1057 msg.nonce = t->kx_ctx->challenge;
@@ -1073,13 +1073,13 @@ send_ping (struct MeshTunnel3 *t)
1073 * @param challenge Value sent in the ping that we have to send back. 1073 * @param challenge Value sent in the ping that we have to send back.
1074 */ 1074 */
1075static void 1075static void
1076send_pong (struct MeshTunnel3 *t, uint32_t challenge) 1076send_pong (struct CadetTunnel3 *t, uint32_t challenge)
1077{ 1077{
1078 struct GNUNET_MESH_KX_Pong msg; 1078 struct GNUNET_CADET_KX_Pong msg;
1079 1079
1080 LOG (GNUNET_ERROR_TYPE_INFO, "=> PONG for %s\n", GMT_2s (t)); 1080 LOG (GNUNET_ERROR_TYPE_INFO, "=> PONG for %s\n", GMT_2s (t));
1081 msg.header.size = htons (sizeof (msg)); 1081 msg.header.size = htons (sizeof (msg));
1082 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_KX_PONG); 1082 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX_PONG);
1083 msg.iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 1083 msg.iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
1084 msg.nonce = challenge; 1084 msg.nonce = challenge;
1085 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending %u\n", msg.nonce); 1085 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending %u\n", msg.nonce);
@@ -1099,7 +1099,7 @@ send_pong (struct MeshTunnel3 *t, uint32_t challenge)
1099static void 1099static void
1100rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1100rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1101{ 1101{
1102 struct MeshTunnel3 *t = cls; 1102 struct CadetTunnel3 *t = cls;
1103 1103
1104 t->rekey_task = GNUNET_SCHEDULER_NO_TASK; 1104 t->rekey_task = GNUNET_SCHEDULER_NO_TASK;
1105 1105
@@ -1110,7 +1110,7 @@ rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1110 if (NULL == t->kx_ctx) 1110 if (NULL == t->kx_ctx)
1111 { 1111 {
1112 LOG (GNUNET_ERROR_TYPE_DEBUG, " new kx ctx\n"); 1112 LOG (GNUNET_ERROR_TYPE_DEBUG, " new kx ctx\n");
1113 t->kx_ctx = GNUNET_new (struct MeshTunnelKXCtx); 1113 t->kx_ctx = GNUNET_new (struct CadetTunnelKXCtx);
1114 t->kx_ctx->challenge = 1114 t->kx_ctx->challenge =
1115 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 1115 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
1116 t->kx_ctx->d_key_old = t->d_key; 1116 t->kx_ctx->d_key_old = t->d_key;
@@ -1120,15 +1120,15 @@ rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1120 send_ephemeral (t); 1120 send_ephemeral (t);
1121 switch (t->estate) 1121 switch (t->estate)
1122 { 1122 {
1123 case MESH_TUNNEL3_KEY_UNINITIALIZED: 1123 case CADET_TUNNEL3_KEY_UNINITIALIZED:
1124 t->estate = MESH_TUNNEL3_KEY_SENT; 1124 t->estate = CADET_TUNNEL3_KEY_SENT;
1125 break; 1125 break;
1126 case MESH_TUNNEL3_KEY_SENT: 1126 case CADET_TUNNEL3_KEY_SENT:
1127 break; 1127 break;
1128 case MESH_TUNNEL3_KEY_PING: 1128 case CADET_TUNNEL3_KEY_PING:
1129 case MESH_TUNNEL3_KEY_OK: 1129 case CADET_TUNNEL3_KEY_OK:
1130 send_ping (t); 1130 send_ping (t);
1131 t->estate = MESH_TUNNEL3_KEY_PING; 1131 t->estate = CADET_TUNNEL3_KEY_PING;
1132 break; 1132 break;
1133 default: 1133 default:
1134 LOG (GNUNET_ERROR_TYPE_DEBUG, "Unexpected state %u\n", t->estate); 1134 LOG (GNUNET_ERROR_TYPE_DEBUG, "Unexpected state %u\n", t->estate);
@@ -1154,7 +1154,7 @@ rekey_iterator (void *cls,
1154 const struct GNUNET_PeerIdentity *key, 1154 const struct GNUNET_PeerIdentity *key,
1155 void *value) 1155 void *value)
1156{ 1156{
1157 struct MeshTunnel3 *t = value; 1157 struct CadetTunnel3 *t = value;
1158 struct GNUNET_TIME_Relative delay; 1158 struct GNUNET_TIME_Relative delay;
1159 long n = (long) cls; 1159 long n = (long) cls;
1160 uint32_t r; 1160 uint32_t r;
@@ -1226,7 +1226,7 @@ destroy_iterator (void *cls,
1226 const struct GNUNET_PeerIdentity *key, 1226 const struct GNUNET_PeerIdentity *key,
1227 void *value) 1227 void *value)
1228{ 1228{
1229 struct MeshTunnel3 *t = value; 1229 struct CadetTunnel3 *t = value;
1230 1230
1231 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT_shutdown destroying tunnel at %p\n", t); 1231 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT_shutdown destroying tunnel at %p\n", t);
1232 GMT_destroy (t); 1232 GMT_destroy (t);
@@ -1242,11 +1242,11 @@ destroy_iterator (void *cls,
1242 * @param gid ID of the channel. 1242 * @param gid ID of the channel.
1243 */ 1243 */
1244static void 1244static void
1245send_channel_destroy (struct MeshTunnel3 *t, unsigned int gid) 1245send_channel_destroy (struct CadetTunnel3 *t, unsigned int gid)
1246{ 1246{
1247 struct GNUNET_MESH_ChannelManage msg; 1247 struct GNUNET_CADET_ChannelManage msg;
1248 1248
1249 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY); 1249 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
1250 msg.header.size = htons (sizeof (msg)); 1250 msg.header.size = htons (sizeof (msg));
1251 msg.chid = htonl (gid); 1251 msg.chid = htonl (gid);
1252 1252
@@ -1268,17 +1268,17 @@ send_channel_destroy (struct MeshTunnel3 *t, unsigned int gid)
1268 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1268 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1269 */ 1269 */
1270static void 1270static void
1271handle_data (struct MeshTunnel3 *t, 1271handle_data (struct CadetTunnel3 *t,
1272 const struct GNUNET_MESH_Data *msg, 1272 const struct GNUNET_CADET_Data *msg,
1273 int fwd) 1273 int fwd)
1274{ 1274{
1275 struct MeshChannel *ch; 1275 struct CadetChannel *ch;
1276 size_t size; 1276 size_t size;
1277 1277
1278 /* Check size */ 1278 /* Check size */
1279 size = ntohs (msg->header.size); 1279 size = ntohs (msg->header.size);
1280 if (size < 1280 if (size <
1281 sizeof (struct GNUNET_MESH_Data) + 1281 sizeof (struct GNUNET_CADET_Data) +
1282 sizeof (struct GNUNET_MessageHeader)) 1282 sizeof (struct GNUNET_MessageHeader))
1283 { 1283 {
1284 GNUNET_break (0); 1284 GNUNET_break (0);
@@ -1314,16 +1314,16 @@ handle_data (struct MeshTunnel3 *t,
1314 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1314 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1315 */ 1315 */
1316static void 1316static void
1317handle_data_ack (struct MeshTunnel3 *t, 1317handle_data_ack (struct CadetTunnel3 *t,
1318 const struct GNUNET_MESH_DataACK *msg, 1318 const struct GNUNET_CADET_DataACK *msg,
1319 int fwd) 1319 int fwd)
1320{ 1320{
1321 struct MeshChannel *ch; 1321 struct CadetChannel *ch;
1322 size_t size; 1322 size_t size;
1323 1323
1324 /* Check size */ 1324 /* Check size */
1325 size = ntohs (msg->header.size); 1325 size = ntohs (msg->header.size);
1326 if (size != sizeof (struct GNUNET_MESH_DataACK)) 1326 if (size != sizeof (struct GNUNET_CADET_DataACK))
1327 { 1327 {
1328 GNUNET_break (0); 1328 GNUNET_break (0);
1329 return; 1329 return;
@@ -1351,15 +1351,15 @@ handle_data_ack (struct MeshTunnel3 *t,
1351 * @param msg Data message. 1351 * @param msg Data message.
1352 */ 1352 */
1353static void 1353static void
1354handle_ch_create (struct MeshTunnel3 *t, 1354handle_ch_create (struct CadetTunnel3 *t,
1355 const struct GNUNET_MESH_ChannelCreate *msg) 1355 const struct GNUNET_CADET_ChannelCreate *msg)
1356{ 1356{
1357 struct MeshChannel *ch; 1357 struct CadetChannel *ch;
1358 size_t size; 1358 size_t size;
1359 1359
1360 /* Check size */ 1360 /* Check size */
1361 size = ntohs (msg->header.size); 1361 size = ntohs (msg->header.size);
1362 if (size != sizeof (struct GNUNET_MESH_ChannelCreate)) 1362 if (size != sizeof (struct GNUNET_CADET_ChannelCreate))
1363 { 1363 {
1364 GNUNET_break (0); 1364 GNUNET_break (0);
1365 return; 1365 return;
@@ -1386,15 +1386,15 @@ handle_ch_create (struct MeshTunnel3 *t,
1386 * @param msg NACK message. 1386 * @param msg NACK message.
1387 */ 1387 */
1388static void 1388static void
1389handle_ch_nack (struct MeshTunnel3 *t, 1389handle_ch_nack (struct CadetTunnel3 *t,
1390 const struct GNUNET_MESH_ChannelManage *msg) 1390 const struct GNUNET_CADET_ChannelManage *msg)
1391{ 1391{
1392 struct MeshChannel *ch; 1392 struct CadetChannel *ch;
1393 size_t size; 1393 size_t size;
1394 1394
1395 /* Check size */ 1395 /* Check size */
1396 size = ntohs (msg->header.size); 1396 size = ntohs (msg->header.size);
1397 if (size != sizeof (struct GNUNET_MESH_ChannelManage)) 1397 if (size != sizeof (struct GNUNET_CADET_ChannelManage))
1398 { 1398 {
1399 GNUNET_break (0); 1399 GNUNET_break (0);
1400 return; 1400 return;
@@ -1426,16 +1426,16 @@ handle_ch_nack (struct MeshTunnel3 *t,
1426 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1426 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1427 */ 1427 */
1428static void 1428static void
1429handle_ch_ack (struct MeshTunnel3 *t, 1429handle_ch_ack (struct CadetTunnel3 *t,
1430 const struct GNUNET_MESH_ChannelManage *msg, 1430 const struct GNUNET_CADET_ChannelManage *msg,
1431 int fwd) 1431 int fwd)
1432{ 1432{
1433 struct MeshChannel *ch; 1433 struct CadetChannel *ch;
1434 size_t size; 1434 size_t size;
1435 1435
1436 /* Check size */ 1436 /* Check size */
1437 size = ntohs (msg->header.size); 1437 size = ntohs (msg->header.size);
1438 if (size != sizeof (struct GNUNET_MESH_ChannelManage)) 1438 if (size != sizeof (struct GNUNET_CADET_ChannelManage))
1439 { 1439 {
1440 GNUNET_break (0); 1440 GNUNET_break (0);
1441 return; 1441 return;
@@ -1468,16 +1468,16 @@ handle_ch_ack (struct MeshTunnel3 *t,
1468 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1468 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1469 */ 1469 */
1470static void 1470static void
1471handle_ch_destroy (struct MeshTunnel3 *t, 1471handle_ch_destroy (struct CadetTunnel3 *t,
1472 const struct GNUNET_MESH_ChannelManage *msg, 1472 const struct GNUNET_CADET_ChannelManage *msg,
1473 int fwd) 1473 int fwd)
1474{ 1474{
1475 struct MeshChannel *ch; 1475 struct CadetChannel *ch;
1476 size_t size; 1476 size_t size;
1477 1477
1478 /* Check size */ 1478 /* Check size */
1479 size = ntohs (msg->header.size); 1479 size = ntohs (msg->header.size);
1480 if (size != sizeof (struct GNUNET_MESH_ChannelManage)) 1480 if (size != sizeof (struct GNUNET_CADET_ChannelManage))
1481 { 1481 {
1482 GNUNET_break (0); 1482 GNUNET_break (0);
1483 return; 1483 return;
@@ -1502,8 +1502,8 @@ handle_ch_destroy (struct MeshTunnel3 *t,
1502 * @param msg Key eXchange message. 1502 * @param msg Key eXchange message.
1503 */ 1503 */
1504static void 1504static void
1505handle_ephemeral (struct MeshTunnel3 *t, 1505handle_ephemeral (struct CadetTunnel3 *t,
1506 const struct GNUNET_MESH_KX_Ephemeral *msg) 1506 const struct GNUNET_CADET_KX_Ephemeral *msg)
1507{ 1507{
1508 struct GNUNET_HashCode km; 1508 struct GNUNET_HashCode km;
1509 LOG (GNUNET_ERROR_TYPE_INFO, "<=== EPHM for %s\n", GMT_2s (t)); 1509 LOG (GNUNET_ERROR_TYPE_INFO, "<=== EPHM for %s\n", GMT_2s (t));
@@ -1517,11 +1517,11 @@ handle_ephemeral (struct MeshTunnel3 *t,
1517 LOG (GNUNET_ERROR_TYPE_DEBUG, " km is %s\n", GNUNET_h2s (&km)); 1517 LOG (GNUNET_ERROR_TYPE_DEBUG, " km is %s\n", GNUNET_h2s (&km));
1518 derive_symmertic (&t->e_key, &my_full_id, GMP_get_id (t->peer), &km); 1518 derive_symmertic (&t->e_key, &my_full_id, GMP_get_id (t->peer), &km);
1519 derive_symmertic (&t->d_key, GMP_get_id (t->peer), &my_full_id, &km); 1519 derive_symmertic (&t->d_key, GMP_get_id (t->peer), &my_full_id, &km);
1520 if (MESH_TUNNEL3_KEY_SENT == t->estate) 1520 if (CADET_TUNNEL3_KEY_SENT == t->estate)
1521 { 1521 {
1522 LOG (GNUNET_ERROR_TYPE_DEBUG, " our key was sent, send ping\n"); 1522 LOG (GNUNET_ERROR_TYPE_DEBUG, " our key was sent, send ping\n");
1523 send_ping (t); 1523 send_ping (t);
1524 t->estate = MESH_TUNNEL3_KEY_PING; 1524 t->estate = CADET_TUNNEL3_KEY_PING;
1525 } 1525 }
1526} 1526}
1527 1527
@@ -1534,10 +1534,10 @@ handle_ephemeral (struct MeshTunnel3 *t,
1534 * @param msg Key eXchange Ping message. 1534 * @param msg Key eXchange Ping message.
1535 */ 1535 */
1536static void 1536static void
1537handle_ping (struct MeshTunnel3 *t, 1537handle_ping (struct CadetTunnel3 *t,
1538 const struct GNUNET_MESH_KX_Ping *msg) 1538 const struct GNUNET_CADET_KX_Ping *msg)
1539{ 1539{
1540 struct GNUNET_MESH_KX_Ping res; 1540 struct GNUNET_CADET_KX_Ping res;
1541 1541
1542 if (ntohs (msg->header.size) != sizeof (res)) 1542 if (ntohs (msg->header.size) != sizeof (res))
1543 { 1543 {
@@ -1572,8 +1572,8 @@ handle_ping (struct MeshTunnel3 *t,
1572 * @param msg Key eXchange Pong message. 1572 * @param msg Key eXchange Pong message.
1573 */ 1573 */
1574static void 1574static void
1575handle_pong (struct MeshTunnel3 *t, 1575handle_pong (struct CadetTunnel3 *t,
1576 const struct GNUNET_MESH_KX_Pong *msg) 1576 const struct GNUNET_CADET_KX_Pong *msg)
1577{ 1577{
1578 uint32_t challenge; 1578 uint32_t challenge;
1579 1579
@@ -1597,7 +1597,7 @@ handle_pong (struct MeshTunnel3 *t,
1597 t->rekey_task = GNUNET_SCHEDULER_NO_TASK; 1597 t->rekey_task = GNUNET_SCHEDULER_NO_TASK;
1598 GNUNET_free (t->kx_ctx); 1598 GNUNET_free (t->kx_ctx);
1599 t->kx_ctx = NULL; 1599 t->kx_ctx = NULL;
1600 GMT_change_estate (t, MESH_TUNNEL3_KEY_OK); 1600 GMT_change_estate (t, CADET_TUNNEL3_KEY_OK);
1601} 1601}
1602 1602
1603 1603
@@ -1613,7 +1613,7 @@ handle_pong (struct MeshTunnel3 *t,
1613 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1613 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1614 */ 1614 */
1615static void 1615static void
1616handle_decrypted (struct MeshTunnel3 *t, 1616handle_decrypted (struct CadetTunnel3 *t,
1617 const struct GNUNET_MessageHeader *msgh, 1617 const struct GNUNET_MessageHeader *msgh,
1618 int fwd) 1618 int fwd)
1619{ 1619{
@@ -1624,39 +1624,39 @@ handle_decrypted (struct MeshTunnel3 *t,
1624 1624
1625 switch (type) 1625 switch (type)
1626 { 1626 {
1627 case GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE: 1627 case GNUNET_MESSAGE_TYPE_CADET_KEEPALIVE:
1628 /* Do nothing, connection aleady got updated. */ 1628 /* Do nothing, connection aleady got updated. */
1629 GNUNET_STATISTICS_update (stats, "# keepalives received", 1, GNUNET_NO); 1629 GNUNET_STATISTICS_update (stats, "# keepalives received", 1, GNUNET_NO);
1630 break; 1630 break;
1631 1631
1632 case GNUNET_MESSAGE_TYPE_MESH_DATA: 1632 case GNUNET_MESSAGE_TYPE_CADET_DATA:
1633 /* Don't send hop ACK, wait for client to ACK */ 1633 /* Don't send hop ACK, wait for client to ACK */
1634 handle_data (t, (struct GNUNET_MESH_Data *) msgh, fwd); 1634 handle_data (t, (struct GNUNET_CADET_Data *) msgh, fwd);
1635 break; 1635 break;
1636 1636
1637 case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK: 1637 case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK:
1638 handle_data_ack (t, (struct GNUNET_MESH_DataACK *) msgh, fwd); 1638 handle_data_ack (t, (struct GNUNET_CADET_DataACK *) msgh, fwd);
1639 break; 1639 break;
1640 1640
1641 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE: 1641 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE:
1642 handle_ch_create (t, 1642 handle_ch_create (t,
1643 (struct GNUNET_MESH_ChannelCreate *) msgh); 1643 (struct GNUNET_CADET_ChannelCreate *) msgh);
1644 break; 1644 break;
1645 1645
1646 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_NACK: 1646 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK:
1647 handle_ch_nack (t, 1647 handle_ch_nack (t,
1648 (struct GNUNET_MESH_ChannelManage *) msgh); 1648 (struct GNUNET_CADET_ChannelManage *) msgh);
1649 break; 1649 break;
1650 1650
1651 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK: 1651 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK:
1652 handle_ch_ack (t, 1652 handle_ch_ack (t,
1653 (struct GNUNET_MESH_ChannelManage *) msgh, 1653 (struct GNUNET_CADET_ChannelManage *) msgh,
1654 fwd); 1654 fwd);
1655 break; 1655 break;
1656 1656
1657 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY: 1657 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY:
1658 handle_ch_destroy (t, 1658 handle_ch_destroy (t,
1659 (struct GNUNET_MESH_ChannelManage *) msgh, 1659 (struct GNUNET_CADET_ChannelManage *) msgh,
1660 fwd); 1660 fwd);
1661 break; 1661 break;
1662 1662
@@ -1681,16 +1681,16 @@ handle_decrypted (struct MeshTunnel3 *t,
1681 * @param msg Encrypted message. 1681 * @param msg Encrypted message.
1682 */ 1682 */
1683void 1683void
1684GMT_handle_encrypted (struct MeshTunnel3 *t, 1684GMT_handle_encrypted (struct CadetTunnel3 *t,
1685 const struct GNUNET_MESH_Encrypted *msg) 1685 const struct GNUNET_CADET_Encrypted *msg)
1686{ 1686{
1687 size_t size = ntohs (msg->header.size); 1687 size_t size = ntohs (msg->header.size);
1688 size_t payload_size = size - sizeof (struct GNUNET_MESH_Encrypted); 1688 size_t payload_size = size - sizeof (struct GNUNET_CADET_Encrypted);
1689 size_t decrypted_size; 1689 size_t decrypted_size;
1690 char cbuf [payload_size]; 1690 char cbuf [payload_size];
1691 struct GNUNET_MessageHeader *msgh; 1691 struct GNUNET_MessageHeader *msgh;
1692 unsigned int off; 1692 unsigned int off;
1693 struct GNUNET_MESH_Hash hmac; 1693 struct GNUNET_CADET_Hash hmac;
1694 1694
1695 decrypted_size = t_decrypt (t, cbuf, &msg[1], payload_size, msg->iv); 1695 decrypted_size = t_decrypt (t, cbuf, &msg[1], payload_size, msg->iv);
1696 t_hmac (t, &msg[1], payload_size, msg->iv, GNUNET_NO, &hmac); 1696 t_hmac (t, &msg[1], payload_size, msg->iv, GNUNET_NO, &hmac);
@@ -1720,7 +1720,7 @@ GMT_handle_encrypted (struct MeshTunnel3 *t,
1720 * @param message Payload of KX message. 1720 * @param message Payload of KX message.
1721 */ 1721 */
1722void 1722void
1723GMT_handle_kx (struct MeshTunnel3 *t, 1723GMT_handle_kx (struct CadetTunnel3 *t,
1724 const struct GNUNET_MessageHeader *message) 1724 const struct GNUNET_MessageHeader *message)
1725{ 1725{
1726 uint16_t type; 1726 uint16_t type;
@@ -1729,16 +1729,16 @@ GMT_handle_kx (struct MeshTunnel3 *t,
1729 LOG (GNUNET_ERROR_TYPE_DEBUG, "kx message received\n", type); 1729 LOG (GNUNET_ERROR_TYPE_DEBUG, "kx message received\n", type);
1730 switch (type) 1730 switch (type)
1731 { 1731 {
1732 case GNUNET_MESSAGE_TYPE_MESH_KX_EPHEMERAL: 1732 case GNUNET_MESSAGE_TYPE_CADET_KX_EPHEMERAL:
1733 handle_ephemeral (t, (struct GNUNET_MESH_KX_Ephemeral *) message); 1733 handle_ephemeral (t, (struct GNUNET_CADET_KX_Ephemeral *) message);
1734 break; 1734 break;
1735 1735
1736 case GNUNET_MESSAGE_TYPE_MESH_KX_PING: 1736 case GNUNET_MESSAGE_TYPE_CADET_KX_PING:
1737 handle_ping (t, (struct GNUNET_MESH_KX_Ping *) message); 1737 handle_ping (t, (struct GNUNET_CADET_KX_Ping *) message);
1738 break; 1738 break;
1739 1739
1740 case GNUNET_MESSAGE_TYPE_MESH_KX_PONG: 1740 case GNUNET_MESSAGE_TYPE_CADET_KX_PONG:
1741 handle_pong (t, (struct GNUNET_MESH_KX_Pong *) message); 1741 handle_pong (t, (struct GNUNET_CADET_KX_Pong *) message);
1742 break; 1742 break;
1743 1743
1744 default: 1744 default:
@@ -1760,15 +1760,15 @@ GMT_init (const struct GNUNET_CONFIGURATION_Handle *c,
1760{ 1760{
1761 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); 1761 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
1762 if (GNUNET_OK != 1762 if (GNUNET_OK !=
1763 GNUNET_CONFIGURATION_get_value_number (c, "MESH", "DEFAULT_TTL", 1763 GNUNET_CONFIGURATION_get_value_number (c, "CADET", "DEFAULT_TTL",
1764 &default_ttl)) 1764 &default_ttl))
1765 { 1765 {
1766 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, 1766 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING,
1767 "MESH", "DEFAULT_TTL", "USING DEFAULT"); 1767 "CADET", "DEFAULT_TTL", "USING DEFAULT");
1768 default_ttl = 64; 1768 default_ttl = 64;
1769 } 1769 }
1770 if (GNUNET_OK != 1770 if (GNUNET_OK !=
1771 GNUNET_CONFIGURATION_get_value_time (c, "MESH", "REKEY_PERIOD", 1771 GNUNET_CONFIGURATION_get_value_time (c, "CADET", "REKEY_PERIOD",
1772 &rekey_period)) 1772 &rekey_period))
1773 { 1773 {
1774 rekey_period = GNUNET_TIME_UNIT_DAYS; 1774 rekey_period = GNUNET_TIME_UNIT_DAYS;
@@ -1776,8 +1776,8 @@ GMT_init (const struct GNUNET_CONFIGURATION_Handle *c,
1776 1776
1777 my_private_key = key; 1777 my_private_key = key;
1778 kx_msg.header.size = htons (sizeof (kx_msg)); 1778 kx_msg.header.size = htons (sizeof (kx_msg));
1779 kx_msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_KX_EPHEMERAL); 1779 kx_msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX_EPHEMERAL);
1780 kx_msg.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MESH_KX); 1780 kx_msg.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CADET_KX);
1781 kx_msg.purpose.size = htonl (ephemeral_purpose_size ()); 1781 kx_msg.purpose.size = htonl (ephemeral_purpose_size ());
1782 kx_msg.origin_identity = my_full_id; 1782 kx_msg.origin_identity = my_full_id;
1783 rekey_task = GNUNET_SCHEDULER_add_now (&rekey, NULL); 1783 rekey_task = GNUNET_SCHEDULER_add_now (&rekey, NULL);
@@ -1807,12 +1807,12 @@ GMT_shutdown (void)
1807 * 1807 *
1808 * @param destination Peer this tunnel is towards. 1808 * @param destination Peer this tunnel is towards.
1809 */ 1809 */
1810struct MeshTunnel3 * 1810struct CadetTunnel3 *
1811GMT_new (struct MeshPeer *destination) 1811GMT_new (struct CadetPeer *destination)
1812{ 1812{
1813 struct MeshTunnel3 *t; 1813 struct CadetTunnel3 *t;
1814 1814
1815 t = GNUNET_new (struct MeshTunnel3); 1815 t = GNUNET_new (struct CadetTunnel3);
1816 t->next_chid = 0; 1816 t->next_chid = 0;
1817 t->peer = destination; 1817 t->peer = destination;
1818 1818
@@ -1835,23 +1835,23 @@ GMT_new (struct MeshPeer *destination)
1835 * @param cstate New connection state. 1835 * @param cstate New connection state.
1836 */ 1836 */
1837void 1837void
1838GMT_change_cstate (struct MeshTunnel3* t, enum MeshTunnel3CState cstate) 1838GMT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate)
1839{ 1839{
1840 if (NULL == t) 1840 if (NULL == t)
1841 return; 1841 return;
1842 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s cstate %s => %s\n", 1842 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s cstate %s => %s\n",
1843 GMP_2s (t->peer), cstate2s (t->cstate), cstate2s (cstate)); 1843 GMP_2s (t->peer), cstate2s (t->cstate), cstate2s (cstate));
1844 if (myid != GMP_get_short_id (t->peer) && 1844 if (myid != GMP_get_short_id (t->peer) &&
1845 MESH_TUNNEL3_READY != t->cstate && 1845 CADET_TUNNEL3_READY != t->cstate &&
1846 MESH_TUNNEL3_READY == cstate) 1846 CADET_TUNNEL3_READY == cstate)
1847 { 1847 {
1848 t->cstate = cstate; 1848 t->cstate = cstate;
1849 if (MESH_TUNNEL3_KEY_OK == t->estate) 1849 if (CADET_TUNNEL3_KEY_OK == t->estate)
1850 { 1850 {
1851 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered send queued data\n"); 1851 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered send queued data\n");
1852 send_queued_data (t); 1852 send_queued_data (t);
1853 } 1853 }
1854 else if (MESH_TUNNEL3_KEY_UNINITIALIZED == t->estate) 1854 else if (CADET_TUNNEL3_KEY_UNINITIALIZED == t->estate)
1855 { 1855 {
1856 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered rekey\n"); 1856 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered rekey\n");
1857 rekey_tunnel (t, NULL); 1857 rekey_tunnel (t, NULL);
@@ -1859,7 +1859,7 @@ GMT_change_cstate (struct MeshTunnel3* t, enum MeshTunnel3CState cstate)
1859 } 1859 }
1860 t->cstate = cstate; 1860 t->cstate = cstate;
1861 1861
1862 if (MESH_TUNNEL3_READY == cstate 1862 if (CADET_TUNNEL3_READY == cstate
1863 && CONNECTIONS_PER_TUNNEL <= GMT_count_connections (t)) 1863 && CONNECTIONS_PER_TUNNEL <= GMT_count_connections (t))
1864 { 1864 {
1865 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered stop dht\n"); 1865 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered stop dht\n");
@@ -1874,7 +1874,7 @@ GMT_change_cstate (struct MeshTunnel3* t, enum MeshTunnel3CState cstate)
1874 * @param state New encryption state. 1874 * @param state New encryption state.
1875 */ 1875 */
1876void 1876void
1877GMT_change_estate (struct MeshTunnel3* t, enum MeshTunnel3EState state) 1877GMT_change_estate (struct CadetTunnel3* t, enum CadetTunnel3EState state)
1878{ 1878{
1879 if (NULL == t) 1879 if (NULL == t)
1880 return; 1880 return;
@@ -1885,7 +1885,7 @@ GMT_change_estate (struct MeshTunnel3* t, enum MeshTunnel3EState state)
1885 "Tunnel %s estate is now %s\n", 1885 "Tunnel %s estate is now %s\n",
1886 GMP_2s (t->peer), estate2s (state)); 1886 GMP_2s (t->peer), estate2s (state));
1887 if (myid != GMP_get_short_id (t->peer) && 1887 if (myid != GMP_get_short_id (t->peer) &&
1888 MESH_TUNNEL3_KEY_OK != t->estate && MESH_TUNNEL3_KEY_OK == state) 1888 CADET_TUNNEL3_KEY_OK != t->estate && CADET_TUNNEL3_KEY_OK == state)
1889 { 1889 {
1890 t->estate = state; 1890 t->estate = state;
1891 send_queued_data (t); 1891 send_queued_data (t);
@@ -1908,15 +1908,15 @@ GMT_change_estate (struct MeshTunnel3* t, enum MeshTunnel3EState state)
1908static void 1908static void
1909trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1909trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1910{ 1910{
1911 struct MeshTunnel3 *t = cls; 1911 struct CadetTunnel3 *t = cls;
1912 1912
1913 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1913 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1914 return; 1914 return;
1915 1915
1916 if (GMT_count_connections (t) > 2 * CONNECTIONS_PER_TUNNEL) 1916 if (GMT_count_connections (t) > 2 * CONNECTIONS_PER_TUNNEL)
1917 { 1917 {
1918 struct MeshTConnection *iter; 1918 struct CadetTConnection *iter;
1919 struct MeshTConnection *c; 1919 struct CadetTConnection *c;
1920 1920
1921 for (c = iter = t->connection_head; NULL != iter; iter = iter->next) 1921 for (c = iter = t->connection_head; NULL != iter; iter = iter->next)
1922 { 1922 {
@@ -1949,9 +1949,9 @@ trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1949 * @param c Connection. 1949 * @param c Connection.
1950 */ 1950 */
1951void 1951void
1952GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c) 1952GMT_add_connection (struct CadetTunnel3 *t, struct CadetConnection *c)
1953{ 1953{
1954 struct MeshTConnection *aux; 1954 struct CadetTConnection *aux;
1955 1955
1956 GNUNET_assert (NULL != c); 1956 GNUNET_assert (NULL != c);
1957 1957
@@ -1961,7 +1961,7 @@ GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c)
1961 if (aux->c == c) 1961 if (aux->c == c)
1962 return; 1962 return;
1963 1963
1964 aux = GNUNET_new (struct MeshTConnection); 1964 aux = GNUNET_new (struct CadetTConnection);
1965 aux->c = c; 1965 aux->c = c;
1966 aux->created = GNUNET_TIME_absolute_get (); 1966 aux->created = GNUNET_TIME_absolute_get ();
1967 1967
@@ -1978,7 +1978,7 @@ GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c)
1978 * @param path Invalid path to remove. Is destroyed after removal. 1978 * @param path Invalid path to remove. Is destroyed after removal.
1979 */ 1979 */
1980void 1980void
1981GMT_remove_path (struct MeshTunnel3 *t, struct MeshPeerPath *path) 1981GMT_remove_path (struct CadetTunnel3 *t, struct CadetPeerPath *path)
1982{ 1982{
1983 GMP_remove_path (t->peer, path); 1983 GMP_remove_path (t->peer, path);
1984} 1984}
@@ -1991,11 +1991,11 @@ GMT_remove_path (struct MeshTunnel3 *t, struct MeshPeerPath *path)
1991 * @param c Connection. 1991 * @param c Connection.
1992 */ 1992 */
1993void 1993void
1994GMT_remove_connection (struct MeshTunnel3 *t, 1994GMT_remove_connection (struct CadetTunnel3 *t,
1995 struct MeshConnection *c) 1995 struct CadetConnection *c)
1996{ 1996{
1997 struct MeshTConnection *aux; 1997 struct CadetTConnection *aux;
1998 struct MeshTConnection *next; 1998 struct CadetTConnection *next;
1999 1999
2000 LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing connection %s from tunnel %s\n", 2000 LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing connection %s from tunnel %s\n",
2001 GMC_2s (c), GMT_2s (t)); 2001 GMC_2s (c), GMT_2s (t));
@@ -2012,25 +2012,25 @@ GMT_remove_connection (struct MeshTunnel3 *t,
2012 /* Start new connections if needed */ 2012 /* Start new connections if needed */
2013 if (CONNECTIONS_PER_TUNNEL < GMT_count_connections (t) 2013 if (CONNECTIONS_PER_TUNNEL < GMT_count_connections (t)
2014 && GNUNET_SCHEDULER_NO_TASK == t->destroy_task 2014 && GNUNET_SCHEDULER_NO_TASK == t->destroy_task
2015 && MESH_TUNNEL3_SHUTDOWN != t->cstate 2015 && CADET_TUNNEL3_SHUTDOWN != t->cstate
2016 && GNUNET_NO == shutting_down) 2016 && GNUNET_NO == shutting_down)
2017 { 2017 {
2018 LOG (GNUNET_ERROR_TYPE_DEBUG, " no more connections, getting new ones\n"); 2018 LOG (GNUNET_ERROR_TYPE_DEBUG, " no more connections, getting new ones\n");
2019 t->cstate = MESH_TUNNEL3_SEARCHING; 2019 t->cstate = CADET_TUNNEL3_SEARCHING;
2020 GMP_connect (t->peer); 2020 GMP_connect (t->peer);
2021 return; 2021 return;
2022 } 2022 }
2023 2023
2024 /* If not marked as ready, no change is needed */ 2024 /* If not marked as ready, no change is needed */
2025 if (MESH_TUNNEL3_READY != t->cstate) 2025 if (CADET_TUNNEL3_READY != t->cstate)
2026 return; 2026 return;
2027 2027
2028 /* Check if any connection is ready to maintaing cstate */ 2028 /* Check if any connection is ready to maintaing cstate */
2029 for (aux = t->connection_head; aux != NULL; aux = aux->next) 2029 for (aux = t->connection_head; aux != NULL; aux = aux->next)
2030 if (MESH_CONNECTION_READY == GMC_get_state (aux->c)) 2030 if (CADET_CONNECTION_READY == GMC_get_state (aux->c))
2031 return; 2031 return;
2032 2032
2033 t->cstate = MESH_TUNNEL3_WAITING; 2033 t->cstate = CADET_TUNNEL3_WAITING;
2034} 2034}
2035 2035
2036 2036
@@ -2041,9 +2041,9 @@ GMT_remove_connection (struct MeshTunnel3 *t,
2041 * @param ch Channel. 2041 * @param ch Channel.
2042 */ 2042 */
2043void 2043void
2044GMT_add_channel (struct MeshTunnel3 *t, struct MeshChannel *ch) 2044GMT_add_channel (struct CadetTunnel3 *t, struct CadetChannel *ch)
2045{ 2045{
2046 struct MeshTChannel *aux; 2046 struct CadetTChannel *aux;
2047 2047
2048 GNUNET_assert (NULL != ch); 2048 GNUNET_assert (NULL != ch);
2049 2049
@@ -2056,7 +2056,7 @@ GMT_add_channel (struct MeshTunnel3 *t, struct MeshChannel *ch)
2056 return; 2056 return;
2057 } 2057 }
2058 2058
2059 aux = GNUNET_new (struct MeshTChannel); 2059 aux = GNUNET_new (struct CadetTChannel);
2060 aux->ch = ch; 2060 aux->ch = ch;
2061 LOG (GNUNET_ERROR_TYPE_DEBUG, " adding %p to %p\n", aux, t->channel_head); 2061 LOG (GNUNET_ERROR_TYPE_DEBUG, " adding %p to %p\n", aux, t->channel_head);
2062 GNUNET_CONTAINER_DLL_insert_tail (t->channel_head, t->channel_tail, aux); 2062 GNUNET_CONTAINER_DLL_insert_tail (t->channel_head, t->channel_tail, aux);
@@ -2077,9 +2077,9 @@ GMT_add_channel (struct MeshTunnel3 *t, struct MeshChannel *ch)
2077 * @param ch Channel. 2077 * @param ch Channel.
2078 */ 2078 */
2079void 2079void
2080GMT_remove_channel (struct MeshTunnel3 *t, struct MeshChannel *ch) 2080GMT_remove_channel (struct CadetTunnel3 *t, struct CadetChannel *ch)
2081{ 2081{
2082 struct MeshTChannel *aux; 2082 struct CadetTChannel *aux;
2083 2083
2084 LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing channel %p from tunnel %p\n", ch, t); 2084 LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing channel %p from tunnel %p\n", ch, t);
2085 for (aux = t->channel_head; aux != NULL; aux = aux->next) 2085 for (aux = t->channel_head; aux != NULL; aux = aux->next)
@@ -2103,10 +2103,10 @@ GMT_remove_channel (struct MeshTunnel3 *t, struct MeshChannel *ch)
2103 * 2103 *
2104 * @return channel handler, NULL if doesn't exist 2104 * @return channel handler, NULL if doesn't exist
2105 */ 2105 */
2106struct MeshChannel * 2106struct CadetChannel *
2107GMT_get_channel (struct MeshTunnel3 *t, MESH_ChannelNumber chid) 2107GMT_get_channel (struct CadetTunnel3 *t, CADET_ChannelNumber chid)
2108{ 2108{
2109 struct MeshTChannel *iter; 2109 struct CadetTChannel *iter;
2110 2110
2111 if (NULL == t) 2111 if (NULL == t)
2112 return NULL; 2112 return NULL;
@@ -2134,8 +2134,8 @@ GMT_get_channel (struct MeshTunnel3 *t, MESH_ChannelNumber chid)
2134static void 2134static void
2135delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 2135delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2136{ 2136{
2137 struct MeshTunnel3 *t = cls; 2137 struct CadetTunnel3 *t = cls;
2138 struct MeshTConnection *iter; 2138 struct CadetTConnection *iter;
2139 2139
2140 LOG (GNUNET_ERROR_TYPE_DEBUG, "delayed destroying tunnel %p\n", t); 2140 LOG (GNUNET_ERROR_TYPE_DEBUG, "delayed destroying tunnel %p\n", t);
2141 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 2141 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
@@ -2146,7 +2146,7 @@ delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2146 return; 2146 return;
2147 } 2147 }
2148 t->destroy_task = GNUNET_SCHEDULER_NO_TASK; 2148 t->destroy_task = GNUNET_SCHEDULER_NO_TASK;
2149 t->cstate = MESH_TUNNEL3_SHUTDOWN; 2149 t->cstate = CADET_TUNNEL3_SHUTDOWN;
2150 2150
2151 for (iter = t->connection_head; NULL != iter; iter = iter->next) 2151 for (iter = t->connection_head; NULL != iter; iter = iter->next)
2152 { 2152 {
@@ -2164,7 +2164,7 @@ delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2164 * @param t Tunnel to destroy. 2164 * @param t Tunnel to destroy.
2165 */ 2165 */
2166void 2166void
2167GMT_destroy_empty (struct MeshTunnel3 *t) 2167GMT_destroy_empty (struct CadetTunnel3 *t)
2168{ 2168{
2169 if (GNUNET_YES == shutting_down) 2169 if (GNUNET_YES == shutting_down)
2170 return; /* Will be destroyed immediately anyway */ 2170 return; /* Will be destroyed immediately anyway */
@@ -2198,7 +2198,7 @@ GMT_destroy_empty (struct MeshTunnel3 *t)
2198 * @param t Tunnel to destroy if empty. 2198 * @param t Tunnel to destroy if empty.
2199 */ 2199 */
2200void 2200void
2201GMT_destroy_if_empty (struct MeshTunnel3 *t) 2201GMT_destroy_if_empty (struct CadetTunnel3 *t)
2202{ 2202{
2203 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s destroy if empty\n", GMT_2s (t)); 2203 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s destroy if empty\n", GMT_2s (t));
2204 if (1 < GMT_count_channels (t)) 2204 if (1 < GMT_count_channels (t))
@@ -2220,12 +2220,12 @@ GMT_destroy_if_empty (struct MeshTunnel3 *t)
2220 * @param t The tunnel to destroy. 2220 * @param t The tunnel to destroy.
2221 */ 2221 */
2222void 2222void
2223GMT_destroy (struct MeshTunnel3 *t) 2223GMT_destroy (struct CadetTunnel3 *t)
2224{ 2224{
2225 struct MeshTConnection *iter_c; 2225 struct CadetTConnection *iter_c;
2226 struct MeshTConnection *next_c; 2226 struct CadetTConnection *next_c;
2227 struct MeshTChannel *iter_ch; 2227 struct CadetTChannel *iter_ch;
2228 struct MeshTChannel *next_ch; 2228 struct CadetTChannel *next_ch;
2229 2229
2230 if (NULL == t) 2230 if (NULL == t)
2231 return; 2231 return;
@@ -2282,11 +2282,11 @@ GMT_destroy (struct MeshTunnel3 *t)
2282 * 2282 *
2283 * @return Connection created. 2283 * @return Connection created.
2284 */ 2284 */
2285struct MeshConnection * 2285struct CadetConnection *
2286GMT_use_path (struct MeshTunnel3 *t, struct MeshPeerPath *p) 2286GMT_use_path (struct CadetTunnel3 *t, struct CadetPeerPath *p)
2287{ 2287{
2288 struct MeshConnection *c; 2288 struct CadetConnection *c;
2289 struct GNUNET_MESH_Hash cid; 2289 struct GNUNET_CADET_Hash cid;
2290 unsigned int own_pos; 2290 unsigned int own_pos;
2291 2291
2292 if (NULL == t || NULL == p) 2292 if (NULL == t || NULL == p)
@@ -2295,7 +2295,7 @@ GMT_use_path (struct MeshTunnel3 *t, struct MeshPeerPath *p)
2295 return NULL; 2295 return NULL;
2296 } 2296 }
2297 2297
2298 if (MESH_TUNNEL3_SHUTDOWN == t->cstate) 2298 if (CADET_TUNNEL3_SHUTDOWN == t->cstate)
2299 { 2299 {
2300 GNUNET_break (0); 2300 GNUNET_break (0);
2301 return NULL; 2301 return NULL;
@@ -2332,16 +2332,16 @@ GMT_use_path (struct MeshTunnel3 *t, struct MeshPeerPath *p)
2332 * @return Number of connections. 2332 * @return Number of connections.
2333 */ 2333 */
2334unsigned int 2334unsigned int
2335GMT_count_connections (struct MeshTunnel3 *t) 2335GMT_count_connections (struct CadetTunnel3 *t)
2336{ 2336{
2337 struct MeshTConnection *iter; 2337 struct CadetTConnection *iter;
2338 unsigned int count; 2338 unsigned int count;
2339 2339
2340 if (NULL == t) 2340 if (NULL == t)
2341 return 0; 2341 return 0;
2342 2342
2343 for (count = 0, iter = t->connection_head; NULL != iter; iter = iter->next) 2343 for (count = 0, iter = t->connection_head; NULL != iter; iter = iter->next)
2344 if (MESH_CONNECTION_DESTROYED != GMC_get_state (iter->c)) 2344 if (CADET_CONNECTION_DESTROYED != GMC_get_state (iter->c))
2345 count++; 2345 count++;
2346 2346
2347 return count; 2347 return count;
@@ -2355,9 +2355,9 @@ GMT_count_connections (struct MeshTunnel3 *t)
2355 * @return Number of channels. 2355 * @return Number of channels.
2356 */ 2356 */
2357unsigned int 2357unsigned int
2358GMT_count_channels (struct MeshTunnel3 *t) 2358GMT_count_channels (struct CadetTunnel3 *t)
2359{ 2359{
2360 struct MeshTChannel *iter; 2360 struct CadetTChannel *iter;
2361 unsigned int count; 2361 unsigned int count;
2362 2362
2363 for (count = 0, iter = t->channel_head; 2363 for (count = 0, iter = t->channel_head;
@@ -2375,13 +2375,13 @@ GMT_count_channels (struct MeshTunnel3 *t)
2375 * 2375 *
2376 * @return Tunnel's connectivity state. 2376 * @return Tunnel's connectivity state.
2377 */ 2377 */
2378enum MeshTunnel3CState 2378enum CadetTunnel3CState
2379GMT_get_cstate (struct MeshTunnel3 *t) 2379GMT_get_cstate (struct CadetTunnel3 *t)
2380{ 2380{
2381 if (NULL == t) 2381 if (NULL == t)
2382 { 2382 {
2383 GNUNET_assert (0); 2383 GNUNET_assert (0);
2384 return (enum MeshTunnel3CState) -1; 2384 return (enum CadetTunnel3CState) -1;
2385 } 2385 }
2386 return t->cstate; 2386 return t->cstate;
2387} 2387}
@@ -2394,13 +2394,13 @@ GMT_get_cstate (struct MeshTunnel3 *t)
2394 * 2394 *
2395 * @return Tunnel's encryption state. 2395 * @return Tunnel's encryption state.
2396 */ 2396 */
2397enum MeshTunnel3EState 2397enum CadetTunnel3EState
2398GMT_get_estate (struct MeshTunnel3 *t) 2398GMT_get_estate (struct CadetTunnel3 *t)
2399{ 2399{
2400 if (NULL == t) 2400 if (NULL == t)
2401 { 2401 {
2402 GNUNET_assert (0); 2402 GNUNET_assert (0);
2403 return (enum MeshTunnel3EState) -1; 2403 return (enum CadetTunnel3EState) -1;
2404 } 2404 }
2405 return t->estate; 2405 return t->estate;
2406} 2406}
@@ -2413,9 +2413,9 @@ GMT_get_estate (struct MeshTunnel3 *t)
2413 * @return Biggest buffer space offered by any channel in the tunnel. 2413 * @return Biggest buffer space offered by any channel in the tunnel.
2414 */ 2414 */
2415unsigned int 2415unsigned int
2416GMT_get_channels_buffer (struct MeshTunnel3 *t) 2416GMT_get_channels_buffer (struct CadetTunnel3 *t)
2417{ 2417{
2418 struct MeshTChannel *iter; 2418 struct CadetTChannel *iter;
2419 unsigned int buffer; 2419 unsigned int buffer;
2420 unsigned int ch_buf; 2420 unsigned int ch_buf;
2421 2421
@@ -2444,15 +2444,15 @@ GMT_get_channels_buffer (struct MeshTunnel3 *t)
2444 * @return Buffer space offered by all connections in the tunnel. 2444 * @return Buffer space offered by all connections in the tunnel.
2445 */ 2445 */
2446unsigned int 2446unsigned int
2447GMT_get_connections_buffer (struct MeshTunnel3 *t) 2447GMT_get_connections_buffer (struct CadetTunnel3 *t)
2448{ 2448{
2449 struct MeshTConnection *iter; 2449 struct CadetTConnection *iter;
2450 unsigned int buffer; 2450 unsigned int buffer;
2451 2451
2452 buffer = 0; 2452 buffer = 0;
2453 for (iter = t->connection_head; NULL != iter; iter = iter->next) 2453 for (iter = t->connection_head; NULL != iter; iter = iter->next)
2454 { 2454 {
2455 if (GMC_get_state (iter->c) != MESH_CONNECTION_READY) 2455 if (GMC_get_state (iter->c) != CADET_CONNECTION_READY)
2456 { 2456 {
2457 continue; 2457 continue;
2458 } 2458 }
@@ -2471,7 +2471,7 @@ GMT_get_connections_buffer (struct MeshTunnel3 *t)
2471 * @return ID of the destination peer. 2471 * @return ID of the destination peer.
2472 */ 2472 */
2473const struct GNUNET_PeerIdentity * 2473const struct GNUNET_PeerIdentity *
2474GMT_get_destination (struct MeshTunnel3 *t) 2474GMT_get_destination (struct CadetTunnel3 *t)
2475{ 2475{
2476 return GMP_get_id (t->peer); 2476 return GMP_get_id (t->peer);
2477} 2477}
@@ -2484,11 +2484,11 @@ GMT_get_destination (struct MeshTunnel3 *t)
2484 * 2484 *
2485 * @return GID of a channel free to use. 2485 * @return GID of a channel free to use.
2486 */ 2486 */
2487MESH_ChannelNumber 2487CADET_ChannelNumber
2488GMT_get_next_chid (struct MeshTunnel3 *t) 2488GMT_get_next_chid (struct CadetTunnel3 *t)
2489{ 2489{
2490 MESH_ChannelNumber chid; 2490 CADET_ChannelNumber chid;
2491 MESH_ChannelNumber mask; 2491 CADET_ChannelNumber mask;
2492 int result; 2492 int result;
2493 2493
2494 /* Set bit 30 depending on the ID relationship. Bit 31 is always 0 for GID. 2494 /* Set bit 30 depending on the ID relationship. Bit 31 is always 0 for GID.
@@ -2505,11 +2505,11 @@ GMT_get_next_chid (struct MeshTunnel3 *t)
2505 while (NULL != GMT_get_channel (t, t->next_chid)) 2505 while (NULL != GMT_get_channel (t, t->next_chid))
2506 { 2506 {
2507 LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %u exists...\n", t->next_chid); 2507 LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %u exists...\n", t->next_chid);
2508 t->next_chid = (t->next_chid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; 2508 t->next_chid = (t->next_chid + 1) & ~GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
2509 t->next_chid |= mask; 2509 t->next_chid |= mask;
2510 } 2510 }
2511 chid = t->next_chid; 2511 chid = t->next_chid;
2512 t->next_chid = (t->next_chid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; 2512 t->next_chid = (t->next_chid + 1) & ~GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
2513 t->next_chid |= mask; 2513 t->next_chid |= mask;
2514 2514
2515 return chid; 2515 return chid;
@@ -2522,13 +2522,13 @@ GMT_get_next_chid (struct MeshTunnel3 *t)
2522 * @param t Channel which has some free buffer space. 2522 * @param t Channel which has some free buffer space.
2523 */ 2523 */
2524void 2524void
2525GMT_unchoke_channels (struct MeshTunnel3 *t) 2525GMT_unchoke_channels (struct CadetTunnel3 *t)
2526{ 2526{
2527 struct MeshTChannel *iter; 2527 struct CadetTChannel *iter;
2528 unsigned int buffer; 2528 unsigned int buffer;
2529 unsigned int channels = GMT_count_channels (t); 2529 unsigned int channels = GMT_count_channels (t);
2530 unsigned int choked_n; 2530 unsigned int choked_n;
2531 struct MeshChannel *choked[channels]; 2531 struct CadetChannel *choked[channels];
2532 2532
2533 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT_unchoke_channels on %s\n", GMT_2s (t)); 2533 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT_unchoke_channels on %s\n", GMT_2s (t));
2534 LOG (GNUNET_ERROR_TYPE_DEBUG, " head: %p\n", t->channel_head); 2534 LOG (GNUNET_ERROR_TYPE_DEBUG, " head: %p\n", t->channel_head);
@@ -2573,9 +2573,9 @@ GMT_unchoke_channels (struct MeshTunnel3 *t)
2573 * @param t Tunnel. 2573 * @param t Tunnel.
2574 */ 2574 */
2575void 2575void
2576GMT_send_connection_acks (struct MeshTunnel3 *t) 2576GMT_send_connection_acks (struct CadetTunnel3 *t)
2577{ 2577{
2578 struct MeshTConnection *iter; 2578 struct CadetTConnection *iter;
2579 uint32_t allowed; 2579 uint32_t allowed;
2580 uint32_t to_allow; 2580 uint32_t to_allow;
2581 uint32_t allow_per_connection; 2581 uint32_t allow_per_connection;
@@ -2640,7 +2640,7 @@ GMT_send_connection_acks (struct MeshTunnel3 *t)
2640 * @param q Handle to the queue. 2640 * @param q Handle to the queue.
2641 */ 2641 */
2642void 2642void
2643GMT_cancel (struct MeshTunnel3Queue *q) 2643GMT_cancel (struct CadetTunnel3Queue *q)
2644{ 2644{
2645 if (NULL != q->cq) 2645 if (NULL != q->cq)
2646 { 2646 {
@@ -2675,9 +2675,9 @@ GMT_cancel (struct MeshTunnel3Queue *q)
2675 * 2675 *
2676 * @return Handle to cancel message. NULL if @c cont is NULL. 2676 * @return Handle to cancel message. NULL if @c cont is NULL.
2677 */ 2677 */
2678struct MeshTunnel3Queue * 2678struct CadetTunnel3Queue *
2679GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, 2679GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2680 struct MeshTunnel3 *t, struct MeshConnection *c, 2680 struct CadetTunnel3 *t, struct CadetConnection *c,
2681 int force, GMT_sent cont, void *cont_cls) 2681 int force, GMT_sent cont, void *cont_cls)
2682{ 2682{
2683 return send_prebuilt_message (message, t, c, force, cont, cont_cls, NULL); 2683 return send_prebuilt_message (message, t, c, force, cont, cont_cls, NULL);
@@ -2692,7 +2692,7 @@ GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2692 * @return #GNUNET_YES if it is loopback. 2692 * @return #GNUNET_YES if it is loopback.
2693 */ 2693 */
2694int 2694int
2695GMT_is_loopback (const struct MeshTunnel3 *t) 2695GMT_is_loopback (const struct CadetTunnel3 *t)
2696{ 2696{
2697 return (myid == GMP_get_short_id (t->peer)); 2697 return (myid == GMP_get_short_id (t->peer));
2698} 2698}
@@ -2707,9 +2707,9 @@ GMT_is_loopback (const struct MeshTunnel3 *t)
2707 * @return #GNUNET_YES a connection uses this path. 2707 * @return #GNUNET_YES a connection uses this path.
2708 */ 2708 */
2709int 2709int
2710GMT_is_path_used (const struct MeshTunnel3 *t, const struct MeshPeerPath *p) 2710GMT_is_path_used (const struct CadetTunnel3 *t, const struct CadetPeerPath *p)
2711{ 2711{
2712 struct MeshTConnection *iter; 2712 struct CadetTConnection *iter;
2713 2713
2714 for (iter = t->connection_head; NULL != iter; iter = iter->next) 2714 for (iter = t->connection_head; NULL != iter; iter = iter->next)
2715 if (GMC_get_path (iter->c) == p) 2715 if (GMC_get_path (iter->c) == p)
@@ -2728,11 +2728,11 @@ GMT_is_path_used (const struct MeshTunnel3 *t, const struct MeshPeerPath *p)
2728 * @return Cost of the path (path length + number of overlapping nodes) 2728 * @return Cost of the path (path length + number of overlapping nodes)
2729 */ 2729 */
2730unsigned int 2730unsigned int
2731GMT_get_path_cost (const struct MeshTunnel3 *t, 2731GMT_get_path_cost (const struct CadetTunnel3 *t,
2732 const struct MeshPeerPath *path) 2732 const struct CadetPeerPath *path)
2733{ 2733{
2734 struct MeshTConnection *iter; 2734 struct CadetTConnection *iter;
2735 const struct MeshPeerPath *aux; 2735 const struct CadetPeerPath *aux;
2736 unsigned int overlap; 2736 unsigned int overlap;
2737 unsigned int i; 2737 unsigned int i;
2738 unsigned int j; 2738 unsigned int j;
@@ -2773,7 +2773,7 @@ GMT_get_path_cost (const struct MeshTunnel3 *t,
2773 * @return Static string the destination peer's ID. 2773 * @return Static string the destination peer's ID.
2774 */ 2774 */
2775const char * 2775const char *
2776GMT_2s (const struct MeshTunnel3 *t) 2776GMT_2s (const struct CadetTunnel3 *t)
2777{ 2777{
2778 if (NULL == t) 2778 if (NULL == t)
2779 return "(NULL)"; 2779 return "(NULL)";
@@ -2793,10 +2793,10 @@ GMT_2s (const struct MeshTunnel3 *t)
2793 * @param t Tunnel to debug. 2793 * @param t Tunnel to debug.
2794 */ 2794 */
2795void 2795void
2796GMT_debug (const struct MeshTunnel3 *t) 2796GMT_debug (const struct CadetTunnel3 *t)
2797{ 2797{
2798 struct MeshTChannel *iterch; 2798 struct CadetTChannel *iterch;
2799 struct MeshTConnection *iterc; 2799 struct CadetTConnection *iterc;
2800 2800
2801 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT DEBUG TUNNEL TOWARDS %s\n", GMT_2s (t)); 2801 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT DEBUG TUNNEL TOWARDS %s\n", GMT_2s (t));
2802 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT cstate %s, estate %s\n", 2802 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT cstate %s, estate %s\n",
@@ -2861,9 +2861,9 @@ GMT_count_all (void)
2861 * @param cls Closure for @c iter. 2861 * @param cls Closure for @c iter.
2862 */ 2862 */
2863void 2863void
2864GMT_iterate_connections (struct MeshTunnel3 *t, GMT_conn_iter iter, void *cls) 2864GMT_iterate_connections (struct CadetTunnel3 *t, GMT_conn_iter iter, void *cls)
2865{ 2865{
2866 struct MeshTConnection *ct; 2866 struct CadetTConnection *ct;
2867 2867
2868 for (ct = t->connection_head; NULL != ct; ct = ct->next) 2868 for (ct = t->connection_head; NULL != ct; ct = ct->next)
2869 iter (cls, ct->c); 2869 iter (cls, ct->c);
@@ -2878,9 +2878,9 @@ GMT_iterate_connections (struct MeshTunnel3 *t, GMT_conn_iter iter, void *cls)
2878 * @param cls Closure for @c iter. 2878 * @param cls Closure for @c iter.
2879 */ 2879 */
2880void 2880void
2881GMT_iterate_channels (struct MeshTunnel3 *t, GMT_chan_iter iter, void *cls) 2881GMT_iterate_channels (struct CadetTunnel3 *t, GMT_chan_iter iter, void *cls)
2882{ 2882{
2883 struct MeshTChannel *cht; 2883 struct CadetTChannel *cht;
2884 2884
2885 for (cht = t->channel_head; NULL != cht; cht = cht->next) 2885 for (cht = t->channel_head; NULL != cht; cht = cht->next)
2886 iter (cls, cht->ch); 2886 iter (cls, cht->ch);