mikroSDK Reference Manual
icmpv6.h
Go to the documentation of this file.
1
31#ifndef _ICMPV6_H
32#define _ICMPV6_H
33
34//Dependencies
35#include "core/net.h"
36
37//C++ guard
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42
51typedef enum
52{
53 ICMPV6_TYPE_DEST_UNREACHABLE = 1,
54 ICMPV6_TYPE_PACKET_TOO_BIG = 2,
55 ICMPV6_TYPE_TIME_EXCEEDED = 3,
56 ICMPV6_TYPE_PARAM_PROBLEM = 4,
57 ICMPV6_TYPE_ECHO_REQUEST = 128,
58 ICMPV6_TYPE_ECHO_REPLY = 129,
59 ICMPV6_TYPE_MULTICAST_LISTENER_QUERY = 130,
60 ICMPV6_TYPE_MULTICAST_LISTENER_REPORT_V1 = 131,
61 ICMPV6_TYPE_MULTICAST_LISTENER_DONE_V1 = 132,
62 ICMPV6_TYPE_ROUTER_SOL = 133,
63 ICMPV6_TYPE_ROUTER_ADV = 134,
64 ICMPV6_TYPE_NEIGHBOR_SOL = 135,
65 ICMPV6_TYPE_NEIGHBOR_ADV = 136,
66 ICMPV6_TYPE_REDIRECT = 137,
67 ICMPV6_TYPE_MULTICAST_LISTENER_REPORT_V2 = 143
69
70
75typedef enum
76{
77 ICMPV6_CODE_NO_ROUTE_TO_DEST = 0,
78 ICMPV6_CODE_ADMIN_PROHIBITED = 1,
79 ICMPV6_CODE_BEYOND_SCOPE_OF_SRC_ADDR = 2,
80 ICMPV6_CODE_ADDR_UNREACHABLE = 3,
81 ICMPV6_CODE_PORT_UNREACHABLE = 4
83
84
89typedef enum
90{
91 ICMPV6_CODE_HOP_LIMIT_EXCEEDED = 0,
92 ICMPV6_CODE_REASSEMBLY_TIME_EXCEEDED = 1
94
95
99typedef enum
100{
101 ICMPV6_CODE_INVALID_HEADER_FIELD = 0,
102 ICMPV6_CODE_UNKNOWN_NEXT_HEADER = 1,
103 ICMPV6_CODE_UNKNOWN_IPV6_OPTION = 2
105
106
107//CodeWarrior or Win32 compiler?
108#if defined(__CWCC__) || defined(_WIN32)
109 #pragma pack(push, 1)
110#endif
111
112
118{
119 uint8_t type; //0
120 uint8_t code; //1
121 uint16_t checksum; //2-3
122 uint8_t data[]; //4
123} Icmpv6Header;
124
125
130typedef __packed_struct
131{
132 uint8_t type; //0
133 uint8_t code; //1
134 uint16_t checksum; //2-3
135 uint32_t parameter; //4-7
136 uint8_t data[]; //8
137} Icmpv6ErrorMessage;
138
139
149typedef __packed_struct
150{
151 uint8_t type; //0
152 uint8_t code; //1
153 uint16_t checksum; //2-3
154 uint32_t unused; //4-7
155 uint8_t data[]; //8
156} Icmpv6DestUnreachableMessage;
157
158
168typedef __packed_struct
169{
170 uint8_t type; //0
171 uint8_t code; //1
172 uint16_t checksum; //2-3
173 uint32_t mtu; //4-7
174 uint8_t data[]; //8
175} Icmpv6PacketTooBigMessage;
176
177
186typedef __packed_struct
187{
188 uint8_t type; //0
189 uint8_t code; //1
190 uint16_t checksum; //2-3
191 uint32_t unused; //4-7
192 uint8_t data[]; //8
193} Icmpv6TimeExceededMessage;
194
195
205typedef __packed_struct
206{
207 uint8_t type; //0
208 uint8_t code; //1
209 uint16_t checksum; //2-3
210 uint32_t pointer; //4-7
211 uint8_t data[]; //8
212} Icmpv6ParamProblemMessage;
213
214
223typedef __packed_struct
224{
225 uint8_t type; //0
226 uint8_t code; //1
227 uint16_t checksum; //2-3
228 uint16_t identifier; //4-6
229 uint16_t sequenceNumber; //7-8
230 uint8_t data[]; //8
231} Icmpv6EchoMessage;
232
233
234//CodeWarrior or Win32 compiler?
235#if defined(__CWCC__) || defined(_WIN32)
236 #pragma pack(pop)
237#endif
238
239//ICMPv6 related functions
240error_t icmpv6EnableEchoRequests(NetInterface *interface, bool_t enable);
241
242error_t icmpv6EnableMulticastEchoRequests(NetInterface *interface,
243 bool_t enable);
244
245void icmpv6ProcessMessage(NetInterface *interface,
246 const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
247 size_t offset, uint8_t hopLimit);
248
249void icmpv6ProcessDestUnreachable(NetInterface *interface,
250 const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
251 size_t offset);
252
253void icmpv6ProcessPacketTooBig(NetInterface *interface,
254 const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
255 size_t offset);
256
257void icmpv6ProcessEchoRequest(NetInterface *interface,
258 const Ipv6PseudoHeader *requestPseudoHeader, const NetBuffer *request,
259 size_t requestOffset);
260
261error_t icmpv6SendErrorMessage(NetInterface *interface, uint8_t type,
262 uint8_t code, uint32_t parameter, const NetBuffer *ipPacket,
263 size_t ipPacketOffset);
264
265void icmpv6DumpMessage(const Icmpv6Header *message);
266void icmpv6DumpDestUnreachableMessage(const Icmpv6DestUnreachableMessage *message);
267void icmpv6DumpPacketTooBigMessage(const Icmpv6PacketTooBigMessage *message);
268void icmpv6DumpEchoMessage(const Icmpv6EchoMessage *message);
269void icmpv6DumpErrorMessage(const Icmpv6ErrorMessage *message);
270
271//C++ guard
272#ifdef __cplusplus
273}
274#endif
275
276#endif
error_t
Error codes.
Definition error.h:43
Icmpv6Type
ICMPv6 message type.
Definition icmpv6.h:52
Icmpv6DestUnreachableCode
Destination Unreachable message codes.
Definition icmpv6.h:76
Icmpv6ParamProblemCode
Parameter Problem message codes.
Definition icmpv6.h:100
typedef __packed_struct
ICMPv6 header.
Definition icmpv6.h:118
Icmpv6TimeExceededCode
Time Exceeded message codes.
Definition icmpv6.h:90
TCP/IP stack core.
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89