diff options
-rw-r--r-- | src/nat-auto/gnunet-service-nat-auto.c | 16 | ||||
-rw-r--r-- | src/nat/gnunet-service-nat.c | 148 |
2 files changed, 82 insertions, 82 deletions
diff --git a/src/nat-auto/gnunet-service-nat-auto.c b/src/nat-auto/gnunet-service-nat-auto.c index fafc4d382..ae570c351 100644 --- a/src/nat-auto/gnunet-service-nat-auto.c +++ b/src/nat-auto/gnunet-service-nat-auto.c | |||
@@ -58,7 +58,7 @@ struct ClientHandle | |||
58 | * Kept in a DLL. | 58 | * Kept in a DLL. |
59 | */ | 59 | */ |
60 | struct ClientHandle *next; | 60 | struct ClientHandle *next; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Kept in a DLL. | 63 | * Kept in a DLL. |
64 | */ | 64 | */ |
@@ -66,7 +66,7 @@ struct ClientHandle | |||
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Underlying handle for this client with the service. | 68 | * Underlying handle for this client with the service. |
69 | */ | 69 | */ |
70 | struct GNUNET_SERVICE_Client *client; | 70 | struct GNUNET_SERVICE_Client *client; |
71 | 71 | ||
72 | /** | 72 | /** |
@@ -98,12 +98,12 @@ struct AutoconfigContext | |||
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Configuration we are creating. | 100 | * Configuration we are creating. |
101 | */ | 101 | */ |
102 | struct GNUNET_CONFIGURATION_Handle *c; | 102 | struct GNUNET_CONFIGURATION_Handle *c; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * Original configuration (for diffing). | 105 | * Original configuration (for diffing). |
106 | */ | 106 | */ |
107 | struct GNUNET_CONFIGURATION_Handle *orig; | 107 | struct GNUNET_CONFIGURATION_Handle *orig; |
108 | 108 | ||
109 | /** | 109 | /** |
@@ -134,7 +134,7 @@ struct AutoconfigContext | |||
134 | * Head of client DLL. | 134 | * Head of client DLL. |
135 | */ | 135 | */ |
136 | static struct ClientHandle *ch_head; | 136 | static struct ClientHandle *ch_head; |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * Tail of client DLL. | 139 | * Tail of client DLL. |
140 | */ | 140 | */ |
@@ -209,7 +209,7 @@ conclude_autoconfig_request (void *cls) | |||
209 | size_t c_size; | 209 | size_t c_size; |
210 | char *buf; | 210 | char *buf; |
211 | struct GNUNET_CONFIGURATION_Handle *diff; | 211 | struct GNUNET_CONFIGURATION_Handle *diff; |
212 | 212 | ||
213 | ac->timeout_task = NULL; | 213 | ac->timeout_task = NULL; |
214 | terminate_ac_activities (ac); | 214 | terminate_ac_activities (ac); |
215 | 215 | ||
@@ -331,7 +331,7 @@ handle_autoconfig_request (void *cls, | |||
331 | &conclude_autoconfig_request, | 331 | &conclude_autoconfig_request, |
332 | ac); | 332 | ac); |
333 | ac->enable_upnpc = GNUNET_SYSERR; /* undecided */ | 333 | ac->enable_upnpc = GNUNET_SYSERR; /* undecided */ |
334 | 334 | ||
335 | /* Probe for upnpc */ | 335 | /* Probe for upnpc */ |
336 | if (GNUNET_SYSERR == | 336 | if (GNUNET_SYSERR == |
337 | GNUNET_OS_check_helper_binary ("upnpc", | 337 | GNUNET_OS_check_helper_binary ("upnpc", |
@@ -349,7 +349,7 @@ handle_autoconfig_request (void *cls, | |||
349 | } | 349 | } |
350 | update_enable_upnpc_option (ac); | 350 | update_enable_upnpc_option (ac); |
351 | 351 | ||
352 | /* Finally, check if we are already done */ | 352 | /* Finally, check if we are already done */ |
353 | check_autoconfig_finished (ac); | 353 | check_autoconfig_finished (ac); |
354 | } | 354 | } |
355 | 355 | ||
diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c index 8f9e9f7fe..ccb37d2f9 100644 --- a/src/nat/gnunet-service-nat.c +++ b/src/nat/gnunet-service-nat.c | |||
@@ -23,7 +23,7 @@ | |||
23 | * @brief network address translation traversal service | 23 | * @brief network address translation traversal service |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | 25 | * |
26 | * The purpose of this service is to enable transports to | 26 | * The purpose of this service is to enable transports to |
27 | * traverse NAT routers, by providing traversal options and | 27 | * traverse NAT routers, by providing traversal options and |
28 | * knowledge about the local network topology. | 28 | * knowledge about the local network topology. |
29 | * | 29 | * |
@@ -69,7 +69,7 @@ | |||
69 | 69 | ||
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Information we track per client address. | 72 | * Information we track per client address. |
73 | */ | 73 | */ |
74 | struct ClientAddress | 74 | struct ClientAddress |
75 | { | 75 | { |
@@ -84,7 +84,7 @@ struct ClientAddress | |||
84 | * pending. | 84 | * pending. |
85 | */ | 85 | */ |
86 | struct GNUNET_NAT_MiniHandle *mh; | 86 | struct GNUNET_NAT_MiniHandle *mh; |
87 | 87 | ||
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
@@ -108,7 +108,7 @@ struct LocalAddressList | |||
108 | * for ICMP messages to this client for connection reversal. | 108 | * for ICMP messages to this client for connection reversal. |
109 | */ | 109 | */ |
110 | struct HelperContext *hc; | 110 | struct HelperContext *hc; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * The address itself (i.e. `struct sockaddr_in` or `struct | 113 | * The address itself (i.e. `struct sockaddr_in` or `struct |
114 | * sockaddr_in6`, in the respective byte order). | 114 | * sockaddr_in6`, in the respective byte order). |
@@ -119,7 +119,7 @@ struct LocalAddressList | |||
119 | * Address family. (FIXME: redundant, addr.ss_family! Remove!?) | 119 | * Address family. (FIXME: redundant, addr.ss_family! Remove!?) |
120 | */ | 120 | */ |
121 | int af; | 121 | int af; |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * #GNUNET_YES if we saw this one in the previous iteration, | 124 | * #GNUNET_YES if we saw this one in the previous iteration, |
125 | * but not in the current iteration and thus might need to | 125 | * but not in the current iteration and thus might need to |
@@ -131,7 +131,7 @@ struct LocalAddressList | |||
131 | * What type of address is this? | 131 | * What type of address is this? |
132 | */ | 132 | */ |
133 | enum GNUNET_NAT_AddressClass ac; | 133 | enum GNUNET_NAT_AddressClass ac; |
134 | 134 | ||
135 | }; | 135 | }; |
136 | 136 | ||
137 | 137 | ||
@@ -145,7 +145,7 @@ struct ClientHandle | |||
145 | * Kept in a DLL. | 145 | * Kept in a DLL. |
146 | */ | 146 | */ |
147 | struct ClientHandle *next; | 147 | struct ClientHandle *next; |
148 | 148 | ||
149 | /** | 149 | /** |
150 | * Kept in a DLL. | 150 | * Kept in a DLL. |
151 | */ | 151 | */ |
@@ -153,7 +153,7 @@ struct ClientHandle | |||
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Underlying handle for this client with the service. | 155 | * Underlying handle for this client with the service. |
156 | */ | 156 | */ |
157 | struct GNUNET_SERVICE_Client *client; | 157 | struct GNUNET_SERVICE_Client *client; |
158 | 158 | ||
159 | /** | 159 | /** |
@@ -169,8 +169,8 @@ struct ClientHandle | |||
169 | /** | 169 | /** |
170 | * External DNS name and port given by user due to manual | 170 | * External DNS name and port given by user due to manual |
171 | * hole punching. Special DNS name 'AUTO' is used to indicate | 171 | * hole punching. Special DNS name 'AUTO' is used to indicate |
172 | * desire for automatic determination of the external IP | 172 | * desire for automatic determination of the external IP |
173 | * (instead of DNS or manual configuration, i.e. to be used | 173 | * (instead of DNS or manual configuration, i.e. to be used |
174 | * if the IP keeps changing and we have no DynDNS, but we do | 174 | * if the IP keeps changing and we have no DynDNS, but we do |
175 | * have a hole punched). | 175 | * have a hole punched). |
176 | */ | 176 | */ |
@@ -183,9 +183,9 @@ struct ClientHandle | |||
183 | 183 | ||
184 | /** | 184 | /** |
185 | * Task for periodically re-running the @e ext_dns DNS lookup. | 185 | * Task for periodically re-running the @e ext_dns DNS lookup. |
186 | */ | 186 | */ |
187 | struct GNUNET_SCHEDULER_Task *ext_dns_task; | 187 | struct GNUNET_SCHEDULER_Task *ext_dns_task; |
188 | 188 | ||
189 | /** | 189 | /** |
190 | * Handle for (DYN)DNS lookup of our external IP as given in | 190 | * Handle for (DYN)DNS lookup of our external IP as given in |
191 | * @e hole_external. | 191 | * @e hole_external. |
@@ -196,7 +196,7 @@ struct ClientHandle | |||
196 | * Handle for monitoring external IP changes. | 196 | * Handle for monitoring external IP changes. |
197 | */ | 197 | */ |
198 | struct GN_ExternalIPMonitor *external_monitor; | 198 | struct GN_ExternalIPMonitor *external_monitor; |
199 | 199 | ||
200 | /** | 200 | /** |
201 | * DLL of external IP addresses as given in @e hole_external. | 201 | * DLL of external IP addresses as given in @e hole_external. |
202 | */ | 202 | */ |
@@ -209,9 +209,9 @@ struct ClientHandle | |||
209 | 209 | ||
210 | /** | 210 | /** |
211 | * Port number we found in @e hole_external. | 211 | * Port number we found in @e hole_external. |
212 | */ | 212 | */ |
213 | uint16_t ext_dns_port; | 213 | uint16_t ext_dns_port; |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * What does this client care about? | 216 | * What does this client care about? |
217 | */ | 217 | */ |
@@ -221,13 +221,13 @@ struct ClientHandle | |||
221 | * Is any of the @e caddrs in a reserved subnet for NAT? | 221 | * Is any of the @e caddrs in a reserved subnet for NAT? |
222 | */ | 222 | */ |
223 | int natted_address; | 223 | int natted_address; |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * Number of addresses that this service is bound to. | 226 | * Number of addresses that this service is bound to. |
227 | * Length of the @e caddrs array. | 227 | * Length of the @e caddrs array. |
228 | */ | 228 | */ |
229 | uint16_t num_caddrs; | 229 | uint16_t num_caddrs; |
230 | 230 | ||
231 | /** | 231 | /** |
232 | * Client's IPPROTO, e.g. IPPROTO_UDP or IPPROTO_TCP. | 232 | * Client's IPPROTO, e.g. IPPROTO_UDP or IPPROTO_TCP. |
233 | */ | 233 | */ |
@@ -243,12 +243,12 @@ struct StunExternalIP | |||
243 | { | 243 | { |
244 | /** | 244 | /** |
245 | * Kept in a DLL. | 245 | * Kept in a DLL. |
246 | */ | 246 | */ |
247 | struct StunExternalIP *next; | 247 | struct StunExternalIP *next; |
248 | 248 | ||
249 | /** | 249 | /** |
250 | * Kept in a DLL. | 250 | * Kept in a DLL. |
251 | */ | 251 | */ |
252 | struct StunExternalIP *prev; | 252 | struct StunExternalIP *prev; |
253 | 253 | ||
254 | /** | 254 | /** |
@@ -257,13 +257,13 @@ struct StunExternalIP | |||
257 | struct GNUNET_SCHEDULER_Task *timeout_task; | 257 | struct GNUNET_SCHEDULER_Task *timeout_task; |
258 | 258 | ||
259 | /** | 259 | /** |
260 | * Our external IP address as reported by the | 260 | * Our external IP address as reported by the |
261 | * STUN server. | 261 | * STUN server. |
262 | */ | 262 | */ |
263 | struct sockaddr_in external_addr; | 263 | struct sockaddr_in external_addr; |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * Address of the reporting STUN server. Used to | 266 | * Address of the reporting STUN server. Used to |
267 | * detect when a STUN server changes its opinion | 267 | * detect when a STUN server changes its opinion |
268 | * to more quickly remove stale results. | 268 | * to more quickly remove stale results. |
269 | */ | 269 | */ |
@@ -305,7 +305,7 @@ static struct GNUNET_SCHEDULER_Task *scan_task; | |||
305 | * Head of client DLL. | 305 | * Head of client DLL. |
306 | */ | 306 | */ |
307 | static struct ClientHandle *ch_head; | 307 | static struct ClientHandle *ch_head; |
308 | 308 | ||
309 | /** | 309 | /** |
310 | * Tail of client DLL. | 310 | * Tail of client DLL. |
311 | */ | 311 | */ |
@@ -323,12 +323,12 @@ static struct LocalAddressList *lal_tail; | |||
323 | 323 | ||
324 | /** | 324 | /** |
325 | * Kept in a DLL. | 325 | * Kept in a DLL. |
326 | */ | 326 | */ |
327 | static struct StunExternalIP *se_head; | 327 | static struct StunExternalIP *se_head; |
328 | 328 | ||
329 | /** | 329 | /** |
330 | * Kept in a DLL. | 330 | * Kept in a DLL. |
331 | */ | 331 | */ |
332 | static struct StunExternalIP *se_tail; | 332 | static struct StunExternalIP *se_tail; |
333 | 333 | ||
334 | /** | 334 | /** |
@@ -365,7 +365,7 @@ free_lal (struct LocalAddressList *lal) | |||
365 | 365 | ||
366 | /** | 366 | /** |
367 | * Free the DLL starting at #lal_head. | 367 | * Free the DLL starting at #lal_head. |
368 | */ | 368 | */ |
369 | static void | 369 | static void |
370 | destroy_lal () | 370 | destroy_lal () |
371 | { | 371 | { |
@@ -417,12 +417,12 @@ check_register (void *cls, | |||
417 | #endif | 417 | #endif |
418 | default: | 418 | default: |
419 | GNUNET_break (0); | 419 | GNUNET_break (0); |
420 | return GNUNET_SYSERR; | 420 | return GNUNET_SYSERR; |
421 | } | 421 | } |
422 | if (alen > left) | 422 | if (alen > left) |
423 | { | 423 | { |
424 | GNUNET_break (0); | 424 | GNUNET_break (0); |
425 | return GNUNET_SYSERR; | 425 | return GNUNET_SYSERR; |
426 | } | 426 | } |
427 | off += alen; | 427 | off += alen; |
428 | left -= alen; | 428 | left -= alen; |
@@ -430,9 +430,9 @@ check_register (void *cls, | |||
430 | if (left != ntohs (message->str_len)) | 430 | if (left != ntohs (message->str_len)) |
431 | { | 431 | { |
432 | GNUNET_break (0); | 432 | GNUNET_break (0); |
433 | return GNUNET_SYSERR; | 433 | return GNUNET_SYSERR; |
434 | } | 434 | } |
435 | return GNUNET_OK; | 435 | return GNUNET_OK; |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
@@ -478,7 +478,7 @@ match_ipv6 (const char *network, | |||
478 | struct in6_addr net; | 478 | struct in6_addr net; |
479 | struct in6_addr mask; | 479 | struct in6_addr mask; |
480 | unsigned int off; | 480 | unsigned int off; |
481 | 481 | ||
482 | if (0 == bits) | 482 | if (0 == bits) |
483 | return GNUNET_YES; | 483 | return GNUNET_YES; |
484 | GNUNET_assert (1 == inet_pton (AF_INET6, | 484 | GNUNET_assert (1 == inet_pton (AF_INET6, |
@@ -550,7 +550,7 @@ is_nat_v6 (const struct in6_addr *ip) | |||
550 | struct IfcProcContext | 550 | struct IfcProcContext |
551 | { | 551 | { |
552 | 552 | ||
553 | /** | 553 | /** |
554 | * Head of DLL of local addresses. | 554 | * Head of DLL of local addresses. |
555 | */ | 555 | */ |
556 | struct LocalAddressList *lal_head; | 556 | struct LocalAddressList *lal_head; |
@@ -661,7 +661,7 @@ notify_client (enum GNUNET_NAT_AddressClass ac, | |||
661 | { | 661 | { |
662 | struct GNUNET_MQ_Envelope *env; | 662 | struct GNUNET_MQ_Envelope *env; |
663 | struct GNUNET_NAT_AddressChangeNotificationMessage *msg; | 663 | struct GNUNET_NAT_AddressChangeNotificationMessage *msg; |
664 | 664 | ||
665 | env = GNUNET_MQ_msg_extra (msg, | 665 | env = GNUNET_MQ_msg_extra (msg, |
666 | addr_len, | 666 | addr_len, |
667 | GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE); | 667 | GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE); |
@@ -672,7 +672,7 @@ notify_client (enum GNUNET_NAT_AddressClass ac, | |||
672 | addr_len); | 672 | addr_len); |
673 | GNUNET_MQ_send (ch->mq, | 673 | GNUNET_MQ_send (ch->mq, |
674 | env); | 674 | env); |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | /** | 678 | /** |
@@ -691,7 +691,7 @@ check_notify_client (struct LocalAddressList *delta, | |||
691 | size_t alen; | 691 | size_t alen; |
692 | struct sockaddr_in v4; | 692 | struct sockaddr_in v4; |
693 | struct sockaddr_in6 v6; | 693 | struct sockaddr_in6 v6; |
694 | 694 | ||
695 | if (0 == (ch->flags & GNUNET_NAT_RF_ADDRESSES)) | 695 | if (0 == (ch->flags & GNUNET_NAT_RF_ADDRESSES)) |
696 | return; | 696 | return; |
697 | switch (delta->af) | 697 | switch (delta->af) |
@@ -701,7 +701,7 @@ check_notify_client (struct LocalAddressList *delta, | |||
701 | GNUNET_memcpy (&v4, | 701 | GNUNET_memcpy (&v4, |
702 | &delta->addr, | 702 | &delta->addr, |
703 | alen); | 703 | alen); |
704 | 704 | ||
705 | /* Check for client notifications */ | 705 | /* Check for client notifications */ |
706 | for (unsigned int i=0;i<ch->num_caddrs;i++) | 706 | for (unsigned int i=0;i<ch->num_caddrs;i++) |
707 | { | 707 | { |
@@ -749,7 +749,7 @@ check_notify_client (struct LocalAddressList *delta, | |||
749 | for (unsigned int i=0;i<ch->num_caddrs;i++) | 749 | for (unsigned int i=0;i<ch->num_caddrs;i++) |
750 | { | 750 | { |
751 | const struct sockaddr_in6 *c6; | 751 | const struct sockaddr_in6 *c6; |
752 | 752 | ||
753 | if (AF_INET6 != ch->caddrs[i].ss.ss_family) | 753 | if (AF_INET6 != ch->caddrs[i].ss.ss_family) |
754 | continue; /* IPv4 not relevant */ | 754 | continue; /* IPv4 not relevant */ |
755 | c6 = (const struct sockaddr_in6 *) &ch->caddrs[i].ss; | 755 | c6 = (const struct sockaddr_in6 *) &ch->caddrs[i].ss; |
@@ -831,7 +831,7 @@ notify_clients (struct LocalAddressList *delta, | |||
831 | /** | 831 | /** |
832 | * Tell relevant client about a change in our external | 832 | * Tell relevant client about a change in our external |
833 | * IPv4 address. | 833 | * IPv4 address. |
834 | * | 834 | * |
835 | * @param cls client to check if it cares and possibly notify | 835 | * @param cls client to check if it cares and possibly notify |
836 | * @param v4 the external address that changed | 836 | * @param v4 the external address that changed |
837 | * @param add #GNUNET_YES to add, #GNUNET_NO to remove | 837 | * @param add #GNUNET_YES to add, #GNUNET_NO to remove |
@@ -852,7 +852,7 @@ notify_client_external_ipv4_change (void *cls, | |||
852 | { | 852 | { |
853 | struct LocalAddressList lal; | 853 | struct LocalAddressList lal; |
854 | struct sockaddr_in *s4; | 854 | struct sockaddr_in *s4; |
855 | 855 | ||
856 | memset (&lal, 0, sizeof (lal)); | 856 | memset (&lal, 0, sizeof (lal)); |
857 | s4 = (struct sockaddr_in *) &lal.addr; | 857 | s4 = (struct sockaddr_in *) &lal.addr; |
858 | s4->sin_family = AF_INET; | 858 | s4->sin_family = AF_INET; |
@@ -864,7 +864,7 @@ notify_client_external_ipv4_change (void *cls, | |||
864 | ch, | 864 | ch, |
865 | add); | 865 | add); |
866 | } | 866 | } |
867 | 867 | ||
868 | /* (1) check if client cares. */ | 868 | /* (1) check if client cares. */ |
869 | if (! ch->natted_address) | 869 | if (! ch->natted_address) |
870 | return; | 870 | return; |
@@ -890,10 +890,10 @@ notify_client_external_ipv4_change (void *cls, | |||
890 | sa.sin_family = AF_INET; | 890 | sa.sin_family = AF_INET; |
891 | sa.sin_addr = *v4; | 891 | sa.sin_addr = *v4; |
892 | sa.sin_port = htons (0); | 892 | sa.sin_port = htons (0); |
893 | 893 | ||
894 | /* (3) notify client of change */ | 894 | /* (3) notify client of change */ |
895 | notify_client (is_nat_v4 (v4) | 895 | notify_client (is_nat_v4 (v4) |
896 | ? GNUNET_NAT_AC_EXTERN | GNUNET_NAT_AC_LAN | 896 | ? GNUNET_NAT_AC_EXTERN | GNUNET_NAT_AC_LAN |
897 | : GNUNET_NAT_AC_EXTERN | GNUNET_NAT_AC_GLOBAL, | 897 | : GNUNET_NAT_AC_EXTERN | GNUNET_NAT_AC_GLOBAL, |
898 | ch, | 898 | ch, |
899 | add, | 899 | add, |
@@ -906,8 +906,8 @@ notify_client_external_ipv4_change (void *cls, | |||
906 | * We got a connection reversal request from another peer. | 906 | * We got a connection reversal request from another peer. |
907 | * Notify applicable clients. | 907 | * Notify applicable clients. |
908 | * | 908 | * |
909 | * @param cls closure with the `struct LocalAddressList` | 909 | * @param cls closure with the `struct LocalAddressList` |
910 | * @param ra IP address of the peer who wants us to connect to it | 910 | * @param ra IP address of the peer who wants us to connect to it |
911 | */ | 911 | */ |
912 | static void | 912 | static void |
913 | reversal_callback (void *cls, | 913 | reversal_callback (void *cls, |
@@ -921,7 +921,7 @@ reversal_callback (void *cls, | |||
921 | for (struct ClientHandle *ch = ch_head; | 921 | for (struct ClientHandle *ch = ch_head; |
922 | NULL != ch; | 922 | NULL != ch; |
923 | ch = ch->next) | 923 | ch = ch->next) |
924 | { | 924 | { |
925 | struct GNUNET_NAT_ConnectionReversalRequestedMessage *crrm; | 925 | struct GNUNET_NAT_ConnectionReversalRequestedMessage *crrm; |
926 | struct GNUNET_MQ_Envelope *env; | 926 | struct GNUNET_MQ_Envelope *env; |
927 | int match; | 927 | int match; |
@@ -935,7 +935,7 @@ reversal_callback (void *cls, | |||
935 | { | 935 | { |
936 | struct ClientAddress *ca = &ch->caddrs[i]; | 936 | struct ClientAddress *ca = &ch->caddrs[i]; |
937 | const struct sockaddr_in *c4; | 937 | const struct sockaddr_in *c4; |
938 | 938 | ||
939 | if (AF_INET != ca->ss.ss_family) | 939 | if (AF_INET != ca->ss.ss_family) |
940 | continue; | 940 | continue; |
941 | c4 = (const struct sockaddr_in *) &ca->ss; | 941 | c4 = (const struct sockaddr_in *) &ca->ss; |
@@ -965,7 +965,7 @@ reversal_callback (void *cls, | |||
965 | * Task we run periodically to scan for network interfaces. | 965 | * Task we run periodically to scan for network interfaces. |
966 | * | 966 | * |
967 | * @param cls NULL | 967 | * @param cls NULL |
968 | */ | 968 | */ |
969 | static void | 969 | static void |
970 | run_scan (void *cls) | 970 | run_scan (void *cls) |
971 | { | 971 | { |
@@ -973,7 +973,7 @@ run_scan (void *cls) | |||
973 | int found; | 973 | int found; |
974 | int have_nat; | 974 | int have_nat; |
975 | struct LocalAddressList *lnext; | 975 | struct LocalAddressList *lnext; |
976 | 976 | ||
977 | scan_task = GNUNET_SCHEDULER_add_delayed (SCAN_FREQ, | 977 | scan_task = GNUNET_SCHEDULER_add_delayed (SCAN_FREQ, |
978 | &run_scan, | 978 | &run_scan, |
979 | NULL); | 979 | NULL); |
@@ -1052,7 +1052,7 @@ run_scan (void *cls) | |||
1052 | { | 1052 | { |
1053 | const struct sockaddr_in *s4 | 1053 | const struct sockaddr_in *s4 |
1054 | = (const struct sockaddr_in *) &pos->addr; | 1054 | = (const struct sockaddr_in *) &pos->addr; |
1055 | 1055 | ||
1056 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1056 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1057 | "Found NATed local address %s, starting NAT server\n", | 1057 | "Found NATed local address %s, starting NAT server\n", |
1058 | GNUNET_a2s ((void *) &pos->addr, sizeof (*s4))); | 1058 | GNUNET_a2s ((void *) &pos->addr, sizeof (*s4))); |
@@ -1153,9 +1153,9 @@ upnp_addr_change_cb (void *cls, | |||
1153 | 1153 | ||
1154 | 1154 | ||
1155 | /** | 1155 | /** |
1156 | * Resolve the `hole_external` name to figure out our | 1156 | * Resolve the `hole_external` name to figure out our |
1157 | * external address from a manually punched hole. The | 1157 | * external address from a manually punched hole. The |
1158 | * port number has already been parsed, this task is | 1158 | * port number has already been parsed, this task is |
1159 | * responsible for periodically doing a DNS lookup. | 1159 | * responsible for periodically doing a DNS lookup. |
1160 | * | 1160 | * |
1161 | * @param ch client handle to act upon | 1161 | * @param ch client handle to act upon |
@@ -1187,9 +1187,9 @@ process_external_ip (void *cls, | |||
1187 | if (NULL == addr) | 1187 | if (NULL == addr) |
1188 | { | 1188 | { |
1189 | struct LocalAddressList *laln; | 1189 | struct LocalAddressList *laln; |
1190 | 1190 | ||
1191 | ch->ext_dns = NULL; | 1191 | ch->ext_dns = NULL; |
1192 | ch->ext_dns_task | 1192 | ch->ext_dns_task |
1193 | = GNUNET_SCHEDULER_add_delayed (dyndns_frequency, | 1193 | = GNUNET_SCHEDULER_add_delayed (dyndns_frequency, |
1194 | &dyndns_lookup, | 1194 | &dyndns_lookup, |
1195 | ch); | 1195 | ch); |
@@ -1215,7 +1215,7 @@ process_external_ip (void *cls, | |||
1215 | GNUNET_a2s (addr, | 1215 | GNUNET_a2s (addr, |
1216 | addrlen), | 1216 | addrlen), |
1217 | ch->hole_external); | 1217 | ch->hole_external); |
1218 | 1218 | ||
1219 | /* build sockaddr storage with port number */ | 1219 | /* build sockaddr storage with port number */ |
1220 | memset (&ss, 0, sizeof (ss)); | 1220 | memset (&ss, 0, sizeof (ss)); |
1221 | memcpy (&ss, addr, addrlen); | 1221 | memcpy (&ss, addr, addrlen); |
@@ -1263,9 +1263,9 @@ process_external_ip (void *cls, | |||
1263 | 1263 | ||
1264 | 1264 | ||
1265 | /** | 1265 | /** |
1266 | * Resolve the `hole_external` name to figure out our | 1266 | * Resolve the `hole_external` name to figure out our |
1267 | * external address from a manually punched hole. The | 1267 | * external address from a manually punched hole. The |
1268 | * port number has already been parsed, this task is | 1268 | * port number has already been parsed, this task is |
1269 | * responsible for periodically doing a DNS lookup. | 1269 | * responsible for periodically doing a DNS lookup. |
1270 | * | 1270 | * |
1271 | * @param ch client handle to act upon | 1271 | * @param ch client handle to act upon |
@@ -1283,16 +1283,16 @@ dyndns_lookup (void *cls) | |||
1283 | AF_UNSPEC, | 1283 | AF_UNSPEC, |
1284 | GNUNET_TIME_UNIT_MINUTES, | 1284 | GNUNET_TIME_UNIT_MINUTES, |
1285 | &process_external_ip, | 1285 | &process_external_ip, |
1286 | ch); | 1286 | ch); |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | 1289 | ||
1290 | /** | 1290 | /** |
1291 | * Resolve the `hole_external` name to figure out our | 1291 | * Resolve the `hole_external` name to figure out our |
1292 | * external address from a manually punched hole. The | 1292 | * external address from a manually punched hole. The |
1293 | * given name may be "AUTO" in which case we should use | 1293 | * given name may be "AUTO" in which case we should use |
1294 | * the IP address(es) we have from upnpc or other methods. | 1294 | * the IP address(es) we have from upnpc or other methods. |
1295 | * The name can also be an IP address, in which case we | 1295 | * The name can also be an IP address, in which case we |
1296 | * do not need to do DNS resolution. Finally, we also | 1296 | * do not need to do DNS resolution. Finally, we also |
1297 | * need to parse the port number. | 1297 | * need to parse the port number. |
1298 | * | 1298 | * |
@@ -1305,7 +1305,7 @@ lookup_hole_external (struct ClientHandle *ch) | |||
1305 | unsigned int pnum; | 1305 | unsigned int pnum; |
1306 | struct sockaddr_in *s4; | 1306 | struct sockaddr_in *s4; |
1307 | struct LocalAddressList *lal; | 1307 | struct LocalAddressList *lal; |
1308 | 1308 | ||
1309 | port = strrchr (ch->hole_external, ':'); | 1309 | port = strrchr (ch->hole_external, ':'); |
1310 | if (NULL == port) | 1310 | if (NULL == port) |
1311 | { | 1311 | { |
@@ -1322,7 +1322,7 @@ lookup_hole_external (struct ClientHandle *ch) | |||
1322 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1322 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1323 | _("Invalid port number in punched hole specification `%s' (lacks port)\n"), | 1323 | _("Invalid port number in punched hole specification `%s' (lacks port)\n"), |
1324 | port + 1); | 1324 | port + 1); |
1325 | return; | 1325 | return; |
1326 | } | 1326 | } |
1327 | ch->ext_dns_port = (uint16_t) pnum; | 1327 | ch->ext_dns_port = (uint16_t) pnum; |
1328 | *port = '\0'; | 1328 | *port = '\0'; |
@@ -1392,7 +1392,7 @@ lookup_hole_external (struct ClientHandle *ch) | |||
1392 | GNUNET_free (lal); | 1392 | GNUNET_free (lal); |
1393 | ch->ext_dns_task | 1393 | ch->ext_dns_task |
1394 | = GNUNET_SCHEDULER_add_now (&dyndns_lookup, | 1394 | = GNUNET_SCHEDULER_add_now (&dyndns_lookup, |
1395 | ch); | 1395 | ch); |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | 1398 | ||
@@ -1447,7 +1447,7 @@ handle_register (void *cls, | |||
1447 | case AF_INET: | 1447 | case AF_INET: |
1448 | { | 1448 | { |
1449 | const struct sockaddr_in *s4 = (const struct sockaddr_in *) sa; | 1449 | const struct sockaddr_in *s4 = (const struct sockaddr_in *) sa; |
1450 | 1450 | ||
1451 | alen = sizeof (struct sockaddr_in); | 1451 | alen = sizeof (struct sockaddr_in); |
1452 | if (is_nat_v4 (&s4->sin_addr)) | 1452 | if (is_nat_v4 (&s4->sin_addr)) |
1453 | is_nat = GNUNET_YES; | 1453 | is_nat = GNUNET_YES; |
@@ -1457,7 +1457,7 @@ handle_register (void *cls, | |||
1457 | case AF_INET6: | 1457 | case AF_INET6: |
1458 | { | 1458 | { |
1459 | const struct sockaddr_in6 *s6 = (const struct sockaddr_in6 *) sa; | 1459 | const struct sockaddr_in6 *s6 = (const struct sockaddr_in6 *) sa; |
1460 | 1460 | ||
1461 | alen = sizeof (struct sockaddr_in6); | 1461 | alen = sizeof (struct sockaddr_in6); |
1462 | if (is_nat_v6 (&s6->sin6_addr)) | 1462 | if (is_nat_v6 (&s6->sin6_addr)) |
1463 | is_nat = GNUNET_YES; | 1463 | is_nat = GNUNET_YES; |
@@ -1473,14 +1473,14 @@ handle_register (void *cls, | |||
1473 | default: | 1473 | default: |
1474 | GNUNET_break (0); | 1474 | GNUNET_break (0); |
1475 | GNUNET_SERVICE_client_drop (ch->client); | 1475 | GNUNET_SERVICE_client_drop (ch->client); |
1476 | return; | 1476 | return; |
1477 | } | 1477 | } |
1478 | /* store address */ | 1478 | /* store address */ |
1479 | GNUNET_assert (alen <= left); | 1479 | GNUNET_assert (alen <= left); |
1480 | GNUNET_assert (alen <= sizeof (struct sockaddr_storage)); | 1480 | GNUNET_assert (alen <= sizeof (struct sockaddr_storage)); |
1481 | GNUNET_memcpy (&ch->caddrs[i].ss, | 1481 | GNUNET_memcpy (&ch->caddrs[i].ss, |
1482 | sa, | 1482 | sa, |
1483 | alen); | 1483 | alen); |
1484 | 1484 | ||
1485 | /* If applicable, try UPNPC NAT punching */ | 1485 | /* If applicable, try UPNPC NAT punching */ |
1486 | if ( (is_nat) && | 1486 | if ( (is_nat) && |
@@ -1508,7 +1508,7 @@ handle_register (void *cls, | |||
1508 | "HOLE_EXTERNAL", | 1508 | "HOLE_EXTERNAL", |
1509 | &ch->hole_external)) | 1509 | &ch->hole_external)) |
1510 | lookup_hole_external (ch); | 1510 | lookup_hole_external (ch); |
1511 | 1511 | ||
1512 | /* Actually send IP address list to client */ | 1512 | /* Actually send IP address list to client */ |
1513 | for (struct LocalAddressList *lal = lal_head; | 1513 | for (struct LocalAddressList *lal = lal_head; |
1514 | NULL != lal; | 1514 | NULL != lal; |
@@ -1540,7 +1540,7 @@ check_stun (void *cls, | |||
1540 | { | 1540 | { |
1541 | size_t sa_len = ntohs (message->sender_addr_size); | 1541 | size_t sa_len = ntohs (message->sender_addr_size); |
1542 | size_t expect = sa_len + ntohs (message->payload_size); | 1542 | size_t expect = sa_len + ntohs (message->payload_size); |
1543 | 1543 | ||
1544 | if (ntohs (message->header.size) - sizeof (*message) != expect) | 1544 | if (ntohs (message->header.size) - sizeof (*message) != expect) |
1545 | { | 1545 | { |
1546 | GNUNET_break (0); | 1546 | GNUNET_break (0); |
@@ -1573,7 +1573,7 @@ notify_clients_stun_change (const struct sockaddr_in *ip, | |||
1573 | struct sockaddr_in v4; | 1573 | struct sockaddr_in v4; |
1574 | struct GNUNET_NAT_AddressChangeNotificationMessage *msg; | 1574 | struct GNUNET_NAT_AddressChangeNotificationMessage *msg; |
1575 | struct GNUNET_MQ_Envelope *env; | 1575 | struct GNUNET_MQ_Envelope *env; |
1576 | 1576 | ||
1577 | if (! ch->natted_address) | 1577 | if (! ch->natted_address) |
1578 | continue; | 1578 | continue; |
1579 | v4 = *ip; | 1579 | v4 = *ip; |
@@ -1663,9 +1663,9 @@ handle_stun (void *cls, | |||
1663 | GNUNET_NAT_stun_handle_packet_ (payload, | 1663 | GNUNET_NAT_stun_handle_packet_ (payload, |
1664 | payload_size, | 1664 | payload_size, |
1665 | &external_addr)) | 1665 | &external_addr)) |
1666 | { | 1666 | { |
1667 | /* We now know that a server at "sa" claims that | 1667 | /* We now know that a server at "sa" claims that |
1668 | we are visible at IP "external_addr". | 1668 | we are visible at IP "external_addr". |
1669 | 1669 | ||
1670 | We should (for some fixed period of time) tell | 1670 | We should (for some fixed period of time) tell |
1671 | all of our clients that listen to a NAT'ed address | 1671 | all of our clients that listen to a NAT'ed address |
@@ -1771,7 +1771,7 @@ handle_request_connection_reversal (void *cls, | |||
1771 | struct sockaddr_in l4; | 1771 | struct sockaddr_in l4; |
1772 | struct sockaddr_in r4; | 1772 | struct sockaddr_in r4; |
1773 | int ret; | 1773 | int ret; |
1774 | 1774 | ||
1775 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1775 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1776 | "Received REQUEST CONNECTION REVERSAL message from client\n"); | 1776 | "Received REQUEST CONNECTION REVERSAL message from client\n"); |
1777 | if (local_sa_len != sizeof (struct sockaddr_in)) | 1777 | if (local_sa_len != sizeof (struct sockaddr_in)) |
@@ -1800,7 +1800,7 @@ handle_request_connection_reversal (void *cls, | |||
1800 | &r4.sin_addr); | 1800 | &r4.sin_addr); |
1801 | if (GNUNET_OK != ret) | 1801 | if (GNUNET_OK != ret) |
1802 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1802 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1803 | _("Connection reversal request failed\n")); | 1803 | _("Connection reversal request failed\n")); |
1804 | GNUNET_SERVICE_client_continue (ch->client); | 1804 | GNUNET_SERVICE_client_continue (ch->client); |
1805 | } | 1805 | } |
1806 | 1806 | ||
@@ -1860,7 +1860,7 @@ run (void *cls, | |||
1860 | stun_stale_timeout = GNUNET_TIME_UNIT_HOURS; | 1860 | stun_stale_timeout = GNUNET_TIME_UNIT_HOURS; |
1861 | 1861 | ||
1862 | /* Check for UPnP */ | 1862 | /* Check for UPnP */ |
1863 | enable_upnp | 1863 | enable_upnp |
1864 | = GNUNET_CONFIGURATION_get_value_yesno (cfg, | 1864 | = GNUNET_CONFIGURATION_get_value_yesno (cfg, |
1865 | "NAT", | 1865 | "NAT", |
1866 | "ENABLE_UPNP"); | 1866 | "ENABLE_UPNP"); |
@@ -1883,7 +1883,7 @@ run (void *cls, | |||
1883 | "DYNDNS_FREQUENCY", | 1883 | "DYNDNS_FREQUENCY", |
1884 | &dyndns_frequency)) | 1884 | &dyndns_frequency)) |
1885 | dyndns_frequency = DYNDNS_FREQUENCY; | 1885 | dyndns_frequency = DYNDNS_FREQUENCY; |
1886 | 1886 | ||
1887 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 1887 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1888 | NULL); | 1888 | NULL); |
1889 | stats = GNUNET_STATISTICS_create ("nat", | 1889 | stats = GNUNET_STATISTICS_create ("nat", |