]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
1. Fix a bug in PXE driver that the PXE boot do not restart if a new boot option...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Impl.h
index 08ca3708dd7e3d9bc9c5dacec2adee38ff6e6531..563cf7f91ff28ab505944f5443db43f2451da59b 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
-\r
-Copyright (c) 2005 - 2007, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials\r
+  Ip4 internal functions and type defintions.\r
+  \r
+Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -9,22 +10,14 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Ip4Impl.h\r
-\r
-Abstract:\r
-\r
-  Ip4 internal functions and type defintions.\r
-\r
-\r
 **/\r
 \r
 #ifndef __EFI_IP4_IMPL_H__\r
 #define __EFI_IP4_IMPL_H__\r
 \r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
 \r
+#include <Protocol/IpSec.h>\r
 #include <Protocol/Ip4.h>\r
 #include <Protocol/Ip4Config.h>\r
 #include <Protocol/Arp.h>\r
@@ -39,6 +32,7 @@ Abstract:
 #include <Library/NetLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <Library/DpcLib.h>\r
 \r
 #include "Ip4Common.h"\r
 #include "Ip4Driver.h"\r
@@ -50,34 +44,31 @@ Abstract:
 #include "Ip4Input.h"\r
 #include "Ip4Output.h"\r
 \r
+#define IP4_PROTOCOL_SIGNATURE  SIGNATURE_32 ('I', 'P', '4', 'P')\r
+#define IP4_SERVICE_SIGNATURE   SIGNATURE_32 ('I', 'P', '4', 'S')\r
+\r
+//\r
+// The state of IP4 protocol. It starts from UNCONFIGED. if it is\r
+// successfully configured, it goes to CONFIGED. if configure NULL\r
+// is called, it becomes UNCONFIGED again. If (partly) destroyed, it\r
+// becomes DESTROY.\r
+//\r
+#define IP4_STATE_UNCONFIGED    0\r
+#define IP4_STATE_CONFIGED      1\r
+#define IP4_STATE_DESTROY       2\r
+\r
+//\r
+// The state of IP4 service. It starts from UNSTARTED. It transits\r
+// to STARTED if autoconfigure is started. If default address is\r
+// configured, it becomes CONFIGED. and if partly destroyed, it goes\r
+// to DESTROY.\r
+//\r
+#define IP4_SERVICE_UNSTARTED   0\r
+#define IP4_SERVICE_STARTED     1\r
+#define IP4_SERVICE_CONFIGED    2\r
+#define IP4_SERVICE_DESTROY     3\r
 \r
 \r
-typedef enum {\r
-  IP4_PROTOCOL_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', '4', 'P'),\r
-  IP4_SERVICE_SIGNATURE  = EFI_SIGNATURE_32 ('I', 'P', '4', 'S'),\r
-\r
-  //\r
-  // The state of IP4 protocol. It starts from UNCONFIGED. if it is\r
-  // successfully configured, it goes to CONFIGED. if configure NULL\r
-  // is called, it becomes UNCONFIGED again. If (partly) destoried, it\r
-  // becomes DESTORY.\r
-  //\r
-  IP4_STATE_UNCONFIGED   = 0,\r
-  IP4_STATE_CONFIGED,\r
-  IP4_STATE_DESTORY,\r
-\r
-  //\r
-  // The state of IP4 service. It starts from UNSTARTED. It transits\r
-  // to STARTED if autoconfigure is started. If default address is\r
-  // configured, it becomes CONFIGED. and if partly destoried, it goes\r
-  // to DESTORY.\r
-  //\r
-  IP4_SERVICE_UNSTARTED  = 0,\r
-  IP4_SERVICE_STARTED,\r
-  IP4_SERVICE_CONFIGED,\r
-  IP4_SERVICE_DESTORY\r
-} IP4_IMPL_ENUM_TYPES;\r
-\r
 ///\r
 /// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.\r
 /// The user's data is kept in the Packet. When fragment is\r
@@ -90,11 +81,23 @@ typedef enum {
 typedef struct {\r
   IP4_PROTOCOL              *IpInstance;\r
   EFI_IP4_COMPLETION_TOKEN  *Token;\r
+  EFI_EVENT                 IpSecRecycleSignal;\r
   NET_BUF                   *Packet;\r
   BOOLEAN                   Sent;\r
   INTN                      Life;\r
 } IP4_TXTOKEN_WRAP;\r
 \r
+///\r
+/// IP4_IPSEC_WRAP wraps the packet received from MNP layer. The packet\r
+/// will be released after it has been processed by the receiver. Upon then,\r
+/// the IP4_IPSEC_WRAP will be released, and the IpSecRecycleSignal will be signaled\r
+/// to notice IPsec to free the resources.\r
+///\r
+typedef struct {\r
+  EFI_EVENT                 IpSecRecycleSignal;\r
+  NET_BUF                   *Packet;\r
+} IP4_IPSEC_WRAP;\r
+\r
 ///\r
 /// IP4_RXDATA_WRAP wraps the data IP4 child delivers to the\r
 /// upper layers. The received packet is kept in the Packet.\r
@@ -120,7 +123,7 @@ struct _IP4_PROTOCOL {
   INTN                      State;\r
 \r
   IP4_SERVICE               *Service;\r
-  LIST_ENTRY                Link; // Link to all the IP protocol from the service\r
+  LIST_ENTRY                Link;       // Link to all the IP protocol from the service\r
 \r
   //\r
   // User's transmit/receive tokens, and received/deliverd packets\r
@@ -146,7 +149,7 @@ struct _IP4_PROTOCOL {
   //\r
   // IGMP data for this instance\r
   //\r
-  IP4_ADDR                  *Groups;  // stored in network byte order\r
+  IP4_ADDR                  *Groups;    // stored in network byte order\r
   UINT32                    GroupCount;\r
 \r
   EFI_IP4_CONFIG_DATA       ConfigData;\r
@@ -157,7 +160,7 @@ struct _IP4_SERVICE {
   UINT32                          Signature;\r
   EFI_SERVICE_BINDING_PROTOCOL    ServiceBinding;\r
   INTN                            State;\r
-  BOOLEAN                         InDestory;\r
+  BOOLEAN                         InDestroy;\r
 \r
   //\r
   // List of all the IP instances and interfaces, and default\r
@@ -204,6 +207,8 @@ struct _IP4_SERVICE {
   // NIC this IP4_SERVICE works on.\r
   //\r
   CHAR16                          *MacString;\r
+  UINT32                          MaxPacketSize;\r
+  UINT32                          OldMaxPacketSize; ///< The MTU before IPsec enable.\r
 };\r
 \r
 #define IP4_INSTANCE_FROM_PROTOCOL(Ip4) \\r
@@ -227,8 +232,8 @@ extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;
   reconfigure the MNP. If Force is TRUE, the MNP is configured no\r
   matter whether that is changed or not.\r
 \r
-  @param  IpSb                   The IP4 service instance that is to be changed.\r
-  @param  Force                  Force the configuration or not.\r
+  @param[in]  IpSb               The IP4 service instance that is to be changed.\r
+  @param[in]  Force              Force the configuration or not.\r
 \r
   @retval EFI_SUCCESS            The MNP is successfully configured/reconfigured.\r
   @retval Others                 Configuration failed.\r
@@ -246,8 +251,6 @@ Ip4ServiceConfigMnp (
   @param  IpSb                   The IP4 service instance.\r
   @param  IpInstance             The IP4 child instance.\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 Ip4InitProtocol (\r
@@ -258,7 +261,7 @@ Ip4InitProtocol (
 /**\r
   Clean up the IP4 child, release all the resources used by it.\r
 \r
-  @param  IpInstance             The IP4 child to clean up.\r
+  @param[in]  IpInstance         The IP4 child to clean up.\r
 \r
   @retval EFI_SUCCESS            The IP4 child is cleaned up\r
   @retval EFI_DEVICE_ERROR       Some resources failed to be released\r
@@ -272,8 +275,8 @@ Ip4CleanProtocol (
 /**\r
   Cancel the user's receive/transmit request.\r
 \r
-  @param  IpInstance             The IP4 child\r
-  @param  Token                  The token to cancel. If NULL, all token will be\r
+  @param[in]  IpInstance         The IP4 child\r
+  @param[in]  Token              The token to cancel. If NULL, all token will be\r
                                  cancelled.\r
 \r
   @retval EFI_SUCCESS            The token is cancelled\r
@@ -292,9 +295,9 @@ Ip4Cancel (
   Change the IP4 child's multicast setting. The caller\r
   should make sure that the parameters is valid.\r
 \r
-  @param  IpInstance             The IP4 child to change the setting.\r
-  @param  JoinFlag               TRUE to join the group, otherwise leave it\r
-  @param  GroupAddress           The target group address\r
+  @param[in]  IpInstance             The IP4 child to change the setting.\r
+  @param[in]  JoinFlag               TRUE to join the group, otherwise leave it\r
+  @param[in]  GroupAddress           The target group address\r
 \r
   @retval EFI_ALREADY_STARTED    Want to join the group, but already a member of it\r
   @retval EFI_OUT_OF_RESOURCES   Failed to allocate some resources.\r
@@ -316,10 +319,8 @@ Ip4Groups (
   transmitted-but-not-recycle packets, and provides time input\r
   for its IGMP protocol.\r
 \r
-  @param  Event                  The IP4 service instance's heart beat timer.\r
-  @param  Context                The IP4 service instance.\r
-\r
-  @return None\r
+  @param[in]  Event                  The IP4 service instance's heart beat timer.\r
+  @param[in]  Context                The IP4 service instance.\r
 \r
 **/\r
 VOID\r
@@ -336,17 +337,48 @@ Ip4TimerTicking (
   received-but-not-delivered and transmitted-but-not-recycle\r
   packets.\r
 \r
-  @param  Map                    The IP4 child's transmit map.\r
-  @param  Item                   Current transmitted packet\r
-  @param  Context                Not used.\r
+  @param[in]  Map                    The IP4 child's transmit map.\r
+  @param[in]  Item                   Current transmitted packet\r
+  @param[in]  Context                Not used.\r
 \r
   @retval EFI_SUCCESS            Always returns EFI_SUCCESS\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Ip4SentPacketTicking (\r
   IN NET_MAP                *Map,\r
   IN NET_MAP_ITEM           *Item,\r
   IN VOID                   *Context\r
   );\r
+\r
+/**\r
+  The callback function for the net buffer which wraps the user's\r
+  transmit token. Although it seems this function is pretty simple,\r
+  there are some subtle things.\r
+  When user requests the IP to transmit a packet by passing it a\r
+  token, the token is wrapped in an IP4_TXTOKEN_WRAP and the data\r
+  is wrapped in an net buffer. the net buffer's Free function is\r
+  set to Ip4FreeTxToken. The Token and token wrap are added to the\r
+  IP child's TxToken map. Then the buffer is passed to Ip4Output for\r
+  transmission. If something error happened before that, the buffer\r
+  is freed, which in turn will free the token wrap. The wrap may\r
+  have been added to the TxToken map or not, and the user's event\r
+  shouldn't be fired because we are still in the EfiIp4Transmit. If\r
+  the buffer has been sent by Ip4Output, it should be removed from\r
+  the TxToken map and user's event signaled. The token wrap and buffer\r
+  are bound together. Check the comments in Ip4Output for information\r
+  about IP fragmentation.\r
+\r
+  @param[in]  Context                The token's wrap\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Ip4FreeTxToken (\r
+  IN VOID                   *Context\r
+  );\r
+\r
+extern EFI_IPSEC2_PROTOCOL   *mIpSec;\r
+\r
 #endif\r