aboutsummaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-11-14 13:55:12 +0000
committerBart Polot <bart@net.in.tum.de>2013-11-14 13:55:12 +0000
commitb7366f3d6a56d38d0269a33039f88de967e8c130 (patch)
treee299448a28e358c6549670a094b82f247925f7e2 /src/exit
parent6bde5e0c83d1fd344a26de64172ddce37920bb40 (diff)
downloadgnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.tar.gz
gnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.zip
Use encrypted MESH by default
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/gnunet-daemon-exit.c298
1 files changed, 149 insertions, 149 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 2de707133..819e4f4b6 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -184,22 +184,22 @@ struct RedirectInformation
184 184
185 185
186/** 186/**
187 * Queue of messages to a tunnel. 187 * Queue of messages to a channel.
188 */ 188 */
189struct TunnelMessageQueue 189struct ChannelMessageQueue
190{ 190{
191 /** 191 /**
192 * This is a doubly-linked list. 192 * This is a doubly-linked list.
193 */ 193 */
194 struct TunnelMessageQueue *next; 194 struct ChannelMessageQueue *next;
195 195
196 /** 196 /**
197 * This is a doubly-linked list. 197 * This is a doubly-linked list.
198 */ 198 */
199 struct TunnelMessageQueue *prev; 199 struct ChannelMessageQueue *prev;
200 200
201 /** 201 /**
202 * Payload to send via the tunnel. 202 * Payload to send via the channel.
203 */ 203 */
204 const void *payload; 204 const void *payload;
205 205
@@ -212,32 +212,32 @@ struct TunnelMessageQueue
212 212
213/** 213/**
214 * This struct is saved into connections_map to allow finding the 214 * This struct is saved into connections_map to allow finding the
215 * right tunnel given an IP packet from TUN. It is also associated 215 * right channel given an IP packet from TUN. It is also associated
216 * with the tunnel's closure so we can find it again for the next 216 * with the channel's closure so we can find it again for the next
217 * message from the tunnel. 217 * message from the channel.
218 */ 218 */
219struct TunnelState 219struct ChannelState
220{ 220{
221 /** 221 /**
222 * Mesh tunnel that is used for this connection. 222 * Mesh channel that is used for this connection.
223 */ 223 */
224 struct GNUNET_MESH_Tunnel *tunnel; 224 struct GNUNET_MESH_Channel *channel;
225 225
226 /** 226 /**
227 * Who is the other end of this tunnel. 227 * Who is the other end of this channel.
228 * FIXME is this needed? Only used for debugging messages 228 * FIXME is this needed? Only used for debugging messages
229 */ 229 */
230 struct GNUNET_PeerIdentity peer; 230 struct GNUNET_PeerIdentity peer;
231 231
232 /** 232 /**
233 * Active tunnel transmission request (or NULL). 233 * Active channel transmission request (or NULL).
234 */ 234 */
235 struct GNUNET_MESH_TransmitHandle *th; 235 struct GNUNET_MESH_TransmitHandle *th;
236 236
237 /** 237 /**
238 * #GNUNET_NO if this is a tunnel for TCP/UDP, 238 * #GNUNET_NO if this is a channel for TCP/UDP,
239 * #GNUNET_YES if this is a tunnel for DNS, 239 * #GNUNET_YES if this is a channel for DNS,
240 * #GNUNET_SYSERR if the tunnel is not yet initialized. 240 * #GNUNET_SYSERR if the channel is not yet initialized.
241 */ 241 */
242 int is_dns; 242 int is_dns;
243 243
@@ -262,14 +262,14 @@ struct TunnelState
262 struct LocalService *serv; 262 struct LocalService *serv;
263 263
264 /** 264 /**
265 * Head of DLL of messages for this tunnel. 265 * Head of DLL of messages for this channel.
266 */ 266 */
267 struct TunnelMessageQueue *head; 267 struct ChannelMessageQueue *head;
268 268
269 /** 269 /**
270 * Tail of DLL of messages for this tunnel. 270 * Tail of DLL of messages for this channel.
271 */ 271 */
272 struct TunnelMessageQueue *tail; 272 struct ChannelMessageQueue *tail;
273 273
274 /** 274 /**
275 * Primary redirection information for this connection. 275 * Primary redirection information for this connection.
@@ -375,7 +375,7 @@ static struct GNUNET_MESH_Handle *mesh_handle;
375 375
376/** 376/**
377 * This hashmaps contains the mapping from peer, service-descriptor, 377 * This hashmaps contains the mapping from peer, service-descriptor,
378 * source-port and destination-port to a struct TunnelState 378 * source-port and destination-port to a struct ChannelState
379 */ 379 */
380static struct GNUNET_CONTAINER_MultiHashMap *connections_map; 380static struct GNUNET_CONTAINER_MultiHashMap *connections_map;
381 381
@@ -400,9 +400,9 @@ static struct GNUNET_CONTAINER_MultiHashMap *udp_services;
400static struct GNUNET_CONTAINER_MultiHashMap *tcp_services; 400static struct GNUNET_CONTAINER_MultiHashMap *tcp_services;
401 401
402/** 402/**
403 * Array of all open DNS requests from tunnels. 403 * Array of all open DNS requests from channels.
404 */ 404 */
405static struct TunnelState *tunnels[UINT16_MAX + 1]; 405static struct ChannelState *channels[UINT16_MAX + 1];
406 406
407/** 407/**
408 * Handle to the DNS Stub resolver. 408 * Handle to the DNS Stub resolver.
@@ -462,10 +462,10 @@ static int ipv6_enabled;
462 462
463 463
464/** 464/**
465 * We got a reply from DNS for a request of a MESH tunnel. Send it 465 * We got a reply from DNS for a request of a MESH channel. Send it
466 * via the tunnel (after changing the request ID back). 466 * via the channel (after changing the request ID back).
467 * 467 *
468 * @param cls the 'struct TunnelState' 468 * @param cls the 'struct ChannelState'
469 * @param size number of bytes available in buf 469 * @param size number of bytes available in buf
470 * @param buf where to copy the reply 470 * @param buf where to copy the reply
471 * @return number of bytes written to buf 471 * @return number of bytes written to buf
@@ -475,7 +475,7 @@ transmit_reply_to_mesh (void *cls,
475 size_t size, 475 size_t size,
476 void *buf) 476 void *buf)
477{ 477{
478 struct TunnelState *ts = cls; 478 struct ChannelState *ts = cls;
479 size_t off; 479 size_t off;
480 size_t ret; 480 size_t ret;
481 char *cbuf = buf; 481 char *cbuf = buf;
@@ -523,26 +523,26 @@ process_dns_result (void *cls,
523 const struct GNUNET_TUN_DnsHeader *dns, 523 const struct GNUNET_TUN_DnsHeader *dns,
524 size_t r) 524 size_t r)
525{ 525{
526 struct TunnelState *ts; 526 struct ChannelState *ts;
527 527
528 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 528 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
529 "Processing DNS result from stub resolver\n"); 529 "Processing DNS result from stub resolver\n");
530 GNUNET_assert (NULL == cls); 530 GNUNET_assert (NULL == cls);
531 /* Handle case that this is a reply to a request from a MESH DNS tunnel */ 531 /* Handle case that this is a reply to a request from a MESH DNS channel */
532 ts = tunnels[dns->id]; 532 ts = channels[dns->id];
533 if ( (NULL == ts) || 533 if ( (NULL == ts) ||
534 (ts->specifics.dns.rs != rs) ) 534 (ts->specifics.dns.rs != rs) )
535 return; 535 return;
536 LOG (GNUNET_ERROR_TYPE_DEBUG, 536 LOG (GNUNET_ERROR_TYPE_DEBUG,
537 "Got a response from the stub resolver for DNS request received via MESH!\n"); 537 "Got a response from the stub resolver for DNS request received via MESH!\n");
538 tunnels[dns->id] = NULL; 538 channels[dns->id] = NULL;
539 GNUNET_free_non_null (ts->specifics.dns.reply); 539 GNUNET_free_non_null (ts->specifics.dns.reply);
540 ts->specifics.dns.reply = GNUNET_malloc (r); 540 ts->specifics.dns.reply = GNUNET_malloc (r);
541 ts->specifics.dns.reply_length = r; 541 ts->specifics.dns.reply_length = r;
542 memcpy (ts->specifics.dns.reply, dns, r); 542 memcpy (ts->specifics.dns.reply, dns, r);
543 if (NULL != ts->th) 543 if (NULL != ts->th)
544 GNUNET_MESH_notify_transmit_ready_cancel (ts->th); 544 GNUNET_MESH_notify_transmit_ready_cancel (ts->th);
545 ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel, 545 ts->th = GNUNET_MESH_notify_transmit_ready (ts->channel,
546 GNUNET_NO, 546 GNUNET_NO,
547 GNUNET_TIME_UNIT_FOREVER_REL, 547 GNUNET_TIME_UNIT_FOREVER_REL,
548 sizeof (struct GNUNET_MessageHeader) + r, 548 sizeof (struct GNUNET_MessageHeader) + r,
@@ -555,19 +555,19 @@ process_dns_result (void *cls,
555 * Process a request via mesh to perform a DNS query. 555 * Process a request via mesh to perform a DNS query.
556 * 556 *
557 * @param cls closure, NULL 557 * @param cls closure, NULL
558 * @param tunnel connection to the other end 558 * @param channel connection to the other end
559 * @param tunnel_ctx pointer to our `struct TunnelState *` 559 * @param channel_ctx pointer to our `struct ChannelState *`
560 * @param message the actual message 560 * @param message the actual message
561 * 561 *
562 * @return #GNUNET_OK to keep the connection open, 562 * @return #GNUNET_OK to keep the connection open,
563 * #GNUNET_SYSERR to close it (signal serious error) 563 * #GNUNET_SYSERR to close it (signal serious error)
564 */ 564 */
565static int 565static int
566receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, 566receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Channel *channel,
567 void **tunnel_ctx, 567 void **channel_ctx,
568 const struct GNUNET_MessageHeader *message) 568 const struct GNUNET_MessageHeader *message)
569{ 569{
570 struct TunnelState *ts = *tunnel_ctx; 570 struct ChannelState *ts = *channel_ctx;
571 const struct GNUNET_TUN_DnsHeader *dns; 571 const struct GNUNET_TUN_DnsHeader *dns;
572 size_t mlen = ntohs (message->size); 572 size_t mlen = ntohs (message->size);
573 size_t dlen = mlen - sizeof (struct GNUNET_MessageHeader); 573 size_t dlen = mlen - sizeof (struct GNUNET_MessageHeader);
@@ -583,7 +583,7 @@ receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
583 } 583 }
584 if (GNUNET_SYSERR == ts->is_dns) 584 if (GNUNET_SYSERR == ts->is_dns)
585 { 585 {
586 /* tunnel is DNS from now on */ 586 /* channel is DNS from now on */
587 ts->is_dns = GNUNET_YES; 587 ts->is_dns = GNUNET_YES;
588 } 588 }
589 if (dlen < sizeof (struct GNUNET_TUN_DnsHeader)) 589 if (dlen < sizeof (struct GNUNET_TUN_DnsHeader))
@@ -593,11 +593,11 @@ receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
593 } 593 }
594 dns = (const struct GNUNET_TUN_DnsHeader *) &message[1]; 594 dns = (const struct GNUNET_TUN_DnsHeader *) &message[1];
595 ts->specifics.dns.original_id = dns->id; 595 ts->specifics.dns.original_id = dns->id;
596 if (tunnels[ts->specifics.dns.my_id] == ts) 596 if (channels[ts->specifics.dns.my_id] == ts)
597 tunnels[ts->specifics.dns.my_id] = NULL; 597 channels[ts->specifics.dns.my_id] = NULL;
598 ts->specifics.dns.my_id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 598 ts->specifics.dns.my_id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
599 UINT16_MAX + 1); 599 UINT16_MAX + 1);
600 tunnels[ts->specifics.dns.my_id] = ts; 600 channels[ts->specifics.dns.my_id] = ts;
601 memcpy (buf, dns, dlen); 601 memcpy (buf, dns, dlen);
602 dout = (struct GNUNET_TUN_DnsHeader *) buf; 602 dout = (struct GNUNET_TUN_DnsHeader *) buf;
603 dout->id = ts->specifics.dns.my_id; 603 dout->id = ts->specifics.dns.my_id;
@@ -676,7 +676,7 @@ hash_redirect_info (struct GNUNET_HashCode *hash,
676 * @param state_key set to hash's state if non-NULL 676 * @param state_key set to hash's state if non-NULL
677 * @return NULL if we have no tracking information for this tuple 677 * @return NULL if we have no tracking information for this tuple
678 */ 678 */
679static struct TunnelState * 679static struct ChannelState *
680get_redirect_state (int af, 680get_redirect_state (int af,
681 int protocol, 681 int protocol,
682 const void *destination_ip, 682 const void *destination_ip,
@@ -687,7 +687,7 @@ get_redirect_state (int af,
687{ 687{
688 struct RedirectInformation ri; 688 struct RedirectInformation ri;
689 struct GNUNET_HashCode key; 689 struct GNUNET_HashCode key;
690 struct TunnelState *state; 690 struct ChannelState *state;
691 691
692 if ( ( (af == AF_INET) && (protocol == IPPROTO_ICMP) ) || 692 if ( ( (af == AF_INET) && (protocol == IPPROTO_ICMP) ) ||
693 ( (af == AF_INET6) && (protocol == IPPROTO_ICMPV6) ) ) 693 ( (af == AF_INET6) && (protocol == IPPROTO_ICMPV6) ) )
@@ -807,9 +807,9 @@ store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map,
807 807
808 808
809/** 809/**
810 * MESH is ready to receive a message for the tunnel. Transmit it. 810 * MESH is ready to receive a message for the channel. Transmit it.
811 * 811 *
812 * @param cls the 'struct TunnelState'. 812 * @param cls the 'struct ChannelState'.
813 * @param size number of bytes available in buf 813 * @param size number of bytes available in buf
814 * @param buf where to copy the message 814 * @param buf where to copy the message
815 * @return number of bytes copied to buf 815 * @return number of bytes copied to buf
@@ -817,9 +817,9 @@ store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map,
817static size_t 817static size_t
818send_to_peer_notify_callback (void *cls, size_t size, void *buf) 818send_to_peer_notify_callback (void *cls, size_t size, void *buf)
819{ 819{
820 struct TunnelState *s = cls; 820 struct ChannelState *s = cls;
821 struct GNUNET_MESH_Tunnel *tunnel = s->tunnel; 821 struct GNUNET_MESH_Channel *channel = s->channel;
822 struct TunnelMessageQueue *tnq; 822 struct ChannelMessageQueue *tnq;
823 823
824 s->th = NULL; 824 s->th = NULL;
825 tnq = s->specifics.tcp_udp.head; 825 tnq = s->specifics.tcp_udp.head;
@@ -827,7 +827,7 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
827 return 0; 827 return 0;
828 if (0 == size) 828 if (0 == size)
829 { 829 {
830 s->th = GNUNET_MESH_notify_transmit_ready (tunnel, 830 s->th = GNUNET_MESH_notify_transmit_ready (channel,
831 GNUNET_NO /* corking */, 831 GNUNET_NO /* corking */,
832 GNUNET_TIME_UNIT_FOREVER_REL, 832 GNUNET_TIME_UNIT_FOREVER_REL,
833 tnq->len, 833 tnq->len,
@@ -843,36 +843,36 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
843 tnq); 843 tnq);
844 GNUNET_free (tnq); 844 GNUNET_free (tnq);
845 if (NULL != (tnq = s->specifics.tcp_udp.head)) 845 if (NULL != (tnq = s->specifics.tcp_udp.head))
846 s->th = GNUNET_MESH_notify_transmit_ready (tunnel, 846 s->th = GNUNET_MESH_notify_transmit_ready (channel,
847 GNUNET_NO /* corking */, 847 GNUNET_NO /* corking */,
848 GNUNET_TIME_UNIT_FOREVER_REL, 848 GNUNET_TIME_UNIT_FOREVER_REL,
849 tnq->len, 849 tnq->len,
850 &send_to_peer_notify_callback, 850 &send_to_peer_notify_callback,
851 s); 851 s);
852 GNUNET_STATISTICS_update (stats, 852 GNUNET_STATISTICS_update (stats,
853 gettext_noop ("# Bytes transmitted via mesh tunnels"), 853 gettext_noop ("# Bytes transmitted via mesh channels"),
854 size, GNUNET_NO); 854 size, GNUNET_NO);
855 return size; 855 return size;
856} 856}
857 857
858 858
859/** 859/**
860 * Send the given packet via the mesh tunnel. 860 * Send the given packet via the mesh channel.
861 * 861 *
862 * @param s tunnel destination 862 * @param s channel destination
863 * @param tnq message to queue 863 * @param tnq message to queue
864 */ 864 */
865static void 865static void
866send_packet_to_mesh_tunnel (struct TunnelState *s, 866send_packet_to_mesh_channel (struct ChannelState *s,
867 struct TunnelMessageQueue *tnq) 867 struct ChannelMessageQueue *tnq)
868{ 868{
869 struct GNUNET_MESH_Tunnel *mesh_tunnel; 869 struct GNUNET_MESH_Channel *mesh_channel;
870 870
871 mesh_tunnel = s->tunnel; 871 mesh_channel = s->channel;
872 GNUNET_assert (NULL != s); 872 GNUNET_assert (NULL != s);
873 GNUNET_CONTAINER_DLL_insert_tail (s->specifics.tcp_udp.head, s->specifics.tcp_udp.tail, tnq); 873 GNUNET_CONTAINER_DLL_insert_tail (s->specifics.tcp_udp.head, s->specifics.tcp_udp.tail, tnq);
874 if (NULL == s->th) 874 if (NULL == s->th)
875 s->th = GNUNET_MESH_notify_transmit_ready (mesh_tunnel, 875 s->th = GNUNET_MESH_notify_transmit_ready (mesh_channel,
876 GNUNET_NO /* cork */, 876 GNUNET_NO /* cork */,
877 GNUNET_TIME_UNIT_FOREVER_REL, 877 GNUNET_TIME_UNIT_FOREVER_REL,
878 tnq->len, 878 tnq->len,
@@ -899,8 +899,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
899 const void *destination_ip, 899 const void *destination_ip,
900 const void *source_ip) 900 const void *source_ip)
901{ 901{
902 struct TunnelState *state; 902 struct ChannelState *state;
903 struct TunnelMessageQueue *tnq; 903 struct ChannelMessageQueue *tnq;
904 struct GNUNET_EXIT_IcmpToVPNMessage *i2v; 904 struct GNUNET_EXIT_IcmpToVPNMessage *i2v;
905 const struct GNUNET_TUN_IPv4Header *ipv4; 905 const struct GNUNET_TUN_IPv4Header *ipv4;
906 const struct GNUNET_TUN_IPv6Header *ipv6; 906 const struct GNUNET_TUN_IPv6Header *ipv6;
@@ -1055,7 +1055,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
1055 return; 1055 return;
1056 } 1056 }
1057 mlen = sizeof (struct GNUNET_EXIT_IcmpToVPNMessage) + pktlen - sizeof (struct GNUNET_TUN_IcmpHeader); 1057 mlen = sizeof (struct GNUNET_EXIT_IcmpToVPNMessage) + pktlen - sizeof (struct GNUNET_TUN_IcmpHeader);
1058 tnq = GNUNET_malloc (sizeof (struct TunnelMessageQueue) + mlen); 1058 tnq = GNUNET_malloc (sizeof (struct ChannelMessageQueue) + mlen);
1059 tnq->payload = &tnq[1]; 1059 tnq->payload = &tnq[1];
1060 tnq->len = mlen; 1060 tnq->len = mlen;
1061 i2v = (struct GNUNET_EXIT_IcmpToVPNMessage *) &tnq[1]; 1061 i2v = (struct GNUNET_EXIT_IcmpToVPNMessage *) &tnq[1];
@@ -1065,7 +1065,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
1065 memcpy (&i2v->icmp_header, 1065 memcpy (&i2v->icmp_header,
1066 icmp, 1066 icmp,
1067 pktlen); 1067 pktlen);
1068 send_packet_to_mesh_tunnel (state, tnq); 1068 send_packet_to_mesh_channel (state, tnq);
1069} 1069}
1070 1070
1071 1071
@@ -1087,8 +1087,8 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
1087 const void *destination_ip, 1087 const void *destination_ip,
1088 const void *source_ip) 1088 const void *source_ip)
1089{ 1089{
1090 struct TunnelState *state; 1090 struct ChannelState *state;
1091 struct TunnelMessageQueue *tnq; 1091 struct ChannelMessageQueue *tnq;
1092 struct GNUNET_EXIT_UdpReplyMessage *urm; 1092 struct GNUNET_EXIT_UdpReplyMessage *urm;
1093 size_t mlen; 1093 size_t mlen;
1094 1094
@@ -1131,7 +1131,7 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
1131 return; 1131 return;
1132 } 1132 }
1133 mlen = sizeof (struct GNUNET_EXIT_UdpReplyMessage) + pktlen - sizeof (struct GNUNET_TUN_UdpHeader); 1133 mlen = sizeof (struct GNUNET_EXIT_UdpReplyMessage) + pktlen - sizeof (struct GNUNET_TUN_UdpHeader);
1134 tnq = GNUNET_malloc (sizeof (struct TunnelMessageQueue) + mlen); 1134 tnq = GNUNET_malloc (sizeof (struct ChannelMessageQueue) + mlen);
1135 tnq->payload = &tnq[1]; 1135 tnq->payload = &tnq[1];
1136 tnq->len = mlen; 1136 tnq->len = mlen;
1137 urm = (struct GNUNET_EXIT_UdpReplyMessage *) &tnq[1]; 1137 urm = (struct GNUNET_EXIT_UdpReplyMessage *) &tnq[1];
@@ -1142,7 +1142,7 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
1142 memcpy (&urm[1], 1142 memcpy (&urm[1],
1143 &udp[1], 1143 &udp[1],
1144 pktlen - sizeof (struct GNUNET_TUN_UdpHeader)); 1144 pktlen - sizeof (struct GNUNET_TUN_UdpHeader));
1145 send_packet_to_mesh_tunnel (state, tnq); 1145 send_packet_to_mesh_channel (state, tnq);
1146} 1146}
1147 1147
1148 1148
@@ -1164,11 +1164,11 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
1164 const void *destination_ip, 1164 const void *destination_ip,
1165 const void *source_ip) 1165 const void *source_ip)
1166{ 1166{
1167 struct TunnelState *state; 1167 struct ChannelState *state;
1168 char buf[pktlen] GNUNET_ALIGN; 1168 char buf[pktlen] GNUNET_ALIGN;
1169 struct GNUNET_TUN_TcpHeader *mtcp; 1169 struct GNUNET_TUN_TcpHeader *mtcp;
1170 struct GNUNET_EXIT_TcpDataMessage *tdm; 1170 struct GNUNET_EXIT_TcpDataMessage *tdm;
1171 struct TunnelMessageQueue *tnq; 1171 struct ChannelMessageQueue *tnq;
1172 size_t mlen; 1172 size_t mlen;
1173 1173
1174 { 1174 {
@@ -1220,7 +1220,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
1220 return; 1220 return;
1221 } 1221 }
1222 1222
1223 tnq = GNUNET_malloc (sizeof (struct TunnelMessageQueue) + mlen); 1223 tnq = GNUNET_malloc (sizeof (struct ChannelMessageQueue) + mlen);
1224 tnq->payload = &tnq[1]; 1224 tnq->payload = &tnq[1];
1225 tnq->len = mlen; 1225 tnq->len = mlen;
1226 tdm = (struct GNUNET_EXIT_TcpDataMessage *) &tnq[1]; 1226 tdm = (struct GNUNET_EXIT_TcpDataMessage *) &tnq[1];
@@ -1230,7 +1230,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
1230 memcpy (&tdm->tcp_header, 1230 memcpy (&tdm->tcp_header,
1231 buf, 1231 buf,
1232 pktlen); 1232 pktlen);
1233 send_packet_to_mesh_tunnel (state, tnq); 1233 send_packet_to_mesh_channel (state, tnq);
1234} 1234}
1235 1235
1236 1236
@@ -1486,7 +1486,7 @@ setup_fresh_address (int af,
1486 * We are starting a fresh connection (TCP or UDP) and need 1486 * We are starting a fresh connection (TCP or UDP) and need
1487 * to pick a source port and IP address (within the correct 1487 * to pick a source port and IP address (within the correct
1488 * range and address family) to associate replies with the 1488 * range and address family) to associate replies with the
1489 * connection / correct mesh tunnel. This function generates 1489 * connection / correct mesh channel. This function generates
1490 * a "fresh" source IP and source port number for a connection 1490 * a "fresh" source IP and source port number for a connection
1491 * After picking a good source address, this function sets up 1491 * After picking a good source address, this function sets up
1492 * the state in the 'connections_map' and 'connections_heap' 1492 * the state in the 'connections_map' and 'connections_heap'
@@ -1497,17 +1497,17 @@ setup_fresh_address (int af,
1497 * @param state skeleton state to setup a record for; should 1497 * @param state skeleton state to setup a record for; should
1498 * 'state->specifics.tcp_udp.ri.remote_address' filled in so that 1498 * 'state->specifics.tcp_udp.ri.remote_address' filled in so that
1499 * this code can determine which AF/protocol is 1499 * this code can determine which AF/protocol is
1500 * going to be used (the 'tunnel' should also 1500 * going to be used (the 'channel' should also
1501 * already be set); after calling this function, 1501 * already be set); after calling this function,
1502 * heap_node and the local_address will be 1502 * heap_node and the local_address will be
1503 * also initialized (heap_node != NULL can be 1503 * also initialized (heap_node != NULL can be
1504 * used to test if a state has been fully setup). 1504 * used to test if a state has been fully setup).
1505 */ 1505 */
1506static void 1506static void
1507setup_state_record (struct TunnelState *state) 1507setup_state_record (struct ChannelState *state)
1508{ 1508{
1509 struct GNUNET_HashCode key; 1509 struct GNUNET_HashCode key;
1510 struct TunnelState *s; 1510 struct ChannelState *s;
1511 1511
1512 /* generate fresh, unique address */ 1512 /* generate fresh, unique address */
1513 do 1513 do
@@ -1549,7 +1549,7 @@ setup_state_record (struct TunnelState *state)
1549 s = GNUNET_CONTAINER_heap_remove_root (connections_heap); 1549 s = GNUNET_CONTAINER_heap_remove_root (connections_heap);
1550 GNUNET_assert (state != s); 1550 GNUNET_assert (state != s);
1551 s->specifics.tcp_udp.heap_node = NULL; 1551 s->specifics.tcp_udp.heap_node = NULL;
1552 GNUNET_MESH_tunnel_destroy (s->tunnel); 1552 GNUNET_MESH_channel_destroy (s->channel);
1553 GNUNET_assert (GNUNET_OK == 1553 GNUNET_assert (GNUNET_OK ==
1554 GNUNET_CONTAINER_multihashmap_remove (connections_map, 1554 GNUNET_CONTAINER_multihashmap_remove (connections_map,
1555 &s->specifics.tcp_udp.state_key, 1555 &s->specifics.tcp_udp.state_key,
@@ -1837,19 +1837,19 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1837 * offered by this system. 1837 * offered by this system.
1838 * 1838 *
1839 * @param cls closure, NULL 1839 * @param cls closure, NULL
1840 * @param tunnel connection to the other end 1840 * @param channel connection to the other end
1841 * @param tunnel_ctx pointer to our `struct TunnelState *` 1841 * @param channel_ctx pointer to our `struct ChannelState *`
1842 * @param message the actual message 1842 * @param message the actual message
1843 * @return #GNUNET_OK to keep the connection open, 1843 * @return #GNUNET_OK to keep the connection open,
1844 * #GNUNET_SYSERR to close it (signal serious error) 1844 * #GNUNET_SYSERR to close it (signal serious error)
1845 */ 1845 */
1846static int 1846static int
1847receive_tcp_service (void *cls, 1847receive_tcp_service (void *cls,
1848 struct GNUNET_MESH_Tunnel *tunnel, 1848 struct GNUNET_MESH_Channel *channel,
1849 void **tunnel_ctx, 1849 void **channel_ctx,
1850 const struct GNUNET_MessageHeader *message) 1850 const struct GNUNET_MessageHeader *message)
1851{ 1851{
1852 struct TunnelState *state = *tunnel_ctx; 1852 struct ChannelState *state = *channel_ctx;
1853 const struct GNUNET_EXIT_TcpServiceStartMessage *start; 1853 const struct GNUNET_EXIT_TcpServiceStartMessage *start;
1854 uint16_t pkt_len = ntohs (message->size); 1854 uint16_t pkt_len = ntohs (message->size);
1855 1855
@@ -1865,7 +1865,7 @@ receive_tcp_service (void *cls,
1865 } 1865 }
1866 if (GNUNET_SYSERR == state->is_dns) 1866 if (GNUNET_SYSERR == state->is_dns)
1867 { 1867 {
1868 /* tunnel is UDP/TCP from now on */ 1868 /* channel is UDP/TCP from now on */
1869 state->is_dns = GNUNET_NO; 1869 state->is_dns = GNUNET_NO;
1870 } 1870 }
1871 GNUNET_STATISTICS_update (stats, 1871 GNUNET_STATISTICS_update (stats,
@@ -1926,19 +1926,19 @@ receive_tcp_service (void *cls,
1926 * Process a request to forward TCP data to the Internet via this peer. 1926 * Process a request to forward TCP data to the Internet via this peer.
1927 * 1927 *
1928 * @param cls closure, NULL 1928 * @param cls closure, NULL
1929 * @param tunnel connection to the other end 1929 * @param channel connection to the other end
1930 * @param tunnel_ctx pointer to our 'struct TunnelState *' 1930 * @param channel_ctx pointer to our 'struct ChannelState *'
1931 * @param message the actual message 1931 * @param message the actual message
1932 * 1932 *
1933 * @return GNUNET_OK to keep the connection open, 1933 * @return GNUNET_OK to keep the connection open,
1934 * GNUNET_SYSERR to close it (signal serious error) 1934 * GNUNET_SYSERR to close it (signal serious error)
1935 */ 1935 */
1936static int 1936static int
1937receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, 1937receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Channel *channel,
1938 void **tunnel_ctx GNUNET_UNUSED, 1938 void **channel_ctx GNUNET_UNUSED,
1939 const struct GNUNET_MessageHeader *message) 1939 const struct GNUNET_MessageHeader *message)
1940{ 1940{
1941 struct TunnelState *state = *tunnel_ctx; 1941 struct ChannelState *state = *channel_ctx;
1942 const struct GNUNET_EXIT_TcpInternetStartMessage *start; 1942 const struct GNUNET_EXIT_TcpInternetStartMessage *start;
1943 uint16_t pkt_len = ntohs (message->size); 1943 uint16_t pkt_len = ntohs (message->size);
1944 const struct in_addr *v4; 1944 const struct in_addr *v4;
@@ -1958,7 +1958,7 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1958 } 1958 }
1959 if (GNUNET_SYSERR == state->is_dns) 1959 if (GNUNET_SYSERR == state->is_dns)
1960 { 1960 {
1961 /* tunnel is UDP/TCP from now on */ 1961 /* channel is UDP/TCP from now on */
1962 state->is_dns = GNUNET_NO; 1962 state->is_dns = GNUNET_NO;
1963 } 1963 }
1964 GNUNET_STATISTICS_update (stats, 1964 GNUNET_STATISTICS_update (stats,
@@ -2051,18 +2051,18 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2051 * connection via this peer. 2051 * connection via this peer.
2052 * 2052 *
2053 * @param cls closure, NULL 2053 * @param cls closure, NULL
2054 * @param tunnel connection to the other end 2054 * @param channel connection to the other end
2055 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2055 * @param channel_ctx pointer to our 'struct ChannelState *'
2056 * @param message the actual message 2056 * @param message the actual message
2057 * @return #GNUNET_OK to keep the connection open, 2057 * @return #GNUNET_OK to keep the connection open,
2058 * #GNUNET_SYSERR to close it (signal serious error) 2058 * #GNUNET_SYSERR to close it (signal serious error)
2059 */ 2059 */
2060static int 2060static int
2061receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, 2061receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Channel *channel,
2062 void **tunnel_ctx GNUNET_UNUSED, 2062 void **channel_ctx GNUNET_UNUSED,
2063 const struct GNUNET_MessageHeader *message) 2063 const struct GNUNET_MessageHeader *message)
2064{ 2064{
2065 struct TunnelState *state = *tunnel_ctx; 2065 struct ChannelState *state = *channel_ctx;
2066 const struct GNUNET_EXIT_TcpDataMessage *data; 2066 const struct GNUNET_EXIT_TcpDataMessage *data;
2067 uint16_t pkt_len = ntohs (message->size); 2067 uint16_t pkt_len = ntohs (message->size);
2068 2068
@@ -2100,7 +2100,7 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2100 } 2100 }
2101 if (GNUNET_SYSERR == state->is_dns) 2101 if (GNUNET_SYSERR == state->is_dns)
2102 { 2102 {
2103 /* tunnel is UDP/TCP from now on */ 2103 /* channel is UDP/TCP from now on */
2104 state->is_dns = GNUNET_NO; 2104 state->is_dns = GNUNET_NO;
2105 } 2105 }
2106 2106
@@ -2229,15 +2229,15 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
2229 2229
2230/** 2230/**
2231 * Synthesize a plausible ICMP payload for an ICMPv4 error 2231 * Synthesize a plausible ICMP payload for an ICMPv4 error
2232 * response on the given tunnel. 2232 * response on the given channel.
2233 * 2233 *
2234 * @param state tunnel information 2234 * @param state channel information
2235 * @param ipp IPv6 header to fill in (ICMP payload) 2235 * @param ipp IPv6 header to fill in (ICMP payload)
2236 * @param udp "UDP" header to fill in (ICMP payload); might actually 2236 * @param udp "UDP" header to fill in (ICMP payload); might actually
2237 * also be the first 8 bytes of the TCP header 2237 * also be the first 8 bytes of the TCP header
2238 */ 2238 */
2239static void 2239static void
2240make_up_icmpv4_payload (struct TunnelState *state, 2240make_up_icmpv4_payload (struct ChannelState *state,
2241 struct GNUNET_TUN_IPv4Header *ipp, 2241 struct GNUNET_TUN_IPv4Header *ipp,
2242 struct GNUNET_TUN_UdpHeader *udp) 2242 struct GNUNET_TUN_UdpHeader *udp)
2243{ 2243{
@@ -2255,15 +2255,15 @@ make_up_icmpv4_payload (struct TunnelState *state,
2255 2255
2256/** 2256/**
2257 * Synthesize a plausible ICMP payload for an ICMPv6 error 2257 * Synthesize a plausible ICMP payload for an ICMPv6 error
2258 * response on the given tunnel. 2258 * response on the given channel.
2259 * 2259 *
2260 * @param state tunnel information 2260 * @param state channel information
2261 * @param ipp IPv6 header to fill in (ICMP payload) 2261 * @param ipp IPv6 header to fill in (ICMP payload)
2262 * @param udp "UDP" header to fill in (ICMP payload); might actually 2262 * @param udp "UDP" header to fill in (ICMP payload); might actually
2263 * also be the first 8 bytes of the TCP header 2263 * also be the first 8 bytes of the TCP header
2264 */ 2264 */
2265static void 2265static void
2266make_up_icmpv6_payload (struct TunnelState *state, 2266make_up_icmpv6_payload (struct ChannelState *state,
2267 struct GNUNET_TUN_IPv6Header *ipp, 2267 struct GNUNET_TUN_IPv6Header *ipp,
2268 struct GNUNET_TUN_UdpHeader *udp) 2268 struct GNUNET_TUN_UdpHeader *udp)
2269{ 2269{
@@ -2283,19 +2283,19 @@ make_up_icmpv6_payload (struct TunnelState *state,
2283 * Process a request to forward ICMP data to the Internet via this peer. 2283 * Process a request to forward ICMP data to the Internet via this peer.
2284 * 2284 *
2285 * @param cls closure, NULL 2285 * @param cls closure, NULL
2286 * @param tunnel connection to the other end 2286 * @param channel connection to the other end
2287 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2287 * @param channel_ctx pointer to our 'struct ChannelState *'
2288 * @param message the actual message 2288 * @param message the actual message
2289 * @return #GNUNET_OK to keep the connection open, 2289 * @return #GNUNET_OK to keep the connection open,
2290 * #GNUNET_SYSERR to close it (signal serious error) 2290 * #GNUNET_SYSERR to close it (signal serious error)
2291 */ 2291 */
2292static int 2292static int
2293receive_icmp_remote (void *cls, 2293receive_icmp_remote (void *cls,
2294 struct GNUNET_MESH_Tunnel *tunnel, 2294 struct GNUNET_MESH_Channel *channel,
2295 void **tunnel_ctx, 2295 void **channel_ctx,
2296 const struct GNUNET_MessageHeader *message) 2296 const struct GNUNET_MessageHeader *message)
2297{ 2297{
2298 struct TunnelState *state = *tunnel_ctx; 2298 struct ChannelState *state = *channel_ctx;
2299 const struct GNUNET_EXIT_IcmpInternetMessage *msg; 2299 const struct GNUNET_EXIT_IcmpInternetMessage *msg;
2300 uint16_t pkt_len = ntohs (message->size); 2300 uint16_t pkt_len = ntohs (message->size);
2301 const struct in_addr *v4; 2301 const struct in_addr *v4;
@@ -2311,7 +2311,7 @@ receive_icmp_remote (void *cls,
2311 } 2311 }
2312 if (GNUNET_SYSERR == state->is_dns) 2312 if (GNUNET_SYSERR == state->is_dns)
2313 { 2313 {
2314 /* tunnel is UDP/TCP from now on */ 2314 /* channel is UDP/TCP from now on */
2315 state->is_dns = GNUNET_NO; 2315 state->is_dns = GNUNET_NO;
2316 } 2316 }
2317 GNUNET_STATISTICS_update (stats, 2317 GNUNET_STATISTICS_update (stats,
@@ -2332,7 +2332,7 @@ receive_icmp_remote (void *cls,
2332 if ( (NULL != state->specifics.tcp_udp.heap_node) && 2332 if ( (NULL != state->specifics.tcp_udp.heap_node) &&
2333 (af != state->specifics.tcp_udp.ri.remote_address.af) ) 2333 (af != state->specifics.tcp_udp.ri.remote_address.af) )
2334 { 2334 {
2335 /* other peer switched AF on this tunnel; not allowed */ 2335 /* other peer switched AF on this channel; not allowed */
2336 GNUNET_break_op (0); 2336 GNUNET_break_op (0);
2337 return GNUNET_SYSERR; 2337 return GNUNET_SYSERR;
2338 } 2338 }
@@ -2489,7 +2489,7 @@ receive_icmp_remote (void *cls,
2489 * @return number of bytes of payload we created in buf 2489 * @return number of bytes of payload we created in buf
2490 */ 2490 */
2491static uint16_t 2491static uint16_t
2492make_up_icmp_service_payload (struct TunnelState *state, 2492make_up_icmp_service_payload (struct ChannelState *state,
2493 char *buf) 2493 char *buf)
2494{ 2494{
2495 switch (state->specifics.tcp_udp.serv->address.af) 2495 switch (state->specifics.tcp_udp.serv->address.af)
@@ -2534,19 +2534,19 @@ make_up_icmp_service_payload (struct TunnelState *state,
2534 * offered by this system. 2534 * offered by this system.
2535 * 2535 *
2536 * @param cls closure, NULL 2536 * @param cls closure, NULL
2537 * @param tunnel connection to the other end 2537 * @param channel connection to the other end
2538 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2538 * @param channel_ctx pointer to our 'struct ChannelState *'
2539 * @param message the actual message 2539 * @param message the actual message
2540 * @return #GNUNET_OK to keep the connection open, 2540 * @return #GNUNET_OK to keep the connection open,
2541 * #GNUNET_SYSERR to close it (signal serious error) 2541 * #GNUNET_SYSERR to close it (signal serious error)
2542 */ 2542 */
2543static int 2543static int
2544receive_icmp_service (void *cls, 2544receive_icmp_service (void *cls,
2545 struct GNUNET_MESH_Tunnel *tunnel, 2545 struct GNUNET_MESH_Channel *channel,
2546 void **tunnel_ctx, 2546 void **channel_ctx,
2547 const struct GNUNET_MessageHeader *message) 2547 const struct GNUNET_MessageHeader *message)
2548{ 2548{
2549 struct TunnelState *state = *tunnel_ctx; 2549 struct ChannelState *state = *channel_ctx;
2550 const struct GNUNET_EXIT_IcmpServiceMessage *msg; 2550 const struct GNUNET_EXIT_IcmpServiceMessage *msg;
2551 uint16_t pkt_len = ntohs (message->size); 2551 uint16_t pkt_len = ntohs (message->size);
2552 struct GNUNET_TUN_IcmpHeader icmp; 2552 struct GNUNET_TUN_IcmpHeader icmp;
@@ -2560,7 +2560,7 @@ receive_icmp_service (void *cls,
2560 } 2560 }
2561 if (GNUNET_SYSERR == state->is_dns) 2561 if (GNUNET_SYSERR == state->is_dns)
2562 { 2562 {
2563 /* tunnel is UDP/TCP from now on */ 2563 /* channel is UDP/TCP from now on */
2564 state->is_dns = GNUNET_NO; 2564 state->is_dns = GNUNET_NO;
2565 } 2565 }
2566 GNUNET_STATISTICS_update (stats, 2566 GNUNET_STATISTICS_update (stats,
@@ -2822,19 +2822,19 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
2822 * Process a request to forward UDP data to the Internet via this peer. 2822 * Process a request to forward UDP data to the Internet via this peer.
2823 * 2823 *
2824 * @param cls closure, NULL 2824 * @param cls closure, NULL
2825 * @param tunnel connection to the other end 2825 * @param channel connection to the other end
2826 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2826 * @param channel_ctx pointer to our 'struct ChannelState *'
2827 * @param message the actual message 2827 * @param message the actual message
2828 * @return #GNUNET_OK to keep the connection open, 2828 * @return #GNUNET_OK to keep the connection open,
2829 * #GNUNET_SYSERR to close it (signal serious error) 2829 * #GNUNET_SYSERR to close it (signal serious error)
2830 */ 2830 */
2831static int 2831static int
2832receive_udp_remote (void *cls, 2832receive_udp_remote (void *cls,
2833 struct GNUNET_MESH_Tunnel *tunnel, 2833 struct GNUNET_MESH_Channel *channel,
2834 void **tunnel_ctx, 2834 void **channel_ctx,
2835 const struct GNUNET_MessageHeader *message) 2835 const struct GNUNET_MessageHeader *message)
2836{ 2836{
2837 struct TunnelState *state = *tunnel_ctx; 2837 struct ChannelState *state = *channel_ctx;
2838 const struct GNUNET_EXIT_UdpInternetMessage *msg; 2838 const struct GNUNET_EXIT_UdpInternetMessage *msg;
2839 uint16_t pkt_len = ntohs (message->size); 2839 uint16_t pkt_len = ntohs (message->size);
2840 const struct in_addr *v4; 2840 const struct in_addr *v4;
@@ -2849,7 +2849,7 @@ receive_udp_remote (void *cls,
2849 } 2849 }
2850 if (GNUNET_SYSERR == state->is_dns) 2850 if (GNUNET_SYSERR == state->is_dns)
2851 { 2851 {
2852 /* tunnel is UDP/TCP from now on */ 2852 /* channel is UDP/TCP from now on */
2853 state->is_dns = GNUNET_NO; 2853 state->is_dns = GNUNET_NO;
2854 } 2854 }
2855 GNUNET_STATISTICS_update (stats, 2855 GNUNET_STATISTICS_update (stats,
@@ -2933,19 +2933,19 @@ receive_udp_remote (void *cls,
2933 * offered by this system. 2933 * offered by this system.
2934 * 2934 *
2935 * @param cls closure, NULL 2935 * @param cls closure, NULL
2936 * @param tunnel connection to the other end 2936 * @param channel connection to the other end
2937 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2937 * @param channel_ctx pointer to our 'struct ChannelState *'
2938 * @param message the actual message 2938 * @param message the actual message
2939 * @return #GNUNET_OK to keep the connection open, 2939 * @return #GNUNET_OK to keep the connection open,
2940 * #GNUNET_SYSERR to close it (signal serious error) 2940 * #GNUNET_SYSERR to close it (signal serious error)
2941 */ 2941 */
2942static int 2942static int
2943receive_udp_service (void *cls, 2943receive_udp_service (void *cls,
2944 struct GNUNET_MESH_Tunnel *tunnel, 2944 struct GNUNET_MESH_Channel *channel,
2945 void **tunnel_ctx, 2945 void **channel_ctx,
2946 const struct GNUNET_MessageHeader *message) 2946 const struct GNUNET_MessageHeader *message)
2947{ 2947{
2948 struct TunnelState *state = *tunnel_ctx; 2948 struct ChannelState *state = *channel_ctx;
2949 const struct GNUNET_EXIT_UdpServiceMessage *msg; 2949 const struct GNUNET_EXIT_UdpServiceMessage *msg;
2950 uint16_t pkt_len = ntohs (message->size); 2950 uint16_t pkt_len = ntohs (message->size);
2951 2951
@@ -2956,7 +2956,7 @@ receive_udp_service (void *cls,
2956 } 2956 }
2957 if (GNUNET_SYSERR == state->is_dns) 2957 if (GNUNET_SYSERR == state->is_dns)
2958 { 2958 {
2959 /* tunnel is UDP/TCP from now on */ 2959 /* channel is UDP/TCP from now on */
2960 state->is_dns = GNUNET_NO; 2960 state->is_dns = GNUNET_NO;
2961 } 2961 }
2962 GNUNET_STATISTICS_update (stats, 2962 GNUNET_STATISTICS_update (stats,
@@ -3002,54 +3002,54 @@ receive_udp_service (void *cls,
3002 3002
3003 3003
3004/** 3004/**
3005 * Callback from GNUNET_MESH for new tunnels. 3005 * Callback from GNUNET_MESH for new channels.
3006 * 3006 *
3007 * @param cls closure 3007 * @param cls closure
3008 * @param tunnel new handle to the tunnel 3008 * @param channel new handle to the channel
3009 * @param initiator peer that started the tunnel 3009 * @param initiator peer that started the channel
3010 * @param port destination port 3010 * @param port destination port
3011 * @return initial tunnel context for the tunnel 3011 * @return initial channel context for the channel
3012 */ 3012 */
3013static void * 3013static void *
3014new_tunnel (void *cls, 3014new_channel (void *cls,
3015 struct GNUNET_MESH_Tunnel *tunnel, 3015 struct GNUNET_MESH_Channel *channel,
3016 const struct GNUNET_PeerIdentity *initiator, 3016 const struct GNUNET_PeerIdentity *initiator,
3017 uint32_t port) 3017 uint32_t port)
3018{ 3018{
3019 struct TunnelState *s = GNUNET_new (struct TunnelState); 3019 struct ChannelState *s = GNUNET_new (struct ChannelState);
3020 3020
3021 s->is_dns = GNUNET_SYSERR; 3021 s->is_dns = GNUNET_SYSERR;
3022 s->peer = *initiator; 3022 s->peer = *initiator;
3023 GNUNET_STATISTICS_update (stats, 3023 GNUNET_STATISTICS_update (stats,
3024 gettext_noop ("# Inbound MESH tunnels created"), 3024 gettext_noop ("# Inbound MESH channels created"),
3025 1, GNUNET_NO); 3025 1, GNUNET_NO);
3026 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3026 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3027 "Received inbound tunnel from `%s'\n", 3027 "Received inbound channel from `%s'\n",
3028 GNUNET_i2s (initiator)); 3028 GNUNET_i2s (initiator));
3029 s->tunnel = tunnel; 3029 s->channel = channel;
3030 return s; 3030 return s;
3031} 3031}
3032 3032
3033 3033
3034/** 3034/**
3035 * Function called by mesh whenever an inbound tunnel is destroyed. 3035 * Function called by mesh whenever an inbound channel is destroyed.
3036 * Should clean up any associated state. 3036 * Should clean up any associated state.
3037 * 3037 *
3038 * @param cls closure (set from #GNUNET_MESH_connect) 3038 * @param cls closure (set from #GNUNET_MESH_connect)
3039 * @param tunnel connection to the other end (henceforth invalid) 3039 * @param channel connection to the other end (henceforth invalid)
3040 * @param tunnel_ctx place where local state associated 3040 * @param channel_ctx place where local state associated
3041 * with the tunnel is stored 3041 * with the channel is stored
3042 */ 3042 */
3043static void 3043static void
3044clean_tunnel (void *cls, 3044clean_channel (void *cls,
3045 const struct GNUNET_MESH_Tunnel *tunnel, 3045 const struct GNUNET_MESH_Channel *channel,
3046 void *tunnel_ctx) 3046 void *channel_ctx)
3047{ 3047{
3048 struct TunnelState *s = tunnel_ctx; 3048 struct ChannelState *s = channel_ctx;
3049 struct TunnelMessageQueue *tnq; 3049 struct ChannelMessageQueue *tnq;
3050 3050
3051 LOG (GNUNET_ERROR_TYPE_DEBUG, 3051 LOG (GNUNET_ERROR_TYPE_DEBUG,
3052 "Tunnel destroyed\n"); 3052 "Channel destroyed\n");
3053 if (GNUNET_SYSERR == s->is_dns) 3053 if (GNUNET_SYSERR == s->is_dns)
3054 { 3054 {
3055 GNUNET_free (s); 3055 GNUNET_free (s);
@@ -3057,8 +3057,8 @@ clean_tunnel (void *cls,
3057 } 3057 }
3058 if (GNUNET_YES == s->is_dns) 3058 if (GNUNET_YES == s->is_dns)
3059 { 3059 {
3060 if (tunnels[s->specifics.dns.my_id] == s) 3060 if (channels[s->specifics.dns.my_id] == s)
3061 tunnels[s->specifics.dns.my_id] = NULL; 3061 channels[s->specifics.dns.my_id] = NULL;
3062 GNUNET_free_non_null (s->specifics.dns.reply); 3062 GNUNET_free_non_null (s->specifics.dns.reply);
3063 } 3063 }
3064 else 3064 else
@@ -3703,8 +3703,8 @@ run (void *cls,
3703 connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 3703 connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
3704 mesh_handle 3704 mesh_handle
3705 = GNUNET_MESH_connect (cfg, NULL, 3705 = GNUNET_MESH_connect (cfg, NULL,
3706 &new_tunnel, 3706 &new_channel,
3707 &clean_tunnel, handlers, 3707 &clean_channel, handlers,
3708 apptypes); // FIXME use ports 3708 apptypes); // FIXME use ports
3709 if (NULL == mesh_handle) 3709 if (NULL == mesh_handle)
3710 { 3710 {