]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c
Fix a bug for vlan ping failure.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpIo.c
index 28349bc438df61317c1480e5fc782e3afd94d551..b8f61bf696fe1d82e45b9122202e18ee59da1d67 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of Managed Network Protocol I/O functions.\r
 \r
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
 of the BSD License which accompanies this distribution.  The full\r
@@ -130,10 +130,20 @@ MnpBuildTxPacket (
   MnpDerviceData = MnpServiceData->MnpDeviceData;\r
   if ((TxData->DestinationAddress == NULL) && (TxData->FragmentCount == 1)) {\r
     //\r
-    // Media header is in FragmentTable and there is only one fragment,\r
-    // use fragment buffer directly.\r
+    // Reserve space for vlan tag,if necessary.\r
     //\r
-    *PktBuf = TxData->FragmentTable[0].FragmentBuffer;\r
+    if (MnpServiceData->VlanId != 0) {\r
+      *PktBuf = MnpDerviceData->TxBuf + NET_VLAN_TAG_LEN;\r
+    } else {\r
+      *PktBuf = MnpDerviceData->TxBuf;\r
+    } \r
+    \r
+    CopyMem (\r
+        *PktBuf,\r
+        TxData->FragmentTable[0].FragmentBuffer,\r
+        TxData->FragmentTable[0].FragmentLength\r
+        );\r
+    \r
     *PktLen = TxData->FragmentTable[0].FragmentLength;\r
   } else {\r
     //\r
@@ -235,10 +245,15 @@ MnpSyncSendPacket (
     goto SIGNAL_TOKEN;\r
   }\r
 \r
-  //\r
-  // Insert VLAN tag\r
-  //\r
-  MnpInsertVlanTag (MnpServiceData, TxData, &ProtocolType, &Packet, &Length);\r
+  \r
+  if (MnpServiceData->VlanId != 0) {\r
+    //\r
+    // Insert VLAN tag\r
+    //\r
+    MnpInsertVlanTag (MnpServiceData, TxData, &ProtocolType, &Packet, &Length);\r
+  } else {\r
+    ProtocolType = TxData->ProtocolType;\r
+  }\r
 \r
   for (;;) {\r
     //\r
@@ -944,7 +959,14 @@ MnpReceivePacket (
   }\r
 \r
   VlanId = 0;\r
-  IsVlanPacket = MnpRemoveVlanTag (MnpDeviceData, Nbuf, &VlanId);\r
+  if (MnpDeviceData->NumberOfVlan != 0) {\r
+    //\r
+    // VLAN is configured, remove the VLAN tag if any\r
+    //\r
+    IsVlanPacket = MnpRemoveVlanTag (MnpDeviceData, Nbuf, &VlanId);\r
+  } else {\r
+    IsVlanPacket = FALSE;\r
+  }\r
 \r
   MnpServiceData = MnpFindServiceData (MnpDeviceData, VlanId);\r
   if (MnpServiceData == NULL) {\r