gnunet-service-nat_stun.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009, 2015, 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. * This code provides some support for doing STUN transactions. We
  18. * receive the simplest possible packet as the STUN server and try
  19. * to respond properly.
  20. *
  21. * All STUN packets start with a simple header made of a type,
  22. * length (excluding the header) and a 16-byte random transaction id.
  23. * Following the header we may have zero or more attributes, each
  24. * structured as a type, length and a value (whose format depends
  25. * on the type, but often contains addresses).
  26. * Of course all fields are in network format.
  27. *
  28. * This code was based on ministun.c.
  29. *
  30. * @file nat/gnunet-service-nat_stun.h
  31. * @brief Functions for STUN functionality
  32. * @author Bruno Souza Cabral
  33. */
  34. #ifndef GNUNET_SERVICE_NAT_STUN_H
  35. #define GNUNET_SERVICE_NAT_STUN_H
  36. #include "platform.h"
  37. /**
  38. * Handle an incoming STUN response. Do some basic sanity checks on
  39. * packet size and content, try to extract information.
  40. * At the moment this only processes BIND requests,
  41. * and returns the externally visible address of the original
  42. * request.
  43. *
  44. * @param data the packet
  45. * @param len the length of the packet in @a data
  46. * @param[out] arg sockaddr_in where we will set our discovered address
  47. * @return #GNUNET_OK on success,
  48. * #GNUNET_NO if the packet is invalid (not a stun packet)
  49. */
  50. int
  51. GNUNET_NAT_stun_handle_packet_ (const void *data,
  52. size_t len,
  53. struct sockaddr_in *arg);
  54. #endif