00001 /** @file00002 UDP4 Service Binding Protocol as defined in UEFI specification.00003 00004 The EFI UDPv4 Protocol provides simple packet-oriented services00005 to transmit and receive UDP packets.00006 00007 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>00008 This program and the accompanying materials are licensed and made available under00009 the terms and conditions of the BSD License that accompanies this distribution.00010 The full text of the license may be found at00011 http://opensource.org/licenses/bsd-license.php.00012 00013 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,00014 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.00015 00016 @par Revision Reference:00017 This Protocol is introduced in UEFI Specification 2.0.00018 00019 **/00020
00021 #ifndef __EFI_UDP4_PROTOCOL_H__00022 #define __EFI_UDP4_PROTOCOL_H__00023 00024 FILE_LICENCE ( BSD3 );
00025
00026 #include <ipxe/efi/Protocol/Ip4.h>00027 //00028 //GUID definitions00029 //00030#define EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID \00031 { \00032 0x83f01464, 0x99bd, 0x45e5, {0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } \00033 }00034 00035#define EFI_UDP4_PROTOCOL_GUID \00036 { \00037 0x3ad9df29, 0x4501, 0x478d, {0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } \00038 }00039 00040typedefstruct _EFI_UDP4_PROTOCOLEFI_UDP4_PROTOCOL;
00041 00042 ///00043 /// EFI_UDP4_SERVICE_POINT is deprecated in the UEFI 2.4B and should not be used any more.00044 /// The definition in here is only present to provide backwards compatability.00045 ///00046typedefstruct {
00047EFI_HANDLEInstanceHandle;
00048EFI_IPv4_ADDRESSLocalAddress;
00049UINT16LocalPort;
00050EFI_IPv4_ADDRESSRemoteAddress;
00051UINT16RemotePort;
00052 } EFI_UDP4_SERVICE_POINT;
00053 00054 ///00055 /// EFI_UDP4_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.00056 /// The definition in here is only present to provide backwards compatability.00057 ///00058typedefstruct {
00059EFI_HANDLEDriverHandle;
00060UINT32ServiceCount;
00061EFI_UDP4_SERVICE_POINT Services[1];
00062 } EFI_UDP4_VARIABLE_DATA;
00063
00064typedefstruct {
00065UINT32FragmentLength;
00066VOID *FragmentBuffer;
00067 } EFI_UDP4_FRAGMENT_DATA;
00068
00069typedefstruct {
00070EFI_IPv4_ADDRESSSourceAddress;
00071UINT16SourcePort;
00072EFI_IPv4_ADDRESSDestinationAddress;
00073UINT16DestinationPort;
00074 } EFI_UDP4_SESSION_DATA;
00075typedefstruct {
00076 //00077 // Receiving Filters00078 //00079BOOLEANAcceptBroadcast;
00080BOOLEANAcceptPromiscuous;
00081BOOLEANAcceptAnyPort;
00082BOOLEANAllowDuplicatePort;
00083 //00084 // I/O parameters00085 //00086UINT8TypeOfService;
00087UINT8TimeToLive;
00088BOOLEANDoNotFragment;
00089UINT32ReceiveTimeout;
00090UINT32TransmitTimeout;
00091 //00092 // Access Point00093 //00094BOOLEANUseDefaultAddress;
00095EFI_IPv4_ADDRESSStationAddress;
00096EFI_IPv4_ADDRESSSubnetMask;
00097UINT16StationPort;
00098EFI_IPv4_ADDRESSRemoteAddress;
00099UINT16RemotePort;
00100 } EFI_UDP4_CONFIG_DATA;
00101
00102typedefstruct {
00103EFI_UDP4_SESSION_DATA *UdpSessionData; //OPTIONAL00104EFI_IPv4_ADDRESS *GatewayAddress; //OPTIONAL00105UINT32DataLength;
00106UINT32FragmentCount;
00107EFI_UDP4_FRAGMENT_DATA FragmentTable[1];
00108 } EFI_UDP4_TRANSMIT_DATA;
00109
00110typedefstruct {
00111EFI_TIMETimeStamp;
00112EFI_EVENTRecycleSignal;
00113EFI_UDP4_SESSION_DATAUdpSession;
00114UINT32DataLength;
00115UINT32FragmentCount;
00116EFI_UDP4_FRAGMENT_DATA FragmentTable[1];
00117 } EFI_UDP4_RECEIVE_DATA;
00118
00119
00120typedefstruct {
00121EFI_EVENTEvent;
00122EFI_STATUSStatus;
00123 union {
00124EFI_UDP4_RECEIVE_DATA *RxData;
00125EFI_UDP4_TRANSMIT_DATA *TxData;
00126 } Packet;
00127 } EFI_UDP4_COMPLETION_TOKEN;
00128 00129 /**00130 Reads the current operational settings.00131 00132 The GetModeData() function copies the current operational settings of this EFI00133 UDPv4 Protocol instance into user-supplied buffers. This function is used00134 optionally to retrieve the operational mode data of underlying networks or00135 drivers.00136 00137 @param This The pointer to the EFI_UDP4_PROTOCOL instance.00138 @param Udp4ConfigData The pointer to the buffer to receive the current configuration data.00139 @param Ip4ModeData The pointer to the EFI IPv4 Protocol mode data structure.00140 @param MnpConfigData The pointer to the managed network configuration data structure.00141 @param SnpModeData The pointer to the simple network mode data structure.00142 00143 @retval EFI_SUCCESS The mode data was read.00144 @retval EFI_NOT_STARTED When Udp4ConfigData is queried, no configuration data is00145 available because this instance has not been started.00146 @retval EFI_INVALID_PARAMETER This is NULL.00147 00148 **/00149 typedef00150 EFI_STATUS00151 (EFIAPI *EFI_UDP4_GET_MODE_DATA)(
00152 INEFI_UDP4_PROTOCOL *This,
00153 OUTEFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL,
00154 OUTEFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
00155 OUTEFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
00156 OUTEFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL00157 );
00158
00159 00160 /**00161 Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv400162 Protocol.00163 00164 The Configure() function is used to do the following:00165 * Initialize and start this instance of the EFI UDPv4 Protocol.00166 * Change the filtering rules and operational parameters.00167 * Reset this instance of the EFI UDPv4 Protocol.00168 Until these parameters are initialized, no network traffic can be sent or00169 received by this instance. This instance can be also reset by calling Configure()00170 with UdpConfigData set to NULL. Once reset, the receiving queue and transmitting00171 queue are flushed and no traffic is allowed through this instance.00172 With different parameters in UdpConfigData, Configure() can be used to bind00173 this instance to specified port.00174 00175 @param This The pointer to the EFI_UDP4_PROTOCOL instance.00176 @param Udp4ConfigData The pointer to the buffer to receive the current configuration data.00177 00178 @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully.00179 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,00180 RARP, etc.) is not finished yet.00181 @retval EFI_INVALID_PARAMETER This is NULL.00182 @retval EFI_INVALID_PARAMETER UdpConfigData.StationAddress is not a valid unicast IPv4 address.00183 @retval EFI_INVALID_PARAMETER UdpConfigData.SubnetMask is not a valid IPv4 address mask. The subnet00184 mask must be contiguous.00185 @retval EFI_INVALID_PARAMETER UdpConfigData.RemoteAddress is not a valid unicast IPv4 address if it00186 is not zero.00187 @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured00188 and must be stopped/reset before it can be reconfigured.00189 @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE00190 and UdpConfigData.StationPort is already used by00191 other instance.00192 @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this00193 EFI UDPv4 Protocol instance.00194 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance00195 was not opened.00196 00197 **/00198 typedef00199 EFI_STATUS00200 (EFIAPI *EFI_UDP4_CONFIGURE)(
00201 INEFI_UDP4_PROTOCOL *This,
00202 INEFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL00203 );
00204 00205 /**00206 Joins and leaves multicast groups.00207 00208 The Groups() function is used to enable and disable the multicast group00209 filtering. If the JoinFlag is FALSE and the MulticastAddress is NULL, then all00210 currently joined groups are left.00211 00212 @param This The pointer to the EFI_UDP4_PROTOCOL instance.00213 @param JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one00214 or all multicast groups.00215 @param MulticastAddress The pointer to multicast group address to join or leave.00216 00217 @retval EFI_SUCCESS The operation completed successfully.00218 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.00219 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,00220 RARP, etc.) is not finished yet.00221 @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group.00222 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:00223 - This is NULL.00224 - JoinFlag is TRUE and MulticastAddress is NULL.00225 - JoinFlag is TRUE and *MulticastAddress is not00226 a valid multicast address.00227 @retval EFI_ALREADY_STARTED The group address is already in the group table (when00228 JoinFlag is TRUE).00229 @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is00230 FALSE).00231 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.00232 00233 **/00234 typedef00235 EFI_STATUS00236 (EFIAPI *EFI_UDP4_GROUPS)(
00237 INEFI_UDP4_PROTOCOL *This,
00238 INBOOLEAN JoinFlag,
00239 INEFI_IPv4_ADDRESS *MulticastAddress OPTIONAL00240 );
00241 00242 /**00243 Adds and deletes routing table entries.00244 00245 The Routes() function adds a route to or deletes a route from the routing table.00246 Routes are determined by comparing the SubnetAddress with the destination IP00247 address and arithmetically AND-ing it with the SubnetMask. The gateway address00248 must be on the same subnet as the configured station address.00249 The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.00250 The default route matches all destination IP addresses that do not match any00251 other routes.00252 A zero GatewayAddress is a nonroute. Packets are sent to the destination IP00253 address if it can be found in the Address Resolution Protocol (ARP) cache or00254 on the local subnet. One automatic nonroute entry will be inserted into the00255 routing table for outgoing packets that are addressed to a local subnet00256 (gateway address of 0.0.0.0).00257 Each instance of the EFI UDPv4 Protocol has its own independent routing table.00258 Instances of the EFI UDPv4 Protocol that use the default IP address will also00259 have copies of the routing table provided by the EFI_IP4_CONFIG_PROTOCOL. These00260 copies will be updated automatically whenever the IP driver reconfigures its00261 instances; as a result, the previous modification to these copies will be lost.00262 00263 @param This The pointer to the EFI_UDP4_PROTOCOL instance.00264 @param DeleteRoute Set to TRUE to delete this route from the routing table.00265 Set to FALSE to add this route to the routing table.00266 @param SubnetAddress The destination network address that needs to be routed.00267 @param SubnetMask The subnet mask of SubnetAddress.00268 @param GatewayAddress The gateway IP address for this route.00269 00270 @retval EFI_SUCCESS The operation completed successfully.00271 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.00272 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,00273 - RARP, etc.) is not finished yet.00274 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.00275 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.00276 @retval EFI_NOT_FOUND This route is not in the routing table.00277 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.00278 00279 **/00280 typedef00281 EFI_STATUS00282 (EFIAPI *EFI_UDP4_ROUTES)(
00283 INEFI_UDP4_PROTOCOL *This,
00284 INBOOLEAN DeleteRoute,
00285 INEFI_IPv4_ADDRESS *SubnetAddress,
00286 INEFI_IPv4_ADDRESS *SubnetMask,
00287 INEFI_IPv4_ADDRESS *GatewayAddress
00288 );
00289 00290 /**00291 Polls for incoming data packets and processes outgoing data packets.00292 00293 The Poll() function can be used by network drivers and applications to increase00294 the rate that data packets are moved between the communications device and the00295 transmit and receive queues.00296 In some systems, the periodic timer event in the managed network driver may not00297 poll the underlying communications device fast enough to transmit and/or receive00298 all data packets without missing incoming packets or dropping outgoing packets.00299 Drivers and applications that are experiencing packet loss should try calling00300 the Poll() function more often.00301 00302 @param This The pointer to the EFI_UDP4_PROTOCOL instance.00303 00304 @retval EFI_SUCCESS Incoming or outgoing data was processed.00305 @retval EFI_INVALID_PARAMETER This is NULL.00306 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.00307 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.00308 00309 **/00310 typedef00311 EFI_STATUS00312 (EFIAPI *EFI_UDP4_POLL)(
00313 INEFI_UDP4_PROTOCOL *This
00314 );
00315 00316 /**00317 Places an asynchronous receive request into the receiving queue.00318 00319 The Receive() function places a completion token into the receive packet queue.00320 This function is always asynchronous.00321 The caller must fill in the Token.Event field in the completion token, and this00322 field cannot be NULL. When the receive operation completes, the EFI UDPv4 Protocol00323 driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event00324 is signaled. Providing a proper notification function and context for the event00325 will enable the user to receive the notification and receiving status. That00326 notification function is guaranteed to not be re-entered.00327 00328 @param This The pointer to the EFI_UDP4_PROTOCOL instance.00329 @param Token The pointer to a token that is associated with the receive data00330 descriptor.00331 00332 @retval EFI_SUCCESS The receive completion token was cached.00333 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.00334 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.)00335 is not finished yet.00336 @retval EFI_INVALID_PARAMETER This is NULL.00337 @retval EFI_INVALID_PARAMETER Token is NULL.00338 @retval EFI_INVALID_PARAMETER Token.Event is NULL.00339 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system00340 resources (usually memory).00341 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.00342 @retval EFI_ACCESS_DENIED A receive completion token with the same Token.Event was already in00343 the receive queue.00344 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.00345 00346 **/00347 typedef00348 EFI_STATUS00349 (EFIAPI *EFI_UDP4_RECEIVE)(
00350 INEFI_UDP4_PROTOCOL *This,
00351 INEFI_UDP4_COMPLETION_TOKEN *Token00352 );
00353 00354 /**00355 Queues outgoing data packets into the transmit queue.00356 00357 The Transmit() function places a sending request to this instance of the EFI00358 UDPv4 Protocol, alongside the transmit data that was filled by the user. Whenever00359 the packet in the token is sent out or some errors occur, the Token.Event will00360 be signaled and Token.Status is updated. Providing a proper notification function00361 and context for the event will enable the user to receive the notification and00362 transmitting status.00363 00364 @param This The pointer to the EFI_UDP4_PROTOCOL instance.00365 @param Token The pointer to the completion token that will be placed into the00366 transmit queue.00367 00368 @retval EFI_SUCCESS The data has been queued for transmission.00369 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.00370 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,00371 RARP, etc.) is not finished yet.00372 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.00373 @retval EFI_ACCESS_DENIED The transmit completion token with the same00374 Token.Event was already in the transmit queue.00375 @retval EFI_NOT_READY The completion token could not be queued because the00376 transmit queue is full.00377 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.00378 @retval EFI_NOT_FOUND There is no route to the destination network or address.00379 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP packet00380 size. Or the length of the IP header + UDP header + data00381 length is greater than MTU if DoNotFragment is TRUE.00382 00383 **/00384 typedef00385 EFI_STATUS00386 (EFIAPI *EFI_UDP4_TRANSMIT)(
00387 INEFI_UDP4_PROTOCOL *This,
00388 INEFI_UDP4_COMPLETION_TOKEN *Token00389 );
00390 00391 /**00392 Aborts an asynchronous transmit or receive request.00393 00394 The Cancel() function is used to abort a pending transmit or receive request.00395 If the token is in the transmit or receive request queues, after calling this00396 function, Token.Status will be set to EFI_ABORTED and then Token.Event will be00397 signaled. If the token is not in one of the queues, which usually means that00398 the asynchronous operation has completed, this function will not signal the00399 token and EFI_NOT_FOUND is returned.00400 00401 @param This The pointer to the EFI_UDP4_PROTOCOL instance.00402 @param Token The pointer to a token that has been issued by00403 EFI_UDP4_PROTOCOL.Transmit() or00404 EFI_UDP4_PROTOCOL.Receive().If NULL, all pending00405 tokens are aborted.00406 00407 @retval EFI_SUCCESS The asynchronous I/O request was aborted and Token.Event00408 was signaled. When Token is NULL, all pending requests are00409 aborted and their events are signaled.00410 @retval EFI_INVALID_PARAMETER This is NULL.00411 @retval EFI_NOT_STARTED This instance has not been started.00412 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,00413 RARP, etc.) is not finished yet.00414 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was00415 not found in the transmit or receive queue. It has either completed00416 or was not issued by Transmit() and Receive().00417 00418 **/00419 typedef00420 EFI_STATUS00421 (EFIAPI *EFI_UDP4_CANCEL)(
00422 INEFI_UDP4_PROTOCOL *This,
00423 INEFI_UDP4_COMPLETION_TOKEN *TokenOPTIONAL00424 );
00425 00426 ///00427 /// The EFI_UDP4_PROTOCOL defines an EFI UDPv4 Protocol session that can be used00428 /// by any network drivers, applications, or daemons to transmit or receive UDP packets.00429 /// This protocol instance can either be bound to a specified port as a service or00430 /// connected to some remote peer as an active client. Each instance has its own settings,00431 /// such as the routing table and group table, which are independent from each other.00432 ///00433struct _EFI_UDP4_PROTOCOL {
00434 EFI_UDP4_GET_MODE_DATA GetModeData;
00435 EFI_UDP4_CONFIGURE Configure;
00436 EFI_UDP4_GROUPS Groups;
00437 EFI_UDP4_ROUTES Routes;
00438 EFI_UDP4_TRANSMIT Transmit;
00439 EFI_UDP4_RECEIVE Receive;
00440 EFI_UDP4_CANCEL Cancel;
00441 EFI_UDP4_POLL Poll;
00442 };
00443
00444 externEFI_GUIDgEfiUdp4ServiceBindingProtocolGuid;
00445 externEFI_GUIDgEfiUdp4ProtocolGuid;
00446
00447 #endif