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.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c
index 4622b1428..20e7b6ec6 100644
--- a/src/nat/nat_api.c
+++ b/src/nat/nat_api.c
@@ -311,7 +311,8 @@ handle_address_change_notification (
311 * @param error details about the error 311 * @param error details about the error
312 */ 312 */
313static void 313static void
314mq_error_handler (void *cls, enum GNUNET_MQ_Error error) 314mq_error_handler (void *cls,
315 enum GNUNET_MQ_Error error)
315{ 316{
316 struct GNUNET_NAT_Handle *nh = cls; 317 struct GNUNET_NAT_Handle *nh = cls;
317 318
@@ -328,29 +329,36 @@ static void
328do_connect (void *cls) 329do_connect (void *cls)
329{ 330{
330 struct GNUNET_NAT_Handle *nh = cls; 331 struct GNUNET_NAT_Handle *nh = cls;
331 struct GNUNET_MQ_MessageHandler handlers[] = 332 struct GNUNET_MQ_MessageHandler handlers[] = {
332 { GNUNET_MQ_hd_var_size (connection_reversal_request, 333 GNUNET_MQ_hd_var_size (
333 GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED, 334 connection_reversal_request,
334 struct 335 GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED,
335 GNUNET_NAT_ConnectionReversalRequestedMessage, 336 struct GNUNET_NAT_ConnectionReversalRequestedMessage,
336 nh), 337 nh),
337 GNUNET_MQ_hd_var_size (address_change_notification, 338 GNUNET_MQ_hd_var_size (
338 GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE, 339 address_change_notification,
339 struct GNUNET_NAT_AddressChangeNotificationMessage, 340 GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE,
340 nh), 341 struct GNUNET_NAT_AddressChangeNotificationMessage,
341 GNUNET_MQ_handler_end () }; 342 nh),
343 GNUNET_MQ_handler_end ()
344 };
342 struct GNUNET_MQ_Envelope *env; 345 struct GNUNET_MQ_Envelope *env;
343 346
344 nh->reconnect_task = NULL; 347 nh->reconnect_task = NULL;
345 nh->mq = 348 nh->mq =
346 GNUNET_CLIENT_connect (nh->cfg, "nat", handlers, &mq_error_handler, nh); 349 GNUNET_CLIENT_connect (nh->cfg,
350 "nat",
351 handlers,
352 &mq_error_handler,
353 nh);
347 if (NULL == nh->mq) 354 if (NULL == nh->mq)
348 { 355 {
349 reconnect (nh); 356 reconnect (nh);
350 return; 357 return;
351 } 358 }
352 env = GNUNET_MQ_msg_copy (nh->reg); 359 env = GNUNET_MQ_msg_copy (nh->reg);
353 GNUNET_MQ_send (nh->mq, env); 360 GNUNET_MQ_send (nh->mq,
361 env);
354} 362}
355 363
356 364
@@ -396,8 +404,9 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
396 len += addrlens[i]; 404 len += addrlens[i];
397 str_len = strlen (config_section) + 1; 405 str_len = strlen (config_section) + 1;
398 len += str_len; 406 len += str_len;
399 if ((len > GNUNET_MAX_MESSAGE_SIZE - sizeof(*rm)) || 407 if ( (len > GNUNET_MAX_MESSAGE_SIZE - sizeof(*rm)) ||
400 (num_addrs > UINT16_MAX)) 408 (num_addrs > UINT16_MAX) ||
409 (str_len > UINT16_MAX) )
401 { 410 {
402 GNUNET_break (0); 411 GNUNET_break (0);
403 return NULL; 412 return NULL;
@@ -475,7 +484,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
475 * @return #GNUNET_YES if @a data is a STUN packet, 484 * @return #GNUNET_YES if @a data is a STUN packet,
476 * #GNUNET_NO if the packet is invalid (not a stun packet) 485 * #GNUNET_NO if the packet is invalid (not a stun packet)
477 */ 486 */
478static int 487static enum GNUNET_GenericReturnValue
479test_stun_packet (const void *data, size_t len) 488test_stun_packet (const void *data, size_t len)
480{ 489{
481 const struct stun_header *hdr; 490 const struct stun_header *hdr;