Ducttape.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef Ducttape_H
  16. #define Ducttape_H
  17. #include "dht/DHTModuleRegistry.h"
  18. #include "dht/dhtcore/RouterModule.h"
  19. #include "dht/dhtcore/SearchRunner.h"
  20. #include "switch/SwitchCore.h"
  21. #include "memory/Allocator.h"
  22. #include "tunnel/IpTunnel.h"
  23. #include "wire/Headers.h"
  24. #include "util/events/EventBase.h"
  25. struct Ducttape
  26. {
  27. struct Interface switchPingerIf;
  28. struct SessionManager* sessionManager;
  29. };
  30. struct Ducttape* Ducttape_register(uint8_t privateKey[32],
  31. struct DHTModuleRegistry* registry,
  32. struct RouterModule* routerModule,
  33. struct SearchRunner* searchRunner,
  34. struct SwitchCore* switchCore,
  35. struct EventBase* eventBase,
  36. struct Allocator* allocator,
  37. struct Log* logger,
  38. struct IpTunnel* ipTun,
  39. struct Random* rand);
  40. /**
  41. * Set the interface which the user will use to communicate with the network.
  42. *
  43. * @param dt the ducttape struct.
  44. * @param userIf the (TUN) interface which will be used to send and receive packets.
  45. */
  46. void Ducttape_setUserInterface(struct Ducttape* dt, struct Interface* userIf);
  47. /**
  48. * The structure of data which should be the beginning
  49. * of the content in the message sent to injectIncomingForMe.
  50. */
  51. struct Ducttape_IncomingForMe
  52. {
  53. struct Headers_SwitchHeader switchHeader;
  54. struct Headers_IP6Header ip6Header;
  55. };
  56. /**
  57. * Inject a packet into the stream of packets destine for this node.
  58. * The message must contain switch header, ipv6 header, then content.
  59. * None of it should be encrypted and there should be no CryptoAuth headers.
  60. */
  61. uint8_t Ducttape_injectIncomingForMe(struct Message* message,
  62. struct Ducttape* ducttape,
  63. uint8_t herPublicKey[32]);
  64. #endif