aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cadet/cadet.h14
-rw-r--r--src/cadet/cadet_api.c14
-rw-r--r--src/cadet/cadet_common.c22
-rw-r--r--src/cadet/cadet_path.c4
-rw-r--r--src/cadet/gnunet-cadet.c2
-rw-r--r--src/cadet/gnunet-service-cadet.c20
-rw-r--r--src/cadet/gnunet-service-cadet_channel.c210
-rw-r--r--src/cadet/gnunet-service-cadet_channel.h46
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c422
-rw-r--r--src/cadet/gnunet-service-cadet_connection.h80
-rw-r--r--src/cadet/gnunet-service-cadet_dht.c38
-rw-r--r--src/cadet/gnunet-service-cadet_dht.h16
-rw-r--r--src/cadet/gnunet-service-cadet_hello.c20
-rw-r--r--src/cadet/gnunet-service-cadet_hello.h6
-rw-r--r--src/cadet/gnunet-service-cadet_local.c46
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c262
-rw-r--r--src/cadet/gnunet-service-cadet_peer.h66
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c360
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.h84
19 files changed, 866 insertions, 866 deletions
diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h
index 757f8c501..3667647eb 100644
--- a/src/cadet/cadet.h
+++ b/src/cadet/cadet.h
@@ -271,7 +271,7 @@ GNUNET_NETWORK_STRUCT_END
271 * @return String representing FWD or BCK. 271 * @return String representing FWD or BCK.
272 */ 272 */
273char * 273char *
274GM_f2s (int fwd); 274GC_f2s (int fwd);
275 275
276 276
277/** 277/**
@@ -283,7 +283,7 @@ GM_f2s (int fwd);
283 * @return True if bigger (arg1) has a higher value than smaller (arg 2). 283 * @return True if bigger (arg1) has a higher value than smaller (arg 2).
284 */ 284 */
285int 285int
286GM_is_pid_bigger (uint32_t bigger, uint32_t smaller); 286GC_is_pid_bigger (uint32_t bigger, uint32_t smaller);
287 287
288 288
289/** 289/**
@@ -295,7 +295,7 @@ GM_is_pid_bigger (uint32_t bigger, uint32_t smaller);
295 * @return Highest ACK value from the two. 295 * @return Highest ACK value from the two.
296 */ 296 */
297uint32_t 297uint32_t
298GM_max_pid (uint32_t a, uint32_t b); 298GC_max_pid (uint32_t a, uint32_t b);
299 299
300 300
301/** 301/**
@@ -307,7 +307,7 @@ GM_max_pid (uint32_t a, uint32_t b);
307 * @return Lowest ACK value from the two. 307 * @return Lowest ACK value from the two.
308 */ 308 */
309uint32_t 309uint32_t
310GM_min_pid (uint32_t a, uint32_t b); 310GC_min_pid (uint32_t a, uint32_t b);
311 311
312 312
313/** 313/**
@@ -319,14 +319,14 @@ GM_min_pid (uint32_t a, uint32_t b);
319 * @return A HashCode containing the original 256 bit hash right-padded with 0. 319 * @return A HashCode containing the original 256 bit hash right-padded with 0.
320 */ 320 */
321const struct GNUNET_HashCode * 321const struct GNUNET_HashCode *
322GM_h2hc (const struct GNUNET_CADET_Hash *id); 322GC_h2hc (const struct GNUNET_CADET_Hash *id);
323 323
324/** 324/**
325 * Get a string from a Cadet Hash (256 bits). 325 * Get a string from a Cadet Hash (256 bits).
326 * WARNING: Not reentrant (based on GNUNET_h2s). 326 * WARNING: Not reentrant (based on GNUNET_h2s).
327 */ 327 */
328const char * 328const char *
329GM_h2s (const struct GNUNET_CADET_Hash *id); 329GC_h2s (const struct GNUNET_CADET_Hash *id);
330 330
331/** 331/**
332 * Convert a message type into a string to help debug 332 * Convert a message type into a string to help debug
@@ -339,7 +339,7 @@ GM_h2s (const struct GNUNET_CADET_Hash *id);
339 * @return Human readable string description. 339 * @return Human readable string description.
340 */ 340 */
341const char * 341const char *
342GM_m2s (uint16_t m); 342GC_m2s (uint16_t m);
343 343
344#if 0 /* keep Emacsens' auto-indent happy */ 344#if 0 /* keep Emacsens' auto-indent happy */
345{ 345{
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index aa5c67329..bcbc33ce3 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -865,7 +865,7 @@ process_incoming_data (struct GNUNET_CADET_Handle *h,
865 865
866 payload = (struct GNUNET_MessageHeader *) &dmsg[1]; 866 payload = (struct GNUNET_MessageHeader *) &dmsg[1];
867 LOG (GNUNET_ERROR_TYPE_DEBUG, " %s data on channel %s [%X]\n", 867 LOG (GNUNET_ERROR_TYPE_DEBUG, " %s data on channel %s [%X]\n",
868 GM_f2s (ch->chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_SERV), 868 GC_f2s (ch->chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_SERV),
869 GNUNET_i2s (GNUNET_PEER_resolve2 (ch->peer)), ntohl (dmsg->id)); 869 GNUNET_i2s (GNUNET_PEER_resolve2 (ch->peer)), ntohl (dmsg->id));
870 870
871 size = ntohs (message->size); 871 size = ntohs (message->size);
@@ -879,7 +879,7 @@ process_incoming_data (struct GNUNET_CADET_Handle *h,
879 } 879 }
880 type = ntohs (payload->type); 880 type = ntohs (payload->type);
881 size = ntohs (payload->size); 881 size = ntohs (payload->size);
882 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload type %s\n", GM_m2s (type)); 882 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload type %s\n", GC_m2s (type));
883 for (i = 0; i < h->n_handlers; i++) 883 for (i = 0; i < h->n_handlers; i++)
884 { 884 {
885 handler = &h->message_handlers[i]; 885 handler = &h->message_handlers[i];
@@ -1253,7 +1253,7 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg)
1253 type = ntohs (msg->type); 1253 type = ntohs (msg->type);
1254 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n"); 1254 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
1255 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received a message: %s\n", 1255 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received a message: %s\n",
1256 GM_m2s (type)); 1256 GC_m2s (type));
1257 switch (type) 1257 switch (type)
1258 { 1258 {
1259 /* Notify of a new incoming channel */ 1259 /* Notify of a new incoming channel */
@@ -1296,7 +1296,7 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg)
1296 /* We shouldn't get any other packages, log and ignore */ 1296 /* We shouldn't get any other packages, log and ignore */
1297 LOG (GNUNET_ERROR_TYPE_WARNING, 1297 LOG (GNUNET_ERROR_TYPE_WARNING,
1298 "unsolicited message form service (type %s)\n", 1298 "unsolicited message form service (type %s)\n",
1299 GM_m2s (ntohs (msg->type))); 1299 GC_m2s (ntohs (msg->type)));
1300 } 1300 }
1301 LOG (GNUNET_ERROR_TYPE_DEBUG, "message processed\n"); 1301 LOG (GNUNET_ERROR_TYPE_DEBUG, "message processed\n");
1302 if (GNUNET_YES == h->in_receive) 1302 if (GNUNET_YES == h->in_receive)
@@ -1380,7 +1380,7 @@ send_callback (void *cls, size_t size, void *buf)
1380 dmsg->id = htonl (ch->chid); 1380 dmsg->id = htonl (ch->chid);
1381 dmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); 1381 dmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA);
1382 LOG (GNUNET_ERROR_TYPE_DEBUG, "# payload type %s\n", 1382 LOG (GNUNET_ERROR_TYPE_DEBUG, "# payload type %s\n",
1383 GM_m2s (ntohs (mh->type))); 1383 GC_m2s (ntohs (mh->type)));
1384 ch->allow_send = GNUNET_NO; 1384 ch->allow_send = GNUNET_NO;
1385 } 1385 }
1386 else 1386 else
@@ -1395,7 +1395,7 @@ send_callback (void *cls, size_t size, void *buf)
1395 struct GNUNET_MessageHeader *mh = (struct GNUNET_MessageHeader *) &th[1]; 1395 struct GNUNET_MessageHeader *mh = (struct GNUNET_MessageHeader *) &th[1];
1396 1396
1397 LOG (GNUNET_ERROR_TYPE_DEBUG, "# cadet internal traffic, type %s\n", 1397 LOG (GNUNET_ERROR_TYPE_DEBUG, "# cadet internal traffic, type %s\n",
1398 GM_m2s (ntohs (mh->type))); 1398 GC_m2s (ntohs (mh->type)));
1399 memcpy (cbuf, &th[1], th->size); 1399 memcpy (cbuf, &th[1], th->size);
1400 psize = th->size; 1400 psize = th->size;
1401 } 1401 }
@@ -1457,7 +1457,7 @@ send_packet (struct GNUNET_CADET_Handle *h,
1457 size_t msize; 1457 size_t msize;
1458 1458
1459 LOG (GNUNET_ERROR_TYPE_DEBUG, " Sending message to service: %s\n", 1459 LOG (GNUNET_ERROR_TYPE_DEBUG, " Sending message to service: %s\n",
1460 GM_m2s(ntohs(msg->type))); 1460 GC_m2s(ntohs(msg->type)));
1461 msize = ntohs (msg->size); 1461 msize = ntohs (msg->size);
1462 th = GNUNET_malloc (sizeof (struct GNUNET_CADET_TransmitHandle) + msize); 1462 th = GNUNET_malloc (sizeof (struct GNUNET_CADET_TransmitHandle) + msize);
1463 th->timeout = GNUNET_TIME_UNIT_FOREVER_ABS; 1463 th->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
diff --git a/src/cadet/cadet_common.c b/src/cadet/cadet_common.c
index 855e9e20c..42ccf189c 100644
--- a/src/cadet/cadet_common.c
+++ b/src/cadet/cadet_common.c
@@ -34,7 +34,7 @@
34 * @return String representing FWD or BCK. 34 * @return String representing FWD or BCK.
35 */ 35 */
36char * 36char *
37GM_f2s (int fwd) 37GC_f2s (int fwd)
38{ 38{
39 if (GNUNET_YES == fwd) 39 if (GNUNET_YES == fwd)
40 { 40 {
@@ -52,7 +52,7 @@ GM_f2s (int fwd)
52} 52}
53 53
54int 54int
55GM_is_pid_bigger (uint32_t bigger, uint32_t smaller) 55GC_is_pid_bigger (uint32_t bigger, uint32_t smaller)
56{ 56{
57 return (GNUNET_YES == PID_OVERFLOW (smaller, bigger) || 57 return (GNUNET_YES == PID_OVERFLOW (smaller, bigger) ||
58 (bigger > smaller && GNUNET_NO == PID_OVERFLOW (bigger, smaller))); 58 (bigger > smaller && GNUNET_NO == PID_OVERFLOW (bigger, smaller)));
@@ -60,25 +60,25 @@ GM_is_pid_bigger (uint32_t bigger, uint32_t smaller)
60 60
61 61
62uint32_t 62uint32_t
63GM_max_pid (uint32_t a, uint32_t b) 63GC_max_pid (uint32_t a, uint32_t b)
64{ 64{
65 if (GM_is_pid_bigger(a, b)) 65 if (GC_is_pid_bigger(a, b))
66 return a; 66 return a;
67 return b; 67 return b;
68} 68}
69 69
70 70
71uint32_t 71uint32_t
72GM_min_pid (uint32_t a, uint32_t b) 72GC_min_pid (uint32_t a, uint32_t b)
73{ 73{
74 if (GM_is_pid_bigger(a, b)) 74 if (GC_is_pid_bigger(a, b))
75 return b; 75 return b;
76 return a; 76 return a;
77} 77}
78 78
79 79
80const struct GNUNET_HashCode * 80const struct GNUNET_HashCode *
81GM_h2hc (const struct GNUNET_CADET_Hash *id) 81GC_h2hc (const struct GNUNET_CADET_Hash *id)
82{ 82{
83 static struct GNUNET_HashCode hc; 83 static struct GNUNET_HashCode hc;
84 memcpy (&hc, id, sizeof (*id)); 84 memcpy (&hc, id, sizeof (*id));
@@ -88,11 +88,11 @@ GM_h2hc (const struct GNUNET_CADET_Hash *id)
88 88
89 89
90const char * 90const char *
91GM_h2s (const struct GNUNET_CADET_Hash *id) 91GC_h2s (const struct GNUNET_CADET_Hash *id)
92{ 92{
93 static char s[53]; 93 static char s[53];
94 94
95 memcpy (s, GNUNET_h2s_full (GM_h2hc (id)), 52); 95 memcpy (s, GNUNET_h2s_full (GC_h2hc (id)), 52);
96 s[52] = '\0'; 96 s[52] = '\0';
97 97
98 return s; 98 return s;
@@ -101,7 +101,7 @@ GM_h2s (const struct GNUNET_CADET_Hash *id)
101 101
102#if !defined(GNUNET_CULL_LOGGING) 102#if !defined(GNUNET_CULL_LOGGING)
103const char * 103const char *
104GM_m2s (uint16_t m) 104GC_m2s (uint16_t m)
105{ 105{
106 static char buf[32]; 106 static char buf[32];
107 const char *t; 107 const char *t;
@@ -341,7 +341,7 @@ GM_m2s (uint16_t m)
341} 341}
342#else 342#else
343const char * 343const char *
344GM_m2s (uint16_t m) 344GC_m2s (uint16_t m)
345{ 345{
346 return ""; 346 return "";
347} 347}
diff --git a/src/cadet/cadet_path.c b/src/cadet/cadet_path.c
index 0a97e73ef..21c8ed158 100644
--- a/src/cadet/cadet_path.c
+++ b/src/cadet/cadet_path.c
@@ -43,8 +43,8 @@ path_destroy_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
43 struct CadetPeer *peer; 43 struct CadetPeer *peer;
44 44
45 path->path_delete = GNUNET_SCHEDULER_NO_TASK; 45 path->path_delete = GNUNET_SCHEDULER_NO_TASK;
46 peer = GMP_get_short (path->peers[path->length - 1]); 46 peer = GCP_get_short (path->peers[path->length - 1]);
47 GMP_remove_path (peer, path); 47 GCP_remove_path (peer, path);
48} 48}
49 49
50 50
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index 840c6d0ac..2a43f570d 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -556,7 +556,7 @@ tunnel_callback (void *cls,
556 FPRINTF (stdout, " %u\n", channels[i]); 556 FPRINTF (stdout, " %u\n", channels[i]);
557 FPRINTF (stdout, "- %u connections\n", n_connections); 557 FPRINTF (stdout, "- %u connections\n", n_connections);
558 for (i = 0; i < n_connections; i++) 558 for (i = 0; i < n_connections; i++)
559 FPRINTF (stdout, " %s\n", GM_h2s (&connections[i])); 559 FPRINTF (stdout, " %s\n", GC_h2s (&connections[i]));
560 FPRINTF (stdout, "- enc state: %u\n", estate); 560 FPRINTF (stdout, "- enc state: %u\n", estate);
561 FPRINTF (stdout, "- con state: %u\n", cstate); 561 FPRINTF (stdout, "- con state: %u\n", cstate);
562 } 562 }
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c
index de9aaf7a5..7ac4c6370 100644
--- a/src/cadet/gnunet-service-cadet.c
+++ b/src/cadet/gnunet-service-cadet.c
@@ -108,11 +108,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
108 shutting_down = GNUNET_YES; 108 shutting_down = GNUNET_YES;
109 109
110 GML_shutdown (); 110 GML_shutdown ();
111 GMH_shutdown (); 111 GCH_shutdown ();
112 GMC_shutdown (); 112 GCC_shutdown ();
113 GMT_shutdown (); 113 GCT_shutdown ();
114 GMD_shutdown (); 114 GCD_shutdown ();
115 GMP_shutdown (); 115 GCP_shutdown ();
116 116
117 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 117 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
118 stats = NULL; 118 stats = NULL;
@@ -148,11 +148,11 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
148 GNUNET_i2s (&my_full_id)); 148 GNUNET_i2s (&my_full_id));
149 149
150 GML_init (server); /* Local clients */ 150 GML_init (server); /* Local clients */
151 GMH_init (c); /* Hellos */ 151 GCH_init (c); /* Hellos */
152 GMC_init (c); /* Connections */ 152 GCC_init (c); /* Connections */
153 GMP_init (c); /* Peers */ 153 GCP_init (c); /* Peers */
154 GMD_init (c); /* DHT */ 154 GCD_init (c); /* DHT */
155 GMT_init (c, my_private_key); /* Tunnels */ 155 GCT_init (c, my_private_key); /* Tunnels */
156 156
157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cadet service running\n"); 157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cadet service running\n");
158} 158}
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c
index 91338d5c0..c85900456 100644
--- a/src/cadet/gnunet-service-cadet_channel.c
+++ b/src/cadet/gnunet-service-cadet_channel.c
@@ -350,7 +350,7 @@ static int
350is_loopback (const struct CadetChannel *ch) 350is_loopback (const struct CadetChannel *ch)
351{ 351{
352 if (NULL != ch->t) 352 if (NULL != ch->t)
353 return GMT_is_loopback (ch->t); 353 return GCT_is_loopback (ch->t);
354 354
355 return (NULL != ch->root && NULL != ch->dest); 355 return (NULL != ch->root && NULL != ch->dest);
356} 356}
@@ -412,7 +412,7 @@ add_buffered_data (const struct GNUNET_CADET_Data *msg,
412 LOG (GNUNET_ERROR_TYPE_DEBUG, " already there!\n"); 412 LOG (GNUNET_ERROR_TYPE_DEBUG, " already there!\n");
413 return; 413 return;
414 } 414 }
415 else if (GM_is_pid_bigger (prev->mid, mid)) 415 else if (GC_is_pid_bigger (prev->mid, mid))
416 { 416 {
417 LOG (GNUNET_ERROR_TYPE_DEBUG, " bingo!\n"); 417 LOG (GNUNET_ERROR_TYPE_DEBUG, " bingo!\n");
418 copy = copy_message (msg, mid, rel); 418 copy = copy_message (msg, mid, rel);
@@ -521,12 +521,12 @@ send_destroy (struct CadetChannel *ch, int local_only)
521 if (NULL != ch->root) 521 if (NULL != ch->root)
522 GML_send_channel_destroy (ch->root, ch->lid_root); 522 GML_send_channel_destroy (ch->root, ch->lid_root);
523 else if (0 == ch->lid_root && GNUNET_NO == local_only) 523 else if (0 == ch->lid_root && GNUNET_NO == local_only)
524 GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO, NULL); 524 GCCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO, NULL);
525 525
526 if (NULL != ch->dest) 526 if (NULL != ch->dest)
527 GML_send_channel_destroy (ch->dest, ch->lid_dest); 527 GML_send_channel_destroy (ch->dest, ch->lid_dest);
528 else if (0 == ch->lid_dest && GNUNET_NO == local_only) 528 else if (0 == ch->lid_dest && GNUNET_NO == local_only)
529 GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_YES, NULL); 529 GCCH_send_prebuilt_message (&msg.header, ch, GNUNET_YES, NULL);
530} 530}
531 531
532 532
@@ -547,7 +547,7 @@ send_client_create (struct CadetChannel *ch)
547 opt |= GNUNET_YES == ch->reliable ? GNUNET_CADET_OPTION_RELIABLE : 0; 547 opt |= GNUNET_YES == ch->reliable ? GNUNET_CADET_OPTION_RELIABLE : 0;
548 opt |= GNUNET_YES == ch->nobuffer ? GNUNET_CADET_OPTION_NOBUFFER : 0; 548 opt |= GNUNET_YES == ch->nobuffer ? GNUNET_CADET_OPTION_NOBUFFER : 0;
549 GML_send_channel_create (ch->dest, ch->lid_dest, ch->port, opt, 549 GML_send_channel_create (ch->dest, ch->lid_dest, ch->port, opt,
550 GMT_get_destination (ch->t)); 550 GCT_get_destination (ch->t));
551 551
552} 552}
553 553
@@ -640,7 +640,7 @@ send_client_buffered_data (struct CadetChannel *ch,
640 * deliver missing messages 640 * deliver missing messages
641 */ 641 */
642 send_destroy (ch, GNUNET_YES); 642 send_destroy (ch, GNUNET_YES);
643 GMCH_destroy (ch); 643 GCCH_destroy (ch);
644 } 644 }
645 } 645 }
646 } 646 }
@@ -669,7 +669,7 @@ send_client_ack (struct CadetChannel *ch, int fwd)
669 } 669 }
670 LOG (GNUNET_ERROR_TYPE_DEBUG, 670 LOG (GNUNET_ERROR_TYPE_DEBUG,
671 " sending %s ack to client on channel %s\n", 671 " sending %s ack to client on channel %s\n",
672 GM_f2s (fwd), GMCH_2s (ch)); 672 GC_f2s (fwd), GCCH_2s (ch));
673 673
674 if (NULL == rel) 674 if (NULL == rel)
675 { 675 {
@@ -739,7 +739,7 @@ channel_retransmit_message (void *cls,
739 /* Message not found in the queue that we are going to use. */ 739 /* Message not found in the queue that we are going to use. */
740 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid); 740 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid);
741 741
742 GMCH_send_prebuilt_message (&payload->header, ch, fwd, copy); 742 GCCH_send_prebuilt_message (&payload->header, ch, fwd, copy);
743 GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO); 743 GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO);
744} 744}
745 745
@@ -798,7 +798,7 @@ ch_message_sent (void *cls,
798 struct CadetChannelReliability *rel; 798 struct CadetChannelReliability *rel;
799 799
800 LOG (GNUNET_ERROR_TYPE_DEBUG, "channel message sent callback %s\n", 800 LOG (GNUNET_ERROR_TYPE_DEBUG, "channel message sent callback %s\n",
801 GM_m2s (chq->type)); 801 GC_m2s (chq->type));
802 802
803 switch (chq->type) 803 switch (chq->type)
804 { 804 {
@@ -842,7 +842,7 @@ ch_message_sent (void *cls,
842 case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK: 842 case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK:
843 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE: 843 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE:
844 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK: 844 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK:
845 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SENT %s\n", GM_m2s (chq->type)); 845 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SENT %s\n", GC_m2s (chq->type));
846 rel = chq->rel; 846 rel = chq->rel;
847 GNUNET_assert (rel->uniq == chq); 847 GNUNET_assert (rel->uniq == chq);
848 rel->uniq = NULL; 848 rel->uniq = NULL;
@@ -885,7 +885,7 @@ send_create (struct CadetChannel *ch)
885 msgcc.port = htonl (ch->port); 885 msgcc.port = htonl (ch->port);
886 msgcc.opt = htonl (channel_get_options (ch)); 886 msgcc.opt = htonl (channel_get_options (ch));
887 887
888 GMCH_send_prebuilt_message (&msgcc.header, ch, GNUNET_YES, NULL); 888 GCCH_send_prebuilt_message (&msgcc.header, ch, GNUNET_YES, NULL);
889} 889}
890 890
891 891
@@ -904,10 +904,10 @@ send_ack (struct CadetChannel *ch, int fwd, int reaction)
904 msg.header.size = htons (sizeof (msg)); 904 msg.header.size = htons (sizeof (msg));
905 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK); 905 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK);
906 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending channel %s ack for channel %s\n", 906 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending channel %s ack for channel %s\n",
907 GM_f2s (fwd), GMCH_2s (ch)); 907 GC_f2s (fwd), GCCH_2s (ch));
908 908
909 msg.chid = htonl (ch->gid); 909 msg.chid = htonl (ch->gid);
910 GMCH_send_prebuilt_message (&msg.header, ch, !fwd, reaction ? &msg : NULL); 910 GCCH_send_prebuilt_message (&msg.header, ch, !fwd, reaction ? &msg : NULL);
911} 911}
912 912
913 913
@@ -924,7 +924,7 @@ fire_and_forget (const struct GNUNET_MessageHeader *msg,
924 struct CadetChannel *ch, 924 struct CadetChannel *ch,
925 int force) 925 int force)
926{ 926{
927 GNUNET_break (NULL == GMT_send_prebuilt_message (msg, ch->t, NULL, 927 GNUNET_break (NULL == GCT_send_prebuilt_message (msg, ch->t, NULL,
928 force, NULL, NULL)); 928 force, NULL, NULL));
929} 929}
930 930
@@ -943,10 +943,10 @@ send_nack (struct CadetChannel *ch)
943 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK); 943 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK);
944 LOG (GNUNET_ERROR_TYPE_DEBUG, 944 LOG (GNUNET_ERROR_TYPE_DEBUG,
945 " sending channel NACK for channel %s\n", 945 " sending channel NACK for channel %s\n",
946 GMCH_2s (ch)); 946 GCCH_2s (ch));
947 947
948 msg.chid = htonl (ch->gid); 948 msg.chid = htonl (ch->gid);
949 GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO, NULL); 949 GCCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO, NULL);
950} 950}
951 951
952 952
@@ -983,7 +983,7 @@ channel_rel_free_all (struct CadetChannelReliability *rel)
983 { 983 {
984 if (NULL != copy->chq->tq) 984 if (NULL != copy->chq->tq)
985 { 985 {
986 GMT_cancel (copy->chq->tq); 986 GCT_cancel (copy->chq->tq);
987 /* ch_message_sent will free copy->q */ 987 /* ch_message_sent will free copy->q */
988 } 988 }
989 else 989 else
@@ -996,7 +996,7 @@ channel_rel_free_all (struct CadetChannelReliability *rel)
996 } 996 }
997 if (NULL != rel->uniq && NULL != rel->uniq->tq) 997 if (NULL != rel->uniq && NULL != rel->uniq->tq)
998 { 998 {
999 GMT_cancel (rel->uniq->tq); 999 GCT_cancel (rel->uniq->tq);
1000 /* ch_message_sent is called freeing uniq */ 1000 /* ch_message_sent is called freeing uniq */
1001 } 1001 }
1002 if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task) 1002 if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task)
@@ -1053,7 +1053,7 @@ channel_rel_free_sent (struct CadetChannelReliability *rel,
1053 /* Skip copies with mid < target */ 1053 /* Skip copies with mid < target */
1054 target = mid + i + 1; 1054 target = mid + i + 1;
1055 LOG (GNUNET_ERROR_TYPE_DEBUG, " target %u\n", target); 1055 LOG (GNUNET_ERROR_TYPE_DEBUG, " target %u\n", target);
1056 while (NULL != copy && GM_is_pid_bigger (target, copy->mid)) 1056 while (NULL != copy && GC_is_pid_bigger (target, copy->mid))
1057 copy = copy->next; 1057 copy = copy->next;
1058 1058
1059 /* Did we run out of copies? (previously freed, it's ok) */ 1059 /* Did we run out of copies? (previously freed, it's ok) */
@@ -1064,7 +1064,7 @@ channel_rel_free_sent (struct CadetChannelReliability *rel,
1064 } 1064 }
1065 1065
1066 /* Did we overshoot the target? (previously freed, it's ok) */ 1066 /* Did we overshoot the target? (previously freed, it's ok) */
1067 if (GM_is_pid_bigger (copy->mid, target)) 1067 if (GC_is_pid_bigger (copy->mid, target))
1068 { 1068 {
1069 LOG (GNUNET_ERROR_TYPE_DEBUG, " next copy %u\n", copy->mid); 1069 LOG (GNUNET_ERROR_TYPE_DEBUG, " next copy %u\n", copy->mid);
1070 continue; 1070 continue;
@@ -1125,7 +1125,7 @@ rel_message_free (struct CadetReliableMessage *copy, int update_time)
1125 rel->ch->pending_messages--; 1125 rel->ch->pending_messages--;
1126 if (NULL != copy->chq) 1126 if (NULL != copy->chq)
1127 { 1127 {
1128 GMT_cancel (copy->chq->tq); 1128 GCT_cancel (copy->chq->tq);
1129 /* copy->q is set to NULL by ch_message_sent */ 1129 /* copy->q is set to NULL by ch_message_sent */
1130 } 1130 }
1131 GNUNET_CONTAINER_DLL_remove (rel->head_sent, rel->tail_sent, copy); 1131 GNUNET_CONTAINER_DLL_remove (rel->head_sent, rel->tail_sent, copy);
@@ -1134,7 +1134,7 @@ rel_message_free (struct CadetReliableMessage *copy, int update_time)
1134 1134
1135 if (GNUNET_NO != rel->ch->destroy && 0 == rel->ch->pending_messages) 1135 if (GNUNET_NO != rel->ch->destroy && 0 == rel->ch->pending_messages)
1136 { 1136 {
1137 GMCH_destroy (rel->ch); 1137 GCCH_destroy (rel->ch);
1138 return GNUNET_YES; 1138 return GNUNET_YES;
1139 } 1139 }
1140 return GNUNET_NO; 1140 return GNUNET_NO;
@@ -1160,7 +1160,7 @@ channel_confirm (struct CadetChannel *ch, int fwd)
1160 return; 1160 return;
1161 } 1161 }
1162 LOG (GNUNET_ERROR_TYPE_DEBUG, " channel confirm %s %s\n", 1162 LOG (GNUNET_ERROR_TYPE_DEBUG, " channel confirm %s %s\n",
1163 GM_f2s (fwd), GMCH_2s (ch)); 1163 GC_f2s (fwd), GCCH_2s (ch));
1164 oldstate = ch->state; 1164 oldstate = ch->state;
1165 ch->state = CADET_CHANNEL_READY; 1165 ch->state = CADET_CHANNEL_READY;
1166 1166
@@ -1170,7 +1170,7 @@ channel_confirm (struct CadetChannel *ch, int fwd)
1170 rel->expected_delay = rel->retry_timer; 1170 rel->expected_delay = rel->retry_timer;
1171 LOG (GNUNET_ERROR_TYPE_DEBUG, " !! retry timer confirm %s\n", 1171 LOG (GNUNET_ERROR_TYPE_DEBUG, " !! retry timer confirm %s\n",
1172 GNUNET_STRINGS_relative_time_to_string (rel->retry_timer, GNUNET_NO)); 1172 GNUNET_STRINGS_relative_time_to_string (rel->retry_timer, GNUNET_NO));
1173 if (GMT_get_connections_buffer (ch->t) > 0 || GMT_is_loopback (ch->t)) 1173 if (GCT_get_connections_buffer (ch->t) > 0 || GCT_is_loopback (ch->t))
1174 send_client_ack (ch, fwd); 1174 send_client_ack (ch, fwd);
1175 1175
1176 if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task) 1176 if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task)
@@ -1180,7 +1180,7 @@ channel_confirm (struct CadetChannel *ch, int fwd)
1180 } 1180 }
1181 else if (NULL != rel->uniq) 1181 else if (NULL != rel->uniq)
1182 { 1182 {
1183 GMT_cancel (rel->uniq->tq); 1183 GCT_cancel (rel->uniq->tq);
1184 /* ch_message_sent will free and NULL uniq */ 1184 /* ch_message_sent will free and NULL uniq */
1185 } 1185 }
1186 else 1186 else
@@ -1224,7 +1224,7 @@ channel_save_copy (struct CadetChannel *ch,
1224 type = ntohs (msg->type); 1224 type = ntohs (msg->type);
1225 size = ntohs (msg->size); 1225 size = ntohs (msg->size);
1226 1226
1227 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SAVE %u %s\n", mid, GM_m2s (type)); 1227 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SAVE %u %s\n", mid, GC_m2s (type));
1228 copy = GNUNET_malloc (sizeof (struct CadetReliableMessage) + size); 1228 copy = GNUNET_malloc (sizeof (struct CadetReliableMessage) + size);
1229 LOG (GNUNET_ERROR_TYPE_DEBUG, " at %p\n", copy); 1229 LOG (GNUNET_ERROR_TYPE_DEBUG, " at %p\n", copy);
1230 copy->mid = mid; 1230 copy->mid = mid;
@@ -1263,10 +1263,10 @@ channel_new (struct CadetTunnel3 *t,
1263 1263
1264 if (NULL != owner) 1264 if (NULL != owner)
1265 { 1265 {
1266 ch->gid = GMT_get_next_chid (t); 1266 ch->gid = GCT_get_next_chid (t);
1267 GML_channel_add (owner, lid_root, ch); 1267 GML_channel_add (owner, lid_root, ch);
1268 } 1268 }
1269 GMT_add_channel (t, ch); 1269 GCT_add_channel (t, ch);
1270 1270
1271 return ch; 1271 return ch;
1272} 1272}
@@ -1289,7 +1289,7 @@ handle_loopback (struct CadetChannel *ch,
1289 type = ntohs (msgh->type); 1289 type = ntohs (msgh->type);
1290 LOG (GNUNET_ERROR_TYPE_DEBUG, 1290 LOG (GNUNET_ERROR_TYPE_DEBUG,
1291 "Loopback %s %s message!\n", 1291 "Loopback %s %s message!\n",
1292 GM_f2s (fwd), GM_m2s (type)); 1292 GC_f2s (fwd), GC_m2s (type));
1293 1293
1294 switch (type) 1294 switch (type)
1295 { 1295 {
@@ -1297,30 +1297,30 @@ handle_loopback (struct CadetChannel *ch,
1297 /* Don't send hop ACK, wait for client to ACK */ 1297 /* Don't send hop ACK, wait for client to ACK */
1298 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SEND loopback %u (%u)\n", 1298 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SEND loopback %u (%u)\n",
1299 ntohl (((struct GNUNET_CADET_Data *) msgh)->mid), ntohs (msgh->size)); 1299 ntohl (((struct GNUNET_CADET_Data *) msgh)->mid), ntohs (msgh->size));
1300 GMCH_handle_data (ch, (struct GNUNET_CADET_Data *) msgh, fwd); 1300 GCCH_handle_data (ch, (struct GNUNET_CADET_Data *) msgh, fwd);
1301 break; 1301 break;
1302 1302
1303 case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK: 1303 case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK:
1304 GMCH_handle_data_ack (ch, (struct GNUNET_CADET_DataACK *) msgh, fwd); 1304 GCCH_handle_data_ack (ch, (struct GNUNET_CADET_DataACK *) msgh, fwd);
1305 break; 1305 break;
1306 1306
1307 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE: 1307 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE:
1308 GMCH_handle_create (ch->t, 1308 GCCH_handle_create (ch->t,
1309 (struct GNUNET_CADET_ChannelCreate *) msgh); 1309 (struct GNUNET_CADET_ChannelCreate *) msgh);
1310 break; 1310 break;
1311 1311
1312 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK: 1312 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK:
1313 GMCH_handle_ack (ch, 1313 GCCH_handle_ack (ch,
1314 (struct GNUNET_CADET_ChannelManage *) msgh, 1314 (struct GNUNET_CADET_ChannelManage *) msgh,
1315 fwd); 1315 fwd);
1316 break; 1316 break;
1317 1317
1318 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK: 1318 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK:
1319 GMCH_handle_nack (ch); 1319 GCCH_handle_nack (ch);
1320 break; 1320 break;
1321 1321
1322 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY: 1322 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY:
1323 GMCH_handle_destroy (ch, 1323 GCCH_handle_destroy (ch,
1324 (struct GNUNET_CADET_ChannelManage *) msgh, 1324 (struct GNUNET_CADET_ChannelManage *) msgh,
1325 fwd); 1325 fwd);
1326 break; 1326 break;
@@ -1345,7 +1345,7 @@ handle_loopback (struct CadetChannel *ch,
1345 * @param ch Channel to destroy. 1345 * @param ch Channel to destroy.
1346 */ 1346 */
1347void 1347void
1348GMCH_destroy (struct CadetChannel *ch) 1348GCCH_destroy (struct CadetChannel *ch)
1349{ 1349{
1350 struct CadetClient *c; 1350 struct CadetClient *c;
1351 struct CadetTunnel3 *t; 1351 struct CadetTunnel3 *t;
@@ -1357,8 +1357,8 @@ GMCH_destroy (struct CadetChannel *ch)
1357 ch->destroy = 2; 1357 ch->destroy = 2;
1358 1358
1359 LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying channel %s:%u\n", 1359 LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying channel %s:%u\n",
1360 GMT_2s (ch->t), ch->gid); 1360 GCT_2s (ch->t), ch->gid);
1361 GMCH_debug (ch); 1361 GCCH_debug (ch);
1362 1362
1363 c = ch->root; 1363 c = ch->root;
1364 if (NULL != c) 1364 if (NULL != c)
@@ -1376,11 +1376,11 @@ GMCH_destroy (struct CadetChannel *ch)
1376 channel_rel_free_all (ch->dest_rel); 1376 channel_rel_free_all (ch->dest_rel);
1377 1377
1378 t = ch->t; 1378 t = ch->t;
1379 GMT_remove_channel (t, ch); 1379 GCT_remove_channel (t, ch);
1380 GNUNET_STATISTICS_update (stats, "# channels", -1, GNUNET_NO); 1380 GNUNET_STATISTICS_update (stats, "# channels", -1, GNUNET_NO);
1381 1381
1382 GNUNET_free (ch); 1382 GNUNET_free (ch);
1383 GMT_destroy_if_empty (t); 1383 GCT_destroy_if_empty (t);
1384} 1384}
1385 1385
1386 1386
@@ -1392,7 +1392,7 @@ GMCH_destroy (struct CadetChannel *ch)
1392 * @return ID used to identify the channel with the remote peer. 1392 * @return ID used to identify the channel with the remote peer.
1393 */ 1393 */
1394CADET_ChannelNumber 1394CADET_ChannelNumber
1395GMCH_get_id (const struct CadetChannel *ch) 1395GCCH_get_id (const struct CadetChannel *ch)
1396{ 1396{
1397 return ch->gid; 1397 return ch->gid;
1398} 1398}
@@ -1406,7 +1406,7 @@ GMCH_get_id (const struct CadetChannel *ch)
1406 * @return tunnel of the channel. 1406 * @return tunnel of the channel.
1407 */ 1407 */
1408struct CadetTunnel3 * 1408struct CadetTunnel3 *
1409GMCH_get_tunnel (const struct CadetChannel *ch) 1409GCCH_get_tunnel (const struct CadetChannel *ch)
1410{ 1410{
1411 return ch->t; 1411 return ch->t;
1412} 1412}
@@ -1421,7 +1421,7 @@ GMCH_get_tunnel (const struct CadetChannel *ch)
1421 * @return Free buffer space [0 - 64] 1421 * @return Free buffer space [0 - 64]
1422 */ 1422 */
1423unsigned int 1423unsigned int
1424GMCH_get_buffer (struct CadetChannel *ch, int fwd) 1424GCCH_get_buffer (struct CadetChannel *ch, int fwd)
1425{ 1425{
1426 struct CadetChannelReliability *rel; 1426 struct CadetChannelReliability *rel;
1427 1427
@@ -1447,7 +1447,7 @@ GMCH_get_buffer (struct CadetChannel *ch, int fwd)
1447 * @return #GNUNET_YES if client is allowed to send us data. 1447 * @return #GNUNET_YES if client is allowed to send us data.
1448 */ 1448 */
1449int 1449int
1450GMCH_get_allowed (struct CadetChannel *ch, int fwd) 1450GCCH_get_allowed (struct CadetChannel *ch, int fwd)
1451{ 1451{
1452 struct CadetChannelReliability *rel; 1452 struct CadetChannelReliability *rel;
1453 1453
@@ -1473,7 +1473,7 @@ GMCH_get_allowed (struct CadetChannel *ch, int fwd)
1473 * @return #GNUNET_YES in case it is. 1473 * @return #GNUNET_YES in case it is.
1474 */ 1474 */
1475int 1475int
1476GMCH_is_origin (struct CadetChannel *ch, int fwd) 1476GCCH_is_origin (struct CadetChannel *ch, int fwd)
1477{ 1477{
1478 struct CadetClient *c; 1478 struct CadetClient *c;
1479 1479
@@ -1491,7 +1491,7 @@ GMCH_is_origin (struct CadetChannel *ch, int fwd)
1491 * @return #GNUNET_YES in case it is. 1491 * @return #GNUNET_YES in case it is.
1492 */ 1492 */
1493int 1493int
1494GMCH_is_terminal (struct CadetChannel *ch, int fwd) 1494GCCH_is_terminal (struct CadetChannel *ch, int fwd)
1495{ 1495{
1496 struct CadetClient *c; 1496 struct CadetClient *c;
1497 1497
@@ -1509,7 +1509,7 @@ GMCH_is_terminal (struct CadetChannel *ch, int fwd)
1509 * @param fwd Is for FWD traffic? (ACK dest->owner) 1509 * @param fwd Is for FWD traffic? (ACK dest->owner)
1510 */ 1510 */
1511void 1511void
1512GMCH_send_data_ack (struct CadetChannel *ch, int fwd) 1512GCCH_send_data_ack (struct CadetChannel *ch, int fwd)
1513{ 1513{
1514 struct GNUNET_CADET_DataACK msg; 1514 struct GNUNET_CADET_DataACK msg;
1515 struct CadetChannelReliability *rel; 1515 struct CadetChannelReliability *rel;
@@ -1536,7 +1536,7 @@ GMCH_send_data_ack (struct CadetChannel *ch, int fwd)
1536 { 1536 {
1537 LOG (GNUNET_ERROR_TYPE_DEBUG, 1537 LOG (GNUNET_ERROR_TYPE_DEBUG,
1538 "!! Type %s, expected DATA\n", 1538 "!! Type %s, expected DATA\n",
1539 GM_m2s (copy->type)); 1539 GC_m2s (copy->type));
1540 continue; 1540 continue;
1541 } 1541 }
1542 if (copy->mid == ack + 1) 1542 if (copy->mid == ack + 1)
@@ -1558,7 +1558,7 @@ GMCH_send_data_ack (struct CadetChannel *ch, int fwd)
1558 "!!! ACK for %u, futures %llX\n", 1558 "!!! ACK for %u, futures %llX\n",
1559 ack, msg.futures); 1559 ack, msg.futures);
1560 1560
1561 GMCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL); 1561 GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL);
1562 LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n"); 1562 LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n");
1563} 1563}
1564 1564
@@ -1570,7 +1570,7 @@ GMCH_send_data_ack (struct CadetChannel *ch, int fwd)
1570 * @param fwd Is this about FWD traffic? (Root client). 1570 * @param fwd Is this about FWD traffic? (Root client).
1571 */ 1571 */
1572void 1572void
1573GMCH_allow_client (struct CadetChannel *ch, int fwd) 1573GCCH_allow_client (struct CadetChannel *ch, int fwd)
1574{ 1574{
1575 struct CadetChannelReliability *rel; 1575 struct CadetChannelReliability *rel;
1576 unsigned int buffer; 1576 unsigned int buffer;
@@ -1609,9 +1609,9 @@ GMCH_allow_client (struct CadetChannel *ch, int fwd)
1609 } 1609 }
1610 1610
1611 if (is_loopback (ch)) 1611 if (is_loopback (ch))
1612 buffer = GMCH_get_buffer (ch, fwd); 1612 buffer = GCCH_get_buffer (ch, fwd);
1613 else 1613 else
1614 buffer = GMT_get_connections_buffer (ch->t); 1614 buffer = GCT_get_connections_buffer (ch->t);
1615 1615
1616 if (0 == buffer) 1616 if (0 == buffer)
1617 { 1617 {
@@ -1630,7 +1630,7 @@ GMCH_allow_client (struct CadetChannel *ch, int fwd)
1630 * @param ch Channel. 1630 * @param ch Channel.
1631 */ 1631 */
1632void 1632void
1633GMCH_debug (struct CadetChannel *ch) 1633GCCH_debug (struct CadetChannel *ch)
1634{ 1634{
1635 if (NULL == ch) 1635 if (NULL == ch)
1636 { 1636 {
@@ -1638,7 +1638,7 @@ GMCH_debug (struct CadetChannel *ch)
1638 return; 1638 return;
1639 } 1639 }
1640 LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %s:%X (%p)\n", 1640 LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %s:%X (%p)\n",
1641 GMT_2s (ch->t), ch->gid, ch); 1641 GCT_2s (ch->t), ch->gid, ch);
1642 LOG (GNUNET_ERROR_TYPE_DEBUG, " root %p/%p\n", 1642 LOG (GNUNET_ERROR_TYPE_DEBUG, " root %p/%p\n",
1643 ch->root, ch->root_rel); 1643 ch->root, ch->root_rel);
1644 if (NULL != ch->root) 1644 if (NULL != ch->root)
@@ -1669,7 +1669,7 @@ GMCH_debug (struct CadetChannel *ch)
1669 * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by dest and go BCK) 1669 * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by dest and go BCK)
1670 */ 1670 */
1671void 1671void
1672GMCH_handle_local_ack (struct CadetChannel *ch, int fwd) 1672GCCH_handle_local_ack (struct CadetChannel *ch, int fwd)
1673{ 1673{
1674 struct CadetChannelReliability *rel; 1674 struct CadetChannelReliability *rel;
1675 struct CadetClient *c; 1675 struct CadetClient *c;
@@ -1683,7 +1683,7 @@ GMCH_handle_local_ack (struct CadetChannel *ch, int fwd)
1683 if (GNUNET_YES == ch->destroy && 0 == rel->n_recv) 1683 if (GNUNET_YES == ch->destroy && 0 == rel->n_recv)
1684 { 1684 {
1685 send_destroy (ch, GNUNET_YES); 1685 send_destroy (ch, GNUNET_YES);
1686 GMCH_destroy (ch); 1686 GCCH_destroy (ch);
1687 } 1687 }
1688 /* if loopback is marked for destruction, no need to ACK to the other peer, 1688 /* if loopback is marked for destruction, no need to ACK to the other peer,
1689 * it requested the destruction and is already gone, therefore, else if. 1689 * it requested the destruction and is already gone, therefore, else if.
@@ -1692,13 +1692,13 @@ GMCH_handle_local_ack (struct CadetChannel *ch, int fwd)
1692 { 1692 {
1693 unsigned int buffer; 1693 unsigned int buffer;
1694 1694
1695 buffer = GMCH_get_buffer (ch, fwd); 1695 buffer = GCCH_get_buffer (ch, fwd);
1696 if (0 < buffer) 1696 if (0 < buffer)
1697 GMCH_allow_client (ch, fwd); 1697 GCCH_allow_client (ch, fwd);
1698 1698
1699 return; 1699 return;
1700 } 1700 }
1701 GMT_send_connection_acks (ch->t); 1701 GCT_send_connection_acks (ch->t);
1702} 1702}
1703 1703
1704 1704
@@ -1717,7 +1717,7 @@ GMCH_handle_local_ack (struct CadetChannel *ch, int fwd)
1717 * @return GNUNET_OK if everything goes well, GNUNET_SYSERR in case of en error. 1717 * @return GNUNET_OK if everything goes well, GNUNET_SYSERR in case of en error.
1718 */ 1718 */
1719int 1719int
1720GMCH_handle_local_data (struct CadetChannel *ch, 1720GCCH_handle_local_data (struct CadetChannel *ch,
1721 struct CadetClient *c, 1721 struct CadetClient *c,
1722 struct GNUNET_MessageHeader *message, 1722 struct GNUNET_MessageHeader *message,
1723 int fwd) 1723 int fwd)
@@ -1758,19 +1758,19 @@ GMCH_handle_local_data (struct CadetChannel *ch,
1758 payload->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_DATA); 1758 payload->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_DATA);
1759 payload->chid = htonl (ch->gid); 1759 payload->chid = htonl (ch->gid);
1760 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on channel...\n"); 1760 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on channel...\n");
1761 GMCH_send_prebuilt_message (&payload->header, ch, fwd, NULL); 1761 GCCH_send_prebuilt_message (&payload->header, ch, fwd, NULL);
1762 1762
1763 if (is_loopback (ch)) 1763 if (is_loopback (ch))
1764 { 1764 {
1765 if (GMCH_get_buffer (ch, fwd) > 0) 1765 if (GCCH_get_buffer (ch, fwd) > 0)
1766 GMCH_allow_client (ch, fwd); 1766 GCCH_allow_client (ch, fwd);
1767 1767
1768 return GNUNET_OK; 1768 return GNUNET_OK;
1769 } 1769 }
1770 1770
1771 if (GMT_get_connections_buffer (ch->t) > 0) 1771 if (GCT_get_connections_buffer (ch->t) > 0)
1772 { 1772 {
1773 GMCH_allow_client (ch, fwd); 1773 GCCH_allow_client (ch, fwd);
1774 } 1774 }
1775 1775
1776 return GNUNET_OK; 1776 return GNUNET_OK;
@@ -1787,7 +1787,7 @@ GMCH_handle_local_data (struct CadetChannel *ch,
1787 * @param is_root Is the request coming from root? 1787 * @param is_root Is the request coming from root?
1788 */ 1788 */
1789void 1789void
1790GMCH_handle_local_destroy (struct CadetChannel *ch, 1790GCCH_handle_local_destroy (struct CadetChannel *ch,
1791 struct CadetClient *c, 1791 struct CadetClient *c,
1792 int is_root) 1792 int is_root)
1793{ 1793{
@@ -1808,7 +1808,7 @@ GMCH_handle_local_destroy (struct CadetChannel *ch,
1808 1808
1809 send_destroy (ch, GNUNET_NO); 1809 send_destroy (ch, GNUNET_NO);
1810 if (0 == ch->pending_messages) 1810 if (0 == ch->pending_messages)
1811 GMCH_destroy (ch); 1811 GCCH_destroy (ch);
1812} 1812}
1813 1813
1814 1814
@@ -1823,7 +1823,7 @@ GMCH_handle_local_destroy (struct CadetChannel *ch,
1823 * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise. 1823 * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise.
1824 */ 1824 */
1825int 1825int
1826GMCH_handle_local_create (struct CadetClient *c, 1826GCCH_handle_local_create (struct CadetClient *c,
1827 struct GNUNET_CADET_ChannelMessage *msg) 1827 struct GNUNET_CADET_ChannelMessage *msg)
1828{ 1828{
1829 struct CadetChannel *ch; 1829 struct CadetChannel *ch;
@@ -1842,18 +1842,18 @@ GMCH_handle_local_create (struct CadetClient *c,
1842 return GNUNET_SYSERR; 1842 return GNUNET_SYSERR;
1843 } 1843 }
1844 1844
1845 peer = GMP_get (&msg->peer); 1845 peer = GCP_get (&msg->peer);
1846 GMP_add_tunnel (peer); 1846 GCP_add_tunnel (peer);
1847 t = GMP_get_tunnel (peer); 1847 t = GCP_get_tunnel (peer);
1848 1848
1849 if (GMP_get_short_id (peer) == myid) 1849 if (GCP_get_short_id (peer) == myid)
1850 { 1850 {
1851 GMT_change_cstate (t, CADET_TUNNEL3_READY); 1851 GCT_change_cstate (t, CADET_TUNNEL3_READY);
1852 } 1852 }
1853 else 1853 else
1854 { 1854 {
1855 /* FIXME change to a tunnel API, eliminate ch <-> peer connection */ 1855 /* FIXME change to a tunnel API, eliminate ch <-> peer connection */
1856 GMP_connect (peer); 1856 GCP_connect (peer);
1857 } 1857 }
1858 1858
1859 /* Create channel */ 1859 /* Create channel */
@@ -1872,7 +1872,7 @@ GMCH_handle_local_create (struct CadetClient *c,
1872 ch->root_rel->retry_timer = CADET_RETRANSMIT_TIME; 1872 ch->root_rel->retry_timer = CADET_RETRANSMIT_TIME;
1873 ch->root_rel->expected_delay.rel_value_us = 0; 1873 ch->root_rel->expected_delay.rel_value_us = 0;
1874 1874
1875 LOG (GNUNET_ERROR_TYPE_DEBUG, "CREATED CHANNEL %s\n", GMCH_2s (ch)); 1875 LOG (GNUNET_ERROR_TYPE_DEBUG, "CREATED CHANNEL %s\n", GCCH_2s (ch));
1876 1876
1877 send_create (ch); 1877 send_create (ch);
1878 1878
@@ -1891,7 +1891,7 @@ GMCH_handle_local_create (struct CadetClient *c,
1891 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1891 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1892 */ 1892 */
1893void 1893void
1894GMCH_handle_data (struct CadetChannel *ch, 1894GCCH_handle_data (struct CadetChannel *ch,
1895 const struct GNUNET_CADET_Data *msg, 1895 const struct GNUNET_CADET_Data *msg,
1896 int fwd) 1896 int fwd)
1897{ 1897{
@@ -1942,11 +1942,11 @@ GMCH_handle_data (struct CadetChannel *ch,
1942 1942
1943 mid = ntohl (msg->mid); 1943 mid = ntohl (msg->mid);
1944 LOG (GNUNET_ERROR_TYPE_INFO, "<=== DATA %u %s on channel %s\n", 1944 LOG (GNUNET_ERROR_TYPE_INFO, "<=== DATA %u %s on channel %s\n",
1945 mid, GM_f2s (fwd), GMCH_2s (ch)); 1945 mid, GC_f2s (fwd), GCCH_2s (ch));
1946 1946
1947 if (GNUNET_NO == ch->reliable || 1947 if (GNUNET_NO == ch->reliable ||
1948 ( !GM_is_pid_bigger (rel->mid_recv, mid) && 1948 ( !GC_is_pid_bigger (rel->mid_recv, mid) &&
1949 GM_is_pid_bigger (rel->mid_recv + 64, mid) ) ) 1949 GC_is_pid_bigger (rel->mid_recv + 64, mid) ) )
1950 { 1950 {
1951 LOG (GNUNET_ERROR_TYPE_DEBUG, "RECV %u (%u)\n", 1951 LOG (GNUNET_ERROR_TYPE_DEBUG, "RECV %u (%u)\n",
1952 mid, ntohs (msg->header.size)); 1952 mid, ntohs (msg->header.size));
@@ -1975,13 +1975,13 @@ GMCH_handle_data (struct CadetChannel *ch,
1975 } 1975 }
1976 else 1976 else
1977 { 1977 {
1978 GNUNET_break_op (GM_is_pid_bigger (rel->mid_recv, mid)); 1978 GNUNET_break_op (GC_is_pid_bigger (rel->mid_recv, mid));
1979 LOG (GNUNET_ERROR_TYPE_WARNING, 1979 LOG (GNUNET_ERROR_TYPE_WARNING,
1980 "MID %u not expected (%u - %u), dropping!\n", 1980 "MID %u not expected (%u - %u), dropping!\n",
1981 mid, rel->mid_recv, rel->mid_recv + 63); 1981 mid, rel->mid_recv, rel->mid_recv + 63);
1982 } 1982 }
1983 1983
1984 GMCH_send_data_ack (ch, fwd); 1984 GCCH_send_data_ack (ch, fwd);
1985} 1985}
1986 1986
1987 1987
@@ -1996,7 +1996,7 @@ GMCH_handle_data (struct CadetChannel *ch,
1996 * #GNUNET_SYSERR if message on a one-ended channel (remote) 1996 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1997 */ 1997 */
1998void 1998void
1999GMCH_handle_data_ack (struct CadetChannel *ch, 1999GCCH_handle_data_ack (struct CadetChannel *ch,
2000 const struct GNUNET_CADET_DataACK *msg, 2000 const struct GNUNET_CADET_DataACK *msg,
2001 int fwd) 2001 int fwd)
2002{ 2002{
@@ -2020,7 +2020,7 @@ GMCH_handle_data_ack (struct CadetChannel *ch,
2020 } 2020 }
2021 2021
2022 ack = ntohl (msg->mid); 2022 ack = ntohl (msg->mid);
2023 LOG (GNUNET_ERROR_TYPE_INFO, "<=== %s ACK %u\n", GM_f2s (fwd), ack); 2023 LOG (GNUNET_ERROR_TYPE_INFO, "<=== %s ACK %u\n", GC_f2s (fwd), ack);
2024 2024
2025 if (GNUNET_YES == fwd) 2025 if (GNUNET_YES == fwd)
2026 { 2026 {
@@ -2039,7 +2039,7 @@ GMCH_handle_data_ack (struct CadetChannel *ch,
2039 /* Free ACK'd copies: no need to retransmit those anymore FIXME refactor */ 2039 /* Free ACK'd copies: no need to retransmit those anymore FIXME refactor */
2040 for (work = GNUNET_NO, copy = rel->head_sent; copy != NULL; copy = next) 2040 for (work = GNUNET_NO, copy = rel->head_sent; copy != NULL; copy = next)
2041 { 2041 {
2042 if (GM_is_pid_bigger (copy->mid, ack)) 2042 if (GC_is_pid_bigger (copy->mid, ack))
2043 { 2043 {
2044 LOG (GNUNET_ERROR_TYPE_DEBUG, " head %u, out!\n", copy->mid); 2044 LOG (GNUNET_ERROR_TYPE_DEBUG, " head %u, out!\n", copy->mid);
2045 channel_rel_free_sent (rel, msg); 2045 channel_rel_free_sent (rel, msg);
@@ -2053,7 +2053,7 @@ GMCH_handle_data_ack (struct CadetChannel *ch,
2053 } 2053 }
2054 2054
2055 /* ACK client if needed and possible */ 2055 /* ACK client if needed and possible */
2056 GMCH_allow_client (ch, fwd); 2056 GCCH_allow_client (ch, fwd);
2057 2057
2058 /* If some message was free'd, update the retransmission delay */ 2058 /* If some message was free'd, update the retransmission delay */
2059 if (GNUNET_YES == work) 2059 if (GNUNET_YES == work)
@@ -2096,7 +2096,7 @@ GMCH_handle_data_ack (struct CadetChannel *ch,
2096 * @param msg Channel crate message. 2096 * @param msg Channel crate message.
2097 */ 2097 */
2098struct CadetChannel * 2098struct CadetChannel *
2099GMCH_handle_create (struct CadetTunnel3 *t, 2099GCCH_handle_create (struct CadetTunnel3 *t,
2100 const struct GNUNET_CADET_ChannelCreate *msg) 2100 const struct GNUNET_CADET_ChannelCreate *msg)
2101{ 2101{
2102 CADET_ChannelNumber chid; 2102 CADET_ChannelNumber chid;
@@ -2107,7 +2107,7 @@ GMCH_handle_create (struct CadetTunnel3 *t,
2107 2107
2108 reaction = GNUNET_NO; 2108 reaction = GNUNET_NO;
2109 chid = ntohl (msg->chid); 2109 chid = ntohl (msg->chid);
2110 ch = GMT_get_channel (t, chid); 2110 ch = GCT_get_channel (t, chid);
2111 if (NULL == ch) 2111 if (NULL == ch)
2112 { 2112 {
2113 /* Create channel */ 2113 /* Create channel */
@@ -2121,7 +2121,7 @@ GMCH_handle_create (struct CadetTunnel3 *t,
2121 new_channel = GNUNET_NO; 2121 new_channel = GNUNET_NO;
2122 } 2122 }
2123 2123
2124 if (GNUNET_YES == new_channel || GMT_is_loopback (t)) 2124 if (GNUNET_YES == new_channel || GCT_is_loopback (t))
2125 { 2125 {
2126 /* Find a destination client */ 2126 /* Find a destination client */
2127 ch->port = ntohl (msg->port); 2127 ch->port = ntohl (msg->port);
@@ -2139,7 +2139,7 @@ GMCH_handle_create (struct CadetTunnel3 *t,
2139 { 2139 {
2140 LOG (GNUNET_ERROR_TYPE_DEBUG, " not loopback: destroy now\n"); 2140 LOG (GNUNET_ERROR_TYPE_DEBUG, " not loopback: destroy now\n");
2141 send_nack (ch); 2141 send_nack (ch);
2142 GMCH_destroy (ch); 2142 GCCH_destroy (ch);
2143 } 2143 }
2144 return NULL; 2144 return NULL;
2145 } 2145 }
@@ -2183,10 +2183,10 @@ GMCH_handle_create (struct CadetTunnel3 *t,
2183 * @param ch Channel. 2183 * @param ch Channel.
2184 */ 2184 */
2185void 2185void
2186GMCH_handle_nack (struct CadetChannel *ch) 2186GCCH_handle_nack (struct CadetChannel *ch)
2187{ 2187{
2188 send_client_nack (ch); 2188 send_client_nack (ch);
2189 GMCH_destroy (ch); 2189 GCCH_destroy (ch);
2190} 2190}
2191 2191
2192 2192
@@ -2201,7 +2201,7 @@ GMCH_handle_nack (struct CadetChannel *ch)
2201 * #GNUNET_SYSERR if message on a one-ended channel (remote) 2201 * #GNUNET_SYSERR if message on a one-ended channel (remote)
2202 */ 2202 */
2203void 2203void
2204GMCH_handle_ack (struct CadetChannel *ch, 2204GCCH_handle_ack (struct CadetChannel *ch,
2205 const struct GNUNET_CADET_ChannelManage *msg, 2205 const struct GNUNET_CADET_ChannelManage *msg,
2206 int fwd) 2206 int fwd)
2207{ 2207{
@@ -2232,7 +2232,7 @@ GMCH_handle_ack (struct CadetChannel *ch,
2232 * #GNUNET_SYSERR if message on a one-ended channel (remote) 2232 * #GNUNET_SYSERR if message on a one-ended channel (remote)
2233 */ 2233 */
2234void 2234void
2235GMCH_handle_destroy (struct CadetChannel *ch, 2235GCCH_handle_destroy (struct CadetChannel *ch,
2236 const struct GNUNET_CADET_ChannelManage *msg, 2236 const struct GNUNET_CADET_ChannelManage *msg,
2237 int fwd) 2237 int fwd)
2238{ 2238{
@@ -2250,7 +2250,7 @@ GMCH_handle_destroy (struct CadetChannel *ch,
2250 fwd = (NULL != ch->dest) ? GNUNET_YES : GNUNET_NO; 2250 fwd = (NULL != ch->dest) ? GNUNET_YES : GNUNET_NO;
2251 } 2251 }
2252 2252
2253 GMCH_debug (ch); 2253 GCCH_debug (ch);
2254 if ( (fwd && NULL == ch->dest) || (!fwd && NULL == ch->root) ) 2254 if ( (fwd && NULL == ch->dest) || (!fwd && NULL == ch->root) )
2255 { 2255 {
2256 /* Not for us (don't destroy twice a half-open loopback channel) */ 2256 /* Not for us (don't destroy twice a half-open loopback channel) */
@@ -2261,7 +2261,7 @@ GMCH_handle_destroy (struct CadetChannel *ch,
2261 if (0 == rel->n_recv) 2261 if (0 == rel->n_recv)
2262 { 2262 {
2263 send_destroy (ch, GNUNET_YES); 2263 send_destroy (ch, GNUNET_YES);
2264 GMCH_destroy (ch); 2264 GCCH_destroy (ch);
2265 } 2265 }
2266 else 2266 else
2267 { 2267 {
@@ -2287,7 +2287,7 @@ GMCH_handle_destroy (struct CadetChannel *ch,
2287 * @param existing_copy This is a retransmission, don't save a copy. 2287 * @param existing_copy This is a retransmission, don't save a copy.
2288 */ 2288 */
2289void 2289void
2290GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, 2290GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2291 struct CadetChannel *ch, int fwd, 2291 struct CadetChannel *ch, int fwd,
2292 void *existing_copy) 2292 void *existing_copy)
2293{ 2293{
@@ -2296,9 +2296,9 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2296 2296
2297 type = ntohs (message->type); 2297 type = ntohs (message->type);
2298 LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %s on channel %s\n", 2298 LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %s on channel %s\n",
2299 GM_m2s (type), GM_f2s (fwd), GMCH_2s (ch)); 2299 GC_m2s (type), GC_f2s (fwd), GCCH_2s (ch));
2300 2300
2301 if (GMT_is_loopback (ch->t)) 2301 if (GCT_is_loopback (ch->t))
2302 { 2302 {
2303 handle_loopback (ch, message, fwd); 2303 handle_loopback (ch, message, fwd);
2304 return; 2304 return;
@@ -2311,7 +2311,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2311 2311
2312 payload = (struct GNUNET_CADET_Data *) message; 2312 payload = (struct GNUNET_CADET_Data *) message;
2313 LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %u\n", 2313 LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %u\n",
2314 GM_m2s (type), ntohl (payload->mid)); 2314 GC_m2s (type), ntohl (payload->mid));
2315 if (GNUNET_YES == ch->reliable) 2315 if (GNUNET_YES == ch->reliable)
2316 { 2316 {
2317 chq = GNUNET_new (struct CadetChannelQueue); 2317 chq = GNUNET_new (struct CadetChannelQueue);
@@ -2344,7 +2344,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2344 } 2344 }
2345 LOG (GNUNET_ERROR_TYPE_DEBUG, " new chq: %p\n", chq); 2345 LOG (GNUNET_ERROR_TYPE_DEBUG, " new chq: %p\n", chq);
2346 chq->copy->chq = chq; 2346 chq->copy->chq = chq;
2347 chq->tq = GMT_send_prebuilt_message (message, ch->t, NULL, 2347 chq->tq = GCT_send_prebuilt_message (message, ch->t, NULL,
2348 NULL != existing_copy, 2348 NULL != existing_copy,
2349 &ch_message_sent, chq); 2349 &ch_message_sent, chq);
2350 /* q itself is stored in copy */ 2350 /* q itself is stored in copy */
@@ -2374,7 +2374,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2374 { 2374 {
2375 if (NULL != chq->rel->uniq->tq) 2375 if (NULL != chq->rel->uniq->tq)
2376 { 2376 {
2377 GMT_cancel (chq->rel->uniq->tq); 2377 GCT_cancel (chq->rel->uniq->tq);
2378 /* ch_message_sent is called, freeing and NULLing uniq */ 2378 /* ch_message_sent is called, freeing and NULLing uniq */
2379 } 2379 }
2380 else 2380 else
@@ -2383,7 +2383,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2383 GNUNET_free (chq->rel->uniq); 2383 GNUNET_free (chq->rel->uniq);
2384 } 2384 }
2385 } 2385 }
2386 chq->tq = GMT_send_prebuilt_message (message, ch->t, NULL, GNUNET_YES, 2386 chq->tq = GCT_send_prebuilt_message (message, ch->t, NULL, GNUNET_YES,
2387 &ch_message_sent, chq); 2387 &ch_message_sent, chq);
2388 if (NULL == chq->tq) 2388 if (NULL == chq->tq)
2389 { 2389 {
@@ -2404,7 +2404,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2404 2404
2405 default: 2405 default:
2406 GNUNET_break (0); 2406 GNUNET_break (0);
2407 LOG (GNUNET_ERROR_TYPE_DEBUG, "type %s unknown!\n", GM_m2s (type)); 2407 LOG (GNUNET_ERROR_TYPE_DEBUG, "type %s unknown!\n", GC_m2s (type));
2408 fire_and_forget (message, ch, GNUNET_YES); 2408 fire_and_forget (message, ch, GNUNET_YES);
2409 } 2409 }
2410} 2410}
@@ -2418,7 +2418,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2418 * @return Static string with the channel IDs. 2418 * @return Static string with the channel IDs.
2419 */ 2419 */
2420const char * 2420const char *
2421GMCH_2s (const struct CadetChannel *ch) 2421GCCH_2s (const struct CadetChannel *ch)
2422{ 2422{
2423 static char buf[64]; 2423 static char buf[64];
2424 2424
@@ -2426,7 +2426,7 @@ GMCH_2s (const struct CadetChannel *ch)
2426 return "(NULL Channel)"; 2426 return "(NULL Channel)";
2427 2427
2428 sprintf (buf, "%s:%u gid:%X (%X / %X)", 2428 sprintf (buf, "%s:%u gid:%X (%X / %X)",
2429 GMT_2s (ch->t), ch->port, ch->gid, ch->lid_root, ch->lid_dest); 2429 GCT_2s (ch->t), ch->port, ch->gid, ch->lid_root, ch->lid_dest);
2430 2430
2431 return buf; 2431 return buf;
2432} 2432}
diff --git a/src/cadet/gnunet-service-cadet_channel.h b/src/cadet/gnunet-service-cadet_channel.h
index f5a89a423..a472669c5 100644
--- a/src/cadet/gnunet-service-cadet_channel.h
+++ b/src/cadet/gnunet-service-cadet_channel.h
@@ -59,7 +59,7 @@ struct CadetChannel;
59 * @param ch Channel to destroy. 59 * @param ch Channel to destroy.
60 */ 60 */
61void 61void
62GMCH_destroy (struct CadetChannel *ch); 62GCCH_destroy (struct CadetChannel *ch);
63 63
64 64
65/** 65/**
@@ -70,7 +70,7 @@ GMCH_destroy (struct CadetChannel *ch);
70 * @return ID used to identify the channel with the remote peer. 70 * @return ID used to identify the channel with the remote peer.
71 */ 71 */
72CADET_ChannelNumber 72CADET_ChannelNumber
73GMCH_get_id (const struct CadetChannel *ch); 73GCCH_get_id (const struct CadetChannel *ch);
74 74
75/** 75/**
76 * Get the channel tunnel. 76 * Get the channel tunnel.
@@ -80,7 +80,7 @@ GMCH_get_id (const struct CadetChannel *ch);
80 * @return tunnel of the channel. 80 * @return tunnel of the channel.
81 */ 81 */
82struct CadetTunnel3 * 82struct CadetTunnel3 *
83GMCH_get_tunnel (const struct CadetChannel *ch); 83GCCH_get_tunnel (const struct CadetChannel *ch);
84 84
85/** 85/**
86 * Get free buffer space towards the client on a specific channel. 86 * Get free buffer space towards the client on a specific channel.
@@ -91,7 +91,7 @@ GMCH_get_tunnel (const struct CadetChannel *ch);
91 * @return Free buffer space [0 - 64] 91 * @return Free buffer space [0 - 64]
92 */ 92 */
93unsigned int 93unsigned int
94GMCH_get_buffer (struct CadetChannel *ch, int fwd); 94GCCH_get_buffer (struct CadetChannel *ch, int fwd);
95 95
96 96
97/** 97/**
@@ -103,7 +103,7 @@ GMCH_get_buffer (struct CadetChannel *ch, int fwd);
103 * @return #GNUNET_YES if client is allowed to send us data. 103 * @return #GNUNET_YES if client is allowed to send us data.
104 */ 104 */
105int 105int
106GMCH_get_allowed (struct CadetChannel *ch, int fwd); 106GCCH_get_allowed (struct CadetChannel *ch, int fwd);
107 107
108 108
109/** 109/**
@@ -115,7 +115,7 @@ GMCH_get_allowed (struct CadetChannel *ch, int fwd);
115 * @return #GNUNET_YES in case it is. 115 * @return #GNUNET_YES in case it is.
116 */ 116 */
117int 117int
118GMCH_is_origin (struct CadetChannel *ch, int fwd); 118GCCH_is_origin (struct CadetChannel *ch, int fwd);
119 119
120/** 120/**
121 * Is the destination client for this channel on this peer? 121 * Is the destination client for this channel on this peer?
@@ -126,7 +126,7 @@ GMCH_is_origin (struct CadetChannel *ch, int fwd);
126 * @return #GNUNET_YES in case it is. 126 * @return #GNUNET_YES in case it is.
127 */ 127 */
128int 128int
129GMCH_is_terminal (struct CadetChannel *ch, int fwd); 129GCCH_is_terminal (struct CadetChannel *ch, int fwd);
130 130
131/** 131/**
132 * Send an end-to-end ACK message for the most recent in-sequence payload. 132 * Send an end-to-end ACK message for the most recent in-sequence payload.
@@ -137,7 +137,7 @@ GMCH_is_terminal (struct CadetChannel *ch, int fwd);
137 * @param fwd Is for FWD traffic? (ACK dest->owner) 137 * @param fwd Is for FWD traffic? (ACK dest->owner)
138 */ 138 */
139void 139void
140GMCH_send_data_ack (struct CadetChannel *ch, int fwd); 140GCCH_send_data_ack (struct CadetChannel *ch, int fwd);
141 141
142/** 142/**
143 * Notify the destination client that a new incoming channel was created. 143 * Notify the destination client that a new incoming channel was created.
@@ -145,7 +145,7 @@ GMCH_send_data_ack (struct CadetChannel *ch, int fwd);
145 * @param ch Channel that was created. 145 * @param ch Channel that was created.
146 */ 146 */
147void 147void
148GMCH_send_create (struct CadetChannel *ch); 148GCCH_send_create (struct CadetChannel *ch);
149 149
150/** 150/**
151 * Allow a client to send us more data, in case it was choked. 151 * Allow a client to send us more data, in case it was choked.
@@ -154,7 +154,7 @@ GMCH_send_create (struct CadetChannel *ch);
154 * @param fwd Is this about FWD traffic? (Root client). 154 * @param fwd Is this about FWD traffic? (Root client).
155 */ 155 */
156void 156void
157GMCH_allow_client (struct CadetChannel *ch, int fwd); 157GCCH_allow_client (struct CadetChannel *ch, int fwd);
158 158
159/** 159/**
160 * Log channel info. 160 * Log channel info.
@@ -162,7 +162,7 @@ GMCH_allow_client (struct CadetChannel *ch, int fwd);
162 * @param ch Channel. 162 * @param ch Channel.
163 */ 163 */
164void 164void
165GMCH_debug (struct CadetChannel *ch); 165GCCH_debug (struct CadetChannel *ch);
166 166
167/** 167/**
168 * Handle an ACK given by a client. 168 * Handle an ACK given by a client.
@@ -173,7 +173,7 @@ GMCH_debug (struct CadetChannel *ch);
173 * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by root and go BCK) 173 * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by root and go BCK)
174 */ 174 */
175void 175void
176GMCH_handle_local_ack (struct CadetChannel *ch, int fwd); 176GCCH_handle_local_ack (struct CadetChannel *ch, int fwd);
177 177
178/** 178/**
179 * Handle data given by a client. 179 * Handle data given by a client.
@@ -190,7 +190,7 @@ GMCH_handle_local_ack (struct CadetChannel *ch, int fwd);
190 * @return GNUNET_OK if everything goes well, GNUNET_SYSERR in case of en error. 190 * @return GNUNET_OK if everything goes well, GNUNET_SYSERR in case of en error.
191 */ 191 */
192int 192int
193GMCH_handle_local_data (struct CadetChannel *ch, 193GCCH_handle_local_data (struct CadetChannel *ch,
194 struct CadetClient *c, 194 struct CadetClient *c,
195 struct GNUNET_MessageHeader *message, 195 struct GNUNET_MessageHeader *message,
196 int fwd); 196 int fwd);
@@ -205,7 +205,7 @@ GMCH_handle_local_data (struct CadetChannel *ch,
205 * @param is_root Is the request coming from root? 205 * @param is_root Is the request coming from root?
206 */ 206 */
207void 207void
208GMCH_handle_local_destroy (struct CadetChannel *ch, 208GCCH_handle_local_destroy (struct CadetChannel *ch,
209 struct CadetClient *c, 209 struct CadetClient *c,
210 int is_root); 210 int is_root);
211 211
@@ -220,7 +220,7 @@ GMCH_handle_local_destroy (struct CadetChannel *ch,
220 * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise. 220 * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise.
221 */ 221 */
222int 222int
223GMCH_handle_local_create (struct CadetClient *c, 223GCCH_handle_local_create (struct CadetClient *c,
224 struct GNUNET_CADET_ChannelMessage *msg); 224 struct GNUNET_CADET_ChannelMessage *msg);
225 225
226/** 226/**
@@ -234,7 +234,7 @@ GMCH_handle_local_create (struct CadetClient *c,
234 * #GNUNET_SYSERR if message on a one-ended channel (remote) 234 * #GNUNET_SYSERR if message on a one-ended channel (remote)
235 */ 235 */
236void 236void
237GMCH_handle_data (struct CadetChannel *ch, 237GCCH_handle_data (struct CadetChannel *ch,
238 const struct GNUNET_CADET_Data *msg, 238 const struct GNUNET_CADET_Data *msg,
239 int fwd); 239 int fwd);
240 240
@@ -249,7 +249,7 @@ GMCH_handle_data (struct CadetChannel *ch,
249 * #GNUNET_SYSERR if message on a one-ended channel (remote) 249 * #GNUNET_SYSERR if message on a one-ended channel (remote)
250 */ 250 */
251void 251void
252GMCH_handle_data_ack (struct CadetChannel *ch, 252GCCH_handle_data_ack (struct CadetChannel *ch,
253 const struct GNUNET_CADET_DataACK *msg, 253 const struct GNUNET_CADET_DataACK *msg,
254 int fwd); 254 int fwd);
255 255
@@ -262,7 +262,7 @@ GMCH_handle_data_ack (struct CadetChannel *ch,
262 * @param msg Channel crate message. 262 * @param msg Channel crate message.
263 */ 263 */
264struct CadetChannel * 264struct CadetChannel *
265GMCH_handle_create (struct CadetTunnel3 *t, 265GCCH_handle_create (struct CadetTunnel3 *t,
266 const struct GNUNET_CADET_ChannelCreate *msg); 266 const struct GNUNET_CADET_ChannelCreate *msg);
267 267
268/** 268/**
@@ -273,7 +273,7 @@ GMCH_handle_create (struct CadetTunnel3 *t,
273 * @param ch Channel. 273 * @param ch Channel.
274 */ 274 */
275void 275void
276GMCH_handle_nack (struct CadetChannel *ch); 276GCCH_handle_nack (struct CadetChannel *ch);
277 277
278/** 278/**
279 * Handler for channel ack messages. 279 * Handler for channel ack messages.
@@ -286,7 +286,7 @@ GMCH_handle_nack (struct CadetChannel *ch);
286 * #GNUNET_SYSERR if message on a one-ended channel (remote) 286 * #GNUNET_SYSERR if message on a one-ended channel (remote)
287 */ 287 */
288void 288void
289GMCH_handle_ack (struct CadetChannel *ch, 289GCCH_handle_ack (struct CadetChannel *ch,
290 const struct GNUNET_CADET_ChannelManage *msg, 290 const struct GNUNET_CADET_ChannelManage *msg,
291 int fwd); 291 int fwd);
292 292
@@ -301,7 +301,7 @@ GMCH_handle_ack (struct CadetChannel *ch,
301 * #GNUNET_SYSERR if message on a one-ended channel (remote) 301 * #GNUNET_SYSERR if message on a one-ended channel (remote)
302 */ 302 */
303void 303void
304GMCH_handle_destroy (struct CadetChannel *ch, 304GCCH_handle_destroy (struct CadetChannel *ch,
305 const struct GNUNET_CADET_ChannelManage *msg, 305 const struct GNUNET_CADET_ChannelManage *msg,
306 int fwd); 306 int fwd);
307 307
@@ -322,7 +322,7 @@ GMCH_handle_destroy (struct CadetChannel *ch,
322 * @param existing_copy This is a retransmission, don't save a copy. 322 * @param existing_copy This is a retransmission, don't save a copy.
323 */ 323 */
324void 324void
325GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, 325GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
326 struct CadetChannel *ch, int fwd, 326 struct CadetChannel *ch, int fwd,
327 void *existing_copy); 327 void *existing_copy);
328 328
@@ -334,7 +334,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
334 * @return Static string with the channel IDs. 334 * @return Static string with the channel IDs.
335 */ 335 */
336const char * 336const char *
337GMCH_2s (const struct CadetChannel *ch); 337GCCH_2s (const struct CadetChannel *ch);
338 338
339 339
340#if 0 /* keep Emacsens' auto-indent happy */ 340#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 9c07e006b..3552a942c 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -236,7 +236,7 @@ struct CadetConnectionQueue
236 /** 236 /**
237 * Continuation to call once sent. 237 * Continuation to call once sent.
238 */ 238 */
239 GMC_sent cont; 239 GCC_sent cont;
240 240
241 /** 241 /**
242 * Closure for @c cont. 242 * Closure for @c cont.
@@ -316,7 +316,7 @@ connection_debug (struct CadetConnection *c)
316 return; 316 return;
317 } 317 }
318 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s:%X\n", 318 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s:%X\n",
319 peer2s (c->t->peer), GMC_2s (c)); 319 peer2s (c->t->peer), GCC_2s (c));
320 LOG (GNUNET_ERROR_TYPE_DEBUG, " state: %u, pending msgs: %u\n", 320 LOG (GNUNET_ERROR_TYPE_DEBUG, " state: %u, pending msgs: %u\n",
321 c->state, c->pending_messages); 321 c->state, c->pending_messages);
322 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD FC\n"); 322 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD FC\n");
@@ -362,7 +362,7 @@ connection_reset_timeout (struct CadetConnection *c, int fwd);
362 * @return String representation. 362 * @return String representation.
363 */ 363 */
364static const char * 364static const char *
365GMC_state2s (enum CadetConnectionState s) 365GCC_state2s (enum CadetConnectionState s)
366{ 366{
367 switch (s) 367 switch (s)
368 { 368 {
@@ -409,7 +409,7 @@ fc_init (struct CadetFlowControl *fc)
409static struct CadetConnection * 409static struct CadetConnection *
410connection_get (const struct GNUNET_CADET_Hash *cid) 410connection_get (const struct GNUNET_CADET_Hash *cid)
411{ 411{
412 return GNUNET_CONTAINER_multihashmap_get (connections, GM_h2hc (cid)); 412 return GNUNET_CONTAINER_multihashmap_get (connections, GC_h2hc (cid));
413} 413}
414 414
415 415
@@ -419,7 +419,7 @@ connection_change_state (struct CadetConnection* c,
419{ 419{
420 LOG (GNUNET_ERROR_TYPE_DEBUG, 420 LOG (GNUNET_ERROR_TYPE_DEBUG,
421 "Connection %s state %s -> %s\n", 421 "Connection %s state %s -> %s\n",
422 GMC_2s (c), GMC_state2s (c->state), GMC_state2s (state)); 422 GCC_2s (c), GCC_state2s (c->state), GCC_state2s (state));
423 if (CADET_CONNECTION_DESTROYED == c->state) 423 if (CADET_CONNECTION_DESTROYED == c->state)
424 { 424 {
425 LOG (GNUNET_ERROR_TYPE_DEBUG, "state not changing anymore\n"); 425 LOG (GNUNET_ERROR_TYPE_DEBUG, "state not changing anymore\n");
@@ -476,10 +476,10 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
476 int delta; 476 int delta;
477 477
478 /* If origin, there is no connection to send ACKs. Wrong function! */ 478 /* If origin, there is no connection to send ACKs. Wrong function! */
479 if (GMC_is_origin (c, fwd)) 479 if (GCC_is_origin (c, fwd))
480 { 480 {
481 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection %s is origin in %s\n", 481 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection %s is origin in %s\n",
482 GMC_2s (c), GM_f2s (fwd)); 482 GCC_2s (c), GC_f2s (fwd));
483 GNUNET_break (0); 483 GNUNET_break (0);
484 return; 484 return;
485 } 485 }
@@ -488,7 +488,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
488 prev_fc = fwd ? &c->bck_fc : &c->fwd_fc; 488 prev_fc = fwd ? &c->bck_fc : &c->fwd_fc;
489 489
490 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection send %s ack on %s\n", 490 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection send %s ack on %s\n",
491 GM_f2s (fwd), GMC_2s (c)); 491 GC_f2s (fwd), GCC_2s (c));
492 492
493 /* Check if we need to transmit the ACK. */ 493 /* Check if we need to transmit the ACK. */
494 delta = prev_fc->last_ack_sent - prev_fc->last_pid_recv; 494 delta = prev_fc->last_ack_sent - prev_fc->last_pid_recv;
@@ -517,11 +517,11 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
517 /* Check if message is already in queue */ 517 /* Check if message is already in queue */
518 if (NULL != prev_fc->ack_msg) 518 if (NULL != prev_fc->ack_msg)
519 { 519 {
520 if (GM_is_pid_bigger (ack, prev_fc->last_ack_sent)) 520 if (GC_is_pid_bigger (ack, prev_fc->last_ack_sent))
521 { 521 {
522 LOG (GNUNET_ERROR_TYPE_DEBUG, " canceling old ACK\n"); 522 LOG (GNUNET_ERROR_TYPE_DEBUG, " canceling old ACK\n");
523 GMC_cancel (prev_fc->ack_msg); 523 GCC_cancel (prev_fc->ack_msg);
524 /* GMC_cancel triggers ack_sent(), which clears fc->ack_msg */ 524 /* GCC_cancel triggers ack_sent(), which clears fc->ack_msg */
525 } 525 }
526 else 526 else
527 { 527 {
@@ -538,7 +538,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
538 msg.ack = htonl (ack); 538 msg.ack = htonl (ack);
539 msg.cid = c->id; 539 msg.cid = c->id;
540 540
541 prev_fc->ack_msg = GMC_send_prebuilt_message (&msg.header, 541 prev_fc->ack_msg = GCC_send_prebuilt_message (&msg.header,
542 GNUNET_MESSAGE_TYPE_CADET_ACK, 542 GNUNET_MESSAGE_TYPE_CADET_ACK,
543 ack, c, !fwd, GNUNET_YES, 543 ack, c, !fwd, GNUNET_YES,
544 &ack_sent, prev_fc); 544 &ack_sent, prev_fc);
@@ -575,7 +575,7 @@ conn_message_sent (void *cls,
575 575
576 fc = fwd ? &c->fwd_fc : &c->bck_fc; 576 fc = fwd ? &c->fwd_fc : &c->bck_fc;
577 LOG (GNUNET_ERROR_TYPE_DEBUG, " %ssent %s %s\n", 577 LOG (GNUNET_ERROR_TYPE_DEBUG, " %ssent %s %s\n",
578 sent ? "" : "not ", GM_f2s (fwd), GM_m2s (type)); 578 sent ? "" : "not ", GC_f2s (fwd), GC_m2s (type));
579 if (NULL != q) 579 if (NULL != q)
580 { 580 {
581 forced = q->forced; 581 forced = q->forced;
@@ -600,7 +600,7 @@ conn_message_sent (void *cls,
600 GNUNET_break (type == GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN || 600 GNUNET_break (type == GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN ||
601 type == GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY); 601 type == GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY);
602 LOG (GNUNET_ERROR_TYPE_ERROR, "Message %s sent on NULL connection!\n", 602 LOG (GNUNET_ERROR_TYPE_ERROR, "Message %s sent on NULL connection!\n",
603 GM_m2s (type)); 603 GC_m2s (type));
604 return; 604 return;
605 } 605 }
606 LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P- %p %u\n", c, c->pending_messages); 606 LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P- %p %u\n", c, c->pending_messages);
@@ -608,7 +608,7 @@ conn_message_sent (void *cls,
608 if (GNUNET_YES == c->destroy && 0 == c->pending_messages) 608 if (GNUNET_YES == c->destroy && 0 == c->pending_messages)
609 { 609 {
610 LOG (GNUNET_ERROR_TYPE_DEBUG, "! destroying connection!\n"); 610 LOG (GNUNET_ERROR_TYPE_DEBUG, "! destroying connection!\n");
611 GMC_destroy (c); 611 GCC_destroy (c);
612 return; 612 return;
613 } 613 }
614 /* Send ACK if needed, after accounting for sent ID in fc->queue_n */ 614 /* Send ACK if needed, after accounting for sent ID in fc->queue_n */
@@ -627,7 +627,7 @@ conn_message_sent (void *cls,
627 { 627 {
628 GNUNET_assert (NULL != q); 628 GNUNET_assert (NULL != q);
629 fc->last_pid_sent = pid; // FIXME 629 fc->last_pid_sent = pid; // FIXME
630 GMC_send_ack (c, fwd, GNUNET_NO); 630 GCC_send_ack (c, fwd, GNUNET_NO);
631 connection_reset_timeout (c, fwd); 631 connection_reset_timeout (c, fwd);
632 } 632 }
633 633
@@ -703,7 +703,7 @@ get_prev_hop (const struct CadetConnection *c)
703 GNUNET_PEER_Id id; 703 GNUNET_PEER_Id id;
704 704
705 LOG (GNUNET_ERROR_TYPE_DEBUG, " get prev hop %s [%u/%u]\n", 705 LOG (GNUNET_ERROR_TYPE_DEBUG, " get prev hop %s [%u/%u]\n",
706 GMC_2s (c), c->own_pos, c->path->length); 706 GCC_2s (c), c->own_pos, c->path->length);
707 if (0 == c->own_pos || c->path->length < 2) 707 if (0 == c->own_pos || c->path->length < 2)
708 id = c->path->peers[0]; 708 id = c->path->peers[0];
709 else 709 else
@@ -712,7 +712,7 @@ get_prev_hop (const struct CadetConnection *c)
712 LOG (GNUNET_ERROR_TYPE_DEBUG, " ID: %s (%u)\n", 712 LOG (GNUNET_ERROR_TYPE_DEBUG, " ID: %s (%u)\n",
713 GNUNET_i2s (GNUNET_PEER_resolve2 (id)), id); 713 GNUNET_i2s (GNUNET_PEER_resolve2 (id)), id);
714 714
715 return GMP_get_short (id); 715 return GCP_get_short (id);
716} 716}
717 717
718 718
@@ -729,7 +729,7 @@ get_next_hop (const struct CadetConnection *c)
729 GNUNET_PEER_Id id; 729 GNUNET_PEER_Id id;
730 730
731 LOG (GNUNET_ERROR_TYPE_DEBUG, " get next hop %s [%u/%u]\n", 731 LOG (GNUNET_ERROR_TYPE_DEBUG, " get next hop %s [%u/%u]\n",
732 GMC_2s (c), c->own_pos, c->path->length); 732 GCC_2s (c), c->own_pos, c->path->length);
733 if ((c->path->length - 1) == c->own_pos || c->path->length < 2) 733 if ((c->path->length - 1) == c->own_pos || c->path->length < 2)
734 id = c->path->peers[c->path->length - 1]; 734 id = c->path->peers[c->path->length - 1];
735 else 735 else
@@ -738,7 +738,7 @@ get_next_hop (const struct CadetConnection *c)
738 LOG (GNUNET_ERROR_TYPE_DEBUG, " ID: %s (%u)\n", 738 LOG (GNUNET_ERROR_TYPE_DEBUG, " ID: %s (%u)\n",
739 GNUNET_i2s (GNUNET_PEER_resolve2 (id)), id); 739 GNUNET_i2s (GNUNET_PEER_resolve2 (id)), id);
740 740
741 return GMP_get_short (id); 741 return GCP_get_short (id);
742} 742}
743 743
744 744
@@ -777,10 +777,10 @@ is_fwd (const struct CadetConnection *c,
777 GNUNET_PEER_Id id; 777 GNUNET_PEER_Id id;
778 778
779 id = GNUNET_PEER_search (sender); 779 id = GNUNET_PEER_search (sender);
780 if (GMP_get_short_id (get_prev_hop (c)) == id) 780 if (GCP_get_short_id (get_prev_hop (c)) == id)
781 return GNUNET_YES; 781 return GNUNET_YES;
782 782
783 if (GMP_get_short_id (get_next_hop (c)) == id) 783 if (GCP_get_short_id (get_next_hop (c)) == id)
784 return GNUNET_NO; 784 return GNUNET_NO;
785 785
786 GNUNET_break (0); 786 GNUNET_break (0);
@@ -803,15 +803,15 @@ send_connection_ack (struct CadetConnection *connection, int fwd)
803 803
804 t = connection->t; 804 t = connection->t;
805 LOG (GNUNET_ERROR_TYPE_INFO, "===> {%14s ACK} on connection %s\n", 805 LOG (GNUNET_ERROR_TYPE_INFO, "===> {%14s ACK} on connection %s\n",
806 GM_f2s (!fwd), GMC_2s (connection)); 806 GC_f2s (!fwd), GCC_2s (connection));
807 GMP_queue_add (get_hop (connection, fwd), NULL, 807 GCP_queue_add (get_hop (connection, fwd), NULL,
808 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK, 808 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK,
809 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK, 0, 809 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK, 0,
810 sizeof (struct GNUNET_CADET_ConnectionACK), 810 sizeof (struct GNUNET_CADET_ConnectionACK),
811 connection, fwd, &conn_message_sent, NULL); 811 connection, fwd, &conn_message_sent, NULL);
812 connection->pending_messages++; 812 connection->pending_messages++;
813 if (CADET_TUNNEL3_NEW == GMT_get_cstate (t)) 813 if (CADET_TUNNEL3_NEW == GCT_get_cstate (t))
814 GMT_change_cstate (t, CADET_TUNNEL3_WAITING); 814 GCT_change_cstate (t, CADET_TUNNEL3_WAITING);
815 if (CADET_CONNECTION_READY != connection->state) 815 if (CADET_CONNECTION_READY != connection->state)
816 connection_change_state (connection, CADET_CONNECTION_SENT); 816 connection_change_state (connection, CADET_CONNECTION_SENT);
817} 817}
@@ -838,7 +838,7 @@ send_broken (struct CadetConnection *c,
838 msg.cid = c->id; 838 msg.cid = c->id;
839 msg.peer1 = *id1; 839 msg.peer1 = *id1;
840 msg.peer2 = *id2; 840 msg.peer2 = *id2;
841 GMC_send_prebuilt_message (&msg.header, 841 GCC_send_prebuilt_message (&msg.header,
842 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 0, 842 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 0,
843 c, fwd, GNUNET_YES, NULL, NULL); 843 c, fwd, GNUNET_YES, NULL, NULL);
844} 844}
@@ -863,7 +863,7 @@ send_broken_unknown (const struct GNUNET_CADET_Hash *connection_id,
863 struct CadetPeer *neighbor; 863 struct CadetPeer *neighbor;
864 864
865 LOG (GNUNET_ERROR_TYPE_INFO, "===> BROKEN on unknown connection %s\n", 865 LOG (GNUNET_ERROR_TYPE_INFO, "===> BROKEN on unknown connection %s\n",
866 GNUNET_h2s (GM_h2hc (connection_id))); 866 GNUNET_h2s (GC_h2hc (connection_id)));
867 867
868 msg = GNUNET_new (struct GNUNET_CADET_ConnectionBroken); 868 msg = GNUNET_new (struct GNUNET_CADET_ConnectionBroken);
869 msg->header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken)); 869 msg->header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken));
@@ -874,8 +874,8 @@ send_broken_unknown (const struct GNUNET_CADET_Hash *connection_id,
874 msg->peer2 = *id2; 874 msg->peer2 = *id2;
875 else 875 else
876 memset (&msg->peer2, 0, sizeof (msg->peer2)); 876 memset (&msg->peer2, 0, sizeof (msg->peer2));
877 neighbor = GMP_get (peer_id); 877 neighbor = GCP_get (peer_id);
878 GMP_queue_add (neighbor, msg, 878 GCP_queue_add (neighbor, msg,
879 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 879 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN,
880 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 2, 880 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 2,
881 sizeof (struct GNUNET_CADET_ConnectionBroken), 881 sizeof (struct GNUNET_CADET_ConnectionBroken),
@@ -898,7 +898,7 @@ send_connection_keepalive (struct CadetConnection *c, int fwd)
898 898
899 LOG (GNUNET_ERROR_TYPE_INFO, 899 LOG (GNUNET_ERROR_TYPE_INFO,
900 "keepalive %s for connection %s\n", 900 "keepalive %s for connection %s\n",
901 GM_f2s (fwd), GMC_2s (c)); 901 GC_f2s (fwd), GCC_2s (c));
902 902
903 fc = fwd ? &c->fwd_fc : &c->bck_fc; 903 fc = fwd ? &c->fwd_fc : &c->bck_fc;
904 if (0 < fc->queue_n) 904 if (0 < fc->queue_n)
@@ -913,7 +913,7 @@ send_connection_keepalive (struct CadetConnection *c, int fwd)
913 msg.type = htons (GNUNET_MESSAGE_TYPE_CADET_KEEPALIVE); 913 msg.type = htons (GNUNET_MESSAGE_TYPE_CADET_KEEPALIVE);
914 914
915 GNUNET_assert (NULL == 915 GNUNET_assert (NULL ==
916 GMT_send_prebuilt_message (&msg, c->t, c, 916 GCT_send_prebuilt_message (&msg, c->t, c,
917 GNUNET_NO, NULL, NULL)); 917 GNUNET_NO, NULL, NULL));
918} 918}
919 919
@@ -929,7 +929,7 @@ connection_recreate (struct CadetConnection *c, int fwd)
929{ 929{
930 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending connection recreate\n"); 930 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending connection recreate\n");
931 if (fwd) 931 if (fwd)
932 GMC_send_create (c); 932 GCC_send_create (c);
933 else 933 else
934 send_connection_ack (c, GNUNET_NO); 934 send_connection_ack (c, GNUNET_NO);
935} 935}
@@ -949,7 +949,7 @@ connection_maintain (struct CadetConnection *c, int fwd)
949 if (GNUNET_NO != c->destroy) 949 if (GNUNET_NO != c->destroy)
950 return; 950 return;
951 951
952 if (CADET_TUNNEL3_SEARCHING == GMT_get_cstate (c->t)) 952 if (CADET_TUNNEL3_SEARCHING == GCT_get_cstate (c->t))
953 { 953 {
954 /* TODO DHT GET with RO_BART */ 954 /* TODO DHT GET with RO_BART */
955 return; 955 return;
@@ -984,7 +984,7 @@ static void
984connection_keepalive (struct CadetConnection *c, int fwd, int shutdown) 984connection_keepalive (struct CadetConnection *c, int fwd, int shutdown)
985{ 985{
986 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s keepalive for %s\n", 986 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s keepalive for %s\n",
987 GM_f2s (fwd), GMC_2s (c)); 987 GC_f2s (fwd), GCC_2s (c));
988 988
989 if (fwd) 989 if (fwd)
990 c->fwd_maintenance_task = GNUNET_SCHEDULER_NO_TASK; 990 c->fwd_maintenance_task = GNUNET_SCHEDULER_NO_TASK;
@@ -1048,7 +1048,7 @@ schedule_next_keepalive (struct CadetConnection *c, int fwd)
1048 GNUNET_SCHEDULER_TaskIdentifier *task_id; 1048 GNUNET_SCHEDULER_TaskIdentifier *task_id;
1049 GNUNET_SCHEDULER_Task keepalive_task; 1049 GNUNET_SCHEDULER_Task keepalive_task;
1050 1050
1051 if (GNUNET_NO == GMC_is_origin (c, fwd)) 1051 if (GNUNET_NO == GCC_is_origin (c, fwd))
1052 return; 1052 return;
1053 1053
1054 /* Calculate delay to use, depending on the state of the connection */ 1054 /* Calculate delay to use, depending on the state of the connection */
@@ -1110,16 +1110,16 @@ connection_unlock_queue (struct CadetConnection *c, int fwd)
1110 1110
1111 LOG (GNUNET_ERROR_TYPE_DEBUG, 1111 LOG (GNUNET_ERROR_TYPE_DEBUG,
1112 "connection_unlock_queue %s on %s\n", 1112 "connection_unlock_queue %s on %s\n",
1113 GM_f2s (fwd), GMC_2s (c)); 1113 GC_f2s (fwd), GCC_2s (c));
1114 1114
1115 if (GMC_is_terminal (c, fwd)) 1115 if (GCC_is_terminal (c, fwd))
1116 { 1116 {
1117 LOG (GNUNET_ERROR_TYPE_DEBUG, " is terminal!\n"); 1117 LOG (GNUNET_ERROR_TYPE_DEBUG, " is terminal!\n");
1118 return; 1118 return;
1119 } 1119 }
1120 1120
1121 peer = get_hop (c, fwd); 1121 peer = get_hop (c, fwd);
1122 GMP_queue_unlock (peer, c); 1122 GCP_queue_unlock (peer, c);
1123} 1123}
1124 1124
1125 1125
@@ -1140,7 +1140,7 @@ connection_cancel_queues (struct CadetConnection *c, int fwd)
1140 1140
1141 LOG (GNUNET_ERROR_TYPE_DEBUG, 1141 LOG (GNUNET_ERROR_TYPE_DEBUG,
1142 " *** Cancel %s queues for connection %s\n", 1142 " *** Cancel %s queues for connection %s\n",
1143 GM_f2s (fwd), GMC_2s (c)); 1143 GC_f2s (fwd), GCC_2s (c));
1144 if (NULL == c) 1144 if (NULL == c)
1145 { 1145 {
1146 GNUNET_break (0); 1146 GNUNET_break (0);
@@ -1155,7 +1155,7 @@ connection_cancel_queues (struct CadetConnection *c, int fwd)
1155 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** Cancel POLL in ccq for fc %p\n", fc); 1155 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** Cancel POLL in ccq for fc %p\n", fc);
1156 } 1156 }
1157 peer = get_hop (c, fwd); 1157 peer = get_hop (c, fwd);
1158 GMP_queue_cancel (peer, c); 1158 GCP_queue_cancel (peer, c);
1159} 1159}
1160 1160
1161 1161
@@ -1225,14 +1225,14 @@ connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1225 1225
1226 c = fc->c; 1226 c = fc->c;
1227 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** Polling connection %s %s\n", 1227 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** Polling connection %s %s\n",
1228 GMC_2s (c), fc == &c->fwd_fc ? "FWD" : "BCK"); 1228 GCC_2s (c), fc == &c->fwd_fc ? "FWD" : "BCK");
1229 1229
1230 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_POLL); 1230 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_POLL);
1231 msg.header.size = htons (sizeof (msg)); 1231 msg.header.size = htons (sizeof (msg));
1232 msg.pid = htonl (fc->last_pid_sent); 1232 msg.pid = htonl (fc->last_pid_sent);
1233 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** last pid sent: %u!\n", fc->last_pid_sent); 1233 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** last pid sent: %u!\n", fc->last_pid_sent);
1234 fc->poll_msg = 1234 fc->poll_msg =
1235 GMC_send_prebuilt_message (&msg.header, 1235 GCC_send_prebuilt_message (&msg.header,
1236 GNUNET_MESSAGE_TYPE_CADET_POLL, 1236 GNUNET_MESSAGE_TYPE_CADET_POLL,
1237 fc->last_pid_sent, 1237 fc->last_pid_sent,
1238 c, fc == &c->fwd_fc, GNUNET_YES, 1238 c, fc == &c->fwd_fc, GNUNET_YES,
@@ -1258,14 +1258,14 @@ connection_fwd_timeout (void *cls,
1258 return; 1258 return;
1259 1259
1260 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s FWD timed out. Destroying.\n", 1260 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s FWD timed out. Destroying.\n",
1261 GMC_2s (c)); 1261 GCC_2s (c));
1262 if (GMC_is_origin (c, GNUNET_YES)) /* If local, leave. */ 1262 if (GCC_is_origin (c, GNUNET_YES)) /* If local, leave. */
1263 { 1263 {
1264 GNUNET_break (0); 1264 GNUNET_break (0);
1265 return; 1265 return;
1266 } 1266 }
1267 1267
1268 GMC_destroy (c); 1268 GCC_destroy (c);
1269} 1269}
1270 1270
1271 1271
@@ -1287,15 +1287,15 @@ connection_bck_timeout (void *cls,
1287 return; 1287 return;
1288 1288
1289 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s BCK timed out. Destroying.\n", 1289 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s BCK timed out. Destroying.\n",
1290 GMC_2s (c)); 1290 GCC_2s (c));
1291 1291
1292 if (GMC_is_origin (c, GNUNET_NO)) /* If local, leave. */ 1292 if (GCC_is_origin (c, GNUNET_NO)) /* If local, leave. */
1293 { 1293 {
1294 GNUNET_break (0); 1294 GNUNET_break (0);
1295 return; 1295 return;
1296 } 1296 }
1297 1297
1298 GMC_destroy (c); 1298 GCC_destroy (c);
1299} 1299}
1300 1300
1301 1301
@@ -1316,9 +1316,9 @@ connection_bck_timeout (void *cls,
1316static void 1316static void
1317connection_reset_timeout (struct CadetConnection *c, int fwd) 1317connection_reset_timeout (struct CadetConnection *c, int fwd)
1318{ 1318{
1319 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s reset timeout\n", GM_f2s (fwd)); 1319 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s reset timeout\n", GC_f2s (fwd));
1320 1320
1321 if (GMC_is_origin (c, fwd)) /* Startpoint */ 1321 if (GCC_is_origin (c, fwd)) /* Startpoint */
1322 { 1322 {
1323 schedule_next_keepalive (c, fwd); 1323 schedule_next_keepalive (c, fwd);
1324 } 1324 }
@@ -1357,33 +1357,33 @@ register_neighbors (struct CadetConnection *c)
1357 prev_peer = get_prev_hop (c); 1357 prev_peer = get_prev_hop (c);
1358 1358
1359 LOG (GNUNET_ERROR_TYPE_DEBUG, "register neighbors for connection %s\n", 1359 LOG (GNUNET_ERROR_TYPE_DEBUG, "register neighbors for connection %s\n",
1360 GMC_2s (c)); 1360 GCC_2s (c));
1361 path_debug (c->path); 1361 path_debug (c->path);
1362 LOG (GNUNET_ERROR_TYPE_DEBUG, "own pos %u\n", c->own_pos); 1362 LOG (GNUNET_ERROR_TYPE_DEBUG, "own pos %u\n", c->own_pos);
1363 LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to next peer %p\n", 1363 LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to next peer %p\n",
1364 GMC_2s (c), next_peer); 1364 GCC_2s (c), next_peer);
1365 LOG (GNUNET_ERROR_TYPE_DEBUG, "next peer %p %s\n", next_peer, GMP_2s (next_peer)); 1365 LOG (GNUNET_ERROR_TYPE_DEBUG, "next peer %p %s\n", next_peer, GCP_2s (next_peer));
1366 LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to prev peer %p\n", 1366 LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to prev peer %p\n",
1367 GMC_2s (c), prev_peer); 1367 GCC_2s (c), prev_peer);
1368 LOG (GNUNET_ERROR_TYPE_DEBUG, "prev peer %p %s\n", prev_peer, GMP_2s (prev_peer)); 1368 LOG (GNUNET_ERROR_TYPE_DEBUG, "prev peer %p %s\n", prev_peer, GCP_2s (prev_peer));
1369 1369
1370 if (GNUNET_NO == GMP_is_neighbor (next_peer) 1370 if (GNUNET_NO == GCP_is_neighbor (next_peer)
1371 || GNUNET_NO == GMP_is_neighbor (prev_peer)) 1371 || GNUNET_NO == GCP_is_neighbor (prev_peer))
1372 { 1372 {
1373 if (GMC_is_origin (c, GNUNET_YES)) 1373 if (GCC_is_origin (c, GNUNET_YES))
1374 GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO); 1374 GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO);
1375 GNUNET_STATISTICS_update (stats, "# bad paths", 1, GNUNET_NO); 1375 GNUNET_STATISTICS_update (stats, "# bad paths", 1, GNUNET_NO);
1376 1376
1377 LOG (GNUNET_ERROR_TYPE_DEBUG, " register neighbors failed\n"); 1377 LOG (GNUNET_ERROR_TYPE_DEBUG, " register neighbors failed\n");
1378 LOG (GNUNET_ERROR_TYPE_DEBUG, " prev: %s, neighbor?: %d\n", 1378 LOG (GNUNET_ERROR_TYPE_DEBUG, " prev: %s, neighbor?: %d\n",
1379 GMP_2s (prev_peer), GMP_is_neighbor (prev_peer)); 1379 GCP_2s (prev_peer), GCP_is_neighbor (prev_peer));
1380 LOG (GNUNET_ERROR_TYPE_DEBUG, " next: %s, neighbor?: %d\n", 1380 LOG (GNUNET_ERROR_TYPE_DEBUG, " next: %s, neighbor?: %d\n",
1381 GMP_2s (next_peer), GMP_is_neighbor (next_peer)); 1381 GCP_2s (next_peer), GCP_is_neighbor (next_peer));
1382 return GNUNET_SYSERR; 1382 return GNUNET_SYSERR;
1383 } 1383 }
1384 1384
1385 GMP_add_connection (next_peer, c); 1385 GCP_add_connection (next_peer, c);
1386 GMP_add_connection (prev_peer, c); 1386 GCP_add_connection (prev_peer, c);
1387 1387
1388 return GNUNET_OK; 1388 return GNUNET_OK;
1389} 1389}
@@ -1400,21 +1400,21 @@ unregister_neighbors (struct CadetConnection *c)
1400 struct CadetPeer *peer; 1400 struct CadetPeer *peer;
1401 1401
1402 peer = get_next_hop (c); 1402 peer = get_next_hop (c);
1403 if (GNUNET_OK != GMP_remove_connection (peer, c)) 1403 if (GNUNET_OK != GCP_remove_connection (peer, c))
1404 { 1404 {
1405 GNUNET_assert (CADET_CONNECTION_NEW == c->state 1405 GNUNET_assert (CADET_CONNECTION_NEW == c->state
1406 || CADET_CONNECTION_DESTROYED == c->state); 1406 || CADET_CONNECTION_DESTROYED == c->state);
1407 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state); 1407 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state);
1408 if (NULL != c->t) GMT_debug (c->t); 1408 if (NULL != c->t) GCT_debug (c->t);
1409 } 1409 }
1410 1410
1411 peer = get_prev_hop (c); 1411 peer = get_prev_hop (c);
1412 if (GNUNET_OK != GMP_remove_connection (peer, c)) 1412 if (GNUNET_OK != GCP_remove_connection (peer, c))
1413 { 1413 {
1414 GNUNET_assert (CADET_CONNECTION_NEW == c->state 1414 GNUNET_assert (CADET_CONNECTION_NEW == c->state
1415 || CADET_CONNECTION_DESTROYED == c->state); 1415 || CADET_CONNECTION_DESTROYED == c->state);
1416 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state); 1416 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state);
1417 if (NULL != c->t) GMT_debug (c->t); 1417 if (NULL != c->t) GCT_debug (c->t);
1418 } 1418 }
1419} 1419}
1420 1420
@@ -1431,9 +1431,9 @@ unregister_neighbors (struct CadetConnection *c)
1431static void 1431static void
1432add_to_peer (struct CadetConnection *c, struct CadetPeer *peer) 1432add_to_peer (struct CadetConnection *c, struct CadetPeer *peer)
1433{ 1433{
1434 GMP_add_tunnel (peer); 1434 GCP_add_tunnel (peer);
1435 c->t = GMP_get_tunnel (peer); 1435 c->t = GCP_get_tunnel (peer);
1436 GMT_add_connection (c->t, c); 1436 GCT_add_connection (c->t, c);
1437} 1437}
1438 1438
1439 1439
@@ -1511,7 +1511,7 @@ log_message (const struct GNUNET_MessageHeader *message,
1511 const struct GNUNET_CADET_Hash *hash) 1511 const struct GNUNET_CADET_Hash *hash)
1512{ 1512{
1513 LOG (GNUNET_ERROR_TYPE_INFO, "<-- %s on connection %s from %s\n", 1513 LOG (GNUNET_ERROR_TYPE_INFO, "<-- %s on connection %s from %s\n",
1514 GM_m2s (ntohs (message->type)), GNUNET_h2s (GM_h2hc (hash)), 1514 GC_m2s (ntohs (message->type)), GNUNET_h2s (GC_h2hc (hash)),
1515 GNUNET_i2s (peer)); 1515 GNUNET_i2s (peer));
1516} 1516}
1517 1517
@@ -1530,7 +1530,7 @@ log_message (const struct GNUNET_MessageHeader *message,
1530 * GNUNET_SYSERR to close it (signal serious error) 1530 * GNUNET_SYSERR to close it (signal serious error)
1531 */ 1531 */
1532int 1532int
1533GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, 1533GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1534 const struct GNUNET_MessageHeader *message) 1534 const struct GNUNET_MessageHeader *message)
1535{ 1535{
1536 struct GNUNET_CADET_ConnectionCreate *msg; 1536 struct GNUNET_CADET_ConnectionCreate *msg;
@@ -1589,7 +1589,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1589 } 1589 }
1590 LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos); 1590 LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos);
1591 LOG (GNUNET_ERROR_TYPE_DEBUG, " Creating connection\n"); 1591 LOG (GNUNET_ERROR_TYPE_DEBUG, " Creating connection\n");
1592 c = GMC_new (cid, NULL, path_duplicate (path), own_pos); 1592 c = GCC_new (cid, NULL, path_duplicate (path), own_pos);
1593 if (NULL == c) 1593 if (NULL == c)
1594 { 1594 {
1595 if (path->length - 1 == own_pos) 1595 if (path->length - 1 == own_pos)
@@ -1604,7 +1604,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1604 path_destroy (path); 1604 path_destroy (path);
1605 return GNUNET_OK; 1605 return GNUNET_OK;
1606 } 1606 }
1607 GMP_add_path_to_all (path, GNUNET_NO); 1607 GCP_add_path_to_all (path, GNUNET_NO);
1608 connection_reset_timeout (c, GNUNET_YES); 1608 connection_reset_timeout (c, GNUNET_YES);
1609 } 1609 }
1610 else 1610 else
@@ -1615,18 +1615,18 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1615 connection_change_state (c, CADET_CONNECTION_SENT); 1615 connection_change_state (c, CADET_CONNECTION_SENT);
1616 1616
1617 /* Remember peers */ 1617 /* Remember peers */
1618 dest_peer = GMP_get (&id[size - 1]); 1618 dest_peer = GCP_get (&id[size - 1]);
1619 orig_peer = GMP_get (&id[0]); 1619 orig_peer = GCP_get (&id[0]);
1620 1620
1621 /* Is it a connection to us? */ 1621 /* Is it a connection to us? */
1622 if (c->own_pos == path->length - 1) 1622 if (c->own_pos == path->length - 1)
1623 { 1623 {
1624 LOG (GNUNET_ERROR_TYPE_DEBUG, " It's for us!\n"); 1624 LOG (GNUNET_ERROR_TYPE_DEBUG, " It's for us!\n");
1625 GMP_add_path_to_origin (orig_peer, path_duplicate (path), GNUNET_YES); 1625 GCP_add_path_to_origin (orig_peer, path_duplicate (path), GNUNET_YES);
1626 1626
1627 add_to_peer (c, orig_peer); 1627 add_to_peer (c, orig_peer);
1628 if (CADET_TUNNEL3_NEW == GMT_get_cstate (c->t)) 1628 if (CADET_TUNNEL3_NEW == GCT_get_cstate (c->t))
1629 GMT_change_cstate (c->t, CADET_TUNNEL3_WAITING); 1629 GCT_change_cstate (c->t, CADET_TUNNEL3_WAITING);
1630 1630
1631 send_connection_ack (c, GNUNET_NO); 1631 send_connection_ack (c, GNUNET_NO);
1632 if (CADET_CONNECTION_SENT == c->state) 1632 if (CADET_CONNECTION_SENT == c->state)
@@ -1636,9 +1636,9 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1636 { 1636 {
1637 /* It's for somebody else! Retransmit. */ 1637 /* It's for somebody else! Retransmit. */
1638 LOG (GNUNET_ERROR_TYPE_DEBUG, " Retransmitting.\n"); 1638 LOG (GNUNET_ERROR_TYPE_DEBUG, " Retransmitting.\n");
1639 GMP_add_path (dest_peer, path_duplicate (path), GNUNET_NO); 1639 GCP_add_path (dest_peer, path_duplicate (path), GNUNET_NO);
1640 GMP_add_path_to_origin (orig_peer, path_duplicate (path), GNUNET_NO); 1640 GCP_add_path_to_origin (orig_peer, path_duplicate (path), GNUNET_NO);
1641 GMC_send_prebuilt_message (message, 1641 GCC_send_prebuilt_message (message,
1642 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, 0, 1642 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, 0,
1643 c, GNUNET_YES, GNUNET_YES, 1643 c, GNUNET_YES, GNUNET_YES,
1644 NULL, NULL); 1644 NULL, NULL);
@@ -1659,7 +1659,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1659 * GNUNET_SYSERR to close it (signal serious error) 1659 * GNUNET_SYSERR to close it (signal serious error)
1660 */ 1660 */
1661int 1661int
1662GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer, 1662GCC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
1663 const struct GNUNET_MessageHeader *message) 1663 const struct GNUNET_MessageHeader *message)
1664{ 1664{
1665 struct GNUNET_CADET_ConnectionACK *msg; 1665 struct GNUNET_CADET_ConnectionACK *msg;
@@ -1689,7 +1689,7 @@ GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
1689 1689
1690 oldstate = c->state; 1690 oldstate = c->state;
1691 LOG (GNUNET_ERROR_TYPE_DEBUG, " via peer %s\n", GNUNET_i2s (peer)); 1691 LOG (GNUNET_ERROR_TYPE_DEBUG, " via peer %s\n", GNUNET_i2s (peer));
1692 pi = GMP_get (peer); 1692 pi = GCP_get (peer);
1693 if (get_next_hop (c) == pi) 1693 if (get_next_hop (c) == pi)
1694 { 1694 {
1695 LOG (GNUNET_ERROR_TYPE_DEBUG, " SYNACK\n"); 1695 LOG (GNUNET_ERROR_TYPE_DEBUG, " SYNACK\n");
@@ -1715,7 +1715,7 @@ GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
1715 p = c->path; 1715 p = c->path;
1716 if (NULL != p) 1716 if (NULL != p)
1717 { 1717 {
1718 GMP_add_path_to_all (p, GNUNET_YES); 1718 GCP_add_path_to_all (p, GNUNET_YES);
1719 } 1719 }
1720 else 1720 else
1721 { 1721 {
@@ -1723,7 +1723,7 @@ GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
1723 } 1723 }
1724 1724
1725 /* Message for us as creator? */ 1725 /* Message for us as creator? */
1726 if (GMC_is_origin (c, GNUNET_YES)) 1726 if (GCC_is_origin (c, GNUNET_YES))
1727 { 1727 {
1728 if (GNUNET_NO != fwd) 1728 if (GNUNET_NO != fwd)
1729 { 1729 {
@@ -1741,14 +1741,14 @@ GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
1741 send_connection_ack (c, GNUNET_YES); 1741 send_connection_ack (c, GNUNET_YES);
1742 1742
1743 /* Change tunnel state, trigger KX */ 1743 /* Change tunnel state, trigger KX */
1744 if (CADET_TUNNEL3_WAITING == GMT_get_cstate (c->t)) 1744 if (CADET_TUNNEL3_WAITING == GCT_get_cstate (c->t))
1745 GMT_change_cstate (c->t, CADET_TUNNEL3_READY); 1745 GCT_change_cstate (c->t, CADET_TUNNEL3_READY);
1746 1746
1747 return GNUNET_OK; 1747 return GNUNET_OK;
1748 } 1748 }
1749 1749
1750 /* Message for us as destination? */ 1750 /* Message for us as destination? */
1751 if (GMC_is_terminal (c, GNUNET_YES)) 1751 if (GCC_is_terminal (c, GNUNET_YES))
1752 { 1752 {
1753 if (GNUNET_YES != fwd) 1753 if (GNUNET_YES != fwd)
1754 { 1754 {
@@ -1762,14 +1762,14 @@ GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
1762 connection_reset_timeout (c, GNUNET_NO); 1762 connection_reset_timeout (c, GNUNET_NO);
1763 1763
1764 /* Change tunnel state */ 1764 /* Change tunnel state */
1765 if (CADET_TUNNEL3_WAITING == GMT_get_cstate (c->t)) 1765 if (CADET_TUNNEL3_WAITING == GCT_get_cstate (c->t))
1766 GMT_change_cstate (c->t, CADET_TUNNEL3_READY); 1766 GCT_change_cstate (c->t, CADET_TUNNEL3_READY);
1767 1767
1768 return GNUNET_OK; 1768 return GNUNET_OK;
1769 } 1769 }
1770 1770
1771 LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n"); 1771 LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n");
1772 GMC_send_prebuilt_message (message, 1772 GCC_send_prebuilt_message (message,
1773 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK, 0, 1773 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK, 0,
1774 c, fwd, GNUNET_YES, NULL, NULL); 1774 c, fwd, GNUNET_YES, NULL, NULL);
1775 return GNUNET_OK; 1775 return GNUNET_OK;
@@ -1787,7 +1787,7 @@ GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
1787 * GNUNET_SYSERR to close it (signal serious error) 1787 * GNUNET_SYSERR to close it (signal serious error)
1788 */ 1788 */
1789int 1789int
1790GMC_handle_broken (void* cls, 1790GCC_handle_broken (void* cls,
1791 const struct GNUNET_PeerIdentity* id, 1791 const struct GNUNET_PeerIdentity* id,
1792 const struct GNUNET_MessageHeader* message) 1792 const struct GNUNET_MessageHeader* message)
1793{ 1793{
@@ -1809,29 +1809,29 @@ GMC_handle_broken (void* cls,
1809 } 1809 }
1810 1810
1811 fwd = is_fwd (c, id); 1811 fwd = is_fwd (c, id);
1812 if (GMC_is_terminal (c, fwd)) 1812 if (GCC_is_terminal (c, fwd))
1813 { 1813 {
1814 struct GNUNET_MessageHeader *out_msg; 1814 struct GNUNET_MessageHeader *out_msg;
1815 struct CadetPeer *neighbor; 1815 struct CadetPeer *neighbor;
1816 struct CadetPeer *endpoint; 1816 struct CadetPeer *endpoint;
1817 1817
1818 neighbor = get_hop (c, !fwd); 1818 neighbor = get_hop (c, !fwd);
1819 endpoint = GMP_get_short (c->path->peers[c->path->length - 1]); 1819 endpoint = GCP_get_short (c->path->peers[c->path->length - 1]);
1820 path_invalidate (c->path); 1820 path_invalidate (c->path);
1821 GMP_notify_broken_link (endpoint, &msg->peer1, &msg->peer2); 1821 GCP_notify_broken_link (endpoint, &msg->peer1, &msg->peer2);
1822 c->state = CADET_CONNECTION_DESTROYED; 1822 c->state = CADET_CONNECTION_DESTROYED;
1823 while (NULL != (out_msg = GMP_connection_pop (neighbor, c))) 1823 while (NULL != (out_msg = GCP_connection_pop (neighbor, c)))
1824 { 1824 {
1825 GNUNET_assert (NULL == 1825 GNUNET_assert (NULL ==
1826 GMT_send_prebuilt_message (out_msg, c->t, NULL, GNUNET_YES, 1826 GCT_send_prebuilt_message (out_msg, c->t, NULL, GNUNET_YES,
1827 NULL, NULL)); 1827 NULL, NULL));
1828 } 1828 }
1829 1829
1830 GMC_destroy (c); 1830 GCC_destroy (c);
1831 } 1831 }
1832 else 1832 else
1833 { 1833 {
1834 GMC_send_prebuilt_message (message, 1834 GCC_send_prebuilt_message (message,
1835 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 0, 1835 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 0,
1836 c, fwd, GNUNET_YES, NULL, NULL); 1836 c, fwd, GNUNET_YES, NULL, NULL);
1837 c->destroy = GNUNET_YES; 1837 c->destroy = GNUNET_YES;
@@ -1854,7 +1854,7 @@ GMC_handle_broken (void* cls,
1854 * GNUNET_SYSERR to close it (signal serious error) 1854 * GNUNET_SYSERR to close it (signal serious error)
1855 */ 1855 */
1856int 1856int
1857GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, 1857GCC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
1858 const struct GNUNET_MessageHeader *message) 1858 const struct GNUNET_MessageHeader *message)
1859{ 1859{
1860 struct GNUNET_CADET_ConnectionDestroy *msg; 1860 struct GNUNET_CADET_ConnectionDestroy *msg;
@@ -1881,21 +1881,21 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
1881 GNUNET_break_op (0); /* FIXME */ 1881 GNUNET_break_op (0); /* FIXME */
1882 return GNUNET_OK; 1882 return GNUNET_OK;
1883 } 1883 }
1884 if (GNUNET_NO == GMC_is_terminal (c, fwd)) 1884 if (GNUNET_NO == GCC_is_terminal (c, fwd))
1885 GMC_send_prebuilt_message (message, 1885 GCC_send_prebuilt_message (message,
1886 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, 0, 1886 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, 0,
1887 c, fwd, GNUNET_YES, NULL, NULL); 1887 c, fwd, GNUNET_YES, NULL, NULL);
1888 else if (0 == c->pending_messages) 1888 else if (0 == c->pending_messages)
1889 { 1889 {
1890 LOG (GNUNET_ERROR_TYPE_DEBUG, " directly destroying connection!\n"); 1890 LOG (GNUNET_ERROR_TYPE_DEBUG, " directly destroying connection!\n");
1891 GMC_destroy (c); 1891 GCC_destroy (c);
1892 return GNUNET_OK; 1892 return GNUNET_OK;
1893 } 1893 }
1894 c->destroy = GNUNET_YES; 1894 c->destroy = GNUNET_YES;
1895 c->state = CADET_CONNECTION_DESTROYED; 1895 c->state = CADET_CONNECTION_DESTROYED;
1896 if (NULL != c->t) 1896 if (NULL != c->t)
1897 { 1897 {
1898 GMT_remove_connection (c->t, c); 1898 GCT_remove_connection (c->t, c);
1899 c->t = NULL; 1899 c->t = NULL;
1900 } 1900 }
1901 1901
@@ -1942,24 +1942,24 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
1942 { 1942 {
1943 GNUNET_STATISTICS_update (stats, "# unknown connection", 1, GNUNET_NO); 1943 GNUNET_STATISTICS_update (stats, "# unknown connection", 1, GNUNET_NO);
1944 LOG (GNUNET_ERROR_TYPE_DEBUG, "enc on unknown connection %s\n", 1944 LOG (GNUNET_ERROR_TYPE_DEBUG, "enc on unknown connection %s\n",
1945 GNUNET_h2s (GM_h2hc (&msg->cid))); 1945 GNUNET_h2s (GC_h2hc (&msg->cid)));
1946 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer); 1946 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer);
1947 return GNUNET_OK; 1947 return GNUNET_OK;
1948 } 1948 }
1949 1949
1950 LOG (GNUNET_ERROR_TYPE_DEBUG, " connection %s\n", GMC_2s (c)); 1950 LOG (GNUNET_ERROR_TYPE_DEBUG, " connection %s\n", GCC_2s (c));
1951 1951
1952 /* Check if origin is as expected */ 1952 /* Check if origin is as expected */
1953 neighbor = get_prev_hop (c); 1953 neighbor = get_prev_hop (c);
1954 peer_id = GNUNET_PEER_search (peer); 1954 peer_id = GNUNET_PEER_search (peer);
1955 if (peer_id == GMP_get_short_id (neighbor)) 1955 if (peer_id == GCP_get_short_id (neighbor))
1956 { 1956 {
1957 fwd = GNUNET_YES; 1957 fwd = GNUNET_YES;
1958 } 1958 }
1959 else 1959 else
1960 { 1960 {
1961 neighbor = get_next_hop (c); 1961 neighbor = get_next_hop (c);
1962 if (peer_id == GMP_get_short_id (neighbor)) 1962 if (peer_id == GCP_get_short_id (neighbor))
1963 { 1963 {
1964 fwd = GNUNET_NO; 1964 fwd = GNUNET_NO;
1965 } 1965 }
@@ -1976,7 +1976,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
1976 pid = ntohl (msg->pid); 1976 pid = ntohl (msg->pid);
1977 LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u+)\n", 1977 LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u+)\n",
1978 pid, fc->last_pid_recv + 1); 1978 pid, fc->last_pid_recv + 1);
1979 if (GM_is_pid_bigger (pid, fc->last_ack_sent)) 1979 if (GC_is_pid_bigger (pid, fc->last_ack_sent))
1980 { 1980 {
1981 GNUNET_STATISTICS_update (stats, "# unsolicited message", 1, GNUNET_NO); 1981 GNUNET_STATISTICS_update (stats, "# unsolicited message", 1, GNUNET_NO);
1982 GNUNET_break_op (0); 1982 GNUNET_break_op (0);
@@ -1985,7 +1985,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
1985 pid, fc->last_pid_recv, fc->last_ack_sent); 1985 pid, fc->last_pid_recv, fc->last_ack_sent);
1986 return GNUNET_OK; 1986 return GNUNET_OK;
1987 } 1987 }
1988 if (GNUNET_NO == GM_is_pid_bigger (pid, fc->last_pid_recv)) 1988 if (GNUNET_NO == GC_is_pid_bigger (pid, fc->last_pid_recv))
1989 { 1989 {
1990 GNUNET_STATISTICS_update (stats, "# duplicate PID", 1, GNUNET_NO); 1990 GNUNET_STATISTICS_update (stats, "# duplicate PID", 1, GNUNET_NO);
1991 LOG (GNUNET_ERROR_TYPE_DEBUG, 1991 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1999,7 +1999,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
1999 fc->last_pid_recv = pid; 1999 fc->last_pid_recv = pid;
2000 2000
2001 /* Is this message for us? */ 2001 /* Is this message for us? */
2002 if (GMC_is_terminal (c, fwd)) 2002 if (GCC_is_terminal (c, fwd))
2003 { 2003 {
2004 LOG (GNUNET_ERROR_TYPE_DEBUG, " message for us!\n"); 2004 LOG (GNUNET_ERROR_TYPE_DEBUG, " message for us!\n");
2005 GNUNET_STATISTICS_update (stats, "# messages received", 1, GNUNET_NO); 2005 GNUNET_STATISTICS_update (stats, "# messages received", 1, GNUNET_NO);
@@ -2010,8 +2010,8 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
2010 return GNUNET_OK; 2010 return GNUNET_OK;
2011 } 2011 }
2012 fc->last_pid_recv = pid; 2012 fc->last_pid_recv = pid;
2013 GMT_handle_encrypted (c->t, msg); 2013 GCT_handle_encrypted (c->t, msg);
2014 GMC_send_ack (c, fwd, GNUNET_NO); 2014 GCC_send_ack (c, fwd, GNUNET_NO);
2015 return GNUNET_OK; 2015 return GNUNET_OK;
2016 } 2016 }
2017 2017
@@ -2023,12 +2023,12 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
2023 { 2023 {
2024 GNUNET_STATISTICS_update (stats, "# TTL drops", 1, GNUNET_NO); 2024 GNUNET_STATISTICS_update (stats, "# TTL drops", 1, GNUNET_NO);
2025 LOG (GNUNET_ERROR_TYPE_WARNING, " TTL is 0, DROPPING!\n"); 2025 LOG (GNUNET_ERROR_TYPE_WARNING, " TTL is 0, DROPPING!\n");
2026 GMC_send_ack (c, fwd, GNUNET_NO); 2026 GCC_send_ack (c, fwd, GNUNET_NO);
2027 return GNUNET_OK; 2027 return GNUNET_OK;
2028 } 2028 }
2029 2029
2030 GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO); 2030 GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO);
2031 GMC_send_prebuilt_message (&msg->header, 2031 GCC_send_prebuilt_message (&msg->header,
2032 GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED, 0, 2032 GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED, 0,
2033 c, fwd, GNUNET_NO, NULL, NULL); 2033 c, fwd, GNUNET_NO, NULL, NULL);
2034 2034
@@ -2072,23 +2072,23 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer,
2072 { 2072 {
2073 GNUNET_STATISTICS_update (stats, "# unknown connection", 1, GNUNET_NO); 2073 GNUNET_STATISTICS_update (stats, "# unknown connection", 1, GNUNET_NO);
2074 LOG (GNUNET_ERROR_TYPE_DEBUG, "kx on unknown connection %s\n", 2074 LOG (GNUNET_ERROR_TYPE_DEBUG, "kx on unknown connection %s\n",
2075 GNUNET_h2s (GM_h2hc (&msg->cid))); 2075 GNUNET_h2s (GC_h2hc (&msg->cid)));
2076 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer); 2076 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer);
2077 return GNUNET_OK; 2077 return GNUNET_OK;
2078 } 2078 }
2079 LOG (GNUNET_ERROR_TYPE_DEBUG, " on connection %s\n", GMC_2s (c)); 2079 LOG (GNUNET_ERROR_TYPE_DEBUG, " on connection %s\n", GCC_2s (c));
2080 2080
2081 /* Check if origin is as expected */ 2081 /* Check if origin is as expected */
2082 neighbor = get_prev_hop (c); 2082 neighbor = get_prev_hop (c);
2083 peer_id = GNUNET_PEER_search (peer); 2083 peer_id = GNUNET_PEER_search (peer);
2084 if (peer_id == GMP_get_short_id (neighbor)) 2084 if (peer_id == GCP_get_short_id (neighbor))
2085 { 2085 {
2086 fwd = GNUNET_YES; 2086 fwd = GNUNET_YES;
2087 } 2087 }
2088 else 2088 else
2089 { 2089 {
2090 neighbor = get_next_hop (c); 2090 neighbor = get_next_hop (c);
2091 if (peer_id == GMP_get_short_id (neighbor)) 2091 if (peer_id == GCP_get_short_id (neighbor))
2092 { 2092 {
2093 fwd = GNUNET_NO; 2093 fwd = GNUNET_NO;
2094 } 2094 }
@@ -2106,14 +2106,14 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer,
2106 connection_change_state (c, CADET_CONNECTION_READY); 2106 connection_change_state (c, CADET_CONNECTION_READY);
2107 if (NULL != c->t) 2107 if (NULL != c->t)
2108 { 2108 {
2109 if (CADET_TUNNEL3_WAITING == GMT_get_cstate (c->t)) 2109 if (CADET_TUNNEL3_WAITING == GCT_get_cstate (c->t))
2110 GMT_change_cstate (c->t, CADET_TUNNEL3_READY); 2110 GCT_change_cstate (c->t, CADET_TUNNEL3_READY);
2111 } 2111 }
2112 } 2112 }
2113 connection_reset_timeout (c, fwd); 2113 connection_reset_timeout (c, fwd);
2114 2114
2115 /* Is this message for us? */ 2115 /* Is this message for us? */
2116 if (GMC_is_terminal (c, fwd)) 2116 if (GCC_is_terminal (c, fwd))
2117 { 2117 {
2118 LOG (GNUNET_ERROR_TYPE_DEBUG, " message for us!\n"); 2118 LOG (GNUNET_ERROR_TYPE_DEBUG, " message for us!\n");
2119 GNUNET_STATISTICS_update (stats, "# messages received", 1, GNUNET_NO); 2119 GNUNET_STATISTICS_update (stats, "# messages received", 1, GNUNET_NO);
@@ -2122,14 +2122,14 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer,
2122 GNUNET_break (0); 2122 GNUNET_break (0);
2123 return GNUNET_OK; 2123 return GNUNET_OK;
2124 } 2124 }
2125 GMT_handle_kx (c->t, &msg[1].header); 2125 GCT_handle_kx (c->t, &msg[1].header);
2126 return GNUNET_OK; 2126 return GNUNET_OK;
2127 } 2127 }
2128 2128
2129 /* Message not for us: forward to next hop */ 2129 /* Message not for us: forward to next hop */
2130 LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n"); 2130 LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n");
2131 GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO); 2131 GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO);
2132 GMC_send_prebuilt_message (&msg->header, GNUNET_MESSAGE_TYPE_CADET_KX, 0, 2132 GCC_send_prebuilt_message (&msg->header, GNUNET_MESSAGE_TYPE_CADET_KX, 0,
2133 c, fwd, GNUNET_NO, NULL, NULL); 2133 c, fwd, GNUNET_NO, NULL, NULL);
2134 2134
2135 return GNUNET_OK; 2135 return GNUNET_OK;
@@ -2147,7 +2147,7 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer,
2147 * GNUNET_SYSERR to close it (signal serious error) 2147 * GNUNET_SYSERR to close it (signal serious error)
2148 */ 2148 */
2149int 2149int
2150GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer, 2150GCC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
2151 const struct GNUNET_MessageHeader *message) 2151 const struct GNUNET_MessageHeader *message)
2152{ 2152{
2153 return handle_cadet_encrypted (peer, 2153 return handle_cadet_encrypted (peer,
@@ -2166,7 +2166,7 @@ GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
2166 * GNUNET_SYSERR to close it (signal serious error) 2166 * GNUNET_SYSERR to close it (signal serious error)
2167 */ 2167 */
2168int 2168int
2169GMC_handle_kx (void *cls, const struct GNUNET_PeerIdentity *peer, 2169GCC_handle_kx (void *cls, const struct GNUNET_PeerIdentity *peer,
2170 const struct GNUNET_MessageHeader *message) 2170 const struct GNUNET_MessageHeader *message)
2171{ 2171{
2172 return handle_cadet_kx (peer, 2172 return handle_cadet_kx (peer,
@@ -2185,7 +2185,7 @@ GMC_handle_kx (void *cls, const struct GNUNET_PeerIdentity *peer,
2185 * GNUNET_SYSERR to close it (signal serious error) 2185 * GNUNET_SYSERR to close it (signal serious error)
2186 */ 2186 */
2187int 2187int
2188GMC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer, 2188GCC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
2189 const struct GNUNET_MessageHeader *message) 2189 const struct GNUNET_MessageHeader *message)
2190{ 2190{
2191 struct GNUNET_CADET_ACK *msg; 2191 struct GNUNET_CADET_ACK *msg;
@@ -2208,13 +2208,13 @@ GMC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
2208 2208
2209 /* Is this a forward or backward ACK? */ 2209 /* Is this a forward or backward ACK? */
2210 id = GNUNET_PEER_search (peer); 2210 id = GNUNET_PEER_search (peer);
2211 if (GMP_get_short_id (get_next_hop (c)) == id) 2211 if (GCP_get_short_id (get_next_hop (c)) == id)
2212 { 2212 {
2213 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n"); 2213 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n");
2214 fc = &c->fwd_fc; 2214 fc = &c->fwd_fc;
2215 fwd = GNUNET_YES; 2215 fwd = GNUNET_YES;
2216 } 2216 }
2217 else if (GMP_get_short_id (get_prev_hop (c)) == id) 2217 else if (GCP_get_short_id (get_prev_hop (c)) == id)
2218 { 2218 {
2219 LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n"); 2219 LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n");
2220 fc = &c->bck_fc; 2220 fc = &c->bck_fc;
@@ -2229,12 +2229,12 @@ GMC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
2229 ack = ntohl (msg->ack); 2229 ack = ntohl (msg->ack);
2230 LOG (GNUNET_ERROR_TYPE_DEBUG, " ACK %u (was %u)\n", 2230 LOG (GNUNET_ERROR_TYPE_DEBUG, " ACK %u (was %u)\n",
2231 ack, fc->last_ack_recv); 2231 ack, fc->last_ack_recv);
2232 if (GM_is_pid_bigger (ack, fc->last_ack_recv)) 2232 if (GC_is_pid_bigger (ack, fc->last_ack_recv))
2233 fc->last_ack_recv = ack; 2233 fc->last_ack_recv = ack;
2234 2234
2235 /* Cancel polling if the ACK is big enough. */ 2235 /* Cancel polling if the ACK is big enough. */
2236 if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task && 2236 if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task &&
2237 GM_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent)) 2237 GC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
2238 { 2238 {
2239 LOG (GNUNET_ERROR_TYPE_DEBUG, " Cancel poll\n"); 2239 LOG (GNUNET_ERROR_TYPE_DEBUG, " Cancel poll\n");
2240 GNUNET_SCHEDULER_cancel (fc->poll_task); 2240 GNUNET_SCHEDULER_cancel (fc->poll_task);
@@ -2259,7 +2259,7 @@ GMC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
2259 * GNUNET_SYSERR to close it (signal serious error) 2259 * GNUNET_SYSERR to close it (signal serious error)
2260 */ 2260 */
2261int 2261int
2262GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer, 2262GCC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
2263 const struct GNUNET_MessageHeader *message) 2263 const struct GNUNET_MessageHeader *message)
2264{ 2264{
2265 struct GNUNET_CADET_Poll *msg; 2265 struct GNUNET_CADET_Poll *msg;
@@ -2277,7 +2277,7 @@ GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
2277 GNUNET_STATISTICS_update (stats, "# poll on unknown connection", 1, 2277 GNUNET_STATISTICS_update (stats, "# poll on unknown connection", 1,
2278 GNUNET_NO); 2278 GNUNET_NO);
2279 LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL message on unknown connection %s!\n", 2279 LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL message on unknown connection %s!\n",
2280 GNUNET_h2s (GM_h2hc (&msg->cid))); 2280 GNUNET_h2s (GC_h2hc (&msg->cid)));
2281 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer); 2281 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer);
2282 return GNUNET_OK; 2282 return GNUNET_OK;
2283 } 2283 }
@@ -2288,12 +2288,12 @@ GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
2288 * this way of discerining FWD/BCK should not be a problem. 2288 * this way of discerining FWD/BCK should not be a problem.
2289 */ 2289 */
2290 id = GNUNET_PEER_search (peer); 2290 id = GNUNET_PEER_search (peer);
2291 if (GMP_get_short_id (get_next_hop (c)) == id) 2291 if (GCP_get_short_id (get_next_hop (c)) == id)
2292 { 2292 {
2293 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD FC\n"); 2293 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD FC\n");
2294 fc = &c->fwd_fc; 2294 fc = &c->fwd_fc;
2295 } 2295 }
2296 else if (GMP_get_short_id (get_prev_hop (c)) == id) 2296 else if (GCP_get_short_id (get_prev_hop (c)) == id)
2297 { 2297 {
2298 LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK FC\n"); 2298 LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK FC\n");
2299 fc = &c->bck_fc; 2299 fc = &c->bck_fc;
@@ -2308,7 +2308,7 @@ GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
2308 LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u, OLD %u\n", pid, fc->last_pid_recv); 2308 LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u, OLD %u\n", pid, fc->last_pid_recv);
2309 fc->last_pid_recv = pid; 2309 fc->last_pid_recv = pid;
2310 fwd = fc == &c->bck_fc; 2310 fwd = fc == &c->bck_fc;
2311 GMC_send_ack (c, fwd, GNUNET_YES); 2311 GCC_send_ack (c, fwd, GNUNET_YES);
2312 2312
2313 return GNUNET_OK; 2313 return GNUNET_OK;
2314} 2314}
@@ -2323,13 +2323,13 @@ GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
2323 * @param force Send the ACK even if suboptimal (e.g. requested by POLL). 2323 * @param force Send the ACK even if suboptimal (e.g. requested by POLL).
2324 */ 2324 */
2325void 2325void
2326GMC_send_ack (struct CadetConnection *c, int fwd, int force) 2326GCC_send_ack (struct CadetConnection *c, int fwd, int force)
2327{ 2327{
2328 unsigned int buffer; 2328 unsigned int buffer;
2329 2329
2330 LOG (GNUNET_ERROR_TYPE_DEBUG, 2330 LOG (GNUNET_ERROR_TYPE_DEBUG,
2331 "GMC send %s ACK on %s\n", 2331 "GMC send %s ACK on %s\n",
2332 GM_f2s (fwd), GMC_2s (c)); 2332 GC_f2s (fwd), GCC_2s (c));
2333 2333
2334 if (NULL == c) 2334 if (NULL == c)
2335 { 2335 {
@@ -2344,26 +2344,26 @@ GMC_send_ack (struct CadetConnection *c, int fwd, int force)
2344 } 2344 }
2345 2345
2346 /* Get available buffer space */ 2346 /* Get available buffer space */
2347 if (GMC_is_terminal (c, fwd)) 2347 if (GCC_is_terminal (c, fwd))
2348 { 2348 {
2349 LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from all channels\n"); 2349 LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from all channels\n");
2350 buffer = GMT_get_channels_buffer (c->t); 2350 buffer = GCT_get_channels_buffer (c->t);
2351 } 2351 }
2352 else 2352 else
2353 { 2353 {
2354 LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from one connection\n"); 2354 LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from one connection\n");
2355 buffer = GMC_get_buffer (c, fwd); 2355 buffer = GCC_get_buffer (c, fwd);
2356 } 2356 }
2357 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer available: %u\n", buffer); 2357 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer available: %u\n", buffer);
2358 if (0 == buffer && GNUNET_NO == force) 2358 if (0 == buffer && GNUNET_NO == force)
2359 return; 2359 return;
2360 2360
2361 /* Send available buffer space */ 2361 /* Send available buffer space */
2362 if (GMC_is_origin (c, fwd)) 2362 if (GCC_is_origin (c, fwd))
2363 { 2363 {
2364 GNUNET_assert (NULL != c->t); 2364 GNUNET_assert (NULL != c->t);
2365 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on channels...\n"); 2365 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on channels...\n");
2366 GMT_unchoke_channels (c->t); 2366 GCT_unchoke_channels (c->t);
2367 } 2367 }
2368 else 2368 else
2369 { 2369 {
@@ -2379,7 +2379,7 @@ GMC_send_ack (struct CadetConnection *c, int fwd, int force)
2379 * @param c Configuration handle. 2379 * @param c Configuration handle.
2380 */ 2380 */
2381void 2381void
2382GMC_init (const struct GNUNET_CONFIGURATION_Handle *c) 2382GCC_init (const struct GNUNET_CONFIGURATION_Handle *c)
2383{ 2383{
2384 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); 2384 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
2385 if (GNUNET_OK != 2385 if (GNUNET_OK !=
@@ -2432,7 +2432,7 @@ shutdown_iterator (void *cls,
2432{ 2432{
2433 struct CadetConnection *c = value; 2433 struct CadetConnection *c = value;
2434 2434
2435 GMC_destroy (c); 2435 GCC_destroy (c);
2436 return GNUNET_YES; 2436 return GNUNET_YES;
2437} 2437}
2438 2438
@@ -2441,7 +2441,7 @@ shutdown_iterator (void *cls,
2441 * Shut down the connections subsystem. 2441 * Shut down the connections subsystem.
2442 */ 2442 */
2443void 2443void
2444GMC_shutdown (void) 2444GCC_shutdown (void)
2445{ 2445{
2446 GNUNET_CONTAINER_multihashmap_iterate (connections, &shutdown_iterator, NULL); 2446 GNUNET_CONTAINER_multihashmap_iterate (connections, &shutdown_iterator, NULL);
2447 GNUNET_CONTAINER_multihashmap_destroy (connections); 2447 GNUNET_CONTAINER_multihashmap_destroy (connections);
@@ -2450,7 +2450,7 @@ GMC_shutdown (void)
2450 2450
2451 2451
2452struct CadetConnection * 2452struct CadetConnection *
2453GMC_new (const struct GNUNET_CADET_Hash *cid, 2453GCC_new (const struct GNUNET_CADET_Hash *cid,
2454 struct CadetTunnel3 *t, 2454 struct CadetTunnel3 *t,
2455 struct CadetPeerPath *p, 2455 struct CadetPeerPath *p,
2456 unsigned int own_pos) 2456 unsigned int own_pos)
@@ -2461,7 +2461,7 @@ GMC_new (const struct GNUNET_CADET_Hash *cid,
2461 c->id = *cid; 2461 c->id = *cid;
2462 GNUNET_assert (GNUNET_OK == 2462 GNUNET_assert (GNUNET_OK ==
2463 GNUNET_CONTAINER_multihashmap_put (connections, 2463 GNUNET_CONTAINER_multihashmap_put (connections,
2464 GMC_get_h (c), c, 2464 GCC_get_h (c), c,
2465 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 2465 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
2466 fc_init (&c->fwd_fc); 2466 fc_init (&c->fwd_fc);
2467 fc_init (&c->bck_fc); 2467 fc_init (&c->bck_fc);
@@ -2482,7 +2482,7 @@ GMC_new (const struct GNUNET_CADET_Hash *cid,
2482 c->t = NULL; 2482 c->t = NULL;
2483 c->path = NULL; 2483 c->path = NULL;
2484 } 2484 }
2485 GMC_destroy (c); 2485 GCC_destroy (c);
2486 return NULL; 2486 return NULL;
2487 } 2487 }
2488 2488
@@ -2491,7 +2491,7 @@ GMC_new (const struct GNUNET_CADET_Hash *cid,
2491 2491
2492 2492
2493void 2493void
2494GMC_destroy (struct CadetConnection *c) 2494GCC_destroy (struct CadetConnection *c)
2495{ 2495{
2496 if (NULL == c) 2496 if (NULL == c)
2497 { 2497 {
@@ -2499,11 +2499,11 @@ GMC_destroy (struct CadetConnection *c)
2499 return; 2499 return;
2500 } 2500 }
2501 2501
2502 if (2 == c->destroy) /* cancel queues -> GMP_queue_cancel -> q_destroy -> */ 2502 if (2 == c->destroy) /* cancel queues -> GCP_queue_cancel -> q_destroy -> */
2503 return; /* -> message_sent -> GMC_destroy. Don't loop. */ 2503 return; /* -> message_sent -> GCC_destroy. Don't loop. */
2504 c->destroy = 2; 2504 c->destroy = 2;
2505 2505
2506 LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying connection %s\n", GMC_2s (c)); 2506 LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying connection %s\n", GCC_2s (c));
2507 LOG (GNUNET_ERROR_TYPE_DEBUG, " fc's f: %p, b: %p\n", 2507 LOG (GNUNET_ERROR_TYPE_DEBUG, " fc's f: %p, b: %p\n",
2508 &c->fwd_fc, &c->bck_fc); 2508 &c->fwd_fc, &c->bck_fc);
2509 LOG (GNUNET_ERROR_TYPE_DEBUG, " fc tasks f: %u, b: %u\n", 2509 LOG (GNUNET_ERROR_TYPE_DEBUG, " fc tasks f: %u, b: %u\n",
@@ -2523,20 +2523,20 @@ GMC_destroy (struct CadetConnection *c)
2523 /* Cancel maintainance task (keepalive/timeout) */ 2523 /* Cancel maintainance task (keepalive/timeout) */
2524 if (NULL != c->fwd_fc.poll_msg) 2524 if (NULL != c->fwd_fc.poll_msg)
2525 { 2525 {
2526 GMC_cancel (c->fwd_fc.poll_msg); 2526 GCC_cancel (c->fwd_fc.poll_msg);
2527 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL msg FWD canceled\n"); 2527 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL msg FWD canceled\n");
2528 } 2528 }
2529 if (NULL != c->bck_fc.poll_msg) 2529 if (NULL != c->bck_fc.poll_msg)
2530 { 2530 {
2531 GMC_cancel (c->bck_fc.poll_msg); 2531 GCC_cancel (c->bck_fc.poll_msg);
2532 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL msg BCK canceled\n"); 2532 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL msg BCK canceled\n");
2533 } 2533 }
2534 2534
2535 /* Delete from tunnel */ 2535 /* Delete from tunnel */
2536 if (NULL != c->t) 2536 if (NULL != c->t)
2537 GMT_remove_connection (c->t, c); 2537 GCT_remove_connection (c->t, c);
2538 2538
2539 if (GNUNET_NO == GMC_is_origin (c, GNUNET_YES) && NULL != c->path) 2539 if (GNUNET_NO == GCC_is_origin (c, GNUNET_YES) && NULL != c->path)
2540 path_destroy (c->path); 2540 path_destroy (c->path);
2541 if (GNUNET_SCHEDULER_NO_TASK != c->fwd_maintenance_task) 2541 if (GNUNET_SCHEDULER_NO_TASK != c->fwd_maintenance_task)
2542 GNUNET_SCHEDULER_cancel (c->fwd_maintenance_task); 2542 GNUNET_SCHEDULER_cancel (c->fwd_maintenance_task);
@@ -2555,7 +2555,7 @@ GMC_destroy (struct CadetConnection *c)
2555 2555
2556 GNUNET_break (GNUNET_YES == 2556 GNUNET_break (GNUNET_YES ==
2557 GNUNET_CONTAINER_multihashmap_remove (connections, 2557 GNUNET_CONTAINER_multihashmap_remove (connections,
2558 GMC_get_h (c), c)); 2558 GCC_get_h (c), c));
2559 2559
2560 GNUNET_STATISTICS_update (stats, "# connections", -1, GNUNET_NO); 2560 GNUNET_STATISTICS_update (stats, "# connections", -1, GNUNET_NO);
2561 GNUNET_free (c); 2561 GNUNET_free (c);
@@ -2569,7 +2569,7 @@ GMC_destroy (struct CadetConnection *c)
2569 * @return ID of the connection. 2569 * @return ID of the connection.
2570 */ 2570 */
2571const struct GNUNET_CADET_Hash * 2571const struct GNUNET_CADET_Hash *
2572GMC_get_id (const struct CadetConnection *c) 2572GCC_get_id (const struct CadetConnection *c)
2573{ 2573{
2574 return &c->id; 2574 return &c->id;
2575} 2575}
@@ -2583,9 +2583,9 @@ GMC_get_id (const struct CadetConnection *c)
2583 * @return ID of the connection. 2583 * @return ID of the connection.
2584 */ 2584 */
2585const struct GNUNET_HashCode * 2585const struct GNUNET_HashCode *
2586GMC_get_h (const struct CadetConnection *c) 2586GCC_get_h (const struct CadetConnection *c)
2587{ 2587{
2588 return GM_h2hc (&c->id); 2588 return GC_h2hc (&c->id);
2589} 2589}
2590 2590
2591 2591
@@ -2597,7 +2597,7 @@ GMC_get_h (const struct CadetConnection *c)
2597 * @return path used by the connection. 2597 * @return path used by the connection.
2598 */ 2598 */
2599const struct CadetPeerPath * 2599const struct CadetPeerPath *
2600GMC_get_path (const struct CadetConnection *c) 2600GCC_get_path (const struct CadetConnection *c)
2601{ 2601{
2602 if (GNUNET_NO == c->destroy) 2602 if (GNUNET_NO == c->destroy)
2603 return c->path; 2603 return c->path;
@@ -2613,7 +2613,7 @@ GMC_get_path (const struct CadetConnection *c)
2613 * @return state of the connection. 2613 * @return state of the connection.
2614 */ 2614 */
2615enum CadetConnectionState 2615enum CadetConnectionState
2616GMC_get_state (const struct CadetConnection *c) 2616GCC_get_state (const struct CadetConnection *c)
2617{ 2617{
2618 return c->state; 2618 return c->state;
2619} 2619}
@@ -2626,7 +2626,7 @@ GMC_get_state (const struct CadetConnection *c)
2626 * @return tunnel of the connection. 2626 * @return tunnel of the connection.
2627 */ 2627 */
2628struct CadetTunnel3 * 2628struct CadetTunnel3 *
2629GMC_get_tunnel (const struct CadetConnection *c) 2629GCC_get_tunnel (const struct CadetConnection *c)
2630{ 2630{
2631 return c->t; 2631 return c->t;
2632} 2632}
@@ -2641,7 +2641,7 @@ GMC_get_tunnel (const struct CadetConnection *c)
2641 * @return Free buffer space [0 - max_msgs_queue/max_connections] 2641 * @return Free buffer space [0 - max_msgs_queue/max_connections]
2642 */ 2642 */
2643unsigned int 2643unsigned int
2644GMC_get_buffer (struct CadetConnection *c, int fwd) 2644GCC_get_buffer (struct CadetConnection *c, int fwd)
2645{ 2645{
2646 struct CadetFlowControl *fc; 2646 struct CadetFlowControl *fc;
2647 2647
@@ -2659,12 +2659,12 @@ GMC_get_buffer (struct CadetConnection *c, int fwd)
2659 * @return last_ack_sent - last_pid_recv 2659 * @return last_ack_sent - last_pid_recv
2660 */ 2660 */
2661unsigned int 2661unsigned int
2662GMC_get_allowed (struct CadetConnection *c, int fwd) 2662GCC_get_allowed (struct CadetConnection *c, int fwd)
2663{ 2663{
2664 struct CadetFlowControl *fc; 2664 struct CadetFlowControl *fc;
2665 2665
2666 fc = fwd ? &c->fwd_fc : &c->bck_fc; 2666 fc = fwd ? &c->fwd_fc : &c->bck_fc;
2667 if (GM_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent)) 2667 if (GC_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent))
2668 { 2668 {
2669 return 0; 2669 return 0;
2670 } 2670 }
@@ -2680,7 +2680,7 @@ GMC_get_allowed (struct CadetConnection *c, int fwd)
2680 * @return Number of messages queued. 2680 * @return Number of messages queued.
2681 */ 2681 */
2682unsigned int 2682unsigned int
2683GMC_get_qn (struct CadetConnection *c, int fwd) 2683GCC_get_qn (struct CadetConnection *c, int fwd)
2684{ 2684{
2685 struct CadetFlowControl *fc; 2685 struct CadetFlowControl *fc;
2686 2686
@@ -2699,7 +2699,7 @@ GMC_get_qn (struct CadetConnection *c, int fwd)
2699 * @return Last PID used + 1. 2699 * @return Last PID used + 1.
2700 */ 2700 */
2701unsigned int 2701unsigned int
2702GMC_get_pid (struct CadetConnection *c, int fwd) 2702GCC_get_pid (struct CadetConnection *c, int fwd)
2703{ 2703{
2704 struct CadetFlowControl *fc; 2704 struct CadetFlowControl *fc;
2705 2705
@@ -2720,10 +2720,10 @@ GMC_get_pid (struct CadetConnection *c, int fwd)
2720 * @param fwd Is this about FWD traffic? (The ack will go dest->root). 2720 * @param fwd Is this about FWD traffic? (The ack will go dest->root).
2721 */ 2721 */
2722void 2722void
2723GMC_allow (struct CadetConnection *c, unsigned int buffer, int fwd) 2723GCC_allow (struct CadetConnection *c, unsigned int buffer, int fwd)
2724{ 2724{
2725 LOG (GNUNET_ERROR_TYPE_DEBUG, " allowing %s %u messages %s\n", 2725 LOG (GNUNET_ERROR_TYPE_DEBUG, " allowing %s %u messages %s\n",
2726 GMC_2s (c), buffer, GM_f2s (fwd)); 2726 GCC_2s (c), buffer, GC_f2s (fwd));
2727 send_ack (c, buffer, fwd, GNUNET_NO); 2727 send_ack (c, buffer, fwd, GNUNET_NO);
2728} 2728}
2729 2729
@@ -2736,25 +2736,25 @@ GMC_allow (struct CadetConnection *c, unsigned int buffer, int fwd)
2736 * @param peer Peer that disconnected. 2736 * @param peer Peer that disconnected.
2737 */ 2737 */
2738void 2738void
2739GMC_notify_broken (struct CadetConnection *c, 2739GCC_notify_broken (struct CadetConnection *c,
2740 struct CadetPeer *peer) 2740 struct CadetPeer *peer)
2741{ 2741{
2742 int fwd; 2742 int fwd;
2743 2743
2744 LOG (GNUNET_ERROR_TYPE_DEBUG, 2744 LOG (GNUNET_ERROR_TYPE_DEBUG,
2745 " notify broken on %s due to %s disconnect\n", 2745 " notify broken on %s due to %s disconnect\n",
2746 GMC_2s (c), GMP_2s (peer)); 2746 GCC_2s (c), GCP_2s (peer));
2747 2747
2748 fwd = peer == get_prev_hop (c); 2748 fwd = peer == get_prev_hop (c);
2749 2749
2750 if (GNUNET_YES == GMC_is_terminal (c, fwd)) 2750 if (GNUNET_YES == GCC_is_terminal (c, fwd))
2751 { 2751 {
2752 /* Local shutdown, no one to notify about this. */ 2752 /* Local shutdown, no one to notify about this. */
2753 GMC_destroy (c); 2753 GCC_destroy (c);
2754 return; 2754 return;
2755 } 2755 }
2756 if (GNUNET_NO == c->destroy) 2756 if (GNUNET_NO == c->destroy)
2757 send_broken (c, &my_full_id, GMP_get_id (peer), fwd); 2757 send_broken (c, &my_full_id, GCP_get_id (peer), fwd);
2758 2758
2759 /* Connection will have at least one pending message 2759 /* Connection will have at least one pending message
2760 * (the one we just scheduled), so no point in checking whether to 2760 * (the one we just scheduled), so no point in checking whether to
@@ -2780,7 +2780,7 @@ GMC_notify_broken (struct CadetConnection *c,
2780 * @return #GNUNET_YES if origin, #GNUNET_NO if relay/terminal. 2780 * @return #GNUNET_YES if origin, #GNUNET_NO if relay/terminal.
2781 */ 2781 */
2782int 2782int
2783GMC_is_origin (struct CadetConnection *c, int fwd) 2783GCC_is_origin (struct CadetConnection *c, int fwd)
2784{ 2784{
2785 if (!fwd && c->path->length - 1 == c->own_pos ) 2785 if (!fwd && c->path->length - 1 == c->own_pos )
2786 return GNUNET_YES; 2786 return GNUNET_YES;
@@ -2800,9 +2800,9 @@ GMC_is_origin (struct CadetConnection *c, int fwd)
2800 * @return #GNUNET_YES if terminal, #GNUNET_NO if relay/origin. 2800 * @return #GNUNET_YES if terminal, #GNUNET_NO if relay/origin.
2801 */ 2801 */
2802int 2802int
2803GMC_is_terminal (struct CadetConnection *c, int fwd) 2803GCC_is_terminal (struct CadetConnection *c, int fwd)
2804{ 2804{
2805 return GMC_is_origin (c, !fwd); 2805 return GCC_is_origin (c, !fwd);
2806} 2806}
2807 2807
2808 2808
@@ -2815,12 +2815,12 @@ GMC_is_terminal (struct CadetConnection *c, int fwd)
2815 * @return #GNUNET_YES in case it's OK to send. 2815 * @return #GNUNET_YES in case it's OK to send.
2816 */ 2816 */
2817int 2817int
2818GMC_is_sendable (struct CadetConnection *c, int fwd) 2818GCC_is_sendable (struct CadetConnection *c, int fwd)
2819{ 2819{
2820 struct CadetFlowControl *fc; 2820 struct CadetFlowControl *fc;
2821 2821
2822 LOG (GNUNET_ERROR_TYPE_DEBUG, " checking sendability of %s traffic on %s\n", 2822 LOG (GNUNET_ERROR_TYPE_DEBUG, " checking sendability of %s traffic on %s\n",
2823 GM_f2s (fwd), GMC_2s (c)); 2823 GC_f2s (fwd), GCC_2s (c));
2824 if (NULL == c) 2824 if (NULL == c)
2825 { 2825 {
2826 GNUNET_break (0); 2826 GNUNET_break (0);
@@ -2830,7 +2830,7 @@ GMC_is_sendable (struct CadetConnection *c, int fwd)
2830 LOG (GNUNET_ERROR_TYPE_DEBUG, 2830 LOG (GNUNET_ERROR_TYPE_DEBUG,
2831 " last ack recv: %u, last pid sent: %u\n", 2831 " last ack recv: %u, last pid sent: %u\n",
2832 fc->last_ack_recv, fc->last_pid_sent); 2832 fc->last_ack_recv, fc->last_pid_sent);
2833 if (GM_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent)) 2833 if (GC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
2834 { 2834 {
2835 LOG (GNUNET_ERROR_TYPE_DEBUG, " sendable\n"); 2835 LOG (GNUNET_ERROR_TYPE_DEBUG, " sendable\n");
2836 return GNUNET_YES; 2836 return GNUNET_YES;
@@ -2848,7 +2848,7 @@ GMC_is_sendable (struct CadetConnection *c, int fwd)
2848 * @return #GNUNET_YES in case it's a direct connection, #GNUNET_NO otherwise. 2848 * @return #GNUNET_YES in case it's a direct connection, #GNUNET_NO otherwise.
2849 */ 2849 */
2850int 2850int
2851GMC_is_direct (struct CadetConnection *c) 2851GCC_is_direct (struct CadetConnection *c)
2852{ 2852{
2853 return (c->path->length == 2) ? GNUNET_YES : GNUNET_NO; 2853 return (c->path->length == 2) ? GNUNET_YES : GNUNET_NO;
2854} 2854}
@@ -2871,10 +2871,10 @@ GMC_is_direct (struct CadetConnection *c)
2871 * Invalid on @c cont call. 2871 * Invalid on @c cont call.
2872 */ 2872 */
2873struct CadetConnectionQueue * 2873struct CadetConnectionQueue *
2874GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, 2874GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2875 uint16_t payload_type, uint32_t payload_id, 2875 uint16_t payload_type, uint32_t payload_id,
2876 struct CadetConnection *c, int fwd, int force, 2876 struct CadetConnection *c, int fwd, int force,
2877 GMC_sent cont, void *cont_cls) 2877 GCC_sent cont, void *cont_cls)
2878{ 2878{
2879 struct CadetFlowControl *fc; 2879 struct CadetFlowControl *fc;
2880 struct CadetConnectionQueue *q; 2880 struct CadetConnectionQueue *q;
@@ -2888,7 +2888,7 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2888 memcpy (data, message, size); 2888 memcpy (data, message, size);
2889 type = ntohs (message->type); 2889 type = ntohs (message->type);
2890 LOG (GNUNET_ERROR_TYPE_INFO, "--> %s (%s %u) on connection %s (%u bytes)\n", 2890 LOG (GNUNET_ERROR_TYPE_INFO, "--> %s (%s %u) on connection %s (%u bytes)\n",
2891 GM_m2s (type), GM_m2s (payload_type), payload_id, GMC_2s (c), size); 2891 GC_m2s (type), GC_m2s (payload_type), payload_id, GCC_2s (c), size);
2892 2892
2893 fc = fwd ? &c->fwd_fc : &c->bck_fc; 2893 fc = fwd ? &c->fwd_fc : &c->bck_fc;
2894 droppable = GNUNET_NO == force; 2894 droppable = GNUNET_NO == force;
@@ -2925,9 +2925,9 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2925 { 2925 {
2926 LOG (GNUNET_ERROR_TYPE_DEBUG, " not droppable, Q_N stays the same\n"); 2926 LOG (GNUNET_ERROR_TYPE_DEBUG, " not droppable, Q_N stays the same\n");
2927 } 2927 }
2928 if (GM_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv)) 2928 if (GC_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv))
2929 { 2929 {
2930 GMC_start_poll (c, fwd); 2930 GCC_start_poll (c, fwd);
2931 } 2931 }
2932 break; 2932 break;
2933 2933
@@ -2994,11 +2994,11 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2994 2994
2995 q = GNUNET_new (struct CadetConnectionQueue); 2995 q = GNUNET_new (struct CadetConnectionQueue);
2996 q->forced = !droppable; 2996 q->forced = !droppable;
2997 q->q = GMP_queue_add (get_hop (c, fwd), data, type, payload_type, payload_id, 2997 q->q = GCP_queue_add (get_hop (c, fwd), data, type, payload_type, payload_id,
2998 size, c, fwd, &conn_message_sent, q); 2998 size, c, fwd, &conn_message_sent, q);
2999 if (NULL == q->q) 2999 if (NULL == q->q)
3000 { 3000 {
3001 LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING dropping msg on %s\n", GMC_2s (c)); 3001 LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING dropping msg on %s\n", GCC_2s (c));
3002 GNUNET_free (data); 3002 GNUNET_free (data);
3003 GNUNET_free (q); 3003 GNUNET_free (q);
3004 return NULL; 3004 return NULL;
@@ -3019,12 +3019,12 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3019 * @param q Handle to the queue. 3019 * @param q Handle to the queue.
3020 */ 3020 */
3021void 3021void
3022GMC_cancel (struct CadetConnectionQueue *q) 3022GCC_cancel (struct CadetConnectionQueue *q)
3023{ 3023{
3024 LOG (GNUNET_ERROR_TYPE_DEBUG, "! GMC cancel message\n"); 3024 LOG (GNUNET_ERROR_TYPE_DEBUG, "! GMC cancel message\n");
3025 3025
3026 /* queue destroy calls message_sent, which calls q->cont and frees q */ 3026 /* queue destroy calls message_sent, which calls q->cont and frees q */
3027 GMP_queue_destroy (q->q, GNUNET_YES, GNUNET_NO, 0); 3027 GCP_queue_destroy (q->q, GNUNET_YES, GNUNET_NO, 0);
3028} 3028}
3029 3029
3030 3030
@@ -3035,7 +3035,7 @@ GMC_cancel (struct CadetConnectionQueue *q)
3035 * @param connection Connection to create. 3035 * @param connection Connection to create.
3036 */ 3036 */
3037void 3037void
3038GMC_send_create (struct CadetConnection *connection) 3038GCC_send_create (struct CadetConnection *connection)
3039{ 3039{
3040 enum CadetTunnel3CState state; 3040 enum CadetTunnel3CState state;
3041 size_t size; 3041 size_t size;
@@ -3044,21 +3044,21 @@ GMC_send_create (struct CadetConnection *connection)
3044 size += connection->path->length * sizeof (struct GNUNET_PeerIdentity); 3044 size += connection->path->length * sizeof (struct GNUNET_PeerIdentity);
3045 3045
3046 LOG (GNUNET_ERROR_TYPE_INFO, "===> %s on connection %s (%u bytes)\n", 3046 LOG (GNUNET_ERROR_TYPE_INFO, "===> %s on connection %s (%u bytes)\n",
3047 GM_m2s (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE), 3047 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE),
3048 GMC_2s (connection), size); 3048 GCC_2s (connection), size);
3049 LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P+ %p %u (create)\n", 3049 LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P+ %p %u (create)\n",
3050 connection, connection->pending_messages); 3050 connection, connection->pending_messages);
3051 connection->pending_messages++; 3051 connection->pending_messages++;
3052 3052
3053 connection->maintenance_q = 3053 connection->maintenance_q =
3054 GMP_queue_add (get_next_hop (connection), NULL, 3054 GCP_queue_add (get_next_hop (connection), NULL,
3055 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, 3055 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE,
3056 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, 0, 3056 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, 0,
3057 size, connection, GNUNET_YES, &conn_message_sent, NULL); 3057 size, connection, GNUNET_YES, &conn_message_sent, NULL);
3058 3058
3059 state = GMT_get_cstate (connection->t); 3059 state = GCT_get_cstate (connection->t);
3060 if (CADET_TUNNEL3_SEARCHING == state || CADET_TUNNEL3_NEW == state) 3060 if (CADET_TUNNEL3_SEARCHING == state || CADET_TUNNEL3_NEW == state)
3061 GMT_change_cstate (connection->t, CADET_TUNNEL3_WAITING); 3061 GCT_change_cstate (connection->t, CADET_TUNNEL3_WAITING);
3062 if (CADET_CONNECTION_NEW == connection->state) 3062 if (CADET_CONNECTION_NEW == connection->state)
3063 connection_change_state (connection, CADET_CONNECTION_SENT); 3063 connection_change_state (connection, CADET_CONNECTION_SENT);
3064} 3064}
@@ -3074,7 +3074,7 @@ GMC_send_create (struct CadetConnection *connection)
3074 * @param c The connection whose peers to notify. 3074 * @param c The connection whose peers to notify.
3075 */ 3075 */
3076void 3076void
3077GMC_send_destroy (struct CadetConnection *c) 3077GCC_send_destroy (struct CadetConnection *c)
3078{ 3078{
3079 struct GNUNET_CADET_ConnectionDestroy msg; 3079 struct GNUNET_CADET_ConnectionDestroy msg;
3080 3080
@@ -3086,14 +3086,14 @@ GMC_send_destroy (struct CadetConnection *c)
3086 msg.cid = c->id; 3086 msg.cid = c->id;
3087 LOG (GNUNET_ERROR_TYPE_DEBUG, 3087 LOG (GNUNET_ERROR_TYPE_DEBUG,
3088 " sending connection destroy for connection %s\n", 3088 " sending connection destroy for connection %s\n",
3089 GMC_2s (c)); 3089 GCC_2s (c));
3090 3090
3091 if (GNUNET_NO == GMC_is_terminal (c, GNUNET_YES)) 3091 if (GNUNET_NO == GCC_is_terminal (c, GNUNET_YES))
3092 GMC_send_prebuilt_message (&msg.header, 3092 GCC_send_prebuilt_message (&msg.header,
3093 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, 0, 3093 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, 0,
3094 c, GNUNET_YES, GNUNET_YES, NULL, NULL); 3094 c, GNUNET_YES, GNUNET_YES, NULL, NULL);
3095 if (GNUNET_NO == GMC_is_terminal (c, GNUNET_NO)) 3095 if (GNUNET_NO == GCC_is_terminal (c, GNUNET_NO))
3096 GMC_send_prebuilt_message (&msg.header, 3096 GCC_send_prebuilt_message (&msg.header,
3097 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, 0, 3097 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, 0,
3098 c, GNUNET_NO, GNUNET_YES, NULL, NULL); 3098 c, GNUNET_NO, GNUNET_YES, NULL, NULL);
3099 c->destroy = GNUNET_YES; 3099 c->destroy = GNUNET_YES;
@@ -3112,13 +3112,13 @@ GMC_send_destroy (struct CadetConnection *c)
3112 * @param fwd Should we poll in the FWD direction? 3112 * @param fwd Should we poll in the FWD direction?
3113 */ 3113 */
3114void 3114void
3115GMC_start_poll (struct CadetConnection *c, int fwd) 3115GCC_start_poll (struct CadetConnection *c, int fwd)
3116{ 3116{
3117 struct CadetFlowControl *fc; 3117 struct CadetFlowControl *fc;
3118 3118
3119 fc = fwd ? &c->fwd_fc : &c->bck_fc; 3119 fc = fwd ? &c->fwd_fc : &c->bck_fc;
3120 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL %s requested\n", 3120 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL %s requested\n",
3121 GM_f2s (fwd)); 3121 GC_f2s (fwd));
3122 if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task || NULL != fc->poll_msg) 3122 if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task || NULL != fc->poll_msg)
3123 { 3123 {
3124 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** not needed (%u, %p)\n", 3124 LOG (GNUNET_ERROR_TYPE_DEBUG, " *** not needed (%u, %p)\n",
@@ -3141,7 +3141,7 @@ GMC_start_poll (struct CadetConnection *c, int fwd)
3141 * @param fwd Should we stop the poll in the FWD direction? 3141 * @param fwd Should we stop the poll in the FWD direction?
3142 */ 3142 */
3143void 3143void
3144GMC_stop_poll (struct CadetConnection *c, int fwd) 3144GCC_stop_poll (struct CadetConnection *c, int fwd)
3145{ 3145{
3146 struct CadetFlowControl *fc; 3146 struct CadetFlowControl *fc;
3147 3147
@@ -3159,7 +3159,7 @@ GMC_stop_poll (struct CadetConnection *c, int fwd)
3159 * @param c Connection. 3159 * @param c Connection.
3160 */ 3160 */
3161const char * 3161const char *
3162GMC_2s (const struct CadetConnection *c) 3162GCC_2s (const struct CadetConnection *c)
3163{ 3163{
3164 if (NULL == c) 3164 if (NULL == c)
3165 return "NULL"; 3165 return "NULL";
@@ -3169,8 +3169,8 @@ GMC_2s (const struct CadetConnection *c)
3169 static char buf[128]; 3169 static char buf[128];
3170 3170
3171 sprintf (buf, "%s (->%s)", 3171 sprintf (buf, "%s (->%s)",
3172 GNUNET_h2s (GM_h2hc (GMC_get_id (c))), GMT_2s (c->t)); 3172 GNUNET_h2s (GC_h2hc (GCC_get_id (c))), GCT_2s (c->t));
3173 return buf; 3173 return buf;
3174 } 3174 }
3175 return GNUNET_h2s (GM_h2hc (&c->id)); 3175 return GNUNET_h2s (GC_h2hc (&c->id));
3176} 3176}
diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h
index 4e1104c2b..535488260 100644
--- a/src/cadet/gnunet-service-cadet_connection.h
+++ b/src/cadet/gnunet-service-cadet_connection.h
@@ -97,7 +97,7 @@ struct CadetConnectionQueue;
97 * @param fwd Was this a FWD going message? 97 * @param fwd Was this a FWD going message?
98 * @param size Size of the message. 98 * @param size Size of the message.
99 */ 99 */
100typedef void (*GMC_sent) (void *cls, 100typedef void (*GCC_sent) (void *cls,
101 struct CadetConnection *c, 101 struct CadetConnection *c,
102 struct CadetConnectionQueue *q, 102 struct CadetConnectionQueue *q,
103 uint16_t type, int fwd, size_t size); 103 uint16_t type, int fwd, size_t size);
@@ -113,7 +113,7 @@ typedef void (*GMC_sent) (void *cls,
113 * GNUNET_SYSERR to close it (signal serious error) 113 * GNUNET_SYSERR to close it (signal serious error)
114 */ 114 */
115int 115int
116GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, 116GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
117 const struct GNUNET_MessageHeader *message); 117 const struct GNUNET_MessageHeader *message);
118 118
119/** 119/**
@@ -127,7 +127,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
127 * GNUNET_SYSERR to close it (signal serious error) 127 * GNUNET_SYSERR to close it (signal serious error)
128 */ 128 */
129int 129int
130GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer, 130GCC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
131 const struct GNUNET_MessageHeader *message); 131 const struct GNUNET_MessageHeader *message);
132 132
133/** 133/**
@@ -141,7 +141,7 @@ GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
141 * GNUNET_SYSERR to close it (signal serious error) 141 * GNUNET_SYSERR to close it (signal serious error)
142 */ 142 */
143int 143int
144GMC_handle_broken (void* cls, 144GCC_handle_broken (void* cls,
145 const struct GNUNET_PeerIdentity* id, 145 const struct GNUNET_PeerIdentity* id,
146 const struct GNUNET_MessageHeader* message); 146 const struct GNUNET_MessageHeader* message);
147 147
@@ -156,7 +156,7 @@ GMC_handle_broken (void* cls,
156 * GNUNET_SYSERR to close it (signal serious error) 156 * GNUNET_SYSERR to close it (signal serious error)
157 */ 157 */
158int 158int
159GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, 159GCC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
160 const struct GNUNET_MessageHeader *message); 160 const struct GNUNET_MessageHeader *message);
161 161
162/** 162/**
@@ -170,7 +170,7 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
170 * GNUNET_SYSERR to close it (signal serious error) 170 * GNUNET_SYSERR to close it (signal serious error)
171 */ 171 */
172int 172int
173GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer, 173GCC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
174 const struct GNUNET_MessageHeader *message); 174 const struct GNUNET_MessageHeader *message);
175 175
176/** 176/**
@@ -184,7 +184,7 @@ GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
184 * GNUNET_SYSERR to close it (signal serious error) 184 * GNUNET_SYSERR to close it (signal serious error)
185 */ 185 */
186int 186int
187GMC_handle_kx (void *cls, const struct GNUNET_PeerIdentity *peer, 187GCC_handle_kx (void *cls, const struct GNUNET_PeerIdentity *peer,
188 const struct GNUNET_MessageHeader *message); 188 const struct GNUNET_MessageHeader *message);
189 189
190/** 190/**
@@ -198,7 +198,7 @@ GMC_handle_kx (void *cls, const struct GNUNET_PeerIdentity *peer,
198 * GNUNET_SYSERR to close it (signal serious error) 198 * GNUNET_SYSERR to close it (signal serious error)
199 */ 199 */
200int 200int
201GMC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer, 201GCC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
202 const struct GNUNET_MessageHeader *message); 202 const struct GNUNET_MessageHeader *message);
203 203
204/** 204/**
@@ -212,7 +212,7 @@ GMC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
212 * GNUNET_SYSERR to close it (signal serious error) 212 * GNUNET_SYSERR to close it (signal serious error)
213 */ 213 */
214int 214int
215GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer, 215GCC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
216 const struct GNUNET_MessageHeader *message); 216 const struct GNUNET_MessageHeader *message);
217 217
218/** 218/**
@@ -227,7 +227,7 @@ GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
227 * TODO: Check who we got this from, to validate route. 227 * TODO: Check who we got this from, to validate route.
228 */ 228 */
229int 229int
230GMC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer, 230GCC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
231 const struct GNUNET_MessageHeader *message); 231 const struct GNUNET_MessageHeader *message);
232 232
233/** 233/**
@@ -239,7 +239,7 @@ GMC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
239 * @param force Send the ACK even if suboptimal (e.g. requested by POLL). 239 * @param force Send the ACK even if suboptimal (e.g. requested by POLL).
240 */ 240 */
241void 241void
242GMC_send_ack (struct CadetConnection *c, int fwd, int force); 242GCC_send_ack (struct CadetConnection *c, int fwd, int force);
243 243
244/** 244/**
245 * Initialize the connections subsystem 245 * Initialize the connections subsystem
@@ -247,13 +247,13 @@ GMC_send_ack (struct CadetConnection *c, int fwd, int force);
247 * @param c Configuration handle. 247 * @param c Configuration handle.
248 */ 248 */
249void 249void
250GMC_init (const struct GNUNET_CONFIGURATION_Handle *c); 250GCC_init (const struct GNUNET_CONFIGURATION_Handle *c);
251 251
252/** 252/**
253 * Shut down the connections subsystem. 253 * Shut down the connections subsystem.
254 */ 254 */
255void 255void
256GMC_shutdown (void); 256GCC_shutdown (void);
257 257
258/** 258/**
259 * Create a connection. 259 * Create a connection.
@@ -266,7 +266,7 @@ GMC_shutdown (void);
266 * @return Newly created connection, NULL in case of error (own id not in path). 266 * @return Newly created connection, NULL in case of error (own id not in path).
267 */ 267 */
268struct CadetConnection * 268struct CadetConnection *
269GMC_new (const struct GNUNET_CADET_Hash *cid, 269GCC_new (const struct GNUNET_CADET_Hash *cid,
270 struct CadetTunnel3 *t, 270 struct CadetTunnel3 *t,
271 struct CadetPeerPath *p, 271 struct CadetPeerPath *p,
272 unsigned int own_pos); 272 unsigned int own_pos);
@@ -280,7 +280,7 @@ GMC_new (const struct GNUNET_CADET_Hash *cid,
280 * @param c Connection to destroy. 280 * @param c Connection to destroy.
281 */ 281 */
282void 282void
283GMC_destroy (struct CadetConnection *c); 283GCC_destroy (struct CadetConnection *c);
284 284
285/** 285/**
286 * Get the connection ID. 286 * Get the connection ID.
@@ -290,7 +290,7 @@ GMC_destroy (struct CadetConnection *c);
290 * @return ID of the connection. 290 * @return ID of the connection.
291 */ 291 */
292const struct GNUNET_CADET_Hash * 292const struct GNUNET_CADET_Hash *
293GMC_get_id (const struct CadetConnection *c); 293GCC_get_id (const struct CadetConnection *c);
294 294
295 295
296/** 296/**
@@ -301,7 +301,7 @@ GMC_get_id (const struct CadetConnection *c);
301 * @return Hash expanded from the ID of the connection. 301 * @return Hash expanded from the ID of the connection.
302 */ 302 */
303const struct GNUNET_HashCode * 303const struct GNUNET_HashCode *
304GMC_get_h (const struct CadetConnection *c); 304GCC_get_h (const struct CadetConnection *c);
305 305
306 306
307/** 307/**
@@ -312,7 +312,7 @@ GMC_get_h (const struct CadetConnection *c);
312 * @return path used by the connection. 312 * @return path used by the connection.
313 */ 313 */
314const struct CadetPeerPath * 314const struct CadetPeerPath *
315GMC_get_path (const struct CadetConnection *c); 315GCC_get_path (const struct CadetConnection *c);
316 316
317/** 317/**
318 * Get the connection state. 318 * Get the connection state.
@@ -322,7 +322,7 @@ GMC_get_path (const struct CadetConnection *c);
322 * @return state of the connection. 322 * @return state of the connection.
323 */ 323 */
324enum CadetConnectionState 324enum CadetConnectionState
325GMC_get_state (const struct CadetConnection *c); 325GCC_get_state (const struct CadetConnection *c);
326 326
327/** 327/**
328 * Get the connection tunnel. 328 * Get the connection tunnel.
@@ -332,7 +332,7 @@ GMC_get_state (const struct CadetConnection *c);
332 * @return tunnel of the connection. 332 * @return tunnel of the connection.
333 */ 333 */
334struct CadetTunnel3 * 334struct CadetTunnel3 *
335GMC_get_tunnel (const struct CadetConnection *c); 335GCC_get_tunnel (const struct CadetConnection *c);
336 336
337/** 337/**
338 * Get free buffer space in a connection. 338 * Get free buffer space in a connection.
@@ -343,7 +343,7 @@ GMC_get_tunnel (const struct CadetConnection *c);
343 * @return Free buffer space [0 - max_msgs_queue/max_connections] 343 * @return Free buffer space [0 - max_msgs_queue/max_connections]
344 */ 344 */
345unsigned int 345unsigned int
346GMC_get_buffer (struct CadetConnection *c, int fwd); 346GCC_get_buffer (struct CadetConnection *c, int fwd);
347 347
348/** 348/**
349 * Get how many messages have we allowed to send to us from a direction. 349 * Get how many messages have we allowed to send to us from a direction.
@@ -354,7 +354,7 @@ GMC_get_buffer (struct CadetConnection *c, int fwd);
354 * @return last_ack_sent - last_pid_recv 354 * @return last_ack_sent - last_pid_recv
355 */ 355 */
356unsigned int 356unsigned int
357GMC_get_allowed (struct CadetConnection *c, int fwd); 357GCC_get_allowed (struct CadetConnection *c, int fwd);
358 358
359/** 359/**
360 * Get messages queued in a connection. 360 * Get messages queued in a connection.
@@ -365,7 +365,7 @@ GMC_get_allowed (struct CadetConnection *c, int fwd);
365 * @return Number of messages queued. 365 * @return Number of messages queued.
366 */ 366 */
367unsigned int 367unsigned int
368GMC_get_qn (struct CadetConnection *c, int fwd); 368GCC_get_qn (struct CadetConnection *c, int fwd);
369 369
370/** 370/**
371 * Get next PID to use. 371 * Get next PID to use.
@@ -376,7 +376,7 @@ GMC_get_qn (struct CadetConnection *c, int fwd);
376 * @return Last PID used + 1. 376 * @return Last PID used + 1.
377 */ 377 */
378unsigned int 378unsigned int
379GMC_get_pid (struct CadetConnection *c, int fwd); 379GCC_get_pid (struct CadetConnection *c, int fwd);
380 380
381/** 381/**
382 * Allow the connection to advertise a buffer of the given size. 382 * Allow the connection to advertise a buffer of the given size.
@@ -389,7 +389,7 @@ GMC_get_pid (struct CadetConnection *c, int fwd);
389 * @param fwd Is this about FWD traffic? (The ack will go dest->root). 389 * @param fwd Is this about FWD traffic? (The ack will go dest->root).
390 */ 390 */
391void 391void
392GMC_allow (struct CadetConnection *c, unsigned int buffer, int fwd); 392GCC_allow (struct CadetConnection *c, unsigned int buffer, int fwd);
393 393
394/** 394/**
395 * Send FWD keepalive packets for a connection. 395 * Send FWD keepalive packets for a connection.
@@ -398,7 +398,7 @@ GMC_allow (struct CadetConnection *c, unsigned int buffer, int fwd);
398 * @param tc Notification context. 398 * @param tc Notification context.
399 */ 399 */
400void 400void
401GMC_fwd_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 401GCC_fwd_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
402 402
403/** 403/**
404 * Send BCK keepalive packets for a connection. 404 * Send BCK keepalive packets for a connection.
@@ -407,7 +407,7 @@ GMC_fwd_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
407 * @param tc Notification context. 407 * @param tc Notification context.
408 */ 408 */
409void 409void
410GMC_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 410GCC_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
411 411
412 412
413/** 413/**
@@ -418,7 +418,7 @@ GMC_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
418 * @param peer Peer that disconnected. 418 * @param peer Peer that disconnected.
419 */ 419 */
420void 420void
421GMC_notify_broken (struct CadetConnection *c, 421GCC_notify_broken (struct CadetConnection *c,
422 struct CadetPeer *peer); 422 struct CadetPeer *peer);
423 423
424/** 424/**
@@ -430,7 +430,7 @@ GMC_notify_broken (struct CadetConnection *c,
430 * @return #GNUNET_YES if origin, #GNUNET_NO if relay/terminal. 430 * @return #GNUNET_YES if origin, #GNUNET_NO if relay/terminal.
431 */ 431 */
432int 432int
433GMC_is_origin (struct CadetConnection *c, int fwd); 433GCC_is_origin (struct CadetConnection *c, int fwd);
434 434
435/** 435/**
436 * Is this peer the last one on the connection? 436 * Is this peer the last one on the connection?
@@ -442,7 +442,7 @@ GMC_is_origin (struct CadetConnection *c, int fwd);
442 * @return #GNUNET_YES if terminal, #GNUNET_NO if relay/origin. 442 * @return #GNUNET_YES if terminal, #GNUNET_NO if relay/origin.
443 */ 443 */
444int 444int
445GMC_is_terminal (struct CadetConnection *c, int fwd); 445GCC_is_terminal (struct CadetConnection *c, int fwd);
446 446
447/** 447/**
448 * See if we are allowed to send by the next hop in the given direction. 448 * See if we are allowed to send by the next hop in the given direction.
@@ -453,7 +453,7 @@ GMC_is_terminal (struct CadetConnection *c, int fwd);
453 * @return #GNUNET_YES in case it's OK to send. 453 * @return #GNUNET_YES in case it's OK to send.
454 */ 454 */
455int 455int
456GMC_is_sendable (struct CadetConnection *c, int fwd); 456GCC_is_sendable (struct CadetConnection *c, int fwd);
457 457
458/** 458/**
459 * Check if this connection is a direct one (never trim a direct connection). 459 * Check if this connection is a direct one (never trim a direct connection).
@@ -463,7 +463,7 @@ GMC_is_sendable (struct CadetConnection *c, int fwd);
463 * @return #GNUNET_YES in case it's a direct connection, #GNUNET_NO otherwise. 463 * @return #GNUNET_YES in case it's a direct connection, #GNUNET_NO otherwise.
464 */ 464 */
465int 465int
466GMC_is_direct (struct CadetConnection *c); 466GCC_is_direct (struct CadetConnection *c);
467 467
468/** 468/**
469 * Cancel a previously sent message while it's in the queue. 469 * Cancel a previously sent message while it's in the queue.
@@ -475,7 +475,7 @@ GMC_is_direct (struct CadetConnection *c);
475 * @param q Handle to the queue. 475 * @param q Handle to the queue.
476 */ 476 */
477void 477void
478GMC_cancel (struct CadetConnectionQueue *q); 478GCC_cancel (struct CadetConnectionQueue *q);
479 479
480/** 480/**
481 * Sends an already built message on a connection, properly registering 481 * Sends an already built message on a connection, properly registering
@@ -495,10 +495,10 @@ GMC_cancel (struct CadetConnectionQueue *q);
495 * Invalid on @c cont call. 495 * Invalid on @c cont call.
496 */ 496 */
497struct CadetConnectionQueue * 497struct CadetConnectionQueue *
498GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, 498GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
499 uint16_t payload_type, uint32_t payload_id, 499 uint16_t payload_type, uint32_t payload_id,
500 struct CadetConnection *c, int fwd, int force, 500 struct CadetConnection *c, int fwd, int force,
501 GMC_sent cont, void *cont_cls); 501 GCC_sent cont, void *cont_cls);
502 502
503/** 503/**
504 * Sends a CREATE CONNECTION message for a path to a peer. 504 * Sends a CREATE CONNECTION message for a path to a peer.
@@ -507,7 +507,7 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
507 * @param connection Connection to create. 507 * @param connection Connection to create.
508 */ 508 */
509void 509void
510GMC_send_create (struct CadetConnection *connection); 510GCC_send_create (struct CadetConnection *connection);
511 511
512/** 512/**
513 * Send a message to all peers in this connection that the connection 513 * Send a message to all peers in this connection that the connection
@@ -519,7 +519,7 @@ GMC_send_create (struct CadetConnection *connection);
519 * @param c The connection whose peers to notify. 519 * @param c The connection whose peers to notify.
520 */ 520 */
521void 521void
522GMC_send_destroy (struct CadetConnection *c); 522GCC_send_destroy (struct CadetConnection *c);
523 523
524/** 524/**
525 * @brief Start a polling timer for the connection. 525 * @brief Start a polling timer for the connection.
@@ -532,7 +532,7 @@ GMC_send_destroy (struct CadetConnection *c);
532 * @param fwd Should we poll in the FWD direction? 532 * @param fwd Should we poll in the FWD direction?
533 */ 533 */
534void 534void
535GMC_start_poll (struct CadetConnection *c, int fwd); 535GCC_start_poll (struct CadetConnection *c, int fwd);
536 536
537 537
538/** 538/**
@@ -544,7 +544,7 @@ GMC_start_poll (struct CadetConnection *c, int fwd);
544 * @param fwd Should we stop the poll in the FWD direction? 544 * @param fwd Should we stop the poll in the FWD direction?
545 */ 545 */
546void 546void
547GMC_stop_poll (struct CadetConnection *c, int fwd); 547GCC_stop_poll (struct CadetConnection *c, int fwd);
548 548
549/** 549/**
550 * Get a (static) string for a connection. 550 * Get a (static) string for a connection.
@@ -552,7 +552,7 @@ GMC_stop_poll (struct CadetConnection *c, int fwd);
552 * @param c Connection. 552 * @param c Connection.
553 */ 553 */
554const char * 554const char *
555GMC_2s (const struct CadetConnection *c); 555GCC_2s (const struct CadetConnection *c);
556 556
557#if 0 /* keep Emacsens' auto-indent happy */ 557#if 0 /* keep Emacsens' auto-indent happy */
558{ 558{
diff --git a/src/cadet/gnunet-service-cadet_dht.c b/src/cadet/gnunet-service-cadet_dht.c
index b187e3cd9..7d31603df 100644
--- a/src/cadet/gnunet-service-cadet_dht.c
+++ b/src/cadet/gnunet-service-cadet_dht.c
@@ -40,13 +40,13 @@
40/** 40/**
41 * Handle for DHT searches. 41 * Handle for DHT searches.
42 */ 42 */
43struct GMD_search_handle 43struct GCD_search_handle
44{ 44{
45 /** DHT_GET handle. */ 45 /** DHT_GET handle. */
46 struct GNUNET_DHT_GetHandle *dhtget; 46 struct GNUNET_DHT_GetHandle *dhtget;
47 47
48 /** Provided callback to call when a path is found. */ 48 /** Provided callback to call when a path is found. */
49 GMD_search_callback callback; 49 GCD_search_callback callback;
50 50
51 /** Provided closure. */ 51 /** Provided closure. */
52 void *cls; 52 void *cls;
@@ -219,7 +219,7 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
219 unsigned int put_path_length, enum GNUNET_BLOCK_Type type, 219 unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
220 size_t size, const void *data) 220 size_t size, const void *data)
221{ 221{
222 struct GMD_search_handle *h = cls; 222 struct GCD_search_handle *h = cls;
223 struct GNUNET_HELLO_Message *hello; 223 struct GNUNET_HELLO_Message *hello;
224 struct CadetPeerPath *p; 224 struct CadetPeerPath *p;
225 struct CadetPeer *peer; 225 struct CadetPeer *peer;
@@ -230,13 +230,13 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
230 s = path_2s (p); 230 s = path_2s (p);
231 LOG (GNUNET_ERROR_TYPE_INFO, "Got path from DHT: %s\n", s); 231 LOG (GNUNET_ERROR_TYPE_INFO, "Got path from DHT: %s\n", s);
232 GNUNET_free_non_null (s); 232 GNUNET_free_non_null (s);
233 peer = GMP_get_short (p->peers[p->length - 1]); 233 peer = GCP_get_short (p->peers[p->length - 1]);
234 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got HELLO for %s\n", GMP_2s (peer)); 234 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got HELLO for %s\n", GCP_2s (peer));
235 h->callback (h->cls, p); 235 h->callback (h->cls, p);
236 path_destroy (p); 236 path_destroy (p);
237 hello = (struct GNUNET_HELLO_Message *) data; 237 hello = (struct GNUNET_HELLO_Message *) data;
238 GMP_set_hello (peer, hello); 238 GCP_set_hello (peer, hello);
239 GMP_try_connect (peer); 239 GCP_try_connect (peer);
240 return; 240 return;
241} 241}
242 242
@@ -267,7 +267,7 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
267 * - Set data expiration in function of X 267 * - Set data expiration in function of X
268 * - Adapt X to churn 268 * - Adapt X to churn
269 */ 269 */
270 hello = GMH_get_mine (); 270 hello = GCH_get_mine ();
271 if (NULL == hello || (size = GNUNET_HELLO_size (hello)) == 0) 271 if (NULL == hello || (size = GNUNET_HELLO_size (hello)) == 0)
272 { 272 {
273 /* Peerinfo gave us no hello yet, try again in a second. */ 273 /* Peerinfo gave us no hello yet, try again in a second. */
@@ -304,7 +304,7 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
304 * 304 *
305 * @param cls Closure (unused) 305 * @param cls Closure (unused)
306 * @param key Current peer ID. 306 * @param key Current peer ID.
307 * @param value Value in the hash map (GMD_search_handle). 307 * @param value Value in the hash map (GCD_search_handle).
308 * 308 *
309 * @return #GNUNET_YES, we should continue to iterate, 309 * @return #GNUNET_YES, we should continue to iterate,
310 */ 310 */
@@ -313,9 +313,9 @@ stop_get (void *cls,
313 uint32_t key, 313 uint32_t key,
314 void *value) 314 void *value)
315{ 315{
316 struct GMD_search_handle *h = value; 316 struct GCD_search_handle *h = value;
317 317
318 GMD_search_stop (h); 318 GCD_search_stop (h);
319 return GNUNET_YES; 319 return GNUNET_YES;
320} 320}
321 321
@@ -330,7 +330,7 @@ stop_get (void *cls,
330 * @param c Configuration. 330 * @param c Configuration.
331 */ 331 */
332void 332void
333GMD_init (const struct GNUNET_CONFIGURATION_Handle *c) 333GCD_init (const struct GNUNET_CONFIGURATION_Handle *c)
334{ 334{
335 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); 335 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
336 if (GNUNET_OK != 336 if (GNUNET_OK !=
@@ -367,7 +367,7 @@ GMD_init (const struct GNUNET_CONFIGURATION_Handle *c)
367 * Shut down the DHT subsystem. 367 * Shut down the DHT subsystem.
368 */ 368 */
369void 369void
370GMD_shutdown (void) 370GCD_shutdown (void)
371{ 371{
372 GNUNET_CONTAINER_multihashmap32_iterate (get_requests, &stop_get, NULL); 372 GNUNET_CONTAINER_multihashmap32_iterate (get_requests, &stop_get, NULL);
373 GNUNET_CONTAINER_multihashmap32_destroy (get_requests); 373 GNUNET_CONTAINER_multihashmap32_destroy (get_requests);
@@ -383,18 +383,18 @@ GMD_shutdown (void)
383 } 383 }
384} 384}
385 385
386struct GMD_search_handle * 386struct GCD_search_handle *
387GMD_search (const struct GNUNET_PeerIdentity *peer_id, 387GCD_search (const struct GNUNET_PeerIdentity *peer_id,
388 GMD_search_callback callback, void *cls) 388 GCD_search_callback callback, void *cls)
389{ 389{
390 struct GNUNET_HashCode phash; 390 struct GNUNET_HashCode phash;
391 struct GMD_search_handle *h; 391 struct GCD_search_handle *h;
392 392
393 LOG (GNUNET_ERROR_TYPE_DEBUG, 393 LOG (GNUNET_ERROR_TYPE_DEBUG,
394 " Starting DHT GET for peer %s\n", GNUNET_i2s (peer_id)); 394 " Starting DHT GET for peer %s\n", GNUNET_i2s (peer_id));
395 memset (&phash, 0, sizeof (phash)); 395 memset (&phash, 0, sizeof (phash));
396 memcpy (&phash, peer_id, sizeof (*peer_id)); 396 memcpy (&phash, peer_id, sizeof (*peer_id));
397 h = GNUNET_new (struct GMD_search_handle); 397 h = GNUNET_new (struct GCD_search_handle);
398 h->peer_id = GNUNET_PEER_intern (peer_id); 398 h->peer_id = GNUNET_PEER_intern (peer_id);
399 h->callback = callback; 399 h->callback = callback;
400 h->cls = cls; 400 h->cls = cls;
@@ -413,7 +413,7 @@ GMD_search (const struct GNUNET_PeerIdentity *peer_id,
413} 413}
414 414
415void 415void
416GMD_search_stop (struct GMD_search_handle *h) 416GCD_search_stop (struct GCD_search_handle *h)
417{ 417{
418 GNUNET_break (GNUNET_OK == 418 GNUNET_break (GNUNET_OK ==
419 GNUNET_CONTAINER_multihashmap32_remove (get_requests, 419 GNUNET_CONTAINER_multihashmap32_remove (get_requests,
diff --git a/src/cadet/gnunet-service-cadet_dht.h b/src/cadet/gnunet-service-cadet_dht.h
index 6cac531ff..85cb6ea24 100644
--- a/src/cadet/gnunet-service-cadet_dht.h
+++ b/src/cadet/gnunet-service-cadet_dht.h
@@ -40,7 +40,7 @@ extern "C"
40#include "platform.h" 40#include "platform.h"
41#include "gnunet_util_lib.h" 41#include "gnunet_util_lib.h"
42 42
43struct GMD_search_handle; 43struct GCD_search_handle;
44 44
45 45
46/** 46/**
@@ -50,7 +50,7 @@ struct GMD_search_handle;
50 * @param path An unchecked, unoptimized path to the target node. 50 * @param path An unchecked, unoptimized path to the target node.
51 * After callback will no longer be valid! 51 * After callback will no longer be valid!
52 */ 52 */
53typedef void (*GMD_search_callback) (void *cls, 53typedef void (*GCD_search_callback) (void *cls,
54 const struct CadetPeerPath *path); 54 const struct CadetPeerPath *path);
55 55
56/******************************************************************************/ 56/******************************************************************************/
@@ -63,22 +63,22 @@ typedef void (*GMD_search_callback) (void *cls,
63 * @param c Configuration. 63 * @param c Configuration.
64 */ 64 */
65void 65void
66GMD_init (const struct GNUNET_CONFIGURATION_Handle *c); 66GCD_init (const struct GNUNET_CONFIGURATION_Handle *c);
67 67
68/** 68/**
69 * Shut down the DHT subsystem. 69 * Shut down the DHT subsystem.
70 */ 70 */
71void 71void
72GMD_shutdown (void); 72GCD_shutdown (void);
73 73
74 74
75struct GMD_search_handle * 75struct GCD_search_handle *
76GMD_search (const struct GNUNET_PeerIdentity *peer_id, 76GCD_search (const struct GNUNET_PeerIdentity *peer_id,
77 GMD_search_callback callback, void *cls); 77 GCD_search_callback callback, void *cls);
78 78
79 79
80void 80void
81GMD_search_stop (struct GMD_search_handle *h); 81GCD_search_stop (struct GCD_search_handle *h);
82 82
83#if 0 /* keep Emacsens' auto-indent happy */ 83#if 0 /* keep Emacsens' auto-indent happy */
84{ 84{
diff --git a/src/cadet/gnunet-service-cadet_hello.c b/src/cadet/gnunet-service-cadet_hello.c
index 7eda3f507..edb1a96a2 100644
--- a/src/cadet/gnunet-service-cadet_hello.c
+++ b/src/cadet/gnunet-service-cadet_hello.c
@@ -108,12 +108,12 @@ got_hello (void *cls, const struct GNUNET_PeerIdentity *id,
108 LOG (GNUNET_ERROR_TYPE_DEBUG, " hello for %s (%d bytes), expires on %s\n", 108 LOG (GNUNET_ERROR_TYPE_DEBUG, " hello for %s (%d bytes), expires on %s\n",
109 GNUNET_i2s (id), GNUNET_HELLO_size (hello), 109 GNUNET_i2s (id), GNUNET_HELLO_size (hello),
110 GNUNET_STRINGS_absolute_time_to_string (GNUNET_HELLO_get_last_expiration(hello))); 110 GNUNET_STRINGS_absolute_time_to_string (GNUNET_HELLO_get_last_expiration(hello)));
111 peer = GMP_get (id); 111 peer = GCP_get (id);
112 GMP_set_hello (peer, hello); 112 GCP_set_hello (peer, hello);
113 113
114 if (GMP_get_short_id (peer) == myid) 114 if (GCP_get_short_id (peer) == myid)
115 { 115 {
116 mine = GMP_get_hello (peer); 116 mine = GCP_get_hello (peer);
117 LOG (GNUNET_ERROR_TYPE_DEBUG, " updated mine to %p\n", mine); 117 LOG (GNUNET_ERROR_TYPE_DEBUG, " updated mine to %p\n", mine);
118 } 118 }
119} 119}
@@ -129,7 +129,7 @@ got_hello (void *cls, const struct GNUNET_PeerIdentity *id,
129 * @param c Configuration. 129 * @param c Configuration.
130 */ 130 */
131void 131void
132GMH_init (const struct GNUNET_CONFIGURATION_Handle *c) 132GCH_init (const struct GNUNET_CONFIGURATION_Handle *c)
133{ 133{
134 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); 134 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
135 GNUNET_assert (NULL == nc); 135 GNUNET_assert (NULL == nc);
@@ -142,7 +142,7 @@ GMH_init (const struct GNUNET_CONFIGURATION_Handle *c)
142 * Shut down the hello subsystem. 142 * Shut down the hello subsystem.
143 */ 143 */
144void 144void
145GMH_shutdown () 145GCH_shutdown ()
146{ 146{
147 if (NULL != nc) 147 if (NULL != nc)
148 { 148 {
@@ -163,7 +163,7 @@ GMH_shutdown ()
163 * @return Own hello message. 163 * @return Own hello message.
164 */ 164 */
165const struct GNUNET_HELLO_Message * 165const struct GNUNET_HELLO_Message *
166GMH_get_mine (void) 166GCH_get_mine (void)
167{ 167{
168 LOG (GNUNET_ERROR_TYPE_DEBUG, " mine is %p\n", mine); 168 LOG (GNUNET_ERROR_TYPE_DEBUG, " mine is %p\n", mine);
169 return mine; 169 return mine;
@@ -178,9 +178,9 @@ GMH_get_mine (void)
178 * @return Hello message, if any (NULL possible). 178 * @return Hello message, if any (NULL possible).
179 */ 179 */
180const struct GNUNET_HELLO_Message * 180const struct GNUNET_HELLO_Message *
181GMH_get (const struct GNUNET_PeerIdentity *id) 181GCH_get (const struct GNUNET_PeerIdentity *id)
182{ 182{
183 return GMP_get_hello (GMP_get (id)); 183 return GCP_get_hello (GCP_get (id));
184} 184}
185 185
186 186
@@ -190,7 +190,7 @@ GMH_get (const struct GNUNET_PeerIdentity *id)
190 * @param h Hello message. 190 * @param h Hello message.
191 */ 191 */
192char * 192char *
193GMH_2s (const struct GNUNET_HELLO_Message *h) 193GCH_2s (const struct GNUNET_HELLO_Message *h)
194{ 194{
195 return "hello (TODO)"; 195 return "hello (TODO)";
196} 196}
diff --git a/src/cadet/gnunet-service-cadet_hello.h b/src/cadet/gnunet-service-cadet_hello.h
index 8e978ea9d..3e894e197 100644
--- a/src/cadet/gnunet-service-cadet_hello.h
+++ b/src/cadet/gnunet-service-cadet_hello.h
@@ -48,13 +48,13 @@ extern "C"
48 * @param c Configuration. 48 * @param c Configuration.
49 */ 49 */
50void 50void
51GMH_init (const struct GNUNET_CONFIGURATION_Handle *c); 51GCH_init (const struct GNUNET_CONFIGURATION_Handle *c);
52 52
53/** 53/**
54 * Shut down the hello subsystem. 54 * Shut down the hello subsystem.
55 */ 55 */
56void 56void
57GMH_shutdown (); 57GCH_shutdown ();
58 58
59/** 59/**
60 * Get own hello message. 60 * Get own hello message.
@@ -62,7 +62,7 @@ GMH_shutdown ();
62 * @return Own hello message. 62 * @return Own hello message.
63 */ 63 */
64const struct GNUNET_HELLO_Message * 64const struct GNUNET_HELLO_Message *
65GMH_get_mine (void); 65GCH_get_mine (void);
66 66
67#if 0 /* keep Emacsens' auto-indent happy */ 67#if 0 /* keep Emacsens' auto-indent happy */
68{ 68{
diff --git a/src/cadet/gnunet-service-cadet_local.c b/src/cadet/gnunet-service-cadet_local.c
index 96596ce68..9a36aae86 100644
--- a/src/cadet/gnunet-service-cadet_local.c
+++ b/src/cadet/gnunet-service-cadet_local.c
@@ -216,9 +216,9 @@ channel_destroy_iterator (void *cls,
216 216
217 LOG (GNUNET_ERROR_TYPE_DEBUG, 217 LOG (GNUNET_ERROR_TYPE_DEBUG,
218 " Channel %s destroy, due to client %s shutdown.\n", 218 " Channel %s destroy, due to client %s shutdown.\n",
219 GMCH_2s (ch), GML_2s (c)); 219 GCCH_2s (ch), GML_2s (c));
220 220
221 GMCH_handle_local_destroy (ch, c, key < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV); 221 GCCH_handle_local_destroy (ch, c, key < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV);
222 return GNUNET_OK; 222 return GNUNET_OK;
223} 223}
224 224
@@ -383,7 +383,7 @@ handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
383 } 383 }
384 384
385 if (GNUNET_OK != 385 if (GNUNET_OK !=
386 GMCH_handle_local_create (c, 386 GCCH_handle_local_create (c,
387 (struct GNUNET_CADET_ChannelMessage *) message)) 387 (struct GNUNET_CADET_ChannelMessage *) message))
388 { 388 {
389 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 389 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -446,7 +446,7 @@ handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
446 return; 446 return;
447 } 447 }
448 448
449 GMCH_handle_local_destroy (ch, c, chid < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV); 449 GCCH_handle_local_destroy (ch, c, chid < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV);
450 450
451 GNUNET_SERVER_receive_done (client, GNUNET_OK); 451 GNUNET_SERVER_receive_done (client, GNUNET_OK);
452 return; 452 return;
@@ -508,7 +508,7 @@ handle_data (void *cls, struct GNUNET_SERVER_Client *client,
508 } 508 }
509 509
510 if (GNUNET_OK != 510 if (GNUNET_OK !=
511 GMCH_handle_local_data (ch, c, 511 GCCH_handle_local_data (ch, c,
512 (struct GNUNET_MessageHeader *)&msg[1], fwd)) 512 (struct GNUNET_MessageHeader *)&msg[1], fwd))
513 { 513 {
514 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 514 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -573,7 +573,7 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client,
573 /* If client is dest, the ACK is going BCK, therefore this is "FWD ACK" */ 573 /* If client is dest, the ACK is going BCK, therefore this is "FWD ACK" */
574 fwd = chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_SERV; 574 fwd = chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_SERV;
575 575
576 GMCH_handle_local_ack (ch, fwd); 576 GCCH_handle_local_ack (ch, fwd);
577 GNUNET_SERVER_receive_done (client, GNUNET_OK); 577 GNUNET_SERVER_receive_done (client, GNUNET_OK);
578 578
579 return; 579 return;
@@ -602,8 +602,8 @@ get_all_peers_iterator (void *cls,
602 msg.header.size = htons (sizeof (msg)); 602 msg.header.size = htons (sizeof (msg));
603 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS); 603 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS);
604 msg.destination = *peer; 604 msg.destination = *peer;
605 msg.paths = htons (GMP_count_paths (p)); 605 msg.paths = htons (GCP_count_paths (p));
606 msg.tunnel = htons (NULL != GMP_get_tunnel (p)); 606 msg.tunnel = htons (NULL != GCP_get_tunnel (p));
607 607
608 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending info about peer %s\n", 608 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending info about peer %s\n",
609 GNUNET_i2s (peer)); 609 GNUNET_i2s (peer));
@@ -640,7 +640,7 @@ handle_get_peers (void *cls, struct GNUNET_SERVER_Client *client,
640 "Received get peers request from client %u (%p)\n", 640 "Received get peers request from client %u (%p)\n",
641 c->id, client); 641 c->id, client);
642 642
643 GMP_iterate_all (get_all_peers_iterator, client); 643 GCP_iterate_all (get_all_peers_iterator, client);
644 reply.size = htons (sizeof (reply)); 644 reply.size = htons (sizeof (reply));
645 reply.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS); 645 reply.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS);
646 GNUNET_SERVER_notification_context_unicast (nc, client, &reply, GNUNET_NO); 646 GNUNET_SERVER_notification_context_unicast (nc, client, &reply, GNUNET_NO);
@@ -672,10 +672,10 @@ get_all_tunnels_iterator (void *cls,
672 msg.header.size = htons (sizeof (msg)); 672 msg.header.size = htons (sizeof (msg));
673 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS); 673 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS);
674 msg.destination = *peer; 674 msg.destination = *peer;
675 msg.channels = htonl (GMT_count_channels (t)); 675 msg.channels = htonl (GCT_count_channels (t));
676 msg.connections = htonl (GMT_count_connections (t)); 676 msg.connections = htonl (GCT_count_connections (t));
677 msg.cstate = htons ((uint16_t) GMT_get_cstate (t)); 677 msg.cstate = htons ((uint16_t) GCT_get_cstate (t));
678 msg.estate = htons ((uint16_t) GMT_get_estate (t)); 678 msg.estate = htons ((uint16_t) GCT_get_estate (t));
679 679
680 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending info about tunnel ->%s\n", 680 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending info about tunnel ->%s\n",
681 GNUNET_i2s (peer)); 681 GNUNET_i2s (peer));
@@ -712,7 +712,7 @@ handle_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client,
712 "Received get tunnels request from client %u (%p)\n", 712 "Received get tunnels request from client %u (%p)\n",
713 c->id, client); 713 c->id, client);
714 714
715 GMT_iterate_all (get_all_tunnels_iterator, client); 715 GCT_iterate_all (get_all_tunnels_iterator, client);
716 reply.size = htons (sizeof (reply)); 716 reply.size = htons (sizeof (reply));
717 reply.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS); 717 reply.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS);
718 GNUNET_SERVER_notification_context_unicast (nc, client, &reply, GNUNET_NO); 718 GNUNET_SERVER_notification_context_unicast (nc, client, &reply, GNUNET_NO);
@@ -729,7 +729,7 @@ iter_connection (void *cls, struct CadetConnection *c)
729 struct GNUNET_CADET_LocalInfoTunnel *msg = cls; 729 struct GNUNET_CADET_LocalInfoTunnel *msg = cls;
730 struct GNUNET_CADET_Hash *h = (struct GNUNET_CADET_Hash *) &msg[1]; 730 struct GNUNET_CADET_Hash *h = (struct GNUNET_CADET_Hash *) &msg[1];
731 731
732 h[msg->connections] = *(GMC_get_id (c)); 732 h[msg->connections] = *(GCC_get_id (c));
733 msg->connections++; 733 msg->connections++;
734} 734}
735 735
@@ -740,7 +740,7 @@ iter_channel (void *cls, struct CadetChannel *ch)
740 struct GNUNET_HashCode *h = (struct GNUNET_HashCode *) &msg[1]; 740 struct GNUNET_HashCode *h = (struct GNUNET_HashCode *) &msg[1];
741 CADET_ChannelNumber *chn = (CADET_ChannelNumber *) &h[msg->connections]; 741 CADET_ChannelNumber *chn = (CADET_ChannelNumber *) &h[msg->connections];
742 742
743 chn[msg->channels] = GMCH_get_id (ch); 743 chn[msg->channels] = GCCH_get_id (ch);
744 msg->channels++; 744 msg->channels++;
745} 745}
746 746
@@ -777,7 +777,7 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
777 "Received tunnel info request from client %u for tunnel %s\n", 777 "Received tunnel info request from client %u for tunnel %s\n",
778 c->id, GNUNET_i2s_full(&msg->peer)); 778 c->id, GNUNET_i2s_full(&msg->peer));
779 779
780 t = GMP_get_tunnel (GMP_get (&msg->peer)); 780 t = GCP_get_tunnel (GCP_get (&msg->peer));
781 if (NULL == t) 781 if (NULL == t)
782 { 782 {
783 /* We don't know the tunnel */ 783 /* We don't know the tunnel */
@@ -801,8 +801,8 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
801 } 801 }
802 802
803 /* Initialize context */ 803 /* Initialize context */
804 ch_n = GMT_count_channels (t); 804 ch_n = GCT_count_channels (t);
805 c_n = GMT_count_connections (t); 805 c_n = GCT_count_connections (t);
806 806
807 size = sizeof (struct GNUNET_CADET_LocalInfoTunnel); 807 size = sizeof (struct GNUNET_CADET_LocalInfoTunnel);
808 size += c_n * sizeof (struct GNUNET_CADET_Hash); 808 size += c_n * sizeof (struct GNUNET_CADET_Hash);
@@ -811,14 +811,14 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
811 resp = GNUNET_malloc (size); 811 resp = GNUNET_malloc (size);
812 resp->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL); 812 resp->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL);
813 resp->header.size = htons (size); 813 resp->header.size = htons (size);
814 GMT_iterate_connections (t, &iter_connection, resp); 814 GCT_iterate_connections (t, &iter_connection, resp);
815 GMT_iterate_channels (t, &iter_channel, resp); 815 GCT_iterate_channels (t, &iter_channel, resp);
816 /* Do not interleave with iterators, iter_channel needs conn in HBO */ 816 /* Do not interleave with iterators, iter_channel needs conn in HBO */
817 resp->destination = msg->peer; 817 resp->destination = msg->peer;
818 resp->connections = htonl (resp->connections); 818 resp->connections = htonl (resp->connections);
819 resp->channels = htonl (resp->channels); 819 resp->channels = htonl (resp->channels);
820 resp->cstate = htons (GMT_get_cstate (t)); 820 resp->cstate = htons (GCT_get_cstate (t));
821 resp->estate = htons (GMT_get_estate (t)); 821 resp->estate = htons (GCT_get_estate (t));
822 GNUNET_SERVER_notification_context_unicast (nc, c->handle, 822 GNUNET_SERVER_notification_context_unicast (nc, c->handle,
823 &resp->header, GNUNET_NO); 823 &resp->header, GNUNET_NO);
824 GNUNET_free (resp); 824 GNUNET_free (resp);
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index 287d42efe..716165374 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -103,7 +103,7 @@ struct CadetPeerQueue
103 /** 103 /**
104 * Function to call on sending. 104 * Function to call on sending.
105 */ 105 */
106 GMP_sent callback; 106 GCP_sent callback;
107 107
108 /** 108 /**
109 * Closure for callback. 109 * Closure for callback.
@@ -139,7 +139,7 @@ struct CadetPeer
139 /** 139 /**
140 * Handle to stop the DHT search for paths to this peer 140 * Handle to stop the DHT search for paths to this peer
141 */ 141 */
142 struct GMD_search_handle *search_h; 142 struct GCD_search_handle *search_h;
143 143
144 /** 144 /**
145 * Tunnel to this peer, if any. 145 * Tunnel to this peer, if any.
@@ -232,16 +232,16 @@ queue_debug (struct CadetPeer *peer)
232{ 232{
233 struct CadetPeerQueue *q; 233 struct CadetPeerQueue *q;
234 234
235 LOG (GNUNET_ERROR_TYPE_DEBUG, "QQQ Messages queued towards %s\n", GMP_2s (peer)); 235 LOG (GNUNET_ERROR_TYPE_DEBUG, "QQQ Messages queued towards %s\n", GCP_2s (peer));
236 LOG (GNUNET_ERROR_TYPE_DEBUG, "QQQ core tmt rdy: %p\n", peer->core_transmit); 236 LOG (GNUNET_ERROR_TYPE_DEBUG, "QQQ core tmt rdy: %p\n", peer->core_transmit);
237 237
238 for (q = peer->queue_head; NULL != q; q = q->next) 238 for (q = peer->queue_head; NULL != q; q = q->next)
239 { 239 {
240 LOG (GNUNET_ERROR_TYPE_DEBUG, "QQQ - %s %s on %s\n", 240 LOG (GNUNET_ERROR_TYPE_DEBUG, "QQQ - %s %s on %s\n",
241 GM_m2s (q->type), GM_f2s (q->fwd), GMC_2s (q->c)); 241 GC_m2s (q->type), GC_f2s (q->fwd), GCC_2s (q->c));
242 } 242 }
243 243
244 LOG (GNUNET_ERROR_TYPE_DEBUG, "QQQ End queued towards %s\n", GMP_2s (peer)); 244 LOG (GNUNET_ERROR_TYPE_DEBUG, "QQQ End queued towards %s\n", GCP_2s (peer));
245} 245}
246 246
247 247
@@ -269,8 +269,8 @@ notify_broken (void *cls,
269 struct CadetConnection *c = value; 269 struct CadetConnection *c = value;
270 270
271 LOG (GNUNET_ERROR_TYPE_DEBUG, " notifying %s due to %s\n", 271 LOG (GNUNET_ERROR_TYPE_DEBUG, " notifying %s due to %s\n",
272 GMC_2s (c), GMP_2s (peer)); 272 GCC_2s (c), GCP_2s (peer));
273 GMC_notify_broken (c, peer); 273 GCC_notify_broken (c, peer);
274 274
275 return GNUNET_YES; 275 return GNUNET_YES;
276} 276}
@@ -317,7 +317,7 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
317 char own_id[16]; 317 char own_id[16];
318 318
319 strncpy (own_id, GNUNET_i2s (&my_full_id), 15); 319 strncpy (own_id, GNUNET_i2s (&my_full_id), 15);
320 mp = GMP_get (peer); 320 mp = GCP_get (peer);
321 if (myid == mp->id) 321 if (myid == mp->id)
322 { 322 {
323 LOG (GNUNET_ERROR_TYPE_INFO, "CONNECTED %s (self)\n", own_id); 323 LOG (GNUNET_ERROR_TYPE_INFO, "CONNECTED %s (self)\n", own_id);
@@ -334,14 +334,14 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
334 } 334 }
335 path->peers[0] = myid; 335 path->peers[0] = myid;
336 GNUNET_PEER_change_rc (myid, 1); 336 GNUNET_PEER_change_rc (myid, 1);
337 GMP_add_path (mp, path, GNUNET_YES); 337 GCP_add_path (mp, path, GNUNET_YES);
338 338
339 mp->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES); 339 mp->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES);
340 340
341 if (NULL != GMP_get_tunnel (mp) && 341 if (NULL != GCP_get_tunnel (mp) &&
342 0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) 342 0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer))
343 { 343 {
344 GMP_connect (mp); 344 GCP_connect (mp);
345 } 345 }
346 346
347 return; 347 return;
@@ -393,19 +393,19 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
393 * Functions to handle messages from core 393 * Functions to handle messages from core
394 */ 394 */
395static struct GNUNET_CORE_MessageHandler core_handlers[] = { 395static struct GNUNET_CORE_MessageHandler core_handlers[] = {
396 {&GMC_handle_create, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, 0}, 396 {&GCC_handle_create, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, 0},
397 {&GMC_handle_confirm, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK, 397 {&GCC_handle_confirm, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK,
398 sizeof (struct GNUNET_CADET_ConnectionACK)}, 398 sizeof (struct GNUNET_CADET_ConnectionACK)},
399 {&GMC_handle_broken, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 399 {&GCC_handle_broken, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN,
400 sizeof (struct GNUNET_CADET_ConnectionBroken)}, 400 sizeof (struct GNUNET_CADET_ConnectionBroken)},
401 {&GMC_handle_destroy, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, 401 {&GCC_handle_destroy, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY,
402 sizeof (struct GNUNET_CADET_ConnectionDestroy)}, 402 sizeof (struct GNUNET_CADET_ConnectionDestroy)},
403 {&GMC_handle_ack, GNUNET_MESSAGE_TYPE_CADET_ACK, 403 {&GCC_handle_ack, GNUNET_MESSAGE_TYPE_CADET_ACK,
404 sizeof (struct GNUNET_CADET_ACK)}, 404 sizeof (struct GNUNET_CADET_ACK)},
405 {&GMC_handle_poll, GNUNET_MESSAGE_TYPE_CADET_POLL, 405 {&GCC_handle_poll, GNUNET_MESSAGE_TYPE_CADET_POLL,
406 sizeof (struct GNUNET_CADET_Poll)}, 406 sizeof (struct GNUNET_CADET_Poll)},
407 {&GMC_handle_encrypted, GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED, 0}, 407 {&GCC_handle_encrypted, GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED, 0},
408 {&GMC_handle_kx, GNUNET_MESSAGE_TYPE_CADET_KX, 0}, 408 {&GCC_handle_kx, GNUNET_MESSAGE_TYPE_CADET_KX, 0},
409 {NULL, 0, 0} 409 {NULL, 0, 0}
410}; 410};
411 411
@@ -490,7 +490,7 @@ send_core_connection_create (struct CadetConnection *c, size_t size, void *buf)
490{ 490{
491 struct GNUNET_CADET_ConnectionCreate *msg; 491 struct GNUNET_CADET_ConnectionCreate *msg;
492 struct GNUNET_PeerIdentity *peer_ptr; 492 struct GNUNET_PeerIdentity *peer_ptr;
493 const struct CadetPeerPath *p = GMC_get_path (c); 493 const struct CadetPeerPath *p = GCC_get_path (c);
494 size_t size_needed; 494 size_t size_needed;
495 int i; 495 int i;
496 496
@@ -510,7 +510,7 @@ send_core_connection_create (struct CadetConnection *c, size_t size, void *buf)
510 msg = (struct GNUNET_CADET_ConnectionCreate *) buf; 510 msg = (struct GNUNET_CADET_ConnectionCreate *) buf;
511 msg->header.size = htons (size_needed); 511 msg->header.size = htons (size_needed);
512 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); 512 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE);
513 msg->cid = *GMC_get_id (c); 513 msg->cid = *GCC_get_id (c);
514 514
515 peer_ptr = (struct GNUNET_PeerIdentity *) &msg[1]; 515 peer_ptr = (struct GNUNET_PeerIdentity *) &msg[1];
516 for (i = 0; i < p->length; i++) 516 for (i = 0; i < p->length; i++)
@@ -547,7 +547,7 @@ send_core_connection_ack (struct CadetConnection *c, size_t size, void *buf)
547 } 547 }
548 msg->header.size = htons (sizeof (struct GNUNET_CADET_ConnectionACK)); 548 msg->header.size = htons (sizeof (struct GNUNET_CADET_ConnectionACK));
549 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK); 549 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK);
550 msg->cid = *GMC_get_id (c); 550 msg->cid = *GCC_get_id (c);
551 551
552 LOG (GNUNET_ERROR_TYPE_DEBUG, "CONNECTION ACK sent!\n"); 552 LOG (GNUNET_ERROR_TYPE_DEBUG, "CONNECTION ACK sent!\n");
553 return sizeof (struct GNUNET_CADET_ConnectionACK); 553 return sizeof (struct GNUNET_CADET_ConnectionACK);
@@ -579,7 +579,7 @@ get_priority (struct CadetPeerQueue *q)
579 } 579 }
580 580
581 /* Relayed traffic has lower priority, our own traffic has higher */ 581 /* Relayed traffic has lower priority, our own traffic has higher */
582 if (NULL == q->c || GNUNET_NO == GMC_is_origin (q->c, q->fwd)) 582 if (NULL == q->c || GNUNET_NO == GCC_is_origin (q->c, q->fwd))
583 { 583 {
584 low = GNUNET_CORE_PRIO_BEST_EFFORT; 584 low = GNUNET_CORE_PRIO_BEST_EFFORT;
585 high = GNUNET_CORE_PRIO_URGENT; 585 high = GNUNET_CORE_PRIO_URGENT;
@@ -616,7 +616,7 @@ shutdown_tunnel (void *cls,
616 struct CadetTunnel3 *t = p->tunnel; 616 struct CadetTunnel3 *t = p->tunnel;
617 617
618 if (NULL != t) 618 if (NULL != t)
619 GMT_destroy (t); 619 GCT_destroy (t);
620 return GNUNET_YES; 620 return GNUNET_YES;
621} 621}
622 622
@@ -648,7 +648,7 @@ peer_destroy (struct CadetPeer *peer)
648 } 648 }
649 if (NULL != peer->search_h) 649 if (NULL != peer->search_h)
650 { 650 {
651 GMD_search_stop (peer->search_h); 651 GCD_search_stop (peer->search_h);
652 } 652 }
653 p = peer->path_head; 653 p = peer->path_head;
654 while (NULL != p) 654 while (NULL != p)
@@ -658,7 +658,7 @@ peer_destroy (struct CadetPeer *peer)
658 path_destroy (p); 658 path_destroy (p);
659 p = nextp; 659 p = nextp;
660 } 660 }
661 GMT_destroy_empty (peer->tunnel); 661 GCT_destroy_empty (peer->tunnel);
662 GNUNET_free (peer); 662 GNUNET_free (peer);
663 return GNUNET_OK; 663 return GNUNET_OK;
664} 664}
@@ -783,10 +783,10 @@ peer_get_best_path (const struct CadetPeer *peer)
783 { 783 {
784 if (GNUNET_NO == path_is_valid (p)) 784 if (GNUNET_NO == path_is_valid (p))
785 continue; /* Don't use invalid paths. */ 785 continue; /* Don't use invalid paths. */
786 if (GNUNET_YES == GMT_is_path_used (peer->tunnel, p)) 786 if (GNUNET_YES == GCT_is_path_used (peer->tunnel, p))
787 continue; /* If path is already in use, skip it. */ 787 continue; /* If path is already in use, skip it. */
788 788
789 if ((cost = GMT_get_path_cost (peer->tunnel, p)) < best_cost) 789 if ((cost = GCT_get_path_cost (peer->tunnel, p)) < best_cost)
790 { 790 {
791 best_cost = cost; 791 best_cost = cost;
792 best_p = p; 792 best_p = p;
@@ -828,7 +828,7 @@ queue_is_sendable (struct CadetPeerQueue *q)
828 GNUNET_break (0); 828 GNUNET_break (0);
829 } 829 }
830 830
831 return GMC_is_sendable (q->c, q->fwd); 831 return GCC_is_sendable (q->c, q->fwd);
832} 832}
833 833
834 834
@@ -846,7 +846,7 @@ peer_get_first_message (const struct CadetPeer *peer)
846 846
847 for (q = peer->queue_head; NULL != q; q = q->next) 847 for (q = peer->queue_head; NULL != q; q = q->next)
848 { 848 {
849 LOG (GNUNET_ERROR_TYPE_DEBUG, "Checking %p towards %s\n", q, GMC_2s (q->c)); 849 LOG (GNUNET_ERROR_TYPE_DEBUG, "Checking %p towards %s\n", q, GCC_2s (q->c));
850 if (queue_is_sendable (q)) 850 if (queue_is_sendable (q))
851 return q; 851 return q;
852 } 852 }
@@ -869,19 +869,19 @@ search_handler (void *cls, const struct CadetPeerPath *path)
869 struct CadetPeer *peer = cls; 869 struct CadetPeer *peer = cls;
870 unsigned int connection_count; 870 unsigned int connection_count;
871 871
872 GMP_add_path_to_all (path, GNUNET_NO); 872 GCP_add_path_to_all (path, GNUNET_NO);
873 873
874 /* Count connections */ 874 /* Count connections */
875 connection_count = GMT_count_connections (peer->tunnel); 875 connection_count = GCT_count_connections (peer->tunnel);
876 876
877 /* If we already have 3 (or more (?!)) connections, it's enough */ 877 /* If we already have 3 (or more (?!)) connections, it's enough */
878 if (3 <= connection_count) 878 if (3 <= connection_count)
879 return; 879 return;
880 880
881 if (CADET_TUNNEL3_SEARCHING == GMT_get_cstate (peer->tunnel)) 881 if (CADET_TUNNEL3_SEARCHING == GCT_get_cstate (peer->tunnel))
882 { 882 {
883 LOG (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n"); 883 LOG (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n");
884 GMP_connect (peer); 884 GCP_connect (peer);
885 } 885 }
886 return; 886 return;
887} 887}
@@ -910,7 +910,7 @@ queue_send (void *cls, size_t size, void *buf)
910 pid = 0; 910 pid = 0;
911 peer->core_transmit = NULL; 911 peer->core_transmit = NULL;
912 LOG (GNUNET_ERROR_TYPE_DEBUG, "Queue send towards %s (max %u)\n", 912 LOG (GNUNET_ERROR_TYPE_DEBUG, "Queue send towards %s (max %u)\n",
913 GMP_2s (peer), size); 913 GCP_2s (peer), size);
914 914
915 if (NULL == buf || 0 == size) 915 if (NULL == buf || 0 == size)
916 { 916 {
@@ -929,7 +929,7 @@ queue_send (void *cls, size_t size, void *buf)
929 929
930 dst_id = GNUNET_PEER_resolve2 (peer->id); 930 dst_id = GNUNET_PEER_resolve2 (peer->id);
931 LOG (GNUNET_ERROR_TYPE_DEBUG, " on connection %s %s\n", 931 LOG (GNUNET_ERROR_TYPE_DEBUG, " on connection %s %s\n",
932 GMC_2s (c), GM_f2s(queue->fwd)); 932 GCC_2s (c), GC_f2s(queue->fwd));
933 /* Check if buffer size is enough for the message */ 933 /* Check if buffer size is enough for the message */
934 if (queue->size > size) 934 if (queue->size > size)
935 { 935 {
@@ -951,7 +951,7 @@ queue_send (void *cls, size_t size, void *buf)
951 switch (queue->type) 951 switch (queue->type)
952 { 952 {
953 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED: 953 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
954 pid = GMC_get_pid (queue->c, queue->fwd); 954 pid = GCC_get_pid (queue->c, queue->fwd);
955 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload ID %u\n", pid); 955 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload ID %u\n", pid);
956 data_size = send_core_data_raw (queue->cls, size, buf); 956 data_size = send_core_data_raw (queue->cls, size, buf);
957 ((struct GNUNET_CADET_Encrypted *) buf)->pid = htonl (pid); 957 ((struct GNUNET_CADET_Encrypted *) buf)->pid = htonl (pid);
@@ -961,20 +961,20 @@ queue_send (void *cls, size_t size, void *buf)
961 case GNUNET_MESSAGE_TYPE_CADET_KX: 961 case GNUNET_MESSAGE_TYPE_CADET_KX:
962 case GNUNET_MESSAGE_TYPE_CADET_ACK: 962 case GNUNET_MESSAGE_TYPE_CADET_ACK:
963 case GNUNET_MESSAGE_TYPE_CADET_POLL: 963 case GNUNET_MESSAGE_TYPE_CADET_POLL:
964 LOG (GNUNET_ERROR_TYPE_DEBUG, " raw %s\n", GM_m2s (queue->type)); 964 LOG (GNUNET_ERROR_TYPE_DEBUG, " raw %s\n", GC_m2s (queue->type));
965 data_size = send_core_data_raw (queue->cls, size, buf); 965 data_size = send_core_data_raw (queue->cls, size, buf);
966 break; 966 break;
967 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE: 967 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE:
968 LOG (GNUNET_ERROR_TYPE_DEBUG, " path create\n"); 968 LOG (GNUNET_ERROR_TYPE_DEBUG, " path create\n");
969 if (GMC_is_origin (c, GNUNET_YES)) 969 if (GCC_is_origin (c, GNUNET_YES))
970 data_size = send_core_connection_create (queue->c, size, buf); 970 data_size = send_core_connection_create (queue->c, size, buf);
971 else 971 else
972 data_size = send_core_data_raw (queue->cls, size, buf); 972 data_size = send_core_data_raw (queue->cls, size, buf);
973 break; 973 break;
974 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK: 974 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK:
975 LOG (GNUNET_ERROR_TYPE_DEBUG, " path ack\n"); 975 LOG (GNUNET_ERROR_TYPE_DEBUG, " path ack\n");
976 if (GMC_is_origin (c, GNUNET_NO) || 976 if (GCC_is_origin (c, GNUNET_NO) ||
977 GMC_is_origin (c, GNUNET_YES)) 977 GCC_is_origin (c, GNUNET_YES))
978 data_size = send_core_connection_ack (queue->c, size, buf); 978 data_size = send_core_connection_ack (queue->c, size, buf);
979 else 979 else
980 data_size = send_core_data_raw (queue->cls, size, buf); 980 data_size = send_core_data_raw (queue->cls, size, buf);
@@ -996,19 +996,19 @@ queue_send (void *cls, size_t size, void *buf)
996 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 101) < drop_percent) 996 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 101) < drop_percent)
997 { 997 {
998 LOG (GNUNET_ERROR_TYPE_WARNING, "DD %s on connection %s\n", 998 LOG (GNUNET_ERROR_TYPE_WARNING, "DD %s on connection %s\n",
999 GM_m2s (queue->type), GMC_2s (c)); 999 GC_m2s (queue->type), GCC_2s (c));
1000 data_size = 0; 1000 data_size = 0;
1001 } 1001 }
1002 else 1002 else
1003 { 1003 {
1004 LOG (GNUNET_ERROR_TYPE_INFO, 1004 LOG (GNUNET_ERROR_TYPE_INFO,
1005 "snd %s (%s %u) on connection %s (%p) %s (size %u)\n", 1005 "snd %s (%s %u) on connection %s (%p) %s (size %u)\n",
1006 GM_m2s (queue->type), GM_m2s (queue->payload_type), 1006 GC_m2s (queue->type), GC_m2s (queue->payload_type),
1007 queue->payload_type, GMC_2s (c), c, GM_f2s (queue->fwd), data_size); 1007 queue->payload_type, GCC_2s (c), c, GC_f2s (queue->fwd), data_size);
1008 } 1008 }
1009 1009
1010 /* Free queue, but cls was freed by send_core_* */ 1010 /* Free queue, but cls was freed by send_core_* */
1011 GMP_queue_destroy (queue, GNUNET_NO, GNUNET_YES, pid); 1011 GCP_queue_destroy (queue, GNUNET_NO, GNUNET_YES, pid);
1012 1012
1013 /* If more data in queue, send next */ 1013 /* If more data in queue, send next */
1014 queue = peer_get_first_message (peer); 1014 queue = peer_get_first_message (peer);
@@ -1032,11 +1032,11 @@ queue_send (void *cls, size_t size, void *buf)
1032 LOG (GNUNET_ERROR_TYPE_DEBUG, 1032 LOG (GNUNET_ERROR_TYPE_DEBUG,
1033 "* tmt rdy called somewhere else\n"); 1033 "* tmt rdy called somewhere else\n");
1034 } 1034 }
1035// GMC_start_poll (); FIXME needed? 1035// GCC_start_poll (); FIXME needed?
1036 } 1036 }
1037 else 1037 else
1038 { 1038 {
1039// GMC_stop_poll(); FIXME needed? 1039// GCC_stop_poll(); FIXME needed?
1040 } 1040 }
1041 1041
1042 LOG (GNUNET_ERROR_TYPE_DEBUG, " return %d\n", data_size); 1042 LOG (GNUNET_ERROR_TYPE_DEBUG, " return %d\n", data_size);
@@ -1060,7 +1060,7 @@ queue_send (void *cls, size_t size, void *buf)
1060 * @param pid PID, if relevant (was sent and was a payload message). 1060 * @param pid PID, if relevant (was sent and was a payload message).
1061 */ 1061 */
1062void 1062void
1063GMP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls, 1063GCP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
1064 int sent, uint32_t pid) 1064 int sent, uint32_t pid)
1065{ 1065{
1066 struct CadetPeer *peer; 1066 struct CadetPeer *peer;
@@ -1070,7 +1070,7 @@ GMP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
1070 if (GNUNET_YES == clear_cls) 1070 if (GNUNET_YES == clear_cls)
1071 { 1071 {
1072 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue destroy type %s\n", 1072 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue destroy type %s\n",
1073 GM_m2s (queue->type)); 1073 GC_m2s (queue->type));
1074 switch (queue->type) 1074 switch (queue->type)
1075 { 1075 {
1076 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY: 1076 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY:
@@ -1090,7 +1090,7 @@ GMP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
1090 default: 1090 default:
1091 GNUNET_break (0); 1091 GNUNET_break (0);
1092 LOG (GNUNET_ERROR_TYPE_ERROR, " type %s unknown!\n", 1092 LOG (GNUNET_ERROR_TYPE_ERROR, " type %s unknown!\n",
1093 GM_m2s (queue->type)); 1093 GC_m2s (queue->type));
1094 } 1094 }
1095 } 1095 }
1096 GNUNET_CONTAINER_DLL_remove (peer->queue_head, peer->queue_tail, queue); 1096 GNUNET_CONTAINER_DLL_remove (peer->queue_head, peer->queue_tail, queue);
@@ -1137,10 +1137,10 @@ GMP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
1137 * message has been sent and therefore the handle is no longer valid. 1137 * message has been sent and therefore the handle is no longer valid.
1138 */ 1138 */
1139struct CadetPeerQueue * 1139struct CadetPeerQueue *
1140GMP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type, 1140GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1141 uint16_t payload_type, uint32_t payload_id, size_t size, 1141 uint16_t payload_type, uint32_t payload_id, size_t size,
1142 struct CadetConnection *c, int fwd, 1142 struct CadetConnection *c, int fwd,
1143 GMP_sent cont, void *cont_cls) 1143 GCP_sent cont, void *cont_cls)
1144{ 1144{
1145 struct CadetPeerQueue *queue; 1145 struct CadetPeerQueue *queue;
1146 int priority; 1146 int priority;
@@ -1148,13 +1148,13 @@ GMP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1148 1148
1149 LOG (GNUNET_ERROR_TYPE_INFO, 1149 LOG (GNUNET_ERROR_TYPE_INFO,
1150 "que %s (%s %u) on connection %s (%p) %s towards %s (size %u)\n", 1150 "que %s (%s %u) on connection %s (%p) %s towards %s (size %u)\n",
1151 GM_m2s (type), GM_m2s (payload_type), payload_id, 1151 GC_m2s (type), GC_m2s (payload_type), payload_id,
1152 GMC_2s (c), c, GM_f2s (fwd), GMP_2s (peer), size); 1152 GCC_2s (c), c, GC_f2s (fwd), GCP_2s (peer), size);
1153 1153
1154 if (NULL == peer->connections) 1154 if (NULL == peer->connections)
1155 { 1155 {
1156 /* We are not connected to this peer, ignore request. */ 1156 /* We are not connected to this peer, ignore request. */
1157 LOG (GNUNET_ERROR_TYPE_WARNING, "%s not a neighbor\n", GMP_2s (peer)); 1157 LOG (GNUNET_ERROR_TYPE_WARNING, "%s not a neighbor\n", GCP_2s (peer));
1158 GNUNET_STATISTICS_update (stats, "# messages dropped due to wrong hop", 1, 1158 GNUNET_STATISTICS_update (stats, "# messages dropped due to wrong hop", 1,
1159 GNUNET_NO); 1159 GNUNET_NO);
1160 return NULL; 1160 return NULL;
@@ -1170,7 +1170,7 @@ GMP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1170 1170
1171 LOG (GNUNET_ERROR_TYPE_DEBUG, "priority %d\n", priority); 1171 LOG (GNUNET_ERROR_TYPE_DEBUG, "priority %d\n", priority);
1172 1172
1173 call_core = NULL == c ? GNUNET_YES : GMC_is_sendable (c, fwd); 1173 call_core = NULL == c ? GNUNET_YES : GCC_is_sendable (c, fwd);
1174 queue = GNUNET_new (struct CadetPeerQueue); 1174 queue = GNUNET_new (struct CadetPeerQueue);
1175 queue->cls = cls; 1175 queue->cls = cls;
1176 queue->type = type; 1176 queue->type = type;
@@ -1197,7 +1197,7 @@ GMP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1197 { 1197 {
1198 LOG (GNUNET_ERROR_TYPE_DEBUG, 1198 LOG (GNUNET_ERROR_TYPE_DEBUG,
1199 "calling core tmt rdy towards %s for %u bytes\n", 1199 "calling core tmt rdy towards %s for %u bytes\n",
1200 GMP_2s (peer), size); 1200 GCP_2s (peer), size);
1201 peer->core_transmit = 1201 peer->core_transmit =
1202 GNUNET_CORE_notify_transmit_ready (core_handle, 1202 GNUNET_CORE_notify_transmit_ready (core_handle,
1203 GNUNET_NO, get_priority (queue), 1203 GNUNET_NO, get_priority (queue),
@@ -1211,13 +1211,13 @@ GMP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1211 else if (GNUNET_NO == call_core) 1211 else if (GNUNET_NO == call_core)
1212 { 1212 {
1213 LOG (GNUNET_ERROR_TYPE_DEBUG, "core tmt rdy towards %s not needed\n", 1213 LOG (GNUNET_ERROR_TYPE_DEBUG, "core tmt rdy towards %s not needed\n",
1214 GMP_2s (peer)); 1214 GCP_2s (peer));
1215 1215
1216 } 1216 }
1217 else 1217 else
1218 { 1218 {
1219 LOG (GNUNET_ERROR_TYPE_DEBUG, "core tmt rdy towards %s already called\n", 1219 LOG (GNUNET_ERROR_TYPE_DEBUG, "core tmt rdy towards %s already called\n",
1220 GMP_2s (peer)); 1220 GCP_2s (peer));
1221 1221
1222 } 1222 }
1223 queue_debug (peer); 1223 queue_debug (peer);
@@ -1233,7 +1233,7 @@ GMP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1233 * the sent continuation call. 1233 * the sent continuation call.
1234 */ 1234 */
1235void 1235void
1236GMP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c) 1236GCP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c)
1237{ 1237{
1238 struct CadetPeerQueue *q; 1238 struct CadetPeerQueue *q;
1239 struct CadetPeerQueue *next; 1239 struct CadetPeerQueue *next;
@@ -1244,18 +1244,18 @@ GMP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c)
1244 prev = q->prev; 1244 prev = q->prev;
1245 if (q->c == c) 1245 if (q->c == c)
1246 { 1246 {
1247 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMP queue cancel %s\n", GM_m2s (q->type)); 1247 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMP queue cancel %s\n", GC_m2s (q->type));
1248 if (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY != q->type) 1248 if (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY != q->type)
1249 { 1249 {
1250 q->c = NULL; 1250 q->c = NULL;
1251 } 1251 }
1252 else 1252 else
1253 { 1253 {
1254 GMP_queue_destroy (q, GNUNET_YES, GNUNET_NO, 0); 1254 GCP_queue_destroy (q, GNUNET_YES, GNUNET_NO, 0);
1255 } 1255 }
1256 1256
1257 /* Get next from prev, q->next might be already freed: 1257 /* Get next from prev, q->next might be already freed:
1258 * queue destroy -> callback -> GMC_destroy -> cancel_queues -> here 1258 * queue destroy -> callback -> GCC_destroy -> cancel_queues -> here
1259 */ 1259 */
1260 if (NULL == prev) 1260 if (NULL == prev)
1261 next = peer->queue_head; 1261 next = peer->queue_head;
@@ -1316,13 +1316,13 @@ connection_get_first_message (struct CadetPeer *peer, struct CadetConnection *c)
1316 * @return First message for this connection. 1316 * @return First message for this connection.
1317 */ 1317 */
1318struct GNUNET_MessageHeader * 1318struct GNUNET_MessageHeader *
1319GMP_connection_pop (struct CadetPeer *peer, struct CadetConnection *c) 1319GCP_connection_pop (struct CadetPeer *peer, struct CadetConnection *c)
1320{ 1320{
1321 struct CadetPeerQueue *q; 1321 struct CadetPeerQueue *q;
1322 struct CadetPeerQueue *next; 1322 struct CadetPeerQueue *next;
1323 struct GNUNET_MessageHeader *msg; 1323 struct GNUNET_MessageHeader *msg;
1324 1324
1325 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection pop on %s\n", GMC_2s (c)); 1325 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection pop on %s\n", GCC_2s (c));
1326 for (q = peer->queue_head; NULL != q; q = next) 1326 for (q = peer->queue_head; NULL != q; q = next)
1327 { 1327 {
1328 next = q->next; 1328 next = q->next;
@@ -1336,13 +1336,13 @@ GMP_connection_pop (struct CadetPeer *peer, struct CadetConnection *c)
1336 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN: 1336 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN:
1337 case GNUNET_MESSAGE_TYPE_CADET_ACK: 1337 case GNUNET_MESSAGE_TYPE_CADET_ACK:
1338 case GNUNET_MESSAGE_TYPE_CADET_POLL: 1338 case GNUNET_MESSAGE_TYPE_CADET_POLL:
1339 GMP_queue_destroy (q, GNUNET_YES, GNUNET_NO, 0); 1339 GCP_queue_destroy (q, GNUNET_YES, GNUNET_NO, 0);
1340 continue; 1340 continue;
1341 1341
1342 case GNUNET_MESSAGE_TYPE_CADET_KX: 1342 case GNUNET_MESSAGE_TYPE_CADET_KX:
1343 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED: 1343 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
1344 msg = (struct GNUNET_MessageHeader *) q->cls; 1344 msg = (struct GNUNET_MessageHeader *) q->cls;
1345 GMP_queue_destroy (q, GNUNET_NO, GNUNET_NO, 0); 1345 GCP_queue_destroy (q, GNUNET_NO, GNUNET_NO, 0);
1346 return msg; 1346 return msg;
1347 1347
1348 default: 1348 default:
@@ -1355,7 +1355,7 @@ GMP_connection_pop (struct CadetPeer *peer, struct CadetConnection *c)
1355 1355
1356 1356
1357void 1357void
1358GMP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c) 1358GCP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c)
1359{ 1359{
1360 struct CadetPeerQueue *q; 1360 struct CadetPeerQueue *q;
1361 size_t size; 1361 size_t size;
@@ -1391,7 +1391,7 @@ GMP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c)
1391 * @param c Configuration. 1391 * @param c Configuration.
1392 */ 1392 */
1393void 1393void
1394GMP_init (const struct GNUNET_CONFIGURATION_Handle *c) 1394GCP_init (const struct GNUNET_CONFIGURATION_Handle *c)
1395{ 1395{
1396 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); 1396 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
1397 peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); 1397 peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
@@ -1460,7 +1460,7 @@ GMP_init (const struct GNUNET_CONFIGURATION_Handle *c)
1460 * Shut down the peer subsystem. 1460 * Shut down the peer subsystem.
1461 */ 1461 */
1462void 1462void
1463GMP_shutdown (void) 1463GCP_shutdown (void)
1464{ 1464{
1465 GNUNET_CONTAINER_multipeermap_iterate (peers, &shutdown_tunnel, NULL); 1465 GNUNET_CONTAINER_multipeermap_iterate (peers, &shutdown_tunnel, NULL);
1466 1466
@@ -1486,7 +1486,7 @@ GMP_shutdown (void)
1486 * @return Existing or newly created peer structure. 1486 * @return Existing or newly created peer structure.
1487 */ 1487 */
1488struct CadetPeer * 1488struct CadetPeer *
1489GMP_get (const struct GNUNET_PeerIdentity *peer_id) 1489GCP_get (const struct GNUNET_PeerIdentity *peer_id)
1490{ 1490{
1491 struct CadetPeer *peer; 1491 struct CadetPeer *peer;
1492 1492
@@ -1517,9 +1517,9 @@ GMP_get (const struct GNUNET_PeerIdentity *peer_id)
1517 * @return Existing or newly created peer structure. 1517 * @return Existing or newly created peer structure.
1518 */ 1518 */
1519struct CadetPeer * 1519struct CadetPeer *
1520GMP_get_short (const GNUNET_PEER_Id peer) 1520GCP_get_short (const GNUNET_PEER_Id peer)
1521{ 1521{
1522 return GMP_get (GNUNET_PEER_resolve2 (peer)); 1522 return GCP_get (GNUNET_PEER_resolve2 (peer));
1523} 1523}
1524 1524
1525 1525
@@ -1550,17 +1550,17 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1550 * @param peer Peer to connect to. 1550 * @param peer Peer to connect to.
1551 */ 1551 */
1552void 1552void
1553GMP_connect (struct CadetPeer *peer) 1553GCP_connect (struct CadetPeer *peer)
1554{ 1554{
1555 struct CadetTunnel3 *t; 1555 struct CadetTunnel3 *t;
1556 struct CadetPeerPath *p; 1556 struct CadetPeerPath *p;
1557 struct CadetConnection *c; 1557 struct CadetConnection *c;
1558 int rerun_search; 1558 int rerun_search;
1559 1559
1560 LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GMP_2s (peer)); 1560 LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GCP_2s (peer));
1561 1561
1562 /* If we have a current hello, try to connect using it. */ 1562 /* If we have a current hello, try to connect using it. */
1563 GMP_try_connect (peer); 1563 GCP_try_connect (peer);
1564 1564
1565 t = peer->tunnel; 1565 t = peer->tunnel;
1566 c = NULL; 1566 c = NULL;
@@ -1578,7 +1578,7 @@ GMP_connect (struct CadetPeer *peer)
1578 LOG (GNUNET_ERROR_TYPE_DEBUG, " path to use: %s\n", s); 1578 LOG (GNUNET_ERROR_TYPE_DEBUG, " path to use: %s\n", s);
1579 GNUNET_free (s); 1579 GNUNET_free (s);
1580 1580
1581 c = GMT_use_path (t, p); 1581 c = GCT_use_path (t, p);
1582 if (NULL == c) 1582 if (NULL == c)
1583 { 1583 {
1584 /* This case can happen when the path includes a first hop that is 1584 /* This case can happen when the path includes a first hop that is
@@ -1593,14 +1593,14 @@ GMP_connect (struct CadetPeer *peer)
1593 * 1593 *
1594 * Re-running the DHT GET should give core time to callback. 1594 * Re-running the DHT GET should give core time to callback.
1595 * 1595 *
1596 * GMT_use_path -> GMC_new -> register_neighbors takes care of 1596 * GCT_use_path -> GCC_new -> register_neighbors takes care of
1597 * updating statistics about this issue. 1597 * updating statistics about this issue.
1598 */ 1598 */
1599 rerun_search = GNUNET_YES; 1599 rerun_search = GNUNET_YES;
1600 } 1600 }
1601 else 1601 else
1602 { 1602 {
1603 GMC_send_create (c); 1603 GCC_send_create (c);
1604 return; 1604 return;
1605 } 1605 }
1606 } 1606 }
@@ -1612,11 +1612,11 @@ GMP_connect (struct CadetPeer *peer)
1612 1612
1613 if (NULL != peer->search_h && GNUNET_YES == rerun_search) 1613 if (NULL != peer->search_h && GNUNET_YES == rerun_search)
1614 { 1614 {
1615 GMD_search_stop (peer->search_h); 1615 GCD_search_stop (peer->search_h);
1616 peer->search_h = NULL; 1616 peer->search_h = NULL;
1617 LOG (GNUNET_ERROR_TYPE_DEBUG, 1617 LOG (GNUNET_ERROR_TYPE_DEBUG,
1618 " Stopping DHT GET for peer %s\n", 1618 " Stopping DHT GET for peer %s\n",
1619 GMP_2s (peer)); 1619 GCP_2s (peer));
1620 } 1620 }
1621 1621
1622 if (NULL == peer->search_h) 1622 if (NULL == peer->search_h)
@@ -1625,10 +1625,10 @@ GMP_connect (struct CadetPeer *peer)
1625 1625
1626 id = GNUNET_PEER_resolve2 (peer->id); 1626 id = GNUNET_PEER_resolve2 (peer->id);
1627 LOG (GNUNET_ERROR_TYPE_DEBUG, 1627 LOG (GNUNET_ERROR_TYPE_DEBUG,
1628 " Starting DHT GET for peer %s\n", GMP_2s (peer)); 1628 " Starting DHT GET for peer %s\n", GCP_2s (peer));
1629 peer->search_h = GMD_search (id, &search_handler, peer); 1629 peer->search_h = GCD_search (id, &search_handler, peer);
1630 if (CADET_TUNNEL3_NEW == GMT_get_cstate (t)) 1630 if (CADET_TUNNEL3_NEW == GCT_get_cstate (t))
1631 GMT_change_cstate (t, CADET_TUNNEL3_SEARCHING); 1631 GCT_change_cstate (t, CADET_TUNNEL3_SEARCHING);
1632 } 1632 }
1633} 1633}
1634 1634
@@ -1641,7 +1641,7 @@ GMP_connect (struct CadetPeer *peer)
1641 * @return #GNUNET_YES if there is a direct connection. 1641 * @return #GNUNET_YES if there is a direct connection.
1642 */ 1642 */
1643int 1643int
1644GMP_is_neighbor (const struct CadetPeer *peer) 1644GCP_is_neighbor (const struct CadetPeer *peer)
1645{ 1645{
1646 struct CadetPeerPath *path; 1646 struct CadetPeerPath *path;
1647 1647
@@ -1668,11 +1668,11 @@ GMP_is_neighbor (const struct CadetPeer *peer)
1668 * @param peer Peer towards which to create the tunnel. 1668 * @param peer Peer towards which to create the tunnel.
1669 */ 1669 */
1670void 1670void
1671GMP_add_tunnel (struct CadetPeer *peer) 1671GCP_add_tunnel (struct CadetPeer *peer)
1672{ 1672{
1673 if (NULL != peer->tunnel) 1673 if (NULL != peer->tunnel)
1674 return; 1674 return;
1675 peer->tunnel = GMT_new (peer); 1675 peer->tunnel = GCT_new (peer);
1676} 1676}
1677 1677
1678 1678
@@ -1689,26 +1689,26 @@ GMP_add_tunnel (struct CadetPeer *peer)
1689 * @return GNUNET_OK on success. 1689 * @return GNUNET_OK on success.
1690 */ 1690 */
1691int 1691int
1692GMP_add_connection (struct CadetPeer *peer, 1692GCP_add_connection (struct CadetPeer *peer,
1693 struct CadetConnection *c) 1693 struct CadetConnection *c)
1694{ 1694{
1695 int result; 1695 int result;
1696 LOG (GNUNET_ERROR_TYPE_DEBUG, "adding connection %s\n", GMC_2s (c)); 1696 LOG (GNUNET_ERROR_TYPE_DEBUG, "adding connection %s\n", GCC_2s (c));
1697 LOG (GNUNET_ERROR_TYPE_DEBUG, "to peer %s\n", GMP_2s (peer)); 1697 LOG (GNUNET_ERROR_TYPE_DEBUG, "to peer %s\n", GCP_2s (peer));
1698 1698
1699 if (NULL == peer->connections) 1699 if (NULL == peer->connections)
1700 { 1700 {
1701 GNUNET_break (0); 1701 GNUNET_break (0);
1702 LOG (GNUNET_ERROR_TYPE_DEBUG, 1702 LOG (GNUNET_ERROR_TYPE_DEBUG,
1703 "Peer %s is not a neighbor!\n", 1703 "Peer %s is not a neighbor!\n",
1704 GMP_2s (peer)); 1704 GCP_2s (peer));
1705 return GNUNET_SYSERR; 1705 return GNUNET_SYSERR;
1706 } 1706 }
1707 LOG (GNUNET_ERROR_TYPE_DEBUG, 1707 LOG (GNUNET_ERROR_TYPE_DEBUG,
1708 "peer %s ok, has %u connections.\n", 1708 "peer %s ok, has %u connections.\n",
1709 GMP_2s (peer), GNUNET_CONTAINER_multihashmap_size (peer->connections)); 1709 GCP_2s (peer), GNUNET_CONTAINER_multihashmap_size (peer->connections));
1710 result = GNUNET_CONTAINER_multihashmap_put (peer->connections, 1710 result = GNUNET_CONTAINER_multihashmap_put (peer->connections,
1711 GMC_get_h (c), 1711 GCC_get_h (c),
1712 c, 1712 c,
1713 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1713 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1714 LOG (GNUNET_ERROR_TYPE_DEBUG, 1714 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1733,7 +1733,7 @@ GMP_add_connection (struct CadetPeer *peer,
1733 * NULL on error. 1733 * NULL on error.
1734 */ 1734 */
1735struct CadetPeerPath * 1735struct CadetPeerPath *
1736GMP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path, 1736GCP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path,
1737 int trusted) 1737 int trusted)
1738{ 1738{
1739 struct CadetPeerPath *aux; 1739 struct CadetPeerPath *aux;
@@ -1741,7 +1741,7 @@ GMP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path,
1741 unsigned int l2; 1741 unsigned int l2;
1742 1742
1743 LOG (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n", 1743 LOG (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n",
1744 path->length, GMP_2s (peer)); 1744 path->length, GCP_2s (peer));
1745 1745
1746 if ((NULL == peer) || (NULL == path)) 1746 if ((NULL == peer) || (NULL == path))
1747 { 1747 {
@@ -1797,9 +1797,9 @@ GMP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path,
1797 LOG (GNUNET_ERROR_TYPE_DEBUG, " added\n"); 1797 LOG (GNUNET_ERROR_TYPE_DEBUG, " added\n");
1798 GNUNET_CONTAINER_DLL_insert_before (peer->path_head, 1798 GNUNET_CONTAINER_DLL_insert_before (peer->path_head,
1799 peer->path_tail, aux, path); 1799 peer->path_tail, aux, path);
1800 if (NULL != peer->tunnel && 3 < GMT_count_connections (peer->tunnel)) 1800 if (NULL != peer->tunnel && 3 < GCT_count_connections (peer->tunnel))
1801 { 1801 {
1802 GMP_connect (peer); 1802 GCP_connect (peer);
1803 } 1803 }
1804 return path; 1804 return path;
1805 } 1805 }
@@ -1816,9 +1816,9 @@ GMP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path,
1816 GNUNET_CONTAINER_DLL_insert_tail (peer->path_head, peer->path_tail, 1816 GNUNET_CONTAINER_DLL_insert_tail (peer->path_head, peer->path_tail,
1817 path); 1817 path);
1818 LOG (GNUNET_ERROR_TYPE_DEBUG, " added last\n"); 1818 LOG (GNUNET_ERROR_TYPE_DEBUG, " added last\n");
1819 if (NULL != peer->tunnel && 3 < GMT_count_connections (peer->tunnel)) 1819 if (NULL != peer->tunnel && 3 < GCT_count_connections (peer->tunnel))
1820 { 1820 {
1821 GMP_connect (peer); 1821 GCP_connect (peer);
1822 } 1822 }
1823 return path; 1823 return path;
1824} 1824}
@@ -1839,14 +1839,14 @@ GMP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path,
1839 * NULL on error. 1839 * NULL on error.
1840 */ 1840 */
1841struct CadetPeerPath * 1841struct CadetPeerPath *
1842GMP_add_path_to_origin (struct CadetPeer *peer, 1842GCP_add_path_to_origin (struct CadetPeer *peer,
1843 struct CadetPeerPath *path, 1843 struct CadetPeerPath *path,
1844 int trusted) 1844 int trusted)
1845{ 1845{
1846 if (NULL == path) 1846 if (NULL == path)
1847 return NULL; 1847 return NULL;
1848 path_invert (path); 1848 path_invert (path);
1849 return GMP_add_path (peer, path, trusted); 1849 return GCP_add_path (peer, path, trusted);
1850} 1850}
1851 1851
1852 1852
@@ -1857,7 +1857,7 @@ GMP_add_path_to_origin (struct CadetPeer *peer,
1857 * @param confirmed Whether we know if the path works or not. 1857 * @param confirmed Whether we know if the path works or not.
1858 */ 1858 */
1859void 1859void
1860GMP_add_path_to_all (const struct CadetPeerPath *p, int confirmed) 1860GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed)
1861{ 1861{
1862 unsigned int i; 1862 unsigned int i;
1863 1863
@@ -1868,10 +1868,10 @@ GMP_add_path_to_all (const struct CadetPeerPath *p, int confirmed)
1868 struct CadetPeer *aux; 1868 struct CadetPeer *aux;
1869 struct CadetPeerPath *copy; 1869 struct CadetPeerPath *copy;
1870 1870
1871 aux = GMP_get_short (p->peers[i]); 1871 aux = GCP_get_short (p->peers[i]);
1872 copy = path_duplicate (p); 1872 copy = path_duplicate (p);
1873 copy->length = i + 1; 1873 copy->length = i + 1;
1874 GMP_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed); 1874 GCP_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed);
1875 } 1875 }
1876} 1876}
1877 1877
@@ -1883,7 +1883,7 @@ GMP_add_path_to_all (const struct CadetPeerPath *p, int confirmed)
1883 * @param path Path to remove. Is always destroyed . 1883 * @param path Path to remove. Is always destroyed .
1884 */ 1884 */
1885void 1885void
1886GMP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path) 1886GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path)
1887{ 1887{
1888 struct CadetPeerPath *iter; 1888 struct CadetPeerPath *iter;
1889 struct CadetPeerPath *next; 1889 struct CadetPeerPath *next;
@@ -1915,25 +1915,25 @@ GMP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path)
1915 * @return GNUNET_OK on success. 1915 * @return GNUNET_OK on success.
1916 */ 1916 */
1917int 1917int
1918GMP_remove_connection (struct CadetPeer *peer, 1918GCP_remove_connection (struct CadetPeer *peer,
1919 const struct CadetConnection *c) 1919 const struct CadetConnection *c)
1920{ 1920{
1921 LOG (GNUNET_ERROR_TYPE_DEBUG, "removing connection %s\n", GMC_2s (c)); 1921 LOG (GNUNET_ERROR_TYPE_DEBUG, "removing connection %s\n", GCC_2s (c));
1922 LOG (GNUNET_ERROR_TYPE_DEBUG, "from peer %s\n", GMP_2s (peer)); 1922 LOG (GNUNET_ERROR_TYPE_DEBUG, "from peer %s\n", GCP_2s (peer));
1923 1923
1924 if (NULL == peer || NULL == peer->connections) 1924 if (NULL == peer || NULL == peer->connections)
1925 { 1925 {
1926 LOG (GNUNET_ERROR_TYPE_DEBUG, 1926 LOG (GNUNET_ERROR_TYPE_DEBUG,
1927 "Peer %s is not a neighbor!\n", 1927 "Peer %s is not a neighbor!\n",
1928 GMP_2s (peer)); 1928 GCP_2s (peer));
1929 return GNUNET_SYSERR; 1929 return GNUNET_SYSERR;
1930 } 1930 }
1931 LOG (GNUNET_ERROR_TYPE_DEBUG, 1931 LOG (GNUNET_ERROR_TYPE_DEBUG,
1932 "peer %s ok, has %u connections.\n", 1932 "peer %s ok, has %u connections.\n",
1933 GMP_2s (peer), GNUNET_CONTAINER_multihashmap_size (peer->connections)); 1933 GCP_2s (peer), GNUNET_CONTAINER_multihashmap_size (peer->connections));
1934 1934
1935 return GNUNET_CONTAINER_multihashmap_remove (peer->connections, 1935 return GNUNET_CONTAINER_multihashmap_remove (peer->connections,
1936 GMC_get_h (c), 1936 GCC_get_h (c),
1937 c); 1937 c);
1938} 1938}
1939 1939
@@ -1944,7 +1944,7 @@ GMP_remove_connection (struct CadetPeer *peer,
1944 * @param peer Destination peer. 1944 * @param peer Destination peer.
1945 */ 1945 */
1946void 1946void
1947GMP_start_search (struct CadetPeer *peer) 1947GCP_start_search (struct CadetPeer *peer)
1948{ 1948{
1949 if (NULL != peer->search_h) 1949 if (NULL != peer->search_h)
1950 { 1950 {
@@ -1952,7 +1952,7 @@ GMP_start_search (struct CadetPeer *peer)
1952 return; 1952 return;
1953 } 1953 }
1954 1954
1955 peer->search_h = GMD_search (GMP_get_id (peer), &search_handler, peer); 1955 peer->search_h = GCD_search (GCP_get_id (peer), &search_handler, peer);
1956} 1956}
1957 1957
1958 1958
@@ -1963,14 +1963,14 @@ GMP_start_search (struct CadetPeer *peer)
1963 * @param peer Destination peer. 1963 * @param peer Destination peer.
1964 */ 1964 */
1965void 1965void
1966GMP_stop_search (struct CadetPeer *peer) 1966GCP_stop_search (struct CadetPeer *peer)
1967{ 1967{
1968 if (NULL == peer->search_h) 1968 if (NULL == peer->search_h)
1969 { 1969 {
1970 return; 1970 return;
1971 } 1971 }
1972 1972
1973 GMD_search_stop (peer->search_h); 1973 GCD_search_stop (peer->search_h);
1974 peer->search_h = NULL; 1974 peer->search_h = NULL;
1975} 1975}
1976 1976
@@ -1983,7 +1983,7 @@ GMP_stop_search (struct CadetPeer *peer)
1983 * @return Full ID of peer. 1983 * @return Full ID of peer.
1984 */ 1984 */
1985const struct GNUNET_PeerIdentity * 1985const struct GNUNET_PeerIdentity *
1986GMP_get_id (const struct CadetPeer *peer) 1986GCP_get_id (const struct CadetPeer *peer)
1987{ 1987{
1988 return GNUNET_PEER_resolve2 (peer->id); 1988 return GNUNET_PEER_resolve2 (peer->id);
1989} 1989}
@@ -1997,7 +1997,7 @@ GMP_get_id (const struct CadetPeer *peer)
1997 * @return Short ID of peer. 1997 * @return Short ID of peer.
1998 */ 1998 */
1999GNUNET_PEER_Id 1999GNUNET_PEER_Id
2000GMP_get_short_id (const struct CadetPeer *peer) 2000GCP_get_short_id (const struct CadetPeer *peer)
2001{ 2001{
2002 return peer->id; 2002 return peer->id;
2003} 2003}
@@ -2010,12 +2010,12 @@ GMP_get_short_id (const struct CadetPeer *peer)
2010 * @param t Tunnel. 2010 * @param t Tunnel.
2011 */ 2011 */
2012void 2012void
2013GMP_set_tunnel (struct CadetPeer *peer, struct CadetTunnel3 *t) 2013GCP_set_tunnel (struct CadetPeer *peer, struct CadetTunnel3 *t)
2014{ 2014{
2015 peer->tunnel = t; 2015 peer->tunnel = t;
2016 if (NULL == t && NULL != peer->search_h) 2016 if (NULL == t && NULL != peer->search_h)
2017 { 2017 {
2018 GMP_stop_search (peer); 2018 GCP_stop_search (peer);
2019 } 2019 }
2020} 2020}
2021 2021
@@ -2028,7 +2028,7 @@ GMP_set_tunnel (struct CadetPeer *peer, struct CadetTunnel3 *t)
2028 * @return Tunnel towards peer. 2028 * @return Tunnel towards peer.
2029 */ 2029 */
2030struct CadetTunnel3 * 2030struct CadetTunnel3 *
2031GMP_get_tunnel (const struct CadetPeer *peer) 2031GCP_get_tunnel (const struct CadetPeer *peer)
2032{ 2032{
2033 return peer->tunnel; 2033 return peer->tunnel;
2034} 2034}
@@ -2041,16 +2041,16 @@ GMP_get_tunnel (const struct CadetPeer *peer)
2041 * @param hello Hello message. 2041 * @param hello Hello message.
2042 */ 2042 */
2043void 2043void
2044GMP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello) 2044GCP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello)
2045{ 2045{
2046 struct GNUNET_HELLO_Message *old; 2046 struct GNUNET_HELLO_Message *old;
2047 size_t size; 2047 size_t size;
2048 2048
2049 LOG (GNUNET_ERROR_TYPE_DEBUG, "set hello for %s\n", GMP_2s (peer)); 2049 LOG (GNUNET_ERROR_TYPE_DEBUG, "set hello for %s\n", GCP_2s (peer));
2050 if (NULL == hello) 2050 if (NULL == hello)
2051 return; 2051 return;
2052 2052
2053 old = GMP_get_hello (peer); 2053 old = GCP_get_hello (peer);
2054 if (NULL == old) 2054 if (NULL == old)
2055 { 2055 {
2056 size = GNUNET_HELLO_size (hello); 2056 size = GNUNET_HELLO_size (hello);
@@ -2076,7 +2076,7 @@ GMP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello)
2076 * @return Hello message. 2076 * @return Hello message.
2077 */ 2077 */
2078struct GNUNET_HELLO_Message * 2078struct GNUNET_HELLO_Message *
2079GMP_get_hello (struct CadetPeer *peer) 2079GCP_get_hello (struct CadetPeer *peer)
2080{ 2080{
2081 struct GNUNET_TIME_Absolute expiration; 2081 struct GNUNET_TIME_Absolute expiration;
2082 struct GNUNET_TIME_Relative remaining; 2082 struct GNUNET_TIME_Relative remaining;
@@ -2103,7 +2103,7 @@ GMP_get_hello (struct CadetPeer *peer)
2103 * @param peer Peer to whom to connect. 2103 * @param peer Peer to whom to connect.
2104 */ 2104 */
2105void 2105void
2106GMP_try_connect (struct CadetPeer *peer) 2106GCP_try_connect (struct CadetPeer *peer)
2107{ 2107{
2108 struct GNUNET_HELLO_Message *hello; 2108 struct GNUNET_HELLO_Message *hello;
2109 struct GNUNET_MessageHeader *mh; 2109 struct GNUNET_MessageHeader *mh;
@@ -2111,7 +2111,7 @@ GMP_try_connect (struct CadetPeer *peer)
2111 if (NULL == transport_handle) 2111 if (NULL == transport_handle)
2112 return; 2112 return;
2113 2113
2114 hello = GMP_get_hello (peer); 2114 hello = GCP_get_hello (peer);
2115 if (NULL == hello) 2115 if (NULL == hello)
2116 return; 2116 return;
2117 2117
@@ -2129,7 +2129,7 @@ GMP_try_connect (struct CadetPeer *peer)
2129 * @param peer2 Peer whose link is broken. 2129 * @param peer2 Peer whose link is broken.
2130 */ 2130 */
2131void 2131void
2132GMP_notify_broken_link (struct CadetPeer *peer, 2132GCP_notify_broken_link (struct CadetPeer *peer,
2133 struct GNUNET_PeerIdentity *peer1, 2133 struct GNUNET_PeerIdentity *peer1,
2134 struct GNUNET_PeerIdentity *peer2) 2134 struct GNUNET_PeerIdentity *peer2)
2135{ 2135{
@@ -2178,7 +2178,7 @@ GMP_notify_broken_link (struct CadetPeer *peer,
2178 * @return Number of known paths. 2178 * @return Number of known paths.
2179 */ 2179 */
2180unsigned int 2180unsigned int
2181GMP_count_paths (const struct CadetPeer *peer) 2181GCP_count_paths (const struct CadetPeer *peer)
2182{ 2182{
2183 struct CadetPeerPath *iter; 2183 struct CadetPeerPath *iter;
2184 unsigned int i; 2184 unsigned int i;
@@ -2197,7 +2197,7 @@ GMP_count_paths (const struct CadetPeer *peer)
2197 * @param cls Closure for @c iter. 2197 * @param cls Closure for @c iter.
2198 */ 2198 */
2199void 2199void
2200GMP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls) 2200GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls)
2201{ 2201{
2202 GNUNET_CONTAINER_multipeermap_iterate (peers, iter, cls); 2202 GNUNET_CONTAINER_multipeermap_iterate (peers, iter, cls);
2203} 2203}
@@ -2211,7 +2211,7 @@ GMP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls)
2211 * @return Static string for it's ID. 2211 * @return Static string for it's ID.
2212 */ 2212 */
2213const char * 2213const char *
2214GMP_2s (const struct CadetPeer *peer) 2214GCP_2s (const struct CadetPeer *peer)
2215{ 2215{
2216 if (NULL == peer) 2216 if (NULL == peer)
2217 return "(NULL)"; 2217 return "(NULL)";
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h
index 9f1146e9f..e9668305b 100644
--- a/src/cadet/gnunet-service-cadet_peer.h
+++ b/src/cadet/gnunet-service-cadet_peer.h
@@ -64,7 +64,7 @@ struct CadetPeerQueue;
64 * @param size Size of the message. 64 * @param size Size of the message.
65 * @param wait Time spent waiting for core (only the time for THIS message) 65 * @param wait Time spent waiting for core (only the time for THIS message)
66 */ 66 */
67typedef void (*GMP_sent) (void *cls, 67typedef void (*GCP_sent) (void *cls,
68 struct CadetConnection *c, int sent, 68 struct CadetConnection *c, int sent,
69 uint16_t type, uint32_t pid, int fwd, size_t size, 69 uint16_t type, uint32_t pid, int fwd, size_t size,
70 struct GNUNET_TIME_Relative wait); 70 struct GNUNET_TIME_Relative wait);
@@ -79,13 +79,13 @@ typedef void (*GMP_sent) (void *cls,
79 * @param c Configuration. 79 * @param c Configuration.
80 */ 80 */
81void 81void
82GMP_init (const struct GNUNET_CONFIGURATION_Handle *c); 82GCP_init (const struct GNUNET_CONFIGURATION_Handle *c);
83 83
84/** 84/**
85 * Shut down the peer subsystem. 85 * Shut down the peer subsystem.
86 */ 86 */
87void 87void
88GMP_shutdown (void); 88GCP_shutdown (void);
89 89
90 90
91/** 91/**
@@ -97,7 +97,7 @@ GMP_shutdown (void);
97 * @return Existing or newly created peer structure. 97 * @return Existing or newly created peer structure.
98 */ 98 */
99struct CadetPeer * 99struct CadetPeer *
100GMP_get (const struct GNUNET_PeerIdentity *peer_id); 100GCP_get (const struct GNUNET_PeerIdentity *peer_id);
101 101
102 102
103/** 103/**
@@ -109,7 +109,7 @@ GMP_get (const struct GNUNET_PeerIdentity *peer_id);
109 * @return Existing or newly created peer structure. 109 * @return Existing or newly created peer structure.
110 */ 110 */
111struct CadetPeer * 111struct CadetPeer *
112GMP_get_short (const GNUNET_PEER_Id peer); 112GCP_get_short (const GNUNET_PEER_Id peer);
113 113
114/** 114/**
115 * Try to establish a new connection to this peer (in its tunnel). 115 * Try to establish a new connection to this peer (in its tunnel).
@@ -119,7 +119,7 @@ GMP_get_short (const GNUNET_PEER_Id peer);
119 * @param peer Peer to connect to. 119 * @param peer Peer to connect to.
120 */ 120 */
121void 121void
122GMP_connect (struct CadetPeer *peer); 122GCP_connect (struct CadetPeer *peer);
123 123
124/** 124/**
125 * Free a transmission that was already queued with all resources 125 * Free a transmission that was already queued with all resources
@@ -131,7 +131,7 @@ GMP_connect (struct CadetPeer *peer);
131 * @param pid PID, if relevant (was sent and was a payload message). 131 * @param pid PID, if relevant (was sent and was a payload message).
132 */ 132 */
133void 133void
134GMP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls, 134GCP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
135 int sent, uint32_t pid); 135 int sent, uint32_t pid);
136 136
137/** 137/**
@@ -151,10 +151,10 @@ GMP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
151 * message has been sent and therefore the handle is no longer valid. 151 * message has been sent and therefore the handle is no longer valid.
152 */ 152 */
153struct CadetPeerQueue * 153struct CadetPeerQueue *
154GMP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type, 154GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
155 uint16_t payload_type, uint32_t payload_id, 155 uint16_t payload_type, uint32_t payload_id,
156 size_t size, struct CadetConnection *c, int fwd, 156 size_t size, struct CadetConnection *c, int fwd,
157 GMP_sent cont, void *cont_cls); 157 GCP_sent cont, void *cont_cls);
158 158
159/** 159/**
160 * Cancel all queued messages to a peer that belong to a certain connection. 160 * Cancel all queued messages to a peer that belong to a certain connection.
@@ -164,7 +164,7 @@ GMP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
164 * the sent continuation call. 164 * the sent continuation call.
165 */ 165 */
166void 166void
167GMP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c); 167GCP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c);
168 168
169/** 169/**
170 * Get the first message for a connection and unqueue it. 170 * Get the first message for a connection and unqueue it.
@@ -175,10 +175,10 @@ GMP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c);
175 * @return First message for this connection. 175 * @return First message for this connection.
176 */ 176 */
177struct GNUNET_MessageHeader * 177struct GNUNET_MessageHeader *
178GMP_connection_pop (struct CadetPeer *peer, struct CadetConnection *c); 178GCP_connection_pop (struct CadetPeer *peer, struct CadetConnection *c);
179 179
180void 180void
181GMP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c); 181GCP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c);
182 182
183/** 183/**
184 * Set tunnel. 184 * Set tunnel.
@@ -187,7 +187,7 @@ GMP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c);
187 * @param t Tunnel. 187 * @param t Tunnel.
188 */ 188 */
189void 189void
190GMP_set_tunnel (struct CadetPeer *peer, struct CadetTunnel3 *t); 190GCP_set_tunnel (struct CadetPeer *peer, struct CadetTunnel3 *t);
191 191
192/** 192/**
193 * Check whether there is a direct (core level) connection to peer. 193 * Check whether there is a direct (core level) connection to peer.
@@ -197,7 +197,7 @@ GMP_set_tunnel (struct CadetPeer *peer, struct CadetTunnel3 *t);
197 * @return #GNUNET_YES if there is a direct connection. 197 * @return #GNUNET_YES if there is a direct connection.
198 */ 198 */
199int 199int
200GMP_is_neighbor (const struct CadetPeer *peer); 200GCP_is_neighbor (const struct CadetPeer *peer);
201 201
202/** 202/**
203 * Create and initialize a new tunnel towards a peer, in case it has none. 203 * Create and initialize a new tunnel towards a peer, in case it has none.
@@ -207,7 +207,7 @@ GMP_is_neighbor (const struct CadetPeer *peer);
207 * @param peer Peer towards which to create the tunnel. 207 * @param peer Peer towards which to create the tunnel.
208 */ 208 */
209void 209void
210GMP_add_tunnel (struct CadetPeer *peer); 210GCP_add_tunnel (struct CadetPeer *peer);
211 211
212/** 212/**
213 * Add a connection to a neighboring peer. 213 * Add a connection to a neighboring peer.
@@ -222,7 +222,7 @@ GMP_add_tunnel (struct CadetPeer *peer);
222 * @return GNUNET_OK on success. 222 * @return GNUNET_OK on success.
223 */ 223 */
224int 224int
225GMP_add_connection (struct CadetPeer *peer, struct CadetConnection *c); 225GCP_add_connection (struct CadetPeer *peer, struct CadetConnection *c);
226 226
227/** 227/**
228 * Add the path to the peer and update the path used to reach it in case this 228 * Add the path to the peer and update the path used to reach it in case this
@@ -237,7 +237,7 @@ GMP_add_connection (struct CadetPeer *peer, struct CadetConnection *c);
237 * NULL on error. 237 * NULL on error.
238 */ 238 */
239struct CadetPeerPath * 239struct CadetPeerPath *
240GMP_add_path (struct CadetPeer *peer, struct CadetPeerPath *p, int trusted); 240GCP_add_path (struct CadetPeer *peer, struct CadetPeerPath *p, int trusted);
241 241
242/** 242/**
243 * Add the path to the origin peer and update the path used to reach it in case 243 * Add the path to the origin peer and update the path used to reach it in case
@@ -254,7 +254,7 @@ GMP_add_path (struct CadetPeer *peer, struct CadetPeerPath *p, int trusted);
254 * NULL on error. 254 * NULL on error.
255 */ 255 */
256struct CadetPeerPath * 256struct CadetPeerPath *
257GMP_add_path_to_origin (struct CadetPeer *peer, 257GCP_add_path_to_origin (struct CadetPeer *peer,
258 struct CadetPeerPath *path, 258 struct CadetPeerPath *path,
259 int trusted); 259 int trusted);
260 260
@@ -265,7 +265,7 @@ GMP_add_path_to_origin (struct CadetPeer *peer,
265 * @param confirmed Whether we know if the path works or not. 265 * @param confirmed Whether we know if the path works or not.
266 */ 266 */
267void 267void
268GMP_add_path_to_all (const struct CadetPeerPath *p, int confirmed); 268GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed);
269 269
270/** 270/**
271 * Remove any path to the peer that has the extact same peers as the one given. 271 * Remove any path to the peer that has the extact same peers as the one given.
@@ -274,7 +274,7 @@ GMP_add_path_to_all (const struct CadetPeerPath *p, int confirmed);
274 * @param path Path to remove. Is always destroyed . 274 * @param path Path to remove. Is always destroyed .
275 */ 275 */
276void 276void
277GMP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path); 277GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path);
278 278
279/** 279/**
280 * Remove a connection from a neighboring peer. 280 * Remove a connection from a neighboring peer.
@@ -285,7 +285,7 @@ GMP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path);
285 * @return GNUNET_OK on success. 285 * @return GNUNET_OK on success.
286 */ 286 */
287int 287int
288GMP_remove_connection (struct CadetPeer *peer, const struct CadetConnection *c); 288GCP_remove_connection (struct CadetPeer *peer, const struct CadetConnection *c);
289 289
290/** 290/**
291 * Start the DHT search for new paths towards the peer: we don't have 291 * Start the DHT search for new paths towards the peer: we don't have
@@ -294,7 +294,7 @@ GMP_remove_connection (struct CadetPeer *peer, const struct CadetConnection *c);
294 * @param peer Destination peer. 294 * @param peer Destination peer.
295 */ 295 */
296void 296void
297GMP_start_search (struct CadetPeer *peer); 297GCP_start_search (struct CadetPeer *peer);
298 298
299/** 299/**
300 * Stop the DHT search for new paths towards the peer: we already have 300 * Stop the DHT search for new paths towards the peer: we already have
@@ -303,7 +303,7 @@ GMP_start_search (struct CadetPeer *peer);
303 * @param peer Destination peer. 303 * @param peer Destination peer.
304 */ 304 */
305void 305void
306GMP_stop_search (struct CadetPeer *peer); 306GCP_stop_search (struct CadetPeer *peer);
307 307
308/** 308/**
309 * Get the Full ID of a peer. 309 * Get the Full ID of a peer.
@@ -313,7 +313,7 @@ GMP_stop_search (struct CadetPeer *peer);
313 * @return Full ID of peer. 313 * @return Full ID of peer.
314 */ 314 */
315const struct GNUNET_PeerIdentity * 315const struct GNUNET_PeerIdentity *
316GMP_get_id (const struct CadetPeer *peer); 316GCP_get_id (const struct CadetPeer *peer);
317 317
318/** 318/**
319 * Get the Short ID of a peer. 319 * Get the Short ID of a peer.
@@ -323,7 +323,7 @@ GMP_get_id (const struct CadetPeer *peer);
323 * @return Short ID of peer. 323 * @return Short ID of peer.
324 */ 324 */
325GNUNET_PEER_Id 325GNUNET_PEER_Id
326GMP_get_short_id (const struct CadetPeer *peer); 326GCP_get_short_id (const struct CadetPeer *peer);
327 327
328/** 328/**
329 * Get the tunnel towards a peer. 329 * Get the tunnel towards a peer.
@@ -333,7 +333,7 @@ GMP_get_short_id (const struct CadetPeer *peer);
333 * @return Tunnel towards peer. 333 * @return Tunnel towards peer.
334 */ 334 */
335struct CadetTunnel3 * 335struct CadetTunnel3 *
336GMP_get_tunnel (const struct CadetPeer *peer); 336GCP_get_tunnel (const struct CadetPeer *peer);
337 337
338/** 338/**
339 * Set the hello message. 339 * Set the hello message.
@@ -342,7 +342,7 @@ GMP_get_tunnel (const struct CadetPeer *peer);
342 * @param hello Hello message. 342 * @param hello Hello message.
343 */ 343 */
344void 344void
345GMP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello); 345GCP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello);
346 346
347/** 347/**
348 * Get the hello message. 348 * Get the hello message.
@@ -352,7 +352,7 @@ GMP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello)
352 * @return Hello message. 352 * @return Hello message.
353 */ 353 */
354struct GNUNET_HELLO_Message * 354struct GNUNET_HELLO_Message *
355GMP_get_hello (struct CadetPeer *peer); 355GCP_get_hello (struct CadetPeer *peer);
356 356
357 357
358/** 358/**
@@ -361,7 +361,7 @@ GMP_get_hello (struct CadetPeer *peer);
361 * @param peer Peer to whom to connect. 361 * @param peer Peer to whom to connect.
362 */ 362 */
363void 363void
364GMP_try_connect (struct CadetPeer *peer); 364GCP_try_connect (struct CadetPeer *peer);
365 365
366/** 366/**
367 * Notify a peer that a link between two other peers is broken. If any path 367 * Notify a peer that a link between two other peers is broken. If any path
@@ -372,7 +372,7 @@ GMP_try_connect (struct CadetPeer *peer);
372 * @param peer2 Peer whose link is broken. 372 * @param peer2 Peer whose link is broken.
373 */ 373 */
374void 374void
375GMP_notify_broken_link (struct CadetPeer *peer, 375GCP_notify_broken_link (struct CadetPeer *peer,
376 struct GNUNET_PeerIdentity *peer1, 376 struct GNUNET_PeerIdentity *peer1,
377 struct GNUNET_PeerIdentity *peer2); 377 struct GNUNET_PeerIdentity *peer2);
378 378
@@ -384,7 +384,7 @@ GMP_notify_broken_link (struct CadetPeer *peer,
384 * @return Number of known paths. 384 * @return Number of known paths.
385 */ 385 */
386unsigned int 386unsigned int
387GMP_count_paths (const struct CadetPeer *peer); 387GCP_count_paths (const struct CadetPeer *peer);
388 388
389/** 389/**
390 * Iterate all known peers. 390 * Iterate all known peers.
@@ -393,7 +393,7 @@ GMP_count_paths (const struct CadetPeer *peer);
393 * @param cls Closure for @c iter. 393 * @param cls Closure for @c iter.
394 */ 394 */
395void 395void
396GMP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls); 396GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls);
397 397
398/** 398/**
399 * Get the static string for a peer ID. 399 * Get the static string for a peer ID.
@@ -403,7 +403,7 @@ GMP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls);
403 * @return Static string for it's ID. 403 * @return Static string for it's ID.
404 */ 404 */
405const char * 405const char *
406GMP_2s (const struct CadetPeer *peer); 406GCP_2s (const struct CadetPeer *peer);
407 407
408 408
409#if 0 /* keep Emacsens' auto-indent happy */ 409#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index 15883b43e..971b186c9 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -219,7 +219,7 @@ struct CadetTunnel3Queue
219 /** 219 /**
220 * Continuation to call once sent. 220 * Continuation to call once sent.
221 */ 221 */
222 GMT_sent cont; 222 GCT_sent cont;
223 223
224 /** 224 /**
225 * Closure for @c cont. 225 * Closure for @c cont.
@@ -370,9 +370,9 @@ is_ready (struct CadetTunnel3 *t)
370{ 370{
371 int ready; 371 int ready;
372 372
373 GMT_debug (t); 373 GCT_debug (t);
374 ready = (CADET_TUNNEL3_READY == t->cstate && CADET_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 || GCT_is_loopback (t);
376 return ready; 376 return ready;
377} 377}
378 378
@@ -418,9 +418,9 @@ get_channel_buffer (const struct CadetTChannel *tch)
418 int fwd; 418 int fwd;
419 419
420 /* If channel is outgoing, is origin in the FWD direction and fwd is YES */ 420 /* If channel is outgoing, is origin in the FWD direction and fwd is YES */
421 fwd = GMCH_is_origin (tch->ch, GNUNET_YES); 421 fwd = GCCH_is_origin (tch->ch, GNUNET_YES);
422 422
423 return GMCH_get_buffer (tch->ch, fwd); 423 return GCCH_get_buffer (tch->ch, fwd);
424} 424}
425 425
426 426
@@ -437,9 +437,9 @@ get_channel_allowed (const struct CadetTChannel *tch)
437 int fwd; 437 int fwd;
438 438
439 /* If channel is outgoing, is origin in the FWD direction and fwd is YES */ 439 /* If channel is outgoing, is origin in the FWD direction and fwd is YES */
440 fwd = GMCH_is_origin (tch->ch, GNUNET_YES); 440 fwd = GCCH_is_origin (tch->ch, GNUNET_YES);
441 441
442 return GMCH_get_allowed (tch->ch, fwd); 442 return GCCH_get_allowed (tch->ch, fwd);
443} 443}
444 444
445 445
@@ -456,9 +456,9 @@ get_connection_buffer (const struct CadetTConnection *tc)
456 int fwd; 456 int fwd;
457 457
458 /* If connection is outgoing, is origin in the FWD direction and fwd is YES */ 458 /* If connection is outgoing, is origin in the FWD direction and fwd is YES */
459 fwd = GMC_is_origin (tc->c, GNUNET_YES); 459 fwd = GCC_is_origin (tc->c, GNUNET_YES);
460 460
461 return GMC_get_buffer (tc->c, fwd); 461 return GCC_get_buffer (tc->c, fwd);
462} 462}
463 463
464 464
@@ -475,9 +475,9 @@ get_connection_allowed (const struct CadetTConnection *tc)
475 int fwd; 475 int fwd;
476 476
477 /* If connection is outgoing, is origin in the FWD direction and fwd is YES */ 477 /* If connection is outgoing, is origin in the FWD direction and fwd is YES */
478 fwd = GMC_is_origin (tc->c, GNUNET_YES); 478 fwd = GCC_is_origin (tc->c, GNUNET_YES);
479 479
480 return GMC_get_allowed (tc->c, fwd); 480 return GCC_get_allowed (tc->c, fwd);
481} 481}
482 482
483 483
@@ -503,7 +503,7 @@ check_ephemeral (struct CadetTunnel3 *t,
503 503
504 /* Check origin */ 504 /* Check origin */
505 if (0 != memcmp (&msg->origin_identity, 505 if (0 != memcmp (&msg->origin_identity,
506 GMP_get_id (t->peer), 506 GCP_get_id (t->peer),
507 sizeof (struct GNUNET_PeerIdentity))) 507 sizeof (struct GNUNET_PeerIdentity)))
508 return GNUNET_SYSERR; 508 return GNUNET_SYSERR;
509 509
@@ -578,8 +578,8 @@ t_decrypt (struct CadetTunnel3 *t,
578 GNUNET_STATISTICS_update (stats, "# non decryptable data", 1, GNUNET_NO); 578 GNUNET_STATISTICS_update (stats, "# non decryptable data", 1, GNUNET_NO);
579 LOG (GNUNET_ERROR_TYPE_DEBUG, 579 LOG (GNUNET_ERROR_TYPE_DEBUG,
580 "WARNING got data on %s without a valid key\n", 580 "WARNING got data on %s without a valid key\n",
581 GMT_2s (t)); 581 GCT_2s (t));
582 GMT_debug (t); 582 GCT_debug (t);
583 return 0; 583 return 0;
584 } 584 }
585 585
@@ -652,16 +652,16 @@ tunnel_get_connection (struct CadetTunnel3 *t)
652 unsigned int qn; 652 unsigned int qn;
653 unsigned int lowest_q; 653 unsigned int lowest_q;
654 654
655 LOG (GNUNET_ERROR_TYPE_DEBUG, "tunnel_get_connection %s\n", GMT_2s (t)); 655 LOG (GNUNET_ERROR_TYPE_DEBUG, "tunnel_get_connection %s\n", GCT_2s (t));
656 best = NULL; 656 best = NULL;
657 lowest_q = UINT_MAX; 657 lowest_q = UINT_MAX;
658 for (iter = t->connection_head; NULL != iter; iter = iter->next) 658 for (iter = t->connection_head; NULL != iter; iter = iter->next)
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 GCC_2s (iter->c), GCC_get_state (iter->c));
662 if (CADET_CONNECTION_READY == GMC_get_state (iter->c)) 662 if (CADET_CONNECTION_READY == GCC_get_state (iter->c))
663 { 663 {
664 qn = GMC_get_qn (iter->c, GMC_is_origin (iter->c, GNUNET_YES)); 664 qn = GCC_get_qn (iter->c, GCC_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);
666 if (qn < lowest_q) 666 if (qn < lowest_q)
667 { 667 {
@@ -670,7 +670,7 @@ tunnel_get_connection (struct CadetTunnel3 *t)
670 } 670 }
671 } 671 }
672 } 672 }
673 LOG (GNUNET_ERROR_TYPE_DEBUG, " selected: connection %s\n", GMC_2s (best)); 673 LOG (GNUNET_ERROR_TYPE_DEBUG, " selected: connection %s\n", GCC_2s (best));
674 return best; 674 return best;
675} 675}
676 676
@@ -699,7 +699,7 @@ tun_message_sent (void *cls,
699 LOG (GNUNET_ERROR_TYPE_DEBUG, "tun_message_sent\n"); 699 LOG (GNUNET_ERROR_TYPE_DEBUG, "tun_message_sent\n");
700 700
701 GNUNET_assert (NULL != qt->cont); 701 GNUNET_assert (NULL != qt->cont);
702 t = NULL == c ? NULL : GMC_get_tunnel (c); 702 t = NULL == c ? NULL : GCC_get_tunnel (c);
703 qt->cont (qt->cont_cls, t, qt, type, size); 703 qt->cont (qt->cont_cls, t, qt, type, size);
704 GNUNET_free (qt); 704 GNUNET_free (qt);
705} 705}
@@ -731,7 +731,7 @@ queue_data (struct CadetTunnel3 *t, const struct GNUNET_MessageHeader *msg)
731 struct CadetTunnelDelayed *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", GCT_2s (t));
735 735
736 if (GNUNET_YES == is_ready (t)) 736 if (GNUNET_YES == is_ready (t))
737 { 737 {
@@ -797,7 +797,7 @@ t_hmac (struct CadetTunnel3 *t, const void *plaintext, size_t size, uint32_t iv,
797static struct CadetTunnel3Queue * 797static struct CadetTunnel3Queue *
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 CadetTunnel3 *t, struct CadetConnection *c,
800 int force, GMT_sent cont, void *cont_cls, 800 int force, GCT_sent cont, void *cont_cls,
801 struct CadetTunnel3Queue *existing_q) 801 struct CadetTunnel3Queue *existing_q)
802{ 802{
803 struct CadetTunnel3Queue *tq; 803 struct CadetTunnel3Queue *tq;
@@ -809,7 +809,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
809 uint16_t type; 809 uint16_t type;
810 int fwd; 810 int fwd;
811 811
812 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT Send on Tunnel %s\n", GMT_2s (t)); 812 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT Send on Tunnel %s\n", GCT_2s (t));
813 813
814 if (GNUNET_NO == is_ready (t)) 814 if (GNUNET_NO == is_ready (t))
815 { 815 {
@@ -829,7 +829,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
829 return tq; 829 return tq;
830 } 830 }
831 831
832 GNUNET_assert (GNUNET_NO == GMT_is_loopback (t)); 832 GNUNET_assert (GNUNET_NO == GCT_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_CADET_Encrypted *) cbuf; 835 msg = (struct GNUNET_CADET_Encrypted *) cbuf;
@@ -847,7 +847,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
847 || CADET_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 GCT_debug (t);
851 } 851 }
852 return NULL; 852 return NULL;
853 } 853 }
@@ -868,20 +868,20 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
868 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY: 868 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY:
869 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK: 869 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK:
870 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK: 870 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK:
871 msg->cid = *GMC_get_id (c); 871 msg->cid = *GCC_get_id (c);
872 msg->ttl = htonl (default_ttl); 872 msg->ttl = htonl (default_ttl);
873 break; 873 break;
874 default: 874 default:
875 GNUNET_break (0); 875 GNUNET_break (0);
876 } 876 }
877 LOG (GNUNET_ERROR_TYPE_DEBUG, "type %s\n", GM_m2s (type)); 877 LOG (GNUNET_ERROR_TYPE_DEBUG, "type %s\n", GC_m2s (type));
878 878
879 fwd = GMC_is_origin (c, GNUNET_YES); 879 fwd = GCC_is_origin (c, GNUNET_YES);
880 880
881 if (NULL == cont) 881 if (NULL == cont)
882 { 882 {
883 GNUNET_break (NULL == 883 GNUNET_break (NULL ==
884 GMC_send_prebuilt_message (&msg->header, type, mid, 884 GCC_send_prebuilt_message (&msg->header, type, mid,
885 c, fwd, force, NULL, NULL)); 885 c, fwd, force, NULL, NULL));
886 return NULL; 886 return NULL;
887 } 887 }
@@ -894,7 +894,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
894 tq = existing_q; 894 tq = existing_q;
895 tq->tqd = NULL; 895 tq->tqd = NULL;
896 } 896 }
897 tq->cq = GMC_send_prebuilt_message (&msg->header, type, mid, c, fwd, force, 897 tq->cq = GCC_send_prebuilt_message (&msg->header, type, mid, c, fwd, force,
898 &tun_message_sent, tq); 898 &tun_message_sent, tq);
899 tq->cont = cont; 899 tq->cont = cont;
900 tq->cont_cls = cont_cls; 900 tq->cont_cls = cont_cls;
@@ -916,10 +916,10 @@ send_queued_data (struct CadetTunnel3 *t)
916 unsigned int room; 916 unsigned int room;
917 917
918 LOG (GNUNET_ERROR_TYPE_DEBUG, 918 LOG (GNUNET_ERROR_TYPE_DEBUG,
919 "GMT_send_queued_data on tunnel %s\n", 919 "GCT_send_queued_data on tunnel %s\n",
920 GMT_2s (t)); 920 GCT_2s (t));
921 921
922 if (GMT_is_loopback (t)) 922 if (GCT_is_loopback (t))
923 { 923 {
924 GNUNET_break (0); 924 GNUNET_break (0);
925 return; 925 return;
@@ -932,7 +932,7 @@ send_queued_data (struct CadetTunnel3 *t)
932 return; 932 return;
933 } 933 }
934 934
935 room = GMT_get_connections_buffer (t); 935 room = GCT_get_connections_buffer (t);
936 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer space: %u\n", room); 936 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer space: %u\n", room);
937 LOG (GNUNET_ERROR_TYPE_DEBUG, " tq head: %p\n", t->tq_head); 937 LOG (GNUNET_ERROR_TYPE_DEBUG, " tq head: %p\n", t->tq_head);
938 for (tqd = t->tq_head; NULL != tqd && room > 0; tqd = next) 938 for (tqd = t->tq_head; NULL != tqd && room > 0; tqd = next)
@@ -947,7 +947,7 @@ send_queued_data (struct CadetTunnel3 *t)
947 tqd->tq); 947 tqd->tq);
948 unqueue_data (tqd); 948 unqueue_data (tqd);
949 } 949 }
950 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT_send_queued_data end\n", GMP_2s (t->peer)); 950 LOG (GNUNET_ERROR_TYPE_DEBUG, "GCT_send_queued_data end\n", GCP_2s (t->peer));
951} 951}
952 952
953 953
@@ -969,10 +969,10 @@ send_kx (struct CadetTunnel3 *t,
969 uint16_t type; 969 uint16_t type;
970 int fwd; 970 int fwd;
971 971
972 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT KX on Tunnel %s\n", GMT_2s (t)); 972 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT KX on Tunnel %s\n", GCT_2s (t));
973 973
974 /* Avoid loopback. */ 974 /* Avoid loopback. */
975 if (GMT_is_loopback (t)) 975 if (GCT_is_loopback (t))
976 { 976 {
977 LOG (GNUNET_ERROR_TYPE_DEBUG, " loopback!\n"); 977 LOG (GNUNET_ERROR_TYPE_DEBUG, " loopback!\n");
978 GNUNET_break (0); 978 GNUNET_break (0);
@@ -988,7 +988,7 @@ send_kx (struct CadetTunnel3 *t,
988 if (NULL == t->connection_head) 988 if (NULL == t->connection_head)
989 { 989 {
990 GNUNET_break (CADET_TUNNEL3_SEARCHING == t->cstate); 990 GNUNET_break (CADET_TUNNEL3_SEARCHING == t->cstate);
991 GMT_debug (t); 991 GCT_debug (t);
992 return; 992 return;
993 } 993 }
994 994
@@ -1000,7 +1000,7 @@ send_kx (struct CadetTunnel3 *t,
1000 { 1000 {
1001 GNUNET_break (GNUNET_SCHEDULER_NO_TASK != t->destroy_task 1001 GNUNET_break (GNUNET_SCHEDULER_NO_TASK != t->destroy_task
1002 || CADET_TUNNEL3_READY != t->cstate); 1002 || CADET_TUNNEL3_READY != t->cstate);
1003 GMT_debug (t); 1003 GCT_debug (t);
1004 return; 1004 return;
1005 } 1005 }
1006 type = ntohs (message->type); 1006 type = ntohs (message->type);
@@ -1013,13 +1013,13 @@ send_kx (struct CadetTunnel3 *t,
1013 break; 1013 break;
1014 default: 1014 default:
1015 LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n", 1015 LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n",
1016 GM_m2s (type)); 1016 GC_m2s (type));
1017 GNUNET_break (0); 1017 GNUNET_break (0);
1018 } 1018 }
1019 1019
1020 fwd = GMC_is_origin (t->connection_head->c, GNUNET_YES); 1020 fwd = GCC_is_origin (t->connection_head->c, GNUNET_YES);
1021 /* TODO save handle and cancel in case of a unneeded retransmission */ 1021 /* TODO save handle and cancel in case of a unneeded retransmission */
1022 GMC_send_prebuilt_message (&msg->header, GNUNET_MESSAGE_TYPE_CADET_KX, 1022 GCC_send_prebuilt_message (&msg->header, GNUNET_MESSAGE_TYPE_CADET_KX,
1023 message->type, c, fwd, GNUNET_YES, NULL, NULL); 1023 message->type, c, fwd, GNUNET_YES, NULL, NULL);
1024} 1024}
1025 1025
@@ -1032,7 +1032,7 @@ send_kx (struct CadetTunnel3 *t,
1032static void 1032static void
1033send_ephemeral (struct CadetTunnel3 *t) 1033send_ephemeral (struct CadetTunnel3 *t)
1034{ 1034{
1035 LOG (GNUNET_ERROR_TYPE_INFO, "=> EPHM for %s\n", GMT_2s (t)); 1035 LOG (GNUNET_ERROR_TYPE_INFO, "=> EPHM for %s\n", GCT_2s (t));
1036 1036
1037 kx_msg.sender_status = htonl (t->estate); 1037 kx_msg.sender_status = htonl (t->estate);
1038 send_kx (t, &kx_msg.header); 1038 send_kx (t, &kx_msg.header);
@@ -1048,11 +1048,11 @@ send_ping (struct CadetTunnel3 *t)
1048{ 1048{
1049 struct GNUNET_CADET_KX_Ping msg; 1049 struct GNUNET_CADET_KX_Ping msg;
1050 1050
1051 LOG (GNUNET_ERROR_TYPE_INFO, "=> PING for %s\n", GMT_2s (t)); 1051 LOG (GNUNET_ERROR_TYPE_INFO, "=> PING for %s\n", GCT_2s (t));
1052 msg.header.size = htons (sizeof (msg)); 1052 msg.header.size = htons (sizeof (msg));
1053 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX_PING); 1053 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX_PING);
1054 msg.iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 1054 msg.iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
1055 msg.target = *GMP_get_id (t->peer); 1055 msg.target = *GCP_get_id (t->peer);
1056 msg.nonce = t->kx_ctx->challenge; 1056 msg.nonce = t->kx_ctx->challenge;
1057 1057
1058 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending %u\n", msg.nonce); 1058 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending %u\n", msg.nonce);
@@ -1076,7 +1076,7 @@ send_pong (struct CadetTunnel3 *t, uint32_t challenge)
1076{ 1076{
1077 struct GNUNET_CADET_KX_Pong msg; 1077 struct GNUNET_CADET_KX_Pong msg;
1078 1078
1079 LOG (GNUNET_ERROR_TYPE_INFO, "=> PONG for %s\n", GMT_2s (t)); 1079 LOG (GNUNET_ERROR_TYPE_INFO, "=> PONG for %s\n", GCT_2s (t));
1080 msg.header.size = htons (sizeof (msg)); 1080 msg.header.size = htons (sizeof (msg));
1081 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX_PONG); 1081 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX_PONG);
1082 msg.iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 1082 msg.iv = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
@@ -1102,7 +1102,7 @@ rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1102 1102
1103 t->rekey_task = GNUNET_SCHEDULER_NO_TASK; 1103 t->rekey_task = GNUNET_SCHEDULER_NO_TASK;
1104 1104
1105 LOG (GNUNET_ERROR_TYPE_DEBUG, "Re-key Tunnel %s\n", GMT_2s (t)); 1105 LOG (GNUNET_ERROR_TYPE_DEBUG, "Re-key Tunnel %s\n", GCT_2s (t));
1106 if (NULL != tc && 0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 1106 if (NULL != tc && 0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
1107 return; 1107 return;
1108 1108
@@ -1114,7 +1114,7 @@ rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1114 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 1114 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
1115 t->kx_ctx->d_key_old = t->d_key; 1115 t->kx_ctx->d_key_old = t->d_key;
1116 LOG (GNUNET_ERROR_TYPE_DEBUG, " new challenge for %s: %u\n", 1116 LOG (GNUNET_ERROR_TYPE_DEBUG, " new challenge for %s: %u\n",
1117 GMT_2s (t), t->kx_ctx->challenge); 1117 GCT_2s (t), t->kx_ctx->challenge);
1118 } 1118 }
1119 send_ephemeral (t); 1119 send_ephemeral (t);
1120 switch (t->estate) 1120 switch (t->estate)
@@ -1161,7 +1161,7 @@ rekey_iterator (void *cls,
1161 if (GNUNET_SCHEDULER_NO_TASK != t->rekey_task) 1161 if (GNUNET_SCHEDULER_NO_TASK != t->rekey_task)
1162 return GNUNET_YES; 1162 return GNUNET_YES;
1163 1163
1164 if (GNUNET_YES == GMT_is_loopback (t)) 1164 if (GNUNET_YES == GCT_is_loopback (t))
1165 return GNUNET_YES; 1165 return GNUNET_YES;
1166 1166
1167 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t) n * 100); 1167 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t) n * 100);
@@ -1227,8 +1227,8 @@ destroy_iterator (void *cls,
1227{ 1227{
1228 struct CadetTunnel3 *t = value; 1228 struct CadetTunnel3 *t = value;
1229 1229
1230 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT_shutdown destroying tunnel at %p\n", t); 1230 LOG (GNUNET_ERROR_TYPE_DEBUG, "GCT_shutdown destroying tunnel at %p\n", t);
1231 GMT_destroy (t); 1231 GCT_destroy (t);
1232 return GNUNET_YES; 1232 return GNUNET_YES;
1233} 1233}
1234 1234
@@ -1251,7 +1251,7 @@ send_channel_destroy (struct CadetTunnel3 *t, unsigned int gid)
1251 1251
1252 LOG (GNUNET_ERROR_TYPE_DEBUG, 1252 LOG (GNUNET_ERROR_TYPE_DEBUG,
1253 "WARNING destroying unknown channel %u on tunnel %s\n", 1253 "WARNING destroying unknown channel %u on tunnel %s\n",
1254 gid, GMT_2s (t)); 1254 gid, GCT_2s (t));
1255 send_prebuilt_message (&msg.header, t, NULL, GNUNET_YES, NULL, NULL, NULL); 1255 send_prebuilt_message (&msg.header, t, NULL, GNUNET_YES, NULL, NULL, NULL);
1256} 1256}
1257 1257
@@ -1284,10 +1284,10 @@ handle_data (struct CadetTunnel3 *t,
1284 return; 1284 return;
1285 } 1285 }
1286 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload of type %s\n", 1286 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload of type %s\n",
1287 GM_m2s (ntohs (msg[1].header.type))); 1287 GC_m2s (ntohs (msg[1].header.type)));
1288 1288
1289 /* Check channel */ 1289 /* Check channel */
1290 ch = GMT_get_channel (t, ntohl (msg->chid)); 1290 ch = GCT_get_channel (t, ntohl (msg->chid));
1291 if (NULL == ch) 1291 if (NULL == ch)
1292 { 1292 {
1293 GNUNET_STATISTICS_update (stats, "# data on unknown channel", 1293 GNUNET_STATISTICS_update (stats, "# data on unknown channel",
@@ -1298,7 +1298,7 @@ handle_data (struct CadetTunnel3 *t,
1298 return; 1298 return;
1299 } 1299 }
1300 1300
1301 GMCH_handle_data (ch, msg, fwd); 1301 GCCH_handle_data (ch, msg, fwd);
1302} 1302}
1303 1303
1304 1304
@@ -1329,7 +1329,7 @@ handle_data_ack (struct CadetTunnel3 *t,
1329 } 1329 }
1330 1330
1331 /* Check channel */ 1331 /* Check channel */
1332 ch = GMT_get_channel (t, ntohl (msg->chid)); 1332 ch = GCT_get_channel (t, ntohl (msg->chid));
1333 if (NULL == ch) 1333 if (NULL == ch)
1334 { 1334 {
1335 GNUNET_STATISTICS_update (stats, "# data ack on unknown channel", 1335 GNUNET_STATISTICS_update (stats, "# data ack on unknown channel",
@@ -1339,7 +1339,7 @@ handle_data_ack (struct CadetTunnel3 *t,
1339 return; 1339 return;
1340 } 1340 }
1341 1341
1342 GMCH_handle_data_ack (ch, msg, fwd); 1342 GCCH_handle_data_ack (ch, msg, fwd);
1343} 1343}
1344 1344
1345 1345
@@ -1365,15 +1365,15 @@ handle_ch_create (struct CadetTunnel3 *t,
1365 } 1365 }
1366 1366
1367 /* Check channel */ 1367 /* Check channel */
1368 ch = GMT_get_channel (t, ntohl (msg->chid)); 1368 ch = GCT_get_channel (t, ntohl (msg->chid));
1369 if (NULL != ch && ! GMT_is_loopback (t)) 1369 if (NULL != ch && ! GCT_is_loopback (t))
1370 { 1370 {
1371 /* Probably a retransmission, safe to ignore */ 1371 /* Probably a retransmission, safe to ignore */
1372 LOG (GNUNET_ERROR_TYPE_DEBUG, " already exists...\n"); 1372 LOG (GNUNET_ERROR_TYPE_DEBUG, " already exists...\n");
1373 } 1373 }
1374 ch = GMCH_handle_create (t, msg); 1374 ch = GCCH_handle_create (t, msg);
1375 if (NULL != ch) 1375 if (NULL != ch)
1376 GMT_add_channel (t, ch); 1376 GCT_add_channel (t, ch);
1377} 1377}
1378 1378
1379 1379
@@ -1400,7 +1400,7 @@ handle_ch_nack (struct CadetTunnel3 *t,
1400 } 1400 }
1401 1401
1402 /* Check channel */ 1402 /* Check channel */
1403 ch = GMT_get_channel (t, ntohl (msg->chid)); 1403 ch = GCT_get_channel (t, ntohl (msg->chid));
1404 if (NULL == ch) 1404 if (NULL == ch)
1405 { 1405 {
1406 GNUNET_STATISTICS_update (stats, "# channel NACK on unknown channel", 1406 GNUNET_STATISTICS_update (stats, "# channel NACK on unknown channel",
@@ -1410,7 +1410,7 @@ handle_ch_nack (struct CadetTunnel3 *t,
1410 return; 1410 return;
1411 } 1411 }
1412 1412
1413 GMCH_handle_nack (ch); 1413 GCCH_handle_nack (ch);
1414} 1414}
1415 1415
1416 1416
@@ -1441,7 +1441,7 @@ handle_ch_ack (struct CadetTunnel3 *t,
1441 } 1441 }
1442 1442
1443 /* Check channel */ 1443 /* Check channel */
1444 ch = GMT_get_channel (t, ntohl (msg->chid)); 1444 ch = GCT_get_channel (t, ntohl (msg->chid));
1445 if (NULL == ch) 1445 if (NULL == ch)
1446 { 1446 {
1447 GNUNET_STATISTICS_update (stats, "# channel ack on unknown channel", 1447 GNUNET_STATISTICS_update (stats, "# channel ack on unknown channel",
@@ -1451,7 +1451,7 @@ handle_ch_ack (struct CadetTunnel3 *t,
1451 return; 1451 return;
1452 } 1452 }
1453 1453
1454 GMCH_handle_ack (ch, msg, fwd); 1454 GCCH_handle_ack (ch, msg, fwd);
1455} 1455}
1456 1456
1457 1457
@@ -1483,14 +1483,14 @@ handle_ch_destroy (struct CadetTunnel3 *t,
1483 } 1483 }
1484 1484
1485 /* Check channel */ 1485 /* Check channel */
1486 ch = GMT_get_channel (t, ntohl (msg->chid)); 1486 ch = GCT_get_channel (t, ntohl (msg->chid));
1487 if (NULL == ch) 1487 if (NULL == ch)
1488 { 1488 {
1489 /* Probably a retransmission, safe to ignore */ 1489 /* Probably a retransmission, safe to ignore */
1490 return; 1490 return;
1491 } 1491 }
1492 1492
1493 GMCH_handle_destroy (ch, msg, fwd); 1493 GCCH_handle_destroy (ch, msg, fwd);
1494} 1494}
1495 1495
1496 1496
@@ -1505,7 +1505,7 @@ handle_ephemeral (struct CadetTunnel3 *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;
1508 LOG (GNUNET_ERROR_TYPE_INFO, "<=== EPHM for %s\n", GMT_2s (t)); 1508 LOG (GNUNET_ERROR_TYPE_INFO, "<=== EPHM for %s\n", GCT_2s (t));
1509 1509
1510 if (GNUNET_OK != check_ephemeral (t, msg)) 1510 if (GNUNET_OK != check_ephemeral (t, msg))
1511 { 1511 {
@@ -1514,8 +1514,8 @@ handle_ephemeral (struct CadetTunnel3 *t,
1514 } 1514 }
1515 derive_key_material (&km, &msg->ephemeral_key); 1515 derive_key_material (&km, &msg->ephemeral_key);
1516 LOG (GNUNET_ERROR_TYPE_DEBUG, " km is %s\n", GNUNET_h2s (&km)); 1516 LOG (GNUNET_ERROR_TYPE_DEBUG, " km is %s\n", GNUNET_h2s (&km));
1517 derive_symmertic (&t->e_key, &my_full_id, GMP_get_id (t->peer), &km); 1517 derive_symmertic (&t->e_key, &my_full_id, GCP_get_id (t->peer), &km);
1518 derive_symmertic (&t->d_key, GMP_get_id (t->peer), &my_full_id, &km); 1518 derive_symmertic (&t->d_key, GCP_get_id (t->peer), &my_full_id, &km);
1519 if (CADET_TUNNEL3_KEY_SENT == t->estate) 1519 if (CADET_TUNNEL3_KEY_SENT == t->estate)
1520 { 1520 {
1521 LOG (GNUNET_ERROR_TYPE_DEBUG, " our key was sent, send ping\n"); 1521 LOG (GNUNET_ERROR_TYPE_DEBUG, " our key was sent, send ping\n");
@@ -1544,12 +1544,12 @@ handle_ping (struct CadetTunnel3 *t,
1544 return; 1544 return;
1545 } 1545 }
1546 1546
1547 LOG (GNUNET_ERROR_TYPE_INFO, "<=== PING for %s\n", GMT_2s (t)); 1547 LOG (GNUNET_ERROR_TYPE_INFO, "<=== PING for %s\n", GCT_2s (t));
1548 t_decrypt (t, &res.target, &msg->target, ping_encryption_size (), msg->iv); 1548 t_decrypt (t, &res.target, &msg->target, ping_encryption_size (), msg->iv);
1549 if (0 != memcmp (&my_full_id, &res.target, sizeof (my_full_id))) 1549 if (0 != memcmp (&my_full_id, &res.target, sizeof (my_full_id)))
1550 { 1550 {
1551 GNUNET_STATISTICS_update (stats, "# malformed PINGs", 1, GNUNET_NO); 1551 GNUNET_STATISTICS_update (stats, "# malformed PINGs", 1, GNUNET_NO);
1552 LOG (GNUNET_ERROR_TYPE_WARNING, " malformed PING on %s\n", GMT_2s (t)); 1552 LOG (GNUNET_ERROR_TYPE_WARNING, " malformed PING on %s\n", GCT_2s (t));
1553 LOG (GNUNET_ERROR_TYPE_DEBUG, " e got %u\n", msg->nonce); 1553 LOG (GNUNET_ERROR_TYPE_DEBUG, " e got %u\n", msg->nonce);
1554 LOG (GNUNET_ERROR_TYPE_DEBUG, " e towards %s\n", GNUNET_i2s (&msg->target)); 1554 LOG (GNUNET_ERROR_TYPE_DEBUG, " e towards %s\n", GNUNET_i2s (&msg->target));
1555 LOG (GNUNET_ERROR_TYPE_DEBUG, " got %u\n", res.nonce); 1555 LOG (GNUNET_ERROR_TYPE_DEBUG, " got %u\n", res.nonce);
@@ -1577,7 +1577,7 @@ handle_pong (struct CadetTunnel3 *t,
1577{ 1577{
1578 uint32_t challenge; 1578 uint32_t challenge;
1579 1579
1580 LOG (GNUNET_ERROR_TYPE_INFO, "<=== PONG for %s\n", GMT_2s (t)); 1580 LOG (GNUNET_ERROR_TYPE_INFO, "<=== PONG for %s\n", GCT_2s (t));
1581 if (GNUNET_SCHEDULER_NO_TASK == t->rekey_task) 1581 if (GNUNET_SCHEDULER_NO_TASK == t->rekey_task)
1582 { 1582 {
1583 GNUNET_STATISTICS_update (stats, "# duplicate PONG messages", 1, GNUNET_NO); 1583 GNUNET_STATISTICS_update (stats, "# duplicate PONG messages", 1, GNUNET_NO);
@@ -1587,7 +1587,7 @@ handle_pong (struct CadetTunnel3 *t,
1587 1587
1588 if (challenge != t->kx_ctx->challenge) 1588 if (challenge != t->kx_ctx->challenge)
1589 { 1589 {
1590 LOG (GNUNET_ERROR_TYPE_WARNING, "Wrong PONG challenge on %s\n", GMT_2s (t)); 1590 LOG (GNUNET_ERROR_TYPE_WARNING, "Wrong PONG challenge on %s\n", GCT_2s (t));
1591 LOG (GNUNET_ERROR_TYPE_DEBUG, "PONG: %u (e: %u). Expected: %u.\n", 1591 LOG (GNUNET_ERROR_TYPE_DEBUG, "PONG: %u (e: %u). Expected: %u.\n",
1592 challenge, msg->nonce, t->kx_ctx->challenge); 1592 challenge, msg->nonce, t->kx_ctx->challenge);
1593 send_ephemeral (t); 1593 send_ephemeral (t);
@@ -1598,7 +1598,7 @@ handle_pong (struct CadetTunnel3 *t,
1598 t->rekey_task = GNUNET_SCHEDULER_NO_TASK; 1598 t->rekey_task = GNUNET_SCHEDULER_NO_TASK;
1599 GNUNET_free (t->kx_ctx); 1599 GNUNET_free (t->kx_ctx);
1600 t->kx_ctx = NULL; 1600 t->kx_ctx = NULL;
1601 GMT_change_estate (t, CADET_TUNNEL3_KEY_OK); 1601 GCT_change_estate (t, CADET_TUNNEL3_KEY_OK);
1602} 1602}
1603 1603
1604 1604
@@ -1621,7 +1621,7 @@ handle_decrypted (struct CadetTunnel3 *t,
1621 uint16_t type; 1621 uint16_t type;
1622 1622
1623 type = ntohs (msgh->type); 1623 type = ntohs (msgh->type);
1624 LOG (GNUNET_ERROR_TYPE_INFO, "<=== %s on %s\n", GM_m2s (type), GMT_2s (t)); 1624 LOG (GNUNET_ERROR_TYPE_INFO, "<=== %s on %s\n", GC_m2s (type), GCT_2s (t));
1625 1625
1626 switch (type) 1626 switch (type)
1627 { 1627 {
@@ -1666,7 +1666,7 @@ handle_decrypted (struct CadetTunnel3 *t,
1666 LOG (GNUNET_ERROR_TYPE_WARNING, 1666 LOG (GNUNET_ERROR_TYPE_WARNING,
1667 "end-to-end message not known (%u)\n", 1667 "end-to-end message not known (%u)\n",
1668 ntohs (msgh->type)); 1668 ntohs (msgh->type));
1669 GMT_debug (t); 1669 GCT_debug (t);
1670 } 1670 }
1671} 1671}
1672 1672
@@ -1682,7 +1682,7 @@ handle_decrypted (struct CadetTunnel3 *t,
1682 * @param msg Encrypted message. 1682 * @param msg Encrypted message.
1683 */ 1683 */
1684void 1684void
1685GMT_handle_encrypted (struct CadetTunnel3 *t, 1685GCT_handle_encrypted (struct CadetTunnel3 *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);
@@ -1700,7 +1700,7 @@ GMT_handle_encrypted (struct CadetTunnel3 *t,
1700 /* checksum failed */ 1700 /* checksum failed */
1701 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1701 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1702 "Failed checksum validation for a message on tunnel `%s'\n", 1702 "Failed checksum validation for a message on tunnel `%s'\n",
1703 GMT_2s (t)); 1703 GCT_2s (t));
1704 GNUNET_STATISTICS_update (stats, "# wrong HMAC", 1, GNUNET_NO); 1704 GNUNET_STATISTICS_update (stats, "# wrong HMAC", 1, GNUNET_NO);
1705 return; 1705 return;
1706 } 1706 }
@@ -1721,7 +1721,7 @@ GMT_handle_encrypted (struct CadetTunnel3 *t,
1721 * @param message Payload of KX message. 1721 * @param message Payload of KX message.
1722 */ 1722 */
1723void 1723void
1724GMT_handle_kx (struct CadetTunnel3 *t, 1724GCT_handle_kx (struct CadetTunnel3 *t,
1725 const struct GNUNET_MessageHeader *message) 1725 const struct GNUNET_MessageHeader *message)
1726{ 1726{
1727 uint16_t type; 1727 uint16_t type;
@@ -1756,7 +1756,7 @@ GMT_handle_kx (struct CadetTunnel3 *t,
1756 * @param key ECC private key, to derive all other keys and do crypto. 1756 * @param key ECC private key, to derive all other keys and do crypto.
1757 */ 1757 */
1758void 1758void
1759GMT_init (const struct GNUNET_CONFIGURATION_Handle *c, 1759GCT_init (const struct GNUNET_CONFIGURATION_Handle *c,
1760 const struct GNUNET_CRYPTO_EddsaPrivateKey *key) 1760 const struct GNUNET_CRYPTO_EddsaPrivateKey *key)
1761{ 1761{
1762 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); 1762 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
@@ -1791,7 +1791,7 @@ GMT_init (const struct GNUNET_CONFIGURATION_Handle *c,
1791 * Shut down the tunnel subsystem. 1791 * Shut down the tunnel subsystem.
1792 */ 1792 */
1793void 1793void
1794GMT_shutdown (void) 1794GCT_shutdown (void)
1795{ 1795{
1796 if (GNUNET_SCHEDULER_NO_TASK != rekey_task) 1796 if (GNUNET_SCHEDULER_NO_TASK != rekey_task)
1797 { 1797 {
@@ -1809,7 +1809,7 @@ GMT_shutdown (void)
1809 * @param destination Peer this tunnel is towards. 1809 * @param destination Peer this tunnel is towards.
1810 */ 1810 */
1811struct CadetTunnel3 * 1811struct CadetTunnel3 *
1812GMT_new (struct CadetPeer *destination) 1812GCT_new (struct CadetPeer *destination)
1813{ 1813{
1814 struct CadetTunnel3 *t; 1814 struct CadetTunnel3 *t;
1815 1815
@@ -1818,7 +1818,7 @@ GMT_new (struct CadetPeer *destination)
1818 t->peer = destination; 1818 t->peer = destination;
1819 1819
1820 if (GNUNET_OK != 1820 if (GNUNET_OK !=
1821 GNUNET_CONTAINER_multipeermap_put (tunnels, GMP_get_id (destination), t, 1821 GNUNET_CONTAINER_multipeermap_put (tunnels, GCP_get_id (destination), t,
1822 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) 1822 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
1823 { 1823 {
1824 GNUNET_break (0); 1824 GNUNET_break (0);
@@ -1836,13 +1836,13 @@ GMT_new (struct CadetPeer *destination)
1836 * @param cstate New connection state. 1836 * @param cstate New connection state.
1837 */ 1837 */
1838void 1838void
1839GMT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate) 1839GCT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate)
1840{ 1840{
1841 if (NULL == t) 1841 if (NULL == t)
1842 return; 1842 return;
1843 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s cstate %s => %s\n", 1843 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s cstate %s => %s\n",
1844 GMP_2s (t->peer), cstate2s (t->cstate), cstate2s (cstate)); 1844 GCP_2s (t->peer), cstate2s (t->cstate), cstate2s (cstate));
1845 if (myid != GMP_get_short_id (t->peer) && 1845 if (myid != GCP_get_short_id (t->peer) &&
1846 CADET_TUNNEL3_READY != t->cstate && 1846 CADET_TUNNEL3_READY != t->cstate &&
1847 CADET_TUNNEL3_READY == cstate) 1847 CADET_TUNNEL3_READY == cstate)
1848 { 1848 {
@@ -1861,10 +1861,10 @@ GMT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate)
1861 t->cstate = cstate; 1861 t->cstate = cstate;
1862 1862
1863 if (CADET_TUNNEL3_READY == cstate 1863 if (CADET_TUNNEL3_READY == cstate
1864 && CONNECTIONS_PER_TUNNEL <= GMT_count_connections (t)) 1864 && CONNECTIONS_PER_TUNNEL <= GCT_count_connections (t))
1865 { 1865 {
1866 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered stop dht\n"); 1866 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered stop dht\n");
1867 GMP_stop_search (t->peer); 1867 GCP_stop_search (t->peer);
1868 } 1868 }
1869} 1869}
1870 1870
@@ -1875,17 +1875,17 @@ GMT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate)
1875 * @param state New encryption state. 1875 * @param state New encryption state.
1876 */ 1876 */
1877void 1877void
1878GMT_change_estate (struct CadetTunnel3* t, enum CadetTunnel3EState state) 1878GCT_change_estate (struct CadetTunnel3* t, enum CadetTunnel3EState state)
1879{ 1879{
1880 if (NULL == t) 1880 if (NULL == t)
1881 return; 1881 return;
1882 LOG (GNUNET_ERROR_TYPE_DEBUG, 1882 LOG (GNUNET_ERROR_TYPE_DEBUG,
1883 "Tunnel %s estate was %s\n", 1883 "Tunnel %s estate was %s\n",
1884 GMP_2s (t->peer), estate2s (t->estate)); 1884 GCP_2s (t->peer), estate2s (t->estate));
1885 LOG (GNUNET_ERROR_TYPE_DEBUG, 1885 LOG (GNUNET_ERROR_TYPE_DEBUG,
1886 "Tunnel %s estate is now %s\n", 1886 "Tunnel %s estate is now %s\n",
1887 GMP_2s (t->peer), estate2s (state)); 1887 GCP_2s (t->peer), estate2s (state));
1888 if (myid != GMP_get_short_id (t->peer) && 1888 if (myid != GCP_get_short_id (t->peer) &&
1889 CADET_TUNNEL3_KEY_OK != t->estate && CADET_TUNNEL3_KEY_OK == state) 1889 CADET_TUNNEL3_KEY_OK != t->estate && CADET_TUNNEL3_KEY_OK == state)
1890 { 1890 {
1891 t->estate = state; 1891 t->estate = state;
@@ -1914,7 +1914,7 @@ trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1914 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1914 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1915 return; 1915 return;
1916 1916
1917 if (GMT_count_connections (t) > 2 * CONNECTIONS_PER_TUNNEL) 1917 if (GCT_count_connections (t) > 2 * CONNECTIONS_PER_TUNNEL)
1918 { 1918 {
1919 struct CadetTConnection *iter; 1919 struct CadetTConnection *iter;
1920 struct CadetTConnection *c; 1920 struct CadetTConnection *c;
@@ -1922,7 +1922,7 @@ trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1922 for (c = iter = t->connection_head; NULL != iter; iter = iter->next) 1922 for (c = iter = t->connection_head; NULL != iter; iter = iter->next)
1923 { 1923 {
1924 if ((NULL == c || iter->created.abs_value_us > c->created.abs_value_us) 1924 if ((NULL == c || iter->created.abs_value_us > c->created.abs_value_us)
1925 && GNUNET_NO == GMC_is_direct (iter->c)) 1925 && GNUNET_NO == GCC_is_direct (iter->c))
1926 { 1926 {
1927 c = iter; 1927 c = iter;
1928 } 1928 }
@@ -1930,10 +1930,10 @@ trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1930 if (NULL != c) 1930 if (NULL != c)
1931 { 1931 {
1932 LOG (GNUNET_ERROR_TYPE_DEBUG, "Too many connections on tunnel %s\n", 1932 LOG (GNUNET_ERROR_TYPE_DEBUG, "Too many connections on tunnel %s\n",
1933 GMT_2s (t)); 1933 GCT_2s (t));
1934 LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying connection %s\n", 1934 LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying connection %s\n",
1935 GMC_2s (c->c)); 1935 GCC_2s (c->c));
1936 GMC_destroy (c->c); 1936 GCC_destroy (c->c);
1937 } 1937 }
1938 else 1938 else
1939 { 1939 {
@@ -1950,14 +1950,14 @@ trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1950 * @param c Connection. 1950 * @param c Connection.
1951 */ 1951 */
1952void 1952void
1953GMT_add_connection (struct CadetTunnel3 *t, struct CadetConnection *c) 1953GCT_add_connection (struct CadetTunnel3 *t, struct CadetConnection *c)
1954{ 1954{
1955 struct CadetTConnection *aux; 1955 struct CadetTConnection *aux;
1956 1956
1957 GNUNET_assert (NULL != c); 1957 GNUNET_assert (NULL != c);
1958 1958
1959 LOG (GNUNET_ERROR_TYPE_DEBUG, "add connection %s\n", GMC_2s (c)); 1959 LOG (GNUNET_ERROR_TYPE_DEBUG, "add connection %s\n", GCC_2s (c));
1960 LOG (GNUNET_ERROR_TYPE_DEBUG, " to tunnel %s\n", GMT_2s (t)); 1960 LOG (GNUNET_ERROR_TYPE_DEBUG, " to tunnel %s\n", GCT_2s (t));
1961 for (aux = t->connection_head; aux != NULL; aux = aux->next) 1961 for (aux = t->connection_head; aux != NULL; aux = aux->next)
1962 if (aux->c == c) 1962 if (aux->c == c)
1963 return; 1963 return;
@@ -1979,9 +1979,9 @@ GMT_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
1982GMT_remove_path (struct CadetTunnel3 *t, struct CadetPeerPath *path) 1982GCT_remove_path (struct CadetTunnel3 *t, struct CadetPeerPath *path)
1983{ 1983{
1984 GMP_remove_path (t->peer, path); 1984 GCP_remove_path (t->peer, path);
1985} 1985}
1986 1986
1987 1987
@@ -1992,14 +1992,14 @@ GMT_remove_path (struct CadetTunnel3 *t, struct CadetPeerPath *path)
1992 * @param c Connection. 1992 * @param c Connection.
1993 */ 1993 */
1994void 1994void
1995GMT_remove_connection (struct CadetTunnel3 *t, 1995GCT_remove_connection (struct CadetTunnel3 *t,
1996 struct CadetConnection *c) 1996 struct CadetConnection *c)
1997{ 1997{
1998 struct CadetTConnection *aux; 1998 struct CadetTConnection *aux;
1999 struct CadetTConnection *next; 1999 struct CadetTConnection *next;
2000 2000
2001 LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing connection %s from tunnel %s\n", 2001 LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing connection %s from tunnel %s\n",
2002 GMC_2s (c), GMT_2s (t)); 2002 GCC_2s (c), GCT_2s (t));
2003 for (aux = t->connection_head; aux != NULL; aux = next) 2003 for (aux = t->connection_head; aux != NULL; aux = next)
2004 { 2004 {
2005 next = aux->next; 2005 next = aux->next;
@@ -2011,14 +2011,14 @@ GMT_remove_connection (struct CadetTunnel3 *t,
2011 } 2011 }
2012 2012
2013 /* Start new connections if needed */ 2013 /* Start new connections if needed */
2014 if (CONNECTIONS_PER_TUNNEL < GMT_count_connections (t) 2014 if (CONNECTIONS_PER_TUNNEL < GCT_count_connections (t)
2015 && GNUNET_SCHEDULER_NO_TASK == t->destroy_task 2015 && GNUNET_SCHEDULER_NO_TASK == t->destroy_task
2016 && CADET_TUNNEL3_SHUTDOWN != t->cstate 2016 && CADET_TUNNEL3_SHUTDOWN != t->cstate
2017 && GNUNET_NO == shutting_down) 2017 && GNUNET_NO == shutting_down)
2018 { 2018 {
2019 LOG (GNUNET_ERROR_TYPE_DEBUG, " no more connections, getting new ones\n"); 2019 LOG (GNUNET_ERROR_TYPE_DEBUG, " no more connections, getting new ones\n");
2020 t->cstate = CADET_TUNNEL3_SEARCHING; 2020 t->cstate = CADET_TUNNEL3_SEARCHING;
2021 GMP_connect (t->peer); 2021 GCP_connect (t->peer);
2022 return; 2022 return;
2023 } 2023 }
2024 2024
@@ -2028,7 +2028,7 @@ GMT_remove_connection (struct CadetTunnel3 *t,
2028 2028
2029 /* Check if any connection is ready to maintaing cstate */ 2029 /* Check if any connection is ready to maintaing cstate */
2030 for (aux = t->connection_head; aux != NULL; aux = aux->next) 2030 for (aux = t->connection_head; aux != NULL; aux = aux->next)
2031 if (CADET_CONNECTION_READY == GMC_get_state (aux->c)) 2031 if (CADET_CONNECTION_READY == GCC_get_state (aux->c))
2032 return; 2032 return;
2033 2033
2034 t->cstate = CADET_TUNNEL3_WAITING; 2034 t->cstate = CADET_TUNNEL3_WAITING;
@@ -2042,7 +2042,7 @@ GMT_remove_connection (struct CadetTunnel3 *t,
2042 * @param ch Channel. 2042 * @param ch Channel.
2043 */ 2043 */
2044void 2044void
2045GMT_add_channel (struct CadetTunnel3 *t, struct CadetChannel *ch) 2045GCT_add_channel (struct CadetTunnel3 *t, struct CadetChannel *ch)
2046{ 2046{
2047 struct CadetTChannel *aux; 2047 struct CadetTChannel *aux;
2048 2048
@@ -2078,7 +2078,7 @@ GMT_add_channel (struct CadetTunnel3 *t, struct CadetChannel *ch)
2078 * @param ch Channel. 2078 * @param ch Channel.
2079 */ 2079 */
2080void 2080void
2081GMT_remove_channel (struct CadetTunnel3 *t, struct CadetChannel *ch) 2081GCT_remove_channel (struct CadetTunnel3 *t, struct CadetChannel *ch)
2082{ 2082{
2083 struct CadetTChannel *aux; 2083 struct CadetTChannel *aux;
2084 2084
@@ -2087,7 +2087,7 @@ GMT_remove_channel (struct CadetTunnel3 *t, struct CadetChannel *ch)
2087 { 2087 {
2088 if (aux->ch == ch) 2088 if (aux->ch == ch)
2089 { 2089 {
2090 LOG (GNUNET_ERROR_TYPE_DEBUG, " found! %s\n", GMCH_2s (ch)); 2090 LOG (GNUNET_ERROR_TYPE_DEBUG, " found! %s\n", GCCH_2s (ch));
2091 GNUNET_CONTAINER_DLL_remove (t->channel_head, t->channel_tail, aux); 2091 GNUNET_CONTAINER_DLL_remove (t->channel_head, t->channel_tail, aux);
2092 GNUNET_free (aux); 2092 GNUNET_free (aux);
2093 return; 2093 return;
@@ -2105,7 +2105,7 @@ GMT_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 *
2108GMT_get_channel (struct CadetTunnel3 *t, CADET_ChannelNumber chid) 2108GCT_get_channel (struct CadetTunnel3 *t, CADET_ChannelNumber chid)
2109{ 2109{
2110 struct CadetTChannel *iter; 2110 struct CadetTChannel *iter;
2111 2111
@@ -2114,7 +2114,7 @@ GMT_get_channel (struct CadetTunnel3 *t, CADET_ChannelNumber chid)
2114 2114
2115 for (iter = t->channel_head; NULL != iter; iter = iter->next) 2115 for (iter = t->channel_head; NULL != iter; iter = iter->next)
2116 { 2116 {
2117 if (GMCH_get_id (iter->ch) == chid) 2117 if (GCCH_get_id (iter->ch) == chid)
2118 break; 2118 break;
2119 } 2119 }
2120 2120
@@ -2143,7 +2143,7 @@ delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2143 { 2143 {
2144 LOG (GNUNET_ERROR_TYPE_WARNING, 2144 LOG (GNUNET_ERROR_TYPE_WARNING,
2145 "Not destroying tunnel, due to shutdown. " 2145 "Not destroying tunnel, due to shutdown. "
2146 "Tunnel at %p should have been freed by GMT_shutdown\n", t); 2146 "Tunnel at %p should have been freed by GCT_shutdown\n", t);
2147 return; 2147 return;
2148 } 2148 }
2149 t->destroy_task = GNUNET_SCHEDULER_NO_TASK; 2149 t->destroy_task = GNUNET_SCHEDULER_NO_TASK;
@@ -2151,9 +2151,9 @@ delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2151 2151
2152 for (iter = t->connection_head; NULL != iter; iter = iter->next) 2152 for (iter = t->connection_head; NULL != iter; iter = iter->next)
2153 { 2153 {
2154 GMC_send_destroy (iter->c); 2154 GCC_send_destroy (iter->c);
2155 } 2155 }
2156 GMT_destroy (t); 2156 GCT_destroy (t);
2157} 2157}
2158 2158
2159 2159
@@ -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
2168GMT_destroy_empty (struct CadetTunnel3 *t) 2168GCT_destroy_empty (struct CadetTunnel3 *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 */
@@ -2174,7 +2174,7 @@ GMT_destroy_empty (struct CadetTunnel3 *t)
2174 { 2174 {
2175 LOG (GNUNET_ERROR_TYPE_DEBUG, 2175 LOG (GNUNET_ERROR_TYPE_DEBUG,
2176 "Tunnel %s is already scheduled for destruction\n", 2176 "Tunnel %s is already scheduled for destruction\n",
2177 GMT_2s (t)); 2177 GCT_2s (t));
2178 GNUNET_break (0); 2178 GNUNET_break (0);
2179 /* should never happen, tunnel can only become empty once, and the 2179 /* should never happen, tunnel can only become empty once, and the
2180 * task identifier should be NO_TASK (cleaned when the tunnel was created 2180 * task identifier should be NO_TASK (cleaned when the tunnel was created
@@ -2184,7 +2184,7 @@ GMT_destroy_empty (struct CadetTunnel3 *t)
2184 } 2184 }
2185 2185
2186 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s empty: destroying scheduled\n", 2186 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s empty: destroying scheduled\n",
2187 GMT_2s (t)); 2187 GCT_2s (t));
2188 2188
2189 t->destroy_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 2189 t->destroy_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
2190 &delayed_destroy, t); 2190 &delayed_destroy, t);
@@ -2199,13 +2199,13 @@ GMT_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
2202GMT_destroy_if_empty (struct CadetTunnel3 *t) 2202GCT_destroy_if_empty (struct CadetTunnel3 *t)
2203{ 2203{
2204 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s destroy if empty\n", GMT_2s (t)); 2204 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s destroy if empty\n", GCT_2s (t));
2205 if (1 < GMT_count_channels (t)) 2205 if (1 < GCT_count_channels (t))
2206 return; 2206 return;
2207 2207
2208 GMT_destroy_empty (t); 2208 GCT_destroy_empty (t);
2209} 2209}
2210 2210
2211 2211
@@ -2221,7 +2221,7 @@ GMT_destroy_if_empty (struct CadetTunnel3 *t)
2221 * @param t The tunnel to destroy. 2221 * @param t The tunnel to destroy.
2222 */ 2222 */
2223void 2223void
2224GMT_destroy (struct CadetTunnel3 *t) 2224GCT_destroy (struct CadetTunnel3 *t)
2225{ 2225{
2226 struct CadetTConnection *iter_c; 2226 struct CadetTConnection *iter_c;
2227 struct CadetTConnection *next_c; 2227 struct CadetTConnection *next_c;
@@ -2231,21 +2231,21 @@ GMT_destroy (struct CadetTunnel3 *t)
2231 if (NULL == t) 2231 if (NULL == t)
2232 return; 2232 return;
2233 2233
2234 LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s\n", GMP_2s (t->peer)); 2234 LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s\n", GCP_2s (t->peer));
2235 2235
2236 GNUNET_break (GNUNET_YES == 2236 GNUNET_break (GNUNET_YES ==
2237 GNUNET_CONTAINER_multipeermap_remove (tunnels, 2237 GNUNET_CONTAINER_multipeermap_remove (tunnels,
2238 GMP_get_id (t->peer), t)); 2238 GCP_get_id (t->peer), t));
2239 2239
2240 for (iter_c = t->connection_head; NULL != iter_c; iter_c = next_c) 2240 for (iter_c = t->connection_head; NULL != iter_c; iter_c = next_c)
2241 { 2241 {
2242 next_c = iter_c->next; 2242 next_c = iter_c->next;
2243 GMC_destroy (iter_c->c); 2243 GCC_destroy (iter_c->c);
2244 } 2244 }
2245 for (iter_ch = t->channel_head; NULL != iter_ch; iter_ch = next_ch) 2245 for (iter_ch = t->channel_head; NULL != iter_ch; iter_ch = next_ch)
2246 { 2246 {
2247 next_ch = iter_ch->next; 2247 next_ch = iter_ch->next;
2248 GMCH_destroy (iter_ch->ch); 2248 GCCH_destroy (iter_ch->ch);
2249 /* Should only happen on shutdown, but it's ok. */ 2249 /* Should only happen on shutdown, but it's ok. */
2250 } 2250 }
2251 2251
@@ -2257,7 +2257,7 @@ GMT_destroy (struct CadetTunnel3 *t)
2257 } 2257 }
2258 2258
2259 GNUNET_STATISTICS_update (stats, "# tunnels", -1, GNUNET_NO); 2259 GNUNET_STATISTICS_update (stats, "# tunnels", -1, GNUNET_NO);
2260 GMP_set_tunnel (t->peer, NULL); 2260 GCP_set_tunnel (t->peer, NULL);
2261 2261
2262 if (GNUNET_SCHEDULER_NO_TASK != t->rekey_task) 2262 if (GNUNET_SCHEDULER_NO_TASK != t->rekey_task)
2263 { 2263 {
@@ -2284,7 +2284,7 @@ GMT_destroy (struct CadetTunnel3 *t)
2284 * @return Connection created. 2284 * @return Connection created.
2285 */ 2285 */
2286struct CadetConnection * 2286struct CadetConnection *
2287GMT_use_path (struct CadetTunnel3 *t, struct CadetPeerPath *p) 2287GCT_use_path (struct CadetTunnel3 *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;
@@ -2314,13 +2314,13 @@ GMT_use_path (struct CadetTunnel3 *t, struct CadetPeerPath *p)
2314 } 2314 }
2315 2315
2316 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, &cid, sizeof (cid)); 2316 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, &cid, sizeof (cid));
2317 c = GMC_new (&cid, t, p, own_pos); 2317 c = GCC_new (&cid, t, p, own_pos);
2318 if (NULL == c) 2318 if (NULL == c)
2319 { 2319 {
2320 /* Path was flawed */ 2320 /* Path was flawed */
2321 return NULL; 2321 return NULL;
2322 } 2322 }
2323 GMT_add_connection (t, c); 2323 GCT_add_connection (t, c);
2324 return c; 2324 return c;
2325} 2325}
2326 2326
@@ -2333,7 +2333,7 @@ GMT_use_path (struct CadetTunnel3 *t, struct CadetPeerPath *p)
2333 * @return Number of connections. 2333 * @return Number of connections.
2334 */ 2334 */
2335unsigned int 2335unsigned int
2336GMT_count_connections (struct CadetTunnel3 *t) 2336GCT_count_connections (struct CadetTunnel3 *t)
2337{ 2337{
2338 struct CadetTConnection *iter; 2338 struct CadetTConnection *iter;
2339 unsigned int count; 2339 unsigned int count;
@@ -2342,7 +2342,7 @@ GMT_count_connections (struct CadetTunnel3 *t)
2342 return 0; 2342 return 0;
2343 2343
2344 for (count = 0, iter = t->connection_head; NULL != iter; iter = iter->next) 2344 for (count = 0, iter = t->connection_head; NULL != iter; iter = iter->next)
2345 if (CADET_CONNECTION_DESTROYED != GMC_get_state (iter->c)) 2345 if (CADET_CONNECTION_DESTROYED != GCC_get_state (iter->c))
2346 count++; 2346 count++;
2347 2347
2348 return count; 2348 return count;
@@ -2356,7 +2356,7 @@ GMT_count_connections (struct CadetTunnel3 *t)
2356 * @return Number of channels. 2356 * @return Number of channels.
2357 */ 2357 */
2358unsigned int 2358unsigned int
2359GMT_count_channels (struct CadetTunnel3 *t) 2359GCT_count_channels (struct CadetTunnel3 *t)
2360{ 2360{
2361 struct CadetTChannel *iter; 2361 struct CadetTChannel *iter;
2362 unsigned int count; 2362 unsigned int count;
@@ -2377,7 +2377,7 @@ GMT_count_channels (struct CadetTunnel3 *t)
2377 * @return Tunnel's connectivity state. 2377 * @return Tunnel's connectivity state.
2378 */ 2378 */
2379enum CadetTunnel3CState 2379enum CadetTunnel3CState
2380GMT_get_cstate (struct CadetTunnel3 *t) 2380GCT_get_cstate (struct CadetTunnel3 *t)
2381{ 2381{
2382 if (NULL == t) 2382 if (NULL == t)
2383 { 2383 {
@@ -2396,7 +2396,7 @@ GMT_get_cstate (struct CadetTunnel3 *t)
2396 * @return Tunnel's encryption state. 2396 * @return Tunnel's encryption state.
2397 */ 2397 */
2398enum CadetTunnel3EState 2398enum CadetTunnel3EState
2399GMT_get_estate (struct CadetTunnel3 *t) 2399GCT_get_estate (struct CadetTunnel3 *t)
2400{ 2400{
2401 if (NULL == t) 2401 if (NULL == t)
2402 { 2402 {
@@ -2414,7 +2414,7 @@ GMT_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
2417GMT_get_channels_buffer (struct CadetTunnel3 *t) 2417GCT_get_channels_buffer (struct CadetTunnel3 *t)
2418{ 2418{
2419 struct CadetTChannel *iter; 2419 struct CadetTChannel *iter;
2420 unsigned int buffer; 2420 unsigned int buffer;
@@ -2445,7 +2445,7 @@ GMT_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
2448GMT_get_connections_buffer (struct CadetTunnel3 *t) 2448GCT_get_connections_buffer (struct CadetTunnel3 *t)
2449{ 2449{
2450 struct CadetTConnection *iter; 2450 struct CadetTConnection *iter;
2451 unsigned int buffer; 2451 unsigned int buffer;
@@ -2453,7 +2453,7 @@ GMT_get_connections_buffer (struct CadetTunnel3 *t)
2453 buffer = 0; 2453 buffer = 0;
2454 for (iter = t->connection_head; NULL != iter; iter = iter->next) 2454 for (iter = t->connection_head; NULL != iter; iter = iter->next)
2455 { 2455 {
2456 if (GMC_get_state (iter->c) != CADET_CONNECTION_READY) 2456 if (GCC_get_state (iter->c) != CADET_CONNECTION_READY)
2457 { 2457 {
2458 continue; 2458 continue;
2459 } 2459 }
@@ -2472,9 +2472,9 @@ GMT_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 *
2475GMT_get_destination (struct CadetTunnel3 *t) 2475GCT_get_destination (struct CadetTunnel3 *t)
2476{ 2476{
2477 return GMP_get_id (t->peer); 2477 return GCP_get_id (t->peer);
2478} 2478}
2479 2479
2480 2480
@@ -2486,7 +2486,7 @@ GMT_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
2489GMT_get_next_chid (struct CadetTunnel3 *t) 2489GCT_get_next_chid (struct CadetTunnel3 *t)
2490{ 2490{
2491 CADET_ChannelNumber chid; 2491 CADET_ChannelNumber chid;
2492 CADET_ChannelNumber mask; 2492 CADET_ChannelNumber mask;
@@ -2496,14 +2496,14 @@ GMT_get_next_chid (struct CadetTunnel3 *t)
2496 * If our ID is bigger or loopback tunnel, start at 0, bit 30 = 0 2496 * If our ID is bigger or loopback tunnel, start at 0, bit 30 = 0
2497 * If peer's ID is bigger, start at 0x4... bit 30 = 1 2497 * If peer's ID is bigger, start at 0x4... bit 30 = 1
2498 */ 2498 */
2499 result = GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, GMP_get_id (t->peer)); 2499 result = GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, GCP_get_id (t->peer));
2500 if (0 > result) 2500 if (0 > result)
2501 mask = 0x40000000; 2501 mask = 0x40000000;
2502 else 2502 else
2503 mask = 0x0; 2503 mask = 0x0;
2504 t->next_chid |= mask; 2504 t->next_chid |= mask;
2505 2505
2506 while (NULL != GMT_get_channel (t, t->next_chid)) 2506 while (NULL != GCT_get_channel (t, t->next_chid))
2507 { 2507 {
2508 LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %u exists...\n", t->next_chid); 2508 LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %u exists...\n", t->next_chid);
2509 t->next_chid = (t->next_chid + 1) & ~GNUNET_CADET_LOCAL_CHANNEL_ID_CLI; 2509 t->next_chid = (t->next_chid + 1) & ~GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
@@ -2523,21 +2523,21 @@ GMT_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
2526GMT_unchoke_channels (struct CadetTunnel3 *t) 2526GCT_unchoke_channels (struct CadetTunnel3 *t)
2527{ 2527{
2528 struct CadetTChannel *iter; 2528 struct CadetTChannel *iter;
2529 unsigned int buffer; 2529 unsigned int buffer;
2530 unsigned int channels = GMT_count_channels (t); 2530 unsigned int channels = GCT_count_channels (t);
2531 unsigned int choked_n; 2531 unsigned int choked_n;
2532 struct CadetChannel *choked[channels]; 2532 struct CadetChannel *choked[channels];
2533 2533
2534 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT_unchoke_channels on %s\n", GMT_2s (t)); 2534 LOG (GNUNET_ERROR_TYPE_DEBUG, "GCT_unchoke_channels on %s\n", GCT_2s (t));
2535 LOG (GNUNET_ERROR_TYPE_DEBUG, " head: %p\n", t->channel_head); 2535 LOG (GNUNET_ERROR_TYPE_DEBUG, " head: %p\n", t->channel_head);
2536 if (NULL != t->channel_head) 2536 if (NULL != t->channel_head)
2537 LOG (GNUNET_ERROR_TYPE_DEBUG, " head ch: %p\n", t->channel_head->ch); 2537 LOG (GNUNET_ERROR_TYPE_DEBUG, " head ch: %p\n", t->channel_head->ch);
2538 2538
2539 /* Get buffer space */ 2539 /* Get buffer space */
2540 buffer = GMT_get_connections_buffer (t); 2540 buffer = GCT_get_connections_buffer (t);
2541 if (0 == buffer) 2541 if (0 == buffer)
2542 { 2542 {
2543 return; 2543 return;
@@ -2558,7 +2558,7 @@ GMT_unchoke_channels (struct CadetTunnel3 *t)
2558 { 2558 {
2559 unsigned int r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2559 unsigned int r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
2560 choked_n); 2560 choked_n);
2561 GMCH_allow_client (choked[r], GMCH_is_origin (choked[r], GNUNET_YES)); 2561 GCCH_allow_client (choked[r], GCCH_is_origin (choked[r], GNUNET_YES));
2562 choked_n--; 2562 choked_n--;
2563 buffer--; 2563 buffer--;
2564 choked[r] = choked[choked_n]; 2564 choked[r] = choked[choked_n];
@@ -2574,7 +2574,7 @@ GMT_unchoke_channels (struct CadetTunnel3 *t)
2574 * @param t Tunnel. 2574 * @param t Tunnel.
2575 */ 2575 */
2576void 2576void
2577GMT_send_connection_acks (struct CadetTunnel3 *t) 2577GCT_send_connection_acks (struct CadetTunnel3 *t)
2578{ 2578{
2579 struct CadetTConnection *iter; 2579 struct CadetTConnection *iter;
2580 uint32_t allowed; 2580 uint32_t allowed;
@@ -2584,7 +2584,7 @@ GMT_send_connection_acks (struct CadetTunnel3 *t)
2584 unsigned int buffer; 2584 unsigned int buffer;
2585 2585
2586 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel send connection ACKs on %s\n", 2586 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel send connection ACKs on %s\n",
2587 GMT_2s (t)); 2587 GCT_2s (t));
2588 2588
2589 if (NULL == t) 2589 if (NULL == t)
2590 { 2590 {
@@ -2592,11 +2592,11 @@ GMT_send_connection_acks (struct CadetTunnel3 *t)
2592 return; 2592 return;
2593 } 2593 }
2594 2594
2595 buffer = GMT_get_channels_buffer (t); 2595 buffer = GCT_get_channels_buffer (t);
2596 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer %u\n", buffer); 2596 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer %u\n", buffer);
2597 2597
2598 /* Count connections, how many messages are already allowed */ 2598 /* Count connections, how many messages are already allowed */
2599 cs = GMT_count_connections (t); 2599 cs = GCT_count_connections (t);
2600 for (allowed = 0, iter = t->connection_head; NULL != iter; iter = iter->next) 2600 for (allowed = 0, iter = t->connection_head; NULL != iter; iter = iter->next)
2601 { 2601 {
2602 allowed += get_connection_allowed (iter); 2602 allowed += get_connection_allowed (iter);
@@ -2623,8 +2623,8 @@ GMT_send_connection_acks (struct CadetTunnel3 *t)
2623 { 2623 {
2624 continue; 2624 continue;
2625 } 2625 }
2626 GMC_allow (iter->c, allow_per_connection, 2626 GCC_allow (iter->c, allow_per_connection,
2627 GMC_is_origin (iter->c, GNUNET_NO)); 2627 GCC_is_origin (iter->c, GNUNET_NO));
2628 } 2628 }
2629 2629
2630 GNUNET_break (to_allow == 0); 2630 GNUNET_break (to_allow == 0);
@@ -2641,11 +2641,11 @@ GMT_send_connection_acks (struct CadetTunnel3 *t)
2641 * @param q Handle to the queue. 2641 * @param q Handle to the queue.
2642 */ 2642 */
2643void 2643void
2644GMT_cancel (struct CadetTunnel3Queue *q) 2644GCT_cancel (struct CadetTunnel3Queue *q)
2645{ 2645{
2646 if (NULL != q->cq) 2646 if (NULL != q->cq)
2647 { 2647 {
2648 GMC_cancel (q->cq); 2648 GCC_cancel (q->cq);
2649 /* tun_message_sent() will be called and free q */ 2649 /* tun_message_sent() will be called and free q */
2650 } 2650 }
2651 else if (NULL != q->tqd) 2651 else if (NULL != q->tqd)
@@ -2677,9 +2677,9 @@ GMT_cancel (struct CadetTunnel3Queue *q)
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 CadetTunnel3Queue *
2680GMT_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 CadetTunnel3 *t, struct CadetConnection *c,
2682 int force, GMT_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);
2685} 2685}
@@ -2693,9 +2693,9 @@ GMT_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
2696GMT_is_loopback (const struct CadetTunnel3 *t) 2696GCT_is_loopback (const struct CadetTunnel3 *t)
2697{ 2697{
2698 return (myid == GMP_get_short_id (t->peer)); 2698 return (myid == GCP_get_short_id (t->peer));
2699} 2699}
2700 2700
2701 2701
@@ -2708,12 +2708,12 @@ GMT_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
2711GMT_is_path_used (const struct CadetTunnel3 *t, const struct CadetPeerPath *p) 2711GCT_is_path_used (const struct CadetTunnel3 *t, const struct CadetPeerPath *p)
2712{ 2712{
2713 struct CadetTConnection *iter; 2713 struct CadetTConnection *iter;
2714 2714
2715 for (iter = t->connection_head; NULL != iter; iter = iter->next) 2715 for (iter = t->connection_head; NULL != iter; iter = iter->next)
2716 if (GMC_get_path (iter->c) == p) 2716 if (GCC_get_path (iter->c) == p)
2717 return GNUNET_YES; 2717 return GNUNET_YES;
2718 2718
2719 return GNUNET_NO; 2719 return GNUNET_NO;
@@ -2729,7 +2729,7 @@ GMT_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
2732GMT_get_path_cost (const struct CadetTunnel3 *t, 2732GCT_get_path_cost (const struct CadetTunnel3 *t,
2733 const struct CadetPeerPath *path) 2733 const struct CadetPeerPath *path)
2734{ 2734{
2735 struct CadetTConnection *iter; 2735 struct CadetTConnection *iter;
@@ -2748,7 +2748,7 @@ GMT_get_path_cost (const struct CadetTunnel3 *t,
2748 { 2748 {
2749 for (iter = t->connection_head; NULL != iter; iter = iter->next) 2749 for (iter = t->connection_head; NULL != iter; iter = iter->next)
2750 { 2750 {
2751 aux = GMC_get_path (iter->c); 2751 aux = GCC_get_path (iter->c);
2752 if (NULL == aux) 2752 if (NULL == aux)
2753 continue; 2753 continue;
2754 2754
@@ -2774,12 +2774,12 @@ GMT_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 *
2777GMT_2s (const struct CadetTunnel3 *t) 2777GCT_2s (const struct CadetTunnel3 *t)
2778{ 2778{
2779 if (NULL == t) 2779 if (NULL == t)
2780 return "(NULL)"; 2780 return "(NULL)";
2781 2781
2782 return GMP_2s (t->peer); 2782 return GCP_2s (t->peer);
2783} 2783}
2784 2784
2785 2785
@@ -2794,12 +2794,12 @@ GMT_2s (const struct CadetTunnel3 *t)
2794 * @param t Tunnel to debug. 2794 * @param t Tunnel to debug.
2795 */ 2795 */
2796void 2796void
2797GMT_debug (const struct CadetTunnel3 *t) 2797GCT_debug (const struct CadetTunnel3 *t)
2798{ 2798{
2799 struct CadetTChannel *iterch; 2799 struct CadetTChannel *iterch;
2800 struct CadetTConnection *iterc; 2800 struct CadetTConnection *iterc;
2801 2801
2802 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT DEBUG TUNNEL TOWARDS %s\n", GMT_2s (t)); 2802 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT DEBUG TUNNEL TOWARDS %s\n", GCT_2s (t));
2803 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT cstate %s, estate %s\n", 2803 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT cstate %s, estate %s\n",
2804 cstate2s (t->cstate), estate2s (t->estate)); 2804 cstate2s (t->cstate), estate2s (t->estate));
2805 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT kx_ctx %p, rekey_task %u\n", 2805 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT kx_ctx %p, rekey_task %u\n",
@@ -2811,18 +2811,18 @@ GMT_debug (const struct CadetTunnel3 *t)
2811 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT channels:\n"); 2811 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT channels:\n");
2812 for (iterch = t->channel_head; NULL != iterch; iterch = iterch->next) 2812 for (iterch = t->channel_head; NULL != iterch; iterch = iterch->next)
2813 { 2813 {
2814 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT - %s\n", GMCH_2s (iterch->ch)); 2814 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT - %s\n", GCCH_2s (iterch->ch));
2815 } 2815 }
2816 2816
2817 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT connections:\n"); 2817 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT connections:\n");
2818 for (iterc = t->connection_head; NULL != iterc; iterc = iterc->next) 2818 for (iterc = t->connection_head; NULL != iterc; iterc = iterc->next)
2819 { 2819 {
2820 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT - %s [%u] buf: %u/%u (qn %u/%u)\n", 2820 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT - %s [%u] buf: %u/%u (qn %u/%u)\n",
2821 GMC_2s (iterc->c), GMC_get_state (iterc->c), 2821 GCC_2s (iterc->c), GCC_get_state (iterc->c),
2822 GMC_get_buffer (iterc->c, GNUNET_YES), 2822 GCC_get_buffer (iterc->c, GNUNET_YES),
2823 GMC_get_buffer (iterc->c, GNUNET_NO), 2823 GCC_get_buffer (iterc->c, GNUNET_NO),
2824 GMC_get_qn (iterc->c, GNUNET_YES), 2824 GCC_get_qn (iterc->c, GNUNET_YES),
2825 GMC_get_qn (iterc->c, GNUNET_NO)); 2825 GCC_get_qn (iterc->c, GNUNET_NO));
2826 } 2826 }
2827 2827
2828 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT DEBUG TUNNEL END\n"); 2828 LOG (GNUNET_ERROR_TYPE_DEBUG, "TTT DEBUG TUNNEL END\n");
@@ -2836,7 +2836,7 @@ GMT_debug (const struct CadetTunnel3 *t)
2836 * @param cls Closure for @c iter. 2836 * @param cls Closure for @c iter.
2837 */ 2837 */
2838void 2838void
2839GMT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls) 2839GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls)
2840{ 2840{
2841 GNUNET_CONTAINER_multipeermap_iterate (tunnels, iter, cls); 2841 GNUNET_CONTAINER_multipeermap_iterate (tunnels, iter, cls);
2842} 2842}
@@ -2848,7 +2848,7 @@ GMT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls)
2848 * @return Number of tunnels to remote peers kept by this peer. 2848 * @return Number of tunnels to remote peers kept by this peer.
2849 */ 2849 */
2850unsigned int 2850unsigned int
2851GMT_count_all (void) 2851GCT_count_all (void)
2852{ 2852{
2853 return GNUNET_CONTAINER_multipeermap_size (tunnels); 2853 return GNUNET_CONTAINER_multipeermap_size (tunnels);
2854} 2854}
@@ -2862,7 +2862,7 @@ GMT_count_all (void)
2862 * @param cls Closure for @c iter. 2862 * @param cls Closure for @c iter.
2863 */ 2863 */
2864void 2864void
2865GMT_iterate_connections (struct CadetTunnel3 *t, GMT_conn_iter iter, void *cls) 2865GCT_iterate_connections (struct CadetTunnel3 *t, GCT_conn_iter iter, void *cls)
2866{ 2866{
2867 struct CadetTConnection *ct; 2867 struct CadetTConnection *ct;
2868 2868
@@ -2879,7 +2879,7 @@ GMT_iterate_connections (struct CadetTunnel3 *t, GMT_conn_iter iter, void *cls)
2879 * @param cls Closure for @c iter. 2879 * @param cls Closure for @c iter.
2880 */ 2880 */
2881void 2881void
2882GMT_iterate_channels (struct CadetTunnel3 *t, GMT_chan_iter iter, void *cls) 2882GCT_iterate_channels (struct CadetTunnel3 *t, GCT_chan_iter iter, void *cls)
2883{ 2883{
2884 struct CadetTChannel *cht; 2884 struct CadetTChannel *cht;
2885 2885
diff --git a/src/cadet/gnunet-service-cadet_tunnel.h b/src/cadet/gnunet-service-cadet_tunnel.h
index 16616de59..304015fa5 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.h
+++ b/src/cadet/gnunet-service-cadet_tunnel.h
@@ -123,13 +123,13 @@ struct CadetTunnel3Queue;
123 * @param type Type of message sent. 123 * @param type Type of message sent.
124 * @param size Size of the message. 124 * @param size Size of the message.
125 */ 125 */
126typedef void (*GMT_sent) (void *cls, 126typedef void (*GCT_sent) (void *cls,
127 struct CadetTunnel3 *t, 127 struct CadetTunnel3 *t,
128 struct CadetTunnel3Queue *q, 128 struct CadetTunnel3Queue *q,
129 uint16_t type, size_t size); 129 uint16_t type, size_t size);
130 130
131typedef void (*GMT_conn_iter) (void *cls, struct CadetConnection *c); 131typedef void (*GCT_conn_iter) (void *cls, struct CadetConnection *c);
132typedef void (*GMT_chan_iter) (void *cls, struct CadetChannel *ch); 132typedef void (*GCT_chan_iter) (void *cls, struct CadetChannel *ch);
133 133
134 134
135/******************************************************************************/ 135/******************************************************************************/
@@ -143,14 +143,14 @@ typedef void (*GMT_chan_iter) (void *cls, struct CadetChannel *ch);
143 * @param key ECC private key, to derive all other keys and do crypto. 143 * @param key ECC private key, to derive all other keys and do crypto.
144 */ 144 */
145void 145void
146GMT_init (const struct GNUNET_CONFIGURATION_Handle *c, 146GCT_init (const struct GNUNET_CONFIGURATION_Handle *c,
147 const struct GNUNET_CRYPTO_EddsaPrivateKey *key); 147 const struct GNUNET_CRYPTO_EddsaPrivateKey *key);
148 148
149/** 149/**
150 * Shut down the tunnel subsystem. 150 * Shut down the tunnel subsystem.
151 */ 151 */
152void 152void
153GMT_shutdown (void); 153GCT_shutdown (void);
154 154
155/** 155/**
156 * Create a tunnel. 156 * Create a tunnel.
@@ -158,7 +158,7 @@ GMT_shutdown (void);
158 * @param destination Peer this tunnel is towards. 158 * @param destination Peer this tunnel is towards.
159 */ 159 */
160struct CadetTunnel3 * 160struct CadetTunnel3 *
161GMT_new (struct CadetPeer *destination); 161GCT_new (struct CadetPeer *destination);
162 162
163/** 163/**
164 * Tunnel is empty: destroy it. 164 * Tunnel is empty: destroy it.
@@ -168,7 +168,7 @@ GMT_new (struct CadetPeer *destination);
168 * @param t Tunnel to destroy. 168 * @param t Tunnel to destroy.
169 */ 169 */
170void 170void
171GMT_destroy_empty (struct CadetTunnel3 *t); 171GCT_destroy_empty (struct CadetTunnel3 *t);
172 172
173/** 173/**
174 * Destroy tunnel if empty (no more channels). 174 * Destroy tunnel if empty (no more channels).
@@ -176,7 +176,7 @@ GMT_destroy_empty (struct CadetTunnel3 *t);
176 * @param t Tunnel to destroy if empty. 176 * @param t Tunnel to destroy if empty.
177 */ 177 */
178void 178void
179GMT_destroy_if_empty (struct CadetTunnel3 *t); 179GCT_destroy_if_empty (struct CadetTunnel3 *t);
180 180
181/** 181/**
182 * Destroy the tunnel. 182 * Destroy the tunnel.
@@ -190,7 +190,7 @@ GMT_destroy_if_empty (struct CadetTunnel3 *t);
190 * @param t The tunnel to destroy. 190 * @param t The tunnel to destroy.
191 */ 191 */
192void 192void
193GMT_destroy (struct CadetTunnel3 *t); 193GCT_destroy (struct CadetTunnel3 *t);
194 194
195 195
196/** 196/**
@@ -200,7 +200,7 @@ GMT_destroy (struct CadetTunnel3 *t);
200 * @param cstate New connection state. 200 * @param cstate New connection state.
201 */ 201 */
202void 202void
203GMT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate); 203GCT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate);
204 204
205 205
206/** 206/**
@@ -210,7 +210,7 @@ GMT_change_cstate (struct CadetTunnel3* t, enum CadetTunnel3CState cstate);
210 * @param state New encryption state. 210 * @param state New encryption state.
211 */ 211 */
212void 212void
213GMT_change_estate (struct CadetTunnel3* t, enum CadetTunnel3EState state); 213GCT_change_estate (struct CadetTunnel3* t, enum CadetTunnel3EState state);
214 214
215/** 215/**
216 * Add a connection to a tunnel. 216 * Add a connection to a tunnel.
@@ -219,7 +219,7 @@ GMT_change_estate (struct CadetTunnel3* t, enum CadetTunnel3EState state);
219 * @param c Connection. 219 * @param c Connection.
220 */ 220 */
221void 221void
222GMT_add_connection (struct CadetTunnel3 *t, struct CadetConnection *c); 222GCT_add_connection (struct CadetTunnel3 *t, struct CadetConnection *c);
223 223
224/** 224/**
225 * Mark a path as no longer valid for this tunnel: has been tried and failed. 225 * Mark a path as no longer valid for this tunnel: has been tried and failed.
@@ -228,7 +228,7 @@ GMT_add_connection (struct CadetTunnel3 *t, struct CadetConnection *c);
228 * @param path Invalid path to remove. Is destroyed after removal. 228 * @param path Invalid path to remove. Is destroyed after removal.
229 */ 229 */
230void 230void
231GMT_remove_path (struct CadetTunnel3 *t, struct CadetPeerPath *path); 231GCT_remove_path (struct CadetTunnel3 *t, struct CadetPeerPath *path);
232 232
233/** 233/**
234 * Remove a connection from a tunnel. 234 * Remove a connection from a tunnel.
@@ -237,7 +237,7 @@ GMT_remove_path (struct CadetTunnel3 *t, struct CadetPeerPath *path);
237 * @param c Connection. 237 * @param c Connection.
238 */ 238 */
239void 239void
240GMT_remove_connection (struct CadetTunnel3 *t, struct CadetConnection *c); 240GCT_remove_connection (struct CadetTunnel3 *t, struct CadetConnection *c);
241 241
242/** 242/**
243 * Add a channel to a tunnel. 243 * Add a channel to a tunnel.
@@ -246,7 +246,7 @@ GMT_remove_connection (struct CadetTunnel3 *t, struct CadetConnection *c);
246 * @param ch Channel. 246 * @param ch Channel.
247 */ 247 */
248void 248void
249GMT_add_channel (struct CadetTunnel3 *t, struct CadetChannel *ch); 249GCT_add_channel (struct CadetTunnel3 *t, struct CadetChannel *ch);
250 250
251/** 251/**
252 * Remove a channel from a tunnel. 252 * Remove a channel from a tunnel.
@@ -255,7 +255,7 @@ GMT_add_channel (struct CadetTunnel3 *t, struct CadetChannel *ch);
255 * @param ch Channel. 255 * @param ch Channel.
256 */ 256 */
257void 257void
258GMT_remove_channel (struct CadetTunnel3 *t, struct CadetChannel *ch); 258GCT_remove_channel (struct CadetTunnel3 *t, struct CadetChannel *ch);
259 259
260/** 260/**
261 * Search for a channel by global ID. 261 * Search for a channel by global ID.
@@ -266,7 +266,7 @@ GMT_remove_channel (struct CadetTunnel3 *t, struct CadetChannel *ch);
266 * @return channel handler, NULL if doesn't exist 266 * @return channel handler, NULL if doesn't exist
267 */ 267 */
268struct CadetChannel * 268struct CadetChannel *
269GMT_get_channel (struct CadetTunnel3 *t, CADET_ChannelNumber chid); 269GCT_get_channel (struct CadetTunnel3 *t, CADET_ChannelNumber chid);
270 270
271/** 271/**
272 * Decrypt and demultiplex by message type. Call appropriate handler 272 * Decrypt and demultiplex by message type. Call appropriate handler
@@ -277,7 +277,7 @@ GMT_get_channel (struct CadetTunnel3 *t, CADET_ChannelNumber chid);
277 * @param msg Message header. 277 * @param msg Message header.
278 */ 278 */
279void 279void
280GMT_handle_encrypted (struct CadetTunnel3 *t, 280GCT_handle_encrypted (struct CadetTunnel3 *t,
281 const struct GNUNET_CADET_Encrypted *msg); 281 const struct GNUNET_CADET_Encrypted *msg);
282 282
283/** 283/**
@@ -287,7 +287,7 @@ GMT_handle_encrypted (struct CadetTunnel3 *t,
287 * @param message KX message itself. 287 * @param message KX message itself.
288 */ 288 */
289void 289void
290GMT_handle_kx (struct CadetTunnel3 *t, 290GCT_handle_kx (struct CadetTunnel3 *t,
291 const struct GNUNET_MessageHeader *message); 291 const struct GNUNET_MessageHeader *message);
292 292
293/** 293/**
@@ -301,7 +301,7 @@ GMT_handle_kx (struct CadetTunnel3 *t,
301 * @return Connection created. 301 * @return Connection created.
302 */ 302 */
303struct CadetConnection * 303struct CadetConnection *
304GMT_use_path (struct CadetTunnel3 *t, struct CadetPeerPath *p); 304GCT_use_path (struct CadetTunnel3 *t, struct CadetPeerPath *p);
305 305
306/** 306/**
307 * Count established (ready) connections of a tunnel. 307 * Count established (ready) connections of a tunnel.
@@ -311,7 +311,7 @@ GMT_use_path (struct CadetTunnel3 *t, struct CadetPeerPath *p);
311 * @return Number of connections. 311 * @return Number of connections.
312 */ 312 */
313unsigned int 313unsigned int
314GMT_count_connections (struct CadetTunnel3 *t); 314GCT_count_connections (struct CadetTunnel3 *t);
315 315
316/** 316/**
317 * Count channels of a tunnel. 317 * Count channels of a tunnel.
@@ -321,7 +321,7 @@ GMT_count_connections (struct CadetTunnel3 *t);
321 * @return Number of channels. 321 * @return Number of channels.
322 */ 322 */
323unsigned int 323unsigned int
324GMT_count_channels (struct CadetTunnel3 *t); 324GCT_count_channels (struct CadetTunnel3 *t);
325 325
326/** 326/**
327 * Get the connectivity state of a tunnel. 327 * Get the connectivity state of a tunnel.
@@ -331,7 +331,7 @@ GMT_count_channels (struct CadetTunnel3 *t);
331 * @return Tunnel's connectivity state. 331 * @return Tunnel's connectivity state.
332 */ 332 */
333enum CadetTunnel3CState 333enum CadetTunnel3CState
334GMT_get_cstate (struct CadetTunnel3 *t); 334GCT_get_cstate (struct CadetTunnel3 *t);
335 335
336/** 336/**
337 * Get the encryption state of a tunnel. 337 * Get the encryption state of a tunnel.
@@ -341,7 +341,7 @@ GMT_get_cstate (struct CadetTunnel3 *t);
341 * @return Tunnel's encryption state. 341 * @return Tunnel's encryption state.
342 */ 342 */
343enum CadetTunnel3EState 343enum CadetTunnel3EState
344GMT_get_estate (struct CadetTunnel3 *t); 344GCT_get_estate (struct CadetTunnel3 *t);
345 345
346/** 346/**
347 * Get the maximum buffer space for a tunnel towards a local client. 347 * Get the maximum buffer space for a tunnel towards a local client.
@@ -351,7 +351,7 @@ GMT_get_estate (struct CadetTunnel3 *t);
351 * @return Biggest buffer space offered by any channel in the tunnel. 351 * @return Biggest buffer space offered by any channel in the tunnel.
352 */ 352 */
353unsigned int 353unsigned int
354GMT_get_channels_buffer (struct CadetTunnel3 *t); 354GCT_get_channels_buffer (struct CadetTunnel3 *t);
355 355
356/** 356/**
357 * Get the total buffer space for a tunnel for P2P traffic. 357 * Get the total buffer space for a tunnel for P2P traffic.
@@ -361,7 +361,7 @@ GMT_get_channels_buffer (struct CadetTunnel3 *t);
361 * @return Buffer space offered by all connections in the tunnel. 361 * @return Buffer space offered by all connections in the tunnel.
362 */ 362 */
363unsigned int 363unsigned int
364GMT_get_connections_buffer (struct CadetTunnel3 *t); 364GCT_get_connections_buffer (struct CadetTunnel3 *t);
365 365
366/** 366/**
367 * Get the tunnel's destination. 367 * Get the tunnel's destination.
@@ -371,7 +371,7 @@ GMT_get_connections_buffer (struct CadetTunnel3 *t);
371 * @return ID of the destination peer. 371 * @return ID of the destination peer.
372 */ 372 */
373const struct GNUNET_PeerIdentity * 373const struct GNUNET_PeerIdentity *
374GMT_get_destination (struct CadetTunnel3 *t); 374GCT_get_destination (struct CadetTunnel3 *t);
375 375
376/** 376/**
377 * Get the tunnel's next free Channel ID. 377 * Get the tunnel's next free Channel ID.
@@ -381,7 +381,7 @@ GMT_get_destination (struct CadetTunnel3 *t);
381 * @return ID of a channel free to use. 381 * @return ID of a channel free to use.
382 */ 382 */
383CADET_ChannelNumber 383CADET_ChannelNumber
384GMT_get_next_chid (struct CadetTunnel3 *t); 384GCT_get_next_chid (struct CadetTunnel3 *t);
385 385
386/** 386/**
387 * Send ACK on one or more channels due to buffer in connections. 387 * Send ACK on one or more channels due to buffer in connections.
@@ -389,7 +389,7 @@ GMT_get_next_chid (struct CadetTunnel3 *t);
389 * @param t Channel which has some free buffer space. 389 * @param t Channel which has some free buffer space.
390 */ 390 */
391void 391void
392GMT_unchoke_channels (struct CadetTunnel3 *t); 392GCT_unchoke_channels (struct CadetTunnel3 *t);
393 393
394/** 394/**
395 * Send ACK on one or more connections due to buffer space to the client. 395 * Send ACK on one or more connections due to buffer space to the client.
@@ -399,7 +399,7 @@ GMT_unchoke_channels (struct CadetTunnel3 *t);
399 * @param t Tunnel which has some free buffer space. 399 * @param t Tunnel which has some free buffer space.
400 */ 400 */
401void 401void
402GMT_send_connection_acks (struct CadetTunnel3 *t); 402GCT_send_connection_acks (struct CadetTunnel3 *t);
403 403
404/** 404/**
405 * Cancel a previously sent message while it's in the queue. 405 * Cancel a previously sent message while it's in the queue.
@@ -411,7 +411,7 @@ GMT_send_connection_acks (struct CadetTunnel3 *t);
411 * @param q Handle to the queue. 411 * @param q Handle to the queue.
412 */ 412 */
413void 413void
414GMT_cancel (struct CadetTunnel3Queue *q); 414GCT_cancel (struct CadetTunnel3Queue *q);
415 415
416/** 416/**
417 * Sends an already built message on a tunnel, encrypting it and 417 * Sends an already built message on a tunnel, encrypting it and
@@ -427,9 +427,9 @@ GMT_cancel (struct CadetTunnel3Queue *q);
427 * @return Handle to cancel message. NULL if @c cont is NULL. 427 * @return Handle to cancel message. NULL if @c cont is NULL.
428 */ 428 */
429struct CadetTunnel3Queue * 429struct CadetTunnel3Queue *
430GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, 430GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
431 struct CadetTunnel3 *t, struct CadetConnection *c, 431 struct CadetTunnel3 *t, struct CadetConnection *c,
432 int force, GMT_sent cont, void *cont_cls); 432 int force, GCT_sent cont, void *cont_cls);
433 433
434/** 434/**
435 * Is the tunnel directed towards the local peer? 435 * Is the tunnel directed towards the local peer?
@@ -439,7 +439,7 @@ GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
439 * @return #GNUNET_YES if it is loopback. 439 * @return #GNUNET_YES if it is loopback.
440 */ 440 */
441int 441int
442GMT_is_loopback (const struct CadetTunnel3 *t); 442GCT_is_loopback (const struct CadetTunnel3 *t);
443 443
444/** 444/**
445 * Is the tunnel using this path already? 445 * Is the tunnel using this path already?
@@ -450,7 +450,7 @@ GMT_is_loopback (const struct CadetTunnel3 *t);
450 * @return #GNUNET_YES a connection uses this path. 450 * @return #GNUNET_YES a connection uses this path.
451 */ 451 */
452int 452int
453GMT_is_path_used (const struct CadetTunnel3 *t, const struct CadetPeerPath *p); 453GCT_is_path_used (const struct CadetTunnel3 *t, const struct CadetPeerPath *p);
454 454
455/** 455/**
456 * Get a cost of a path for a tunnel considering existing connections. 456 * Get a cost of a path for a tunnel considering existing connections.
@@ -461,7 +461,7 @@ GMT_is_path_used (const struct CadetTunnel3 *t, const struct CadetPeerPath *p);
461 * @return Cost of the path (path length + number of overlapping nodes) 461 * @return Cost of the path (path length + number of overlapping nodes)
462 */ 462 */
463unsigned int 463unsigned int
464GMT_get_path_cost (const struct CadetTunnel3 *t, 464GCT_get_path_cost (const struct CadetTunnel3 *t,
465 const struct CadetPeerPath *path); 465 const struct CadetPeerPath *path);
466 466
467/** 467/**
@@ -472,7 +472,7 @@ GMT_get_path_cost (const struct CadetTunnel3 *t,
472 * @return Static string the destination peer's ID. 472 * @return Static string the destination peer's ID.
473 */ 473 */
474const char * 474const char *
475GMT_2s (const struct CadetTunnel3 *t); 475GCT_2s (const struct CadetTunnel3 *t);
476 476
477/** 477/**
478 * Log all possible info about the tunnel state. 478 * Log all possible info about the tunnel state.
@@ -480,7 +480,7 @@ GMT_2s (const struct CadetTunnel3 *t);
480 * @param t Tunnel to debug. 480 * @param t Tunnel to debug.
481 */ 481 */
482void 482void
483GMT_debug (const struct CadetTunnel3 *t); 483GCT_debug (const struct CadetTunnel3 *t);
484 484
485/** 485/**
486 * Iterate all tunnels. 486 * Iterate all tunnels.
@@ -489,7 +489,7 @@ GMT_debug (const struct CadetTunnel3 *t);
489 * @param cls Closure for @c iter. 489 * @param cls Closure for @c iter.
490 */ 490 */
491void 491void
492GMT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls); 492GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls);
493 493
494/** 494/**
495 * Count all tunnels. 495 * Count all tunnels.
@@ -497,7 +497,7 @@ GMT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls);
497 * @return Number of tunnels to remote peers kept by this peer. 497 * @return Number of tunnels to remote peers kept by this peer.
498 */ 498 */
499unsigned int 499unsigned int
500GMT_count_all (void); 500GCT_count_all (void);
501 501
502/** 502/**
503 * Iterate all connections of a tunnel. 503 * Iterate all connections of a tunnel.
@@ -507,7 +507,7 @@ GMT_count_all (void);
507 * @param cls Closure for @c iter. 507 * @param cls Closure for @c iter.
508 */ 508 */
509void 509void
510GMT_iterate_connections (struct CadetTunnel3 *t, GMT_conn_iter iter, void *cls); 510GCT_iterate_connections (struct CadetTunnel3 *t, GCT_conn_iter iter, void *cls);
511 511
512/** 512/**
513 * Iterate all channels of a tunnel. 513 * Iterate all channels of a tunnel.
@@ -517,7 +517,7 @@ GMT_iterate_connections (struct CadetTunnel3 *t, GMT_conn_iter iter, void *cls);
517 * @param cls Closure for @c iter. 517 * @param cls Closure for @c iter.
518 */ 518 */
519void 519void
520GMT_iterate_channels (struct CadetTunnel3 *t, GMT_chan_iter iter, void *cls); 520GCT_iterate_channels (struct CadetTunnel3 *t, GCT_chan_iter iter, void *cls);
521 521
522#if 0 /* keep Emacsens' auto-indent happy */ 522#if 0 /* keep Emacsens' auto-indent happy */
523{ 523{