]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
1. Add Link MTU support to IP4 and TCP4 driver.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Impl.h
index 8b2e286f0c364adc314cd9b4950347a8428b620c..43d6765add8910f7a84bf0e3a6c941f98e52f39c 100644 (file)
@@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \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
@@ -80,11 +81,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 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
@@ -110,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
@@ -136,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
@@ -194,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
@@ -335,4 +350,33 @@ Ip4SentPacketTicking (
   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
+Ip4FreeTxToken (\r
+  IN VOID                   *Context\r
+  );\r
+\r
+extern EFI_IPSEC_PROTOCOL   *mIpSec;\r
+\r
 #endif\r