ShellPkg: Fix issue about ping fail with IPv4
authorJiaxin Wu <jiaxin.wu@intel.com>
Thu, 6 Aug 2015 05:45:32 +0000 (05:45 +0000)
committerjiaxinwu <jiaxinwu@Edk2>
Thu, 6 Aug 2015 05:45:32 +0000 (05:45 +0000)
Fix issue about ping fail with IPv4, which is caused by the incorrect
checksum in request message.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18167 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c

index 643be23..cc3c0c3 100644 (file)
@@ -598,8 +598,7 @@ PingGenerateToken (
   //\r
   Request->Type        = (UINT8)(Private->IpChoice==PING_IP_CHOICE_IP6?ICMP_V6_ECHO_REQUEST:ICMP_V4_ECHO_REQUEST);\r
   Request->Code        = 0;\r
-  Request->SequenceNum = SequenceNum;\r
-  Request->TimeStamp   = TimeStamp; \r
+  Request->SequenceNum = SequenceNum; \r
   Request->Identifier  = 0;\r
   Request->Checksum    = 0;\r
 \r
@@ -607,6 +606,7 @@ PingGenerateToken (
   // Assembly token for transmit.\r
   //\r
   if (Private->IpChoice==PING_IP_CHOICE_IP6) {\r
+    Request->TimeStamp   = TimeStamp;\r
     ((EFI_IP6_TRANSMIT_DATA*)TxData)->ExtHdrsLength                   = 0;\r
     ((EFI_IP6_TRANSMIT_DATA*)TxData)->ExtHdrs                         = NULL;\r
     ((EFI_IP6_TRANSMIT_DATA*)TxData)->OverrideData                    = 0;\r
@@ -628,6 +628,7 @@ PingGenerateToken (
     ((EFI_IP4_TRANSMIT_DATA*)TxData)->DestinationAddress.Addr[3]      = Private->DstAddress[3];\r
 \r
     HeadSum = NetChecksum ((UINT8 *) Request, Private->BufferSize);\r
+    Request->TimeStamp   = TimeStamp;\r
     TempChecksum = NetChecksum ((UINT8 *) &Request->TimeStamp, sizeof (UINT64));\r
     Request->Checksum = (UINT16)(~NetAddChecksum (HeadSum, TempChecksum));\r
   }\r