describe.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file describe.h
  8. * \brief Header file for describe.c.
  9. **/
  10. #ifndef TOR_DESCRIBE_H
  11. #define TOR_DESCRIBE_H
  12. struct extend_info_t;
  13. struct node_t;
  14. struct routerinfo_t;
  15. struct routerstatus_t;
  16. const char *extend_info_describe(const struct extend_info_t *ei);
  17. const char *node_describe(const struct node_t *node);
  18. const char *router_describe(const struct routerinfo_t *ri);
  19. const char *routerstatus_describe(const struct routerstatus_t *ri);
  20. void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
  21. #if defined(DESCRIBE_PRIVATE) || defined(TOR_UNIT_TESTS)
  22. /**
  23. * Longest allowed output for an IPv4 address "255.255.255.255", with NO
  24. * terminating NUL.
  25. */
  26. #define IPV4_BUF_LEN_NO_NUL 15
  27. /**
  28. * Longest allowed output of format_node_description, plus 1 character for
  29. * NUL. This allows space for:
  30. * "$FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF~xxxxxxxxxxxxxxxxxxx at"
  31. * " 255.255.255.255 and [ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]"
  32. * plus a terminating NUL.
  33. */
  34. #define NODE_DESC_BUF_LEN \
  35. (MAX_VERBOSE_NICKNAME_LEN+4+IPV4_BUF_LEN_NO_NUL+5+TOR_ADDR_BUF_LEN)
  36. #endif /* defined(DESCRIBE_PRIVATE) || defined(TOR_UNIT_TESTS) */
  37. #ifdef TOR_UNIT_TESTS
  38. STATIC const char *format_node_description(char *buf,
  39. const char *id_digest,
  40. const char *nickname,
  41. const tor_addr_t *addr,
  42. uint32_t addr32h);
  43. #endif /* defined(TOR_UNIT_TESTS) */
  44. #endif /* !defined(TOR_DESCRIBE_H) */