Ducttape_pvt.h 3.2 KB

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