1
0

ICMP6Generator.h 2.2 KB

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