Ip6Impl.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. /** @file
  2. Implementation of EFI_IP6_PROTOCOL protocol interfaces and type definitions.
  3. Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
  4. (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef __EFI_IP6_IMPL_H__
  8. #define __EFI_IP6_IMPL_H__
  9. #include <Uefi.h>
  10. #include <IndustryStandard/Dhcp.h>
  11. #include <Protocol/ServiceBinding.h>
  12. #include <Protocol/ManagedNetwork.h>
  13. #include <Protocol/IpSec.h>
  14. #include <Protocol/Ip6.h>
  15. #include <Protocol/Ip6Config.h>
  16. #include <Protocol/Dhcp6.h>
  17. #include <Protocol/DevicePath.h>
  18. #include <Protocol/HiiConfigRouting.h>
  19. #include <Protocol/HiiConfigAccess.h>
  20. #include <Library/DebugLib.h>
  21. #include <Library/UefiBootServicesTableLib.h>
  22. #include <Library/UefiRuntimeServicesTableLib.h>
  23. #include <Library/BaseLib.h>
  24. #include <Library/UefiLib.h>
  25. #include <Library/NetLib.h>
  26. #include <Library/BaseMemoryLib.h>
  27. #include <Library/MemoryAllocationLib.h>
  28. #include <Library/DpcLib.h>
  29. #include <Library/HiiLib.h>
  30. #include <Library/UefiHiiServicesLib.h>
  31. #include <Library/DevicePathLib.h>
  32. #include <Library/PrintLib.h>
  33. #include <Guid/MdeModuleHii.h>
  34. #include "Ip6Common.h"
  35. #include "Ip6Driver.h"
  36. #include "Ip6Icmp.h"
  37. #include "Ip6If.h"
  38. #include "Ip6Input.h"
  39. #include "Ip6Mld.h"
  40. #include "Ip6Nd.h"
  41. #include "Ip6Option.h"
  42. #include "Ip6Output.h"
  43. #include "Ip6Route.h"
  44. #include "Ip6ConfigNv.h"
  45. #include "Ip6ConfigImpl.h"
  46. #define IP6_PROTOCOL_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'P')
  47. #define IP6_SERVICE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'S')
  48. //
  49. // The state of IP6 protocol. It starts from UNCONFIGED. if it is
  50. // successfully configured, it goes to CONFIGED. if configure NULL
  51. // is called, it becomes UNCONFIGED again. If (partly) destroyed, it
  52. // becomes DESTROY.
  53. //
  54. #define IP6_STATE_UNCONFIGED 0
  55. #define IP6_STATE_CONFIGED 1
  56. //
  57. // The state of IP6 service. It starts from UNSTARTED. It transits
  58. // to STARTED if autoconfigure is started. If default address is
  59. // configured, it becomes CONFIGED. and if partly destroyed, it goes
  60. // to DESTROY.
  61. //
  62. #define IP6_SERVICE_UNSTARTED 0
  63. #define IP6_SERVICE_STARTED 1
  64. #define IP6_SERVICE_CONFIGED 2
  65. #define IP6_SERVICE_DESTROY 3
  66. #define IP6_INSTANCE_FROM_PROTOCOL(Ip6) \
  67. CR ((Ip6), IP6_PROTOCOL, Ip6Proto, IP6_PROTOCOL_SIGNATURE)
  68. #define IP6_SERVICE_FROM_PROTOCOL(Sb) \
  69. CR ((Sb), IP6_SERVICE, ServiceBinding, IP6_SERVICE_SIGNATURE)
  70. #define IP6_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
  71. extern EFI_IPSEC2_PROTOCOL *mIpSec;
  72. extern BOOLEAN mIpSec2Installed;
  73. //
  74. // IP6_TXTOKEN_WRAP wraps the upper layer's transmit token.
  75. // The user's data is kept in the Packet. When fragment is
  76. // needed, each fragment of the Packet has a reference to the
  77. // Packet, no data is actually copied. The Packet will be
  78. // released when all the fragments of it have been recycled by
  79. // MNP. Upon then, the IP6_TXTOKEN_WRAP will be released, and
  80. // user's event signalled.
  81. //
  82. typedef struct {
  83. IP6_PROTOCOL *IpInstance;
  84. EFI_IP6_COMPLETION_TOKEN *Token;
  85. EFI_EVENT IpSecRecycleSignal;
  86. NET_BUF *Packet;
  87. BOOLEAN Sent;
  88. INTN Life;
  89. } IP6_TXTOKEN_WRAP;
  90. typedef struct {
  91. EFI_EVENT IpSecRecycleSignal;
  92. NET_BUF *Packet;
  93. } IP6_IPSEC_WRAP;
  94. //
  95. // IP6_RXDATA_WRAP wraps the data IP6 child delivers to the
  96. // upper layers. The received packet is kept in the Packet.
  97. // The Packet itself may be constructured from some fragments.
  98. // All the fragments of the Packet is organized by a
  99. // IP6_ASSEMBLE_ENTRY structure. If the Packet is recycled by
  100. // the upper layer, the assemble entry and its associated
  101. // fragments will be freed at last.
  102. //
  103. typedef struct {
  104. LIST_ENTRY Link;
  105. IP6_PROTOCOL *IpInstance;
  106. NET_BUF *Packet;
  107. EFI_IP6_RECEIVE_DATA RxData;
  108. } IP6_RXDATA_WRAP;
  109. struct _IP6_PROTOCOL {
  110. UINT32 Signature;
  111. EFI_IP6_PROTOCOL Ip6Proto;
  112. EFI_HANDLE Handle;
  113. INTN State;
  114. IP6_SERVICE *Service;
  115. LIST_ENTRY Link; // Link to all the IP protocol from the service
  116. UINT8 PrefixLength; // PrefixLength of the configured station address.
  117. //
  118. // User's transmit/receive tokens, and received/delivered packets
  119. //
  120. NET_MAP RxTokens;
  121. NET_MAP TxTokens; // map between (User's Token, IP6_TXTOKE_WRAP)
  122. LIST_ENTRY Received; // Received but not delivered packet
  123. LIST_ENTRY Delivered; // Delivered and to be recycled packets
  124. EFI_LOCK RecycleLock;
  125. IP6_INTERFACE *Interface;
  126. LIST_ENTRY AddrLink; // Ip instances with the same IP address.
  127. EFI_IPv6_ADDRESS *GroupList; // stored in network order.
  128. UINT32 GroupCount;
  129. EFI_IP6_CONFIG_DATA ConfigData;
  130. BOOLEAN InDestroy;
  131. };
  132. struct _IP6_SERVICE {
  133. UINT32 Signature;
  134. EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
  135. INTN State;
  136. //
  137. // List of all the IP instances and interfaces, and default
  138. // interface and route table and caches.
  139. //
  140. UINTN NumChildren;
  141. LIST_ENTRY Children;
  142. LIST_ENTRY Interfaces;
  143. IP6_INTERFACE *DefaultInterface;
  144. IP6_ROUTE_TABLE *RouteTable;
  145. IP6_LINK_RX_TOKEN RecvRequest;
  146. //
  147. // Ip reassemble utilities and MLD data
  148. //
  149. IP6_ASSEMBLE_TABLE Assemble;
  150. IP6_MLD_SERVICE_DATA MldCtrl;
  151. EFI_IPv6_ADDRESS LinkLocalAddr;
  152. BOOLEAN LinkLocalOk;
  153. BOOLEAN LinkLocalDadFail;
  154. BOOLEAN Dhcp6NeedStart;
  155. BOOLEAN Dhcp6NeedInfoRequest;
  156. //
  157. // ND data
  158. //
  159. UINT8 CurHopLimit;
  160. UINT32 LinkMTU;
  161. UINT32 BaseReachableTime;
  162. UINT32 ReachableTime;
  163. UINT32 RetransTimer;
  164. LIST_ENTRY NeighborTable;
  165. LIST_ENTRY OnlinkPrefix;
  166. LIST_ENTRY AutonomousPrefix;
  167. LIST_ENTRY DefaultRouterList;
  168. UINT32 RoundRobin;
  169. UINT8 InterfaceIdLen;
  170. UINT8 *InterfaceId;
  171. BOOLEAN RouterAdvertiseReceived;
  172. UINT8 SolicitTimer;
  173. UINT32 Ticks;
  174. //
  175. // Low level protocol used by this service instance
  176. //
  177. EFI_HANDLE Image;
  178. EFI_HANDLE Controller;
  179. EFI_HANDLE MnpChildHandle;
  180. EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
  181. EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
  182. EFI_SIMPLE_NETWORK_MODE SnpMode;
  183. EFI_EVENT Timer;
  184. EFI_EVENT FasterTimer;
  185. //
  186. // IPv6 Configuration Protocol instance
  187. //
  188. IP6_CONFIG_INSTANCE Ip6ConfigInstance;
  189. //
  190. // The string representation of the current mac address of the
  191. // NIC this IP6_SERVICE works on.
  192. //
  193. CHAR16 *MacString;
  194. UINT32 MaxPacketSize;
  195. UINT32 OldMaxPacketSize;
  196. };
  197. /**
  198. The callback function for the net buffer which wraps the user's
  199. transmit token. Although this function seems simple,
  200. there are some subtle aspects.
  201. When a user requests the IP to transmit a packet by passing it a
  202. token, the token is wrapped in an IP6_TXTOKEN_WRAP and the data
  203. is wrapped in a net buffer. The net buffer's Free function is
  204. set to Ip6FreeTxToken. The Token and token wrap are added to the
  205. IP child's TxToken map. Then the buffer is passed to Ip6Output for
  206. transmission. If an error occurs before that, the buffer
  207. is freed, which in turn frees the token wrap. The wrap may
  208. have been added to the TxToken map or not, and the user's event
  209. shouldn't be signaled because we are still in the EfiIp6Transmit. If
  210. the buffer has been sent by Ip6Output, it should be removed from
  211. the TxToken map and the user's event signaled. The token wrap and buffer
  212. are bound together. Refer to the comments in Ip6Output for information
  213. about IP fragmentation.
  214. @param[in] Context The token's wrap.
  215. **/
  216. VOID
  217. EFIAPI
  218. Ip6FreeTxToken (
  219. IN VOID *Context
  220. );
  221. /**
  222. Config the MNP parameter used by IP. The IP driver use one MNP
  223. child to transmit/receive frames. By default, it configures MNP
  224. to receive unicast/multicast/broadcast. And it will enable/disable
  225. the promiscuous receive according to whether there is IP child
  226. enable that or not. If Force is FALSE, it will iterate through
  227. all the IP children to check whether the promiscuous receive
  228. setting has been changed. If it hasn't been changed, it won't
  229. reconfigure the MNP. If Force is TRUE, the MNP is configured
  230. whether that is changed or not.
  231. @param[in] IpSb The IP6 service instance that is to be changed.
  232. @param[in] Force Force the configuration or not.
  233. @retval EFI_SUCCESS The MNP successfully configured/reconfigured.
  234. @retval Others The configuration failed.
  235. **/
  236. EFI_STATUS
  237. Ip6ServiceConfigMnp (
  238. IN IP6_SERVICE *IpSb,
  239. IN BOOLEAN Force
  240. );
  241. /**
  242. Cancel the user's receive/transmit request. It is the worker function of
  243. EfiIp6Cancel API.
  244. @param[in] IpInstance The IP6 child.
  245. @param[in] Token The token to cancel. If NULL, all tokens will be
  246. cancelled.
  247. @retval EFI_SUCCESS The token was cancelled.
  248. @retval EFI_NOT_FOUND The token isn't found on either the
  249. transmit or receive queue.
  250. @retval EFI_DEVICE_ERROR Not all tokens are cancelled when Token is NULL.
  251. **/
  252. EFI_STATUS
  253. Ip6Cancel (
  254. IN IP6_PROTOCOL *IpInstance,
  255. IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL
  256. );
  257. /**
  258. Initialize the IP6_PROTOCOL structure to the unconfigured states.
  259. @param[in] IpSb The IP6 service instance.
  260. @param[in, out] IpInstance The IP6 child instance.
  261. **/
  262. VOID
  263. Ip6InitProtocol (
  264. IN IP6_SERVICE *IpSb,
  265. IN OUT IP6_PROTOCOL *IpInstance
  266. );
  267. /**
  268. Clean up the IP6 child, release all the resources used by it.
  269. @param[in, out] IpInstance The IP6 child to clean up.
  270. @retval EFI_SUCCESS The IP6 child was cleaned up
  271. @retval EFI_DEVICE_ERROR Some resources failed to be released.
  272. **/
  273. EFI_STATUS
  274. Ip6CleanProtocol (
  275. IN OUT IP6_PROTOCOL *IpInstance
  276. );
  277. //
  278. // EFI_IP6_PROTOCOL interface prototypes
  279. //
  280. /**
  281. Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
  282. The GetModeData() function returns the current operational mode data for this driver instance.
  283. The data fields in EFI_IP6_MODE_DATA are read only. This function is used optionally to
  284. retrieve the operational mode data of underlying networks or drivers.
  285. @param[in] This The pointer to the EFI_IP6_PROTOCOL instance.
  286. @param[out] Ip6ModeData The pointer to the EFI IPv6 Protocol mode data structure.
  287. @param[out] MnpConfigData The pointer to the managed network configuration data structure.
  288. @param[out] SnpModeData The pointer to the simple network mode data structure.
  289. @retval EFI_SUCCESS The operation completed successfully.
  290. @retval EFI_INVALID_PARAMETER This is NULL.
  291. @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
  292. **/
  293. EFI_STATUS
  294. EFIAPI
  295. EfiIp6GetModeData (
  296. IN EFI_IP6_PROTOCOL *This,
  297. OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
  298. OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
  299. OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
  300. );
  301. /**
  302. Assigns an IPv6 address and subnet mask to this EFI IPv6 Protocol driver instance.
  303. The Configure() function is used to set, change, or reset the operational parameters and filter
  304. settings for this EFI IPv6 Protocol instance. Until these parameters have been set, no network traffic
  305. can be sent or received by this instance. Once the parameters have been reset (by calling this
  306. function with Ip6ConfigData set to NULL), no more traffic can be sent or received until these
  307. parameters have been set again. Each EFI IPv6 Protocol instance can be started and stopped
  308. independently of each other by enabling or disabling their receive filter settings with the
  309. Configure() function.
  310. If Ip6ConfigData.StationAddress is a valid non-zero IPv6 unicast address, it is required
  311. to be one of the currently configured IPv6 addresses list in the EFI IPv6 drivers, or else
  312. EFI_INVALID_PARAMETER will be returned. If Ip6ConfigData.StationAddress is
  313. unspecified, the IPv6 driver will bind a source address according to the source address selection
  314. algorithm. Clients could frequently call GetModeData() to check get a currently configured IPv6.
  315. If both Ip6ConfigData.StationAddress and Ip6ConfigData.Destination are unspecified, when
  316. transmitting the packet afterwards, the source address filled in each outgoing IPv6 packet
  317. is decided based on the destination of this packet.
  318. If operational parameters are reset or changed, any pending transmit and receive requests will be
  319. cancelled. Their completion token status will be set to EFI_ABORTED, and their events will be
  320. signaled.
  321. @param[in] This The pointer to the EFI_IP6_PROTOCOL instance.
  322. @param[in] Ip6ConfigData The pointer to the EFI IPv6 Protocol configuration data structure.
  323. If NULL, reset the configuration data.
  324. @retval EFI_SUCCESS The driver instance was successfully opened.
  325. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  326. - This is NULL.
  327. - Ip6ConfigData.StationAddress is neither zero nor
  328. a unicast IPv6 address.
  329. - Ip6ConfigData.StationAddress is neither zero nor
  330. one of the configured IP addresses in the EFI IPv6 driver.
  331. - Ip6ConfigData.DefaultProtocol is illegal.
  332. @retval EFI_OUT_OF_RESOURCES The EFI IPv6 Protocol driver instance data could not be allocated.
  333. @retval EFI_NO_MAPPING The IPv6 driver was responsible for choosing a source address for
  334. this instance, but no source address was available for use.
  335. @retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the IPv6
  336. address or prefix length can be changed.
  337. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv6
  338. Protocol driver instance was not opened.
  339. @retval EFI_UNSUPPORTED Default protocol specified through
  340. Ip6ConfigData.DefaultProtocol isn't supported.
  341. **/
  342. EFI_STATUS
  343. EFIAPI
  344. EfiIp6Configure (
  345. IN EFI_IP6_PROTOCOL *This,
  346. IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL
  347. );
  348. /**
  349. Joins and leaves multicast groups.
  350. The Groups() function is used to join and leave multicast group sessions. Joining a group will
  351. enable reception of matching multicast packets. Leaving a group will disable reception of matching
  352. multicast packets. Source-Specific Multicast isn't required to be supported.
  353. If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.
  354. @param[in] This The pointer to the EFI_IP6_PROTOCOL instance.
  355. @param[in] JoinFlag Set to TRUE to join the multicast group session and FALSE to leave.
  356. @param[in] GroupAddress The pointer to the IPv6 multicast address.
  357. This is an optional parameter that may be NULL.
  358. @retval EFI_SUCCESS The operation completed successfully.
  359. @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:
  360. - This is NULL.
  361. - JoinFlag is TRUE and GroupAddress is NULL.
  362. - GroupAddress is not NULL and *GroupAddress is
  363. not a multicast IPv6 address.
  364. - GroupAddress is not NULL and *GroupAddress is in the
  365. range of SSM destination address.
  366. @retval EFI_NOT_STARTED This instance has not been started.
  367. @retval EFI_OUT_OF_RESOURCES System resources could not be allocated.
  368. @retval EFI_UNSUPPORTED This EFI IPv6 Protocol implementation does not support multicast groups.
  369. @retval EFI_ALREADY_STARTED The group address is already in the group table (when
  370. JoinFlag is TRUE).
  371. @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE).
  372. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  373. **/
  374. EFI_STATUS
  375. EFIAPI
  376. EfiIp6Groups (
  377. IN EFI_IP6_PROTOCOL *This,
  378. IN BOOLEAN JoinFlag,
  379. IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
  380. );
  381. /**
  382. Adds and deletes routing table entries.
  383. The Routes() function adds a route to or deletes a route from the routing table.
  384. Routes are determined by comparing the leftmost PrefixLength bits of Destination with
  385. the destination IPv6 address arithmetically. The gateway address must be on the same subnet as the
  386. configured station address.
  387. The default route is added with Destination and PrefixLength both set to all zeros. The
  388. default route matches all destination IPv6 addresses that do not match any other routes.
  389. All EFI IPv6 Protocol instances share a routing table.
  390. @param[in] This The pointer to the EFI_IP6_PROTOCOL instance.
  391. @param[in] DeleteRoute Set to TRUE to delete this route from the routing table. Set to
  392. FALSE to add this route to the routing table. Destination,
  393. PrefixLength and Gateway are used as the key to each
  394. route entry.
  395. @param[in] Destination The address prefix of the subnet that needs to be routed.
  396. This is an optional parameter that may be NULL.
  397. @param[in] PrefixLength The prefix length of Destination. Ignored if Destination
  398. is NULL.
  399. @param[in] GatewayAddress The unicast gateway IPv6 address for this route.
  400. This is an optional parameter that may be NULL.
  401. @retval EFI_SUCCESS The operation completed successfully.
  402. @retval EFI_NOT_STARTED The driver instance has not been started.
  403. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  404. - This is NULL.
  405. - When DeleteRoute is TRUE, both Destination and
  406. GatewayAddress are NULL.
  407. - When DeleteRoute is FALSE, either Destination or
  408. GatewayAddress is NULL.
  409. - *GatewayAddress is not a valid unicast IPv6 address.
  410. - *GatewayAddress is one of the local configured IPv6
  411. addresses.
  412. @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
  413. @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).
  414. @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when
  415. DeleteRoute is FALSE).
  416. **/
  417. EFI_STATUS
  418. EFIAPI
  419. EfiIp6Routes (
  420. IN EFI_IP6_PROTOCOL *This,
  421. IN BOOLEAN DeleteRoute,
  422. IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
  423. IN UINT8 PrefixLength,
  424. IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
  425. );
  426. /**
  427. Add or delete Neighbor cache entries.
  428. The Neighbors() function is used to add, update, or delete an entry from a neighbor cache.
  429. IPv6 neighbor cache entries are typically inserted and updated by the network protocol driver as
  430. network traffic is processed. Most neighbor cache entries will timeout and be deleted if the network
  431. traffic stops. Neighbor cache entries that were inserted by Neighbors() may be static (will not
  432. timeout) or dynamic (will timeout).
  433. The implementation should follow the neighbor cache timeout mechanism defined in
  434. RFC4861. The default neighbor cache timeout value should be tuned for the expected network
  435. environment.
  436. @param[in] This The pointer to the EFI_IP6_PROTOCOL instance.
  437. @param[in] DeleteFlag Set to TRUE to delete the specified cache entry. Set to FALSE to
  438. add (or update, if it already exists and Override is TRUE) the
  439. specified cache entry. TargetIp6Address is used as the key
  440. to find the requested cache entry.
  441. @param[in] TargetIp6Address The pointer to the Target IPv6 address.
  442. @param[in] TargetLinkAddress The pointer to link-layer address of the target. Ignored if NULL.
  443. @param[in] Timeout Time in 100-ns units that this entry will remain in the neighbor
  444. cache, it will be deleted after Timeout. A value of zero means that
  445. the entry is permanent. A non-zero value means that the entry is
  446. dynamic.
  447. @param[in] Override If TRUE, the cached link-layer address of the matching entry will
  448. be overridden and updated; if FALSE, EFI_ACCESS_DENIED
  449. will be returned if a corresponding cache entry already exists.
  450. @retval EFI_SUCCESS The data has been queued for transmission.
  451. @retval EFI_NOT_STARTED This instance has not been started.
  452. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  453. - This is NULL.
  454. - TargetIpAddress is NULL.
  455. - *TargetLinkAddress is invalid when not NULL.
  456. - *TargetIpAddress is not a valid unicast IPv6 address.
  457. - *TargetIpAddress is one of the local configured IPv6
  458. addresses.
  459. @retval EFI_OUT_OF_RESOURCES Could not add the entry to the neighbor cache.
  460. @retval EFI_NOT_FOUND This entry is not in the neighbor cache (when DeleteFlag is
  461. TRUE or when DeleteFlag is FALSE while
  462. TargetLinkAddress is NULL.).
  463. @retval EFI_ACCESS_DENIED The to-be-added entry is already defined in the neighbor cache,
  464. and that entry is tagged as un-overridden (when Override
  465. is FALSE).
  466. **/
  467. EFI_STATUS
  468. EFIAPI
  469. EfiIp6Neighbors (
  470. IN EFI_IP6_PROTOCOL *This,
  471. IN BOOLEAN DeleteFlag,
  472. IN EFI_IPv6_ADDRESS *TargetIp6Address,
  473. IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
  474. IN UINT32 Timeout,
  475. IN BOOLEAN Override
  476. );
  477. /**
  478. Places outgoing data packets into the transmit queue.
  479. The Transmit() function places a sending request in the transmit queue of this
  480. EFI IPv6 Protocol instance. Whenever the packet in the token is sent out or some
  481. errors occur, the event in the token will be signaled and the status is updated.
  482. @param[in] This The pointer to the EFI_IP6_PROTOCOL instance.
  483. @param[in] Token The pointer to the transmit token.
  484. @retval EFI_SUCCESS The data has been queued for transmission.
  485. @retval EFI_NOT_STARTED This instance has not been started.
  486. @retval EFI_NO_MAPPING The IPv6 driver was responsible for choosing
  487. a source address for this transmission,
  488. but no source address was available for use.
  489. @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:
  490. - This is NULL.
  491. - Token is NULL.
  492. - Token.Event is NULL.
  493. - Token.Packet.TxData is NULL.
  494. - Token.Packet.ExtHdrsLength is not zero and
  495. Token.Packet.ExtHdrs is NULL.
  496. - Token.Packet.FragmentCount is zero.
  497. - One or more of the Token.Packet.TxData.
  498. FragmentTable[].FragmentLength fields is zero.
  499. - One or more of the Token.Packet.TxData.
  500. FragmentTable[].FragmentBuffer fields is NULL.
  501. - Token.Packet.TxData.DataLength is zero or not
  502. equal to the sum of fragment lengths.
  503. - Token.Packet.TxData.DestinationAddress is non-
  504. zero when DestinationAddress is configured as
  505. non-zero when doing Configure() for this
  506. EFI IPv6 protocol instance.
  507. - Token.Packet.TxData.DestinationAddress is
  508. unspecified when DestinationAddress is unspecified
  509. when doing Configure() for this EFI IPv6 protocol
  510. instance.
  511. @retval EFI_ACCESS_DENIED The transmit completion token with the same Token.
  512. The event was already in the transmit queue.
  513. @retval EFI_NOT_READY The completion token could not be queued because
  514. the transmit queue is full.
  515. @retval EFI_NOT_FOUND Not route is found to the destination address.
  516. @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
  517. @retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too
  518. short to transmit.
  519. @retval EFI_BAD_BUFFER_SIZE If Token.Packet.TxData.DataLength is beyond the
  520. maximum that which can be described through the
  521. Fragment Offset field in Fragment header when
  522. performing fragmentation.
  523. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  524. **/
  525. EFI_STATUS
  526. EFIAPI
  527. EfiIp6Transmit (
  528. IN EFI_IP6_PROTOCOL *This,
  529. IN EFI_IP6_COMPLETION_TOKEN *Token
  530. );
  531. /**
  532. Places a receiving request into the receiving queue.
  533. The Receive() function places a completion token into the receive packet queue.
  534. This function is always asynchronous.
  535. The Token.Event field in the completion token must be filled in by the caller
  536. and cannot be NULL. When the receive operation completes, the EFI IPv6 Protocol
  537. driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
  538. is signaled.
  539. Current Udp implementation creates an IP child for each Udp child.
  540. It initiates a asynchronous receive immediately whether or not
  541. there is no mapping. Therefore, disable the returning EFI_NO_MAPPING for now.
  542. To enable it, the following check must be performed:
  543. if (NetIp6IsUnspecifiedAddr (&Config->StationAddress) && IP6_NO_MAPPING (IpInstance)) {
  544. Status = EFI_NO_MAPPING;
  545. goto Exit;
  546. }
  547. @param[in] This The pointer to the EFI_IP6_PROTOCOL instance.
  548. @param[in] Token The pointer to a token that is associated with the
  549. receive data descriptor.
  550. @retval EFI_SUCCESS The receive completion token was cached.
  551. @retval EFI_NOT_STARTED This EFI IPv6 Protocol instance has not been started.
  552. @retval EFI_NO_MAPPING When IP6 driver responsible for binding source address to this instance,
  553. while no source address is available for use.
  554. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  555. - This is NULL.
  556. - Token is NULL.
  557. - Token.Event is NULL.
  558. @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system
  559. resources (usually memory).
  560. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  561. The EFI IPv6 Protocol instance has been reset to startup defaults.
  562. @retval EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already
  563. in the receive queue.
  564. @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
  565. **/
  566. EFI_STATUS
  567. EFIAPI
  568. EfiIp6Receive (
  569. IN EFI_IP6_PROTOCOL *This,
  570. IN EFI_IP6_COMPLETION_TOKEN *Token
  571. );
  572. /**
  573. Abort an asynchronous transmit or receive request.
  574. The Cancel() function is used to abort a pending transmit or receive request.
  575. If the token is in the transmit or receive request queues, after calling this
  576. function, Token->Status will be set to EFI_ABORTED, and then Token->Event will
  577. be signaled. If the token is not in one of the queues, which usually means the
  578. asynchronous operation has completed, this function will not signal the token,
  579. and EFI_NOT_FOUND is returned.
  580. @param[in] This The pointer to the EFI_IP6_PROTOCOL instance.
  581. @param[in] Token The pointer to a token that has been issued by
  582. EFI_IP6_PROTOCOL.Transmit() or
  583. EFI_IP6_PROTOCOL.Receive(). If NULL, all pending
  584. tokens are aborted. Type EFI_IP6_COMPLETION_TOKEN is
  585. defined in EFI_IP6_PROTOCOL.Transmit().
  586. @retval EFI_SUCCESS The asynchronous I/O request was aborted and
  587. Token->Event was signaled. When Token is NULL, all
  588. pending requests were aborted, and their events were signaled.
  589. @retval EFI_INVALID_PARAMETER This is NULL.
  590. @retval EFI_NOT_STARTED This instance has not been started.
  591. @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was
  592. not found in the transmit or receive queue. It has either completed
  593. or was not issued by Transmit() and Receive().
  594. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  595. **/
  596. EFI_STATUS
  597. EFIAPI
  598. EfiIp6Cancel (
  599. IN EFI_IP6_PROTOCOL *This,
  600. IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL
  601. );
  602. /**
  603. Polls for incoming data packets and processes outgoing data packets.
  604. The Poll() function polls for incoming data packets and processes outgoing data
  605. packets. Network drivers and applications can call the EFI_IP6_PROTOCOL.Poll()
  606. function to increase the rate that data packets are moved between the communications
  607. device and the transmit and receive queues.
  608. In some systems the periodic timer event may not poll the underlying communications
  609. device fast enough to transmit and/or receive all data packets without missing
  610. incoming packets or dropping outgoing packets. Drivers and applications that are
  611. experiencing packet loss should try calling the EFI_IP6_PROTOCOL.Poll() function
  612. more often.
  613. @param[in] This The pointer to the EFI_IP6_PROTOCOL instance.
  614. @retval EFI_SUCCESS Incoming or outgoing data was processed.
  615. @retval EFI_NOT_STARTED This EFI IPv6 Protocol instance has not been started.
  616. @retval EFI_INVALID_PARAMETER This is NULL.
  617. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  618. @retval EFI_NOT_READY No incoming or outgoing data was processed.
  619. @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
  620. Consider increasing the polling rate.
  621. **/
  622. EFI_STATUS
  623. EFIAPI
  624. EfiIp6Poll (
  625. IN EFI_IP6_PROTOCOL *This
  626. );
  627. #endif