gnunet-service-nat_helper.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file nat/gnunet-service-nat_helper.h
  18. * @brief runs the gnunet-helper-nat-server
  19. * @author Milan Bouchet-Valat
  20. * @author Christian Grothoff
  21. */
  22. #include "platform.h"
  23. #include "gnunet_util_lib.h"
  24. /**
  25. * Information we keep per NAT helper process.
  26. */
  27. struct HelperContext;
  28. /**
  29. * Function called whenever we get a connection reversal
  30. * request from another peer.
  31. *
  32. * @param cls closure
  33. * @param ra IP address of the peer who wants us to connect to it
  34. */
  35. typedef void
  36. (*GN_ReversalCallback) (void *cls,
  37. const struct sockaddr_in *ra);
  38. /**
  39. * Start the gnunet-helper-nat-server and process incoming
  40. * requests.
  41. *
  42. * @param internal_address
  43. * @param cb function to call if we receive a request
  44. * @param cb_cls closure for @a cb
  45. * @param cfg handle to the GNUnet configuration
  46. * @return NULL on error
  47. */
  48. struct HelperContext *
  49. GN_start_gnunet_nat_server_ (const struct in_addr *internal_address,
  50. GN_ReversalCallback cb,
  51. void *cb_cls,
  52. const struct GNUNET_CONFIGURATION_Handle *cfg);
  53. /**
  54. * Start the gnunet-helper-nat-server and process incoming
  55. * requests.
  56. *
  57. * @param h helper context to stop
  58. */
  59. void
  60. GN_stop_gnunet_nat_server_ (struct HelperContext *h);
  61. /**
  62. * We want to connect to a peer that is behind NAT. Run the
  63. * gnunet-helper-nat-client to send dummy ICMP responses to cause
  64. * that peer to connect to us (connection reversal).
  65. *
  66. * @param internal_address out internal address to use
  67. * @param internal_port internal port to use
  68. * @param remote_v4 the address of the peer (IPv4-only)
  69. * @param cfg handle to the GNUnet configuration
  70. * @return #GNUNET_SYSERR on error,
  71. * #GNUNET_OK otherwise
  72. */
  73. int
  74. GN_request_connection_reversal (const struct in_addr *internal_address,
  75. uint16_t internal_port,
  76. const struct in_addr *remote_v4,
  77. const struct GNUNET_CONFIGURATION_Handle *cfg);
  78. /* end of gnunet-service-nat_helper.h */