Router.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Router_H
  16. #define Router_H
  17. #ifdef SUBNODE
  18. #error "this file should not be included in subnode"
  19. #endif
  20. #include "dht/Address.h"
  21. #include "memory/Allocator.h"
  22. #include "dht/dhtcore/Node.h"
  23. #include "util/Linker.h"
  24. Linker_require("dht/dhtcore/Router.c")
  25. /**
  26. * This is a facad around the other internals of dht/dhtcore.
  27. * NO OTHER FILE IN dht/dhtcore SHOULD EVER INCLUDE THIS HEADER.
  28. * Files outside of dht/dhtcore should use this instead of the others.
  29. */
  30. struct Router
  31. {
  32. int unused;
  33. };
  34. void Router_sendGetPeers(struct Router* r,
  35. struct Address* addr,
  36. uint64_t nearbyLabel,
  37. uint32_t timeoutMilliseconds,
  38. struct Allocator* alloc);
  39. struct Node_Two* Router_lookup(struct Router* r, uint8_t targetAddr[16]);
  40. void Router_brokenLink(struct Router* r, uint64_t path, uint64_t labelAtErrorHop);
  41. void Router_disconnectedPeer(struct Router* r, uint64_t path);
  42. struct Node_Link* Router_linkForPath(struct Router* r, uint64_t path);
  43. #if defined(NodeStore_H) && defined(SearchRunner_H) && defined(RouterModule_H)
  44. struct Router* Router_new(struct RouterModule* rm,
  45. struct NodeStore* ns,
  46. struct SearchRunner* sr,
  47. struct Allocator* alloc);
  48. #endif
  49. #endif