ICMP6Generator.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 ICMP6Generator_H
  16. #define ICMP6Generator_H
  17. #include "interface/Interface.h"
  18. #include "wire/Message.h"
  19. #include <stdint.h>
  20. #define ICMP6Generator_MIN_IPV6_MTU 1280
  21. struct ICMP6Generator
  22. {
  23. /** Facing the TUN. */
  24. struct Interface external;
  25. /** Facing the Ducttape. */
  26. struct Interface internal;
  27. };
  28. enum ICMP6Generator_Type
  29. {
  30. ICMP6Generator_Type_NO_ROUTE_TO_HOST,
  31. ICMP6Generator_Type_PACKET_TOO_BIG
  32. // add more as needed.
  33. };
  34. /**
  35. * Generate an ICMPv6 message.
  36. * The message parameter must contain all content which will be beneath the ICMPv6 header
  37. * including the MTU in the case of a "packet too big" message.
  38. *
  39. * @param message a message containing the content. This message must have enough padding
  40. * to contain an additional ICMP header and IPv6 header totaling 44 bytes.
  41. * @param sourceAddr the IPv6 address which this ICMP message will be said to have come from.
  42. * @param destAddr the IPv6 address which this ICMP message will be directed to.
  43. * @param type the ICMP message type/code for this message.
  44. * @param mtu the MTU value for this message.
  45. */
  46. void ICMP6Generator_generate(struct Message* message,
  47. const uint8_t* restrict sourceAddr,
  48. const uint8_t* restrict destAddr,
  49. enum ICMP6Generator_Type type,
  50. uint32_t mtu);
  51. struct ICMP6Generator* ICMP6Generator_new(struct Allocator* alloc);
  52. #endif