Ducttape_pvt.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_pvt_H
  16. #define Ducttape_pvt_H
  17. #include "dht/Address.h"
  18. #include "util/version/Version.h"
  19. #include "dht/DHTModule.h"
  20. #include "dht/DHTModuleRegistry.h"
  21. #include "dht/dhtcore/RouterModule.h"
  22. #include "interface/Interface.h"
  23. #include "util/log/Log.h"
  24. #include "net/Ducttape.h"
  25. #include "util/events/EventBase.h"
  26. #include "util/Identity.h"
  27. #include <stdint.h>
  28. enum Ducttape_SessionLayer {
  29. Ducttape_SessionLayer_INVALID = 0,
  30. Ducttape_SessionLayer_INNER,
  31. Ducttape_SessionLayer_OUTER
  32. };
  33. /**
  34. * A network module which connects the DHT router to the SwitchCore.
  35. * This module's job is to grab messages off of the switch,
  36. * determine the peer's address,
  37. * map the message to the appropriate CryptoAuth obj and decrypt,
  38. * and send the message toward the DHT core.
  39. */
  40. struct Ducttape_pvt
  41. {
  42. /** the public fields. */
  43. struct Ducttape pub;
  44. /** The network module for the DHT. */
  45. struct DHTModule module;
  46. /** The registry to call when a message comes in. */
  47. struct DHTModuleRegistry* registry;
  48. /** The DHT router module. */
  49. struct RouterModule* routerModule;
  50. struct SearchRunner* searchRunner;
  51. /** The interface which interacts with the switch core. */
  52. struct Interface switchInterface;
  53. /** The interface which is used by the operator of the node to communicate in the network. */
  54. struct Interface* userIf;
  55. /** An interface which receives messages that are sent to fc00::1 from the TUN. */
  56. struct Interface magicInterface;
  57. struct Address myAddr;
  58. struct SessionManager* sm;
  59. struct EventBase* eventBase;
  60. struct Log* logger;
  61. /** For tunneling IPv4 and ICANN IPv6 packets. */
  62. struct IpTunnel* ipTunnel;
  63. struct Allocator* alloc;
  64. /** Number of milliseconds to wait between searches for a node to send arbitrary data to. */
  65. uint32_t timeBetweenSearches;
  66. /** Absolute time of last search for node to send arbitrary data to. */
  67. uint64_t timeOfLastSearch;
  68. Identity
  69. };
  70. struct Ducttape_MessageHeader
  71. {
  72. /**
  73. * This is to tell the code whether it is in the outer later of encryption or the inner layer.
  74. */
  75. enum Ducttape_SessionLayer layer;
  76. struct Headers_SwitchHeader* switchHeader;
  77. struct Headers_IP6Header* ip6Header;
  78. uint32_t nextHopReceiveHandle;
  79. uint32_t receiveHandle;
  80. uint64_t switchLabel;
  81. #ifdef Version_2_COMPAT
  82. /**
  83. * Cache the session handle and version so that if an incoming (stray) packet fails to
  84. * authenticate it won't assasinate the session.
  85. */
  86. uint32_t currentSessionSendHandle_be;
  87. uint32_t currentSessionVersion;
  88. #endif
  89. Identity
  90. };
  91. #define Ducttape_MessageHeader_SIZE ((int)sizeof(struct Ducttape_MessageHeader))
  92. #endif