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