2 UDP4 Service Binding Protocol as defined in UEFI specification.
4 The EFI UDPv4 Protocol provides simple packet-oriented services
5 to transmit and receive UDP packets.
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
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.
18 #ifndef __EFI_UDP4_PROTOCOL_H__
19 #define __EFI_UDP4_PROTOCOL_H__
21 #include <Protocol/Ip4.h>
25 #define EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID \
27 0x83f01464, 0x99bd, 0x45e5, {0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } \
30 #define EFI_UDP4_PROTOCOL_GUID \
32 0x3ad9df29, 0x4501, 0x478d, {0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } \
35 typedef struct _EFI_UDP4_PROTOCOL EFI_UDP4_PROTOCOL
;
38 EFI_HANDLE InstanceHandle
;
39 EFI_IPv4_ADDRESS LocalAddress
;
41 EFI_IPv4_ADDRESS RemoteAddress
;
43 } EFI_UDP4_SERVICE_POINT
;
46 EFI_HANDLE DriverHandle
;
48 EFI_UDP4_SERVICE_POINT Services
[1];
49 } EFI_UDP4_VARIABLE_DATA
;
52 //ICMP error definitions
54 #define EFI_NETWORK_UNREACHABLE EFIERR(100)
55 #define EFI_HOST_UNREACHABLE EFIERR(101)
56 #define EFI_PROTOCOL_UNREACHABLE EFIERR(102)
57 #define EFI_PORT_UNREACHABLE EFIERR(103)
61 UINT32 FragmentLength
;
63 } EFI_UDP4_FRAGMENT_DATA
;
66 EFI_IPv4_ADDRESS SourceAddress
;
68 EFI_IPv4_ADDRESS DestinationAddress
;
69 UINT16 DestinationPort
;
70 } EFI_UDP4_SESSION_DATA
;
75 BOOLEAN AcceptBroadcast
;
76 BOOLEAN AcceptPromiscuous
;
77 BOOLEAN AcceptAnyPort
;
78 BOOLEAN AllowDuplicatePort
;
84 BOOLEAN DoNotFragment
;
85 UINT32 ReceiveTimeout
;
86 UINT32 TransmitTimeout
;
90 BOOLEAN UseDefaultAddress
;
91 EFI_IPv4_ADDRESS StationAddress
;
92 EFI_IPv4_ADDRESS SubnetMask
;
94 EFI_IPv4_ADDRESS RemoteAddress
;
96 } EFI_UDP4_CONFIG_DATA
;
99 EFI_UDP4_SESSION_DATA
*UdpSessionData
; //OPTIONAL
100 EFI_IPv4_ADDRESS
*GatewayAddress
; //OPTIONAL
102 UINT32 FragmentCount
;
103 EFI_UDP4_FRAGMENT_DATA FragmentTable
[1];
104 } EFI_UDP4_TRANSMIT_DATA
;
108 EFI_EVENT RecycleSignal
;
109 EFI_UDP4_SESSION_DATA UdpSession
;
111 UINT32 FragmentCount
;
112 EFI_UDP4_FRAGMENT_DATA FragmentTable
[1];
113 } EFI_UDP4_RECEIVE_DATA
;
120 EFI_UDP4_RECEIVE_DATA
*RxData
;
121 EFI_UDP4_TRANSMIT_DATA
*TxData
;
123 } EFI_UDP4_COMPLETION_TOKEN
;
126 Reads the current operational settings.
128 The GetModeData() function copies the current operational settings of this EFI
129 UDPv4 Protocol instance into user-supplied buffers. This function is used
130 optionally to retrieve the operational mode data of underlying networks or
133 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
134 @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.
135 @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.
136 @param MnpConfigData Pointer to the managed network configuration data structure.
137 @param SnpModeData Pointer to the simple network mode data structure.
139 @retval EFI_SUCCESS The mode data was read.
140 @retval EFI_NOT_STARTED When Udp4ConfigData is queried, no configuration data is
141 available because this instance has not been started.
142 @retval EFI_INVALID_PARAMETER This is NULL.
147 (EFIAPI
*EFI_UDP4_GET_MODE_DATA
)(
148 IN EFI_UDP4_PROTOCOL
*This
,
149 OUT EFI_UDP4_CONFIG_DATA
*Udp4ConfigData OPTIONAL
,
150 OUT EFI_IP4_MODE_DATA
*Ip4ModeData OPTIONAL
,
151 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
152 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
157 Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4
160 The Configure() function is used to do the following:
161 * Initialize and start this instance of the EFI UDPv4 Protocol.
162 * Change the filtering rules and operational parameters.
163 * Reset this instance of the EFI UDPv4 Protocol.
164 Until these parameters are initialized, no network traffic can be sent or
165 received by this instance. This instance can be also reset by calling Configure()
166 with UdpConfigData set to NULL. Once reset, the receiving queue and transmitting
167 queue are flushed and no traffic is allowed through this instance.
168 With different parameters in UdpConfigData, Configure() can be used to bind
169 this instance to specified port.
171 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
172 @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.
174 @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully.
175 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
176 RARP, etc.) is not finished yet.
177 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
178 @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured
179 and must be stopped/reset before it can be reconfigured.
180 @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE
181 and UdpConfigData.StationPort is already used by
183 @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this
184 EFI UDPv4 Protocol instance.
185 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance
191 (EFIAPI
*EFI_UDP4_CONFIGURE
)(
192 IN EFI_UDP4_PROTOCOL
*This
,
193 IN EFI_UDP4_CONFIG_DATA
*UdpConfigData OPTIONAL
197 Joins and leaves multicast groups.
199 The Groups() function is used to enable and disable the multicast group
200 filtering. If the JoinFlag is FALSE and the MulticastAddress is NULL, then all
201 currently joined groups are left.
203 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
204 @param JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one
205 or all multicast groups.
206 @param MulticastAddress Pointer to multicast group address to join or leave.
208 @retval EFI_SUCCESS The operation completed successfully.
209 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.
210 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
211 RARP, etc.) is not finished yet.
212 @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group.
213 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
215 - JoinFlag is TRUE and MulticastAddress is NULL.
216 - JoinFlag is TRUE and *MulticastAddress is not
217 a valid multicast address.
218 @retval EFI_ALREADY_STARTED The group address is already in the group table (when
220 @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is
222 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
227 (EFIAPI
*EFI_UDP4_GROUPS
)(
228 IN EFI_UDP4_PROTOCOL
*This
,
230 IN EFI_IPv4_ADDRESS
*MulticastAddress OPTIONAL
234 Adds and deletes routing table entries.
236 The Routes() function adds a route to or deletes a route from the routing table.
237 Routes are determined by comparing the SubnetAddress with the destination IP
238 address and arithmetically AND-ing it with the SubnetMask. The gateway address
239 must be on the same subnet as the configured station address.
240 The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.
241 The default route matches all destination IP addresses that do not match any
243 A zero GatewayAddress is a nonroute. Packets are sent to the destination IP
244 address if it can be found in the Address Resolution Protocol (ARP) cache or
245 on the local subnet. One automatic nonroute entry will be inserted into the
246 routing table for outgoing packets that are addressed to a local subnet
247 (gateway address of 0.0.0.0).
248 Each instance of the EFI UDPv4 Protocol has its own independent routing table.
249 Instances of the EFI UDPv4 Protocol that use the default IP address will also
250 have copies of the routing table provided by the EFI_IP4_CONFIG_PROTOCOL. These
251 copies will be updated automatically whenever the IP driver reconfigures its
252 instances; as a result, the previous modification to these copies will be lost.
254 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
255 @param DeleteRoute Set to TRUE to delete this route from the routing table.
256 Set to FALSE to add this route to the routing table.
257 @param SubnetAddress The destination network address that needs to be routed.
258 @param SubnetMask The subnet mask of SubnetAddress.
259 @param GatewayAddress The gateway IP address for this route.
261 @retval EFI_SUCCESS The operation completed successfully.
262 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.
263 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
264 - RARP, etc.) is not finished yet.
265 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
266 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
267 @retval EFI_NOT_FOUND This route is not in the routing table.
268 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.
273 (EFIAPI
*EFI_UDP4_ROUTES
)(
274 IN EFI_UDP4_PROTOCOL
*This
,
275 IN BOOLEAN DeleteRoute
,
276 IN EFI_IPv4_ADDRESS
*SubnetAddress
,
277 IN EFI_IPv4_ADDRESS
*SubnetMask
,
278 IN EFI_IPv4_ADDRESS
*GatewayAddress
282 Polls for incoming data packets and processes outgoing data packets.
284 The Poll() function can be used by network drivers and applications to increase
285 the rate that data packets are moved between the communications device and the
286 transmit and receive queues.
287 In some systems, the periodic timer event in the managed network driver may not
288 poll the underlying communications device fast enough to transmit and/or receive
289 all data packets without missing incoming packets or dropping outgoing packets.
290 Drivers and applications that are experiencing packet loss should try calling
291 the Poll() function more often.
293 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
295 @retval EFI_SUCCESS Incoming or outgoing data was processed.
296 @retval EFI_INVALID_PARAMETER This is NULL.
297 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
298 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
303 (EFIAPI
*EFI_UDP4_POLL
)(
304 IN EFI_UDP4_PROTOCOL
*This
308 Places an asynchronous receive request into the receiving queue.
310 The Receive() function places a completion token into the receive packet queue.
311 This function is always asynchronous.
312 The caller must fill in the Token.Event field in the completion token, and this
313 field cannot be NULL. When the receive operation completes, the EFI UDPv4 Protocol
314 driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
315 is signaled. Providing a proper notification function and context for the event
316 will enable the user to receive the notification and receiving status. That
317 notification function is guaranteed to not be re-entered.
319 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
320 @param Token Pointer to a token that is associated with the receive data
323 @retval EFI_SUCCESS The receive completion token was cached.
324 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.
325 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.)
327 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
328 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system
329 resources (usually memory).
330 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
331 @retval EFI_ACCESS_DENIED A receive completion token with the same Token.Event was already in
333 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
338 (EFIAPI
*EFI_UDP4_RECEIVE
)(
339 IN EFI_UDP4_PROTOCOL
*This
,
340 IN EFI_UDP4_COMPLETION_TOKEN
*Token
344 Queues outgoing data packets into the transmit queue.
346 The Transmit() function places a sending request to this instance of the EFI
347 UDPv4 Protocol, alongside the transmit data that was filled by the user. Whenever
348 the packet in the token is sent out or some errors occur, the Token.Event will
349 be signaled and Token.Status is updated. Providing a proper notification function
350 and context for the event will enable the user to receive the notification and
353 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
354 @param Token Pointer to the completion token that will be placed into the
357 @retval EFI_SUCCESS The data has been queued for transmission.
358 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.
359 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
360 RARP, etc.) is not finished yet.
361 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
362 @retval EFI_ACCESS_DENIED The transmit completion token with the same
363 Token.Event was already in the transmit queue.
364 @retval EFI_NOT_READY The completion token could not be queued because the
365 transmit queue is full.
366 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
367 @retval EFI_NOT_FOUND There is no route to the destination network or address.
368 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP packet
369 size. Or the length of the IP header + UDP header + data
370 length is greater than MTU if DoNotFragment is TRUE.
375 (EFIAPI
*EFI_UDP4_TRANSMIT
)(
376 IN EFI_UDP4_PROTOCOL
*This
,
377 IN EFI_UDP4_COMPLETION_TOKEN
*Token
381 Aborts an asynchronous transmit or receive request.
383 The Cancel() function is used to abort a pending transmit or receive request.
384 If the token is in the transmit or receive request queues, after calling this
385 function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
386 signaled. If the token is not in one of the queues, which usually means that
387 the asynchronous operation has completed, this function will not signal the
388 token and EFI_NOT_FOUND is returned.
390 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
391 @param Token Pointer to a token that has been issued by
392 EFI_UDP4_PROTOCOL.Transmit() or
393 EFI_UDP4_PROTOCOL.Receive().If NULL, all pending
396 @retval EFI_SUCCESS The asynchronous I/O request was aborted and Token.Event
397 was signaled. When Token is NULL, all pending requests are
398 aborted and their events are signaled.
399 @retval EFI_INVALID_PARAMETER This is NULL.
400 @retval EFI_NOT_STARTED This instance has not been started.
401 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
402 RARP, etc.) is not finished yet.
403 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was
404 not found in the transmit or receive queue. It has either completed
405 or was not issued by Transmit() and Receive().
410 (EFIAPI
*EFI_UDP4_CANCEL
)(
411 IN EFI_UDP4_PROTOCOL
*This
,
412 IN EFI_UDP4_COMPLETION_TOKEN
*Token OPTIONAL
416 /// The EFI_UDP4_PROTOCOL defines an EFI UDPv4 Protocol session that can be used
417 /// by any network drivers, applications, or daemons to transmit or receive UDP packets.
418 /// This protocol instance can either be bound to a specified port as a service or
419 /// connected to some remote peer as an active client. Each instance has its own settings,
420 /// such as the routing table and group table, which are independent from each other.
422 struct _EFI_UDP4_PROTOCOL
{
423 EFI_UDP4_GET_MODE_DATA GetModeData
;
424 EFI_UDP4_CONFIGURE Configure
;
425 EFI_UDP4_GROUPS Groups
;
426 EFI_UDP4_ROUTES Routes
;
427 EFI_UDP4_TRANSMIT Transmit
;
428 EFI_UDP4_RECEIVE Receive
;
429 EFI_UDP4_CANCEL Cancel
;
433 extern EFI_GUID gEfiUdp4ServiceBindingProtocolGuid
;
434 extern EFI_GUID gEfiUdp4ProtocolGuid
;