icmpv6.h 4.5 KB

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