]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Library/UdpIoLib.h
Clean up to update the reference of the these macros:
[mirror_edk2.git] / MdeModulePkg / Include / Library / UdpIoLib.h
CommitLineData
97b38d4e 1/** @file\r
2 The helper routines to access UDP service. It is used by both\r
3 DHCP and MTFTP.\r
4\r
5Copyright (c) 2006 - 2008, Intel Corporation\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _UDP4IO_H_\r
17#define _UDP4IO_H_\r
18\r
19#include <Protocol/Udp4.h>\r
20\r
21#include <Library/UdpIoLib.h>\r
22#include <Library/NetLib.h>\r
23\r
24typedef struct _UDP_IO_PORT UDP_IO_PORT;\r
25\r
26typedef enum {\r
f3f2e05d 27 UDP_IO_RX_SIGNATURE = SIGNATURE_32 ('U', 'D', 'P', 'R'),\r
28 UDP_IO_TX_SIGNATURE = SIGNATURE_32 ('U', 'D', 'P', 'T'),\r
29 UDP_IO_SIGNATURE = SIGNATURE_32 ('U', 'D', 'P', 'I')\r
97b38d4e 30} UDP_IO_SIGNATURE_TYPE;\r
31\r
32typedef struct {\r
33 IP4_ADDR LocalAddr;\r
34 UINT16 LocalPort;\r
35 IP4_ADDR RemoteAddr;\r
36 UINT16 RemotePort;\r
37} UDP_POINTS;\r
38\r
39//\r
40// This prototype is used by both receive and transmission.\r
41// When receiving Netbuf is allocated by UDP access point, and\r
42// released by user. When transmitting, the NetBuf is from user,\r
43// and provided to the callback as a reference.\r
44//\r
45typedef\r
46VOID\r
47(*UDP_IO_CALLBACK) (\r
48 IN NET_BUF *Packet,\r
49 IN UDP_POINTS *Points,\r
50 IN EFI_STATUS IoStatus,\r
51 IN VOID *Context\r
52 );\r
53\r
54//\r
55// Each receive request is wrapped in an UDP_RX_TOKEN. Upon completion,\r
56// the CallBack will be called. Only one receive request is send to UDP.\r
57// HeadLen gives the length of the application's header. UDP_IO will\r
58// make the application's header continous before delivery up.\r
59//\r
60typedef struct {\r
61 UINT32 Signature;\r
62 UDP_IO_PORT *UdpIo;\r
63\r
64 UDP_IO_CALLBACK CallBack;\r
65 VOID *Context;\r
66\r
67 UINT32 HeadLen;\r
68 EFI_UDP4_COMPLETION_TOKEN UdpToken;\r
69} UDP_RX_TOKEN;\r
70\r
71//\r
72// Each transmit request is wrapped in an UDP_TX_TOKEN. Upon completion,\r
73// the CallBack will be called. There can be several transmit requests.\r
74//\r
75typedef struct {\r
76 UINT32 Signature;\r
77 LIST_ENTRY Link;\r
78 UDP_IO_PORT *UdpIo;\r
79\r
80 UDP_IO_CALLBACK CallBack;\r
81 NET_BUF *Packet;\r
82 VOID *Context;\r
83\r
84 EFI_UDP4_SESSION_DATA UdpSession;\r
85 EFI_IPv4_ADDRESS Gateway;\r
86\r
87 EFI_UDP4_COMPLETION_TOKEN UdpToken;\r
88 EFI_UDP4_TRANSMIT_DATA UdpTxData;\r
89} UDP_TX_TOKEN;\r
90\r
91struct _UDP_IO_PORT {\r
92 UINT32 Signature;\r
93 LIST_ENTRY Link;\r
94 INTN RefCnt;\r
95\r
96 //\r
97 // Handle used to create/destory UDP child\r
98 //\r
99 EFI_HANDLE Controller;\r
100 EFI_HANDLE Image;\r
101 EFI_HANDLE UdpHandle;\r
102\r
103 EFI_UDP4_PROTOCOL *Udp;\r
104 EFI_UDP4_CONFIG_DATA UdpConfig;\r
105 EFI_SIMPLE_NETWORK_MODE SnpMode;\r
106\r
107 LIST_ENTRY SentDatagram;\r
108 UDP_RX_TOKEN *RecvRequest;\r
109};\r
110\r
111typedef\r
112EFI_STATUS\r
113(*UDP_IO_CONFIG) (\r
114 IN UDP_IO_PORT *UdpIo,\r
115 IN VOID *Context\r
116 );\r
117\r
118typedef\r
119BOOLEAN\r
120(*UDP_IO_TO_CANCEL) (\r
121 IN UDP_TX_TOKEN *Token,\r
122 IN VOID *Context\r
123 );\r
124\r
125/**\r
126 Create a UDP IO port to access the UDP service. It will\r
127 create and configure a UDP child.\r
128\r
129 @param Controller The controller that has the UDP service binding\r
130 protocol installed.\r
131 @param ImageHandle The image handle for the driver.\r
132 @param Configure The function to configure the created UDP child\r
133 @param Context The opaque parameter for the Configure funtion.\r
134\r
135 @return A point to just created UDP IO port or NULL if failed.\r
136\r
137**/\r
138UDP_IO_PORT *\r
139EFIAPI\r
140UdpIoCreatePort (\r
141 IN EFI_HANDLE Controller,\r
142 IN EFI_HANDLE ImageHandle,\r
143 IN UDP_IO_CONFIG Configure,\r
144 IN VOID *Context\r
145 );\r
146\r
147/**\r
148 Free the UDP IO port and all its related resources including\r
149 all the transmitted packet.\r
150\r
151 @param UdpIo The UDP IO port to free.\r
152\r
153 @retval EFI_SUCCESS The UDP IO port is freed.\r
154\r
155**/\r
156EFI_STATUS\r
157EFIAPI\r
158UdpIoFreePort (\r
159 IN UDP_IO_PORT *UdpIo\r
160 );\r
161\r
162/**\r
163 Clean up the UDP IO port. It will release all the transmitted\r
164 datagrams and receive request. It will also configure NULL the\r
165 UDP child.\r
166\r
167 @param UdpIo UDP IO port to clean up.\r
168\r
169 @return None\r
170\r
171**/\r
172VOID\r
173EFIAPI\r
174UdpIoCleanPort (\r
175 IN UDP_IO_PORT *UdpIo\r
176 );\r
177\r
178/**\r
179 Send a packet through the UDP IO port.\r
180\r
181 @param UdpIo The UDP IO Port to send the packet through\r
182 @param Packet The packet to send\r
183 @param EndPoint The local and remote access point\r
184 @param Gateway The gateway to use\r
185 @param CallBack The call back function to call when packet is\r
186 transmitted or failed.\r
187 @param Context The opque parameter to the CallBack\r
188\r
189 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the packet\r
190 @retval EFI_SUCCESS The packet is successfully delivered to UDP for\r
191 transmission.\r
192\r
193**/\r
194EFI_STATUS\r
195EFIAPI\r
196UdpIoSendDatagram (\r
197 IN UDP_IO_PORT *UdpIo,\r
198 IN NET_BUF *Packet,\r
199 IN UDP_POINTS *EndPoint, OPTIONAL\r
200 IN IP4_ADDR Gateway,\r
201 IN UDP_IO_CALLBACK CallBack,\r
202 IN VOID *Context\r
203 );\r
204\r
205/**\r
206 Cancel a single sent datagram.\r
207\r
208 @param UdpIo The UDP IO port to cancel the packet from\r
209 @param Packet The packet to cancel\r
210\r
211 @return None\r
212\r
213**/\r
214VOID\r
215EFIAPI\r
216UdpIoCancelSentDatagram (\r
217 IN UDP_IO_PORT *UdpIo,\r
218 IN NET_BUF *Packet\r
219 );\r
220\r
221/**\r
222 Issue a receive request to the UDP IO port.\r
223\r
224 @param UdpIo The UDP IO port to recieve the packet from.\r
225 @param CallBack The call back function to execute when receive\r
226 finished.\r
227 @param Context The opque context to the call back\r
228 @param HeadLen The lenght of the application's header\r
229\r
230 @retval EFI_ALREADY_STARTED There is already a pending receive request. Only\r
231 one receive request is supported.\r
232 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resource.\r
233 @retval EFI_SUCCESS The receive request is issued successfully.\r
234\r
235**/\r
236EFI_STATUS\r
237EFIAPI\r
238UdpIoRecvDatagram (\r
239 IN UDP_IO_PORT *UdpIo,\r
240 IN UDP_IO_CALLBACK CallBack,\r
241 IN VOID *Context,\r
242 IN UINT32 HeadLen\r
243 );\r
244#endif\r