test_ats_api_common.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. This file is part of GNUnet.
  3. (C) 2010,2011 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. 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. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file ats/test_ats_api_common.h
  19. * @brief shared definitions for ats testcases
  20. * @author Christian Grothoff
  21. * @author Matthias Wachs
  22. */
  23. #include "platform.h"
  24. #include "gnunet_ats_service.h"
  25. #include "gnunet-service-ats_addresses.h"
  26. #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
  27. struct Test_Address
  28. {
  29. char *plugin;
  30. size_t plugin_len;
  31. void *addr;
  32. size_t addr_len;
  33. struct GNUNET_ATS_Information *ats;
  34. int ats_count;
  35. void *session;
  36. };
  37. struct PeerContext
  38. {
  39. struct GNUNET_PeerIdentity id;
  40. struct Test_Address *addr;
  41. unsigned long long bw_out_assigned;
  42. unsigned long long bw_in_assigned;
  43. };
  44. void
  45. free_test_address (struct Test_Address *dest);
  46. void
  47. create_test_address (struct Test_Address *dest, char * plugin, void *session, void *addr, size_t addrlen);
  48. int
  49. compare_addresses (const struct GNUNET_HELLO_Address *address1, void *session1,
  50. const struct GNUNET_HELLO_Address *address2, void *session2);
  51. int
  52. compare_ats (const struct GNUNET_ATS_Information *ats_is, uint32_t ats_count_is,
  53. const struct GNUNET_ATS_Information *ats_should, uint32_t ats_count_should);
  54. struct ATS_Address *
  55. create_address (const struct GNUNET_PeerIdentity *peer,
  56. const char *plugin_name,
  57. const void *plugin_addr, size_t plugin_addr_len,
  58. uint32_t session_id);
  59. /**
  60. * Load quotas for networks from configuration
  61. *
  62. * @param cfg configuration handle
  63. * @param out_dest where to write outbound quotas
  64. * @param in_dest where to write inbound quotas
  65. * @param dest_length length of inbound and outbound arrays
  66. * @return number of networks loaded
  67. */
  68. unsigned int
  69. load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
  70. unsigned long long *out_dest,
  71. unsigned long long *in_dest,
  72. int dest_length);
  73. /* end of file test_ats_api_common.h */