gnunet_transport_hello_service.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009-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. * @author Christian Grothoff
  18. *
  19. * @file
  20. * obtain information about our current address
  21. *
  22. * @deprecated, in TNG applications should query PEERSTORE directly!
  23. *
  24. * @defgroup transport Transport service
  25. * address information
  26. *
  27. * @see [Documentation](https://gnunet.org/transport-service)
  28. *
  29. * @{
  30. */
  31. #ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H
  32. #define GNUNET_TRANSPORT_HELLO_SERVICE_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #if 0 /* keep Emacsens' auto-indent happy */
  36. }
  37. #endif
  38. #endif
  39. #include "gnunet_util_lib.h"
  40. #include "gnunet_ats_service.h"
  41. /**
  42. * Version number of the transport API.
  43. */
  44. #define GNUNET_TRANSPORT_HELLO_VERSION 0x00000000
  45. /**
  46. * Some addresses contain sensitive information or are
  47. * not suitable for global distribution. We use address
  48. * classes to filter addresses by which domain they make
  49. * sense to be used in. These are used in a bitmask.
  50. */
  51. enum GNUNET_TRANSPORT_AddressClass
  52. {
  53. /**
  54. * No address.
  55. */
  56. GNUNET_TRANSPORT_AC_NONE = 0,
  57. /**
  58. * Addresses that fall into no other category
  59. * (i.e. incoming which we cannot use elsewhere).
  60. */
  61. GNUNET_TRANSPORT_AC_OTHER = 1,
  62. /**
  63. * Addresses that are global and are insensitive
  64. * (i.e. IPv4).
  65. */
  66. GNUNET_TRANSPORT_AC_GLOBAL = 2,
  67. /**
  68. * Addresses that are global and are sensitive
  69. * (i.e. IPv6 with our MAC).
  70. */
  71. GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE = 4,
  72. /**
  73. * Addresses useful in the local wired network,
  74. * i.e. a MAC. Sensitive, but obvious to people nearby.
  75. * Useful for broadcasts.
  76. */
  77. GNUNET_TRANSPORT_AC_LAN = 8,
  78. /**
  79. * Addresses useful in the local wireless network,
  80. * i.e. a MAC. Sensitive, but obvious to people nearby.
  81. * Useful for broadcasts.
  82. */
  83. GNUNET_TRANSPORT_AC_WLAN = 16,
  84. /**
  85. * Addresses useful in the local bluetooth network. Sensitive, but
  86. * obvious to people nearby. Useful for broadcasts.
  87. */
  88. GNUNET_TRANSPORT_AC_BT = 32,
  89. /**
  90. * Bitmask for "any" address.
  91. */
  92. GNUNET_TRANSPORT_AC_ANY = 65535
  93. };
  94. /**
  95. * Function called whenever there is an update to the
  96. * HELLO of this peer.
  97. *
  98. * @param cls closure
  99. * @param hello our updated HELLO
  100. */
  101. typedef void (*GNUNET_TRANSPORT_HelloUpdateCallback) (
  102. void *cls,
  103. const struct GNUNET_MessageHeader *hello);
  104. /**
  105. * Handle to cancel a #GNUNET_TRANSPORT_hello_get() operation.
  106. */
  107. struct GNUNET_TRANSPORT_HelloGetHandle;
  108. /**
  109. * Obtain updates on changes to the HELLO message for this peer. The callback
  110. * given in this function is never called synchronously.
  111. *
  112. * @param cfg configuration to use
  113. * @param ac which network type should the addresses from the HELLO belong to?
  114. * @param rec function to call with the HELLO
  115. * @param rec_cls closure for @a rec
  116. * @return handle to cancel the operation
  117. */
  118. struct GNUNET_TRANSPORT_HelloGetHandle *
  119. GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
  120. enum GNUNET_TRANSPORT_AddressClass ac,
  121. GNUNET_TRANSPORT_HelloUpdateCallback rec,
  122. void *rec_cls);
  123. /**
  124. * Stop receiving updates about changes to our HELLO message.
  125. *
  126. * @param ghh handle to cancel
  127. */
  128. void
  129. GNUNET_TRANSPORT_hello_get_cancel (struct GNUNET_TRANSPORT_HelloGetHandle *ghh);
  130. /**
  131. * Function with addresses found in a HELLO.
  132. *
  133. * @param cls closure
  134. * @param peer identity of the peer
  135. * @param address the address (UTF-8, 0-terminated)
  136. * @param nt network type of the address
  137. * @param expiration when does this address expire?
  138. */
  139. typedef void (*GNUNET_TRANSPORT_AddressCallback) (
  140. void *cls,
  141. const struct GNUNET_PeerIdentity *peer,
  142. const char *address,
  143. enum GNUNET_NetworkType nt,
  144. struct GNUNET_TIME_Absolute expiration);
  145. /**
  146. * Parse a HELLO message that we have received into its
  147. * constituent addresses.
  148. *
  149. * @param hello message to parse
  150. * @param cb function to call on each address found
  151. * @param cb_cls closure for @a cb
  152. * @return #GNUNET_OK if hello was well-formed, #GNUNET_SYSERR if not
  153. */
  154. int
  155. GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello,
  156. GNUNET_TRANSPORT_AddressCallback cb,
  157. void *cb_cls);
  158. #if 0 /* keep Emacsens' auto-indent happy */
  159. {
  160. #endif
  161. #ifdef __cplusplus
  162. }
  163. #endif
  164. /* ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H */
  165. #endif
  166. /** @} */ /* end of group */
  167. /* end of gnunet_transport_hello_service.h */