icmpv6.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  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. __u16 icmp6_cksum;
  8. union {
  9. __u32 un_data32[1];
  10. __u16 un_data16[2];
  11. __u8 un_data8[4];
  12. struct icmpv6_echo {
  13. __u16 identifier;
  14. __u16 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:6,
  36. other:1,
  37. managed:1;
  38. #elif defined(__BIG_ENDIAN_BITFIELD)
  39. __u8 managed:1,
  40. other:1,
  41. reserved:6;
  42. #else
  43. #error "Please fix <asm/byteorder.h>"
  44. #endif
  45. __u16 rt_lifetime;
  46.                 } u_nd_ra;
  47. } icmp6_dataun;
  48. #define icmp6_identifier icmp6_dataun.u_echo.identifier
  49. #define icmp6_sequence icmp6_dataun.u_echo.sequence
  50. #define icmp6_pointer icmp6_dataun.un_data32[0]
  51. #define icmp6_mtu icmp6_dataun.un_data32[0]
  52. #define icmp6_unused icmp6_dataun.un_data32[0]
  53. #define icmp6_maxdelay icmp6_dataun.un_data16[0]
  54. #define icmp6_router icmp6_dataun.u_nd_advt.router
  55. #define icmp6_solicited icmp6_dataun.u_nd_advt.solicited
  56. #define icmp6_override icmp6_dataun.u_nd_advt.override
  57. #define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved
  58. #define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit
  59. #define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed
  60. #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
  61. #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
  62. };
  63. #define ICMPV6_DEST_UNREACH 1
  64. #define ICMPV6_PKT_TOOBIG 2
  65. #define ICMPV6_TIME_EXCEED 3
  66. #define ICMPV6_PARAMPROB 4
  67. #define ICMPV6_INFOMSG_MASK 0x80
  68. #define ICMPV6_ECHO_REQUEST 128
  69. #define ICMPV6_ECHO_REPLY 129
  70. #define ICMPV6_MGM_QUERY 130
  71. #define ICMPV6_MGM_REPORT        131
  72. #define ICMPV6_MGM_REDUCTION     132
  73. /*
  74.  * Codes for Destination Unreachable
  75.  */
  76. #define ICMPV6_NOROUTE 0
  77. #define ICMPV6_ADM_PROHIBITED 1
  78. #define ICMPV6_NOT_NEIGHBOUR 2
  79. #define ICMPV6_ADDR_UNREACH 3
  80. #define ICMPV6_PORT_UNREACH 4
  81. /*
  82.  * Codes for Time Exceeded
  83.  */
  84. #define ICMPV6_EXC_HOPLIMIT 0
  85. #define ICMPV6_EXC_FRAGTIME 1
  86. /*
  87.  * Codes for Parameter Problem
  88.  */
  89. #define ICMPV6_HDR_FIELD 0
  90. #define ICMPV6_UNK_NEXTHDR 1
  91. #define ICMPV6_UNK_OPTION 2
  92. /*
  93.  * constants for (set|get)sockopt
  94.  */
  95. #define ICMPV6_FILTER 1
  96. /*
  97.  * ICMPV6 filter
  98.  */
  99. #define ICMPV6_FILTER_BLOCK 1
  100. #define ICMPV6_FILTER_PASS 2
  101. #define ICMPV6_FILTER_BLOCKOTHERS 3
  102. #define ICMPV6_FILTER_PASSONLY 4
  103. struct icmp6_filter {
  104. __u32 data[8];
  105. };
  106. #ifdef __KERNEL__
  107. #include <linux/netdevice.h>
  108. #include <linux/skbuff.h>
  109. extern void icmpv6_send(struct sk_buff *skb,
  110.     int type, int code,
  111.     __u32 info, 
  112.     struct net_device *dev);
  113. extern int icmpv6_init(struct net_proto_family *ops);
  114. extern int icmpv6_err_convert(int type, int code,
  115.    int *err);
  116. extern void icmpv6_cleanup(void);
  117. extern void icmpv6_param_prob(struct sk_buff *skb,
  118.   int code, int pos);
  119. #endif
  120. #endif