diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-05 21:23:02 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-05 21:23:02 +0100 |
commit | 1b7f6eea0a06abab9b75b30f021aa6313fccfcd4 (patch) | |
tree | 0d726dbd6650997c22a7c17ce833ce53c23bde9e /src/nat/nat_api.c | |
parent | 07d7291d64688ecf9ef0bf2b663b10a168d5fff2 (diff) | |
download | gnunet-1b7f6eea0a06abab9b75b30f021aa6313fccfcd4.tar.gz gnunet-1b7f6eea0a06abab9b75b30f021aa6313fccfcd4.zip |
pass section name instead of specific option via IPC
Diffstat (limited to 'src/nat/nat_api.c')
-rw-r--r-- | src/nat/nat_api.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c index 008ad19e4..06b4b99fa 100644 --- a/src/nat/nat_api.c +++ b/src/nat/nat_api.c | |||
@@ -368,8 +368,8 @@ do_connect (void *cls) | |||
368 | * address_callback for any 'plausible' external address. | 368 | * address_callback for any 'plausible' external address. |
369 | * | 369 | * |
370 | * @param cfg configuration to use | 370 | * @param cfg configuration to use |
371 | * @param config_section name of the configuration section for optionsx | ||
371 | * @param proto protocol this is about, IPPROTO_TCP or IPPROTO_UDP | 372 | * @param proto protocol this is about, IPPROTO_TCP or IPPROTO_UDP |
372 | * @param hole_external hostname and port of manually punched hole in NAT, otherwise NULL (or empty string) | ||
373 | * @param num_addrs number of addresses in @a addrs | 373 | * @param num_addrs number of addresses in @a addrs |
374 | * @param addrs list of local addresses packets should be redirected to | 374 | * @param addrs list of local addresses packets should be redirected to |
375 | * @param addrlens actual lengths of the addresses in @a addrs | 375 | * @param addrlens actual lengths of the addresses in @a addrs |
@@ -381,8 +381,8 @@ do_connect (void *cls) | |||
381 | */ | 381 | */ |
382 | struct GNUNET_NAT_Handle * | 382 | struct GNUNET_NAT_Handle * |
383 | GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | 383 | GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, |
384 | const char *config_section, | ||
384 | uint8_t proto, | 385 | uint8_t proto, |
385 | const char *hole_external, | ||
386 | unsigned int num_addrs, | 386 | unsigned int num_addrs, |
387 | const struct sockaddr **addrs, | 387 | const struct sockaddr **addrs, |
388 | const socklen_t *addrlens, | 388 | const socklen_t *addrlens, |
@@ -393,17 +393,14 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
393 | struct GNUNET_NAT_Handle *nh; | 393 | struct GNUNET_NAT_Handle *nh; |
394 | struct GNUNET_NAT_RegisterMessage *rm; | 394 | struct GNUNET_NAT_RegisterMessage *rm; |
395 | size_t len; | 395 | size_t len; |
396 | size_t hole_external_len; | 396 | size_t str_len; |
397 | char *off; | 397 | char *off; |
398 | 398 | ||
399 | len = 0; | 399 | len = 0; |
400 | for (unsigned int i=0;i<num_addrs;i++) | 400 | for (unsigned int i=0;i<num_addrs;i++) |
401 | len += addrlens[i]; | 401 | len += addrlens[i]; |
402 | hole_external_len | 402 | str_len = strlen (config_section) + 1; |
403 | = (NULL == hole_external) | 403 | len += str_len; |
404 | ? 0 | ||
405 | : strlen (hole_external); | ||
406 | len += hole_external_len; | ||
407 | if ( (len > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*rm)) || | 404 | if ( (len > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*rm)) || |
408 | (num_addrs > UINT16_MAX) ) | 405 | (num_addrs > UINT16_MAX) ) |
409 | { | 406 | { |
@@ -419,7 +416,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
419 | if (NULL != reversal_callback) | 416 | if (NULL != reversal_callback) |
420 | rm->flags |= GNUNET_NAT_RF_REVERSAL; | 417 | rm->flags |= GNUNET_NAT_RF_REVERSAL; |
421 | rm->proto = proto; | 418 | rm->proto = proto; |
422 | rm->hole_external_len = htons (hole_external_len); | 419 | rm->str_len = htons (str_len); |
423 | rm->num_addrs = htons ((uint16_t) num_addrs); | 420 | rm->num_addrs = htons ((uint16_t) num_addrs); |
424 | off = (char *) &rm[1]; | 421 | off = (char *) &rm[1]; |
425 | for (unsigned int i=0;i<num_addrs;i++) | 422 | for (unsigned int i=0;i<num_addrs;i++) |
@@ -459,8 +456,8 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
459 | off += addrlens[i]; | 456 | off += addrlens[i]; |
460 | } | 457 | } |
461 | GNUNET_memcpy (off, | 458 | GNUNET_memcpy (off, |
462 | hole_external, | 459 | config_section, |
463 | hole_external_len); | 460 | str_len); |
464 | 461 | ||
465 | nh = GNUNET_new (struct GNUNET_NAT_Handle); | 462 | nh = GNUNET_new (struct GNUNET_NAT_Handle); |
466 | nh->reg = &rm->header; | 463 | nh->reg = &rm->header; |