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