gnunet_nt_lib.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2010-2015, 2018 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 network type characterization
  18. * @author Christian Grothoff
  19. * @author Matthias Wachs
  20. *
  21. * @defgroup nt network type characterization
  22. *
  23. * @{
  24. */
  25. #ifndef GNUNET_NT_LIB_H
  26. #define GNUNET_NT_LIB_H
  27. /**
  28. * Types of networks (with separate quotas) we support.
  29. */
  30. enum GNUNET_NetworkType
  31. {
  32. /**
  33. * Category of last resort.
  34. */
  35. GNUNET_NT_UNSPECIFIED = 0,
  36. /**
  37. * Loopback (same host).
  38. */
  39. GNUNET_NT_LOOPBACK = 1,
  40. /**
  41. * Local area network.
  42. */
  43. GNUNET_NT_LAN = 2,
  44. /**
  45. * Wide area network (i.e. Internet)
  46. */
  47. GNUNET_NT_WAN = 3,
  48. /**
  49. * Wireless LAN (i.e. 802.11abgn)
  50. */
  51. GNUNET_NT_WLAN = 4,
  52. /**
  53. * Bluetooth LAN
  54. */
  55. GNUNET_NT_BT = 5
  56. /**
  57. * Number of network types supported by ATS
  58. */
  59. #define GNUNET_NT_COUNT 6
  60. };
  61. /**
  62. * Convert a `enum GNUNET_NetworkType` to a string
  63. *
  64. * @param net the network type
  65. * @return a string or NULL if invalid
  66. */
  67. const char *
  68. GNUNET_NT_to_string (enum GNUNET_NetworkType net);
  69. /**
  70. * Handle for the LAN Characterization library.
  71. */
  72. struct GNUNET_NT_InterfaceScanner;
  73. /**
  74. * Returns where the address is located: loopback, LAN or WAN.
  75. *
  76. * @param is handle from #GNUNET_ATS_interface_scanner_init()
  77. * @param addr address
  78. * @param addrlen address length
  79. * @return type of the network the address belongs to
  80. */
  81. enum GNUNET_NetworkType
  82. GNUNET_NT_scanner_get_type (struct GNUNET_NT_InterfaceScanner *is,
  83. const struct sockaddr *addr,
  84. socklen_t addrlen);
  85. /**
  86. * Initialize the address characterization client handle.
  87. *
  88. * @return scanner handle, NULL on error
  89. */
  90. struct GNUNET_NT_InterfaceScanner *
  91. GNUNET_NT_scanner_init (void);
  92. /**
  93. * Terminate interface scanner.
  94. *
  95. * @param is scanner we are done with
  96. */
  97. void
  98. GNUNET_NT_scanner_done (struct GNUNET_NT_InterfaceScanner *is);
  99. #endif
  100. /** @} */ /* end of group */