12 { ICMP_ECHO_REPLY, ICMP_QUERY_MESSAGE },
13 { 1, ICMP_INVALID_MESSAGE },
14 { 2, ICMP_INVALID_MESSAGE },
15 { ICMP_DEST_UNREACHABLE, ICMP_ERROR_MESSAGE },
16 { ICMP_SOURCE_QUENCH, ICMP_ERROR_MESSAGE },
17 { ICMP_REDIRECT, ICMP_ERROR_MESSAGE },
18 { 6, ICMP_INVALID_MESSAGE },
19 { 7, ICMP_INVALID_MESSAGE },
20 { ICMP_ECHO_REQUEST, ICMP_QUERY_MESSAGE },
21 { 9, ICMP_INVALID_MESSAGE },
22 { 10, ICMP_INVALID_MESSAGE },
23 { ICMP_TIME_EXCEEDED, ICMP_ERROR_MESSAGE },
24 { ICMP_PARAMETER_PROBLEM, ICMP_ERROR_MESSAGE },
25 { ICMP_TIMESTAMP, ICMP_QUERY_MESSAGE },
26 { 14, ICMP_INVALID_MESSAGE },
27 { ICMP_INFO_REQUEST, ICMP_QUERY_MESSAGE },
28 { ICMP_INFO_REPLY, ICMP_QUERY_MESSAGE },
32 mIp4SupportedIcmp[23] = {
33 { ICMP_ECHO_REPLY, ICMP_DEFAULT_CODE },
35 { ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE },
36 { ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE },
37 { ICMP_DEST_UNREACHABLE, ICMP_PROTO_UNREACHABLE },
38 { ICMP_DEST_UNREACHABLE, ICMP_PORT_UNREACHABLE },
39 { ICMP_DEST_UNREACHABLE, ICMP_FRAGMENT_FAILED },
40 { ICMP_DEST_UNREACHABLE, ICMP_SOURCEROUTE_FAILED },
41 { ICMP_DEST_UNREACHABLE, ICMP_NET_UNKNOWN },
42 { ICMP_DEST_UNREACHABLE, ICMP_HOST_UNKNOWN },
43 { ICMP_DEST_UNREACHABLE, ICMP_SOURCE_ISOLATED },
44 { ICMP_DEST_UNREACHABLE, ICMP_NET_PROHIBITED },
45 { ICMP_DEST_UNREACHABLE, ICMP_HOST_PROHIBITED },
46 { ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE_TOS },
47 { ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE_TOS },
49 { ICMP_SOURCE_QUENCH, ICMP_DEFAULT_CODE },
51 { ICMP_REDIRECT, ICMP_NET_REDIRECT },
52 { ICMP_REDIRECT, ICMP_HOST_REDIRECT },
53 { ICMP_REDIRECT, ICMP_NET_TOS_REDIRECT },
54 { ICMP_REDIRECT, ICMP_HOST_TOS_REDIRECT },
56 { ICMP_ECHO_REQUEST, ICMP_DEFAULT_CODE },
58 { ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_IN_TRANSIT },
59 { ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_REASSEMBLE },
61 { ICMP_PARAMETER_PROBLEM, ICMP_DEFAULT_CODE },
108 Gateway = NTOHL (Icmp->Fourth);
115 if ((IpIf ==
NULL) || !IP4_NET_EQUAL (Gateway, IpIf->Ip, IpIf->SubnetMask)) {
117 return EFI_INVALID_PARAMETER;
123 NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
124 Ip4Instance = NET_LIST_USER_STRUCT (Entry,
IP4_PROTOCOL, AddrLink);
126 if (Ip4Instance->RouteTable ==
NULL) {
130 Dst = NTOHL (Icmp->IpHead.Dst);
131 Src = NTOHL (Icmp->IpHead.Src);
138 if ((CacheEntry !=
NULL) && (NTOHL (Head->Src) == CacheEntry->NextHop)) {
139 CacheEntry->NextHop = Gateway;
171 if (Packet->TotalSize < sizeof (Icmp)) {
173 return EFI_INVALID_PARAMETER;
176 NetbufCopy (Packet, 0,
sizeof (Icmp), (UINT8 *)&Icmp);
182 if (Icmp.Head.Type == ICMP_REDIRECT) {
186 IP4_GET_CLIP_INFO (Packet)->Status = EFI_ICMP_ERROR;
222 Status = EFI_OUT_OF_RESOURCES;
233 ASSERT (Icmp !=
NULL);
234 Icmp->Head.Type = ICMP_ECHO_REPLY;
235 Icmp->Head.Checksum = 0;
236 Icmp->Head.Checksum = (UINT16)(~
NetblockChecksum ((UINT8 *)Icmp, Data->TotalSize));
239 ReplyHead.Fragment = 0;
241 ReplyHead.Protocol = EFI_IP_PROTO_ICMP;
247 ReplyHead.Dst = Head->Src;
260 if (EFI_ERROR (Status)) {
292 if (Packet->TotalSize < sizeof (Icmp)) {
294 return EFI_INVALID_PARAMETER;
297 NetbufCopy (Packet, 0,
sizeof (Icmp), (UINT8 *)&Icmp);
299 if (Icmp.Head.Type == ICMP_ECHO_REQUEST) {
331 if (Packet->TotalSize < sizeof (Icmp)) {
335 NetbufCopy (Packet, 0,
sizeof (Icmp), (UINT8 *)&Icmp);
337 if (Icmp.Type > ICMP_TYPE_MAX) {
342 if ((Icmp.Checksum != 0) && (Checksum != 0)) {
346 if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_ERROR_MESSAGE) {
348 }
else if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_QUERY_MESSAGE) {
354 return EFI_INVALID_PARAMETER;
IP4_INTERFACE * Ip4FindInterface(IN IP4_SERVICE *IpSb, IN IP4_ADDR Ip)
EFI_STATUS Ip4ProcessIcmpError(IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet)
EFI_STATUS Ip4IcmpReplyEcho(IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet)
EFI_STATUS Ip4ProcessIcmpRedirect(IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet, IN IP4_ICMP_ERROR_HEAD *Icmp)
EFI_STATUS Ip4ProcessIcmpQuery(IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet)
EFI_STATUS Ip4IcmpHandle(IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet)
VOID Ip4SysPacketSent(IP4_PROTOCOL *Ip4Instance, NET_BUF *Packet, EFI_STATUS IoStatus, UINT32 LinkFlag, VOID *Context)
EFI_STATUS Ip4Output(IN IP4_SERVICE *IpSb, IN IP4_PROTOCOL *IpInstance OPTIONAL, IN NET_BUF *Packet, IN IP4_HEAD *Head, IN UINT8 *Option, IN UINT32 OptLen, IN IP4_ADDR GateWay, IN IP4_FRAME_CALLBACK Callback, IN VOID *Context)
IP4_ROUTE_CACHE_ENTRY * Ip4FindRouteCache(IN IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Src)
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
UINT16 EFIAPI NetbufChecksum(IN NET_BUF *Nbuf)
UINT16 EFIAPI NetblockChecksum(IN UINT8 *Bulk, IN UINT32 Len)
UINT32 EFIAPI NetbufCopy(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT8 *Dest)
NET_BUF *EFIAPI NetbufDuplicate(IN NET_BUF *Nbuf, IN OUT NET_BUF *Duplicate OPTIONAL, IN UINT32 HeadSpace)
UINT8 *EFIAPI NetbufGetByte(IN NET_BUF *Nbuf, IN UINT32 Offset, OUT UINT32 *Index OPTIONAL)