iPXE
Arp.h
Go to the documentation of this file.
00001 /** @file
00002   EFI ARP Protocol Definition
00003 
00004   The EFI ARP Service Binding Protocol is used to locate EFI
00005   ARP Protocol drivers to create and destroy child of the
00006   driver to communicate with other host using ARP protocol.
00007   The EFI ARP Protocol provides services to map IP network
00008   address to hardware address used by a data link protocol.
00009 
00010 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
00011 This program and the accompanying materials are licensed and made available under
00012 the terms and conditions of the BSD License that accompanies this distribution.
00013 The full text of the license may be found at
00014 http://opensource.org/licenses/bsd-license.php.
00015 
00016 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00017 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00018 
00019   @par Revision Reference:
00020   This Protocol was introduced in UEFI Specification 2.0.
00021 
00022 **/
00023 
00024 #ifndef __EFI_ARP_PROTOCOL_H__
00025 #define __EFI_ARP_PROTOCOL_H__
00026 
00027 FILE_LICENCE ( BSD3 );
00028 
00029 #define EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID \
00030   { \
00031     0xf44c00ee, 0x1f2c, 0x4a00, {0xaa, 0x9, 0x1c, 0x9f, 0x3e, 0x8, 0x0, 0xa3 } \
00032   }
00033 
00034 #define EFI_ARP_PROTOCOL_GUID \
00035   { \
00036     0xf4b427bb, 0xba21, 0x4f16, {0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } \
00037   }
00038 
00039 typedef struct _EFI_ARP_PROTOCOL EFI_ARP_PROTOCOL;
00040 
00041 typedef struct {
00042   ///
00043   /// Length in bytes of this entry.
00044   ///
00045   UINT32                      Size;
00046 
00047   ///
00048   /// Set to TRUE if this entry is a "deny" entry.
00049   /// Set to FALSE if this entry is a "normal" entry.
00050   ///
00051   BOOLEAN                     DenyFlag;
00052 
00053   ///
00054   /// Set to TRUE if this entry will not time out.
00055   /// Set to FALSE if this entry will time out.
00056   ///
00057   BOOLEAN                     StaticFlag;
00058 
00059   ///
00060   /// 16-bit ARP hardware identifier number.
00061   ///
00062   UINT16                      HwAddressType;
00063 
00064   ///
00065   /// 16-bit protocol type number.
00066   ///
00067   UINT16                      SwAddressType;
00068 
00069   ///
00070   /// The length of the hardware address.
00071   ///
00072   UINT8                       HwAddressLength;
00073 
00074   ///
00075   /// The length of the protocol address.
00076   ///
00077   UINT8                       SwAddressLength;
00078 } EFI_ARP_FIND_DATA;
00079 
00080 typedef struct {
00081   ///
00082   /// 16-bit protocol type number in host byte order.
00083   ///
00084   UINT16                    SwAddressType;
00085 
00086   ///
00087   /// The length in bytes of the station's protocol address to register.
00088   ///
00089   UINT8                     SwAddressLength;
00090 
00091   ///
00092   /// The pointer to the first byte of the protocol address to register. For
00093   /// example, if SwAddressType is 0x0800 (IP), then
00094   /// StationAddress points to the first byte of this station's IP
00095   /// address stored in network byte order.
00096   ///
00097   VOID                      *StationAddress;
00098 
00099   ///
00100   /// The timeout value in 100-ns units that is associated with each
00101   /// new dynamic ARP cache entry. If it is set to zero, the value is
00102   /// implementation-specific.
00103   ///
00104   UINT32                    EntryTimeOut;
00105 
00106   ///
00107   /// The number of retries before a MAC address is resolved. If it is
00108   /// set to zero, the value is implementation-specific.
00109   ///
00110   UINT32                    RetryCount;
00111 
00112   ///
00113   /// The timeout value in 100-ns units that is used to wait for the ARP
00114   /// reply packet or the timeout value between two retries. Set to zero
00115   /// to use implementation-specific value.
00116   ///
00117   UINT32                    RetryTimeOut;
00118 } EFI_ARP_CONFIG_DATA;
00119 
00120 
00121 /**
00122   This function is used to assign a station address to the ARP cache for this instance
00123   of the ARP driver.
00124 
00125   Each ARP instance has one station address. The EFI_ARP_PROTOCOL driver will
00126   respond to ARP requests that match this registered station address. A call to
00127   this function with the ConfigData field set to NULL will reset this ARP instance.
00128 
00129   Once a protocol type and station address have been assigned to this ARP instance,
00130   all the following ARP functions will use this information. Attempting to change
00131   the protocol type or station address to a configured ARP instance will result in errors.
00132 
00133   @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
00134   @param  ConfigData             The pointer to the EFI_ARP_CONFIG_DATA structure.
00135 
00136   @retval EFI_SUCCESS            The new station address was successfully
00137                                  registered.
00138   @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
00139                                  * This is NULL.
00140                                  * SwAddressLength is zero when ConfigData is not NULL.
00141                                  * StationAddress is NULL when ConfigData is not NULL.
00142   @retval EFI_ACCESS_DENIED      The SwAddressType, SwAddressLength, or
00143                                  StationAddress is different from the one that is
00144                                  already registered.
00145   @retval EFI_OUT_OF_RESOURCES   Storage for the new StationAddress could not be
00146                                  allocated.
00147 
00148 **/
00149 typedef
00150 EFI_STATUS
00151 (EFIAPI *EFI_ARP_CONFIGURE)(
00152   IN EFI_ARP_PROTOCOL       *This,
00153   IN EFI_ARP_CONFIG_DATA    *ConfigData   OPTIONAL
00154   );
00155 
00156 /**
00157   This function is used to insert entries into the ARP cache.
00158 
00159   ARP cache entries are typically inserted and updated by network protocol drivers
00160   as network traffic is processed. Most ARP cache entries will time out and be
00161   deleted if the network traffic stops. ARP cache entries that were inserted
00162   by the Add() function may be static (will not time out) or dynamic (will time out).
00163   Default ARP cache timeout values are not covered in most network protocol
00164   specifications (although RFC 1122 comes pretty close) and will only be
00165   discussed in general terms in this specification. The timeout values that are
00166   used in the EFI Sample Implementation should be used only as a guideline.
00167   Final product implementations of the EFI network stack should be tuned for
00168   their expected network environments.
00169 
00170   @param  This                   Pointer to the EFI_ARP_PROTOCOL instance.
00171   @param  DenyFlag               Set to TRUE if this entry is a deny entry. Set to
00172                                  FALSE if this  entry is a normal entry.
00173   @param  TargetSwAddress        Pointer to a protocol address to add (or deny).
00174                                  May be set to NULL if DenyFlag is TRUE.
00175   @param  TargetHwAddress        Pointer to a hardware address to add (or deny).
00176                                  May be set to NULL if DenyFlag is TRUE.
00177   @param  TimeoutValue           Time in 100-ns units that this entry will remain
00178                                  in the ARP cache. A value of zero means that the
00179                                  entry is permanent. A nonzero value will override
00180                                  the one given by Configure() if the entry to be
00181                                  added is a dynamic entry.
00182   @param  Overwrite              If TRUE, the matching cache entry will be
00183                                  overwritten with the supplied parameters. If
00184                                  FALSE, EFI_ACCESS_DENIED is returned if the
00185                                  corresponding cache entry already exists.
00186 
00187   @retval EFI_SUCCESS            The entry has been added or updated.
00188   @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
00189                                  * This is NULL.
00190                                  * DenyFlag is FALSE and TargetHwAddress is NULL.
00191                                  * DenyFlag is FALSE and TargetSwAddress is NULL.
00192                                  * TargetHwAddress is NULL and TargetSwAddress is NULL.
00193                                  * Neither TargetSwAddress nor TargetHwAddress are NULL when DenyFlag is
00194                                  TRUE.
00195   @retval EFI_OUT_OF_RESOURCES   The new ARP cache entry could not be allocated.
00196   @retval EFI_ACCESS_DENIED      The ARP cache entry already exists and Overwrite
00197                                  is not true.
00198   @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
00199 
00200 **/
00201 typedef
00202 EFI_STATUS
00203 (EFIAPI *EFI_ARP_ADD)(
00204   IN EFI_ARP_PROTOCOL       *This,
00205   IN BOOLEAN                DenyFlag,
00206   IN VOID                   *TargetSwAddress  OPTIONAL,
00207   IN VOID                   *TargetHwAddress  OPTIONAL,
00208   IN UINT32                 TimeoutValue,
00209   IN BOOLEAN                Overwrite
00210   );
00211 
00212 /**
00213   This function searches the ARP cache for matching entries and allocates a buffer into
00214   which those entries are copied.
00215 
00216   The first part of the allocated buffer is EFI_ARP_FIND_DATA, following which
00217   are protocol address pairs and hardware address pairs.
00218   When finding a specific protocol address (BySwAddress is TRUE and AddressBuffer
00219   is not NULL), the ARP cache timeout for the found entry is reset if Refresh is
00220   set to TRUE. If the found ARP cache entry is a permanent entry, it is not
00221   affected by Refresh.
00222 
00223   @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
00224   @param  BySwAddress            Set to TRUE to look for matching software protocol
00225                                  addresses. Set to FALSE to look for matching
00226                                  hardware protocol addresses.
00227   @param  AddressBuffer          The pointer to the address buffer. Set to NULL
00228                                  to match all addresses.
00229   @param  EntryLength            The size of an entry in the entries buffer.
00230   @param  EntryCount             The number of ARP cache entries that are found by
00231                                  the specified criteria.
00232   @param  Entries                The pointer to the buffer that will receive the ARP
00233                                  cache entries.
00234   @param  Refresh                Set to TRUE to refresh the timeout value of the
00235                                  matching ARP cache entry.
00236 
00237   @retval EFI_SUCCESS            The requested ARP cache entries were copied into
00238                                  the buffer.
00239   @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
00240                                  This is NULL. Both EntryCount and EntryLength are
00241                                  NULL, when Refresh is FALSE.
00242   @retval EFI_NOT_FOUND          No matching entries were found.
00243   @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
00244 
00245 **/
00246 typedef
00247 EFI_STATUS
00248 (EFIAPI *EFI_ARP_FIND)(
00249   IN EFI_ARP_PROTOCOL       *This,
00250   IN BOOLEAN                BySwAddress,
00251   IN VOID                   *AddressBuffer    OPTIONAL,
00252   OUT UINT32                *EntryLength      OPTIONAL,
00253   OUT UINT32                *EntryCount       OPTIONAL,
00254   OUT EFI_ARP_FIND_DATA     **Entries         OPTIONAL,
00255   IN BOOLEAN                Refresh
00256   );
00257 
00258 
00259 /**
00260   This function removes specified ARP cache entries.
00261 
00262   @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
00263   @param  BySwAddress            Set to TRUE to delete matching protocol addresses.
00264                                  Set to FALSE to delete matching hardware
00265                                  addresses.
00266   @param  AddressBuffer          The pointer to the address buffer that is used as a
00267                                  key to look for the cache entry. Set to NULL to
00268                                  delete all entries.
00269 
00270   @retval EFI_SUCCESS            The entry was removed from the ARP cache.
00271   @retval EFI_INVALID_PARAMETER  This is NULL.
00272   @retval EFI_NOT_FOUND          The specified deletion key was not found.
00273   @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
00274 
00275 **/
00276 typedef
00277 EFI_STATUS
00278 (EFIAPI *EFI_ARP_DELETE)(
00279   IN EFI_ARP_PROTOCOL       *This,
00280   IN BOOLEAN                BySwAddress,
00281   IN VOID                   *AddressBuffer   OPTIONAL
00282   );
00283 
00284 /**
00285   This function delete all dynamic entries from the ARP cache that match the specified
00286   software protocol type.
00287 
00288   @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
00289 
00290   @retval EFI_SUCCESS            The cache has been flushed.
00291   @retval EFI_INVALID_PARAMETER  This is NULL.
00292   @retval EFI_NOT_FOUND          There are no matching dynamic cache entries.
00293   @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
00294 
00295 **/
00296 typedef
00297 EFI_STATUS
00298 (EFIAPI *EFI_ARP_FLUSH)(
00299   IN EFI_ARP_PROTOCOL       *This
00300   );
00301 
00302 /**
00303   This function tries to resolve the TargetSwAddress and optionally returns a
00304   TargetHwAddress if it already exists in the ARP cache.
00305 
00306   @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
00307   @param  TargetSwAddress        The pointer to the protocol address to resolve.
00308   @param  ResolvedEvent          The pointer to the event that will be signaled when
00309                                  the address is resolved or some error occurs.
00310   @param  TargetHwAddress        The pointer to the buffer for the resolved hardware
00311                                  address in network byte order.
00312 
00313   @retval EFI_SUCCESS            The data is copied from the ARP cache into the
00314                                  TargetHwAddress buffer.
00315   @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
00316                                  This is NULL. TargetHwAddress is NULL.
00317   @retval EFI_ACCESS_DENIED      The requested address is not present in the normal
00318                                  ARP cache but is present in the deny address list.
00319                                  Outgoing traffic to that address is forbidden.
00320   @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
00321   @retval EFI_NOT_READY          The request has been started and is not finished.
00322 
00323 **/
00324 typedef
00325 EFI_STATUS
00326 (EFIAPI *EFI_ARP_REQUEST)(
00327   IN EFI_ARP_PROTOCOL       *This,
00328   IN VOID                   *TargetSwAddress  OPTIONAL,
00329   IN EFI_EVENT              ResolvedEvent     OPTIONAL,
00330   OUT VOID                  *TargetHwAddress
00331   );
00332 
00333 /**
00334   This function aborts the previous ARP request (identified by This, TargetSwAddress
00335   and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request().
00336 
00337   If the request is in the internal ARP request queue, the request is aborted
00338   immediately and its ResolvedEvent is signaled. Only an asynchronous address
00339   request needs to be canceled. If TargeSwAddress and ResolveEvent are both
00340   NULL, all the pending asynchronous requests that have been issued by This
00341   instance will be cancelled and their corresponding events will be signaled.
00342 
00343   @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
00344   @param  TargetSwAddress        The pointer to the protocol address in previous
00345                                  request session.
00346   @param  ResolvedEvent          Pointer to the event that is used as the
00347                                  notification event in previous request session.
00348 
00349   @retval EFI_SUCCESS            The pending request session(s) is/are aborted and
00350                                  corresponding event(s) is/are signaled.
00351   @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
00352                                  This is NULL. TargetSwAddress is not NULL and
00353                                  ResolvedEvent is NULL. TargetSwAddress is NULL and
00354                                  ResolvedEvent is not NULL.
00355   @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
00356   @retval EFI_NOT_FOUND          The request is not issued by
00357                                  EFI_ARP_PROTOCOL.Request().
00358 
00359 
00360 **/
00361 typedef
00362 EFI_STATUS
00363 (EFIAPI *EFI_ARP_CANCEL)(
00364   IN EFI_ARP_PROTOCOL       *This,
00365   IN VOID                   *TargetSwAddress  OPTIONAL,
00366   IN EFI_EVENT              ResolvedEvent     OPTIONAL
00367   );
00368 
00369 ///
00370 /// ARP is used to resolve local network protocol addresses into
00371 /// network hardware addresses.
00372 ///
00373 struct _EFI_ARP_PROTOCOL {
00374   EFI_ARP_CONFIGURE         Configure;
00375   EFI_ARP_ADD               Add;
00376   EFI_ARP_FIND              Find;
00377   EFI_ARP_DELETE            Delete;
00378   EFI_ARP_FLUSH             Flush;
00379   EFI_ARP_REQUEST           Request;
00380   EFI_ARP_CANCEL            Cancel;
00381 };
00382 
00383 
00384 extern EFI_GUID gEfiArpServiceBindingProtocolGuid;
00385 extern EFI_GUID gEfiArpProtocolGuid;
00386 
00387 #endif