address_set.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* Copyright (c) 2018, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file addressset.h
  5. * \brief Types to handle sets of addresses.
  6. *
  7. * This module was first written on a semi-emergency basis to improve the
  8. * robustness of the anti-DoS module. As such, it's written in a pretty
  9. * conservative way, and should be susceptible to improvement later on.
  10. **/
  11. #ifndef TOR_ADDRESS_SET_H
  12. #define TOR_ADDRESS_SET_H
  13. #include "orconfig.h"
  14. #include "torint.h"
  15. /**
  16. * An address_set_t represents a set of tor_addr_t values. The implementation
  17. * is probabilistic: false negatives cannot occur but false positives are
  18. * possible.
  19. */
  20. typedef struct address_set_t address_set_t;
  21. struct tor_addr_t;
  22. address_set_t *address_set_new(int max_addresses_guess);
  23. void address_set_free(address_set_t *set);
  24. void address_set_add(address_set_t *set, const struct tor_addr_t *addr);
  25. void address_set_add_ipv4h(address_set_t *set, uint32_t addr);
  26. int address_set_probably_contains(address_set_t *set,
  27. const struct tor_addr_t *addr);
  28. #endif