Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Arp.h 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. /** @file
  2. EFI ARP Protocol Definition
  3. The EFI ARP Service Binding Protocol is used to locate EFI
  4. ARP Protocol drivers to create and destroy child of the
  5. driver to communicate with other host using ARP protocol.
  6. The EFI ARP Protocol provides services to map IP network
  7. address to hardware address used by a data link protocol.
  8. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
  9. This program and the accompanying materials are licensed and made available under
  10. the terms and conditions of the BSD License that accompanies this distribution.
  11. The full text of the license may be found at
  12. http://opensource.org/licenses/bsd-license.php.
  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. @par Revision Reference:
  16. This Protocol was introduced in UEFI Specification 2.0.
  17. **/
  18. #ifndef __EFI_ARP_PROTOCOL_H__
  19. #define __EFI_ARP_PROTOCOL_H__
  20. FILE_LICENCE ( BSD3 );
  21. #define EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID \
  22. { \
  23. 0xf44c00ee, 0x1f2c, 0x4a00, {0xaa, 0x9, 0x1c, 0x9f, 0x3e, 0x8, 0x0, 0xa3 } \
  24. }
  25. #define EFI_ARP_PROTOCOL_GUID \
  26. { \
  27. 0xf4b427bb, 0xba21, 0x4f16, {0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } \
  28. }
  29. typedef struct _EFI_ARP_PROTOCOL EFI_ARP_PROTOCOL;
  30. typedef struct {
  31. ///
  32. /// Length in bytes of this entry.
  33. ///
  34. UINT32 Size;
  35. ///
  36. /// Set to TRUE if this entry is a "deny" entry.
  37. /// Set to FALSE if this entry is a "normal" entry.
  38. ///
  39. BOOLEAN DenyFlag;
  40. ///
  41. /// Set to TRUE if this entry will not time out.
  42. /// Set to FALSE if this entry will time out.
  43. ///
  44. BOOLEAN StaticFlag;
  45. ///
  46. /// 16-bit ARP hardware identifier number.
  47. ///
  48. UINT16 HwAddressType;
  49. ///
  50. /// 16-bit protocol type number.
  51. ///
  52. UINT16 SwAddressType;
  53. ///
  54. /// The length of the hardware address.
  55. ///
  56. UINT8 HwAddressLength;
  57. ///
  58. /// The length of the protocol address.
  59. ///
  60. UINT8 SwAddressLength;
  61. } EFI_ARP_FIND_DATA;
  62. typedef struct {
  63. ///
  64. /// 16-bit protocol type number in host byte order.
  65. ///
  66. UINT16 SwAddressType;
  67. ///
  68. /// The length in bytes of the station's protocol address to register.
  69. ///
  70. UINT8 SwAddressLength;
  71. ///
  72. /// The pointer to the first byte of the protocol address to register. For
  73. /// example, if SwAddressType is 0x0800 (IP), then
  74. /// StationAddress points to the first byte of this station's IP
  75. /// address stored in network byte order.
  76. ///
  77. VOID *StationAddress;
  78. ///
  79. /// The timeout value in 100-ns units that is associated with each
  80. /// new dynamic ARP cache entry. If it is set to zero, the value is
  81. /// implementation-specific.
  82. ///
  83. UINT32 EntryTimeOut;
  84. ///
  85. /// The number of retries before a MAC address is resolved. If it is
  86. /// set to zero, the value is implementation-specific.
  87. ///
  88. UINT32 RetryCount;
  89. ///
  90. /// The timeout value in 100-ns units that is used to wait for the ARP
  91. /// reply packet or the timeout value between two retries. Set to zero
  92. /// to use implementation-specific value.
  93. ///
  94. UINT32 RetryTimeOut;
  95. } EFI_ARP_CONFIG_DATA;
  96. /**
  97. This function is used to assign a station address to the ARP cache for this instance
  98. of the ARP driver.
  99. Each ARP instance has one station address. The EFI_ARP_PROTOCOL driver will
  100. respond to ARP requests that match this registered station address. A call to
  101. this function with the ConfigData field set to NULL will reset this ARP instance.
  102. Once a protocol type and station address have been assigned to this ARP instance,
  103. all the following ARP functions will use this information. Attempting to change
  104. the protocol type or station address to a configured ARP instance will result in errors.
  105. @param This The pointer to the EFI_ARP_PROTOCOL instance.
  106. @param ConfigData The pointer to the EFI_ARP_CONFIG_DATA structure.
  107. @retval EFI_SUCCESS The new station address was successfully
  108. registered.
  109. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  110. * This is NULL.
  111. * SwAddressLength is zero when ConfigData is not NULL.
  112. * StationAddress is NULL when ConfigData is not NULL.
  113. @retval EFI_ACCESS_DENIED The SwAddressType, SwAddressLength, or
  114. StationAddress is different from the one that is
  115. already registered.
  116. @retval EFI_OUT_OF_RESOURCES Storage for the new StationAddress could not be
  117. allocated.
  118. **/
  119. typedef
  120. EFI_STATUS
  121. (EFIAPI *EFI_ARP_CONFIGURE)(
  122. IN EFI_ARP_PROTOCOL *This,
  123. IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL
  124. );
  125. /**
  126. This function is used to insert entries into the ARP cache.
  127. ARP cache entries are typically inserted and updated by network protocol drivers
  128. as network traffic is processed. Most ARP cache entries will time out and be
  129. deleted if the network traffic stops. ARP cache entries that were inserted
  130. by the Add() function may be static (will not time out) or dynamic (will time out).
  131. Default ARP cache timeout values are not covered in most network protocol
  132. specifications (although RFC 1122 comes pretty close) and will only be
  133. discussed in general terms in this specification. The timeout values that are
  134. used in the EFI Sample Implementation should be used only as a guideline.
  135. Final product implementations of the EFI network stack should be tuned for
  136. their expected network environments.
  137. @param This Pointer to the EFI_ARP_PROTOCOL instance.
  138. @param DenyFlag Set to TRUE if this entry is a deny entry. Set to
  139. FALSE if this entry is a normal entry.
  140. @param TargetSwAddress Pointer to a protocol address to add (or deny).
  141. May be set to NULL if DenyFlag is TRUE.
  142. @param TargetHwAddress Pointer to a hardware address to add (or deny).
  143. May be set to NULL if DenyFlag is TRUE.
  144. @param TimeoutValue Time in 100-ns units that this entry will remain
  145. in the ARP cache. A value of zero means that the
  146. entry is permanent. A nonzero value will override
  147. the one given by Configure() if the entry to be
  148. added is a dynamic entry.
  149. @param Overwrite If TRUE, the matching cache entry will be
  150. overwritten with the supplied parameters. If
  151. FALSE, EFI_ACCESS_DENIED is returned if the
  152. corresponding cache entry already exists.
  153. @retval EFI_SUCCESS The entry has been added or updated.
  154. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  155. * This is NULL.
  156. * DenyFlag is FALSE and TargetHwAddress is NULL.
  157. * DenyFlag is FALSE and TargetSwAddress is NULL.
  158. * TargetHwAddress is NULL and TargetSwAddress is NULL.
  159. * Neither TargetSwAddress nor TargetHwAddress are NULL when DenyFlag is
  160. TRUE.
  161. @retval EFI_OUT_OF_RESOURCES The new ARP cache entry could not be allocated.
  162. @retval EFI_ACCESS_DENIED The ARP cache entry already exists and Overwrite
  163. is not true.
  164. @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
  165. **/
  166. typedef
  167. EFI_STATUS
  168. (EFIAPI *EFI_ARP_ADD)(
  169. IN EFI_ARP_PROTOCOL *This,
  170. IN BOOLEAN DenyFlag,
  171. IN VOID *TargetSwAddress OPTIONAL,
  172. IN VOID *TargetHwAddress OPTIONAL,
  173. IN UINT32 TimeoutValue,
  174. IN BOOLEAN Overwrite
  175. );
  176. /**
  177. This function searches the ARP cache for matching entries and allocates a buffer into
  178. which those entries are copied.
  179. The first part of the allocated buffer is EFI_ARP_FIND_DATA, following which
  180. are protocol address pairs and hardware address pairs.
  181. When finding a specific protocol address (BySwAddress is TRUE and AddressBuffer
  182. is not NULL), the ARP cache timeout for the found entry is reset if Refresh is
  183. set to TRUE. If the found ARP cache entry is a permanent entry, it is not
  184. affected by Refresh.
  185. @param This The pointer to the EFI_ARP_PROTOCOL instance.
  186. @param BySwAddress Set to TRUE to look for matching software protocol
  187. addresses. Set to FALSE to look for matching
  188. hardware protocol addresses.
  189. @param AddressBuffer The pointer to the address buffer. Set to NULL
  190. to match all addresses.
  191. @param EntryLength The size of an entry in the entries buffer.
  192. @param EntryCount The number of ARP cache entries that are found by
  193. the specified criteria.
  194. @param Entries The pointer to the buffer that will receive the ARP
  195. cache entries.
  196. @param Refresh Set to TRUE to refresh the timeout value of the
  197. matching ARP cache entry.
  198. @retval EFI_SUCCESS The requested ARP cache entries were copied into
  199. the buffer.
  200. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  201. This is NULL. Both EntryCount and EntryLength are
  202. NULL, when Refresh is FALSE.
  203. @retval EFI_NOT_FOUND No matching entries were found.
  204. @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
  205. **/
  206. typedef
  207. EFI_STATUS
  208. (EFIAPI *EFI_ARP_FIND)(
  209. IN EFI_ARP_PROTOCOL *This,
  210. IN BOOLEAN BySwAddress,
  211. IN VOID *AddressBuffer OPTIONAL,
  212. OUT UINT32 *EntryLength OPTIONAL,
  213. OUT UINT32 *EntryCount OPTIONAL,
  214. OUT EFI_ARP_FIND_DATA **Entries OPTIONAL,
  215. IN BOOLEAN Refresh
  216. );
  217. /**
  218. This function removes specified ARP cache entries.
  219. @param This The pointer to the EFI_ARP_PROTOCOL instance.
  220. @param BySwAddress Set to TRUE to delete matching protocol addresses.
  221. Set to FALSE to delete matching hardware
  222. addresses.
  223. @param AddressBuffer The pointer to the address buffer that is used as a
  224. key to look for the cache entry. Set to NULL to
  225. delete all entries.
  226. @retval EFI_SUCCESS The entry was removed from the ARP cache.
  227. @retval EFI_INVALID_PARAMETER This is NULL.
  228. @retval EFI_NOT_FOUND The specified deletion key was not found.
  229. @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
  230. **/
  231. typedef
  232. EFI_STATUS
  233. (EFIAPI *EFI_ARP_DELETE)(
  234. IN EFI_ARP_PROTOCOL *This,
  235. IN BOOLEAN BySwAddress,
  236. IN VOID *AddressBuffer OPTIONAL
  237. );
  238. /**
  239. This function delete all dynamic entries from the ARP cache that match the specified
  240. software protocol type.
  241. @param This The pointer to the EFI_ARP_PROTOCOL instance.
  242. @retval EFI_SUCCESS The cache has been flushed.
  243. @retval EFI_INVALID_PARAMETER This is NULL.
  244. @retval EFI_NOT_FOUND There are no matching dynamic cache entries.
  245. @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
  246. **/
  247. typedef
  248. EFI_STATUS
  249. (EFIAPI *EFI_ARP_FLUSH)(
  250. IN EFI_ARP_PROTOCOL *This
  251. );
  252. /**
  253. This function tries to resolve the TargetSwAddress and optionally returns a
  254. TargetHwAddress if it already exists in the ARP cache.
  255. @param This The pointer to the EFI_ARP_PROTOCOL instance.
  256. @param TargetSwAddress The pointer to the protocol address to resolve.
  257. @param ResolvedEvent The pointer to the event that will be signaled when
  258. the address is resolved or some error occurs.
  259. @param TargetHwAddress The pointer to the buffer for the resolved hardware
  260. address in network byte order.
  261. @retval EFI_SUCCESS The data is copied from the ARP cache into the
  262. TargetHwAddress buffer.
  263. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  264. This is NULL. TargetHwAddress is NULL.
  265. @retval EFI_ACCESS_DENIED The requested address is not present in the normal
  266. ARP cache but is present in the deny address list.
  267. Outgoing traffic to that address is forbidden.
  268. @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
  269. @retval EFI_NOT_READY The request has been started and is not finished.
  270. **/
  271. typedef
  272. EFI_STATUS
  273. (EFIAPI *EFI_ARP_REQUEST)(
  274. IN EFI_ARP_PROTOCOL *This,
  275. IN VOID *TargetSwAddress OPTIONAL,
  276. IN EFI_EVENT ResolvedEvent OPTIONAL,
  277. OUT VOID *TargetHwAddress
  278. );
  279. /**
  280. This function aborts the previous ARP request (identified by This, TargetSwAddress
  281. and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request().
  282. If the request is in the internal ARP request queue, the request is aborted
  283. immediately and its ResolvedEvent is signaled. Only an asynchronous address
  284. request needs to be canceled. If TargeSwAddress and ResolveEvent are both
  285. NULL, all the pending asynchronous requests that have been issued by This
  286. instance will be cancelled and their corresponding events will be signaled.
  287. @param This The pointer to the EFI_ARP_PROTOCOL instance.
  288. @param TargetSwAddress The pointer to the protocol address in previous
  289. request session.
  290. @param ResolvedEvent Pointer to the event that is used as the
  291. notification event in previous request session.
  292. @retval EFI_SUCCESS The pending request session(s) is/are aborted and
  293. corresponding event(s) is/are signaled.
  294. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  295. This is NULL. TargetSwAddress is not NULL and
  296. ResolvedEvent is NULL. TargetSwAddress is NULL and
  297. ResolvedEvent is not NULL.
  298. @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
  299. @retval EFI_NOT_FOUND The request is not issued by
  300. EFI_ARP_PROTOCOL.Request().
  301. **/
  302. typedef
  303. EFI_STATUS
  304. (EFIAPI *EFI_ARP_CANCEL)(
  305. IN EFI_ARP_PROTOCOL *This,
  306. IN VOID *TargetSwAddress OPTIONAL,
  307. IN EFI_EVENT ResolvedEvent OPTIONAL
  308. );
  309. ///
  310. /// ARP is used to resolve local network protocol addresses into
  311. /// network hardware addresses.
  312. ///
  313. struct _EFI_ARP_PROTOCOL {
  314. EFI_ARP_CONFIGURE Configure;
  315. EFI_ARP_ADD Add;
  316. EFI_ARP_FIND Find;
  317. EFI_ARP_DELETE Delete;
  318. EFI_ARP_FLUSH Flush;
  319. EFI_ARP_REQUEST Request;
  320. EFI_ARP_CANCEL Cancel;
  321. };
  322. extern EFI_GUID gEfiArpServiceBindingProtocolGuid;
  323. extern EFI_GUID gEfiArpProtocolGuid;
  324. #endif