]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/IpIoLib.h
NetLib:
[mirror_edk2.git] / MdeModulePkg / Include / Library / IpIoLib.h
index daf8c308a1076ff55cef95c1748e844888702313..a27487f7e57afa8e09c38e8f4a84a8b608dceb19 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
-  Ihis library is only intended to be used by UEFI network stack modules.\r
-  It provides the IpIo layer on the EFI IP4 Protocol.\r
+  This library is only intended to be used by UEFI network stack modules.\r
+  It provides the combined IpIo layer on the EFI IP4 Protocol and EFI IP6 protocol.\r
 \r
-Copyright (c) 2005 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
 All rights reserved. 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
@@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define _IP_IO_H_\r
 \r
 #include <Protocol/Ip4.h>\r
+#include <Protocol/Ip6.h>\r
 \r
 #include <Library/NetLib.h>\r
 \r
@@ -77,7 +78,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define NET_PROTO_HDR(Buf, Type)  ((Type *) ((Buf)->BlockOp[0].Head))\r
 \r
   \r
-extern EFI_IP4_CONFIG_DATA  mIpIoDefaultIpConfigData;\r
+extern EFI_IP4_CONFIG_DATA  mIp4IoDefaultIpConfigData;\r
+extern EFI_IP6_CONFIG_DATA  mIp6IoDefaultIpConfigData;\r
+\r
+typedef enum {\r
+  IP_VERSION_4 = 4,\r
+  IP_VERSION_6 = 6\r
+} IP_VERSION;\r
 \r
 ///\r
 /// This error will be delivered to the\r
@@ -97,21 +104,64 @@ typedef enum {
   ICMP_ERR_PARAMPROB\r
 } ICMP_ERROR;\r
 \r
+typedef enum {\r
+  ICMP6_ERR_UNREACH_NET      = 0,\r
+  ICMP6_ERR_UNREACH_HOST,\r
+  ICMP6_ERR_UNREACH_PROTOCOL,\r
+  ICMP6_ERR_UNREACH_PORT,\r
+  ICMP6_ERR_PACKAGE_TOOBIG,\r
+  ICMP6_ERR_TIMXCEED_HOPLIMIT,\r
+  ICMP6_ERR_TIMXCEED_REASS,\r
+  ICMP6_ERR_PARAMPROB_HEADER,\r
+  ICMP6_ERR_PARAMPROB_NEXHEADER,\r
+  ICMP6_ERR_PARAMPROB_IPV6OPTION\r
+} ICMP6_ERROR;\r
+\r
 ///\r
 /// The helper struct for IpIoGetIcmpErrStatus(). It is for internal use only.\r
 ///\r
 typedef struct {\r
-  BOOLEAN     IsHard;\r
-  BOOLEAN     Notify;\r
+  EFI_STATUS                Error;\r
+  BOOLEAN                   IsHard;\r
+  BOOLEAN                   Notify;\r
 } ICMP_ERROR_INFO;\r
 \r
+typedef union {\r
+  EFI_IP4_COMPLETION_TOKEN  Ip4Token;\r
+  EFI_IP6_COMPLETION_TOKEN  Ip6Token;\r
+} IP_IO_IP_COMPLETION_TOKEN;\r
+\r
+typedef union {\r
+  EFI_IP4_TRANSMIT_DATA     Ip4TxData;\r
+  EFI_IP6_TRANSMIT_DATA     Ip6TxData;\r
+} IP_IO_IP_TX_DATA;\r
+\r
+typedef union {\r
+  EFI_IP4_RECEIVE_DATA      Ip4RxData;\r
+  EFI_IP6_RECEIVE_DATA      Ip6RxData;\r
+} IP_IO_IP_RX_DATA;\r
+\r
+typedef union {\r
+  EFI_IP4_OVERRIDE_DATA     Ip4OverrideData;\r
+  EFI_IP6_OVERRIDE_DATA     Ip6OverrideData;\r
+} IP_IO_OVERRIDE;\r
+\r
+typedef union {\r
+  EFI_IP4_CONFIG_DATA       Ip4CfgData;\r
+  EFI_IP6_CONFIG_DATA       Ip6CfgData;\r
+} IP_IO_IP_CONFIG_DATA;\r
+\r
 ///\r
 /// The IP session for an IP receive packet.\r
 ///\r
 typedef struct _EFI_NET_SESSION_DATA {\r
-  IP4_ADDR        Source;     ///< Source IP of the received packet\r
-  IP4_ADDR        Dest;       ///< Destination IP of the received packet\r
-  EFI_IP4_HEADER  *IpHdr;     ///< IP4 header of the received packet\r
+  EFI_IP_ADDRESS        Source;     ///< Source IP of the received packet\r
+  EFI_IP_ADDRESS        Dest;       ///< Destination IP of the received packet\r
+  union {\r
+    EFI_IP4_HEADER      *Ip4Hdr;    ///< IP4 header of the received packet\r
+    EFI_IP6_HEADER      *Ip6Hdr;    ///< IP6 header of the received packet\r
+  } IpHdr;\r
+  IP_VERSION            IpVersion;  ///< The IP version of the received packet\r
 } EFI_NET_SESSION_DATA;\r
 \r
 /**\r
@@ -141,7 +191,7 @@ VOID
   @param[in] Status        Result of the sending\r
   @param[in] Context       The data provided by user for the received packet when\r
                            the callback is registered in IP_IO_OPEN_DATA::SndContext.\r
-  @param[in] Sender        A pointer to EFI_IP4_PROTOCOL for sender\r
+  @param[in] Sender        A pointer to EFI_IP4_PROTOCOL or EFI_IP6_PROTOCOL\r
   @param[in] NotifyData    Context data specified when calling IpIoSend()\r
   \r
 **/\r
@@ -155,8 +205,8 @@ VOID
   );\r
 \r
 ///\r
-/// This data structure wraps Ip4 instances. The IpIo Library uses it for all\r
-/// Ip4 operations.\r
+/// This data structure wraps Ip4/Ip6 instances. The IpIo Library uses it for all\r
+/// Ip4/Ip6 operations.\r
 ///\r
 typedef struct _IP_IO {\r
   ///\r
@@ -175,7 +225,7 @@ typedef struct _IP_IO {
   //\r
   // The IP instance consumed by this IP_IO\r
   //\r
-  EFI_IP4_PROTOCOL              *Ip;\r
+  VOID                          *Ip;\r
   BOOLEAN                       IsConfigured;\r
 \r
   ///\r
@@ -186,7 +236,7 @@ typedef struct _IP_IO {
   ///\r
   /// Token and event used to get data from IP\r
   ///\r
-  EFI_IP4_COMPLETION_TOKEN      RcvToken;\r
+  IP_IO_IP_COMPLETION_TOKEN     RcvToken; \r
 \r
   ///\r
   /// List entry used to link the token passed to IP_IO\r
@@ -200,6 +250,10 @@ typedef struct _IP_IO {
   VOID                          *SndContext;     ///< See IP_IO_OPEN_DATA::SndContext\r
   PKT_RCVD_NOTIFY               PktRcvdNotify;   ///< See IP_IO_OPEN_DATA::PktRcvdNotify\r
   PKT_SENT_NOTIFY               PktSentNotify;   ///< See IP_IO_OPEN_DATA::PktSentNotify\r
+  //\r
+  // Ip Version \r
+  //\r
+  IP_VERSION                    IpVersion;\r
 } IP_IO;\r
 \r
 ///\r
@@ -207,11 +261,11 @@ typedef struct _IP_IO {
 /// It is used by IpIoOpen().\r
 ///\r
 typedef struct _IP_IO_OPEN_DATA {\r
-  EFI_IP4_CONFIG_DATA IpConfigData;    ///< Configuration of the IP instance\r
-  VOID                *RcvdContext;    ///< Context data used by receive callback\r
-  VOID                *SndContext;     ///< Context data used by send callback\r
-  PKT_RCVD_NOTIFY     PktRcvdNotify;   ///< Receive callback\r
-  PKT_SENT_NOTIFY     PktSentNotify;   ///< Send callback\r
+  IP_IO_IP_CONFIG_DATA IpConfigData;    ///< Configuration of the IP instance\r
+  VOID                 *RcvdContext;    ///< Context data used by receive callback\r
+  VOID                 *SndContext;     ///< Context data used by send callback\r
+  PKT_RCVD_NOTIFY      PktRcvdNotify;   ///< Receive callback\r
+  PKT_SENT_NOTIFY      PktSentNotify;   ///< Send callback\r
 } IP_IO_OPEN_DATA;\r
 \r
 ///\r
@@ -225,37 +279,41 @@ typedef struct _IP_IO_SEND_ENTRY {
   IP_IO                     *IpIo;\r
   VOID                      *Context;\r
   VOID                      *NotifyData;\r
-  EFI_IP4_PROTOCOL          *Ip;\r
+  VOID                      *Ip;\r
   NET_BUF                   *Pkt;\r
-  EFI_IP4_COMPLETION_TOKEN  *SndToken;\r
+  IP_IO_IP_COMPLETION_TOKEN SndToken;\r
 } IP_IO_SEND_ENTRY;\r
 \r
-typedef EFI_IP4_OVERRIDE_DATA IP_IO_OVERRIDE;\r
-\r
 ///\r
 /// The IP_IO_IP_INFO is used in IpIoSend() to override the default IP instance\r
 /// in IP_IO.\r
 ///\r
 typedef struct _IP_IO_IP_INFO {\r
-  IP4_ADDR                  Addr;\r
-  IP4_ADDR                  SubnetMask;\r
+  EFI_IP_ADDRESS            Addr;\r
+  union {\r
+   IP4_ADDR                 SubnetMask;\r
+   UINT8                    PrefixLength;\r
+  } PreMask;\r
   LIST_ENTRY                Entry;\r
   EFI_HANDLE                ChildHandle;\r
-  EFI_IP4_PROTOCOL          *Ip;\r
-  EFI_IP4_COMPLETION_TOKEN  DummyRcvToken;\r
+  VOID                      *Ip;\r
+  IP_IO_IP_COMPLETION_TOKEN DummyRcvToken;\r
   INTN                      RefCnt;\r
+  IP_VERSION                IpVersion;\r
 } IP_IO_IP_INFO;\r
 \r
 /**\r
   Create a new IP_IO instance.\r
   \r
-  This function uses IP4 service binding protocol in Controller to create an IP4\r
-  child (aka IP4 instance).\r
+  This function uses IP4/IP6 service binding protocol in Controller to create\r
+  an IP4/IP6 child (aka IP4/IP6 instance).\r
 \r
   @param[in]  Image             The image handle of the driver or application that\r
                                 consumes IP_IO.\r
-  @param[in]  Controller        The controller handle that has IP4 service binding\r
-                                protocol installed.\r
+  @param[in]  Controller        The controller handle that has IP4 or IP6 service\r
+                                binding protocol installed.\r
+  @param[in]  IpVersion         The version of the IP protocol to use, either\r
+                                IPv4 or IPv6.                            \r
 \r
   @return Pointer to a newly created IP_IO instance, or NULL if failed.\r
 \r
@@ -264,7 +322,8 @@ IP_IO *
 EFIAPI\r
 IpIoCreate (\r
   IN EFI_HANDLE Image,\r
-  IN EFI_HANDLE Controller\r
+  IN EFI_HANDLE Controller,\r
+  IN IP_VERSION IpVersion\r
   );\r
 \r
 /**\r
@@ -361,7 +420,7 @@ IpIoSend (
   IN     IP_IO_IP_INFO  *Sender        OPTIONAL,\r
   IN     VOID           *Context       OPTIONAL,\r
   IN     VOID           *NotifyData    OPTIONAL,\r
-  IN     IP4_ADDR       Dest,\r
+  IN     EFI_IP_ADDRESS *Dest,\r
   IN     IP_IO_OVERRIDE *OverrideData  OPTIONAL\r
   );\r
 \r
@@ -399,15 +458,15 @@ IpIoAddIp (
   );\r
 \r
 /**\r
-  Configure the IP instance of this IpInfo and start the receiving if Ip4ConfigData\r
+  Configure the IP instance of this IpInfo and start the receiving if IpConfigData\r
   is not NULL.\r
 \r
   @param[in, out]  IpInfo          Pointer to the IP_IO_IP_INFO instance.\r
-  @param[in, out]  Ip4ConfigData   The IP4 configure data used to configure the IP\r
-                                   instance. If NULL, the IP instance is reset. If\r
-                                   UseDefaultAddress is set to TRUE, and the configure\r
+  @param[in, out]  IpConfigData    The IP4 or IP6 configure data used to configure \r
+                                   the IP instance. If NULL, the IP instance is reset.\r
+                                   If UseDefaultAddress is set to TRUE, and the configure\r
                                    operation succeeds, the default address information\r
-                                   is written back in this Ip4ConfigData.\r
+                                   is written back in this IpConfigData.\r
 \r
   @retval          EFI_SUCCESS     The IP instance of this IpInfo is configured successfully,\r
                                    or there is no need to reconfigure it.\r
@@ -418,7 +477,7 @@ EFI_STATUS
 EFIAPI\r
 IpIoConfigIp (\r
   IN OUT IP_IO_IP_INFO        *IpInfo,\r
-  IN OUT EFI_IP4_CONFIG_DATA  *Ip4ConfigData OPTIONAL\r
+  IN OUT VOID                 *IpConfigData OPTIONAL\r
   );\r
 \r
 /**\r
@@ -448,6 +507,8 @@ IpIoRemoveIp (
   specified Src. The IpIo was added previously by IpIoAddIp().\r
 \r
   @param[in, out]  IpIo              Pointer to the pointer of the IP_IO instance.\r
+  @param[in]       IpVersion         The version of the IP protocol to use, either\r
+                                     IPv4 or IPv6.\r
   @param[in]       Src               The local IP address.\r
 \r
   @return Pointer to the IP protocol can be used for sending purpose and its local\r
@@ -457,8 +518,9 @@ IpIoRemoveIp (
 IP_IO_IP_INFO *\r
 EFIAPI\r
 IpIoFindSender (\r
-  IN OUT IP_IO     **IpIo,\r
-  IN     IP4_ADDR  Src\r
+  IN OUT IP_IO           **IpIo,\r
+  IN     IP_VERSION      IpVersion,\r
+  IN     EFI_IP_ADDRESS  *Src\r
   );\r
 \r
 /**\r
@@ -468,6 +530,9 @@ IpIoFindSender (
   are not NULL, this routine will fill them.\r
 \r
   @param[in]   IcmpError             IcmpError Type.\r
+  @param[in]   IpVersion             The version of the IP protocol to use,\r
+                                     either IPv4 or IPv6.\r
+  \r
   @param[out]  IsHard                Whether it is a hard error.\r
   @param[out]  Notify                Whether it need to notify SockError.\r
 \r
@@ -478,8 +543,41 @@ EFI_STATUS
 EFIAPI\r
 IpIoGetIcmpErrStatus (\r
   IN  ICMP_ERROR  IcmpError,\r
+  IN  IP_VERSION  IpVersion,\r
   OUT BOOLEAN     *IsHard  OPTIONAL,\r
   OUT BOOLEAN     *Notify  OPTIONAL\r
   );\r
 \r
+/**\r
+  Refresh the remote peer's Neighbor Cache entries.\r
+\r
+  This function is called when the caller needs the IpIo to refresh the existing\r
+  IPv6 neighbor cache entries since the neighbor is considered reachable by the \r
+  node has recently received a confirmation that packets sent recently to the \r
+  neighbor were received by its IP layer. \r
+\r
+  @param[in]   IpIo                  Pointer to an IP_IO instance\r
+  @param[in]   Neighbor              The IP address of the neighbor\r
+  @param[in]   Timeout               Time in 100-ns units that this entry will\r
+                                     remain in the neighbor cache. A value of \r
+                                     zero means that the entry is permanent. \r
+                                     A value of non-zero means that the entry is \r
+                                     dynamic and will be deleted after Timeout.\r
+\r
+  @retval      EFI_SUCCESS           The operation is completed successfully.\r
+  @retval      EFI_NOT_STARTED       The IpIo is not configured.\r
+  @retval      EFI_INVALID_PARAMETER Neighbor Address is invalid.\r
+  @retval      EFI_NOT_FOUND         The neighbor cache entry is not in the \r
+                                     neighbor table.  \r
+  @retval      EFI_OUT_OF_RESOURCES  Failed due to resource limit.\r
+\r
+**/\r
+EFI_STATUS\r
+IpIoRefreshNeighbor (\r
+  IN IP_IO           *IpIo,\r
+  IN EFI_IP_ADDRESS  *Neighbor,\r
+  IN UINT32          Timeout  \r
+  );\r
+\r
 #endif\r
+\r