icmpv6.h 4.6 KB

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