aboutsummaryrefslogtreecommitdiff
path: root/src/exit/gnunet-daemon-exit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exit/gnunet-daemon-exit.c')
-rw-r--r--src/exit/gnunet-daemon-exit.c292
1 files changed, 146 insertions, 146 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index a758162a7..f4d656f3c 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -31,7 +31,7 @@
31 * - which code should advertise services? the service model is right 31 * - which code should advertise services? the service model is right
32 * now a bit odd, especially as this code DOES the exit and knows 32 * now a bit odd, especially as this code DOES the exit and knows
33 * the DNS "name", but OTOH this is clearly NOT the place to advertise 33 * the DNS "name", but OTOH this is clearly NOT the place to advertise
34 * the service's existence; maybe the daemon should turn into a 34 * the service's existence; maybe the daemon should turn into a
35 * service with an API to add local-exit services dynamically? 35 * service with an API to add local-exit services dynamically?
36 */ 36 */
37#include "platform.h" 37#include "platform.h"
@@ -111,7 +111,7 @@ struct SocketAddress
111 */ 111 */
112 struct in6_addr ipv6; 112 struct in6_addr ipv6;
113 } address; 113 } address;
114 114
115 /** 115 /**
116 * IPPROTO_TCP or IPPROTO_UDP; 116 * IPPROTO_TCP or IPPROTO_UDP;
117 */ 117 */
@@ -155,7 +155,7 @@ struct LocalService
155 * IP-version, protocol, source-IP, destination-IP, source-port and 155 * IP-version, protocol, source-IP, destination-IP, source-port and
156 * destinatin-port. 156 * destinatin-port.
157 */ 157 */
158struct RedirectInformation 158struct RedirectInformation
159{ 159{
160 160
161 /** 161 /**
@@ -171,10 +171,10 @@ struct RedirectInformation
171 */ 171 */
172 struct SocketAddress local_address; 172 struct SocketAddress local_address;
173 173
174 /* 174 /*
175 Note 1: additional information might be added here in the 175 Note 1: additional information might be added here in the
176 future to support protocols that require special handling, 176 future to support protocols that require special handling,
177 such as ftp/tftp 177 such as ftp/tftp
178 178
179 Note 2: we might also sometimes not match on all components 179 Note 2: we might also sometimes not match on all components
180 of the tuple, to support protocols where things do not always 180 of the tuple, to support protocols where things do not always
@@ -235,42 +235,42 @@ struct TunnelState
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 tunnel for TCP/UDP,
239 * #GNUNET_YES if this is a tunnel for DNS, 239 * #GNUNET_YES if this is a tunnel for DNS,
240 * #GNUNET_SYSERR if the tunnel is not yet initialized. 240 * #GNUNET_SYSERR if the tunnel is not yet initialized.
241 */ 241 */
242 int is_dns; 242 int is_dns;
243 243
244 union 244 union
245 { 245 {
246 struct 246 struct
247 { 247 {
248 248
249 /** 249 /**
250 * Heap node for this state in the connections_heap. 250 * Heap node for this state in the connections_heap.
251 */ 251 */
252 struct GNUNET_CONTAINER_HeapNode *heap_node; 252 struct GNUNET_CONTAINER_HeapNode *heap_node;
253 253
254 /** 254 /**
255 * Key this state has in the connections_map. 255 * Key this state has in the connections_map.
256 */ 256 */
257 struct GNUNET_HashCode state_key; 257 struct GNUNET_HashCode state_key;
258 258
259 /** 259 /**
260 * Associated service record, or NULL for no service. 260 * Associated service record, or NULL for no service.
261 */ 261 */
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 tunnel.
266 */ 266 */
267 struct TunnelMessageQueue *head; 267 struct TunnelMessageQueue *head;
268 268
269 /** 269 /**
270 * Tail of DLL of messages for this tunnel. 270 * Tail of DLL of messages for this tunnel.
271 */ 271 */
272 struct TunnelMessageQueue *tail; 272 struct TunnelMessageQueue *tail;
273 273
274 /** 274 /**
275 * Primary redirection information for this connection. 275 * Primary redirection information for this connection.
276 */ 276 */
@@ -284,28 +284,28 @@ struct TunnelState
284 * DNS reply ready for transmission. 284 * DNS reply ready for transmission.
285 */ 285 */
286 char *reply; 286 char *reply;
287 287
288 /** 288 /**
289 * Socket we are using to transmit this request (must match if we receive 289 * Socket we are using to transmit this request (must match if we receive
290 * a response). 290 * a response).
291 */ 291 */
292 struct GNUNET_DNSSTUB_RequestSocket *rs; 292 struct GNUNET_DNSSTUB_RequestSocket *rs;
293 293
294 /** 294 /**
295 * Number of bytes in 'reply'. 295 * Number of bytes in 'reply'.
296 */ 296 */
297 size_t reply_length; 297 size_t reply_length;
298 298
299 /** 299 /**
300 * Original DNS request ID as used by the client. 300 * Original DNS request ID as used by the client.
301 */ 301 */
302 uint16_t original_id; 302 uint16_t original_id;
303 303
304 /** 304 /**
305 * DNS request ID that we used for forwarding. 305 * DNS request ID that we used for forwarding.
306 */ 306 */
307 uint16_t my_id; 307 uint16_t my_id;
308 308
309 } dns; 309 } dns;
310 310
311 } specifics; 311 } specifics;
@@ -411,7 +411,7 @@ static struct GNUNET_DNSSTUB_Context *dnsstub;
411 411
412/** 412/**
413 * Handle for ongoing DHT PUT operations to advertise exit service. 413 * Handle for ongoing DHT PUT operations to advertise exit service.
414 */ 414 */
415static struct GNUNET_DHT_PutHandle *dht_put; 415static struct GNUNET_DHT_PutHandle *dht_put;
416 416
417/** 417/**
@@ -487,7 +487,7 @@ transmit_reply_to_mesh (void *cls,
487 GNUNET_assert (ts->specifics.dns.reply != NULL); 487 GNUNET_assert (ts->specifics.dns.reply != NULL);
488 if (size == 0) 488 if (size == 0)
489 return 0; 489 return 0;
490 ret = sizeof (struct GNUNET_MessageHeader) + ts->specifics.dns.reply_length; 490 ret = sizeof (struct GNUNET_MessageHeader) + ts->specifics.dns.reply_length;
491 GNUNET_assert (ret <= size); 491 GNUNET_assert (ret <= size);
492 hdr.size = htons (ret); 492 hdr.size = htons (ret);
493 hdr.type = htons (GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET); 493 hdr.type = htons (GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET);
@@ -502,7 +502,7 @@ transmit_reply_to_mesh (void *cls,
502 off += ts->specifics.dns.reply_length - sizeof (dns); 502 off += ts->specifics.dns.reply_length - sizeof (dns);
503 GNUNET_free (ts->specifics.dns.reply); 503 GNUNET_free (ts->specifics.dns.reply);
504 ts->specifics.dns.reply = NULL; 504 ts->specifics.dns.reply = NULL;
505 ts->specifics.dns.reply_length = 0; 505 ts->specifics.dns.reply_length = 0;
506 GNUNET_assert (ret == off); 506 GNUNET_assert (ret == off);
507 return ret; 507 return ret;
508} 508}
@@ -558,7 +558,7 @@ process_dns_result (void *cls,
558 * @param tunnel connection to the other end 558 * @param tunnel connection to the other end
559 * @param tunnel_ctx pointer to our `struct TunnelState *` 559 * @param tunnel_ctx pointer to our `struct TunnelState *`
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 */
@@ -595,7 +595,7 @@ receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
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 (tunnels[ts->specifics.dns.my_id] == ts)
597 tunnels[ts->specifics.dns.my_id] = NULL; 597 tunnels[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 tunnels[ts->specifics.dns.my_id] = ts;
601 memcpy (buf, dns, dlen); 601 memcpy (buf, dns, dlen);
@@ -619,7 +619,7 @@ receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
619 * @param ri information about the connection 619 * @param ri information about the connection
620 */ 620 */
621static void 621static void
622hash_redirect_info (struct GNUNET_HashCode *hash, 622hash_redirect_info (struct GNUNET_HashCode *hash,
623 const struct RedirectInformation *ri) 623 const struct RedirectInformation *ri)
624{ 624{
625 char *off; 625 char *off;
@@ -678,7 +678,7 @@ hash_redirect_info (struct GNUNET_HashCode *hash,
678 */ 678 */
679static struct TunnelState * 679static struct TunnelState *
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,
683 uint16_t destination_port, 683 uint16_t destination_port,
684 const void *local_ip, 684 const void *local_ip,
@@ -718,7 +718,7 @@ get_redirect_state (int af,
718 return NULL; 718 return NULL;
719 /* Mark this connection as freshly used */ 719 /* Mark this connection as freshly used */
720 if (NULL == state_key) 720 if (NULL == state_key)
721 GNUNET_CONTAINER_heap_update_cost (connections_heap, 721 GNUNET_CONTAINER_heap_update_cost (connections_heap,
722 state->specifics.tcp_udp.heap_node, 722 state->specifics.tcp_udp.heap_node,
723 GNUNET_TIME_absolute_get ().abs_value_us); 723 GNUNET_TIME_absolute_get ().abs_value_us);
724 return state; 724 return state;
@@ -774,7 +774,7 @@ free_service_record (void *cls,
774 * respective service entry. 774 * respective service entry.
775 * 775 *
776 * @param service_map map of services (TCP or UDP) 776 * @param service_map map of services (TCP or UDP)
777 * @param name name of the service 777 * @param name name of the service
778 * @param destination_port destination port 778 * @param destination_port destination port
779 * @param service service information record to store (service->name will be set). 779 * @param service service information record to store (service->name will be set).
780 */ 780 */
@@ -827,8 +827,8 @@ 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 (tunnel,
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,
834 &send_to_peer_notify_callback, 834 &send_to_peer_notify_callback,
@@ -838,13 +838,13 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
838 GNUNET_assert (size >= tnq->len); 838 GNUNET_assert (size >= tnq->len);
839 memcpy (buf, tnq->payload, tnq->len); 839 memcpy (buf, tnq->payload, tnq->len);
840 size = tnq->len; 840 size = tnq->len;
841 GNUNET_CONTAINER_DLL_remove (s->specifics.tcp_udp.head, 841 GNUNET_CONTAINER_DLL_remove (s->specifics.tcp_udp.head,
842 s->specifics.tcp_udp.tail, 842 s->specifics.tcp_udp.tail,
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 (tunnel,
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,
@@ -887,16 +887,16 @@ send_packet_to_mesh_tunnel (struct TunnelState *s,
887 * @param icmp A pointer to the Packet 887 * @param icmp A pointer to the Packet
888 * @param pktlen number of bytes in 'icmp' 888 * @param pktlen number of bytes in 'icmp'
889 * @param af address family (AFINET or AF_INET6) 889 * @param af address family (AFINET or AF_INET6)
890 * @param destination_ip destination IP-address of the IP packet (should 890 * @param destination_ip destination IP-address of the IP packet (should
891 * be our local address) 891 * be our local address)
892 * @param source_ip original source IP-address of the IP packet (should 892 * @param source_ip original source IP-address of the IP packet (should
893 * be the original destination address) 893 * be the original destination address)
894 */ 894 */
895static void 895static void
896icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp, 896icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
897 size_t pktlen, 897 size_t pktlen,
898 int af, 898 int af,
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 TunnelState *state;
@@ -920,7 +920,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
920 sbuf, sizeof (sbuf)), 920 sbuf, sizeof (sbuf)),
921 inet_ntop (af, 921 inet_ntop (af,
922 destination_ip, 922 destination_ip,
923 dbuf, sizeof (dbuf))); 923 dbuf, sizeof (dbuf)));
924 } 924 }
925 if (pktlen < sizeof (struct GNUNET_TUN_IcmpHeader)) 925 if (pktlen < sizeof (struct GNUNET_TUN_IcmpHeader))
926 { 926 {
@@ -946,7 +946,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
946 case GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE: 946 case GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE:
947 case GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH: 947 case GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH:
948 case GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED: 948 case GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED:
949 if (pktlen < 949 if (pktlen <
950 sizeof (struct GNUNET_TUN_IcmpHeader) + 950 sizeof (struct GNUNET_TUN_IcmpHeader) +
951 sizeof (struct GNUNET_TUN_IPv4Header) + 8) 951 sizeof (struct GNUNET_TUN_IPv4Header) + 8)
952 { 952 {
@@ -980,7 +980,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
980 case GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG: 980 case GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG:
981 case GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED: 981 case GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED:
982 case GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM: 982 case GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM:
983 if (pktlen < 983 if (pktlen <
984 sizeof (struct GNUNET_TUN_IcmpHeader) + 984 sizeof (struct GNUNET_TUN_IcmpHeader) +
985 sizeof (struct GNUNET_TUN_IPv6Header) + 8) 985 sizeof (struct GNUNET_TUN_IPv6Header) + 8)
986 { 986 {
@@ -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 TunnelMessageQueue) + 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];
@@ -1075,16 +1075,16 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
1075 * @param udp A pointer to the Packet 1075 * @param udp A pointer to the Packet
1076 * @param pktlen number of bytes in 'udp' 1076 * @param pktlen number of bytes in 'udp'
1077 * @param af address family (AFINET or AF_INET6) 1077 * @param af address family (AFINET or AF_INET6)
1078 * @param destination_ip destination IP-address of the IP packet (should 1078 * @param destination_ip destination IP-address of the IP packet (should
1079 * be our local address) 1079 * be our local address)
1080 * @param source_ip original source IP-address of the IP packet (should 1080 * @param source_ip original source IP-address of the IP packet (should
1081 * be the original destination address) 1081 * be the original destination address)
1082 */ 1082 */
1083static void 1083static void
1084udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp, 1084udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
1085 size_t pktlen, 1085 size_t pktlen,
1086 int af, 1086 int af,
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 TunnelState *state;
@@ -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 TunnelMessageQueue) + 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];
@@ -1152,13 +1152,13 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
1152 * @param tcp A pointer to the Packet 1152 * @param tcp A pointer to the Packet
1153 * @param pktlen the length of the packet, including its TCP header 1153 * @param pktlen the length of the packet, including its TCP header
1154 * @param af address family (AFINET or AF_INET6) 1154 * @param af address family (AFINET or AF_INET6)
1155 * @param destination_ip destination IP-address of the IP packet (should 1155 * @param destination_ip destination IP-address of the IP packet (should
1156 * be our local address) 1156 * be our local address)
1157 * @param source_ip original source IP-address of the IP packet (should 1157 * @param source_ip original source IP-address of the IP packet (should
1158 * be the original destination address) 1158 * be the original destination address)
1159 */ 1159 */
1160static void 1160static void
1161tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp, 1161tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
1162 size_t pktlen, 1162 size_t pktlen,
1163 int af, 1163 int af,
1164 const void *destination_ip, 1164 const void *destination_ip,
@@ -1193,7 +1193,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
1193 return; 1193 return;
1194 } 1194 }
1195 state = get_redirect_state (af, IPPROTO_TCP, 1195 state = get_redirect_state (af, IPPROTO_TCP,
1196 source_ip, 1196 source_ip,
1197 ntohs (tcp->source_port), 1197 ntohs (tcp->source_port),
1198 destination_ip, 1198 destination_ip,
1199 ntohs (tcp->destination_port), 1199 ntohs (tcp->destination_port),
@@ -1202,12 +1202,12 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
1202 { 1202 {
1203 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1203 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1204 _("TCP Packet dropped, have no matching connection information\n")); 1204 _("TCP Packet dropped, have no matching connection information\n"));
1205 1205
1206 return; 1206 return;
1207 } 1207 }
1208 /* mug port numbers and crc to avoid information leakage; 1208 /* mug port numbers and crc to avoid information leakage;
1209 sender will need to lookup the correct values anyway */ 1209 sender will need to lookup the correct values anyway */
1210 memcpy (buf, tcp, pktlen); 1210 memcpy (buf, tcp, pktlen);
1211 mtcp = (struct GNUNET_TUN_TcpHeader *) buf; 1211 mtcp = (struct GNUNET_TUN_TcpHeader *) buf;
1212 mtcp->source_port = 0; 1212 mtcp->source_port = 0;
1213 mtcp->destination_port = 0; 1213 mtcp->destination_port = 0;
@@ -1228,7 +1228,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
1228 tdm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_VPN); 1228 tdm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_VPN);
1229 tdm->reserved = htonl (0); 1229 tdm->reserved = htonl (0);
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_tunnel (state, tnq);
1234} 1234}
@@ -1296,26 +1296,26 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
1296 _("IPv4 packet options received. Ignored.\n")); 1296 _("IPv4 packet options received. Ignored.\n"));
1297 return GNUNET_OK; 1297 return GNUNET_OK;
1298 } 1298 }
1299 1299
1300 size -= sizeof (struct GNUNET_TUN_IPv4Header); 1300 size -= sizeof (struct GNUNET_TUN_IPv4Header);
1301 switch (pkt4->protocol) 1301 switch (pkt4->protocol)
1302 { 1302 {
1303 case IPPROTO_UDP: 1303 case IPPROTO_UDP:
1304 udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt4[1], size, 1304 udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt4[1], size,
1305 AF_INET, 1305 AF_INET,
1306 &pkt4->destination_address, 1306 &pkt4->destination_address,
1307 &pkt4->source_address); 1307 &pkt4->source_address);
1308 break; 1308 break;
1309 case IPPROTO_TCP: 1309 case IPPROTO_TCP:
1310 tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt4[1], size, 1310 tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt4[1], size,
1311 AF_INET, 1311 AF_INET,
1312 &pkt4->destination_address, 1312 &pkt4->destination_address,
1313 &pkt4->source_address); 1313 &pkt4->source_address);
1314 break; 1314 break;
1315 case IPPROTO_ICMP: 1315 case IPPROTO_ICMP:
1316 icmp_from_helper ((const struct GNUNET_TUN_IcmpHeader *) &pkt4[1], size, 1316 icmp_from_helper ((const struct GNUNET_TUN_IcmpHeader *) &pkt4[1], size,
1317 AF_INET, 1317 AF_INET,
1318 &pkt4->destination_address, 1318 &pkt4->destination_address,
1319 &pkt4->source_address); 1319 &pkt4->source_address);
1320 break; 1320 break;
1321 default: 1321 default:
@@ -1349,19 +1349,19 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
1349 case IPPROTO_UDP: 1349 case IPPROTO_UDP:
1350 udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt6[1], size, 1350 udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt6[1], size,
1351 AF_INET6, 1351 AF_INET6,
1352 &pkt6->destination_address, 1352 &pkt6->destination_address,
1353 &pkt6->source_address); 1353 &pkt6->source_address);
1354 break; 1354 break;
1355 case IPPROTO_TCP: 1355 case IPPROTO_TCP:
1356 tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt6[1], size, 1356 tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt6[1], size,
1357 AF_INET6, 1357 AF_INET6,
1358 &pkt6->destination_address, 1358 &pkt6->destination_address,
1359 &pkt6->source_address); 1359 &pkt6->source_address);
1360 break; 1360 break;
1361 case IPPROTO_ICMPV6: 1361 case IPPROTO_ICMPV6:
1362 icmp_from_helper ((const struct GNUNET_TUN_IcmpHeader *) &pkt6[1], size, 1362 icmp_from_helper ((const struct GNUNET_TUN_IcmpHeader *) &pkt6[1], size,
1363 AF_INET6, 1363 AF_INET6,
1364 &pkt6->destination_address, 1364 &pkt6->destination_address,
1365 &pkt6->source_address); 1365 &pkt6->source_address);
1366 break; 1366 break;
1367 default: 1367 default:
@@ -1398,14 +1398,14 @@ setup_fresh_address (int af,
1398 local_address->af = af; 1398 local_address->af = af;
1399 local_address->proto = (uint8_t) proto; 1399 local_address->proto = (uint8_t) proto;
1400 /* default "local" port range is often 32768--61000, 1400 /* default "local" port range is often 32768--61000,
1401 so we pick a random value in that range */ 1401 so we pick a random value in that range */
1402 if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) || 1402 if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
1403 ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) ) 1403 ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
1404 local_address->port = 0; 1404 local_address->port = 0;
1405 else 1405 else
1406 local_address->port 1406 local_address->port
1407 = (uint16_t) 32768 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1407 = (uint16_t) 32768 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1408 28232); 1408 28232);
1409 switch (af) 1409 switch (af)
1410 { 1410 {
1411 case AF_INET: 1411 case AF_INET:
@@ -1422,13 +1422,13 @@ setup_fresh_address (int af,
1422 local_address->address.ipv4 = addr; 1422 local_address->address.ipv4 = addr;
1423 return; 1423 return;
1424 } 1424 }
1425 /* Given 192.168.0.1/255.255.0.0, we want a mask 1425 /* Given 192.168.0.1/255.255.0.0, we want a mask
1426 of '192.168.255.255', thus: */ 1426 of '192.168.255.255', thus: */
1427 mask.s_addr = addr.s_addr | ~mask.s_addr; 1427 mask.s_addr = addr.s_addr | ~mask.s_addr;
1428 /* Pick random IPv4 address within the subnet, except 'addr' or 'mask' itself */ 1428 /* Pick random IPv4 address within the subnet, except 'addr' or 'mask' itself */
1429 do 1429 do
1430 { 1430 {
1431 rnd.s_addr = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1431 rnd.s_addr = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1432 UINT32_MAX); 1432 UINT32_MAX);
1433 local_address->address.ipv4.s_addr = (addr.s_addr | rnd.s_addr) & mask.s_addr; 1433 local_address->address.ipv4.s_addr = (addr.s_addr | rnd.s_addr) & mask.s_addr;
1434 } 1434 }
@@ -1442,7 +1442,7 @@ setup_fresh_address (int af,
1442 struct in6_addr mask; 1442 struct in6_addr mask;
1443 struct in6_addr rnd; 1443 struct in6_addr rnd;
1444 int i; 1444 int i;
1445 1445
1446 addr = exit_ipv6addr; 1446 addr = exit_ipv6addr;
1447 GNUNET_assert (ipv6prefix < 128); 1447 GNUNET_assert (ipv6prefix < 128);
1448 if (ipv6prefix == 127) 1448 if (ipv6prefix == 127)
@@ -1456,13 +1456,13 @@ setup_fresh_address (int af,
1456 mask = addr; 1456 mask = addr;
1457 for (i=127;i>=ipv6prefix;i--) 1457 for (i=127;i>=ipv6prefix;i--)
1458 mask.s6_addr[i / 8] |= (1 << (i % 8)); 1458 mask.s6_addr[i / 8] |= (1 << (i % 8));
1459 1459
1460 /* Pick random IPv6 address within the subnet, except 'addr' or 'mask' itself */ 1460 /* Pick random IPv6 address within the subnet, except 'addr' or 'mask' itself */
1461 do 1461 do
1462 { 1462 {
1463 for (i=0;i<16;i++) 1463 for (i=0;i<16;i++)
1464 { 1464 {
1465 rnd.s6_addr[i] = (unsigned char) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1465 rnd.s6_addr[i] = (unsigned char) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1466 256); 1466 256);
1467 local_address->address.ipv6.s6_addr[i] 1467 local_address->address.ipv6.s6_addr[i]
1468 = (addr.s6_addr[i] | rnd.s6_addr[i]) & mask.s6_addr[i]; 1468 = (addr.s6_addr[i] | rnd.s6_addr[i]) & mask.s6_addr[i];
@@ -1478,7 +1478,7 @@ setup_fresh_address (int af,
1478 break; 1478 break;
1479 default: 1479 default:
1480 GNUNET_assert (0); 1480 GNUNET_assert (0);
1481 } 1481 }
1482} 1482}
1483 1483
1484 1484
@@ -1531,19 +1531,19 @@ setup_state_record (struct TunnelState *state)
1531 char buf[INET6_ADDRSTRLEN]; 1531 char buf[INET6_ADDRSTRLEN];
1532 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1532 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1533 "Picked local address %s:%u for new connection\n", 1533 "Picked local address %s:%u for new connection\n",
1534 inet_ntop (state->specifics.tcp_udp.ri.local_address.af, 1534 inet_ntop (state->specifics.tcp_udp.ri.local_address.af,
1535 &state->specifics.tcp_udp.ri.local_address.address, 1535 &state->specifics.tcp_udp.ri.local_address.address,
1536 buf, sizeof (buf)), 1536 buf, sizeof (buf)),
1537 (unsigned int) state->specifics.tcp_udp.ri.local_address.port); 1537 (unsigned int) state->specifics.tcp_udp.ri.local_address.port);
1538 } 1538 }
1539 state->specifics.tcp_udp.state_key = key; 1539 state->specifics.tcp_udp.state_key = key;
1540 GNUNET_assert (GNUNET_OK == 1540 GNUNET_assert (GNUNET_OK ==
1541 GNUNET_CONTAINER_multihashmap_put (connections_map, 1541 GNUNET_CONTAINER_multihashmap_put (connections_map,
1542 &key, state, 1542 &key, state,
1543 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 1543 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
1544 state->specifics.tcp_udp.heap_node = GNUNET_CONTAINER_heap_insert (connections_heap, 1544 state->specifics.tcp_udp.heap_node = GNUNET_CONTAINER_heap_insert (connections_heap,
1545 state, 1545 state,
1546 GNUNET_TIME_absolute_get ().abs_value_us); 1546 GNUNET_TIME_absolute_get ().abs_value_us);
1547 while (GNUNET_CONTAINER_heap_get_size (connections_heap) > max_connections) 1547 while (GNUNET_CONTAINER_heap_get_size (connections_heap) > max_connections)
1548 { 1548 {
1549 s = GNUNET_CONTAINER_heap_remove_root (connections_heap); 1549 s = GNUNET_CONTAINER_heap_remove_root (connections_heap);
@@ -1552,7 +1552,7 @@ setup_state_record (struct TunnelState *state)
1552 GNUNET_MESH_tunnel_destroy (s->tunnel); 1552 GNUNET_MESH_tunnel_destroy (s->tunnel);
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,
1556 s)); 1556 s));
1557 GNUNET_free (s); 1557 GNUNET_free (s);
1558 } 1558 }
@@ -1630,7 +1630,7 @@ prepare_ipv4_packet (const void *payload, size_t payload_length,
1630 case IPPROTO_TCP: 1630 case IPPROTO_TCP:
1631 { 1631 {
1632 struct GNUNET_TUN_TcpHeader *pkt4_tcp = (struct GNUNET_TUN_TcpHeader *) &pkt4[1]; 1632 struct GNUNET_TUN_TcpHeader *pkt4_tcp = (struct GNUNET_TUN_TcpHeader *) &pkt4[1];
1633 1633
1634 *pkt4_tcp = *tcp_header; 1634 *pkt4_tcp = *tcp_header;
1635 pkt4_tcp->source_port = htons (src_address->port); 1635 pkt4_tcp->source_port = htons (src_address->port);
1636 pkt4_tcp->destination_port = htons (dst_address->port); 1636 pkt4_tcp->destination_port = htons (dst_address->port);
@@ -1696,7 +1696,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
1696 1696
1697 GNUNET_TUN_initialize_ipv6_header (pkt6, 1697 GNUNET_TUN_initialize_ipv6_header (pkt6,
1698 protocol, 1698 protocol,
1699 len, 1699 len,
1700 &src_address->address.ipv6, 1700 &src_address->address.ipv6,
1701 &dst_address->address.ipv6); 1701 &dst_address->address.ipv6);
1702 1702
@@ -1785,7 +1785,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1785 char buf[len] GNUNET_ALIGN; 1785 char buf[len] GNUNET_ALIGN;
1786 struct GNUNET_MessageHeader *hdr; 1786 struct GNUNET_MessageHeader *hdr;
1787 struct GNUNET_TUN_Layer2PacketHeader *tun; 1787 struct GNUNET_TUN_Layer2PacketHeader *tun;
1788 1788
1789 hdr = (struct GNUNET_MessageHeader *) buf; 1789 hdr = (struct GNUNET_MessageHeader *) buf;
1790 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); 1790 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER);
1791 hdr->size = htons (len); 1791 hdr->size = htons (len);
@@ -1800,7 +1800,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1800 tun->proto = htons (ETH_P_IPV4); 1800 tun->proto = htons (ETH_P_IPV4);
1801 prepare_ipv4_packet (payload, payload_length, 1801 prepare_ipv4_packet (payload, payload_length,
1802 IPPROTO_TCP, 1802 IPPROTO_TCP,
1803 tcp_header, 1803 tcp_header,
1804 source_address, 1804 source_address,
1805 destination_address, 1805 destination_address,
1806 ipv4); 1806 ipv4);
@@ -1811,9 +1811,9 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1811 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1]; 1811 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
1812 1812
1813 tun->proto = htons (ETH_P_IPV6); 1813 tun->proto = htons (ETH_P_IPV6);
1814 prepare_ipv6_packet (payload, payload_length, 1814 prepare_ipv6_packet (payload, payload_length,
1815 IPPROTO_TCP, 1815 IPPROTO_TCP,
1816 tcp_header, 1816 tcp_header,
1817 source_address, 1817 source_address,
1818 destination_address, 1818 destination_address,
1819 ipv6); 1819 ipv6);
@@ -1840,7 +1840,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1840 * @param tunnel connection to the other end 1840 * @param tunnel connection to the other end
1841 * @param tunnel_ctx pointer to our 'struct TunnelState *' 1841 * @param tunnel_ctx pointer to our 'struct TunnelState *'
1842 * @param message the actual message 1842 * @param message the actual message
1843 * 1843 *
1844 * @return GNUNET_OK to keep the connection open, 1844 * @return GNUNET_OK to keep the connection open,
1845 * GNUNET_SYSERR to close it (signal serious error) 1845 * GNUNET_SYSERR to close it (signal serious error)
1846 */ 1846 */
@@ -1853,7 +1853,7 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
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
1856 if (NULL == state) 1856 if (NULL == state)
1857 { 1857 {
1858 GNUNET_break_op (0); 1858 GNUNET_break_op (0);
1859 return GNUNET_SYSERR; 1859 return GNUNET_SYSERR;
@@ -1899,11 +1899,11 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1899 "Received data from %s for forwarding to TCP service %s on port %u\n", 1899 "Received data from %s for forwarding to TCP service %s on port %u\n",
1900 GNUNET_i2s (&state->peer), 1900 GNUNET_i2s (&state->peer),
1901 GNUNET_h2s (&start->service_descriptor), 1901 GNUNET_h2s (&start->service_descriptor),
1902 (unsigned int) ntohs (start->tcp_header.destination_port)); 1902 (unsigned int) ntohs (start->tcp_header.destination_port));
1903 if (NULL == (state->specifics.tcp_udp.serv = find_service (tcp_services, &start->service_descriptor, 1903 if (NULL == (state->specifics.tcp_udp.serv = find_service (tcp_services, &start->service_descriptor,
1904 ntohs (start->tcp_header.destination_port)))) 1904 ntohs (start->tcp_header.destination_port))))
1905 { 1905 {
1906 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1906 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1907 _("No service found for %s on port %d!\n"), 1907 _("No service found for %s on port %d!\n"),
1908 "TCP", 1908 "TCP",
1909 ntohs (start->tcp_header.destination_port)); 1909 ntohs (start->tcp_header.destination_port));
@@ -1912,7 +1912,7 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1912 1, GNUNET_NO); 1912 1, GNUNET_NO);
1913 return GNUNET_SYSERR; 1913 return GNUNET_SYSERR;
1914 } 1914 }
1915 state->specifics.tcp_udp.ri.remote_address = state->specifics.tcp_udp.serv->address; 1915 state->specifics.tcp_udp.ri.remote_address = state->specifics.tcp_udp.serv->address;
1916 setup_state_record (state); 1916 setup_state_record (state);
1917 send_tcp_packet_via_tun (&state->specifics.tcp_udp.ri.remote_address, 1917 send_tcp_packet_via_tun (&state->specifics.tcp_udp.ri.remote_address,
1918 &state->specifics.tcp_udp.ri.local_address, 1918 &state->specifics.tcp_udp.ri.local_address,
@@ -1929,7 +1929,7 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1929 * @param tunnel connection to the other end 1929 * @param tunnel connection to the other end
1930 * @param tunnel_ctx pointer to our 'struct TunnelState *' 1930 * @param tunnel_ctx pointer to our 'struct TunnelState *'
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 */
@@ -1946,7 +1946,7 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1946 const void *payload; 1946 const void *payload;
1947 int af; 1947 int af;
1948 1948
1949 if (NULL == state) 1949 if (NULL == state)
1950 { 1950 {
1951 GNUNET_break_op (0); 1951 GNUNET_break_op (0);
1952 return GNUNET_SYSERR; 1952 return GNUNET_SYSERR;
@@ -1973,7 +1973,7 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1973 return GNUNET_SYSERR; 1973 return GNUNET_SYSERR;
1974 } 1974 }
1975 start = (const struct GNUNET_EXIT_TcpInternetStartMessage*) message; 1975 start = (const struct GNUNET_EXIT_TcpInternetStartMessage*) message;
1976 pkt_len -= sizeof (struct GNUNET_EXIT_TcpInternetStartMessage); 1976 pkt_len -= sizeof (struct GNUNET_EXIT_TcpInternetStartMessage);
1977 if ( (NULL != state->specifics.tcp_udp.serv) || 1977 if ( (NULL != state->specifics.tcp_udp.serv) ||
1978 (NULL != state->specifics.tcp_udp.heap_node) ) 1978 (NULL != state->specifics.tcp_udp.heap_node) )
1979 { 1979 {
@@ -2030,10 +2030,10 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2030 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2030 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2031 "Received data from %s for starting TCP stream to %s:%u\n", 2031 "Received data from %s for starting TCP stream to %s:%u\n",
2032 GNUNET_i2s (&state->peer), 2032 GNUNET_i2s (&state->peer),
2033 inet_ntop (af, 2033 inet_ntop (af,
2034 &state->specifics.tcp_udp.ri.remote_address.address, 2034 &state->specifics.tcp_udp.ri.remote_address.address,
2035 buf, sizeof (buf)), 2035 buf, sizeof (buf)),
2036 (unsigned int) ntohs (start->tcp_header.destination_port)); 2036 (unsigned int) ntohs (start->tcp_header.destination_port));
2037 } 2037 }
2038 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_TCP; 2038 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_TCP;
2039 state->specifics.tcp_udp.ri.remote_address.port = ntohs (start->tcp_header.destination_port); 2039 state->specifics.tcp_udp.ri.remote_address.port = ntohs (start->tcp_header.destination_port);
@@ -2047,14 +2047,14 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2047 2047
2048 2048
2049/** 2049/**
2050 * Process a request to forward TCP data on an established 2050 * Process a request to forward TCP data on an established
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 tunnel connection to the other end
2055 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2055 * @param tunnel_ctx pointer to our 'struct TunnelState *'
2056 * @param message the actual message 2056 * @param message the actual message
2057 * 2057 *
2058 * @return GNUNET_OK to keep the connection open, 2058 * @return GNUNET_OK to keep the connection open,
2059 * GNUNET_SYSERR to close it (signal serious error) 2059 * GNUNET_SYSERR to close it (signal serious error)
2060 */ 2060 */
@@ -2089,7 +2089,7 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2089 return GNUNET_SYSERR; 2089 return GNUNET_SYSERR;
2090 } 2090 }
2091 data = (const struct GNUNET_EXIT_TcpDataMessage*) message; 2091 data = (const struct GNUNET_EXIT_TcpDataMessage*) message;
2092 pkt_len -= sizeof (struct GNUNET_EXIT_TcpDataMessage); 2092 pkt_len -= sizeof (struct GNUNET_EXIT_TcpDataMessage);
2093 if ( (NULL == state) || 2093 if ( (NULL == state) ||
2094 (NULL == state->specifics.tcp_udp.heap_node) ) 2094 (NULL == state->specifics.tcp_udp.heap_node) )
2095 { 2095 {
@@ -2112,7 +2112,7 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2112 "Received additional %u bytes of data from %s for TCP stream to %s:%u\n", 2112 "Received additional %u bytes of data from %s for TCP stream to %s:%u\n",
2113 pkt_len, 2113 pkt_len,
2114 GNUNET_i2s (&state->peer), 2114 GNUNET_i2s (&state->peer),
2115 inet_ntop (state->specifics.tcp_udp.ri.remote_address.af, 2115 inet_ntop (state->specifics.tcp_udp.ri.remote_address.af,
2116 &state->specifics.tcp_udp.ri.remote_address.address, 2116 &state->specifics.tcp_udp.ri.remote_address.address,
2117 buf, sizeof (buf)), 2117 buf, sizeof (buf)),
2118 (unsigned int) state->specifics.tcp_udp.ri.remote_address.port); 2118 (unsigned int) state->specifics.tcp_udp.ri.remote_address.port);
@@ -2174,7 +2174,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
2174 char buf[len] GNUNET_ALIGN; 2174 char buf[len] GNUNET_ALIGN;
2175 struct GNUNET_MessageHeader *hdr; 2175 struct GNUNET_MessageHeader *hdr;
2176 struct GNUNET_TUN_Layer2PacketHeader *tun; 2176 struct GNUNET_TUN_Layer2PacketHeader *tun;
2177 2177
2178 hdr= (struct GNUNET_MessageHeader *) buf; 2178 hdr= (struct GNUNET_MessageHeader *) buf;
2179 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); 2179 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER);
2180 hdr->size = htons (len); 2180 hdr->size = htons (len);
@@ -2287,7 +2287,7 @@ make_up_icmpv6_payload (struct TunnelState *state,
2287 * @param tunnel connection to the other end 2287 * @param tunnel connection to the other end
2288 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2288 * @param tunnel_ctx pointer to our 'struct TunnelState *'
2289 * @param message the actual message 2289 * @param message the actual message
2290 * 2290 *
2291 * @return GNUNET_OK to keep the connection open, 2291 * @return GNUNET_OK to keep the connection open,
2292 * GNUNET_SYSERR to close it (signal serious error) 2292 * GNUNET_SYSERR to close it (signal serious error)
2293 */ 2293 */
@@ -2300,7 +2300,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2300 const struct GNUNET_EXIT_IcmpInternetMessage *msg; 2300 const struct GNUNET_EXIT_IcmpInternetMessage *msg;
2301 uint16_t pkt_len = ntohs (message->size); 2301 uint16_t pkt_len = ntohs (message->size);
2302 const struct in_addr *v4; 2302 const struct in_addr *v4;
2303 const struct in6_addr *v6; 2303 const struct in6_addr *v6;
2304 const void *payload; 2304 const void *payload;
2305 char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8] GNUNET_ALIGN; 2305 char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8] GNUNET_ALIGN;
2306 int af; 2306 int af;
@@ -2327,7 +2327,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2327 return GNUNET_SYSERR; 2327 return GNUNET_SYSERR;
2328 } 2328 }
2329 msg = (const struct GNUNET_EXIT_IcmpInternetMessage*) message; 2329 msg = (const struct GNUNET_EXIT_IcmpInternetMessage*) message;
2330 pkt_len -= sizeof (struct GNUNET_EXIT_IcmpInternetMessage); 2330 pkt_len -= sizeof (struct GNUNET_EXIT_IcmpInternetMessage);
2331 2331
2332 af = (int) ntohl (msg->af); 2332 af = (int) ntohl (msg->af);
2333 if ( (NULL != state->specifics.tcp_udp.heap_node) && 2333 if ( (NULL != state->specifics.tcp_udp.heap_node) &&
@@ -2361,7 +2361,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2361 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_ICMP; 2361 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_ICMP;
2362 setup_state_record (state); 2362 setup_state_record (state);
2363 } 2363 }
2364 /* check that ICMP type is something we want to support 2364 /* check that ICMP type is something we want to support
2365 and possibly make up payload! */ 2365 and possibly make up payload! */
2366 switch (msg->icmp_header.type) 2366 switch (msg->icmp_header.type)
2367 { 2367 {
@@ -2383,7 +2383,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2383 2383
2384 GNUNET_assert (8 == sizeof (struct GNUNET_TUN_UdpHeader)); 2384 GNUNET_assert (8 == sizeof (struct GNUNET_TUN_UdpHeader));
2385 pkt_len = sizeof (struct GNUNET_TUN_IPv4Header) + 8; 2385 pkt_len = sizeof (struct GNUNET_TUN_IPv4Header) + 8;
2386 make_up_icmpv4_payload (state, 2386 make_up_icmpv4_payload (state,
2387 ipp, 2387 ipp,
2388 udp); 2388 udp);
2389 payload = ipp; 2389 payload = ipp;
@@ -2394,7 +2394,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2394 GNUNET_STATISTICS_update (stats, 2394 GNUNET_STATISTICS_update (stats,
2395 gettext_noop ("# ICMPv4 packets dropped (type not allowed)"), 2395 gettext_noop ("# ICMPv4 packets dropped (type not allowed)"),
2396 1, GNUNET_NO); 2396 1, GNUNET_NO);
2397 return GNUNET_SYSERR; 2397 return GNUNET_SYSERR;
2398 } 2398 }
2399 /* end AF_INET */ 2399 /* end AF_INET */
2400 break; 2400 break;
@@ -2419,7 +2419,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2419 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_ICMPV6; 2419 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_ICMPV6;
2420 setup_state_record (state); 2420 setup_state_record (state);
2421 } 2421 }
2422 /* check that ICMP type is something we want to support 2422 /* check that ICMP type is something we want to support
2423 and possibly make up payload! */ 2423 and possibly make up payload! */
2424 switch (msg->icmp_header.type) 2424 switch (msg->icmp_header.type)
2425 { 2425 {
@@ -2442,7 +2442,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2442 2442
2443 GNUNET_assert (8 == sizeof (struct GNUNET_TUN_UdpHeader)); 2443 GNUNET_assert (8 == sizeof (struct GNUNET_TUN_UdpHeader));
2444 pkt_len = sizeof (struct GNUNET_TUN_IPv6Header) + 8; 2444 pkt_len = sizeof (struct GNUNET_TUN_IPv6Header) + 8;
2445 make_up_icmpv6_payload (state, 2445 make_up_icmpv6_payload (state,
2446 ipp, 2446 ipp,
2447 udp); 2447 udp);
2448 payload = ipp; 2448 payload = ipp;
@@ -2453,22 +2453,22 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2453 GNUNET_STATISTICS_update (stats, 2453 GNUNET_STATISTICS_update (stats,
2454 gettext_noop ("# ICMPv6 packets dropped (type not allowed)"), 2454 gettext_noop ("# ICMPv6 packets dropped (type not allowed)"),
2455 1, GNUNET_NO); 2455 1, GNUNET_NO);
2456 return GNUNET_SYSERR; 2456 return GNUNET_SYSERR;
2457 } 2457 }
2458 /* end AF_INET6 */ 2458 /* end AF_INET6 */
2459 break; 2459 break;
2460 default: 2460 default:
2461 /* bad AF */ 2461 /* bad AF */
2462 GNUNET_break_op (0); 2462 GNUNET_break_op (0);
2463 return GNUNET_SYSERR; 2463 return GNUNET_SYSERR;
2464 } 2464 }
2465 2465
2466 { 2466 {
2467 char buf[INET6_ADDRSTRLEN]; 2467 char buf[INET6_ADDRSTRLEN];
2468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2469 "Received ICMP data from %s for forwarding to %s\n", 2469 "Received ICMP data from %s for forwarding to %s\n",
2470 GNUNET_i2s (&state->peer), 2470 GNUNET_i2s (&state->peer),
2471 inet_ntop (af, 2471 inet_ntop (af,
2472 &state->specifics.tcp_udp.ri.remote_address.address, 2472 &state->specifics.tcp_udp.ri.remote_address.address,
2473 buf, sizeof (buf))); 2473 buf, sizeof (buf)));
2474 } 2474 }
@@ -2499,7 +2499,7 @@ make_up_icmp_service_payload (struct TunnelState *state,
2499 { 2499 {
2500 struct GNUNET_TUN_IPv4Header *ipv4; 2500 struct GNUNET_TUN_IPv4Header *ipv4;
2501 struct GNUNET_TUN_UdpHeader *udp; 2501 struct GNUNET_TUN_UdpHeader *udp;
2502 2502
2503 ipv4 = (struct GNUNET_TUN_IPv4Header *)buf; 2503 ipv4 = (struct GNUNET_TUN_IPv4Header *)buf;
2504 udp = (struct GNUNET_TUN_UdpHeader *) &ipv4[1]; 2504 udp = (struct GNUNET_TUN_UdpHeader *) &ipv4[1];
2505 make_up_icmpv4_payload (state, 2505 make_up_icmpv4_payload (state,
@@ -2520,7 +2520,7 @@ make_up_icmp_service_payload (struct TunnelState *state,
2520 ipv6, 2520 ipv6,
2521 udp); 2521 udp);
2522 GNUNET_assert (8 == sizeof (struct GNUNET_TUN_UdpHeader)); 2522 GNUNET_assert (8 == sizeof (struct GNUNET_TUN_UdpHeader));
2523 return sizeof (struct GNUNET_TUN_IPv6Header) + 8; 2523 return sizeof (struct GNUNET_TUN_IPv6Header) + 8;
2524 } 2524 }
2525 break; 2525 break;
2526 default: 2526 default:
@@ -2538,7 +2538,7 @@ make_up_icmp_service_payload (struct TunnelState *state,
2538 * @param tunnel connection to the other end 2538 * @param tunnel connection to the other end
2539 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2539 * @param tunnel_ctx pointer to our 'struct TunnelState *'
2540 * @param message the actual message 2540 * @param message the actual message
2541 * 2541 *
2542 * @return GNUNET_OK to keep the connection open, 2542 * @return GNUNET_OK to keep the connection open,
2543 * GNUNET_SYSERR to close it (signal serious error) 2543 * GNUNET_SYSERR to close it (signal serious error)
2544 */ 2544 */
@@ -2590,7 +2590,7 @@ receive_icmp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel
2590 } 2590 }
2591 icmp = msg->icmp_header; 2591 icmp = msg->icmp_header;
2592 payload = &msg[1]; 2592 payload = &msg[1];
2593 state->specifics.tcp_udp.ri.remote_address = state->specifics.tcp_udp.serv->address; 2593 state->specifics.tcp_udp.ri.remote_address = state->specifics.tcp_udp.serv->address;
2594 setup_state_record (state); 2594 setup_state_record (state);
2595 2595
2596 /* check that ICMP type is something we want to support, 2596 /* check that ICMP type is something we want to support,
@@ -2772,7 +2772,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
2772 char buf[len] GNUNET_ALIGN; 2772 char buf[len] GNUNET_ALIGN;
2773 struct GNUNET_MessageHeader *hdr; 2773 struct GNUNET_MessageHeader *hdr;
2774 struct GNUNET_TUN_Layer2PacketHeader *tun; 2774 struct GNUNET_TUN_Layer2PacketHeader *tun;
2775 2775
2776 hdr= (struct GNUNET_MessageHeader *) buf; 2776 hdr= (struct GNUNET_MessageHeader *) buf;
2777 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); 2777 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER);
2778 hdr->size = htons (len); 2778 hdr->size = htons (len);
@@ -2798,7 +2798,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
2798 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1]; 2798 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
2799 2799
2800 tun->proto = htons (ETH_P_IPV6); 2800 tun->proto = htons (ETH_P_IPV6);
2801 prepare_ipv6_packet (payload, payload_length, 2801 prepare_ipv6_packet (payload, payload_length,
2802 IPPROTO_UDP, 2802 IPPROTO_UDP,
2803 NULL, 2803 NULL,
2804 source_address, 2804 source_address,
@@ -2826,7 +2826,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
2826 * @param tunnel connection to the other end 2826 * @param tunnel connection to the other end
2827 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2827 * @param tunnel_ctx pointer to our 'struct TunnelState *'
2828 * @param message the actual message 2828 * @param message the actual message
2829 * 2829 *
2830 * @return GNUNET_OK to keep the connection open, 2830 * @return GNUNET_OK to keep the connection open,
2831 * GNUNET_SYSERR to close it (signal serious error) 2831 * GNUNET_SYSERR to close it (signal serious error)
2832 */ 2832 */
@@ -2865,7 +2865,7 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2865 return GNUNET_SYSERR; 2865 return GNUNET_SYSERR;
2866 } 2866 }
2867 msg = (const struct GNUNET_EXIT_UdpInternetMessage*) message; 2867 msg = (const struct GNUNET_EXIT_UdpInternetMessage*) message;
2868 pkt_len -= sizeof (struct GNUNET_EXIT_UdpInternetMessage); 2868 pkt_len -= sizeof (struct GNUNET_EXIT_UdpInternetMessage);
2869 af = (int) ntohl (msg->af); 2869 af = (int) ntohl (msg->af);
2870 state->specifics.tcp_udp.ri.remote_address.af = af; 2870 state->specifics.tcp_udp.ri.remote_address.af = af;
2871 switch (af) 2871 switch (af)
@@ -2911,10 +2911,10 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2911 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2911 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2912 "Received data from %s for forwarding to UDP %s:%u\n", 2912 "Received data from %s for forwarding to UDP %s:%u\n",
2913 GNUNET_i2s (&state->peer), 2913 GNUNET_i2s (&state->peer),
2914 inet_ntop (af, 2914 inet_ntop (af,
2915 &state->specifics.tcp_udp.ri.remote_address.address, 2915 &state->specifics.tcp_udp.ri.remote_address.address,
2916 buf, sizeof (buf)), 2916 buf, sizeof (buf)),
2917 (unsigned int) ntohs (msg->destination_port)); 2917 (unsigned int) ntohs (msg->destination_port));
2918 } 2918 }
2919 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_UDP; 2919 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_UDP;
2920 state->specifics.tcp_udp.ri.remote_address.port = msg->destination_port; 2920 state->specifics.tcp_udp.ri.remote_address.port = msg->destination_port;
@@ -2937,7 +2937,7 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2937 * @param tunnel connection to the other end 2937 * @param tunnel connection to the other end
2938 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2938 * @param tunnel_ctx pointer to our 'struct TunnelState *'
2939 * @param message the actual message 2939 * @param message the actual message
2940 * 2940 *
2941 * @return GNUNET_OK to keep the connection open, 2941 * @return GNUNET_OK to keep the connection open,
2942 * GNUNET_SYSERR to close it (signal serious error) 2942 * GNUNET_SYSERR to close it (signal serious error)
2943 */ 2943 */
@@ -2978,11 +2978,11 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2978 "Received data from %s for forwarding to UDP service %s on port %u\n", 2978 "Received data from %s for forwarding to UDP service %s on port %u\n",
2979 GNUNET_i2s (&state->peer), 2979 GNUNET_i2s (&state->peer),
2980 GNUNET_h2s (&msg->service_descriptor), 2980 GNUNET_h2s (&msg->service_descriptor),
2981 (unsigned int) ntohs (msg->destination_port)); 2981 (unsigned int) ntohs (msg->destination_port));
2982 if (NULL == (state->specifics.tcp_udp.serv = find_service (udp_services, &msg->service_descriptor, 2982 if (NULL == (state->specifics.tcp_udp.serv = find_service (udp_services, &msg->service_descriptor,
2983 ntohs (msg->destination_port)))) 2983 ntohs (msg->destination_port))))
2984 { 2984 {
2985 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2985 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2986 _("No service found for %s on port %d!\n"), 2986 _("No service found for %s on port %d!\n"),
2987 "UDP", 2987 "UDP",
2988 ntohs (msg->destination_port)); 2988 ntohs (msg->destination_port));
@@ -2991,7 +2991,7 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2991 1, GNUNET_NO); 2991 1, GNUNET_NO);
2992 return GNUNET_SYSERR; 2992 return GNUNET_SYSERR;
2993 } 2993 }
2994 state->specifics.tcp_udp.ri.remote_address = state->specifics.tcp_udp.serv->address; 2994 state->specifics.tcp_udp.ri.remote_address = state->specifics.tcp_udp.serv->address;
2995 setup_state_record (state); 2995 setup_state_record (state);
2996 if (0 != ntohs (msg->source_port)) 2996 if (0 != ntohs (msg->source_port))
2997 state->specifics.tcp_udp.ri.local_address.port = msg->source_port; 2997 state->specifics.tcp_udp.ri.local_address.port = msg->source_port;
@@ -3057,7 +3057,7 @@ clean_tunnel (void *cls GNUNET_UNUSED, const struct GNUNET_MESH_Tunnel *tunnel,
3057 { 3057 {
3058 if (tunnels[s->specifics.dns.my_id] == s) 3058 if (tunnels[s->specifics.dns.my_id] == s)
3059 tunnels[s->specifics.dns.my_id] = NULL; 3059 tunnels[s->specifics.dns.my_id] = NULL;
3060 GNUNET_free_non_null (s->specifics.dns.reply); 3060 GNUNET_free_non_null (s->specifics.dns.reply);
3061 } 3061 }
3062 else 3062 else
3063 { 3063 {
@@ -3233,10 +3233,10 @@ add_services (int proto,
3233 } 3233 }
3234 hostport[0] = '\0'; 3234 hostport[0] = '\0';
3235 hostport++; 3235 hostport++;
3236 3236
3237 int local_port = atoi (redirect); 3237 int local_port = atoi (redirect);
3238 int remote_port = atoi (hostport); 3238 int remote_port = atoi (hostport);
3239 3239
3240 if (!((local_port > 0) && (local_port < 65536))) 3240 if (!((local_port > 0) && (local_port < 65536)))
3241 { 3241 {
3242 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3242 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -3260,7 +3260,7 @@ add_services (int proto,
3260 { 3260 {
3261 const char *ip4addr = exit_argv[5]; 3261 const char *ip4addr = exit_argv[5];
3262 3262
3263 serv->address.af = AF_INET; 3263 serv->address.af = AF_INET;
3264 GNUNET_assert (1 == inet_pton (AF_INET, ip4addr, &serv->address.address.ipv4)); 3264 GNUNET_assert (1 == inet_pton (AF_INET, ip4addr, &serv->address.address.ipv4));
3265 } 3265 }
3266 else if (0 == strcmp ("localhost6", hostname)) 3266 else if (0 == strcmp ("localhost6", hostname))
@@ -3272,10 +3272,10 @@ add_services (int proto,
3272 } 3272 }
3273 else 3273 else
3274 { 3274 {
3275 struct addrinfo *res; 3275 struct addrinfo *res;
3276 int ret; 3276 int ret;
3277 3277
3278 ret = getaddrinfo (hostname, NULL, NULL, &res); 3278 ret = getaddrinfo (hostname, NULL, NULL, &res);
3279 if ( (ret != 0) || (res == NULL) ) 3279 if ( (ret != 0) || (res == NULL) )
3280 { 3280 {
3281 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3281 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -3285,7 +3285,7 @@ add_services (int proto,
3285 GNUNET_free (serv); 3285 GNUNET_free (serv);
3286 continue; 3286 continue;
3287 } 3287 }
3288 3288
3289 serv->address.af = res->ai_family; 3289 serv->address.af = res->ai_family;
3290 switch (res->ai_family) 3290 switch (res->ai_family)
3291 { 3291 {
@@ -3388,7 +3388,7 @@ dht_put_cont (void *cls,
3388{ 3388{
3389 dht_put = NULL; 3389 dht_put = NULL;
3390 dht_task = GNUNET_SCHEDULER_add_delayed (DHT_PUT_FREQUENCY, 3390 dht_task = GNUNET_SCHEDULER_add_delayed (DHT_PUT_FREQUENCY,
3391 &do_dht_put, 3391 &do_dht_put,
3392 NULL); 3392 NULL);
3393} 3393}
3394 3394
@@ -3408,7 +3408,7 @@ do_dht_put (void *cls,
3408 3408
3409 dht_task = GNUNET_SCHEDULER_NO_TASK; 3409 dht_task = GNUNET_SCHEDULER_NO_TASK;
3410 expiration = GNUNET_TIME_absolute_ntoh (dns_advertisement.expiration_time); 3410 expiration = GNUNET_TIME_absolute_ntoh (dns_advertisement.expiration_time);
3411 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us < 3411 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us <
3412 GNUNET_TIME_UNIT_HOURS.rel_value_us) 3412 GNUNET_TIME_UNIT_HOURS.rel_value_us)
3413 { 3413 {
3414 /* refresh advertisement */ 3414 /* refresh advertisement */
@@ -3424,7 +3424,7 @@ do_dht_put (void *cls,
3424 1 /* replication */, 3424 1 /* replication */,
3425 GNUNET_DHT_RO_NONE, 3425 GNUNET_DHT_RO_NONE,
3426 GNUNET_BLOCK_TYPE_DNS, 3426 GNUNET_BLOCK_TYPE_DNS,
3427 sizeof (struct GNUNET_DNS_Advertisement), 3427 sizeof (struct GNUNET_DNS_Advertisement),
3428 &dns_advertisement, 3428 &dns_advertisement,
3429 expiration, 3429 expiration,
3430 GNUNET_TIME_UNIT_FOREVER_REL, 3430 GNUNET_TIME_UNIT_FOREVER_REL,
@@ -3480,9 +3480,9 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3480 3480
3481 cfg = cfg_; 3481 cfg = cfg_;
3482 ipv4_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV4"); 3482 ipv4_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV4");
3483 ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV6"); 3483 ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV6");
3484 ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV4"); 3484 ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV4");
3485 ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV6"); 3485 ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV6");
3486 if ( (ipv4_exit) || (ipv6_exit) ) 3486 if ( (ipv4_exit) || (ipv6_exit) )
3487 { 3487 {
3488 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit"); 3488 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
@@ -3540,13 +3540,13 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3540 if ( (GNUNET_YES == 3540 if ( (GNUNET_YES ==
3541 GNUNET_CONFIGURATION_get_value_yesno (cfg_, "exit", "ENABLE_DNS")) && 3541 GNUNET_CONFIGURATION_get_value_yesno (cfg_, "exit", "ENABLE_DNS")) &&
3542 ( (GNUNET_OK != 3542 ( (GNUNET_OK !=
3543 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", 3543 GNUNET_CONFIGURATION_get_value_string (cfg, "exit",
3544 "DNS_RESOLVER", 3544 "DNS_RESOLVER",
3545 &dns_exit)) || 3545 &dns_exit)) ||
3546 ( (1 != inet_pton (AF_INET, dns_exit, &dns_exit4)) && 3546 ( (1 != inet_pton (AF_INET, dns_exit, &dns_exit4)) &&
3547 (1 != inet_pton (AF_INET6, dns_exit, &dns_exit6)) ) ) ) 3547 (1 != inet_pton (AF_INET6, dns_exit, &dns_exit6)) ) ) )
3548 { 3548 {
3549 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, 3549 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
3550 "dns", "DNS_RESOLVER", 3550 "dns", "DNS_RESOLVER",
3551 _("need a valid IPv4 or IPv6 address\n")); 3551 _("need a valid IPv4 or IPv6 address\n"));
3552 GNUNET_free_non_null (dns_exit); 3552 GNUNET_free_non_null (dns_exit);
@@ -3575,13 +3575,13 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3575 peer_key = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg); 3575 peer_key = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg);
3576 GNUNET_CRYPTO_ecc_key_get_public_for_signature (peer_key, 3576 GNUNET_CRYPTO_ecc_key_get_public_for_signature (peer_key,
3577 &dns_advertisement.peer.public_key); 3577 &dns_advertisement.peer.public_key);
3578 dns_advertisement.purpose.size = htonl (sizeof (struct GNUNET_DNS_Advertisement) - 3578 dns_advertisement.purpose.size = htonl (sizeof (struct GNUNET_DNS_Advertisement) -
3579 sizeof (struct GNUNET_CRYPTO_EccSignature)); 3579 sizeof (struct GNUNET_CRYPTO_EccSignature));
3580 dns_advertisement.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD); 3580 dns_advertisement.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD);
3581 GNUNET_CRYPTO_hash ("dns", 3581 GNUNET_CRYPTO_hash ("dns",
3582 strlen ("dns"), 3582 strlen ("dns"),
3583 &dht_put_key); 3583 &dht_put_key);
3584 dht_task = GNUNET_SCHEDULER_add_now (&do_dht_put, 3584 dht_task = GNUNET_SCHEDULER_add_now (&do_dht_put,
3585 NULL); 3585 NULL);
3586 apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER; 3586 apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER;
3587 app_idx++; 3587 app_idx++;
@@ -3617,7 +3617,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3617 { 3617 {
3618 exit_argv[2] = GNUNET_strdup ("-"); 3618 exit_argv[2] = GNUNET_strdup ("-");
3619 } 3619 }
3620 3620
3621 3621
3622 if (GNUNET_YES == ipv6_enabled) 3622 if (GNUNET_YES == ipv6_enabled)
3623 { 3623 {
@@ -3651,7 +3651,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3651 GNUNET_SCHEDULER_shutdown (); 3651 GNUNET_SCHEDULER_shutdown ();
3652 return; 3652 return;
3653 } 3653 }
3654 } 3654 }
3655 else 3655 else
3656 { 3656 {
3657 /* IPv6 explicitly disabled */ 3657 /* IPv6 explicitly disabled */
@@ -3695,9 +3695,9 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3695 3695
3696 connections_map = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO); 3696 connections_map = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
3697 connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 3697 connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
3698 mesh_handle 3698 mesh_handle
3699 = GNUNET_MESH_connect (cfg, NULL, 3699 = GNUNET_MESH_connect (cfg, NULL,
3700 &new_tunnel, 3700 &new_tunnel,
3701 &clean_tunnel, handlers, 3701 &clean_tunnel, handlers,
3702 apptypes); // FIXME use ports 3702 apptypes); // FIXME use ports
3703 if (NULL == mesh_handle) 3703 if (NULL == mesh_handle)
@@ -3724,12 +3724,12 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3724 (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s", 3724 (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s",
3725 GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, 3725 GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
3726 "4", regex); 3726 "4", regex);
3727 regex4 = GNUNET_REGEX_announce (cfg, 3727 regex4 = GNUNET_REGEX_announce (cfg,
3728 prefixed_regex, 3728 prefixed_regex,
3729 REGEX_REFRESH_FREQUENCY, 3729 REGEX_REFRESH_FREQUENCY,
3730 REGEX_MAX_PATH_LEN_IPV4); 3730 REGEX_MAX_PATH_LEN_IPV4);
3731 GNUNET_free (regex); 3731 GNUNET_free (regex);
3732 GNUNET_free (prefixed_regex); 3732 GNUNET_free (prefixed_regex);
3733 } 3733 }
3734 } 3734 }
3735 3735
@@ -3744,7 +3744,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3744 regex = NULL; 3744 regex = NULL;
3745 else 3745 else
3746 regex = GNUNET_TUN_ipv6policy2regex (policy); 3746 regex = GNUNET_TUN_ipv6policy2regex (policy);
3747 GNUNET_free_non_null (policy); 3747 GNUNET_free_non_null (policy);
3748 if (NULL != regex) 3748 if (NULL != regex)
3749 { 3749 {
3750 (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s", 3750 (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s",
@@ -3760,7 +3760,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3760 } 3760 }
3761 if ((ipv4_exit) || (ipv6_exit)) 3761 if ((ipv4_exit) || (ipv6_exit))
3762 helper_handle = GNUNET_HELPER_start (GNUNET_NO, 3762 helper_handle = GNUNET_HELPER_start (GNUNET_NO,
3763 "gnunet-helper-exit", 3763 "gnunet-helper-exit",
3764 exit_argv, 3764 exit_argv,
3765 &message_token, 3765 &message_token,
3766 NULL, NULL); 3766 NULL, NULL);