Ducttape.h 2.6 KB

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