2 The helper routines to access UDP service. It is used by both
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Protocol/Udp4.h>
21 #include <Library/UdpIoLib.h>
22 #include <Library/NetLib.h>
24 typedef struct _UDP_IO_PORT UDP_IO_PORT
;
27 UDP_IO_RX_SIGNATURE
= EFI_SIGNATURE_32 ('U', 'D', 'P', 'R'),
28 UDP_IO_TX_SIGNATURE
= EFI_SIGNATURE_32 ('U', 'D', 'P', 'T'),
29 UDP_IO_SIGNATURE
= EFI_SIGNATURE_32 ('U', 'D', 'P', 'I')
30 } UDP_IO_SIGNATURE_TYPE
;
40 // This prototype is used by both receive and transmission.
41 // When receiving Netbuf is allocated by UDP access point, and
42 // released by user. When transmitting, the NetBuf is from user,
43 // and provided to the callback as a reference.
49 IN UDP_POINTS
*Points
,
50 IN EFI_STATUS IoStatus
,
55 // Each receive request is wrapped in an UDP_RX_TOKEN. Upon completion,
56 // the CallBack will be called. Only one receive request is send to UDP.
57 // HeadLen gives the length of the application's header. UDP_IO will
58 // make the application's header continous before delivery up.
64 UDP_IO_CALLBACK CallBack
;
68 EFI_UDP4_COMPLETION_TOKEN UdpToken
;
72 // Each transmit request is wrapped in an UDP_TX_TOKEN. Upon completion,
73 // the CallBack will be called. There can be several transmit requests.
80 UDP_IO_CALLBACK CallBack
;
84 EFI_UDP4_SESSION_DATA UdpSession
;
85 EFI_IPv4_ADDRESS Gateway
;
87 EFI_UDP4_COMPLETION_TOKEN UdpToken
;
88 EFI_UDP4_TRANSMIT_DATA UdpTxData
;
97 // Handle used to create/destory UDP child
99 EFI_HANDLE Controller
;
101 EFI_HANDLE UdpHandle
;
103 EFI_UDP4_PROTOCOL
*Udp
;
104 EFI_UDP4_CONFIG_DATA UdpConfig
;
105 EFI_SIMPLE_NETWORK_MODE SnpMode
;
107 LIST_ENTRY SentDatagram
;
108 UDP_RX_TOKEN
*RecvRequest
;
114 IN UDP_IO_PORT
*UdpIo
,
120 (*UDP_IO_TO_CANCEL
) (
121 IN UDP_TX_TOKEN
*Token
,
126 Create a UDP IO port to access the UDP service. It will
127 create and configure a UDP child.
129 @param Controller The controller that has the UDP service binding
131 @param ImageHandle The image handle for the driver.
132 @param Configure The function to configure the created UDP child
133 @param Context The opaque parameter for the Configure funtion.
135 @return A point to just created UDP IO port or NULL if failed.
141 IN EFI_HANDLE Controller
,
142 IN EFI_HANDLE ImageHandle
,
143 IN UDP_IO_CONFIG Configure
,
148 Free the UDP IO port and all its related resources including
149 all the transmitted packet.
151 @param UdpIo The UDP IO port to free.
153 @retval EFI_SUCCESS The UDP IO port is freed.
159 IN UDP_IO_PORT
*UdpIo
163 Clean up the UDP IO port. It will release all the transmitted
164 datagrams and receive request. It will also configure NULL the
167 @param UdpIo UDP IO port to clean up.
175 IN UDP_IO_PORT
*UdpIo
179 Send a packet through the UDP IO port.
181 @param UdpIo The UDP IO Port to send the packet through
182 @param Packet The packet to send
183 @param EndPoint The local and remote access point
184 @param Gateway The gateway to use
185 @param CallBack The call back function to call when packet is
186 transmitted or failed.
187 @param Context The opque parameter to the CallBack
189 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the packet
190 @retval EFI_SUCCESS The packet is successfully delivered to UDP for
197 IN UDP_IO_PORT
*UdpIo
,
199 IN UDP_POINTS
*EndPoint
, OPTIONAL
201 IN UDP_IO_CALLBACK CallBack
,
206 Cancel a single sent datagram.
208 @param UdpIo The UDP IO port to cancel the packet from
209 @param Packet The packet to cancel
216 UdpIoCancelSentDatagram (
217 IN UDP_IO_PORT
*UdpIo
,
222 Issue a receive request to the UDP IO port.
224 @param UdpIo The UDP IO port to recieve the packet from.
225 @param CallBack The call back function to execute when receive
227 @param Context The opque context to the call back
228 @param HeadLen The lenght of the application's header
230 @retval EFI_ALREADY_STARTED There is already a pending receive request. Only
231 one receive request is supported.
232 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resource.
233 @retval EFI_SUCCESS The receive request is issued successfully.
239 IN UDP_IO_PORT
*UdpIo
,
240 IN UDP_IO_CALLBACK CallBack
,