Ducttape_pvt.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. struct RumorMill* nodesOfInterest;
  52. /** The interface which interacts with the switch core. */
  53. struct Interface switchInterface;
  54. /** The interface which is used by the operator of the node to communicate in the network. */
  55. struct Interface* userIf;
  56. /** An interface which receives messages that are sent to fc00::1 from the TUN. */
  57. struct Interface magicInterface;
  58. struct Address myAddr;
  59. struct SessionManager* sm;
  60. struct EventBase* eventBase;
  61. struct Log* logger;
  62. /** For tunneling IPv4 and ICANN IPv6 packets. */
  63. struct IpTunnel* ipTunnel;
  64. struct Allocator* alloc;
  65. /** Number of milliseconds to wait between searches for a node to send arbitrary data to. */
  66. uint32_t timeBetweenSearches;
  67. /** Absolute time of last search for node to send arbitrary data to. */
  68. uint64_t timeOfLastSearch;
  69. Identity
  70. };
  71. struct Ducttape_MessageHeader
  72. {
  73. /**
  74. * This is to tell the code whether it is in the outer later of encryption or the inner layer.
  75. */
  76. enum Ducttape_SessionLayer layer;
  77. struct Headers_SwitchHeader* switchHeader;
  78. struct Headers_IP6Header* ip6Header;
  79. uint32_t nextHopReceiveHandle;
  80. uint32_t receiveHandle;
  81. uint64_t switchLabel;
  82. #ifdef Version_2_COMPAT
  83. /**
  84. * Cache the session handle and version so that if an incoming (stray) packet fails to
  85. * authenticate it won't assasinate the session.
  86. */
  87. uint32_t currentSessionSendHandle_be;
  88. uint32_t currentSessionVersion;
  89. #endif
  90. Identity
  91. };
  92. #define Ducttape_MessageHeader_SIZE ((int)sizeof(struct Ducttape_MessageHeader))
  93. #endif