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