X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4If.h;h=6dada9605b8ca468fbb96ed55443f3ed7cc6b59d;hp=ec07117eeb5adc763782ca5081b2dc5806227f47;hb=1f6729ffe98095107ce82e67a4a0209674601a90;hpb=5405e9a66b5ecf9f8a7ba571ead43cbee45161ae diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h index ec07117eeb..6dada9605b 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h @@ -1,7 +1,8 @@ /** @file - -Copyright (c) 2005 - 2006, Intel Corporation -All rights reserved. This program and the accompanying materials + Definition for IP4 pesudo interface structure. + +Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -9,27 +10,15 @@ http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Ip4If.h - -Abstract: - - Definition for IP4 pesudo interface structure. - - **/ #ifndef __EFI_IP4_IF_H__ #define __EFI_IP4_IF_H__ -typedef enum { - IP4_FRAME_RX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'R'), - IP4_FRAME_TX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'T'), - IP4_FRAME_ARP_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'A'), - IP4_INTERFACE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'I', 'F') -} IP4_IF_ENUM_TYPES; +#define IP4_FRAME_RX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'R') +#define IP4_FRAME_TX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'T') +#define IP4_FRAME_ARP_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'A') +#define IP4_INTERFACE_SIGNATURE SIGNATURE_32 ('I', 'P', 'I', 'F') /** This prototype is used by both receive and transmission. @@ -40,36 +29,36 @@ typedef enum { When transmitting, the Netbuf is from IP4, and provided to the callback as a reference. Flag isn't used. - @param IpInstance The instance that sent or received the packet. - IpInstance can be NULL which means that it is the IP4 driver - itself sending the packets. IP4 driver may send packets that - don't belong to any instance, such as ICMP errors, ICMP echo - responses, or IGMP packets. IpInstance is used as a tag in - this module. - @param Packet The sent or received packet. - @param IoStatus Status of sending or receiving. - @param LinkFlag Indicate if the frame is received as link broadcast/multicast. - When transmitting, it is not used. - @param Context Additional data for callback. - - @return None. + @param[in] IpInstance The instance that sent or received the packet. + IpInstance can be NULL which means that it is the IP4 driver + itself sending the packets. IP4 driver may send packets that + don't belong to any instance, such as ICMP errors, ICMP echo + responses, or IGMP packets. IpInstance is used as a tag in + this module. + @param[in] Packet The sent or received packet. + @param[in] IoStatus Status of sending or receiving. + @param[in] LinkFlag Indicate if the frame is received as link broadcast/multicast. + When transmitting, it is not used. + @param[in] Context Additional data for callback. + + @retval None. **/ typedef VOID (*IP4_FRAME_CALLBACK)( - IN IP4_PROTOCOL *IpInstance, OPTIONAL + IN IP4_PROTOCOL *IpInstance OPTIONAL, IN NET_BUF *Packet, IN EFI_STATUS IoStatus, IN UINT32 LinkFlag, IN VOID *Context ); -// -// Each receive request is wrapped in an IP4_LINK_RX_TOKEN. -// Upon completion, the Callback will be called. Only one -// receive request is send to MNP. IpInstance is always NULL. -// Reference MNP's spec for information. -// +/// +/// Each receive request is wrapped in an IP4_LINK_RX_TOKEN. +/// Upon completion, the Callback will be called. Only one +/// receive request is send to MNP. IpInstance is always NULL. +/// Reference MNP's spec for information. +/// typedef struct { UINT32 Signature; IP4_INTERFACE *Interface; @@ -81,10 +70,10 @@ typedef struct { EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken; } IP4_LINK_RX_TOKEN; -// -// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN. -// Upon completion, the Callback will be called. -// +/// +/// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN. +/// Upon completion, the Callback will be called. +/// typedef struct { UINT32 Signature; LIST_ENTRY Link; @@ -103,12 +92,12 @@ typedef struct { EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData; } IP4_LINK_TX_TOKEN; -// -// Only one ARP request is requested for all the frames in -// a time. It is started for the first frames to the Ip. Any -// subsequent transmission frame will be linked to Frames, and -// be sent all at once the ARP requests succeed. -// +/// +/// Only one ARP request is requested for all the frames in +/// a time. It is started for the first frames to the Ip. Any +/// subsequent transmission frame will be linked to Frames, and +/// be sent all at once the ARP requests succeed. +/// typedef struct { UINT32 Signature; LIST_ENTRY Link; @@ -148,7 +137,7 @@ BOOLEAN // Notice the special cases that DHCP can configure the interface // with 0.0.0.0/0.0.0.0. // -typedef struct _IP4_INTERFACE { +struct _IP4_INTERFACE { UINT32 Signature; LIST_ENTRY Link; INTN RefCnt; @@ -165,7 +154,7 @@ typedef struct _IP4_INTERFACE { BOOLEAN Configured; // - // Handle used to create/destory ARP child. All the IP children + // Handle used to create/destroy ARP child. All the IP children // share one MNP which is owned by IP service binding. // EFI_HANDLE Controller; @@ -196,8 +185,21 @@ typedef struct _IP4_INTERFACE { // LIST_ENTRY IpInstances; BOOLEAN PromiscRecv; -} IP4_INTERFACE; +}; + +/** + Create an IP4_INTERFACE. Delay the creation of ARP instance until + the interface is configured. + @param[in] Mnp The shared MNP child of this IP4 service binding + instance. + @param[in] Controller The controller this IP4 service binding instance + is installed. Most like the UNDI handle. + @param[in] ImageHandle This driver's image handle. + + @return Point to the created IP4_INTERFACE, otherwise NULL. + +**/ IP4_INTERFACE * Ip4CreateInterface ( IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp, @@ -205,46 +207,135 @@ Ip4CreateInterface ( IN EFI_HANDLE ImageHandle ); +/** + Set the interface's address, create and configure + the ARP child if necessary. + + @param Interface The interface to set the address. + @param IpAddr The interface's IP address. + @param SubnetMask The interface's netmask. + + @retval EFI_SUCCESS The interface is configured with Ip/netmask pair, + and a ARP is created for it. + @retval Others Failed to set the interface's address. + +**/ EFI_STATUS Ip4SetAddress ( - IN IP4_INTERFACE *Interface, - IN IP4_ADDR IpAddr, - IN IP4_ADDR SubnetMask + IN OUT IP4_INTERFACE *Interface, + IN IP4_ADDR IpAddr, + IN IP4_ADDR SubnetMask ); +/** + Free the interface used by IpInstance. All the IP instance with + the same Ip/Netmask pair share the same interface. It is reference + counted. All the frames haven't been sent will be cancelled. + Because the IpInstance is optional, the caller must remove + IpInstance from the interface's instance list itself. + + @param[in] Interface The interface used by the IpInstance. + @param[in] IpInstance The Ip instance that free the interface. NULL if + the Ip driver is releasing the default interface. + + @retval EFI_SUCCESS The interface use IpInstance is freed. + +**/ EFI_STATUS Ip4FreeInterface ( IN IP4_INTERFACE *Interface, - IN IP4_PROTOCOL *IpInstance OPTIONAL + IN IP4_PROTOCOL *IpInstance OPTIONAL ); +/** + Send a frame from the interface. If the next hop is broadcast or + multicast address, it is transmitted immediately. If the next hop + is a unicast, it will consult ARP to resolve the NextHop's MAC. + If some error happened, the CallBack won't be called. So, the caller + must test the return value, and take action when there is an error. + + @param[in] Interface The interface to send the frame from + @param[in] IpInstance The IP child that request the transmission. NULL + if it is the IP4 driver itself. + @param[in] Packet The packet to transmit. + @param[in] NextHop The immediate destination to transmit the packet + to. + @param[in] CallBack Function to call back when transmit finished. + @param[in] Context Opaque parameter to the call back. + + @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to send the frame + @retval EFI_NO_MAPPING Can't resolve the MAC for the nexthop + @retval EFI_SUCCESS The packet is successfully transmitted. + @retval other Other error occurs. + +**/ EFI_STATUS Ip4SendFrame ( IN IP4_INTERFACE *Interface, - IN IP4_PROTOCOL *IpInstance, OPTIONAL + IN IP4_PROTOCOL *IpInstance OPTIONAL, IN NET_BUF *Packet, IN IP4_ADDR NextHop, IN IP4_FRAME_CALLBACK CallBack, IN VOID *Context ); +/** + Remove all the frames on the interface that pass the FrameToCancel, + either queued on ARP queues or that have already been delivered to + MNP and not yet recycled. + + @param[in] Interface Interface to remove the frames from. + @param[in] IoStatus The transmit status returned to the frames' + callback. + @param[in] FrameToCancel Function to select the frame to cancel, NULL to + select all. + @param[in] Context Opaque parameters passed to FrameToCancel. + +**/ VOID Ip4CancelFrames ( IN IP4_INTERFACE *Interface, IN EFI_STATUS IoStatus, - IN IP4_FRAME_TO_CANCEL FrameToCancel, OPTIONAL + IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL, IN VOID *Context ); +/** + If there is a pending receive request, cancel it. Don't call + the receive request's callback because this function can be only + called if the instance or driver is tearing itself down. It + doesn't make sense to call it back. But it is necessary to call + the transmit token's callback to give it a chance to free the + packet and update the upper layer's transmit request status, say + that from the UDP. + + @param[in] Interface The interface used by the IpInstance + +**/ VOID Ip4CancelReceive ( IN IP4_INTERFACE *Interface ); +/** + Request to receive the packet from the interface. + + @param[in] Interface The interface to receive the frames from. + @param[in] IpInstance The instance that requests the receive. NULL for + the driver itself. + @param[in] CallBack Function to call when receive finished. + @param[in] Context Opaque parameter to the callback. + + @retval EFI_ALREADY_STARTED There is already a pending receive request. + @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to receive. + @retval EFI_SUCCESS The recieve request has been started. + @retval other Other error occurs. + +**/ EFI_STATUS Ip4ReceiveFrame ( IN IP4_INTERFACE *Interface, - IN IP4_PROTOCOL *IpInstance, OPTIONAL + IN IP4_PROTOCOL *IpInstance OPTIONAL, IN IP4_FRAME_CALLBACK CallBack, IN VOID *Context );