]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/Udp4.h
UEFI 2.3 Specification should be updated to move these status code definitions into...
[mirror_edk2.git] / MdePkg / Include / Protocol / Udp4.h
CommitLineData
d1f95000 1/** @file\r
4ca9b6c4 2 UDP4 Service Binding Protocol as defined in UEFI specification.\r
842f5579 3\r
4ca9b6c4
LG
4 The EFI UDPv4 Protocol provides simple packet-oriented services \r
5 to transmit and receive UDP packets. \r
6\r
7 Copyright (c) 2006 - 2008, Intel Corporation \r
d1f95000 8 All rights reserved. This program and the accompanying materials \r
9 are licensed and made available under the terms and conditions of the BSD License \r
10 which accompanies this distribution. The full text of the license may be found at \r
11 http://opensource.org/licenses/bsd-license.php \r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
15\r
d1f95000 16**/\r
17\r
18#ifndef __EFI_UDP4_PROTOCOL_H__\r
19#define __EFI_UDP4_PROTOCOL_H__\r
20\r
21#include <Protocol/Ip4.h>\r
22//\r
23//GUID definitions\r
24//\r
25#define EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID \\r
26 { \\r
27 0x83f01464, 0x99bd, 0x45e5, {0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } \\r
28 }\r
29\r
30#define EFI_UDP4_PROTOCOL_GUID \\r
31 { \\r
32 0x3ad9df29, 0x4501, 0x478d, {0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } \\r
33 }\r
34\r
35typedef struct _EFI_UDP4_PROTOCOL EFI_UDP4_PROTOCOL; \r
36 \r
37typedef struct {\r
38 EFI_HANDLE InstanceHandle;\r
39 EFI_IPv4_ADDRESS LocalAddress;\r
40 UINT16 LocalPort;\r
41 EFI_IPv4_ADDRESS RemoteAddress;\r
42 UINT16 RemotePort;\r
43} EFI_UDP4_SERVICE_POINT; \r
44\r
45typedef struct {\r
46 EFI_HANDLE DriverHandle;\r
47 UINT32 ServiceCount;\r
48 EFI_UDP4_SERVICE_POINT Services[1];\r
49} EFI_UDP4_VARIABLE_DATA;\r
50\r
d1f95000 51typedef struct {\r
52 UINT32 FragmentLength;\r
53 VOID *FragmentBuffer;\r
54} EFI_UDP4_FRAGMENT_DATA;\r
55\r
56typedef struct {\r
57 EFI_IPv4_ADDRESS SourceAddress;\r
58 UINT16 SourcePort;\r
59 EFI_IPv4_ADDRESS DestinationAddress;\r
60 UINT16 DestinationPort;\r
61} EFI_UDP4_SESSION_DATA;\r
62typedef struct {\r
63 //\r
64 // Receiving Filters\r
65 //\r
66 BOOLEAN AcceptBroadcast;\r
67 BOOLEAN AcceptPromiscuous;\r
68 BOOLEAN AcceptAnyPort;\r
69 BOOLEAN AllowDuplicatePort;\r
70 //\r
71 // I/O parameters\r
72 //\r
73 UINT8 TypeOfService;\r
74 UINT8 TimeToLive;\r
75 BOOLEAN DoNotFragment;\r
76 UINT32 ReceiveTimeout;\r
77 UINT32 TransmitTimeout;\r
78 //\r
79 // Access Point\r
80 //\r
81 BOOLEAN UseDefaultAddress;\r
82 EFI_IPv4_ADDRESS StationAddress;\r
83 EFI_IPv4_ADDRESS SubnetMask;\r
84 UINT16 StationPort;\r
85 EFI_IPv4_ADDRESS RemoteAddress;\r
86 UINT16 RemotePort;\r
87} EFI_UDP4_CONFIG_DATA;\r
88\r
89typedef struct {\r
90 EFI_UDP4_SESSION_DATA *UdpSessionData; //OPTIONAL\r
91 EFI_IPv4_ADDRESS *GatewayAddress; //OPTIONAL\r
92 UINT32 DataLength;\r
93 UINT32 FragmentCount; \r
94 EFI_UDP4_FRAGMENT_DATA FragmentTable[1];\r
95} EFI_UDP4_TRANSMIT_DATA;\r
96\r
97typedef struct {\r
98 EFI_TIME TimeStamp;\r
99 EFI_EVENT RecycleSignal;\r
100 EFI_UDP4_SESSION_DATA UdpSession;\r
101 UINT32 DataLength;\r
102 UINT32 FragmentCount;\r
103 EFI_UDP4_FRAGMENT_DATA FragmentTable[1];\r
104} EFI_UDP4_RECEIVE_DATA;\r
105\r
106\r
107typedef struct {\r
108 EFI_EVENT Event;\r
109 EFI_STATUS Status;\r
110 union {\r
111 EFI_UDP4_RECEIVE_DATA *RxData;\r
112 EFI_UDP4_TRANSMIT_DATA *TxData;\r
113 } Packet;\r
114} EFI_UDP4_COMPLETION_TOKEN;\r
115\r
116/**\r
117 Reads the current operational settings.\r
118\r
30c99a72 119 The GetModeData() function copies the current operational settings of this EFI\r
120 UDPv4 Protocol instance into user-supplied buffers. This function is used\r
121 optionally to retrieve the operational mode data of underlying networks or\r
122 drivers.\r
123\r
d1f95000 124 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
125 @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.\r
126 @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.\r
127 @param MnpConfigData Pointer to the managed network configuration data structure.\r
128 @param SnpModeData Pointer to the simple network mode data structure.\r
129\r
130 @retval EFI_SUCCESS The mode data was read.\r
131 @retval EFI_NOT_STARTED When Udp4ConfigData is queried, no configuration data is\r
132 available because this instance has not been started.\r
133 @retval EFI_INVALID_PARAMETER This is NULL.\r
134\r
135**/\r
136typedef\r
137EFI_STATUS\r
8b13229b 138(EFIAPI *EFI_UDP4_GET_MODE_DATA)(\r
d1f95000 139 IN EFI_UDP4_PROTOCOL *This,\r
140 OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL,\r
141 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r
142 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
143 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
ed66e1bc 144 ); \r
d1f95000 145 \r
146\r
147/**\r
148 Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4\r
149 Protocol.\r
30c99a72 150 \r
151 The Configure() function is used to do the following:\r
152 * Initialize and start this instance of the EFI UDPv4 Protocol.\r
153 * Change the filtering rules and operational parameters.\r
154 * Reset this instance of the EFI UDPv4 Protocol.\r
155 Until these parameters are initialized, no network traffic can be sent or\r
156 received by this instance. This instance can be also reset by calling Configure()\r
157 with UdpConfigData set to NULL. Once reset, the receiving queue and transmitting\r
158 queue are flushed and no traffic is allowed through this instance.\r
159 With different parameters in UdpConfigData, Configure() can be used to bind\r
160 this instance to specified port.\r
d1f95000 161\r
162 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
163 @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.\r
164\r
165 @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully.\r
166 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
167 RARP, etc.) is not finished yet.\r
168 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r
169 @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured\r
170 and must be stopped/reset before it can be reconfigured.\r
171 @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE\r
172 and UdpConfigData.StationPort is already used by\r
173 other instance.\r
174 @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this\r
175 EFI UDPv4 Protocol instance.\r
176 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance\r
177 was not opened. \r
178\r
179**/\r
180typedef\r
181EFI_STATUS\r
8b13229b 182(EFIAPI *EFI_UDP4_CONFIGURE)(\r
d1f95000 183 IN EFI_UDP4_PROTOCOL *This,\r
184 IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL\r
ed66e1bc 185 ); \r
d1f95000 186\r
187/**\r
188 Joins and leaves multicast groups.\r
30c99a72 189 \r
190 The Groups() function is used to enable and disable the multicast group\r
191 filtering. If the JoinFlag is FALSE and the MulticastAddress is NULL, then all\r
192 currently joined groups are left.\r
d1f95000 193\r
194 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
195 @param JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one\r
196 or all multicast groups.\r
197 @param MulticastAddress Pointer to multicast group address to join or leave.\r
198\r
199 @retval EFI_SUCCESS The operation completed successfully.\r
200 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.\r
201 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
202 RARP, etc.) is not finished yet.\r
203 @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group.\r
204 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
205 - This is NULL.\r
206 - JoinFlag is TRUE and MulticastAddress is NULL.\r
207 - JoinFlag is TRUE and *MulticastAddress is not\r
208 a valid multicast address.\r
209 @retval EFI_ALREADY_STARTED The group address is already in the group table (when\r
210 JoinFlag is TRUE).\r
211 @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is\r
212 FALSE).\r
213 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
214\r
215**/\r
216typedef\r
217EFI_STATUS\r
8b13229b 218(EFIAPI *EFI_UDP4_GROUPS)(\r
d1f95000 219 IN EFI_UDP4_PROTOCOL *This,\r
220 IN BOOLEAN JoinFlag,\r
221 IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL\r
ed66e1bc 222 ); \r
d1f95000 223\r
224/**\r
225 Adds and deletes routing table entries.\r
30c99a72 226 \r
227 The Routes() function adds a route to or deletes a route from the routing table.\r
228 Routes are determined by comparing the SubnetAddress with the destination IP\r
229 address and arithmetically AND-ing it with the SubnetMask. The gateway address\r
230 must be on the same subnet as the configured station address.\r
231 The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.\r
232 The default route matches all destination IP addresses that do not match any\r
233 other routes.\r
234 A zero GatewayAddress is a nonroute. Packets are sent to the destination IP\r
235 address if it can be found in the Address Resolution Protocol (ARP) cache or\r
236 on the local subnet. One automatic nonroute entry will be inserted into the\r
237 routing table for outgoing packets that are addressed to a local subnet\r
238 (gateway address of 0.0.0.0).\r
239 Each instance of the EFI UDPv4 Protocol has its own independent routing table.\r
240 Instances of the EFI UDPv4 Protocol that use the default IP address will also\r
241 have copies of the routing table provided by the EFI_IP4_CONFIG_PROTOCOL. These\r
242 copies will be updated automatically whenever the IP driver reconfigures its\r
243 instances; as a result, the previous modification to these copies will be lost.\r
d1f95000 244\r
245 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
246 @param DeleteRoute Set to TRUE to delete this route from the routing table.\r
247 Set to FALSE to add this route to the routing table.\r
248 @param SubnetAddress The destination network address that needs to be routed.\r
249 @param SubnetMask The subnet mask of SubnetAddress.\r
250 @param GatewayAddress The gateway IP address for this route.\r
251\r
252 @retval EFI_SUCCESS The operation completed successfully.\r
253 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.\r
254 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
255 - RARP, etc.) is not finished yet.\r
256 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
257 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.\r
258 @retval EFI_NOT_FOUND This route is not in the routing table.\r
259 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.\r
260\r
261**/\r
262typedef\r
263EFI_STATUS\r
8b13229b 264(EFIAPI *EFI_UDP4_ROUTES)(\r
d1f95000 265 IN EFI_UDP4_PROTOCOL *This,\r
266 IN BOOLEAN DeleteRoute,\r
267 IN EFI_IPv4_ADDRESS *SubnetAddress,\r
268 IN EFI_IPv4_ADDRESS *SubnetMask,\r
269 IN EFI_IPv4_ADDRESS *GatewayAddress\r
ed66e1bc 270 ); \r
d1f95000 271\r
272/**\r
273 Polls for incoming data packets and processes outgoing data packets.\r
30c99a72 274 \r
275 The Poll() function can be used by network drivers and applications to increase\r
276 the rate that data packets are moved between the communications device and the\r
277 transmit and receive queues.\r
278 In some systems, the periodic timer event in the managed network driver may not\r
279 poll the underlying communications device fast enough to transmit and/or receive\r
280 all data packets without missing incoming packets or dropping outgoing packets.\r
281 Drivers and applications that are experiencing packet loss should try calling\r
282 the Poll() function more often.\r
d1f95000 283\r
284 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
285\r
286 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
287 @retval EFI_INVALID_PARAMETER This is NULL.\r
288 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
289 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.\r
290\r
291**/\r
292typedef\r
293EFI_STATUS\r
8b13229b 294(EFIAPI *EFI_UDP4_POLL)(\r
d1f95000 295 IN EFI_UDP4_PROTOCOL *This\r
ed66e1bc 296 ); \r
d1f95000 297\r
298/**\r
299 Places an asynchronous receive request into the receiving queue.\r
30c99a72 300 \r
301 The Receive() function places a completion token into the receive packet queue.\r
302 This function is always asynchronous.\r
303 The caller must fill in the Token.Event field in the completion token, and this\r
304 field cannot be NULL. When the receive operation completes, the EFI UDPv4 Protocol\r
305 driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event\r
306 is signaled. Providing a proper notification function and context for the event\r
307 will enable the user to receive the notification and receiving status. That\r
308 notification function is guaranteed to not be re-entered.\r
d1f95000 309\r
310 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
311 @param Token Pointer to a token that is associated with the receive data\r
312 descriptor.\r
313\r
314 @retval EFI_SUCCESS The receive completion token was cached.\r
315 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.\r
316 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.)\r
317 is not finished yet.\r
318 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
319 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system\r
320 resources (usually memory).\r
321 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
322 @retval EFI_ACCESS_DENIED A receive completion token with the same Token.Event was already in\r
323 the receive queue.\r
324 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.\r
325\r
326**/\r
327typedef\r
328EFI_STATUS\r
8b13229b 329(EFIAPI *EFI_UDP4_RECEIVE)(\r
d1f95000 330 IN EFI_UDP4_PROTOCOL *This,\r
331 IN EFI_UDP4_COMPLETION_TOKEN *Token\r
ed66e1bc 332 ); \r
d1f95000 333\r
334/**\r
335 Queues outgoing data packets into the transmit queue.\r
30c99a72 336 \r
337 The Transmit() function places a sending request to this instance of the EFI\r
338 UDPv4 Protocol, alongside the transmit data that was filled by the user. Whenever\r
339 the packet in the token is sent out or some errors occur, the Token.Event will\r
340 be signaled and Token.Status is updated. Providing a proper notification function\r
341 and context for the event will enable the user to receive the notification and\r
342 transmitting status.\r
d1f95000 343\r
344 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
345 @param Token Pointer to the completion token that will be placed into the\r
346 transmit queue.\r
347\r
348 @retval EFI_SUCCESS The data has been queued for transmission.\r
349 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.\r
350 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
351 RARP, etc.) is not finished yet.\r
352 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
353 @retval EFI_ACCESS_DENIED The transmit completion token with the same\r
354 Token.Event was already in the transmit queue.\r
355 @retval EFI_NOT_READY The completion token could not be queued because the\r
356 transmit queue is full.\r
357 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.\r
358 @retval EFI_NOT_FOUND There is no route to the destination network or address.\r
359 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP packet\r
360 size. Or the length of the IP header + UDP header + data\r
361 length is greater than MTU if DoNotFragment is TRUE.\r
362\r
363**/\r
364typedef\r
365EFI_STATUS\r
8b13229b 366(EFIAPI *EFI_UDP4_TRANSMIT)(\r
d1f95000 367 IN EFI_UDP4_PROTOCOL *This,\r
368 IN EFI_UDP4_COMPLETION_TOKEN *Token\r
ed66e1bc 369 ); \r
d1f95000 370\r
371/**\r
372 Aborts an asynchronous transmit or receive request.\r
30c99a72 373 \r
374 The Cancel() function is used to abort a pending transmit or receive request.\r
375 If the token is in the transmit or receive request queues, after calling this\r
376 function, Token.Status will be set to EFI_ABORTED and then Token.Event will be\r
377 signaled. If the token is not in one of the queues, which usually means that\r
378 the asynchronous operation has completed, this function will not signal the\r
379 token and EFI_NOT_FOUND is returned.\r
d1f95000 380\r
381 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
382 @param Token Pointer to a token that has been issued by\r
383 EFI_UDP4_PROTOCOL.Transmit() or\r
384 EFI_UDP4_PROTOCOL.Receive().If NULL, all pending\r
385 tokens are aborted.\r
386\r
387 @retval EFI_SUCCESS The asynchronous I/O request was aborted and Token.Event\r
388 was signaled. When Token is NULL, all pending requests are\r
389 aborted and their events are signaled.\r
390 @retval EFI_INVALID_PARAMETER This is NULL.\r
391 @retval EFI_NOT_STARTED This instance has not been started.\r
392 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,\r
393 RARP, etc.) is not finished yet.\r
394 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was\r
395 not found in the transmit or receive queue. It has either completed\r
396 or was not issued by Transmit() and Receive().\r
397\r
398**/\r
399typedef\r
400EFI_STATUS\r
401(EFIAPI *EFI_UDP4_CANCEL)(\r
402 IN EFI_UDP4_PROTOCOL *This,\r
403 IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL\r
ed66e1bc 404 ); \r
d1f95000 405\r
44717a39 406///\r
407/// The EFI_UDP4_PROTOCOL defines an EFI UDPv4 Protocol session that can be used \r
408/// by any network drivers, applications, or daemons to transmit or receive UDP packets. \r
409/// This protocol instance can either be bound to a specified port as a service or \r
410/// connected to some remote peer as an active client. Each instance has its own settings, \r
411/// such as the routing table and group table, which are independent from each other.\r
412///\r
d1f95000 413struct _EFI_UDP4_PROTOCOL {\r
414 EFI_UDP4_GET_MODE_DATA GetModeData;\r
415 EFI_UDP4_CONFIGURE Configure;\r
416 EFI_UDP4_GROUPS Groups;\r
417 EFI_UDP4_ROUTES Routes;\r
418 EFI_UDP4_TRANSMIT Transmit;\r
419 EFI_UDP4_RECEIVE Receive;\r
420 EFI_UDP4_CANCEL Cancel;\r
421 EFI_UDP4_POLL Poll;\r
422};\r
423\r
424extern EFI_GUID gEfiUdp4ServiceBindingProtocolGuid;\r
425extern EFI_GUID gEfiUdp4ProtocolGuid;\r
426\r
427#endif\r