1
0

ReachabilityCollector.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef ReachabilityCollector_H
  16. #define ReachabilityCollector_H
  17. #include "subnode/BoilerplateResponder.h"
  18. #include "dht/Address.h"
  19. #include "memory/Allocator.h"
  20. #include "subnode/MsgCore.h"
  21. #include "util/Linker.h"
  22. Linker_require("subnode/ReachabilityCollector.c");
  23. struct ReachabilityCollector_PeerInfo
  24. {
  25. // Address of the peer from us
  26. struct Address addr;
  27. // Their path to us
  28. uint64_t pathThemToUs;
  29. bool querying;
  30. };
  31. struct ReachabilityCollector;
  32. typedef void (* ReachabilityCollector_OnChange)(struct ReachabilityCollector* rc,
  33. uint8_t nodeIpv6[16],
  34. uint64_t pathThemToUs,
  35. uint64_t pathUsToThem,
  36. uint32_t mtu, // 0 = unknown
  37. uint16_t drops, // 0xffff = unknown
  38. uint16_t latency, // 0xffff = unknown
  39. uint16_t penalty); // 0xffff = unknown
  40. struct ReachabilityCollector
  41. {
  42. ReachabilityCollector_OnChange onChange;
  43. void* userData;
  44. };
  45. struct ReachabilityCollector_PeerInfo*
  46. ReachabilityCollector_getPeerInfo(struct ReachabilityCollector* rc, int peerNum);
  47. // NodeAddr->path should be 0 if the node is not reachable.
  48. void ReachabilityCollector_change(struct ReachabilityCollector* rc, struct Address* nodeAddr);
  49. struct ReachabilityCollector* ReachabilityCollector_new(struct Allocator* allocator,
  50. struct MsgCore* mc,
  51. struct Log* log,
  52. struct EventBase* base,
  53. struct BoilerplateResponder* br,
  54. struct Address* myAddr);
  55. #endif