addr_store.h 738 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2017 Linus Lüssing <linus.luessing@c0d3.blue>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. * License-Filename: LICENSE
  6. */
  7. #ifndef _ADDR_STORE_H_
  8. #define _ADDR_STORE_H_
  9. #define ADDR_STORE_NUM_BUCKETS 32
  10. struct addr_list {
  11. struct addr_list *next;
  12. int tic;
  13. char addr[0];
  14. };
  15. struct addr_store {
  16. struct addr_list *buckets[ADDR_STORE_NUM_BUCKETS];
  17. size_t addr_len;
  18. void (*destructor)(struct addr_list *);
  19. char *(*ntoa)(void *);
  20. };
  21. int addr_store_init(size_t addr_len,
  22. void (*destructor)(struct addr_list *),
  23. char *(*ntoa)(void *),
  24. struct addr_store *store);
  25. int addr_store_add(void *addr, struct addr_store *store);
  26. void addr_store_cleanup(struct addr_store *store);
  27. #endif /* _ADDR_STORE_H_ */