]> granicus.if.org Git - esp-idf/blob - components/lwip/include/lwip/lwip/icmp6.h
Initial public version
[esp-idf] / components / lwip / include / lwip / lwip / icmp6.h
1 /**
2  * @file
3  *
4  * IPv6 version of ICMP, as per RFC 4443.
5  */
6
7 /*
8  * Copyright (c) 2010 Inico Technologies Ltd.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without modification,
12  * are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  *    this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  *    this list of conditions and the following disclaimer in the documentation
18  *    and/or other materials provided with the distribution.
19  * 3. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31  * OF SUCH DAMAGE.
32  *
33  * This file is part of the lwIP TCP/IP stack.
34  *
35  * Author: Ivan Delamer <delamer@inicotech.com>
36  *
37  *
38  * Please coordinate changes and requests with Ivan Delamer
39  * <delamer@inicotech.com>
40  */
41 #ifndef LWIP_HDR_ICMP6_H
42 #define LWIP_HDR_ICMP6_H
43
44 #include "lwip/opt.h"
45 #include "lwip/pbuf.h"
46 #include "lwip/ip6_addr.h"
47 #include "lwip/netif.h"
48
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 enum icmp6_type {
55   ICMP6_TYPE_DUR = 1,  /* Destination unreachable */
56   ICMP6_TYPE_PTB = 2,  /* Packet too big */
57   ICMP6_TYPE_TE = 3,   /* Time exceeded */
58   ICMP6_TYPE_PP = 4,   /* Parameter problem */
59   ICMP6_TYPE_PE1 = 100,  /* Private experimentation */
60   ICMP6_TYPE_PE2 = 101,  /* Private experimentation */
61   ICMP6_TYPE_RSV_ERR = 127,  /* Reserved for expansion of error messages */
62
63   ICMP6_TYPE_EREQ = 128,  /* Echo request */
64   ICMP6_TYPE_EREP = 129,  /* Echo reply */
65   ICMP6_TYPE_MLQ = 130,  /* Multicast listener query */
66   ICMP6_TYPE_MLR = 131,  /* Multicast listener report */
67   ICMP6_TYPE_MLD = 132,  /* Multicast listener done */
68   ICMP6_TYPE_RS = 133,  /* Router solicitation */
69   ICMP6_TYPE_RA = 134,  /* Router advertisement */
70   ICMP6_TYPE_NS = 135,  /* Neighbor solicitation */
71   ICMP6_TYPE_NA = 136,  /* Neighbor advertisement */
72   ICMP6_TYPE_RD = 137,  /* Redirect */
73   ICMP6_TYPE_MRA = 151,  /* Multicast router advertisement */
74   ICMP6_TYPE_MRS = 152,  /* Multicast router solicitation */
75   ICMP6_TYPE_MRT = 153,  /* Multicast router termination */
76   ICMP6_TYPE_PE3 = 200,  /* Private experimentation */
77   ICMP6_TYPE_PE4 = 201,  /* Private experimentation */
78   ICMP6_TYPE_RSV_INF = 255  /* Reserved for expansion of informational messages */
79 };
80
81 enum icmp6_dur_code {
82   ICMP6_DUR_NO_ROUTE = 0,     /* No route to destination */
83   ICMP6_DUR_PROHIBITED = 1,   /* Communication with destination administratively prohibited */
84   ICMP6_DUR_SCOPE = 2,        /* Beyond scope of source address */
85   ICMP6_DUR_ADDRESS = 3,      /* Address unreachable */
86   ICMP6_DUR_PORT = 4,         /* Port unreachable */
87   ICMP6_DUR_POLICY = 5,       /* Source address failed ingress/egress policy */
88   ICMP6_DUR_REJECT_ROUTE = 6  /* Reject route to destination */
89 };
90
91 enum icmp6_te_code {
92   ICMP6_TE_HL = 0,   /* Hop limit exceeded in transit */
93   ICMP6_TE_FRAG = 1  /* Fragment reassembly time exceeded */
94 };
95
96 enum icmp6_pp_code {
97   ICMP6_PP_FIELD = 0,   /* Erroneous header field encountered */
98   ICMP6_PP_HEADER = 1,  /* Unrecognized next header type encountered */
99   ICMP6_PP_OPTION = 2   /* Unrecognized IPv6 option encountered */
100 };
101
102 /** This is the standard ICMP6 header. */
103 #ifdef PACK_STRUCT_USE_INCLUDES
104 #  include "arch/bpstruct.h"
105 #endif
106 PACK_STRUCT_BEGIN
107 struct icmp6_hdr {
108   PACK_STRUCT_FLD_8(u8_t type);
109   PACK_STRUCT_FLD_8(u8_t code);
110   PACK_STRUCT_FIELD(u16_t chksum);
111   PACK_STRUCT_FIELD(u32_t data);
112 } PACK_STRUCT_STRUCT;
113 PACK_STRUCT_END
114 #ifdef PACK_STRUCT_USE_INCLUDES
115 #  include "arch/epstruct.h"
116 #endif
117
118 /** This is the ICMP6 header adapted for echo req/resp. */
119 #ifdef PACK_STRUCT_USE_INCLUDES
120 #  include "arch/bpstruct.h"
121 #endif
122 PACK_STRUCT_BEGIN
123 struct icmp6_echo_hdr {
124   PACK_STRUCT_FLD_8(u8_t type);
125   PACK_STRUCT_FLD_8(u8_t code);
126   PACK_STRUCT_FIELD(u16_t chksum);
127   PACK_STRUCT_FIELD(u16_t id);
128   PACK_STRUCT_FIELD(u16_t seqno);
129 } PACK_STRUCT_STRUCT;
130 PACK_STRUCT_END
131 #ifdef PACK_STRUCT_USE_INCLUDES
132 #  include "arch/epstruct.h"
133 #endif
134
135
136 #if LWIP_ICMP6 && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
137
138 void icmp6_input(struct pbuf *p, struct netif *inp);
139 void icmp6_dest_unreach(struct pbuf *p, enum icmp6_dur_code c);
140 void icmp6_packet_too_big(struct pbuf *p, u32_t mtu);
141 void icmp6_time_exceeded(struct pbuf *p, enum icmp6_te_code c);
142 void icmp6_param_problem(struct pbuf *p, enum icmp6_pp_code c, u32_t pointer);
143
144 #endif /* LWIP_ICMP6 && LWIP_IPV6 */
145
146
147 #ifdef __cplusplus
148 }
149 #endif
150
151
152 #endif /* LWIP_HDR_ICMP6_H */