aboutsummaryrefslogtreecommitdiff
path: root/src/nat/nat_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nat/nat_api.c')
-rw-r--r--src/nat/nat_api.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c
index eec5d3968..69612584e 100644
--- a/src/nat/nat_api.c
+++ b/src/nat/nat_api.c
@@ -52,7 +52,7 @@ struct AddrEntry
52 * Address class of the address. 52 * Address class of the address.
53 */ 53 */
54 enum GNUNET_NAT_AddressClass ac; 54 enum GNUNET_NAT_AddressClass ac;
55 55
56 /** 56 /**
57 * Number of bytes that follow. 57 * Number of bytes that follow.
58 */ 58 */
@@ -70,7 +70,7 @@ struct GNUNET_NAT_Handle
70 * Configuration we use. 70 * Configuration we use.
71 */ 71 */
72 const struct GNUNET_CONFIGURATION_Handle *cfg; 72 const struct GNUNET_CONFIGURATION_Handle *cfg;
73 73
74 /** 74 /**
75 * Message queue for communicating with the NAT service. 75 * Message queue for communicating with the NAT service.
76 */ 76 */
@@ -80,7 +80,7 @@ struct GNUNET_NAT_Handle
80 * Our registration message. 80 * Our registration message.
81 */ 81 */
82 struct GNUNET_MessageHeader *reg; 82 struct GNUNET_MessageHeader *reg;
83 83
84 /** 84 /**
85 * Head of address DLL. 85 * Head of address DLL.
86 */ 86 */
@@ -95,12 +95,12 @@ struct GNUNET_NAT_Handle
95 * Function to call when our addresses change. 95 * Function to call when our addresses change.
96 */ 96 */
97 GNUNET_NAT_AddressCallback address_callback; 97 GNUNET_NAT_AddressCallback address_callback;
98 98
99 /** 99 /**
100 * Function to call when another peer requests connection reversal. 100 * Function to call when another peer requests connection reversal.
101 */ 101 */
102 GNUNET_NAT_ReversalCallback reversal_callback; 102 GNUNET_NAT_ReversalCallback reversal_callback;
103 103
104 /** 104 /**
105 * Closure for the various callbacks. 105 * Closure for the various callbacks.
106 */ 106 */
@@ -136,7 +136,7 @@ static void
136reconnect (struct GNUNET_NAT_Handle *nh) 136reconnect (struct GNUNET_NAT_Handle *nh)
137{ 137{
138 struct AddrEntry *ae; 138 struct AddrEntry *ae;
139 139
140 if (NULL != nh->mq) 140 if (NULL != nh->mq)
141 { 141 {
142 GNUNET_MQ_destroy (nh->mq); 142 GNUNET_MQ_destroy (nh->mq);
@@ -184,7 +184,7 @@ check_connection_reversal_request (void *cls,
184 return GNUNET_OK; 184 return GNUNET_OK;
185} 185}
186 186
187 187
188/** 188/**
189 * Handle connection reversal request. 189 * Handle connection reversal request.
190 * 190 *
@@ -247,7 +247,7 @@ check_address_change_notification (void *cls,
247 return GNUNET_OK; 247 return GNUNET_OK;
248} 248}
249 249
250 250
251/** 251/**
252 * Handle connection reversal request. 252 * Handle connection reversal request.
253 * 253 *
@@ -264,6 +264,8 @@ handle_address_change_notification (void *cls,
264 enum GNUNET_NAT_AddressClass ac; 264 enum GNUNET_NAT_AddressClass ac;
265 struct AddrEntry *ae; 265 struct AddrEntry *ae;
266 266
267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
268 "Received address change notification\n");
267 ac = (enum GNUNET_NAT_AddressClass) ntohl (acn->addr_class); 269 ac = (enum GNUNET_NAT_AddressClass) ntohl (acn->addr_class);
268 if (GNUNET_YES == ntohl (acn->add_remove)) 270 if (GNUNET_YES == ntohl (acn->add_remove))
269 { 271 {
@@ -395,13 +397,13 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
395 size_t len; 397 size_t len;
396 size_t str_len; 398 size_t str_len;
397 char *off; 399 char *off;
398 400
399 len = 0; 401 len = 0;
400 for (unsigned int i=0;i<num_addrs;i++) 402 for (unsigned int i=0;i<num_addrs;i++)
401 len += addrlens[i]; 403 len += addrlens[i];
402 str_len = strlen (config_section) + 1; 404 str_len = strlen (config_section) + 1;
403 len += str_len; 405 len += str_len;
404 if ( (len > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*rm)) || 406 if ( (len > GNUNET_MAX_MESSAGE_SIZE - sizeof (*rm)) ||
405 (num_addrs > UINT16_MAX) ) 407 (num_addrs > UINT16_MAX) )
406 { 408 {
407 GNUNET_break (0); 409 GNUNET_break (0);
@@ -427,6 +429,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
427 if (sizeof (struct sockaddr_in) != addrlens[i]) 429 if (sizeof (struct sockaddr_in) != addrlens[i])
428 { 430 {
429 GNUNET_break (0); 431 GNUNET_break (0);
432 GNUNET_free (rm);
430 return NULL; 433 return NULL;
431 } 434 }
432 break; 435 break;
@@ -434,6 +437,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
434 if (sizeof (struct sockaddr_in6) != addrlens[i]) 437 if (sizeof (struct sockaddr_in6) != addrlens[i])
435 { 438 {
436 GNUNET_break (0); 439 GNUNET_break (0);
440 GNUNET_free (rm);
437 return NULL; 441 return NULL;
438 } 442 }
439 break; 443 break;
@@ -442,12 +446,14 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
442 if (sizeof (struct sockaddr_un) != addrlens[i]) 446 if (sizeof (struct sockaddr_un) != addrlens[i])
443 { 447 {
444 GNUNET_break (0); 448 GNUNET_break (0);
449 GNUNET_free (rm);
445 return NULL; 450 return NULL;
446 } 451 }
447 break; 452 break;
448#endif 453#endif
449 default: 454 default:
450 GNUNET_break (0); 455 GNUNET_break (0);
456 GNUNET_free (rm);
451 return NULL; 457 return NULL;
452 } 458 }
453 GNUNET_memcpy (off, 459 GNUNET_memcpy (off,
@@ -569,7 +575,7 @@ test_stun_packet (const void *data,
569 * 575 *
570 * The function does some basic sanity checks on packet size and 576 * The function does some basic sanity checks on packet size and
571 * content, try to extract a bit of information. 577 * content, try to extract a bit of information.
572 * 578 *
573 * At the moment this only processes BIND requests, and returns the 579 * At the moment this only processes BIND requests, and returns the
574 * externally visible address of the request to the rest of the 580 * externally visible address of the request to the rest of the
575 * NAT logic. 581 * NAT logic.
@@ -663,7 +669,7 @@ GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *nh,
663 * @param nh handle (used for configuration) 669 * @param nh handle (used for configuration)
664 * @param local_sa our local address of the peer (IPv4-only) 670 * @param local_sa our local address of the peer (IPv4-only)
665 * @param remote_sa the remote address of the peer (IPv4-only) 671 * @param remote_sa the remote address of the peer (IPv4-only)
666 * @return #GNUNET_SYSERR on error, 672 * @return #GNUNET_SYSERR on error,
667 * #GNUNET_NO if connection reversal is unavailable, 673 * #GNUNET_NO if connection reversal is unavailable,
668 * #GNUNET_OK otherwise (presumably in progress) 674 * #GNUNET_OK otherwise (presumably in progress)
669 */ 675 */