icmp_codes.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * firewall3 - 3rd OpenWrt UCI firewall implementation
  3. *
  4. * Copyright (C) 2013 Jo-Philipp Wich <jo@mein.io>
  5. *
  6. * Permission to use, copy, modify, and/or distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef __FW3_ICMP_CODES_H
  19. #define __FW3_ICMP_CODES_H
  20. struct fw3_icmptype_entry {
  21. const char *name;
  22. uint8_t type;
  23. uint8_t code_min;
  24. uint8_t code_max;
  25. };
  26. /* taken from iptables extensions/libipt_icmp.c */
  27. static const struct fw3_icmptype_entry fw3_icmptype_list_v4[] = {
  28. { "any", 0xFF, 0, 0xFF },
  29. { "echo-reply", 0, 0, 0xFF },
  30. /* Alias */ { "pong", 0, 0, 0xFF },
  31. { "destination-unreachable", 3, 0, 0xFF },
  32. { "network-unreachable", 3, 0, 0 },
  33. { "host-unreachable", 3, 1, 1 },
  34. { "protocol-unreachable", 3, 2, 2 },
  35. { "port-unreachable", 3, 3, 3 },
  36. { "fragmentation-needed", 3, 4, 4 },
  37. { "source-route-failed", 3, 5, 5 },
  38. { "network-unknown", 3, 6, 6 },
  39. { "host-unknown", 3, 7, 7 },
  40. { "network-prohibited", 3, 9, 9 },
  41. { "host-prohibited", 3, 10, 10 },
  42. { "TOS-network-unreachable", 3, 11, 11 },
  43. { "TOS-host-unreachable", 3, 12, 12 },
  44. { "communication-prohibited", 3, 13, 13 },
  45. { "host-precedence-violation", 3, 14, 14 },
  46. { "precedence-cutoff", 3, 15, 15 },
  47. { "source-quench", 4, 0, 0xFF },
  48. { "redirect", 5, 0, 0xFF },
  49. { "network-redirect", 5, 0, 0 },
  50. { "host-redirect", 5, 1, 1 },
  51. { "TOS-network-redirect", 5, 2, 2 },
  52. { "TOS-host-redirect", 5, 3, 3 },
  53. { "echo-request", 8, 0, 0xFF },
  54. /* Alias */ { "ping", 8, 0, 0xFF },
  55. { "router-advertisement", 9, 0, 0xFF },
  56. { "router-solicitation", 10, 0, 0xFF },
  57. { "time-exceeded", 11, 0, 0xFF },
  58. /* Alias */ { "ttl-exceeded", 11, 0, 0xFF },
  59. { "ttl-zero-during-transit", 11, 0, 0 },
  60. { "ttl-zero-during-reassembly", 11, 1, 1 },
  61. { "parameter-problem", 12, 0, 0xFF },
  62. { "ip-header-bad", 12, 0, 0 },
  63. { "required-option-missing", 12, 1, 1 },
  64. { "timestamp-request", 13, 0, 0xFF },
  65. { "timestamp-reply", 14, 0, 0xFF },
  66. { "address-mask-request", 17, 0, 0xFF },
  67. { "address-mask-reply", 18, 0, 0xFF }
  68. };
  69. /* taken from iptables extensions/libip6t_icmp6.c */
  70. static const struct fw3_icmptype_entry fw3_icmptype_list_v6[] = {
  71. { "destination-unreachable", 1, 0, 0xFF },
  72. { "no-route", 1, 0, 0 },
  73. { "communication-prohibited", 1, 1, 1 },
  74. { "address-unreachable", 1, 3, 3 },
  75. { "port-unreachable", 1, 4, 4 },
  76. { "packet-too-big", 2, 0, 0xFF },
  77. { "time-exceeded", 3, 0, 0xFF },
  78. /* Alias */ { "ttl-exceeded", 3, 0, 0xFF },
  79. { "ttl-zero-during-transit", 3, 0, 0 },
  80. { "ttl-zero-during-reassembly", 3, 1, 1 },
  81. { "parameter-problem", 4, 0, 0xFF },
  82. { "bad-header", 4, 0, 0 },
  83. { "unknown-header-type", 4, 1, 1 },
  84. { "unknown-option", 4, 2, 2 },
  85. { "echo-request", 128, 0, 0xFF },
  86. /* Alias */ { "ping", 128, 0, 0xFF },
  87. { "echo-reply", 129, 0, 0xFF },
  88. /* Alias */ { "pong", 129, 0, 0xFF },
  89. { "router-solicitation", 133, 0, 0xFF },
  90. { "router-advertisement", 134, 0, 0xFF },
  91. { "neighbour-solicitation", 135, 0, 0xFF },
  92. /* Alias */ { "neighbor-solicitation", 135, 0, 0xFF },
  93. { "neighbour-advertisement", 136, 0, 0xFF },
  94. /* Alias */ { "neighbor-advertisement", 136, 0, 0xFF },
  95. { "redirect", 137, 0, 0xFF },
  96. };
  97. #endif