]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Udp4.h
a. Fixed conversion failure for ASL style include.
[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 //
52 //ICMP error definitions
53 //
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)
58
59
60 typedef struct {
61 UINT32 FragmentLength;
62 VOID *FragmentBuffer;
63 } EFI_UDP4_FRAGMENT_DATA;
64
65 typedef struct {
66 EFI_IPv4_ADDRESS SourceAddress;
67 UINT16 SourcePort;
68 EFI_IPv4_ADDRESS DestinationAddress;
69 UINT16 DestinationPort;
70 } EFI_UDP4_SESSION_DATA;
71 typedef struct {
72 //
73 // Receiving Filters
74 //
75 BOOLEAN AcceptBroadcast;
76 BOOLEAN AcceptPromiscuous;
77 BOOLEAN AcceptAnyPort;
78 BOOLEAN AllowDuplicatePort;
79 //
80 // I/O parameters
81 //
82 UINT8 TypeOfService;
83 UINT8 TimeToLive;
84 BOOLEAN DoNotFragment;
85 UINT32 ReceiveTimeout;
86 UINT32 TransmitTimeout;
87 //
88 // Access Point
89 //
90 BOOLEAN UseDefaultAddress;
91 EFI_IPv4_ADDRESS StationAddress;
92 EFI_IPv4_ADDRESS SubnetMask;
93 UINT16 StationPort;
94 EFI_IPv4_ADDRESS RemoteAddress;
95 UINT16 RemotePort;
96 } EFI_UDP4_CONFIG_DATA;
97
98 typedef struct {
99 EFI_UDP4_SESSION_DATA *UdpSessionData; //OPTIONAL
100 EFI_IPv4_ADDRESS *GatewayAddress; //OPTIONAL
101 UINT32 DataLength;
102 UINT32 FragmentCount;
103 EFI_UDP4_FRAGMENT_DATA FragmentTable[1];
104 } EFI_UDP4_TRANSMIT_DATA;
105
106 typedef struct {
107 EFI_TIME TimeStamp;
108 EFI_EVENT RecycleSignal;
109 EFI_UDP4_SESSION_DATA UdpSession;
110 UINT32 DataLength;
111 UINT32 FragmentCount;
112 EFI_UDP4_FRAGMENT_DATA FragmentTable[1];
113 } EFI_UDP4_RECEIVE_DATA;
114
115
116 typedef struct {
117 EFI_EVENT Event;
118 EFI_STATUS Status;
119 union {
120 EFI_UDP4_RECEIVE_DATA *RxData;
121 EFI_UDP4_TRANSMIT_DATA *TxData;
122 } Packet;
123 } EFI_UDP4_COMPLETION_TOKEN;
124
125 /**
126 Reads the current operational settings.
127
128 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
129 @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.
130 @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.
131 @param MnpConfigData Pointer to the managed network configuration data structure.
132 @param SnpModeData Pointer to the simple network mode data structure.
133
134 @retval EFI_SUCCESS The mode data was read.
135 @retval EFI_NOT_STARTED When Udp4ConfigData is queried, no configuration data is
136 available because this instance has not been started.
137 @retval EFI_INVALID_PARAMETER This is NULL.
138
139 **/
140 typedef
141 EFI_STATUS
142 (EFIAPI *EFI_UDP4_GET_MODE_DATA)(
143 IN EFI_UDP4_PROTOCOL *This,
144 OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL,
145 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
146 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
147 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
148 );
149
150
151 /**
152 Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4
153 Protocol.
154
155 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
156 @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.
157
158 @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully.
159 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
160 RARP, etc.) is not finished yet.
161 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
162 @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured
163 and must be stopped/reset before it can be reconfigured.
164 @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE
165 and UdpConfigData.StationPort is already used by
166 other instance.
167 @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this
168 EFI UDPv4 Protocol instance.
169 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance
170 was not opened.
171
172 **/
173 typedef
174 EFI_STATUS
175 (EFIAPI *EFI_UDP4_CONFIGURE)(
176 IN EFI_UDP4_PROTOCOL *This,
177 IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL
178 );
179
180 /**
181 Joins and leaves multicast groups.
182
183 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
184 @param JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one
185 or all multicast groups.
186 @param MulticastAddress Pointer to multicast group address to join or leave.
187
188 @retval EFI_SUCCESS The operation completed successfully.
189 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.
190 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
191 RARP, etc.) is not finished yet.
192 @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group.
193 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
194 - This is NULL.
195 - JoinFlag is TRUE and MulticastAddress is NULL.
196 - JoinFlag is TRUE and *MulticastAddress is not
197 a valid multicast address.
198 @retval EFI_ALREADY_STARTED The group address is already in the group table (when
199 JoinFlag is TRUE).
200 @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is
201 FALSE).
202 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
203
204 **/
205 typedef
206 EFI_STATUS
207 (EFIAPI *EFI_UDP4_GROUPS)(
208 IN EFI_UDP4_PROTOCOL *This,
209 IN BOOLEAN JoinFlag,
210 IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL
211 );
212
213 /**
214 Adds and deletes routing table entries.
215
216 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
217 @param DeleteRoute Set to TRUE to delete this route from the routing table.
218 Set to FALSE to add this route to the routing table.
219 @param SubnetAddress The destination network address that needs to be routed.
220 @param SubnetMask The subnet mask of SubnetAddress.
221 @param GatewayAddress The gateway IP address for this route.
222
223 @retval EFI_SUCCESS The operation completed successfully.
224 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.
225 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
226 - RARP, etc.) is not finished yet.
227 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
228 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
229 @retval EFI_NOT_FOUND This route is not in the routing table.
230 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.
231
232 **/
233 typedef
234 EFI_STATUS
235 (EFIAPI *EFI_UDP4_ROUTES)(
236 IN EFI_UDP4_PROTOCOL *This,
237 IN BOOLEAN DeleteRoute,
238 IN EFI_IPv4_ADDRESS *SubnetAddress,
239 IN EFI_IPv4_ADDRESS *SubnetMask,
240 IN EFI_IPv4_ADDRESS *GatewayAddress
241 );
242
243 /**
244 Polls for incoming data packets and processes outgoing data packets.
245
246 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
247
248 @retval EFI_SUCCESS Incoming or outgoing data was processed.
249 @retval EFI_INVALID_PARAMETER This is NULL.
250 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
251 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
252
253 **/
254 typedef
255 EFI_STATUS
256 (EFIAPI *EFI_UDP4_POLL)(
257 IN EFI_UDP4_PROTOCOL *This
258 );
259
260 /**
261 Places an asynchronous receive request into the receiving queue.
262
263 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
264 @param Token Pointer to a token that is associated with the receive data
265 descriptor.
266
267 @retval EFI_SUCCESS The receive completion token was cached.
268 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.
269 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.)
270 is not finished yet.
271 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
272 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system
273 resources (usually memory).
274 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
275 @retval EFI_ACCESS_DENIED A receive completion token with the same Token.Event was already in
276 the receive queue.
277 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
278
279 **/
280 typedef
281 EFI_STATUS
282 (EFIAPI *EFI_UDP4_RECEIVE)(
283 IN EFI_UDP4_PROTOCOL *This,
284 IN EFI_UDP4_COMPLETION_TOKEN *Token
285 );
286
287 /**
288 Queues outgoing data packets into the transmit queue.
289
290 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
291 @param Token Pointer to the completion token that will be placed into the
292 transmit queue.
293
294 @retval EFI_SUCCESS The data has been queued for transmission.
295 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.
296 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
297 RARP, etc.) is not finished yet.
298 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
299 @retval EFI_ACCESS_DENIED The transmit completion token with the same
300 Token.Event was already in the transmit queue.
301 @retval EFI_NOT_READY The completion token could not be queued because the
302 transmit queue is full.
303 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
304 @retval EFI_NOT_FOUND There is no route to the destination network or address.
305 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP packet
306 size. Or the length of the IP header + UDP header + data
307 length is greater than MTU if DoNotFragment is TRUE.
308
309 **/
310 typedef
311 EFI_STATUS
312 (EFIAPI *EFI_UDP4_TRANSMIT)(
313 IN EFI_UDP4_PROTOCOL *This,
314 IN EFI_UDP4_COMPLETION_TOKEN *Token
315 );
316
317 /**
318 Aborts an asynchronous transmit or receive request.
319
320 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
321 @param Token Pointer to a token that has been issued by
322 EFI_UDP4_PROTOCOL.Transmit() or
323 EFI_UDP4_PROTOCOL.Receive().If NULL, all pending
324 tokens are aborted.
325
326 @retval EFI_SUCCESS The asynchronous I/O request was aborted and Token.Event
327 was signaled. When Token is NULL, all pending requests are
328 aborted and their events are signaled.
329 @retval EFI_INVALID_PARAMETER This is NULL.
330 @retval EFI_NOT_STARTED This instance has not been started.
331 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
332 RARP, etc.) is not finished yet.
333 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was
334 not found in the transmit or receive queue. It has either completed
335 or was not issued by Transmit() and Receive().
336
337 **/
338 typedef
339 EFI_STATUS
340 (EFIAPI *EFI_UDP4_CANCEL)(
341 IN EFI_UDP4_PROTOCOL *This,
342 IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL
343 );
344
345 ///
346 /// The EFI_UDP4_PROTOCOL defines an EFI UDPv4 Protocol session that can be used
347 /// by any network drivers, applications, or daemons to transmit or receive UDP packets.
348 /// This protocol instance can either be bound to a specified port as a service or
349 /// connected to some remote peer as an active client. Each instance has its own settings,
350 /// such as the routing table and group table, which are independent from each other.
351 ///
352 struct _EFI_UDP4_PROTOCOL {
353 EFI_UDP4_GET_MODE_DATA GetModeData;
354 EFI_UDP4_CONFIGURE Configure;
355 EFI_UDP4_GROUPS Groups;
356 EFI_UDP4_ROUTES Routes;
357 EFI_UDP4_TRANSMIT Transmit;
358 EFI_UDP4_RECEIVE Receive;
359 EFI_UDP4_CANCEL Cancel;
360 EFI_UDP4_POLL Poll;
361 };
362
363 extern EFI_GUID gEfiUdp4ServiceBindingProtocolGuid;
364 extern EFI_GUID gEfiUdp4ProtocolGuid;
365
366 #endif