exit.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2012 Christian Grothoff
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file exit/exit.h
  18. * @brief format for cadet messages exchanged between VPN service and exit daemon
  19. * @author Christian Grothoff
  20. */
  21. #ifndef EXIT_H
  22. #define EXIT_H
  23. #include "gnunet_util_lib.h"
  24. GNUNET_NETWORK_STRUCT_BEGIN
  25. /**
  26. * Message send via cadet to an exit daemon to initiate forwarding of
  27. * TCP data to a local service.
  28. */
  29. struct GNUNET_EXIT_TcpServiceStartMessage
  30. {
  31. /**
  32. * Type is #GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START
  33. */
  34. struct GNUNET_MessageHeader header;
  35. /**
  36. * Always 0.
  37. */
  38. uint32_t reserved GNUNET_PACKED;
  39. /**
  40. * Skeleton of the TCP header to send. Port numbers are to
  41. * be replaced and the checksum may be updated as necessary.
  42. */
  43. struct GNUNET_TUN_TcpHeader tcp_header;
  44. /* followed by TCP payload */
  45. };
  46. /**
  47. * Message send via cadet to an exit daemon to initiate forwarding of
  48. * TCP data to the Internet.
  49. */
  50. struct GNUNET_EXIT_TcpInternetStartMessage
  51. {
  52. /**
  53. * Type is #GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START
  54. */
  55. struct GNUNET_MessageHeader header;
  56. /**
  57. * Address family, AF_INET or AF_INET6, in network byte order.
  58. */
  59. int32_t af GNUNET_PACKED;
  60. /**
  61. * Skeleton of the TCP header to send. Port numbers are to
  62. * be replaced and the checksum may be updated as necessary.
  63. */
  64. struct GNUNET_TUN_TcpHeader tcp_header;
  65. /* followed by IP address of the destination; either
  66. 'struct in_addr' or 'struct in6_addr', depending on af */
  67. /* followed by TCP payload */
  68. };
  69. /**
  70. * Message send via cadet between VPN and entry and an exit daemon to
  71. * transmit TCP data between the VPN entry and an exit session. This
  72. * format is used for both Internet-exits and service-exits and
  73. * in both directions (VPN to exit and exit to VPN).
  74. */
  75. struct GNUNET_EXIT_TcpDataMessage
  76. {
  77. /**
  78. * Type is #GNUNET_MESSAGE_TYPE_VPN_TCP_DATA
  79. */
  80. struct GNUNET_MessageHeader header;
  81. /**
  82. * Always 0.
  83. */
  84. uint32_t reserved GNUNET_PACKED;
  85. /**
  86. * Skeleton of the TCP header to send. Port numbers are to
  87. * be replaced and the checksum may be updated as necessary. (The destination port number should not be changed, as it contains the desired destination port.)
  88. */
  89. struct GNUNET_TUN_TcpHeader tcp_header;
  90. /* followed by TCP payload */
  91. };
  92. /**
  93. * Message send via cadet to an exit daemon to send
  94. * UDP data to a local service.
  95. */
  96. struct GNUNET_EXIT_UdpServiceMessage
  97. {
  98. /**
  99. * Type is #GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE
  100. */
  101. struct GNUNET_MessageHeader header;
  102. /**
  103. * Source port to use for the UDP request (0 to use a random port). In NBO.
  104. */
  105. uint16_t source_port GNUNET_PACKED;
  106. /**
  107. * Destination port to use for the UDP request. In NBO.
  108. */
  109. uint16_t destination_port GNUNET_PACKED;
  110. /* followed by UDP payload */
  111. };
  112. /**
  113. * Message send via cadet to an exit daemon to forward
  114. * UDP data to the Internet.
  115. */
  116. struct GNUNET_EXIT_UdpInternetMessage
  117. {
  118. /**
  119. * Type is #GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET
  120. */
  121. struct GNUNET_MessageHeader header;
  122. /**
  123. * Address family, AF_INET or AF_INET6, in network byte order.
  124. */
  125. int32_t af GNUNET_PACKED;
  126. /**
  127. * Source port to use for the UDP request (0 to use a random port). In NBO.
  128. */
  129. uint16_t source_port GNUNET_PACKED;
  130. /**
  131. * Destination port to use for the UDP request. In NBO.
  132. */
  133. uint16_t destination_port GNUNET_PACKED;
  134. /* followed by IP address of the destination; either
  135. 'struct in_addr' or 'struct in6_addr', depending on af */
  136. /* followed by UDP payload */
  137. };
  138. /**
  139. * Message send from exit daemon back to the UDP entry point
  140. * (used for both Internet and Service exit replies).
  141. */
  142. struct GNUNET_EXIT_UdpReplyMessage
  143. {
  144. /**
  145. * Type is #GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY
  146. */
  147. struct GNUNET_MessageHeader header;
  148. /**
  149. * Source port to use for the UDP reply (0 to use the same
  150. * port as for the original request). In NBO.
  151. */
  152. uint16_t source_port GNUNET_PACKED;
  153. /**
  154. * Destination port to use for the UDP reply (0 to use the same
  155. * port as for the original request). In NBO.
  156. */
  157. uint16_t destination_port GNUNET_PACKED;
  158. /* followed by UDP payload */
  159. };
  160. /**
  161. * Message send via cadet to an exit daemon to send
  162. * ICMP data to a local service.
  163. */
  164. struct GNUNET_EXIT_IcmpServiceMessage
  165. {
  166. /**
  167. * Type is #GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE
  168. */
  169. struct GNUNET_MessageHeader header;
  170. /**
  171. * Address family, AF_INET or AF_INET6, in network byte order. This
  172. * AF value determines if the 'icmp_header' is ICMPv4 or ICMPv6.
  173. * The receiver (exit) may still have to translate (PT) to the services'
  174. * ICMP version (if possible).
  175. */
  176. int32_t af GNUNET_PACKED;
  177. /**
  178. * ICMP header to use.
  179. */
  180. struct GNUNET_TUN_IcmpHeader icmp_header;
  181. /* followed by ICMP payload; however, for certain ICMP message
  182. types where the payload is the original IP packet, the payload
  183. is omitted as it is useless for the receiver (who will need
  184. to create some fake payload manually) */
  185. };
  186. /**
  187. * Message send via cadet to an exit daemon to forward
  188. * ICMP data to the Internet.
  189. */
  190. struct GNUNET_EXIT_IcmpInternetMessage
  191. {
  192. /**
  193. * Type is #GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET
  194. */
  195. struct GNUNET_MessageHeader header;
  196. /**
  197. * Address family, AF_INET or AF_INET6, in network byte order.
  198. * Determines both the ICMP version used in the 'icmp_header' and
  199. * the IP address format that is used for the target IP. If
  200. * PT is necessary, the sender has already done it.
  201. */
  202. int32_t af GNUNET_PACKED;
  203. /**
  204. * ICMP header to use. Must match the target 'af' given
  205. * above.
  206. */
  207. struct GNUNET_TUN_IcmpHeader icmp_header;
  208. /* followed by IP address of the destination; either
  209. 'struct in_addr' or 'struct in6_addr', depending on af */
  210. /* followed by ICMP payload; however, for certain ICMP message
  211. types where the payload is the original IP packet, the payload
  212. is omitted as it is useless for the receiver (who will need
  213. to create some fake payload manually) */
  214. };
  215. /**
  216. * Message send via cadet to the vpn service to send
  217. * ICMP data to the VPN's TUN interface.
  218. */
  219. struct GNUNET_EXIT_IcmpToVPNMessage
  220. {
  221. /**
  222. * Type is #GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN
  223. */
  224. struct GNUNET_MessageHeader header;
  225. /**
  226. * Address family, AF_INET or AF_INET6, in network byte order.
  227. * Useful to determine if this is an ICMPv4 or ICMPv6 header.
  228. */
  229. int32_t af GNUNET_PACKED;
  230. /**
  231. * ICMP header to use. ICMPv4 or ICMPv6, depending on 'af'.
  232. */
  233. struct GNUNET_TUN_IcmpHeader icmp_header;
  234. /* followed by ICMP payload; however, for certain ICMP message
  235. types where the payload is the original IP packet, the payload
  236. is omitted as it is useless for the receiver (who will need
  237. to create some fake payload manually) */
  238. };
  239. GNUNET_NETWORK_STRUCT_END
  240. #endif