aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_tunnel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/gnunet-service-cadet_tunnel.c')
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c170
1 files changed, 85 insertions, 85 deletions
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index 971b186c9..f4952b870 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -101,7 +101,7 @@ struct CadetTunnelKXCtx
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 CadetTunnel3 104struct CadetTunnel
105{ 105{
106 /** 106 /**
107 * Endpoint of the tunnel. 107 * Endpoint of the tunnel.
@@ -111,12 +111,12 @@ struct CadetTunnel3
111 /** 111 /**
112 * State of the tunnel connectivity. 112 * State of the tunnel connectivity.
113 */ 113 */
114 enum CadetTunnel3CState cstate; 114 enum CadetTunnelCState cstate;
115 115
116 /** 116 /**
117 * State of the tunnel encryption. 117 * State of the tunnel encryption.
118 */ 118 */
119 enum CadetTunnel3EState estate; 119 enum CadetTunnelEState estate;
120 120
121 /** 121 /**
122 * Key eXchange context. 122 * Key eXchange context.
@@ -187,12 +187,12 @@ struct CadetTunnelDelayed
187 /** 187 /**
188 * Tunnel. 188 * Tunnel.
189 */ 189 */
190 struct CadetTunnel3 *t; 190 struct CadetTunnel *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 CadetTunnel3Queue *tq; 195 struct CadetTunnelQueue *tq;
196 196
197 /** 197 /**
198 * Message to send. 198 * Message to send.
@@ -204,7 +204,7 @@ struct CadetTunnelDelayed
204/** 204/**
205 * Handle for messages queued but not yet sent. 205 * Handle for messages queued but not yet sent.
206 */ 206 */
207struct CadetTunnel3Queue 207struct CadetTunnelQueue
208{ 208{
209 /** 209 /**
210 * Connection queue handle, to cancel if necessary. 210 * Connection queue handle, to cancel if necessary.
@@ -302,7 +302,7 @@ 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 CadetTunnel3CState cs) 305cstate2s (enum CadetTunnelCState cs)
306{ 306{
307 static char buf[128]; 307 static char buf[128];
308 308
@@ -333,7 +333,7 @@ cstate2s (enum CadetTunnel3CState cs)
333 * @return String representation. 333 * @return String representation.
334 */ 334 */
335static const char * 335static const char *
336estate2s (enum CadetTunnel3EState es) 336estate2s (enum CadetTunnelEState es)
337{ 337{
338 static char buf[128]; 338 static char buf[128];
339 339
@@ -366,7 +366,7 @@ estate2s (enum CadetTunnel3EState 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 CadetTunnel3 *t) 369is_ready (struct CadetTunnel *t)
370{ 370{
371 int ready; 371 int ready;
372 372
@@ -490,7 +490,7 @@ get_connection_allowed (const struct CadetTConnection *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 CadetTunnel3 *t, 493check_ephemeral (struct CadetTunnel *t,
494 const struct GNUNET_CADET_KX_Ephemeral *msg) 494 const struct GNUNET_CADET_KX_Ephemeral *msg)
495{ 495{
496 /* Check message size */ 496 /* Check message size */
@@ -529,7 +529,7 @@ check_ephemeral (struct CadetTunnel3 *t,
529 * @param iv Initialization Vector to use. 529 * @param iv Initialization Vector to use.
530 */ 530 */
531static int 531static int
532t_encrypt (struct CadetTunnel3 *t, 532t_encrypt (struct CadetTunnel *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 CadetTunnel3 *t,
556 * @param iv Initialization Vector to use. 556 * @param iv Initialization Vector to use.
557 */ 557 */
558static int 558static int
559t_decrypt (struct CadetTunnel3 *t, 559t_decrypt (struct CadetTunnel *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{
@@ -645,7 +645,7 @@ derive_symmertic (struct GNUNET_CRYPTO_SymmetricSessionKey *key,
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 CadetConnection * 647static struct CadetConnection *
648tunnel_get_connection (struct CadetTunnel3 *t) 648tunnel_get_connection (struct CadetTunnel *t)
649{ 649{
650 struct CadetTConnection *iter; 650 struct CadetTConnection *iter;
651 struct CadetConnection *best; 651 struct CadetConnection *best;
@@ -693,8 +693,8 @@ tun_message_sent (void *cls,
693 struct CadetConnectionQueue *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 CadetTunnel3Queue *qt = cls; 696 struct CadetTunnelQueue *qt = cls;
697 struct CadetTunnel3 *t; 697 struct CadetTunnel *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
@@ -726,7 +726,7 @@ unqueue_data (struct CadetTunnelDelayed *tqd)
726 * @param msg Message itself (copy will be made). 726 * @param msg Message itself (copy will be made).
727 */ 727 */
728static struct CadetTunnelDelayed * 728static struct CadetTunnelDelayed *
729queue_data (struct CadetTunnel3 *t, const struct GNUNET_MessageHeader *msg) 729queue_data (struct CadetTunnel *t, const struct GNUNET_MessageHeader *msg)
730{ 730{
731 struct CadetTunnelDelayed *tqd; 731 struct CadetTunnelDelayed *tqd;
732 uint16_t size = ntohs (msg->size); 732 uint16_t size = ntohs (msg->size);
@@ -759,7 +759,7 @@ queue_data (struct CadetTunnel3 *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 CadetTunnel3 *t, const void *plaintext, size_t size, uint32_t iv, 762t_hmac (struct CadetTunnel *t, const void *plaintext, size_t size, uint32_t iv,
763 int outgoing, struct GNUNET_CADET_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;
@@ -794,13 +794,13 @@ t_hmac (struct CadetTunnel3 *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 CadetTunnel3Queue * 797static struct CadetTunnelQueue *
798send_prebuilt_message (const struct GNUNET_MessageHeader *message, 798send_prebuilt_message (const struct GNUNET_MessageHeader *message,
799 struct CadetTunnel3 *t, struct CadetConnection *c, 799 struct CadetTunnel *t, struct CadetConnection *c,
800 int force, GCT_sent cont, void *cont_cls, 800 int force, GCT_sent cont, void *cont_cls,
801 struct CadetTunnel3Queue *existing_q) 801 struct CadetTunnelQueue *existing_q)
802{ 802{
803 struct CadetTunnel3Queue *tq; 803 struct CadetTunnelQueue *tq;
804 struct GNUNET_CADET_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_CADET_Encrypted) + size]; 806 char cbuf[sizeof (struct GNUNET_CADET_Encrypted) + size];
@@ -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 CadetTunnel3Queue); 824 tq = GNUNET_new (struct CadetTunnelQueue);
825 tq->tqd = tqd; 825 tq->tqd = tqd;
826 tqd->tq = tq; 826 tqd->tq = tq;
827 tq->cont = cont; 827 tq->cont = cont;
@@ -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 CadetTunnel3Queue); /* FIXME valgrind: leak*/ 890 tq = GNUNET_new (struct CadetTunnelQueue); /* FIXME valgrind: leak*/
891 } 891 }
892 else 892 else
893 { 893 {
@@ -909,7 +909,7 @@ 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 CadetTunnel3 *t) 912send_queued_data (struct CadetTunnel *t)
913{ 913{
914 struct CadetTunnelDelayed *tqd; 914 struct CadetTunnelDelayed *tqd;
915 struct CadetTunnelDelayed *next; 915 struct CadetTunnelDelayed *next;
@@ -959,7 +959,7 @@ send_queued_data (struct CadetTunnel3 *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 CadetTunnel3 *t, 962send_kx (struct CadetTunnel *t,
963 const struct GNUNET_MessageHeader *message) 963 const struct GNUNET_MessageHeader *message)
964{ 964{
965 struct CadetConnection *c; 965 struct CadetConnection *c;
@@ -1030,7 +1030,7 @@ send_kx (struct CadetTunnel3 *t,
1030 * @param t Tunnel on which to send the key. 1030 * @param t Tunnel on which to send the key.
1031 */ 1031 */
1032static void 1032static void
1033send_ephemeral (struct CadetTunnel3 *t) 1033send_ephemeral (struct CadetTunnel *t)
1034{ 1034{
1035 LOG (GNUNET_ERROR_TYPE_INFO, "=> EPHM for %s\n", GCT_2s (t)); 1035 LOG (GNUNET_ERROR_TYPE_INFO, "=> EPHM for %s\n", GCT_2s (t));
1036 1036
@@ -1044,7 +1044,7 @@ send_ephemeral (struct CadetTunnel3 *t)
1044 * @param t Tunnel on which to send the ping. 1044 * @param t Tunnel on which to send the ping.
1045 */ 1045 */
1046static void 1046static void
1047send_ping (struct CadetTunnel3 *t) 1047send_ping (struct CadetTunnel *t)
1048{ 1048{
1049 struct GNUNET_CADET_KX_Ping msg; 1049 struct GNUNET_CADET_KX_Ping msg;
1050 1050
@@ -1072,7 +1072,7 @@ send_ping (struct CadetTunnel3 *t)
1072 * @param challenge Value sent in the ping that we have to send back. 1072 * @param challenge Value sent in the ping that we have to send back.
1073 */ 1073 */
1074static void 1074static void
1075send_pong (struct CadetTunnel3 *t, uint32_t challenge) 1075send_pong (struct CadetTunnel *t, uint32_t challenge)
1076{ 1076{
1077 struct GNUNET_CADET_KX_Pong msg; 1077 struct GNUNET_CADET_KX_Pong msg;
1078 1078
@@ -1098,7 +1098,7 @@ send_pong (struct CadetTunnel3 *t, uint32_t challenge)
1098static void 1098static void
1099rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1099rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1100{ 1100{
1101 struct CadetTunnel3 *t = cls; 1101 struct CadetTunnel *t = cls;
1102 1102
1103 t->rekey_task = GNUNET_SCHEDULER_NO_TASK; 1103 t->rekey_task = GNUNET_SCHEDULER_NO_TASK;
1104 1104
@@ -1153,7 +1153,7 @@ rekey_iterator (void *cls,
1153 const struct GNUNET_PeerIdentity *key, 1153 const struct GNUNET_PeerIdentity *key,
1154 void *value) 1154 void *value)
1155{ 1155{
1156 struct CadetTunnel3 *t = value; 1156 struct CadetTunnel *t = value;
1157 struct GNUNET_TIME_Relative delay; 1157 struct GNUNET_TIME_Relative delay;
1158 long n = (long) cls; 1158 long n = (long) cls;
1159 uint32_t r; 1159 uint32_t r;
@@ -1225,7 +1225,7 @@ destroy_iterator (void *cls,
1225 const struct GNUNET_PeerIdentity *key, 1225 const struct GNUNET_PeerIdentity *key,
1226 void *value) 1226 void *value)
1227{ 1227{
1228 struct CadetTunnel3 *t = value; 1228 struct CadetTunnel *t = value;
1229 1229
1230 LOG (GNUNET_ERROR_TYPE_DEBUG, "GCT_shutdown destroying tunnel at %p\n", t); 1230 LOG (GNUNET_ERROR_TYPE_DEBUG, "GCT_shutdown destroying tunnel at %p\n", t);
1231 GCT_destroy (t); 1231 GCT_destroy (t);
@@ -1241,7 +1241,7 @@ destroy_iterator (void *cls,
1241 * @param gid ID of the channel. 1241 * @param gid ID of the channel.
1242 */ 1242 */
1243static void 1243static void
1244send_channel_destroy (struct CadetTunnel3 *t, unsigned int gid) 1244send_channel_destroy (struct CadetTunnel *t, unsigned int gid)
1245{ 1245{
1246 struct GNUNET_CADET_ChannelManage msg; 1246 struct GNUNET_CADET_ChannelManage msg;
1247 1247
@@ -1267,7 +1267,7 @@ send_channel_destroy (struct CadetTunnel3 *t, unsigned int gid)
1267 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1267 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1268 */ 1268 */
1269static void 1269static void
1270handle_data (struct CadetTunnel3 *t, 1270handle_data (struct CadetTunnel *t,
1271 const struct GNUNET_CADET_Data *msg, 1271 const struct GNUNET_CADET_Data *msg,
1272 int fwd) 1272 int fwd)
1273{ 1273{
@@ -1313,7 +1313,7 @@ handle_data (struct CadetTunnel3 *t,
1313 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1313 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1314 */ 1314 */
1315static void 1315static void
1316handle_data_ack (struct CadetTunnel3 *t, 1316handle_data_ack (struct CadetTunnel *t,
1317 const struct GNUNET_CADET_DataACK *msg, 1317 const struct GNUNET_CADET_DataACK *msg,
1318 int fwd) 1318 int fwd)
1319{ 1319{
@@ -1350,7 +1350,7 @@ handle_data_ack (struct CadetTunnel3 *t,
1350 * @param msg Data message. 1350 * @param msg Data message.
1351 */ 1351 */
1352static void 1352static void
1353handle_ch_create (struct CadetTunnel3 *t, 1353handle_ch_create (struct CadetTunnel *t,
1354 const struct GNUNET_CADET_ChannelCreate *msg) 1354 const struct GNUNET_CADET_ChannelCreate *msg)
1355{ 1355{
1356 struct CadetChannel *ch; 1356 struct CadetChannel *ch;
@@ -1385,7 +1385,7 @@ handle_ch_create (struct CadetTunnel3 *t,
1385 * @param msg NACK message. 1385 * @param msg NACK message.
1386 */ 1386 */
1387static void 1387static void
1388handle_ch_nack (struct CadetTunnel3 *t, 1388handle_ch_nack (struct CadetTunnel *t,
1389 const struct GNUNET_CADET_ChannelManage *msg) 1389 const struct GNUNET_CADET_ChannelManage *msg)
1390{ 1390{
1391 struct CadetChannel *ch; 1391 struct CadetChannel *ch;
@@ -1425,7 +1425,7 @@ handle_ch_nack (struct CadetTunnel3 *t,
1425 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1425 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1426 */ 1426 */
1427static void 1427static void
1428handle_ch_ack (struct CadetTunnel3 *t, 1428handle_ch_ack (struct CadetTunnel *t,
1429 const struct GNUNET_CADET_ChannelManage *msg, 1429 const struct GNUNET_CADET_ChannelManage *msg,
1430 int fwd) 1430 int fwd)
1431{ 1431{
@@ -1467,7 +1467,7 @@ handle_ch_ack (struct CadetTunnel3 *t,
1467 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1467 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1468 */ 1468 */
1469static void 1469static void
1470handle_ch_destroy (struct CadetTunnel3 *t, 1470handle_ch_destroy (struct CadetTunnel *t,
1471 const struct GNUNET_CADET_ChannelManage *msg, 1471 const struct GNUNET_CADET_ChannelManage *msg,
1472 int fwd) 1472 int fwd)
1473{ 1473{
@@ -1501,7 +1501,7 @@ handle_ch_destroy (struct CadetTunnel3 *t,
1501 * @param msg Key eXchange message. 1501 * @param msg Key eXchange message.
1502 */ 1502 */
1503static void 1503static void
1504handle_ephemeral (struct CadetTunnel3 *t, 1504handle_ephemeral (struct CadetTunnel *t,
1505 const struct GNUNET_CADET_KX_Ephemeral *msg) 1505 const struct GNUNET_CADET_KX_Ephemeral *msg)
1506{ 1506{
1507 struct GNUNET_HashCode km; 1507 struct GNUNET_HashCode km;
@@ -1533,7 +1533,7 @@ handle_ephemeral (struct CadetTunnel3 *t,
1533 * @param msg Key eXchange Ping message. 1533 * @param msg Key eXchange Ping message.
1534 */ 1534 */
1535static void 1535static void
1536handle_ping (struct CadetTunnel3 *t, 1536handle_ping (struct CadetTunnel *t,
1537 const struct GNUNET_CADET_KX_Ping *msg) 1537 const struct GNUNET_CADET_KX_Ping *msg)
1538{ 1538{
1539 struct GNUNET_CADET_KX_Ping res; 1539 struct GNUNET_CADET_KX_Ping res;
@@ -1572,7 +1572,7 @@ handle_ping (struct CadetTunnel3 *t,
1572 * @param msg Key eXchange Pong message. 1572 * @param msg Key eXchange Pong message.
1573 */ 1573 */
1574static void 1574static void
1575handle_pong (struct CadetTunnel3 *t, 1575handle_pong (struct CadetTunnel *t,
1576 const struct GNUNET_CADET_KX_Pong *msg) 1576 const struct GNUNET_CADET_KX_Pong *msg)
1577{ 1577{
1578 uint32_t challenge; 1578 uint32_t challenge;
@@ -1614,7 +1614,7 @@ handle_pong (struct CadetTunnel3 *t,
1614 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1614 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1615 */ 1615 */
1616static void 1616static void
1617handle_decrypted (struct CadetTunnel3 *t, 1617handle_decrypted (struct CadetTunnel *t,
1618 const struct GNUNET_MessageHeader *msgh, 1618 const struct GNUNET_MessageHeader *msgh,
1619 int fwd) 1619 int fwd)
1620{ 1620{
@@ -1682,7 +1682,7 @@ handle_decrypted (struct CadetTunnel3 *t,
1682 * @param msg Encrypted message. 1682 * @param msg Encrypted message.
1683 */ 1683 */
1684void 1684void
1685GCT_handle_encrypted (struct CadetTunnel3 *t, 1685GCT_handle_encrypted (struct CadetTunnel *t,
1686 const struct GNUNET_CADET_Encrypted *msg) 1686 const struct GNUNET_CADET_Encrypted *msg)
1687{ 1687{
1688 size_t size = ntohs (msg->header.size); 1688 size_t size = ntohs (msg->header.size);
@@ -1721,7 +1721,7 @@ GCT_handle_encrypted (struct CadetTunnel3 *t,
1721 * @param message Payload of KX message. 1721 * @param message Payload of KX message.
1722 */ 1722 */
1723void 1723void
1724GCT_handle_kx (struct CadetTunnel3 *t, 1724GCT_handle_kx (struct CadetTunnel *t,
1725 const struct GNUNET_MessageHeader *message) 1725 const struct GNUNET_MessageHeader *message)
1726{ 1726{
1727 uint16_t type; 1727 uint16_t type;
@@ -1808,12 +1808,12 @@ GCT_shutdown (void)
1808 * 1808 *
1809 * @param destination Peer this tunnel is towards. 1809 * @param destination Peer this tunnel is towards.
1810 */ 1810 */
1811struct CadetTunnel3 * 1811struct CadetTunnel *
1812GCT_new (struct CadetPeer *destination) 1812GCT_new (struct CadetPeer *destination)
1813{ 1813{
1814 struct CadetTunnel3 *t; 1814 struct CadetTunnel *t;
1815 1815
1816 t = GNUNET_new (struct CadetTunnel3); 1816 t = GNUNET_new (struct CadetTunnel);
1817 t->next_chid = 0; 1817 t->next_chid = 0;
1818 t->peer = destination; 1818 t->peer = destination;
1819 1819
@@ -1836,7 +1836,7 @@ GCT_new (struct CadetPeer *destination)
1836 * @param cstate New connection state. 1836 * @param cstate New connection state.
1837 */ 1837 */
1838void 1838void
1839GCT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate) 1839GCT_change_cstate (struct CadetTunnel* t, enum CadetTunnelCState cstate)
1840{ 1840{
1841 if (NULL == t) 1841 if (NULL == t)
1842 return; 1842 return;
@@ -1875,7 +1875,7 @@ GCT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate)
1875 * @param state New encryption state. 1875 * @param state New encryption state.
1876 */ 1876 */
1877void 1877void
1878GCT_change_estate (struct CadetTunnel3* t, enum CadetTunnel3EState state) 1878GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state)
1879{ 1879{
1880 if (NULL == t) 1880 if (NULL == t)
1881 return; 1881 return;
@@ -1909,7 +1909,7 @@ GCT_change_estate (struct CadetTunnel3* t, enum CadetTunnel3EState state)
1909static void 1909static void
1910trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1910trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1911{ 1911{
1912 struct CadetTunnel3 *t = cls; 1912 struct CadetTunnel *t = cls;
1913 1913
1914 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1914 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1915 return; 1915 return;
@@ -1950,7 +1950,7 @@ trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1950 * @param c Connection. 1950 * @param c Connection.
1951 */ 1951 */
1952void 1952void
1953GCT_add_connection (struct CadetTunnel3 *t, struct CadetConnection *c) 1953GCT_add_connection (struct CadetTunnel *t, struct CadetConnection *c)
1954{ 1954{
1955 struct CadetTConnection *aux; 1955 struct CadetTConnection *aux;
1956 1956
@@ -1979,7 +1979,7 @@ GCT_add_connection (struct CadetTunnel3 *t, struct CadetConnection *c)
1979 * @param path Invalid path to remove. Is destroyed after removal. 1979 * @param path Invalid path to remove. Is destroyed after removal.
1980 */ 1980 */
1981void 1981void
1982GCT_remove_path (struct CadetTunnel3 *t, struct CadetPeerPath *path) 1982GCT_remove_path (struct CadetTunnel *t, struct CadetPeerPath *path)
1983{ 1983{
1984 GCP_remove_path (t->peer, path); 1984 GCP_remove_path (t->peer, path);
1985} 1985}
@@ -1992,7 +1992,7 @@ GCT_remove_path (struct CadetTunnel3 *t, struct CadetPeerPath *path)
1992 * @param c Connection. 1992 * @param c Connection.
1993 */ 1993 */
1994void 1994void
1995GCT_remove_connection (struct CadetTunnel3 *t, 1995GCT_remove_connection (struct CadetTunnel *t,
1996 struct CadetConnection *c) 1996 struct CadetConnection *c)
1997{ 1997{
1998 struct CadetTConnection *aux; 1998 struct CadetTConnection *aux;
@@ -2042,7 +2042,7 @@ GCT_remove_connection (struct CadetTunnel3 *t,
2042 * @param ch Channel. 2042 * @param ch Channel.
2043 */ 2043 */
2044void 2044void
2045GCT_add_channel (struct CadetTunnel3 *t, struct CadetChannel *ch) 2045GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch)
2046{ 2046{
2047 struct CadetTChannel *aux; 2047 struct CadetTChannel *aux;
2048 2048
@@ -2078,7 +2078,7 @@ GCT_add_channel (struct CadetTunnel3 *t, struct CadetChannel *ch)
2078 * @param ch Channel. 2078 * @param ch Channel.
2079 */ 2079 */
2080void 2080void
2081GCT_remove_channel (struct CadetTunnel3 *t, struct CadetChannel *ch) 2081GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch)
2082{ 2082{
2083 struct CadetTChannel *aux; 2083 struct CadetTChannel *aux;
2084 2084
@@ -2105,7 +2105,7 @@ GCT_remove_channel (struct CadetTunnel3 *t, struct CadetChannel *ch)
2105 * @return channel handler, NULL if doesn't exist 2105 * @return channel handler, NULL if doesn't exist
2106 */ 2106 */
2107struct CadetChannel * 2107struct CadetChannel *
2108GCT_get_channel (struct CadetTunnel3 *t, CADET_ChannelNumber chid) 2108GCT_get_channel (struct CadetTunnel *t, CADET_ChannelNumber chid)
2109{ 2109{
2110 struct CadetTChannel *iter; 2110 struct CadetTChannel *iter;
2111 2111
@@ -2135,7 +2135,7 @@ GCT_get_channel (struct CadetTunnel3 *t, CADET_ChannelNumber chid)
2135static void 2135static void
2136delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 2136delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2137{ 2137{
2138 struct CadetTunnel3 *t = cls; 2138 struct CadetTunnel *t = cls;
2139 struct CadetTConnection *iter; 2139 struct CadetTConnection *iter;
2140 2140
2141 LOG (GNUNET_ERROR_TYPE_DEBUG, "delayed destroying tunnel %p\n", t); 2141 LOG (GNUNET_ERROR_TYPE_DEBUG, "delayed destroying tunnel %p\n", t);
@@ -2165,7 +2165,7 @@ delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2165 * @param t Tunnel to destroy. 2165 * @param t Tunnel to destroy.
2166 */ 2166 */
2167void 2167void
2168GCT_destroy_empty (struct CadetTunnel3 *t) 2168GCT_destroy_empty (struct CadetTunnel *t)
2169{ 2169{
2170 if (GNUNET_YES == shutting_down) 2170 if (GNUNET_YES == shutting_down)
2171 return; /* Will be destroyed immediately anyway */ 2171 return; /* Will be destroyed immediately anyway */
@@ -2199,7 +2199,7 @@ GCT_destroy_empty (struct CadetTunnel3 *t)
2199 * @param t Tunnel to destroy if empty. 2199 * @param t Tunnel to destroy if empty.
2200 */ 2200 */
2201void 2201void
2202GCT_destroy_if_empty (struct CadetTunnel3 *t) 2202GCT_destroy_if_empty (struct CadetTunnel *t)
2203{ 2203{
2204 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s destroy if empty\n", GCT_2s (t)); 2204 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s destroy if empty\n", GCT_2s (t));
2205 if (1 < GCT_count_channels (t)) 2205 if (1 < GCT_count_channels (t))
@@ -2221,7 +2221,7 @@ GCT_destroy_if_empty (struct CadetTunnel3 *t)
2221 * @param t The tunnel to destroy. 2221 * @param t The tunnel to destroy.
2222 */ 2222 */
2223void 2223void
2224GCT_destroy (struct CadetTunnel3 *t) 2224GCT_destroy (struct CadetTunnel *t)
2225{ 2225{
2226 struct CadetTConnection *iter_c; 2226 struct CadetTConnection *iter_c;
2227 struct CadetTConnection *next_c; 2227 struct CadetTConnection *next_c;
@@ -2284,7 +2284,7 @@ GCT_destroy (struct CadetTunnel3 *t)
2284 * @return Connection created. 2284 * @return Connection created.
2285 */ 2285 */
2286struct CadetConnection * 2286struct CadetConnection *
2287GCT_use_path (struct CadetTunnel3 *t, struct CadetPeerPath *p) 2287GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p)
2288{ 2288{
2289 struct CadetConnection *c; 2289 struct CadetConnection *c;
2290 struct GNUNET_CADET_Hash cid; 2290 struct GNUNET_CADET_Hash cid;
@@ -2333,7 +2333,7 @@ GCT_use_path (struct CadetTunnel3 *t, struct CadetPeerPath *p)
2333 * @return Number of connections. 2333 * @return Number of connections.
2334 */ 2334 */
2335unsigned int 2335unsigned int
2336GCT_count_connections (struct CadetTunnel3 *t) 2336GCT_count_connections (struct CadetTunnel *t)
2337{ 2337{
2338 struct CadetTConnection *iter; 2338 struct CadetTConnection *iter;
2339 unsigned int count; 2339 unsigned int count;
@@ -2356,7 +2356,7 @@ GCT_count_connections (struct CadetTunnel3 *t)
2356 * @return Number of channels. 2356 * @return Number of channels.
2357 */ 2357 */
2358unsigned int 2358unsigned int
2359GCT_count_channels (struct CadetTunnel3 *t) 2359GCT_count_channels (struct CadetTunnel *t)
2360{ 2360{
2361 struct CadetTChannel *iter; 2361 struct CadetTChannel *iter;
2362 unsigned int count; 2362 unsigned int count;
@@ -2376,13 +2376,13 @@ GCT_count_channels (struct CadetTunnel3 *t)
2376 * 2376 *
2377 * @return Tunnel's connectivity state. 2377 * @return Tunnel's connectivity state.
2378 */ 2378 */
2379enum CadetTunnel3CState 2379enum CadetTunnelCState
2380GCT_get_cstate (struct CadetTunnel3 *t) 2380GCT_get_cstate (struct CadetTunnel *t)
2381{ 2381{
2382 if (NULL == t) 2382 if (NULL == t)
2383 { 2383 {
2384 GNUNET_assert (0); 2384 GNUNET_assert (0);
2385 return (enum CadetTunnel3CState) -1; 2385 return (enum CadetTunnelCState) -1;
2386 } 2386 }
2387 return t->cstate; 2387 return t->cstate;
2388} 2388}
@@ -2395,13 +2395,13 @@ GCT_get_cstate (struct CadetTunnel3 *t)
2395 * 2395 *
2396 * @return Tunnel's encryption state. 2396 * @return Tunnel's encryption state.
2397 */ 2397 */
2398enum CadetTunnel3EState 2398enum CadetTunnelEState
2399GCT_get_estate (struct CadetTunnel3 *t) 2399GCT_get_estate (struct CadetTunnel *t)
2400{ 2400{
2401 if (NULL == t) 2401 if (NULL == t)
2402 { 2402 {
2403 GNUNET_assert (0); 2403 GNUNET_assert (0);
2404 return (enum CadetTunnel3EState) -1; 2404 return (enum CadetTunnelEState) -1;
2405 } 2405 }
2406 return t->estate; 2406 return t->estate;
2407} 2407}
@@ -2414,7 +2414,7 @@ GCT_get_estate (struct CadetTunnel3 *t)
2414 * @return Biggest buffer space offered by any channel in the tunnel. 2414 * @return Biggest buffer space offered by any channel in the tunnel.
2415 */ 2415 */
2416unsigned int 2416unsigned int
2417GCT_get_channels_buffer (struct CadetTunnel3 *t) 2417GCT_get_channels_buffer (struct CadetTunnel *t)
2418{ 2418{
2419 struct CadetTChannel *iter; 2419 struct CadetTChannel *iter;
2420 unsigned int buffer; 2420 unsigned int buffer;
@@ -2445,7 +2445,7 @@ GCT_get_channels_buffer (struct CadetTunnel3 *t)
2445 * @return Buffer space offered by all connections in the tunnel. 2445 * @return Buffer space offered by all connections in the tunnel.
2446 */ 2446 */
2447unsigned int 2447unsigned int
2448GCT_get_connections_buffer (struct CadetTunnel3 *t) 2448GCT_get_connections_buffer (struct CadetTunnel *t)
2449{ 2449{
2450 struct CadetTConnection *iter; 2450 struct CadetTConnection *iter;
2451 unsigned int buffer; 2451 unsigned int buffer;
@@ -2472,7 +2472,7 @@ GCT_get_connections_buffer (struct CadetTunnel3 *t)
2472 * @return ID of the destination peer. 2472 * @return ID of the destination peer.
2473 */ 2473 */
2474const struct GNUNET_PeerIdentity * 2474const struct GNUNET_PeerIdentity *
2475GCT_get_destination (struct CadetTunnel3 *t) 2475GCT_get_destination (struct CadetTunnel *t)
2476{ 2476{
2477 return GCP_get_id (t->peer); 2477 return GCP_get_id (t->peer);
2478} 2478}
@@ -2486,7 +2486,7 @@ GCT_get_destination (struct CadetTunnel3 *t)
2486 * @return GID of a channel free to use. 2486 * @return GID of a channel free to use.
2487 */ 2487 */
2488CADET_ChannelNumber 2488CADET_ChannelNumber
2489GCT_get_next_chid (struct CadetTunnel3 *t) 2489GCT_get_next_chid (struct CadetTunnel *t)
2490{ 2490{
2491 CADET_ChannelNumber chid; 2491 CADET_ChannelNumber chid;
2492 CADET_ChannelNumber mask; 2492 CADET_ChannelNumber mask;
@@ -2523,7 +2523,7 @@ GCT_get_next_chid (struct CadetTunnel3 *t)
2523 * @param t Channel which has some free buffer space. 2523 * @param t Channel which has some free buffer space.
2524 */ 2524 */
2525void 2525void
2526GCT_unchoke_channels (struct CadetTunnel3 *t) 2526GCT_unchoke_channels (struct CadetTunnel *t)
2527{ 2527{
2528 struct CadetTChannel *iter; 2528 struct CadetTChannel *iter;
2529 unsigned int buffer; 2529 unsigned int buffer;
@@ -2574,7 +2574,7 @@ GCT_unchoke_channels (struct CadetTunnel3 *t)
2574 * @param t Tunnel. 2574 * @param t Tunnel.
2575 */ 2575 */
2576void 2576void
2577GCT_send_connection_acks (struct CadetTunnel3 *t) 2577GCT_send_connection_acks (struct CadetTunnel *t)
2578{ 2578{
2579 struct CadetTConnection *iter; 2579 struct CadetTConnection *iter;
2580 uint32_t allowed; 2580 uint32_t allowed;
@@ -2641,7 +2641,7 @@ GCT_send_connection_acks (struct CadetTunnel3 *t)
2641 * @param q Handle to the queue. 2641 * @param q Handle to the queue.
2642 */ 2642 */
2643void 2643void
2644GCT_cancel (struct CadetTunnel3Queue *q) 2644GCT_cancel (struct CadetTunnelQueue *q)
2645{ 2645{
2646 if (NULL != q->cq) 2646 if (NULL != q->cq)
2647 { 2647 {
@@ -2676,9 +2676,9 @@ GCT_cancel (struct CadetTunnel3Queue *q)
2676 * 2676 *
2677 * @return Handle to cancel message. NULL if @c cont is NULL. 2677 * @return Handle to cancel message. NULL if @c cont is NULL.
2678 */ 2678 */
2679struct CadetTunnel3Queue * 2679struct CadetTunnelQueue *
2680GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, 2680GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2681 struct CadetTunnel3 *t, struct CadetConnection *c, 2681 struct CadetTunnel *t, struct CadetConnection *c,
2682 int force, GCT_sent cont, void *cont_cls) 2682 int force, GCT_sent cont, void *cont_cls)
2683{ 2683{
2684 return send_prebuilt_message (message, t, c, force, cont, cont_cls, NULL); 2684 return send_prebuilt_message (message, t, c, force, cont, cont_cls, NULL);
@@ -2693,7 +2693,7 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2693 * @return #GNUNET_YES if it is loopback. 2693 * @return #GNUNET_YES if it is loopback.
2694 */ 2694 */
2695int 2695int
2696GCT_is_loopback (const struct CadetTunnel3 *t) 2696GCT_is_loopback (const struct CadetTunnel *t)
2697{ 2697{
2698 return (myid == GCP_get_short_id (t->peer)); 2698 return (myid == GCP_get_short_id (t->peer));
2699} 2699}
@@ -2708,7 +2708,7 @@ GCT_is_loopback (const struct CadetTunnel3 *t)
2708 * @return #GNUNET_YES a connection uses this path. 2708 * @return #GNUNET_YES a connection uses this path.
2709 */ 2709 */
2710int 2710int
2711GCT_is_path_used (const struct CadetTunnel3 *t, const struct CadetPeerPath *p) 2711GCT_is_path_used (const struct CadetTunnel *t, const struct CadetPeerPath *p)
2712{ 2712{
2713 struct CadetTConnection *iter; 2713 struct CadetTConnection *iter;
2714 2714
@@ -2729,7 +2729,7 @@ GCT_is_path_used (const struct CadetTunnel3 *t, const struct CadetPeerPath *p)
2729 * @return Cost of the path (path length + number of overlapping nodes) 2729 * @return Cost of the path (path length + number of overlapping nodes)
2730 */ 2730 */
2731unsigned int 2731unsigned int
2732GCT_get_path_cost (const struct CadetTunnel3 *t, 2732GCT_get_path_cost (const struct CadetTunnel *t,
2733 const struct CadetPeerPath *path) 2733 const struct CadetPeerPath *path)
2734{ 2734{
2735 struct CadetTConnection *iter; 2735 struct CadetTConnection *iter;
@@ -2774,7 +2774,7 @@ GCT_get_path_cost (const struct CadetTunnel3 *t,
2774 * @return Static string the destination peer's ID. 2774 * @return Static string the destination peer's ID.
2775 */ 2775 */
2776const char * 2776const char *
2777GCT_2s (const struct CadetTunnel3 *t) 2777GCT_2s (const struct CadetTunnel *t)
2778{ 2778{
2779 if (NULL == t) 2779 if (NULL == t)
2780 return "(NULL)"; 2780 return "(NULL)";
@@ -2794,7 +2794,7 @@ GCT_2s (const struct CadetTunnel3 *t)
2794 * @param t Tunnel to debug. 2794 * @param t Tunnel to debug.
2795 */ 2795 */
2796void 2796void
2797GCT_debug (const struct CadetTunnel3 *t) 2797GCT_debug (const struct CadetTunnel *t)
2798{ 2798{
2799 struct CadetTChannel *iterch; 2799 struct CadetTChannel *iterch;
2800 struct CadetTConnection *iterc; 2800 struct CadetTConnection *iterc;
@@ -2862,7 +2862,7 @@ GCT_count_all (void)
2862 * @param cls Closure for @c iter. 2862 * @param cls Closure for @c iter.
2863 */ 2863 */
2864void 2864void
2865GCT_iterate_connections (struct CadetTunnel3 *t, GCT_conn_iter iter, void *cls) 2865GCT_iterate_connections (struct CadetTunnel *t, GCT_conn_iter iter, void *cls)
2866{ 2866{
2867 struct CadetTConnection *ct; 2867 struct CadetTConnection *ct;
2868 2868
@@ -2879,7 +2879,7 @@ GCT_iterate_connections (struct CadetTunnel3 *t, GCT_conn_iter iter, void *cls)
2879 * @param cls Closure for @c iter. 2879 * @param cls Closure for @c iter.
2880 */ 2880 */
2881void 2881void
2882GCT_iterate_channels (struct CadetTunnel3 *t, GCT_chan_iter iter, void *cls) 2882GCT_iterate_channels (struct CadetTunnel *t, GCT_chan_iter iter, void *cls)
2883{ 2883{
2884 struct CadetTChannel *cht; 2884 struct CadetTChannel *cht;
2885 2885