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