Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_ICMPV6_H |
| 2 | #define _LINUX_ICMPV6_H |
| 3 | |
Jaswinder Singh Rajput | 1cc49ae | 2009-01-30 21:18:37 +0530 | [diff] [blame] | 4 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <asm/byteorder.h> |
| 6 | |
| 7 | struct icmp6hdr { |
| 8 | |
| 9 | __u8 icmp6_type; |
| 10 | __u8 icmp6_code; |
Al Viro | 9981a0e | 2006-11-14 21:24:30 -0800 | [diff] [blame] | 11 | __sum16 icmp6_cksum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | |
| 14 | union { |
Al Viro | a27ee7a | 2006-11-08 00:21:21 -0800 | [diff] [blame] | 15 | __be32 un_data32[1]; |
| 16 | __be16 un_data16[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | __u8 un_data8[4]; |
| 18 | |
| 19 | struct icmpv6_echo { |
Al Viro | a27ee7a | 2006-11-08 00:21:21 -0800 | [diff] [blame] | 20 | __be16 identifier; |
| 21 | __be16 sequence; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | } u_echo; |
| 23 | |
| 24 | struct icmpv6_nd_advt { |
| 25 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
| 26 | __u32 reserved:5, |
| 27 | override:1, |
| 28 | solicited:1, |
| 29 | router:1, |
| 30 | reserved2:24; |
| 31 | #elif defined(__BIG_ENDIAN_BITFIELD) |
| 32 | __u32 router:1, |
| 33 | solicited:1, |
| 34 | override:1, |
| 35 | reserved:29; |
| 36 | #else |
| 37 | #error "Please fix <asm/byteorder.h>" |
| 38 | #endif |
| 39 | } u_nd_advt; |
| 40 | |
| 41 | struct icmpv6_nd_ra { |
| 42 | __u8 hop_limit; |
| 43 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
Pedro Ribeiro | 22441cf | 2008-10-15 15:47:49 -0700 | [diff] [blame] | 44 | __u8 reserved:3, |
YOSHIFUJI Hideaki | ebacaaa | 2006-03-20 17:04:53 -0800 | [diff] [blame] | 45 | router_pref:2, |
Pedro Ribeiro | 22441cf | 2008-10-15 15:47:49 -0700 | [diff] [blame] | 46 | home_agent:1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | other:1, |
| 48 | managed:1; |
| 49 | |
| 50 | #elif defined(__BIG_ENDIAN_BITFIELD) |
| 51 | __u8 managed:1, |
| 52 | other:1, |
Pedro Ribeiro | 22441cf | 2008-10-15 15:47:49 -0700 | [diff] [blame] | 53 | home_agent:1, |
YOSHIFUJI Hideaki | ebacaaa | 2006-03-20 17:04:53 -0800 | [diff] [blame] | 54 | router_pref:2, |
Pedro Ribeiro | 22441cf | 2008-10-15 15:47:49 -0700 | [diff] [blame] | 55 | reserved:3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | #else |
| 57 | #error "Please fix <asm/byteorder.h>" |
| 58 | #endif |
Al Viro | a27ee7a | 2006-11-08 00:21:21 -0800 | [diff] [blame] | 59 | __be16 rt_lifetime; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | } u_nd_ra; |
| 61 | |
| 62 | } icmp6_dataun; |
| 63 | |
| 64 | #define icmp6_identifier icmp6_dataun.u_echo.identifier |
| 65 | #define icmp6_sequence icmp6_dataun.u_echo.sequence |
| 66 | #define icmp6_pointer icmp6_dataun.un_data32[0] |
| 67 | #define icmp6_mtu icmp6_dataun.un_data32[0] |
| 68 | #define icmp6_unused icmp6_dataun.un_data32[0] |
| 69 | #define icmp6_maxdelay icmp6_dataun.un_data16[0] |
| 70 | #define icmp6_router icmp6_dataun.u_nd_advt.router |
| 71 | #define icmp6_solicited icmp6_dataun.u_nd_advt.solicited |
| 72 | #define icmp6_override icmp6_dataun.u_nd_advt.override |
| 73 | #define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved |
| 74 | #define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit |
| 75 | #define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed |
| 76 | #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other |
| 77 | #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime |
YOSHIFUJI Hideaki | ebacaaa | 2006-03-20 17:04:53 -0800 | [diff] [blame] | 78 | #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
Arnaldo Carvalho de Melo | cc70ab2 | 2007-03-13 14:03:22 -0300 | [diff] [blame] | 81 | #ifdef __KERNEL__ |
| 82 | #include <linux/skbuff.h> |
| 83 | |
| 84 | static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb) |
| 85 | { |
Arnaldo Carvalho de Melo | 9c70220 | 2007-04-25 18:04:18 -0700 | [diff] [blame] | 86 | return (struct icmp6hdr *)skb_transport_header(skb); |
Arnaldo Carvalho de Melo | cc70ab2 | 2007-03-13 14:03:22 -0300 | [diff] [blame] | 87 | } |
| 88 | #endif |
| 89 | |
YOSHIFUJI Hideaki | ebacaaa | 2006-03-20 17:04:53 -0800 | [diff] [blame] | 90 | #define ICMPV6_ROUTER_PREF_LOW 0x3 |
| 91 | #define ICMPV6_ROUTER_PREF_MEDIUM 0x0 |
| 92 | #define ICMPV6_ROUTER_PREF_HIGH 0x1 |
| 93 | #define ICMPV6_ROUTER_PREF_INVALID 0x2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
| 95 | #define ICMPV6_DEST_UNREACH 1 |
| 96 | #define ICMPV6_PKT_TOOBIG 2 |
| 97 | #define ICMPV6_TIME_EXCEED 3 |
| 98 | #define ICMPV6_PARAMPROB 4 |
| 99 | |
| 100 | #define ICMPV6_INFOMSG_MASK 0x80 |
| 101 | |
| 102 | #define ICMPV6_ECHO_REQUEST 128 |
| 103 | #define ICMPV6_ECHO_REPLY 129 |
| 104 | #define ICMPV6_MGM_QUERY 130 |
| 105 | #define ICMPV6_MGM_REPORT 131 |
| 106 | #define ICMPV6_MGM_REDUCTION 132 |
| 107 | |
| 108 | #define ICMPV6_NI_QUERY 139 |
| 109 | #define ICMPV6_NI_REPLY 140 |
| 110 | |
| 111 | #define ICMPV6_MLD2_REPORT 143 |
| 112 | |
| 113 | #define ICMPV6_DHAAD_REQUEST 144 |
| 114 | #define ICMPV6_DHAAD_REPLY 145 |
| 115 | #define ICMPV6_MOBILE_PREFIX_SOL 146 |
| 116 | #define ICMPV6_MOBILE_PREFIX_ADV 147 |
| 117 | |
| 118 | /* |
| 119 | * Codes for Destination Unreachable |
| 120 | */ |
| 121 | #define ICMPV6_NOROUTE 0 |
| 122 | #define ICMPV6_ADM_PROHIBITED 1 |
| 123 | #define ICMPV6_NOT_NEIGHBOUR 2 |
| 124 | #define ICMPV6_ADDR_UNREACH 3 |
| 125 | #define ICMPV6_PORT_UNREACH 4 |
| 126 | |
| 127 | /* |
| 128 | * Codes for Time Exceeded |
| 129 | */ |
| 130 | #define ICMPV6_EXC_HOPLIMIT 0 |
| 131 | #define ICMPV6_EXC_FRAGTIME 1 |
| 132 | |
| 133 | /* |
| 134 | * Codes for Parameter Problem |
| 135 | */ |
| 136 | #define ICMPV6_HDR_FIELD 0 |
| 137 | #define ICMPV6_UNK_NEXTHDR 1 |
| 138 | #define ICMPV6_UNK_OPTION 2 |
| 139 | |
| 140 | /* |
| 141 | * constants for (set|get)sockopt |
| 142 | */ |
| 143 | |
| 144 | #define ICMPV6_FILTER 1 |
| 145 | |
| 146 | /* |
| 147 | * ICMPV6 filter |
| 148 | */ |
| 149 | |
| 150 | #define ICMPV6_FILTER_BLOCK 1 |
| 151 | #define ICMPV6_FILTER_PASS 2 |
| 152 | #define ICMPV6_FILTER_BLOCKOTHERS 3 |
| 153 | #define ICMPV6_FILTER_PASSONLY 4 |
| 154 | |
| 155 | struct icmp6_filter { |
| 156 | __u32 data[8]; |
| 157 | }; |
| 158 | |
| 159 | /* |
| 160 | * Definitions for MLDv2 |
| 161 | */ |
| 162 | #define MLD2_MODE_IS_INCLUDE 1 |
| 163 | #define MLD2_MODE_IS_EXCLUDE 2 |
| 164 | #define MLD2_CHANGE_TO_INCLUDE 3 |
| 165 | #define MLD2_CHANGE_TO_EXCLUDE 4 |
| 166 | #define MLD2_ALLOW_NEW_SOURCES 5 |
| 167 | #define MLD2_BLOCK_OLD_SOURCES 6 |
| 168 | |
| 169 | #define MLD2_ALL_MCR_INIT { { { 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 } } } |
| 170 | |
| 171 | #ifdef __KERNEL__ |
| 172 | |
| 173 | #include <linux/netdevice.h> |
| 174 | #include <linux/skbuff.h> |
| 175 | |
| 176 | |
| 177 | extern void icmpv6_send(struct sk_buff *skb, |
Brian Haley | d5fdd6b | 2009-06-23 04:31:07 -0700 | [diff] [blame] | 178 | u8 type, u8 code, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | __u32 info, |
| 180 | struct net_device *dev); |
| 181 | |
Denis V. Lunev | 9b0f976 | 2008-02-29 11:13:15 -0800 | [diff] [blame] | 182 | extern int icmpv6_init(void); |
Brian Haley | d5fdd6b | 2009-06-23 04:31:07 -0700 | [diff] [blame] | 183 | extern int icmpv6_err_convert(u8 type, u8 code, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | int *err); |
| 185 | extern void icmpv6_cleanup(void); |
| 186 | extern void icmpv6_param_prob(struct sk_buff *skb, |
Brian Haley | d5fdd6b | 2009-06-23 04:31:07 -0700 | [diff] [blame] | 187 | u8 code, int pos); |
YOSHIFUJI Hideaki | 95e41e9 | 2007-12-06 15:43:30 -0800 | [diff] [blame] | 188 | |
| 189 | struct flowi; |
David S. Miller | f59d438 | 2008-03-05 20:58:10 -0800 | [diff] [blame] | 190 | struct in6_addr; |
YOSHIFUJI Hideaki | 95e41e9 | 2007-12-06 15:43:30 -0800 | [diff] [blame] | 191 | extern void icmpv6_flow_init(struct sock *sk, |
| 192 | struct flowi *fl, |
| 193 | u8 type, |
| 194 | const struct in6_addr *saddr, |
| 195 | const struct in6_addr *daddr, |
| 196 | int oif); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | #endif |
| 198 | |
| 199 | #endif |