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