mikroSDK Reference Manual
icmp.h
Go to the documentation of this file.
1
31#ifndef _ICMP_H
32#define _ICMP_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 ICMP_TYPE_ECHO_REPLY = 0,
54 ICMP_TYPE_DEST_UNREACHABLE = 3,
55 ICMP_TYPE_SOURCE_QUENCH = 4,
56 ICMP_TYPE_REDIRECT = 5,
57 ICMP_TYPE_ECHO_REQUEST = 8,
58 ICMP_TYPE_TIME_EXCEEDED = 11,
59 ICMP_TYPE_PARAM_PROBLEM = 12,
60 ICMP_TYPE_TIMESTAMP_REQUEST = 13,
61 ICMP_TYPE_TIMESTAMP_REPLY = 14,
62 ICMP_TYPE_INFO_REQUEST = 15,
63 ICMP_TYPE_INFO_REPLY = 16,
64 ICMP_TYPE_ADDR_MASK_REQUEST = 17,
65 ICMP_TYPE_ADDR_MASK_REPLY = 18
66} IcmpType;
67
68
73typedef enum
74{
75 ICMP_CODE_NET_UNREACHABLE = 0,
76 ICMP_CODE_HOST_UNREACHABLE = 1,
77 ICMP_CODE_PROTOCOL_UNREACHABLE = 2,
78 ICMP_CODE_PORT_UNREACHABLE = 3,
79 ICMP_CODE_FRAG_NEEDED_AND_DF_SET = 4,
80 ICMP_CODE_SOURCE_ROUTE_FAILED = 5
82
83
88typedef enum
89{
90 ICMP_CODE_TTL_EXCEEDED = 0,
91 ICMP_CODE_REASSEMBLY_TIME_EXCEEDED = 1
93
94
95//CodeWarrior or Win32 compiler?
96#if defined(__CWCC__) || defined(_WIN32)
97 #pragma pack(push, 1)
98#endif
99
100
106{
107 uint8_t type; //0
108 uint8_t code; //1
109 uint16_t checksum; //2-3
110 uint8_t data[]; //4
111} IcmpHeader;
112
113
118typedef __packed_struct
119{
120 uint8_t type; //0
121 uint8_t code; //1
122 uint16_t checksum; //2-3
123 uint8_t parameter; //4
124 uint8_t unused[3]; //5-7
125 uint8_t data[]; //8
126} IcmpErrorMessage;
127
128
133typedef __packed_struct
134{
135 uint8_t type; //0
136 uint8_t code; //1
137 uint16_t checksum; //2-3
138 uint32_t unused; //4-7
139 uint8_t data[]; //8
140} IcmpDestUnreachableMessage;
141
142
147typedef __packed_struct
148{
149 uint8_t type; //0
150 uint8_t code; //1
151 uint16_t checksum; //2-3
152 uint32_t unused; //4-7
153 uint8_t data[]; //8
154} IcmpTimeExceededMessage;
155
156
161typedef __packed_struct
162{
163 uint8_t type; //0
164 uint8_t code; //1
165 uint16_t checksum; //2-3
166 uint8_t pointer; //4
167 uint8_t unused[3]; //5-7
168 uint8_t data[]; //8
169} IcmpParamProblemMessage;
170
171
176typedef __packed_struct
177{
178 uint8_t type; //0
179 uint8_t code; //1
180 uint16_t checksum; //2-3
181 uint16_t identifier; //4-5
182 uint16_t sequenceNumber; //6-7
183 uint8_t data[]; //8
184} IcmpEchoMessage;
185
186
187//CodeWarrior or Win32 compiler?
188#if defined(__CWCC__) || defined(_WIN32)
189 #pragma pack(pop)
190#endif
191
192//ICMP related functions
193error_t icmpEnableEchoRequests(NetInterface *interface, bool_t enable);
194
195error_t icmpEnableBroadcastEchoRequests(NetInterface *interface,
196 bool_t enable);
197
198void icmpProcessMessage(NetInterface *interface,
199 const Ipv4PseudoHeader *requestPseudoHeader, const NetBuffer *buffer,
200 size_t offset);
201
202void icmpProcessEchoRequest(NetInterface *interface,
203 const Ipv4PseudoHeader *requestPseudoHeader, const NetBuffer *request,
204 size_t requestOffset);
205
206error_t icmpSendErrorMessage(NetInterface *interface, uint8_t type,
207 uint8_t code, uint8_t parameter, const NetBuffer *ipPacket,
208 size_t ipPacketOffset);
209
210void icmpUpdateInStats(uint8_t type);
211void icmpUpdateOutStats(uint8_t type);
212
213void icmpDumpMessage(const IcmpHeader *message);
214void icmpDumpEchoMessage(const IcmpEchoMessage *message);
215void icmpDumpErrorMessage(const IcmpErrorMessage *message);
216
217//C++ guard
218#ifdef __cplusplus
219}
220#endif
221
222#endif
error_t
Error codes.
Definition error.h:43
IcmpType
ICMP message type.
Definition icmp.h:52
IcmpTimeExceededCode
Time Exceeded message codes.
Definition icmp.h:89
IcmpDestUnreachableCode
Destination Unreachable message codes.
Definition icmp.h:74
typedef __packed_struct
ICMP header.
Definition icmp.h:106
TCP/IP stack core.
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89