]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h
Fixed OPTIONAL/comma issue
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4If.h
index 22db034a0a509484dba7aedd5aff3065d865cb98..305e826a8d51d0d9e5f811e3b5fddae20b1b7a80 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+  Definition for IP4 pesudo interface structure.\r
+  \r
+Copyright (c) 2005 - 2006, 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
@@ -9,59 +10,57 @@ 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
-\r
-Module Name:\r
-\r
-  Ip4If.h\r
-\r
-Abstract:\r
-\r
-  Definition for IP4 pesudo interface structure.\r
-\r
-\r
 **/\r
 \r
 #ifndef __EFI_IP4_IF_H__\r
 #define __EFI_IP4_IF_H__\r
 \r
-enum {\r
-  IP4_FRAME_RX_SIGNATURE  = EFI_SIGNATURE_32 ('I', 'P', 'F', 'R'),\r
-  IP4_FRAME_TX_SIGNATURE  = EFI_SIGNATURE_32 ('I', 'P', 'F', 'T'),\r
-  IP4_FRAME_ARP_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'A'),\r
-  IP4_INTERFACE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'I', 'F')\r
-};\r
-\r
-//\r
-// This prototype is used by both receive and transmission.\r
-// When receiving Netbuf is allocated by IP4_INTERFACE, and\r
-// released by IP4. Flag shows whether the frame is received\r
-// as link broadcast/multicast...\r
-//\r
-// When transmitting, the Netbuf is from IP4, and provided\r
-// to the callback as a reference. Flag isn't used.\r
-//\r
-// IpInstance can be NULL which means that it is the IP4 driver\r
-// itself sending the packets. IP4 driver may send packets that\r
-// don't belong to any instance, such as ICMP errors, ICMP echo\r
-// responses, or IGMP packets. IpInstance is used as a tag in\r
-// this module.\r
-//\r
+typedef enum {\r
+  IP4_FRAME_RX_SIGNATURE  = SIGNATURE_32 ('I', 'P', 'F', 'R'),\r
+  IP4_FRAME_TX_SIGNATURE  = SIGNATURE_32 ('I', 'P', 'F', 'T'),\r
+  IP4_FRAME_ARP_SIGNATURE = SIGNATURE_32 ('I', 'P', 'F', 'A'),\r
+  IP4_INTERFACE_SIGNATURE = SIGNATURE_32 ('I', 'P', 'I', 'F')\r
+} IP4_IF_ENUM_TYPES;\r
+\r
+/**\r
+  This prototype is used by both receive and transmission.\r
+  When receiving Netbuf is allocated by IP4_INTERFACE, and\r
+  released by IP4. Flag shows whether the frame is received\r
+  as link broadcast/multicast...\r
+\r
+  When transmitting, the Netbuf is from IP4, and provided\r
+  to the callback as a reference. Flag isn't used.\r
+\r
+  @param[in] IpInstance The instance that sent or received the packet.\r
+                        IpInstance can be NULL which means that it is the IP4 driver\r
+                        itself sending the packets. IP4 driver may send packets that\r
+                        don't belong to any instance, such as ICMP errors, ICMP echo\r
+                        responses, or IGMP packets. IpInstance is used as a tag in\r
+                        this module.\r
+  @param[in] Packet     The sent or received packet.\r
+  @param[in] IoStatus   Status of sending or receiving.\r
+  @param[in] LinkFlag   Indicate if the frame is received as link broadcast/multicast.\r
+                        When transmitting, it is not used.\r
+  @param[in] Context    Additional data for callback.\r
+\r
+  @retval None.\r
+**/\r
 typedef\r
 VOID\r
-(*IP4_FRAME_CALLBACK) (\r
-  IP4_PROTOCOL              *IpInstance,       OPTIONAL\r
-  NET_BUF                   *Packet,\r
-  EFI_STATUS                IoStatus,\r
-  UINT32                    LinkFlag,\r
-  VOID                      *Context\r
+(*IP4_FRAME_CALLBACK)(\r
+  IN IP4_PROTOCOL              *IpInstance       OPTIONAL,\r
+  IN NET_BUF                   *Packet,\r
+  IN EFI_STATUS                IoStatus,\r
+  IN UINT32                    LinkFlag,\r
+  IN VOID                      *Context\r
   );\r
 \r
-//\r
-// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.\r
-// Upon completion, the Callback will be called. Only one\r
-// receive request is send to MNP. IpInstance is always NULL.\r
-// Reference MNP's spec for information.\r
-//\r
+///\r
+/// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.\r
+/// Upon completion, the Callback will be called. Only one\r
+/// receive request is send to MNP. IpInstance is always NULL.\r
+/// Reference MNP's spec for information.\r
+///\r
 typedef struct {\r
   UINT32                                Signature;\r
   IP4_INTERFACE                         *Interface;\r
@@ -73,13 +72,13 @@ typedef struct {
   EFI_MANAGED_NETWORK_COMPLETION_TOKEN  MnpToken;\r
 } IP4_LINK_RX_TOKEN;\r
 \r
-//\r
-// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.\r
-// Upon completion, the Callback will be called.\r
-//\r
+///\r
+/// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.\r
+/// Upon completion, the Callback will be called.\r
+///\r
 typedef struct {\r
   UINT32                                Signature;\r
-  NET_LIST_ENTRY                        Link;\r
+  LIST_ENTRY                            Link;\r
 \r
   IP4_INTERFACE                         *Interface;\r
 \r
@@ -95,17 +94,17 @@ typedef struct {
   EFI_MANAGED_NETWORK_TRANSMIT_DATA     MnpTxData;\r
 } IP4_LINK_TX_TOKEN;\r
 \r
-//\r
-// Only one ARP request is requested for all the frames in\r
-// a time. It is started for the first frames to the Ip. Any\r
-// subsequent transmission frame will be linked to Frames, and\r
-// be sent all at once the ARP requests succeed.\r
-//\r
+///\r
+/// Only one ARP request is requested for all the frames in\r
+/// a time. It is started for the first frames to the Ip. Any\r
+/// subsequent transmission frame will be linked to Frames, and\r
+/// be sent all at once the ARP requests succeed.\r
+///\r
 typedef struct {\r
   UINT32                  Signature;\r
-  NET_LIST_ENTRY          Link;\r
+  LIST_ENTRY              Link;\r
 \r
-  NET_LIST_ENTRY          Frames;\r
+  LIST_ENTRY              Frames;\r
   IP4_INTERFACE           *Interface;\r
 \r
   //\r
@@ -116,13 +115,19 @@ typedef struct {
   EFI_MAC_ADDRESS         Mac;\r
 } IP4_ARP_QUE;\r
 \r
-//\r
-// Callback to select which frame to cancel. Caller can cancel a\r
-// single frame, or all the frame from an IP instance.\r
-//\r
+/**\r
+  Callback to select which frame to cancel. Caller can cancel a\r
+  single frame, or all the frame from an IP instance.\r
+\r
+  @param Frame      The sending frame to check for cancellation.\r
+  @param Context    Additional data for callback.\r
+\r
+  @retval TRUE      The sending of the frame should be cancelled.\r
+  @retval FALSE     Do not cancel the frame sending.\r
+**/\r
 typedef\r
 BOOLEAN\r
-(*IP4_FRAME_TO_CANCEL) (\r
+(*IP4_FRAME_TO_CANCEL)(\r
   IP4_LINK_TX_TOKEN       *Frame,\r
   VOID                    *Context\r
   );\r
@@ -136,7 +141,7 @@ BOOLEAN
 //\r
 struct _IP4_INTERFACE {\r
   UINT32                        Signature;\r
-  NET_LIST_ENTRY                Link;\r
+  LIST_ENTRY                    Link;\r
   INTN                          RefCnt;\r
 \r
   //\r
@@ -164,8 +169,8 @@ struct _IP4_INTERFACE {
   //\r
   // Queues to keep the frames sent and waiting ARP request.\r
   //\r
-  NET_LIST_ENTRY                ArpQues;\r
-  NET_LIST_ENTRY                SentFrames;\r
+  LIST_ENTRY                    ArpQues;\r
+  LIST_ENTRY                    SentFrames;\r
   IP4_LINK_RX_TOKEN             *RecvRequest;\r
 \r
   //\r
@@ -180,10 +185,23 @@ struct _IP4_INTERFACE {
   // together through IpInstances. If any of the instance enables\r
   // promiscuous receive, PromiscRecv is true.\r
   //\r
-  NET_LIST_ENTRY                IpInstances;\r
+  LIST_ENTRY                    IpInstances;\r
   BOOLEAN                       PromiscRecv;\r
 };\r
 \r
+/**\r
+  Create an IP4_INTERFACE. Delay the creation of ARP instance until\r
+  the interface is configured.\r
+\r
+  @param[in]  Mnp               The shared MNP child of this IP4 service binding\r
+                                instance\r
+  @param[in]  Controller        The controller this IP4 service binding instance\r
+                                is installed. Most like the UNDI handle.\r
+  @param[in]  ImageHandle       This driver's image handle\r
+\r
+  @return Point to the created IP4_INTERFACE, otherwise NULL.\r
+\r
+**/\r
 IP4_INTERFACE *\r
 Ip4CreateInterface (\r
   IN  EFI_MANAGED_NETWORK_PROTOCOL  *Mnp,\r
@@ -191,46 +209,135 @@ Ip4CreateInterface (
   IN  EFI_HANDLE                    ImageHandle\r
   );\r
 \r
+/**\r
+  Set the interface's address, create and configure\r
+  the ARP child if necessary.\r
+\r
+  @param  Interface         The interface to set the address\r
+  @param  IpAddr            The interface's IP address\r
+  @param  SubnetMask        The interface's netmask\r
+\r
+  @retval EFI_SUCCESS           The interface is configured with Ip/netmask pair,\r
+                                and a ARP is created for it.\r
+  @retval Others                Failed to set the interface's address.\r
+\r
+**/\r
 EFI_STATUS\r
 Ip4SetAddress (\r
-  IN  IP4_INTERFACE         *Interface,\r
-  IN  IP4_ADDR              IpAddr,\r
-  IN  IP4_ADDR              SubnetMask\r
+  IN OUT IP4_INTERFACE      *Interface,\r
+  IN     IP4_ADDR           IpAddr,\r
+  IN     IP4_ADDR           SubnetMask\r
   );\r
 \r
+/**\r
+  Free the interface used by IpInstance. All the IP instance with\r
+  the same Ip/Netmask pair share the same interface. It is reference\r
+  counted. All the frames haven't been sent will be cancelled.\r
+  Because the IpInstance is optional, the caller must remove\r
+  IpInstance from the interface's instance list itself.\r
+\r
+  @param[in]  Interface         The interface used by the IpInstance\r
+  @param[in]  IpInstance        The Ip instance that free the interface. NULL if\r
+                                the Ip driver is releasing the default interface.\r
+\r
+  @retval EFI_SUCCESS           The interface use IpInstance is freed.\r
+\r
+**/\r
 EFI_STATUS\r
 Ip4FreeInterface (\r
   IN  IP4_INTERFACE         *Interface,\r
-  IN  IP4_PROTOCOL          *IpInstance       OPTIONAL\r
+  IN  IP4_PROTOCOL          *IpInstance           OPTIONAL\r
   );\r
 \r
+/**\r
+  Send a frame from the interface. If the next hop is broadcast or\r
+  multicast address, it is transmitted immediately. If the next hop\r
+  is a unicast, it will consult ARP to resolve the NextHop's MAC.\r
+  If some error happened, the CallBack won't be called. So, the caller\r
+  must test the return value, and take action when there is an error.\r
+\r
+  @param[in]  Interface         The interface to send the frame from\r
+  @param[in]  IpInstance        The IP child that request the transmission.  NULL\r
+                                if it is the IP4 driver itself.\r
+  @param[in]  Packet            The packet to transmit.\r
+  @param[in]  NextHop           The immediate destination to transmit the packet\r
+                                to.\r
+  @param[in]  CallBack          Function to call back when transmit finished.\r
+  @param[in]  Context           Opaque parameter to the call back.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate resource to send the frame\r
+  @retval EFI_NO_MAPPING        Can't resolve the MAC for the nexthop\r
+  @retval EFI_SUCCESS           The packet is successfully transmitted.\r
+  @retval other                 Other error occurs.\r
+\r
+**/\r
 EFI_STATUS\r
 Ip4SendFrame (\r
   IN  IP4_INTERFACE         *Interface,\r
-  IN  IP4_PROTOCOL          *IpInstance,      OPTIONAL\r
+  IN  IP4_PROTOCOL          *IpInstance       OPTIONAL,\r
   IN  NET_BUF               *Packet,\r
   IN  IP4_ADDR              NextHop,\r
   IN  IP4_FRAME_CALLBACK    CallBack,\r
   IN  VOID                  *Context\r
   );\r
 \r
+/**\r
+  Remove all the frames on the interface that pass the FrameToCancel,\r
+  either queued on ARP queues or that have already been delivered to\r
+  MNP and not yet recycled.\r
+\r
+  @param[in]  Interface         Interface to remove the frames from\r
+  @param[in]  IoStatus          The transmit status returned to the frames'\r
+                                callback\r
+  @param[in]  FrameToCancel     Function to select the frame to cancel, NULL to\r
+                                select all\r
+  @param[in]  Context           Opaque parameters passed to FrameToCancel\r
+\r
+**/\r
 VOID\r
 Ip4CancelFrames (\r
   IN IP4_INTERFACE          *Interface,\r
   IN EFI_STATUS             IoStatus,\r
-  IN IP4_FRAME_TO_CANCEL    FrameToCancel,   OPTIONAL\r
+  IN IP4_FRAME_TO_CANCEL    FrameToCancel    OPTIONAL,\r
   IN VOID                   *Context\r
   );\r
 \r
+/**\r
+  If there is a pending receive request, cancel it. Don't call\r
+  the receive request's callback because this function can be only\r
+  called if the instance or driver is tearing itself down. It\r
+  doesn't make sense to call it back. But it is necessary to call\r
+  the transmit token's callback to give it a chance to free the\r
+  packet and update the upper layer's transmit request status, say\r
+  that from the UDP.\r
+\r
+  @param[in]  Interface         The interface used by the IpInstance\r
+\r
+**/\r
 VOID\r
 Ip4CancelReceive (\r
   IN IP4_INTERFACE          *Interface\r
   );\r
 \r
+/**\r
+  Request to receive the packet from the interface.\r
+\r
+  @param[in]  Interface         The interface to receive the frames from\r
+  @param[in]  IpInstance        The instance that requests the receive. NULL for\r
+                                the driver itself.\r
+  @param[in]  CallBack          Function to call when receive finished.\r
+  @param[in]  Context           Opaque parameter to the callback\r
+\r
+  @retval EFI_ALREADY_STARTED   There is already a pending receive request.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate resource to receive\r
+  @retval EFI_SUCCESS           The recieve request has been started.\r
+  @retval other                 Other error occurs.\r
+\r
+**/\r
 EFI_STATUS\r
 Ip4ReceiveFrame (\r
   IN  IP4_INTERFACE         *Interface,\r
-  IN  IP4_PROTOCOL          *IpInstance,      OPTIONAL\r
+  IN  IP4_PROTOCOL          *IpInstance       OPTIONAL,\r
   IN  IP4_FRAME_CALLBACK    CallBack,\r
   IN  VOID                  *Context\r
   );\r