icmpv6.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #ifndef _LINUX_ICMPV6_H
  2. #define _LINUX_ICMPV6_H
  3. #include <asm/byteorder.h>
  4. struct icmp6hdr {
  5. __u8 icmp6_type;
  6. __u8 icmp6_code;
  7. __sum16 icmp6_cksum;
  8. union {
  9. __be32 un_data32[1];
  10. __be16 un_data16[2];
  11. __u8 un_data8[4];
  12. struct icmpv6_echo {
  13. __be16 identifier;
  14. __be16 sequence;
  15. } u_echo;
  16. struct icmpv6_nd_advt {
  17. #if defined(__LITTLE_ENDIAN_BITFIELD)
  18. __u32 reserved:5,
  19. override:1,
  20. solicited:1,
  21. router:1,
  22. reserved2:24;
  23. #elif defined(__BIG_ENDIAN_BITFIELD)
  24. __u32 router:1,
  25. solicited:1,
  26. override:1,
  27. reserved:29;
  28. #else
  29. #error "Please fix <asm/byteorder.h>"
  30. #endif
  31. } u_nd_advt;
  32. struct icmpv6_nd_ra {
  33. __u8 hop_limit;
  34. #if defined(__LITTLE_ENDIAN_BITFIELD)
  35. __u8 reserved:4,
  36. router_pref:2,
  37. other:1,
  38. managed:1;
  39. #elif defined(__BIG_ENDIAN_BITFIELD)
  40. __u8 managed:1,
  41. other:1,
  42. router_pref:2,
  43. reserved:4;
  44. #else
  45. #error "Please fix <asm/byteorder.h>"
  46. #endif
  47. __be16 rt_lifetime;
  48. } u_nd_ra;
  49. } icmp6_dataun;
  50. #define icmp6_identifier icmp6_dataun.u_echo.identifier
  51. #define icmp6_sequence icmp6_dataun.u_echo.sequence
  52. #define icmp6_pointer icmp6_dataun.un_data32[0]
  53. #define icmp6_mtu icmp6_dataun.un_data32[0]
  54. #define icmp6_unused icmp6_dataun.un_data32[0]
  55. #define icmp6_maxdelay icmp6_dataun.un_data16[0]
  56. #define icmp6_router icmp6_dataun.u_nd_advt.router
  57. #define icmp6_solicited icmp6_dataun.u_nd_advt.solicited
  58. #define icmp6_override icmp6_dataun.u_nd_advt.override
  59. #define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved
  60. #define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit
  61. #define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed
  62. #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
  63. #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
  64. #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref
  65. };
  66. #define ICMPV6_ROUTER_PREF_LOW 0x3
  67. #define ICMPV6_ROUTER_PREF_MEDIUM 0x0
  68. #define ICMPV6_ROUTER_PREF_HIGH 0x1
  69. #define ICMPV6_ROUTER_PREF_INVALID 0x2
  70. #define ICMPV6_DEST_UNREACH 1
  71. #define ICMPV6_PKT_TOOBIG 2
  72. #define ICMPV6_TIME_EXCEED 3
  73. #define ICMPV6_PARAMPROB 4
  74. #define ICMPV6_INFOMSG_MASK 0x80
  75. #define ICMPV6_ECHO_REQUEST 128
  76. #define ICMPV6_ECHO_REPLY 129
  77. #define ICMPV6_MGM_QUERY 130
  78. #define ICMPV6_MGM_REPORT 131
  79. #define ICMPV6_MGM_REDUCTION 132
  80. #define ICMPV6_NI_QUERY 139
  81. #define ICMPV6_NI_REPLY 140
  82. #define ICMPV6_MLD2_REPORT 143
  83. #define ICMPV6_DHAAD_REQUEST 144
  84. #define ICMPV6_DHAAD_REPLY 145
  85. #define ICMPV6_MOBILE_PREFIX_SOL 146
  86. #define ICMPV6_MOBILE_PREFIX_ADV 147
  87. /*
  88. * Codes for Destination Unreachable
  89. */
  90. #define ICMPV6_NOROUTE 0
  91. #define ICMPV6_ADM_PROHIBITED 1
  92. #define ICMPV6_NOT_NEIGHBOUR 2
  93. #define ICMPV6_ADDR_UNREACH 3
  94. #define ICMPV6_PORT_UNREACH 4
  95. /*
  96. * Codes for Time Exceeded
  97. */
  98. #define ICMPV6_EXC_HOPLIMIT 0
  99. #define ICMPV6_EXC_FRAGTIME 1
  100. /*
  101. * Codes for Parameter Problem
  102. */
  103. #define ICMPV6_HDR_FIELD 0
  104. #define ICMPV6_UNK_NEXTHDR 1
  105. #define ICMPV6_UNK_OPTION 2
  106. /*
  107. * constants for (set|get)sockopt
  108. */
  109. #define ICMPV6_FILTER 1
  110. /*
  111. * ICMPV6 filter
  112. */
  113. #define ICMPV6_FILTER_BLOCK 1
  114. #define ICMPV6_FILTER_PASS 2
  115. #define ICMPV6_FILTER_BLOCKOTHERS 3
  116. #define ICMPV6_FILTER_PASSONLY 4
  117. struct icmp6_filter {
  118. __u32 data[8];
  119. };
  120. /*
  121. * Definitions for MLDv2
  122. */
  123. #define MLD2_MODE_IS_INCLUDE 1
  124. #define MLD2_MODE_IS_EXCLUDE 2
  125. #define MLD2_CHANGE_TO_INCLUDE 3
  126. #define MLD2_CHANGE_TO_EXCLUDE 4
  127. #define MLD2_ALLOW_NEW_SOURCES 5
  128. #define MLD2_BLOCK_OLD_SOURCES 6
  129. #define MLD2_ALL_MCR_INIT { { { 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 } } }
  130. #ifdef __KERNEL__
  131. #include <linux/netdevice.h>
  132. #include <linux/skbuff.h>
  133. extern void icmpv6_send(struct sk_buff *skb,
  134. int type, int code,
  135. __u32 info,
  136. struct net_device *dev);
  137. extern int icmpv6_init(struct net_proto_family *ops);
  138. extern int icmpv6_err_convert(int type, int code,
  139. int *err);
  140. extern void icmpv6_cleanup(void);
  141. extern void icmpv6_param_prob(struct sk_buff *skb,
  142. int code, int pos);
  143. #endif
  144. #endif