shard.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * ZMap Copyright 2013 Regents of the University of Michigan
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy
  6. * of the License at http://www.apache.org/licenses/LICENSE-2.0
  7. */
  8. #ifndef ZMAP_SHARD_H
  9. #define ZMAP_SHARD_H
  10. #include <stdint.h>
  11. #include "cyclic.h"
  12. typedef void (*shard_complete_cb)(uint8_t id, void *arg);
  13. typedef struct shard {
  14. struct shard_state {
  15. uint32_t sent;
  16. uint32_t blacklisted;
  17. uint32_t whitelisted;
  18. uint32_t failures;
  19. uint32_t first_scanned;
  20. uint32_t max_targets;
  21. } state;
  22. struct shard_params {
  23. uint64_t first;
  24. uint64_t last;
  25. uint64_t factor;
  26. uint64_t modulus;
  27. } params;
  28. uint64_t current;
  29. uint8_t id;
  30. shard_complete_cb cb;
  31. void *arg;
  32. } shard_t;
  33. void shard_init(shard_t* shard,
  34. uint8_t shard_id,
  35. uint8_t num_shards,
  36. uint8_t sub_id,
  37. uint8_t num_subshard,
  38. const cycle_t* cycle,
  39. shard_complete_cb cb,
  40. void *arg);
  41. uint32_t shard_get_cur_ip(shard_t *shard);
  42. uint32_t shard_get_next_ip(shard_t *shard);
  43. #endif /* ZMAP_SHARD_H */