diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-06 20:55:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-06 20:55:28 +0000 |
commit | 61c39c60565b386e0e12ea669556b030e8cd7180 (patch) | |
tree | 59109aeab8297bdc996faca8c4e38ec7426c36cf /src/exit | |
parent | 780eb09dd8040ecf8649d40ddf8314464e0fc48e (diff) | |
download | gnunet-61c39c60565b386e0e12ea669556b030e8cd7180.tar.gz gnunet-61c39c60565b386e0e12ea669556b030e8cd7180.zip |
-remove trailing whitespace
Diffstat (limited to 'src/exit')
-rw-r--r-- | src/exit/exit.h | 8 | ||||
-rw-r--r-- | src/exit/gnunet-daemon-exit.c | 292 | ||||
-rw-r--r-- | src/exit/gnunet-helper-exit-windows.c | 250 | ||||
-rw-r--r-- | src/exit/gnunet-helper-exit.c | 50 |
4 files changed, 300 insertions, 300 deletions
diff --git a/src/exit/exit.h b/src/exit/exit.h index ff5e3f54c..b4cea4c23 100644 --- a/src/exit/exit.h +++ b/src/exit/exit.h | |||
@@ -91,7 +91,7 @@ struct GNUNET_EXIT_TcpInternetStartMessage | |||
91 | 91 | ||
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Message send via mesh between VPN and entry and an exit daemon to | 94 | * Message send via mesh between VPN and entry and an exit daemon to |
95 | * transmit TCP data between the VPN entry and an exit session. This | 95 | * transmit TCP data between the VPN entry and an exit session. This |
96 | * format is used for both Internet-exits and service-exits and | 96 | * format is used for both Internet-exits and service-exits and |
97 | * in both directions (VPN to exit and exit to VPN). | 97 | * in both directions (VPN to exit and exit to VPN). |
@@ -136,7 +136,7 @@ struct GNUNET_EXIT_UdpServiceMessage | |||
136 | 136 | ||
137 | /** | 137 | /** |
138 | * Destination port to use for the UDP request. In NBO. | 138 | * Destination port to use for the UDP request. In NBO. |
139 | */ | 139 | */ |
140 | uint16_t destination_port GNUNET_PACKED; | 140 | uint16_t destination_port GNUNET_PACKED; |
141 | 141 | ||
142 | /** | 142 | /** |
@@ -171,7 +171,7 @@ struct GNUNET_EXIT_UdpInternetMessage | |||
171 | 171 | ||
172 | /** | 172 | /** |
173 | * Destination port to use for the UDP request. In NBO. | 173 | * Destination port to use for the UDP request. In NBO. |
174 | */ | 174 | */ |
175 | uint16_t destination_port GNUNET_PACKED; | 175 | uint16_t destination_port GNUNET_PACKED; |
176 | 176 | ||
177 | /* followed by IP address of the destination; either | 177 | /* followed by IP address of the destination; either |
@@ -201,7 +201,7 @@ struct GNUNET_EXIT_UdpReplyMessage | |||
201 | /** | 201 | /** |
202 | * Destination port to use for the UDP reply (0 to use the same | 202 | * Destination port to use for the UDP reply (0 to use the same |
203 | * port as for the original request). In NBO. | 203 | * port as for the original request). In NBO. |
204 | */ | 204 | */ |
205 | uint16_t destination_port GNUNET_PACKED; | 205 | uint16_t destination_port GNUNET_PACKED; |
206 | 206 | ||
207 | /* followed by UDP payload */ | 207 | /* followed by UDP payload */ |
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 | */ |
158 | struct RedirectInformation | 158 | struct 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 | */ |
415 | static struct GNUNET_DHT_PutHandle *dht_put; | 415 | static 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 | */ |
621 | static void | 621 | static void |
622 | hash_redirect_info (struct GNUNET_HashCode *hash, | 622 | hash_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 | */ |
679 | static struct TunnelState * | 679 | static struct TunnelState * |
680 | get_redirect_state (int af, | 680 | get_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 | */ |
895 | static void | 895 | static void |
896 | icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp, | 896 | icmp_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 | */ |
1083 | static void | 1083 | static void |
1084 | udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp, | 1084 | udp_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 | */ |
1160 | static void | 1160 | static void |
1161 | tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp, | 1161 | tcp_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); |
diff --git a/src/exit/gnunet-helper-exit-windows.c b/src/exit/gnunet-helper-exit-windows.c index 461494480..bb6b6a8e4 100644 --- a/src/exit/gnunet-helper-exit-windows.c +++ b/src/exit/gnunet-helper-exit-windows.c | |||
@@ -19,8 +19,8 @@ | |||
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file exit/gnunet-helper-exit-windows.c | 21 | * @file exit/gnunet-helper-exit-windows.c |
22 | * @brief the helper for the EXIT service in win32 builds. | 22 | * @brief the helper for the EXIT service in win32 builds. |
23 | * Opens a virtual network-interface, sends data received on the if to stdout, | 23 | * Opens a virtual network-interface, sends data received on the if to stdout, |
24 | * sends data received on stdin to the interface | 24 | * sends data received on stdin to the interface |
25 | * @author Christian M. Fuchs | 25 | * @author Christian M. Fuchs |
26 | * | 26 | * |
@@ -68,7 +68,7 @@ | |||
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Will this binary be run in permissions testing mode? | 71 | * Will this binary be run in permissions testing mode? |
72 | */ | 72 | */ |
73 | static boolean privilege_testing = FALSE; | 73 | static boolean privilege_testing = FALSE; |
74 | 74 | ||
@@ -90,7 +90,7 @@ static boolean privilege_testing = FALSE; | |||
90 | #define INF_FILE64 "share/gnunet/openvpn-tap32/tapw64/OemWin2k.inf" | 90 | #define INF_FILE64 "share/gnunet/openvpn-tap32/tapw64/OemWin2k.inf" |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Hardware ID used in the inf-file. | 93 | * Hardware ID used in the inf-file. |
94 | * This might change over time, as openvpn advances their driver | 94 | * This might change over time, as openvpn advances their driver |
95 | */ | 95 | */ |
96 | #define HARDWARE_ID "tap0901" | 96 | #define HARDWARE_ID "tap0901" |
@@ -101,7 +101,7 @@ static boolean privilege_testing = FALSE; | |||
101 | #define TAP_WIN_MIN_MAJOR 9 | 101 | #define TAP_WIN_MIN_MAJOR 9 |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * Minimum minor-id of the driver version we can work with. | 104 | * Minimum minor-id of the driver version we can work with. |
105 | * v <= 7 has buggy IPv6. | 105 | * v <= 7 has buggy IPv6. |
106 | * v == 8 is broken for small IPv4 Packets | 106 | * v == 8 is broken for small IPv4 Packets |
107 | */ | 107 | */ |
@@ -109,7 +109,7 @@ static boolean privilege_testing = FALSE; | |||
109 | 109 | ||
110 | /** | 110 | /** |
111 | * Time in seconds to wait for our virtual device to go up after telling it to do so. | 111 | * Time in seconds to wait for our virtual device to go up after telling it to do so. |
112 | * | 112 | * |
113 | * openvpn doesn't specify a value, 4 seems sane for testing, even for openwrt | 113 | * openvpn doesn't specify a value, 4 seems sane for testing, even for openwrt |
114 | * (in fact, 4 was chosen by a fair dice roll...) | 114 | * (in fact, 4 was chosen by a fair dice roll...) |
115 | */ | 115 | */ |
@@ -121,7 +121,7 @@ static boolean privilege_testing = FALSE; | |||
121 | #define INTERFACE_REGISTRY_LOCATION "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" | 121 | #define INTERFACE_REGISTRY_LOCATION "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * Our local process' PID. Used for creating a sufficiently unique additional | 124 | * Our local process' PID. Used for creating a sufficiently unique additional |
125 | * hardware ID for our device. | 125 | * hardware ID for our device. |
126 | */ | 126 | */ |
127 | static char secondary_hwid[LINE_LEN / 2]; | 127 | static char secondary_hwid[LINE_LEN / 2]; |
@@ -132,13 +132,13 @@ static char secondary_hwid[LINE_LEN / 2]; | |||
132 | */ | 132 | */ |
133 | static char device_visible_name[256]; | 133 | static char device_visible_name[256]; |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * This is our own local instance of a virtual network interface | 136 | * This is our own local instance of a virtual network interface |
137 | * It is (somewhat) equivalent to using tun/tap in unixoid systems | 137 | * It is (somewhat) equivalent to using tun/tap in unixoid systems |
138 | * | 138 | * |
139 | * Upon initialization, we create such an device node. | 139 | * Upon initialization, we create such an device node. |
140 | * Upon termination, we remove it again. | 140 | * Upon termination, we remove it again. |
141 | * | 141 | * |
142 | * If we crash this device might stay around. | 142 | * If we crash this device might stay around. |
143 | */ | 143 | */ |
144 | static HDEVINFO DeviceInfo = INVALID_HANDLE_VALUE; | 144 | static HDEVINFO DeviceInfo = INVALID_HANDLE_VALUE; |
@@ -149,7 +149,7 @@ static HDEVINFO DeviceInfo = INVALID_HANDLE_VALUE; | |||
149 | static SP_DEVINFO_DATA DeviceNode; | 149 | static SP_DEVINFO_DATA DeviceNode; |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * GUID of our virtual device in the form of | 152 | * GUID of our virtual device in the form of |
153 | * {12345678-1234-1234-1234-123456789abc} - in hex | 153 | * {12345678-1234-1234-1234-123456789abc} - in hex |
154 | */ | 154 | */ |
155 | static char device_guid[256]; | 155 | static char device_guid[256]; |
@@ -161,36 +161,36 @@ static char device_guid[256]; | |||
161 | enum IO_State | 161 | enum IO_State |
162 | { | 162 | { |
163 | 163 | ||
164 | /** | 164 | /** |
165 | * overlapped I/O is ready for work | 165 | * overlapped I/O is ready for work |
166 | */ | 166 | */ |
167 | IOSTATE_READY = 0, | 167 | IOSTATE_READY = 0, |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * overlapped I/O has been queued | 170 | * overlapped I/O has been queued |
171 | */ | 171 | */ |
172 | IOSTATE_QUEUED, | 172 | IOSTATE_QUEUED, |
173 | 173 | ||
174 | /** | 174 | /** |
175 | * overlapped I/O has finished, but is waiting for it's write-partner | 175 | * overlapped I/O has finished, but is waiting for it's write-partner |
176 | */ | 176 | */ |
177 | IOSTATE_WAITING, | 177 | IOSTATE_WAITING, |
178 | 178 | ||
179 | /** | 179 | /** |
180 | * there is a full buffer waiting | 180 | * there is a full buffer waiting |
181 | */ | 181 | */ |
182 | IOSTATE_RESUME, | 182 | IOSTATE_RESUME, |
183 | 183 | ||
184 | /** | 184 | /** |
185 | * Operlapped IO states for facility objects | 185 | * Operlapped IO states for facility objects |
186 | * overlapped I/O has failed, stop processing | 186 | * overlapped I/O has failed, stop processing |
187 | */ | 187 | */ |
188 | IOSTATE_FAILED | 188 | IOSTATE_FAILED |
189 | 189 | ||
190 | }; | 190 | }; |
191 | 191 | ||
192 | 192 | ||
193 | /** | 193 | /** |
194 | * A IO Object + read/writebuffer + buffer-size for windows asynchronous IO handling | 194 | * A IO Object + read/writebuffer + buffer-size for windows asynchronous IO handling |
195 | */ | 195 | */ |
196 | struct io_facility | 196 | struct io_facility |
@@ -229,7 +229,7 @@ struct io_facility | |||
229 | * Amount of data actually written or read by readfile/writefile. | 229 | * Amount of data actually written or read by readfile/writefile. |
230 | */ | 230 | */ |
231 | DWORD buffer_size_processed; | 231 | DWORD buffer_size_processed; |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * How much of this buffer we have written in total | 234 | * How much of this buffer we have written in total |
235 | */ | 235 | */ |
@@ -248,32 +248,32 @@ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); | |||
248 | 248 | ||
249 | /** | 249 | /** |
250 | * Determines if the host OS is win32 or win64 | 250 | * Determines if the host OS is win32 or win64 |
251 | * | 251 | * |
252 | * @return true if | 252 | * @return true if |
253 | */ | 253 | */ |
254 | BOOL | 254 | BOOL |
255 | is_win64 () | 255 | is_win64 () |
256 | { | 256 | { |
257 | #if defined(_WIN64) | 257 | #if defined(_WIN64) |
258 | //this is a win64 binary, | 258 | //this is a win64 binary, |
259 | return TRUE; | 259 | return TRUE; |
260 | #elif defined(_WIN32) | 260 | #elif defined(_WIN32) |
261 | //this is a 32bit binary, and we need to check if we are running in WOW64 | 261 | //this is a 32bit binary, and we need to check if we are running in WOW64 |
262 | BOOL success = FALSE; | 262 | BOOL success = FALSE; |
263 | BOOL on_wow64 = FALSE; | 263 | BOOL on_wow64 = FALSE; |
264 | LPFN_ISWOW64PROCESS IsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle ("kernel32"), "IsWow64Process"); | 264 | LPFN_ISWOW64PROCESS IsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle ("kernel32"), "IsWow64Process"); |
265 | 265 | ||
266 | if (NULL != IsWow64Process) | 266 | if (NULL != IsWow64Process) |
267 | success = IsWow64Process (GetCurrentProcess (), &on_wow64); | 267 | success = IsWow64Process (GetCurrentProcess (), &on_wow64); |
268 | 268 | ||
269 | return success && on_wow64; | 269 | return success && on_wow64; |
270 | #endif | 270 | #endif |
271 | } | 271 | } |
272 | /** | 272 | /** |
273 | * Wrapper for executing a shellcommand in windows. | 273 | * Wrapper for executing a shellcommand in windows. |
274 | * | 274 | * |
275 | * @param command - the command + parameters to execute | 275 | * @param command - the command + parameters to execute |
276 | * @return * exitcode of the program executed, | 276 | * @return * exitcode of the program executed, |
277 | * * EINVAL (cmd/file not found) | 277 | * * EINVAL (cmd/file not found) |
278 | * * EPIPE (could not read STDOUT) | 278 | * * EPIPE (could not read STDOUT) |
279 | */ | 279 | */ |
@@ -393,7 +393,7 @@ set_address4 (const char *address, const char *mask) | |||
393 | strerror (errno)); | 393 | strerror (errno)); |
394 | return -1; | 394 | return -1; |
395 | } | 395 | } |
396 | // Set Device to Subnet-Mode? | 396 | // Set Device to Subnet-Mode? |
397 | // do we really need tun.c:2925 ? | 397 | // do we really need tun.c:2925 ? |
398 | 398 | ||
399 | /* | 399 | /* |
@@ -445,8 +445,8 @@ remove_address4 (const char *address) | |||
445 | 445 | ||
446 | 446 | ||
447 | /** | 447 | /** |
448 | * Setup a new virtual interface to use for tunneling. | 448 | * Setup a new virtual interface to use for tunneling. |
449 | * | 449 | * |
450 | * @return: TRUE if setup was successful, else FALSE | 450 | * @return: TRUE if setup was successful, else FALSE |
451 | */ | 451 | */ |
452 | static BOOL | 452 | static BOOL |
@@ -454,7 +454,7 @@ setup_interface () | |||
454 | { | 454 | { |
455 | /* | 455 | /* |
456 | * where to find our inf-file. (+ the "full" path, after windows found") | 456 | * where to find our inf-file. (+ the "full" path, after windows found") |
457 | * | 457 | * |
458 | * We do not directly input all the props here, because openvpn will update | 458 | * We do not directly input all the props here, because openvpn will update |
459 | * these details over time. | 459 | * these details over time. |
460 | */ | 460 | */ |
@@ -465,22 +465,22 @@ setup_interface () | |||
465 | GUID class_guid; | 465 | GUID class_guid; |
466 | int str_length = 0; | 466 | int str_length = 0; |
467 | 467 | ||
468 | /** | 468 | /** |
469 | * Set the device's hardware ID and add it to a list. | 469 | * Set the device's hardware ID and add it to a list. |
470 | * This information will later on identify this device in registry. | 470 | * This information will later on identify this device in registry. |
471 | */ | 471 | */ |
472 | strncpy (hwidlist, HARDWARE_ID, LINE_LEN); | 472 | strncpy (hwidlist, HARDWARE_ID, LINE_LEN); |
473 | /** | 473 | /** |
474 | * this is kind of over-complicated, but allows keeps things independent of | 474 | * this is kind of over-complicated, but allows keeps things independent of |
475 | * how the openvpn-hwid is actually stored. | 475 | * how the openvpn-hwid is actually stored. |
476 | * | 476 | * |
477 | * A HWID list is double-\0 terminated and \0 separated | 477 | * A HWID list is double-\0 terminated and \0 separated |
478 | */ | 478 | */ |
479 | str_length = strlen (hwidlist) + 1; | 479 | str_length = strlen (hwidlist) + 1; |
480 | strncpy (&hwidlist[str_length], secondary_hwid, LINE_LEN); | 480 | strncpy (&hwidlist[str_length], secondary_hwid, LINE_LEN); |
481 | str_length += strlen (&hwidlist[str_length]) + 1; | 481 | str_length += strlen (&hwidlist[str_length]) + 1; |
482 | 482 | ||
483 | /** | 483 | /** |
484 | * Locate the inf-file, we need to store it somewhere where the system can | 484 | * Locate the inf-file, we need to store it somewhere where the system can |
485 | * find it. We need to pick the correct driver for win32/win64. | 485 | * find it. We need to pick the correct driver for win32/win64. |
486 | */ | 486 | */ |
@@ -490,7 +490,7 @@ setup_interface () | |||
490 | GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename); | 490 | GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename); |
491 | 491 | ||
492 | fprintf (stderr, "INFO: Located our driver's .inf file at %s\n", inf_file_path); | 492 | fprintf (stderr, "INFO: Located our driver's .inf file at %s\n", inf_file_path); |
493 | /** | 493 | /** |
494 | * Bootstrap our device info using the drivers inf-file | 494 | * Bootstrap our device info using the drivers inf-file |
495 | */ | 495 | */ |
496 | if ( ! SetupDiGetINFClassA (inf_file_path, | 496 | if ( ! SetupDiGetINFClassA (inf_file_path, |
@@ -499,9 +499,9 @@ setup_interface () | |||
499 | NULL)) | 499 | NULL)) |
500 | return FALSE; | 500 | return FALSE; |
501 | 501 | ||
502 | /** | 502 | /** |
503 | * Collect all the other needed information... | 503 | * Collect all the other needed information... |
504 | * let the system fill our this form | 504 | * let the system fill our this form |
505 | */ | 505 | */ |
506 | DeviceInfo = SetupDiCreateDeviceInfoList (&class_guid, NULL); | 506 | DeviceInfo = SetupDiCreateDeviceInfoList (&class_guid, NULL); |
507 | if (DeviceInfo == INVALID_HANDLE_VALUE) | 507 | if (DeviceInfo == INVALID_HANDLE_VALUE) |
@@ -546,9 +546,9 @@ setup_interface () | |||
546 | 546 | ||
547 | 547 | ||
548 | /** | 548 | /** |
549 | * Remove our new virtual interface to use for tunneling. | 549 | * Remove our new virtual interface to use for tunneling. |
550 | * This function must be called AFTER setup_interface! | 550 | * This function must be called AFTER setup_interface! |
551 | * | 551 | * |
552 | * @return: TRUE if destruction was successful, else FALSE | 552 | * @return: TRUE if destruction was successful, else FALSE |
553 | */ | 553 | */ |
554 | static BOOL | 554 | static BOOL |
@@ -564,7 +564,7 @@ remove_interface () | |||
564 | remove.Scope = DI_REMOVEDEVICE_GLOBAL; | 564 | remove.Scope = DI_REMOVEDEVICE_GLOBAL; |
565 | remove.ClassInstallHeader.InstallFunction = DIF_REMOVE; | 565 | remove.ClassInstallHeader.InstallFunction = DIF_REMOVE; |
566 | /* | 566 | /* |
567 | * 1. Prepare our existing device information set, and place the | 567 | * 1. Prepare our existing device information set, and place the |
568 | * uninstall related information into the structure | 568 | * uninstall related information into the structure |
569 | */ | 569 | */ |
570 | if ( ! SetupDiSetClassInstallParamsA (DeviceInfo, | 570 | if ( ! SetupDiSetClassInstallParamsA (DeviceInfo, |
@@ -581,7 +581,7 @@ remove_interface () | |||
581 | return FALSE; | 581 | return FALSE; |
582 | 582 | ||
583 | SetupDiDestroyDeviceInfoList (DeviceInfo); | 583 | SetupDiDestroyDeviceInfoList (DeviceInfo); |
584 | 584 | ||
585 | fprintf (stderr, "DEBUG: removed interface successfully\n"); | 585 | fprintf (stderr, "DEBUG: removed interface successfully\n"); |
586 | 586 | ||
587 | return TRUE; | 587 | return TRUE; |
@@ -590,8 +590,8 @@ remove_interface () | |||
590 | 590 | ||
591 | /** | 591 | /** |
592 | * Do all the lookup necessary to retrieve the inteface's actual name | 592 | * Do all the lookup necessary to retrieve the inteface's actual name |
593 | * off the registry. | 593 | * off the registry. |
594 | * | 594 | * |
595 | * @return: TRUE if we were able to lookup the interface's name, else FALSE | 595 | * @return: TRUE if we were able to lookup the interface's name, else FALSE |
596 | */ | 596 | */ |
597 | static BOOL | 597 | static BOOL |
@@ -615,7 +615,7 @@ resolve_interface_name () | |||
615 | 0, //must be 0 | 615 | 0, //must be 0 |
616 | NULL)) //hMachine, we are local | 616 | NULL)) //hMachine, we are local |
617 | return FALSE; | 617 | return FALSE; |
618 | 618 | ||
619 | fprintf (stderr, "DEBUG: Resolving interface name for network device %s\n",pnp_instance_id); | 619 | fprintf (stderr, "DEBUG: Resolving interface name for network device %s\n",pnp_instance_id); |
620 | 620 | ||
621 | /* Registry is incredibly slow, retry for up to 30 seconds to allow registry to refresh */ | 621 | /* Registry is incredibly slow, retry for up to 30 seconds to allow registry to refresh */ |
@@ -633,7 +633,7 @@ resolve_interface_name () | |||
633 | &adapter_key_handle)) | 633 | &adapter_key_handle)) |
634 | return FALSE; | 634 | return FALSE; |
635 | 635 | ||
636 | /* Of course there is a multitude of entries here, with arbitrary names, | 636 | /* Of course there is a multitude of entries here, with arbitrary names, |
637 | * thus we need to iterate through there. | 637 | * thus we need to iterate through there. |
638 | */ | 638 | */ |
639 | while (!retval) | 639 | while (!retval) |
@@ -658,7 +658,7 @@ resolve_interface_name () | |||
658 | NULL, | 658 | NULL, |
659 | NULL); | 659 | NULL); |
660 | 660 | ||
661 | /* this may fail due to one of two reasons: | 661 | /* this may fail due to one of two reasons: |
662 | * we are at the end of the list*/ | 662 | * we are at the end of the list*/ |
663 | if (ERROR_NO_MORE_ITEMS == status) | 663 | if (ERROR_NO_MORE_ITEMS == status) |
664 | break; | 664 | break; |
@@ -709,8 +709,8 @@ resolve_interface_name () | |||
709 | if (status != ERROR_SUCCESS || data_type != REG_SZ) | 709 | if (status != ERROR_SUCCESS || data_type != REG_SZ) |
710 | goto cleanup; | 710 | goto cleanup; |
711 | 711 | ||
712 | /* | 712 | /* |
713 | * we have successfully found OUR instance, | 713 | * we have successfully found OUR instance, |
714 | * save the device GUID before exiting | 714 | * save the device GUID before exiting |
715 | */ | 715 | */ |
716 | 716 | ||
@@ -732,7 +732,7 @@ cleanup: | |||
732 | 732 | ||
733 | /** | 733 | /** |
734 | * Determines the version of the installed TAP32 driver and checks if it's sufficiently new for GNUNET | 734 | * Determines the version of the installed TAP32 driver and checks if it's sufficiently new for GNUNET |
735 | * | 735 | * |
736 | * @param handle the handle to our tap device | 736 | * @param handle the handle to our tap device |
737 | * @return TRUE if the version is sufficient, else FALSE | 737 | * @return TRUE if the version is sufficient, else FALSE |
738 | */ | 738 | */ |
@@ -758,7 +758,7 @@ check_tapw32_version (HANDLE handle) | |||
758 | TAP_WIN_MIN_MINOR); | 758 | TAP_WIN_MIN_MINOR); |
759 | return FALSE; | 759 | return FALSE; |
760 | } | 760 | } |
761 | 761 | ||
762 | return TRUE; | 762 | return TRUE; |
763 | } | 763 | } |
764 | 764 | ||
@@ -824,8 +824,8 @@ init_tun () | |||
824 | 824 | ||
825 | /** | 825 | /** |
826 | * Brings a TAP device up and sets it to connected state. | 826 | * Brings a TAP device up and sets it to connected state. |
827 | * | 827 | * |
828 | * @param handle the handle to our TAP device | 828 | * @param handle the handle to our TAP device |
829 | * @return True if the operation succeeded, else false | 829 | * @return True if the operation succeeded, else false |
830 | */ | 830 | */ |
831 | static BOOL | 831 | static BOOL |
@@ -851,25 +851,25 @@ tun_up (HANDLE handle) | |||
851 | 851 | ||
852 | /** | 852 | /** |
853 | * Attempts to read off an input facility (tap or named pipe) in overlapped mode. | 853 | * Attempts to read off an input facility (tap or named pipe) in overlapped mode. |
854 | * | 854 | * |
855 | * 1. | 855 | * 1. |
856 | * If the input facility is in IOSTATE_READY, it will issue a new read operation to the | 856 | * If the input facility is in IOSTATE_READY, it will issue a new read operation to the |
857 | * input handle. Then it goes into IOSTATE_QUEUED state. | 857 | * input handle. Then it goes into IOSTATE_QUEUED state. |
858 | * In case the read succeeded instantly the input facility enters 3. | 858 | * In case the read succeeded instantly the input facility enters 3. |
859 | * | 859 | * |
860 | * 2. | 860 | * 2. |
861 | * If the input facility is in IOSTATE_QUEUED state, it will check if the queued read has finished already. | 861 | * If the input facility is in IOSTATE_QUEUED state, it will check if the queued read has finished already. |
862 | * If it has finished, go to state 3. | 862 | * If it has finished, go to state 3. |
863 | * If it has failed, set IOSTATE_FAILED | 863 | * If it has failed, set IOSTATE_FAILED |
864 | * | 864 | * |
865 | * 3. | 865 | * 3. |
866 | * If the output facility is in state IOSTATE_READY, the read-buffer is copied to the output buffer. | 866 | * If the output facility is in state IOSTATE_READY, the read-buffer is copied to the output buffer. |
867 | * The input facility enters state IOSTATE_READY | 867 | * The input facility enters state IOSTATE_READY |
868 | * The output facility enters state IOSTATE_READY | 868 | * The output facility enters state IOSTATE_READY |
869 | * If the output facility is in state IOSTATE_QUEUED, the input facility enters IOSTATE_WAITING | 869 | * If the output facility is in state IOSTATE_QUEUED, the input facility enters IOSTATE_WAITING |
870 | * | 870 | * |
871 | * IOSTATE_WAITING is reset by the output facility, once it has completed. | 871 | * IOSTATE_WAITING is reset by the output facility, once it has completed. |
872 | * | 872 | * |
873 | * @param input_facility input named pipe or file to work with. | 873 | * @param input_facility input named pipe or file to work with. |
874 | * @param output_facility output pipe or file to hand over data to. | 874 | * @param output_facility output pipe or file to hand over data to. |
875 | * @return false if an event reset was impossible (OS error), else true | 875 | * @return false if an event reset was impossible (OS error), else true |
@@ -880,11 +880,11 @@ attempt_read_tap (struct io_facility * input_facility, | |||
880 | { | 880 | { |
881 | struct GNUNET_MessageHeader * hdr; | 881 | struct GNUNET_MessageHeader * hdr; |
882 | unsigned short size; | 882 | unsigned short size; |
883 | 883 | ||
884 | switch (input_facility->facility_state) | 884 | switch (input_facility->facility_state) |
885 | { | 885 | { |
886 | case IOSTATE_READY: | 886 | case IOSTATE_READY: |
887 | { | 887 | { |
888 | if (! ResetEvent (input_facility->overlapped.hEvent)) | 888 | if (! ResetEvent (input_facility->overlapped.hEvent)) |
889 | { | 889 | { |
890 | return FALSE; | 890 | return FALSE; |
@@ -903,9 +903,9 @@ attempt_read_tap (struct io_facility * input_facility, | |||
903 | /* reset event manually*/ | 903 | /* reset event manually*/ |
904 | if (! SetEvent (input_facility->overlapped.hEvent)) | 904 | if (! SetEvent (input_facility->overlapped.hEvent)) |
905 | return FALSE; | 905 | return FALSE; |
906 | 906 | ||
907 | fprintf (stderr, "DEBUG: tap read succeeded immediately\n"); | 907 | fprintf (stderr, "DEBUG: tap read succeeded immediately\n"); |
908 | 908 | ||
909 | /* we successfully read something from the TAP and now need to | 909 | /* we successfully read something from the TAP and now need to |
910 | * send it our via STDOUT. Is that possible at the moment? */ | 910 | * send it our via STDOUT. Is that possible at the moment? */ |
911 | if ((IOSTATE_READY == output_facility->facility_state || | 911 | if ((IOSTATE_READY == output_facility->facility_state || |
@@ -914,7 +914,7 @@ attempt_read_tap (struct io_facility * input_facility, | |||
914 | { /* hand over this buffers content and apply message header for gnunet */ | 914 | { /* hand over this buffers content and apply message header for gnunet */ |
915 | hdr = (struct GNUNET_MessageHeader *) output_facility->buffer; | 915 | hdr = (struct GNUNET_MessageHeader *) output_facility->buffer; |
916 | size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader); | 916 | size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader); |
917 | 917 | ||
918 | memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader), | 918 | memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader), |
919 | input_facility->buffer, | 919 | input_facility->buffer, |
920 | input_facility->buffer_size); | 920 | input_facility->buffer_size); |
@@ -961,7 +961,7 @@ attempt_read_tap (struct io_facility * input_facility, | |||
961 | return FALSE; | 961 | return FALSE; |
962 | 962 | ||
963 | fprintf (stderr, "DEBUG: tap read succeeded delayed\n"); | 963 | fprintf (stderr, "DEBUG: tap read succeeded delayed\n"); |
964 | 964 | ||
965 | /* we successfully read something from the TAP and now need to | 965 | /* we successfully read something from the TAP and now need to |
966 | * send it our via STDOUT. Is that possible at the moment? */ | 966 | * send it our via STDOUT. Is that possible at the moment? */ |
967 | if ((IOSTATE_READY == output_facility->facility_state || | 967 | if ((IOSTATE_READY == output_facility->facility_state || |
@@ -970,7 +970,7 @@ attempt_read_tap (struct io_facility * input_facility, | |||
970 | { /* hand over this buffers content and apply message header for gnunet */ | 970 | { /* hand over this buffers content and apply message header for gnunet */ |
971 | hdr = (struct GNUNET_MessageHeader *) output_facility->buffer; | 971 | hdr = (struct GNUNET_MessageHeader *) output_facility->buffer; |
972 | size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader); | 972 | size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader); |
973 | 973 | ||
974 | memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader), | 974 | memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader), |
975 | input_facility->buffer, | 975 | input_facility->buffer, |
976 | input_facility->buffer_size); | 976 | input_facility->buffer_size); |
@@ -1023,26 +1023,26 @@ attempt_read_tap (struct io_facility * input_facility, | |||
1023 | 1023 | ||
1024 | /** | 1024 | /** |
1025 | * Attempts to read off an input facility (tap or named pipe) in overlapped mode. | 1025 | * Attempts to read off an input facility (tap or named pipe) in overlapped mode. |
1026 | * | 1026 | * |
1027 | * 1. | 1027 | * 1. |
1028 | * If the input facility is in IOSTATE_READY, it will issue a new read operation to the | 1028 | * If the input facility is in IOSTATE_READY, it will issue a new read operation to the |
1029 | * input handle. Then it goes into IOSTATE_QUEUED state. | 1029 | * input handle. Then it goes into IOSTATE_QUEUED state. |
1030 | * In case the read succeeded instantly the input facility enters 3. | 1030 | * In case the read succeeded instantly the input facility enters 3. |
1031 | * | 1031 | * |
1032 | * 2. | 1032 | * 2. |
1033 | * If the input facility is in IOSTATE_QUEUED state, it will check if the queued read has finished already. | 1033 | * If the input facility is in IOSTATE_QUEUED state, it will check if the queued read has finished already. |
1034 | * If it has finished, go to state 3. | 1034 | * If it has finished, go to state 3. |
1035 | * If it has failed, set IOSTATE_FAILED | 1035 | * If it has failed, set IOSTATE_FAILED |
1036 | * | 1036 | * |
1037 | * 3. | 1037 | * 3. |
1038 | * If the facility is finished with ready | 1038 | * If the facility is finished with ready |
1039 | * The read-buffer is copied to the output buffer, except for the GNUNET_MessageHeader. | 1039 | * The read-buffer is copied to the output buffer, except for the GNUNET_MessageHeader. |
1040 | * The input facility enters state IOSTATE_READY | 1040 | * The input facility enters state IOSTATE_READY |
1041 | * The output facility enters state IOSTATE_READY | 1041 | * The output facility enters state IOSTATE_READY |
1042 | * If the output facility is in state IOSTATE_QUEUED, the input facility enters IOSTATE_WAITING | 1042 | * If the output facility is in state IOSTATE_QUEUED, the input facility enters IOSTATE_WAITING |
1043 | * | 1043 | * |
1044 | * IOSTATE_WAITING is reset by the output facility, once it has completed. | 1044 | * IOSTATE_WAITING is reset by the output facility, once it has completed. |
1045 | * | 1045 | * |
1046 | * @param input_facility input named pipe or file to work with. | 1046 | * @param input_facility input named pipe or file to work with. |
1047 | * @param output_facility output pipe or file to hand over data to. | 1047 | * @param output_facility output pipe or file to hand over data to. |
1048 | * @return false if an event reset was impossible (OS error), else true | 1048 | * @return false if an event reset was impossible (OS error), else true |
@@ -1052,17 +1052,17 @@ attempt_read_stdin (struct io_facility * input_facility, | |||
1052 | struct io_facility * output_facility) | 1052 | struct io_facility * output_facility) |
1053 | { | 1053 | { |
1054 | struct GNUNET_MessageHeader * hdr; | 1054 | struct GNUNET_MessageHeader * hdr; |
1055 | 1055 | ||
1056 | switch (input_facility->facility_state) | 1056 | switch (input_facility->facility_state) |
1057 | { | 1057 | { |
1058 | case IOSTATE_READY: | 1058 | case IOSTATE_READY: |
1059 | { | 1059 | { |
1060 | input_facility->buffer_size = 0; | 1060 | input_facility->buffer_size = 0; |
1061 | 1061 | ||
1062 | partial_read_iostate_ready: | 1062 | partial_read_iostate_ready: |
1063 | if (! ResetEvent (input_facility->overlapped.hEvent)) | 1063 | if (! ResetEvent (input_facility->overlapped.hEvent)) |
1064 | return FALSE; | 1064 | return FALSE; |
1065 | 1065 | ||
1066 | /* Check how the task is handled */ | 1066 | /* Check how the task is handled */ |
1067 | if (ReadFile (input_facility->handle, | 1067 | if (ReadFile (input_facility->handle, |
1068 | input_facility->buffer + input_facility->buffer_size, | 1068 | input_facility->buffer + input_facility->buffer_size, |
@@ -1110,7 +1110,7 @@ partial_read_iostate_ready: | |||
1110 | input_facility->facility_state = IOSTATE_WAITING; | 1110 | input_facility->facility_state = IOSTATE_WAITING; |
1111 | else /* we read nothing */ | 1111 | else /* we read nothing */ |
1112 | input_facility->facility_state = IOSTATE_READY; | 1112 | input_facility->facility_state = IOSTATE_READY; |
1113 | } | 1113 | } |
1114 | else /* operation was either queued or failed*/ | 1114 | else /* operation was either queued or failed*/ |
1115 | { | 1115 | { |
1116 | int err = GetLastError (); | 1116 | int err = GetLastError (); |
@@ -1138,13 +1138,13 @@ partial_read_iostate_ready: | |||
1138 | FALSE)) | 1138 | FALSE)) |
1139 | {/* successful return for a queued operation */ | 1139 | {/* successful return for a queued operation */ |
1140 | hdr = (struct GNUNET_MessageHeader *) input_facility->buffer; | 1140 | hdr = (struct GNUNET_MessageHeader *) input_facility->buffer; |
1141 | 1141 | ||
1142 | if (! ResetEvent (input_facility->overlapped.hEvent)) | 1142 | if (! ResetEvent (input_facility->overlapped.hEvent)) |
1143 | return FALSE; | 1143 | return FALSE; |
1144 | 1144 | ||
1145 | fprintf (stderr, "DEBUG: stdin read succeeded delayed\n"); | 1145 | fprintf (stderr, "DEBUG: stdin read succeeded delayed\n"); |
1146 | input_facility->buffer_size += input_facility->buffer_size_processed; | 1146 | input_facility->buffer_size += input_facility->buffer_size_processed; |
1147 | 1147 | ||
1148 | if ((ntohs (hdr->type) != GNUNET_MESSAGE_TYPE_VPN_HELPER) || | 1148 | if ((ntohs (hdr->type) != GNUNET_MESSAGE_TYPE_VPN_HELPER) || |
1149 | (ntohs (hdr->size) > sizeof (input_facility->buffer))) | 1149 | (ntohs (hdr->size) > sizeof (input_facility->buffer))) |
1150 | { | 1150 | { |
@@ -1206,7 +1206,7 @@ partial_read_iostate_ready: | |||
1206 | * Attempts to write to an output facility (tap or named pipe) in overlapped mode. | 1206 | * Attempts to write to an output facility (tap or named pipe) in overlapped mode. |
1207 | * | 1207 | * |
1208 | * TODO: high level description | 1208 | * TODO: high level description |
1209 | * | 1209 | * |
1210 | * @param output_facility output pipe or file to hand over data to. | 1210 | * @param output_facility output pipe or file to hand over data to. |
1211 | * @param input_facility input named pipe or file to work with. | 1211 | * @param input_facility input named pipe or file to work with. |
1212 | * @return false if an event reset was impossible (OS error), else true | 1212 | * @return false if an event reset was impossible (OS error), else true |
@@ -1219,7 +1219,7 @@ attempt_write (struct io_facility * output_facility, | |||
1219 | { | 1219 | { |
1220 | case IOSTATE_READY: | 1220 | case IOSTATE_READY: |
1221 | output_facility->buffer_size_written = 0; | 1221 | output_facility->buffer_size_written = 0; |
1222 | 1222 | ||
1223 | continue_partial_write: | 1223 | continue_partial_write: |
1224 | if (! ResetEvent (output_facility->overlapped.hEvent)) | 1224 | if (! ResetEvent (output_facility->overlapped.hEvent)) |
1225 | return FALSE; | 1225 | return FALSE; |
@@ -1234,7 +1234,7 @@ continue_partial_write: | |||
1234 | 1234 | ||
1235 | fprintf (stderr, "DEBUG: write succeeded immediately\n"); | 1235 | fprintf (stderr, "DEBUG: write succeeded immediately\n"); |
1236 | output_facility->buffer_size_written += output_facility->buffer_size_processed; | 1236 | output_facility->buffer_size_written += output_facility->buffer_size_processed; |
1237 | 1237 | ||
1238 | /* reset event manually*/ | 1238 | /* reset event manually*/ |
1239 | if (! SetEvent (output_facility->overlapped.hEvent)) | 1239 | if (! SetEvent (output_facility->overlapped.hEvent)) |
1240 | return FALSE; | 1240 | return FALSE; |
@@ -1242,7 +1242,7 @@ continue_partial_write: | |||
1242 | /* partial write */ | 1242 | /* partial write */ |
1243 | if (output_facility->buffer_size_written < output_facility->buffer_size) | 1243 | if (output_facility->buffer_size_written < output_facility->buffer_size) |
1244 | goto continue_partial_write; | 1244 | goto continue_partial_write; |
1245 | 1245 | ||
1246 | /* we are now waiting for our buffer to be filled*/ | 1246 | /* we are now waiting for our buffer to be filled*/ |
1247 | output_facility->facility_state = IOSTATE_WAITING; | 1247 | output_facility->facility_state = IOSTATE_WAITING; |
1248 | 1248 | ||
@@ -1269,7 +1269,7 @@ continue_partial_write: | |||
1269 | return TRUE; | 1269 | return TRUE; |
1270 | case IOSTATE_QUEUED: | 1270 | case IOSTATE_QUEUED: |
1271 | // there was an operation going on already, check if that has completed now. | 1271 | // there was an operation going on already, check if that has completed now. |
1272 | 1272 | ||
1273 | if (GetOverlappedResult (output_facility->handle, | 1273 | if (GetOverlappedResult (output_facility->handle, |
1274 | &output_facility->overlapped, | 1274 | &output_facility->overlapped, |
1275 | &output_facility->buffer_size_processed, | 1275 | &output_facility->buffer_size_processed, |
@@ -1277,17 +1277,17 @@ continue_partial_write: | |||
1277 | {/* successful return for a queued operation */ | 1277 | {/* successful return for a queued operation */ |
1278 | if (! ResetEvent (output_facility->overlapped.hEvent)) | 1278 | if (! ResetEvent (output_facility->overlapped.hEvent)) |
1279 | return FALSE; | 1279 | return FALSE; |
1280 | 1280 | ||
1281 | fprintf (stderr, "DEBUG: write succeeded delayed\n"); | 1281 | fprintf (stderr, "DEBUG: write succeeded delayed\n"); |
1282 | output_facility->buffer_size_written += output_facility->buffer_size_processed; | 1282 | output_facility->buffer_size_written += output_facility->buffer_size_processed; |
1283 | 1283 | ||
1284 | /* partial write */ | 1284 | /* partial write */ |
1285 | if (output_facility->buffer_size_written < output_facility->buffer_size) | 1285 | if (output_facility->buffer_size_written < output_facility->buffer_size) |
1286 | goto continue_partial_write; | 1286 | goto continue_partial_write; |
1287 | 1287 | ||
1288 | /* we are now waiting for our buffer to be filled*/ | 1288 | /* we are now waiting for our buffer to be filled*/ |
1289 | output_facility->facility_state = IOSTATE_WAITING; | 1289 | output_facility->facility_state = IOSTATE_WAITING; |
1290 | 1290 | ||
1291 | /* we successfully wrote something and now need to reset our reader */ | 1291 | /* we successfully wrote something and now need to reset our reader */ |
1292 | if (IOSTATE_WAITING == input_facility->facility_state) | 1292 | if (IOSTATE_WAITING == input_facility->facility_state) |
1293 | input_facility->facility_state = IOSTATE_RESUME; | 1293 | input_facility->facility_state = IOSTATE_RESUME; |
@@ -1304,7 +1304,7 @@ continue_partial_write: | |||
1304 | fprintf (stderr, "FATAL: Write to handle failed, exiting\n"); | 1304 | fprintf (stderr, "FATAL: Write to handle failed, exiting\n"); |
1305 | } | 1305 | } |
1306 | } | 1306 | } |
1307 | default: | 1307 | default: |
1308 | return TRUE; | 1308 | return TRUE; |
1309 | } | 1309 | } |
1310 | } | 1310 | } |
@@ -1312,7 +1312,7 @@ continue_partial_write: | |||
1312 | 1312 | ||
1313 | /** | 1313 | /** |
1314 | * Initialize a overlapped structure | 1314 | * Initialize a overlapped structure |
1315 | * | 1315 | * |
1316 | * @param elem the element to initilize | 1316 | * @param elem the element to initilize |
1317 | * @param initial_state the initial state for this instance | 1317 | * @param initial_state the initial state for this instance |
1318 | * @param signaled if the hEvent created should default to signaled or not | 1318 | * @param signaled if the hEvent created should default to signaled or not |
@@ -1358,13 +1358,13 @@ run (HANDLE tap_handle) | |||
1358 | /* tun up: */ | 1358 | /* tun up: */ |
1359 | /* we do this HERE and not beforehand (in init_tun()), in contrast to openvpn | 1359 | /* we do this HERE and not beforehand (in init_tun()), in contrast to openvpn |
1360 | * to remove the need to flush the arp cache, handle DHCP and wrong IPs. | 1360 | * to remove the need to flush the arp cache, handle DHCP and wrong IPs. |
1361 | * | 1361 | * |
1362 | * DHCP and such are all features we will never use in gnunet afaik. | 1362 | * DHCP and such are all features we will never use in gnunet afaik. |
1363 | * But for openvpn those are essential. | 1363 | * But for openvpn those are essential. |
1364 | */ | 1364 | */ |
1365 | if ((privilege_testing) || (! tun_up (tap_handle) )) | 1365 | if ((privilege_testing) || (! tun_up (tap_handle) )) |
1366 | goto teardown_final; | 1366 | goto teardown_final; |
1367 | 1367 | ||
1368 | /* Initialize our overlapped IO structures*/ | 1368 | /* Initialize our overlapped IO structures*/ |
1369 | if (! (initialize_io_facility (&tap_read, IOSTATE_READY, FALSE) | 1369 | if (! (initialize_io_facility (&tap_read, IOSTATE_READY, FALSE) |
1370 | && initialize_io_facility (&tap_write, IOSTATE_WAITING, TRUE) | 1370 | && initialize_io_facility (&tap_write, IOSTATE_WAITING, TRUE) |
@@ -1380,12 +1380,12 @@ run (HANDLE tap_handle) | |||
1380 | /* Debug output to console STDIN/STDOUT*/ | 1380 | /* Debug output to console STDIN/STDOUT*/ |
1381 | std_in.handle = parent_std_in_handle; | 1381 | std_in.handle = parent_std_in_handle; |
1382 | std_out.handle = parent_std_out_handle; | 1382 | std_out.handle = parent_std_out_handle; |
1383 | 1383 | ||
1384 | #else | 1384 | #else |
1385 | fprintf (stderr, "DEBUG: reopening stdin/out for overlapped IO\n"); | 1385 | fprintf (stderr, "DEBUG: reopening stdin/out for overlapped IO\n"); |
1386 | /* | 1386 | /* |
1387 | * Find out the types of our handles. | 1387 | * Find out the types of our handles. |
1388 | * This part is a problem, because in windows we need to handle files, | 1388 | * This part is a problem, because in windows we need to handle files, |
1389 | * pipes and the console differently. | 1389 | * pipes and the console differently. |
1390 | */ | 1390 | */ |
1391 | if ((FILE_TYPE_PIPE != GetFileType (parent_std_in_handle)) || | 1391 | if ((FILE_TYPE_PIPE != GetFileType (parent_std_in_handle)) || |
@@ -1417,9 +1417,9 @@ run (HANDLE tap_handle) | |||
1417 | goto teardown; | 1417 | goto teardown; |
1418 | } | 1418 | } |
1419 | #endif | 1419 | #endif |
1420 | 1420 | ||
1421 | fprintf (stderr, "DEBUG: mainloop has begun\n"); | 1421 | fprintf (stderr, "DEBUG: mainloop has begun\n"); |
1422 | 1422 | ||
1423 | while (std_out.path_open || tap_write.path_open) | 1423 | while (std_out.path_open || tap_write.path_open) |
1424 | { | 1424 | { |
1425 | /* perform READ from stdin if possible */ | 1425 | /* perform READ from stdin if possible */ |
@@ -1439,15 +1439,15 @@ run (HANDLE tap_handle) | |||
1439 | break; | 1439 | break; |
1440 | } | 1440 | } |
1441 | fprintf (stderr, "DEBUG: teardown initiated\n"); | 1441 | fprintf (stderr, "DEBUG: teardown initiated\n"); |
1442 | 1442 | ||
1443 | teardown: | 1443 | teardown: |
1444 | 1444 | ||
1445 | CancelIo (tap_handle); | 1445 | CancelIo (tap_handle); |
1446 | CancelIo (std_in.handle); | 1446 | CancelIo (std_in.handle); |
1447 | CancelIo (std_out.handle); | 1447 | CancelIo (std_out.handle); |
1448 | 1448 | ||
1449 | teardown_final: | 1449 | teardown_final: |
1450 | 1450 | ||
1451 | CloseHandle (tap_handle); | 1451 | CloseHandle (tap_handle); |
1452 | } | 1452 | } |
1453 | 1453 | ||
@@ -1474,7 +1474,7 @@ main (int argc, char **argv) | |||
1474 | BOOL have_ip4 = FALSE; | 1474 | BOOL have_ip4 = FALSE; |
1475 | BOOL have_ip6 = FALSE; | 1475 | BOOL have_ip6 = FALSE; |
1476 | BOOL have_nat44 = FALSE; | 1476 | BOOL have_nat44 = FALSE; |
1477 | 1477 | ||
1478 | if ( (1 < argc) && (0 != strcmp (argv[1], "-d"))){ | 1478 | if ( (1 < argc) && (0 != strcmp (argv[1], "-d"))){ |
1479 | privilege_testing = TRUE; | 1479 | privilege_testing = TRUE; |
1480 | fprintf (stderr, | 1480 | fprintf (stderr, |
@@ -1483,10 +1483,10 @@ main (int argc, char **argv) | |||
1483 | argv++; | 1483 | argv++; |
1484 | argc--; | 1484 | argc--; |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | if (6 != argc) | 1487 | if (6 != argc) |
1488 | { | 1488 | { |
1489 | fprintf (stderr, | 1489 | fprintf (stderr, |
1490 | "%s", | 1490 | "%s", |
1491 | "FATAL: must supply 6 arguments\nUsage:\ngnunet-helper-exit [-d] <if name prefix> <uplink-interface name> <address6 or \"-\"> <netbits6> <address4 or \"-\"> <netmask4>\n"); | 1491 | "FATAL: must supply 6 arguments\nUsage:\ngnunet-helper-exit [-d] <if name prefix> <uplink-interface name> <address6 or \"-\"> <netbits6> <address4 or \"-\"> <netmask4>\n"); |
1492 | return 1; | 1492 | return 1; |
@@ -1495,9 +1495,9 @@ main (int argc, char **argv) | |||
1495 | strncpy (hwid, argv[1], LINE_LEN); | 1495 | strncpy (hwid, argv[1], LINE_LEN); |
1496 | hwid[LINE_LEN - 1] = '\0'; | 1496 | hwid[LINE_LEN - 1] = '\0'; |
1497 | 1497 | ||
1498 | /* | 1498 | /* |
1499 | * We use our PID for finding/resolving the control-panel name of our virtual | 1499 | * We use our PID for finding/resolving the control-panel name of our virtual |
1500 | * device. PIDs are (of course) unique at runtime, thus we can safely use it | 1500 | * device. PIDs are (of course) unique at runtime, thus we can safely use it |
1501 | * as additional hardware-id for our device. | 1501 | * as additional hardware-id for our device. |
1502 | */ | 1502 | */ |
1503 | snprintf (secondary_hwid, LINE_LEN / 2, "%s-%d", | 1503 | snprintf (secondary_hwid, LINE_LEN / 2, "%s-%d", |
@@ -1558,7 +1558,7 @@ main (int argc, char **argv) | |||
1558 | fprintf (stderr, "FATAL: Could not enable forwarding via netsh: %s\n", strerror (local_ret)); | 1558 | fprintf (stderr, "FATAL: Could not enable forwarding via netsh: %s\n", strerror (local_ret)); |
1559 | goto cleanup; | 1559 | goto cleanup; |
1560 | } | 1560 | } |
1561 | /* we can keep IPv6 forwarding around, as all interfaces have | 1561 | /* we can keep IPv6 forwarding around, as all interfaces have |
1562 | * their forwarding mode reset to false at bootup. */ | 1562 | * their forwarding mode reset to false at bootup. */ |
1563 | } | 1563 | } |
1564 | 1564 | ||
@@ -1574,11 +1574,11 @@ main (int argc, char **argv) | |||
1574 | // setup NAPT, if possible | 1574 | // setup NAPT, if possible |
1575 | /* MS has REMOVED the routing/nat capabilities from Vista+, thus | 1575 | /* MS has REMOVED the routing/nat capabilities from Vista+, thus |
1576 | * we can not setup NAT like in XP or on the server. Actually the | 1576 | * we can not setup NAT like in XP or on the server. Actually the |
1577 | * the only feasible solution seems to be to use | 1577 | * the only feasible solution seems to be to use |
1578 | * Internet Connection Sharing, which introduces a horde of problems | 1578 | * Internet Connection Sharing, which introduces a horde of problems |
1579 | * such as sending out rogue-RAs on the external interface in an ipv6 | 1579 | * such as sending out rogue-RAs on the external interface in an ipv6 |
1580 | * network. | 1580 | * network. |
1581 | * Thus, below stuff ONLY works on | 1581 | * Thus, below stuff ONLY works on |
1582 | * WinXP SP3 | 1582 | * WinXP SP3 |
1583 | * Win Server 2003 SP1+ | 1583 | * Win Server 2003 SP1+ |
1584 | * Win Server 2008 | 1584 | * Win Server 2008 |
@@ -1637,7 +1637,7 @@ cleanup: | |||
1637 | if (0 != local_ret) | 1637 | if (0 != local_ret) |
1638 | fprintf(stderr, "WARNING: Could not remove IPv4-NAPT from internal interface, hopefully this will have no effect in future runs: %s\n", strerror(local_ret)); | 1638 | fprintf(stderr, "WARNING: Could not remove IPv4-NAPT from internal interface, hopefully this will have no effect in future runs: %s\n", strerror(local_ret)); |
1639 | } | 1639 | } |
1640 | 1640 | ||
1641 | fprintf(stderr, "DEBUG: Removing IP4 address\n"); | 1641 | fprintf(stderr, "DEBUG: Removing IP4 address\n"); |
1642 | remove_address4 (address); | 1642 | remove_address4 (address); |
1643 | } | 1643 | } |
diff --git a/src/exit/gnunet-helper-exit.c b/src/exit/gnunet-helper-exit.c index e2a0fd416..e87aac559 100644 --- a/src/exit/gnunet-helper-exit.c +++ b/src/exit/gnunet-helper-exit.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file exit/gnunet-helper-exit.c | 22 | * @file exit/gnunet-helper-exit.c |
23 | * | 23 | * |
24 | * @brief the helper for exit nodes. Opens a virtual | 24 | * @brief the helper for exit nodes. Opens a virtual |
25 | * network-interface, sends data received on the if to stdout, sends | 25 | * network-interface, sends data received on the if to stdout, sends |
@@ -109,7 +109,7 @@ open_dev_null (int target_fd, | |||
109 | if (fd == target_fd) | 109 | if (fd == target_fd) |
110 | return; | 110 | return; |
111 | if (-1 == dup2 (fd, target_fd)) | 111 | if (-1 == dup2 (fd, target_fd)) |
112 | { | 112 | { |
113 | (void) close (fd); | 113 | (void) close (fd); |
114 | abort (); | 114 | abort (); |
115 | } | 115 | } |
@@ -119,13 +119,13 @@ open_dev_null (int target_fd, | |||
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Run the given command and wait for it to complete. | 121 | * Run the given command and wait for it to complete. |
122 | * | 122 | * |
123 | * @param file name of the binary to run | 123 | * @param file name of the binary to run |
124 | * @param cmd command line arguments (as given to 'execv') | 124 | * @param cmd command line arguments (as given to 'execv') |
125 | * @return 0 on success, 1 on any error | 125 | * @return 0 on success, 1 on any error |
126 | */ | 126 | */ |
127 | static int | 127 | static int |
128 | fork_and_exec (const char *file, | 128 | fork_and_exec (const char *file, |
129 | char *const cmd[]) | 129 | char *const cmd[]) |
130 | { | 130 | { |
131 | int status; | 131 | int status; |
@@ -135,8 +135,8 @@ fork_and_exec (const char *file, | |||
135 | pid = fork (); | 135 | pid = fork (); |
136 | if (-1 == pid) | 136 | if (-1 == pid) |
137 | { | 137 | { |
138 | fprintf (stderr, | 138 | fprintf (stderr, |
139 | "fork failed: %s\n", | 139 | "fork failed: %s\n", |
140 | strerror (errno)); | 140 | strerror (errno)); |
141 | return 1; | 141 | return 1; |
142 | } | 142 | } |
@@ -145,25 +145,25 @@ fork_and_exec (const char *file, | |||
145 | /* we are the child process */ | 145 | /* we are the child process */ |
146 | /* close stdin/stdout to not cause interference | 146 | /* close stdin/stdout to not cause interference |
147 | with the helper's main protocol! */ | 147 | with the helper's main protocol! */ |
148 | (void) close (0); | 148 | (void) close (0); |
149 | open_dev_null (0, O_RDONLY); | 149 | open_dev_null (0, O_RDONLY); |
150 | (void) close (1); | 150 | (void) close (1); |
151 | open_dev_null (1, O_WRONLY); | 151 | open_dev_null (1, O_WRONLY); |
152 | (void) execv (file, cmd); | 152 | (void) execv (file, cmd); |
153 | /* can only get here on error */ | 153 | /* can only get here on error */ |
154 | fprintf (stderr, | 154 | fprintf (stderr, |
155 | "exec `%s' failed: %s\n", | 155 | "exec `%s' failed: %s\n", |
156 | file, | 156 | file, |
157 | strerror (errno)); | 157 | strerror (errno)); |
158 | _exit (1); | 158 | _exit (1); |
159 | } | 159 | } |
160 | /* keep running waitpid as long as the only error we get is 'EINTR' */ | 160 | /* keep running waitpid as long as the only error we get is 'EINTR' */ |
161 | while ( (-1 == (ret = waitpid (pid, &status, 0))) && | 161 | while ( (-1 == (ret = waitpid (pid, &status, 0))) && |
162 | (errno == EINTR) ); | 162 | (errno == EINTR) ); |
163 | if (-1 == ret) | 163 | if (-1 == ret) |
164 | { | 164 | { |
165 | fprintf (stderr, | 165 | fprintf (stderr, |
166 | "waitpid failed: %s\n", | 166 | "waitpid failed: %s\n", |
167 | strerror (errno)); | 167 | strerror (errno)); |
168 | return 1; | 168 | return 1; |
169 | } | 169 | } |
@@ -215,7 +215,7 @@ init_tun (char *dev) | |||
215 | 215 | ||
216 | if (-1 == ioctl (fd, TUNSETIFF, (void *) &ifr)) | 216 | if (-1 == ioctl (fd, TUNSETIFF, (void *) &ifr)) |
217 | { | 217 | { |
218 | fprintf (stderr, | 218 | fprintf (stderr, |
219 | "Error with ioctl on `%s': %s\n", "/dev/net/tun", | 219 | "Error with ioctl on `%s': %s\n", "/dev/net/tun", |
220 | strerror (errno)); | 220 | strerror (errno)); |
221 | (void) close (fd); | 221 | (void) close (fd); |
@@ -255,7 +255,7 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len) | |||
255 | 255 | ||
256 | if (-1 == (fd = socket (PF_INET6, SOCK_DGRAM, 0))) | 256 | if (-1 == (fd = socket (PF_INET6, SOCK_DGRAM, 0))) |
257 | { | 257 | { |
258 | fprintf (stderr, "Error creating socket: %s\n", strerror (errno)); | 258 | fprintf (stderr, "Error creating socket: %s\n", strerror (errno)); |
259 | exit (1); | 259 | exit (1); |
260 | } | 260 | } |
261 | 261 | ||
@@ -669,7 +669,7 @@ main (int argc, char **argv) | |||
669 | sbin_iptables = "/usr/sbin/iptables"; | 669 | sbin_iptables = "/usr/sbin/iptables"; |
670 | else | 670 | else |
671 | { | 671 | { |
672 | fprintf (stderr, | 672 | fprintf (stderr, |
673 | "Fatal: executable iptables not found in approved directories: %s\n", | 673 | "Fatal: executable iptables not found in approved directories: %s\n", |
674 | strerror (errno)); | 674 | strerror (errno)); |
675 | return 1; | 675 | return 1; |
@@ -691,7 +691,7 @@ main (int argc, char **argv) | |||
691 | 691 | ||
692 | if (-1 == (fd_tun = init_tun (dev))) | 692 | if (-1 == (fd_tun = init_tun (dev))) |
693 | { | 693 | { |
694 | fprintf (stderr, | 694 | fprintf (stderr, |
695 | "Fatal: could not initialize tun-interface `%s' with IPv6 %s/%s and IPv4 %s/%s\n", | 695 | "Fatal: could not initialize tun-interface `%s' with IPv6 %s/%s and IPv4 %s/%s\n", |
696 | dev, | 696 | dev, |
697 | argv[3], | 697 | argv[3], |
@@ -706,13 +706,13 @@ main (int argc, char **argv) | |||
706 | { | 706 | { |
707 | const char *address = argv[3]; | 707 | const char *address = argv[3]; |
708 | long prefix_len = atol (argv[4]); | 708 | long prefix_len = atol (argv[4]); |
709 | 709 | ||
710 | if ((prefix_len < 1) || (prefix_len > 127)) | 710 | if ((prefix_len < 1) || (prefix_len > 127)) |
711 | { | 711 | { |
712 | fprintf (stderr, "Fatal: prefix_len out of range\n"); | 712 | fprintf (stderr, "Fatal: prefix_len out of range\n"); |
713 | return 1; | 713 | return 1; |
714 | } | 714 | } |
715 | set_address6 (dev, address, prefix_len); | 715 | set_address6 (dev, address, prefix_len); |
716 | } | 716 | } |
717 | { | 717 | { |
718 | char *const sysctl_args[] = | 718 | char *const sysctl_args[] = |
@@ -724,7 +724,7 @@ main (int argc, char **argv) | |||
724 | { | 724 | { |
725 | fprintf (stderr, | 725 | fprintf (stderr, |
726 | "Failed to enable IPv6 forwarding. Will continue anyway.\n"); | 726 | "Failed to enable IPv6 forwarding. Will continue anyway.\n"); |
727 | } | 727 | } |
728 | } | 728 | } |
729 | } | 729 | } |
730 | 730 | ||
@@ -733,7 +733,7 @@ main (int argc, char **argv) | |||
733 | { | 733 | { |
734 | const char *address = argv[5]; | 734 | const char *address = argv[5]; |
735 | const char *mask = argv[6]; | 735 | const char *mask = argv[6]; |
736 | 736 | ||
737 | set_address4 (dev, address, mask); | 737 | set_address4 (dev, address, mask); |
738 | } | 738 | } |
739 | { | 739 | { |
@@ -746,7 +746,7 @@ main (int argc, char **argv) | |||
746 | { | 746 | { |
747 | fprintf (stderr, | 747 | fprintf (stderr, |
748 | "Failed to enable IPv4 forwarding. Will continue anyway.\n"); | 748 | "Failed to enable IPv4 forwarding. Will continue anyway.\n"); |
749 | } | 749 | } |
750 | } | 750 | } |
751 | if (0 != strcmp (argv[2], "-")) | 751 | if (0 != strcmp (argv[2], "-")) |
752 | { | 752 | { |
@@ -759,10 +759,10 @@ main (int argc, char **argv) | |||
759 | { | 759 | { |
760 | fprintf (stderr, | 760 | fprintf (stderr, |
761 | "Failed to enable IPv4 masquerading (NAT). Will continue anyway.\n"); | 761 | "Failed to enable IPv4 masquerading (NAT). Will continue anyway.\n"); |
762 | } | 762 | } |
763 | } | 763 | } |
764 | } | 764 | } |
765 | 765 | ||
766 | uid_t uid = getuid (); | 766 | uid_t uid = getuid (); |
767 | #ifdef HAVE_SETRESUID | 767 | #ifdef HAVE_SETRESUID |
768 | if (0 != setresuid (uid, uid, uid)) | 768 | if (0 != setresuid (uid, uid, uid)) |