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