blob: 03067443198a3baf0e5bef0c3ba0dfa05499fd1d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_ICMPV6_H
2#define _LINUX_ICMPV6_H
3
4#include <asm/byteorder.h>
5
6struct icmp6hdr {
7
8 __u8 icmp6_type;
9 __u8 icmp6_code;
Al Viro9981a0e2006-11-14 21:24:30 -080010 __sum16 icmp6_cksum;
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
12
13 union {
Al Viroa27ee7a2006-11-08 00:21:21 -080014 __be32 un_data32[1];
15 __be16 un_data16[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 __u8 un_data8[4];
17
18 struct icmpv6_echo {
Al Viroa27ee7a2006-11-08 00:21:21 -080019 __be16 identifier;
20 __be16 sequence;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 } u_echo;
22
23 struct icmpv6_nd_advt {
24#if defined(__LITTLE_ENDIAN_BITFIELD)
25 __u32 reserved:5,
26 override:1,
27 solicited:1,
28 router:1,
29 reserved2:24;
30#elif defined(__BIG_ENDIAN_BITFIELD)
31 __u32 router:1,
32 solicited:1,
33 override:1,
34 reserved:29;
35#else
36#error "Please fix <asm/byteorder.h>"
37#endif
38 } u_nd_advt;
39
40 struct icmpv6_nd_ra {
41 __u8 hop_limit;
42#if defined(__LITTLE_ENDIAN_BITFIELD)
YOSHIFUJI Hideakiebacaaa2006-03-20 17:04:53 -080043 __u8 reserved:4,
44 router_pref:2,
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 other:1,
46 managed:1;
47
48#elif defined(__BIG_ENDIAN_BITFIELD)
49 __u8 managed:1,
50 other:1,
YOSHIFUJI Hideakiebacaaa2006-03-20 17:04:53 -080051 router_pref:2,
52 reserved:4;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#else
54#error "Please fix <asm/byteorder.h>"
55#endif
Al Viroa27ee7a2006-11-08 00:21:21 -080056 __be16 rt_lifetime;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 } u_nd_ra;
58
59 } icmp6_dataun;
60
61#define icmp6_identifier icmp6_dataun.u_echo.identifier
62#define icmp6_sequence icmp6_dataun.u_echo.sequence
63#define icmp6_pointer icmp6_dataun.un_data32[0]
64#define icmp6_mtu icmp6_dataun.un_data32[0]
65#define icmp6_unused icmp6_dataun.un_data32[0]
66#define icmp6_maxdelay icmp6_dataun.un_data16[0]
67#define icmp6_router icmp6_dataun.u_nd_advt.router
68#define icmp6_solicited icmp6_dataun.u_nd_advt.solicited
69#define icmp6_override icmp6_dataun.u_nd_advt.override
70#define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved
71#define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit
72#define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed
73#define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
74#define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
YOSHIFUJI Hideakiebacaaa2006-03-20 17:04:53 -080075#define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref
Linus Torvalds1da177e2005-04-16 15:20:36 -070076};
77
Arnaldo Carvalho de Melocc70ab22007-03-13 14:03:22 -030078#ifdef __KERNEL__
79#include <linux/skbuff.h>
80
81static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb)
82{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -070083 return (struct icmp6hdr *)skb_transport_header(skb);
Arnaldo Carvalho de Melocc70ab22007-03-13 14:03:22 -030084}
85#endif
86
YOSHIFUJI Hideakiebacaaa2006-03-20 17:04:53 -080087#define ICMPV6_ROUTER_PREF_LOW 0x3
88#define ICMPV6_ROUTER_PREF_MEDIUM 0x0
89#define ICMPV6_ROUTER_PREF_HIGH 0x1
90#define ICMPV6_ROUTER_PREF_INVALID 0x2
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92#define ICMPV6_DEST_UNREACH 1
93#define ICMPV6_PKT_TOOBIG 2
94#define ICMPV6_TIME_EXCEED 3
95#define ICMPV6_PARAMPROB 4
96
97#define ICMPV6_INFOMSG_MASK 0x80
98
99#define ICMPV6_ECHO_REQUEST 128
100#define ICMPV6_ECHO_REPLY 129
101#define ICMPV6_MGM_QUERY 130
102#define ICMPV6_MGM_REPORT 131
103#define ICMPV6_MGM_REDUCTION 132
104
105#define ICMPV6_NI_QUERY 139
106#define ICMPV6_NI_REPLY 140
107
108#define ICMPV6_MLD2_REPORT 143
109
110#define ICMPV6_DHAAD_REQUEST 144
111#define ICMPV6_DHAAD_REPLY 145
112#define ICMPV6_MOBILE_PREFIX_SOL 146
113#define ICMPV6_MOBILE_PREFIX_ADV 147
114
115/*
116 * Codes for Destination Unreachable
117 */
118#define ICMPV6_NOROUTE 0
119#define ICMPV6_ADM_PROHIBITED 1
120#define ICMPV6_NOT_NEIGHBOUR 2
121#define ICMPV6_ADDR_UNREACH 3
122#define ICMPV6_PORT_UNREACH 4
123
124/*
125 * Codes for Time Exceeded
126 */
127#define ICMPV6_EXC_HOPLIMIT 0
128#define ICMPV6_EXC_FRAGTIME 1
129
130/*
131 * Codes for Parameter Problem
132 */
133#define ICMPV6_HDR_FIELD 0
134#define ICMPV6_UNK_NEXTHDR 1
135#define ICMPV6_UNK_OPTION 2
136
137/*
138 * constants for (set|get)sockopt
139 */
140
141#define ICMPV6_FILTER 1
142
143/*
144 * ICMPV6 filter
145 */
146
147#define ICMPV6_FILTER_BLOCK 1
148#define ICMPV6_FILTER_PASS 2
149#define ICMPV6_FILTER_BLOCKOTHERS 3
150#define ICMPV6_FILTER_PASSONLY 4
151
152struct icmp6_filter {
153 __u32 data[8];
154};
155
156/*
157 * Definitions for MLDv2
158 */
159#define MLD2_MODE_IS_INCLUDE 1
160#define MLD2_MODE_IS_EXCLUDE 2
161#define MLD2_CHANGE_TO_INCLUDE 3
162#define MLD2_CHANGE_TO_EXCLUDE 4
163#define MLD2_ALLOW_NEW_SOURCES 5
164#define MLD2_BLOCK_OLD_SOURCES 6
165
166#define MLD2_ALL_MCR_INIT { { { 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 } } }
167
168#ifdef __KERNEL__
169
170#include <linux/netdevice.h>
171#include <linux/skbuff.h>
172
173
174extern void icmpv6_send(struct sk_buff *skb,
175 int type, int code,
176 __u32 info,
177 struct net_device *dev);
178
Denis V. Lunev9b0f9762008-02-29 11:13:15 -0800179extern int icmpv6_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180extern int icmpv6_err_convert(int type, int code,
181 int *err);
182extern void icmpv6_cleanup(void);
183extern void icmpv6_param_prob(struct sk_buff *skb,
184 int code, int pos);
YOSHIFUJI Hideaki95e41e92007-12-06 15:43:30 -0800185
186struct flowi;
David S. Millerf59d4382008-03-05 20:58:10 -0800187struct in6_addr;
YOSHIFUJI Hideaki95e41e92007-12-06 15:43:30 -0800188extern void icmpv6_flow_init(struct sock *sk,
189 struct flowi *fl,
190 u8 type,
191 const struct in6_addr *saddr,
192 const struct in6_addr *daddr,
193 int oif);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194#endif
195
196#endif