]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Udp4.h
Code Scrub for Protocol and Ppi Definition
[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 /**
153 Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4
154 Protocol.
155
156 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
157 @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.
158
159 @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully.
160 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
161 RARP, etc.) is not finished yet.
162 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
163 @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured
164 and must be stopped/reset before it can be reconfigured.
165 @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE
166 and UdpConfigData.StationPort is already used by
167 other instance.
168 @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this
169 EFI UDPv4 Protocol instance.
170 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance
171 was not opened.
172
173 **/
174 typedef
175 EFI_STATUS
176 (EFIAPI *EFI_UDP4_CONFIGURE)(
177 IN EFI_UDP4_PROTOCOL *This,
178 IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL
179 )
180 ;
181
182 /**
183 Joins and leaves multicast groups.
184
185 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
186 @param JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one
187 or all multicast groups.
188 @param MulticastAddress Pointer to multicast group address to join or leave.
189
190 @retval EFI_SUCCESS The operation completed successfully.
191 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.
192 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
193 RARP, etc.) is not finished yet.
194 @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group.
195 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
196 - This is NULL.
197 - JoinFlag is TRUE and MulticastAddress is NULL.
198 - JoinFlag is TRUE and *MulticastAddress is not
199 a valid multicast address.
200 @retval EFI_ALREADY_STARTED The group address is already in the group table (when
201 JoinFlag is TRUE).
202 @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is
203 FALSE).
204 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
205
206 **/
207 typedef
208 EFI_STATUS
209 (EFIAPI *EFI_UDP4_GROUPS)(
210 IN EFI_UDP4_PROTOCOL *This,
211 IN BOOLEAN JoinFlag,
212 IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL
213 )
214 ;
215
216 /**
217 Adds and deletes routing table entries.
218
219 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
220 @param DeleteRoute Set to TRUE to delete this route from the routing table.
221 Set to FALSE to add this route to the routing table.
222 @param SubnetAddress The destination network address that needs to be routed.
223 @param SubnetMask The subnet mask of SubnetAddress.
224 @param GatewayAddress The gateway IP address for this route.
225
226 @retval EFI_SUCCESS The operation completed successfully.
227 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.
228 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
229 - RARP, etc.) is not finished yet.
230 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
231 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
232 @retval EFI_NOT_FOUND This route is not in the routing table.
233 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.
234
235 **/
236 typedef
237 EFI_STATUS
238 (EFIAPI *EFI_UDP4_ROUTES)(
239 IN EFI_UDP4_PROTOCOL *This,
240 IN BOOLEAN DeleteRoute,
241 IN EFI_IPv4_ADDRESS *SubnetAddress,
242 IN EFI_IPv4_ADDRESS *SubnetMask,
243 IN EFI_IPv4_ADDRESS *GatewayAddress
244 )
245 ;
246
247 /**
248 Polls for incoming data packets and processes outgoing data packets.
249
250 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
251
252 @retval EFI_SUCCESS Incoming or outgoing data was processed.
253 @retval EFI_INVALID_PARAMETER This is NULL.
254 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
255 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
256
257 **/
258 typedef
259 EFI_STATUS
260 (EFIAPI *EFI_UDP4_POLL)(
261 IN EFI_UDP4_PROTOCOL *This
262 )
263 ;
264
265 /**
266 Places an asynchronous receive request into the receiving queue.
267
268 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
269 @param Token Pointer to a token that is associated with the receive data
270 descriptor.
271
272 @retval EFI_SUCCESS The receive completion token was cached.
273 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.
274 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.)
275 is not finished yet.
276 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
277 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system
278 resources (usually memory).
279 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
280 @retval EFI_ACCESS_DENIED A receive completion token with the same Token.Event was already in
281 the receive queue.
282 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
283
284 **/
285 typedef
286 EFI_STATUS
287 (EFIAPI *EFI_UDP4_RECEIVE)(
288 IN EFI_UDP4_PROTOCOL *This,
289 IN EFI_UDP4_COMPLETION_TOKEN *Token
290 )
291 ;
292
293 /**
294 Queues outgoing data packets into the transmit queue.
295
296 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
297 @param Token Pointer to the completion token that will be placed into the
298 transmit queue.
299
300 @retval EFI_SUCCESS The data has been queued for transmission.
301 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.
302 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
303 RARP, etc.) is not finished yet.
304 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
305 @retval EFI_ACCESS_DENIED The transmit completion token with the same
306 Token.Event was already in the transmit queue.
307 @retval EFI_NOT_READY The completion token could not be queued because the
308 transmit queue is full.
309 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
310 @retval EFI_NOT_FOUND There is no route to the destination network or address.
311 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP packet
312 size. Or the length of the IP header + UDP header + data
313 length is greater than MTU if DoNotFragment is TRUE.
314
315 **/
316 typedef
317 EFI_STATUS
318 (EFIAPI *EFI_UDP4_TRANSMIT)(
319 IN EFI_UDP4_PROTOCOL *This,
320 IN EFI_UDP4_COMPLETION_TOKEN *Token
321 )
322 ;
323
324 /**
325 Aborts an asynchronous transmit or receive request.
326
327 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
328 @param Token Pointer to a token that has been issued by
329 EFI_UDP4_PROTOCOL.Transmit() or
330 EFI_UDP4_PROTOCOL.Receive().If NULL, all pending
331 tokens are aborted.
332
333 @retval EFI_SUCCESS The asynchronous I/O request was aborted and Token.Event
334 was signaled. When Token is NULL, all pending requests are
335 aborted and their events are signaled.
336 @retval EFI_INVALID_PARAMETER This is NULL.
337 @retval EFI_NOT_STARTED This instance has not been started.
338 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
339 RARP, etc.) is not finished yet.
340 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was
341 not found in the transmit or receive queue. It has either completed
342 or was not issued by Transmit() and Receive().
343
344 **/
345 typedef
346 EFI_STATUS
347 (EFIAPI *EFI_UDP4_CANCEL)(
348 IN EFI_UDP4_PROTOCOL *This,
349 IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL
350 )
351 ;
352
353 /**
354 @par Protocol Description:
355 The EFI_UDP4_PROTOCOL defines an EFI UDPv4 Protocol session that can be used
356 by any network drivers, applications, or daemons to transmit or receive UDP packets.
357 This protocol instance can either be bound to a specified port as a service or
358 connected to some remote peer as an active client. Each instance has its own settings,
359 such as the routing table and group table, which are independent from each other.
360
361 @param GetModeData
362 Reads the current operational settings.
363
364 @param Configure
365 Initializes, changes, or resets operational settings for the EFI UDPv4 Protocol.
366
367 @param Groups
368 Joins and leaves multicast groups.
369
370 @param Routes
371 Add and deletes routing table entries.
372
373 @param Transmit
374 Queues outgoing data packets into the transmit queue. This function is a nonblocked operation.
375
376 @param Receive
377 Places a receiving request token into the receiving queue. This function is a nonblocked operation.
378
379 @param Cancel
380 Aborts a pending transmit or receive request.
381
382 @param Poll
383 Polls for incoming data packets and processes outgoing data packets.
384 **/
385 struct _EFI_UDP4_PROTOCOL {
386 EFI_UDP4_GET_MODE_DATA GetModeData;
387 EFI_UDP4_CONFIGURE Configure;
388 EFI_UDP4_GROUPS Groups;
389 EFI_UDP4_ROUTES Routes;
390 EFI_UDP4_TRANSMIT Transmit;
391 EFI_UDP4_RECEIVE Receive;
392 EFI_UDP4_CANCEL Cancel;
393 EFI_UDP4_POLL Poll;
394 };
395
396 extern EFI_GUID gEfiUdp4ServiceBindingProtocolGuid;
397 extern EFI_GUID gEfiUdp4ProtocolGuid;
398
399 #endif