Ip6Nd.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. /** @file
  2. Definition of Neighbor Discovery support routines.
  3. Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __EFI_IP6_ND_H__
  7. #define __EFI_IP6_ND_H__
  8. #define IP6_GET_TICKS(Ms) (((Ms) + IP6_TIMER_INTERVAL_IN_MS - 1) / IP6_TIMER_INTERVAL_IN_MS)
  9. enum {
  10. IP6_INF_ROUTER_LIFETIME = 0xFFFF,
  11. IP6_MAX_RTR_SOLICITATION_DELAY = 1000, ///< 1000 milliseconds
  12. IP6_MAX_RTR_SOLICITATIONS = 3,
  13. IP6_RTR_SOLICITATION_INTERVAL = 4000,
  14. IP6_MIN_RANDOM_FACTOR_SCALED = 1,
  15. IP6_MAX_RANDOM_FACTOR_SCALED = 3,
  16. IP6_RANDOM_FACTOR_SCALE = 2,
  17. IP6_MAX_MULTICAST_SOLICIT = 3,
  18. IP6_MAX_UNICAST_SOLICIT = 3,
  19. IP6_MAX_ANYCAST_DELAY_TIME = 1,
  20. IP6_MAX_NEIGHBOR_ADV = 3,
  21. IP6_REACHABLE_TIME = 30000,
  22. IP6_RETRANS_TIMER = 1000,
  23. IP6_DELAY_FIRST_PROBE_TIME = 5000,
  24. IP6_MIN_LINK_MTU = 1280,
  25. IP6_MAX_LINK_MTU = 1500,
  26. IP6_IS_ROUTER_FLAG = 0x80,
  27. IP6_SOLICITED_FLAG = 0x40,
  28. IP6_OVERRIDE_FLAG = 0x20,
  29. IP6_M_ADDR_CONFIG_FLAG = 0x80,
  30. IP6_O_CONFIG_FLAG = 0x40,
  31. IP6_ON_LINK_FLAG = 0x80,
  32. IP6_AUTO_CONFIG_FLAG = 0x40,
  33. IP6_ND_LENGTH = 24,
  34. IP6_RA_LENGTH = 16,
  35. IP6_REDITECT_LENGTH = 40,
  36. IP6_DAD_ENTRY_SIGNATURE = SIGNATURE_32 ('I', 'P', 'D', 'E')
  37. };
  38. typedef
  39. VOID
  40. (*IP6_ARP_CALLBACK) (
  41. VOID *Context
  42. );
  43. typedef struct _IP6_OPTION_HEADER {
  44. UINT8 Type;
  45. UINT8 Length;
  46. } IP6_OPTION_HEADER;
  47. STATIC_ASSERT (sizeof (IP6_OPTION_HEADER) == 2, "IP6_OPTION_HEADER is expected to be exactly 2 bytes long.");
  48. typedef struct _IP6_ETHE_ADDR_OPTION {
  49. UINT8 Type;
  50. UINT8 Length;
  51. UINT8 EtherAddr[6];
  52. } IP6_ETHER_ADDR_OPTION;
  53. STATIC_ASSERT (sizeof (IP6_ETHER_ADDR_OPTION) == 8, "IP6_ETHER_ADDR_OPTION is expected to be exactly 8 bytes long.");
  54. typedef struct _IP6_MTU_OPTION {
  55. UINT8 Type;
  56. UINT8 Length;
  57. UINT16 Reserved;
  58. UINT32 Mtu;
  59. } IP6_MTU_OPTION;
  60. STATIC_ASSERT (sizeof (IP6_MTU_OPTION) == 8, "IP6_MTU_OPTION is expected to be exactly 8 bytes long.");
  61. typedef struct _IP6_PREFIX_INFO_OPTION {
  62. UINT8 Type;
  63. UINT8 Length;
  64. UINT8 PrefixLength;
  65. UINT8 Reserved1;
  66. UINT32 ValidLifetime;
  67. UINT32 PreferredLifetime;
  68. UINT32 Reserved2;
  69. EFI_IPv6_ADDRESS Prefix;
  70. } IP6_PREFIX_INFO_OPTION;
  71. STATIC_ASSERT (sizeof (IP6_PREFIX_INFO_OPTION) == 32, "IP6_PREFIX_INFO_OPTION is expected to be exactly 32 bytes long.");
  72. typedef
  73. VOID
  74. (*IP6_DAD_CALLBACK) (
  75. IN BOOLEAN IsDadPassed,
  76. IN EFI_IPv6_ADDRESS *TargetAddress,
  77. IN VOID *Context
  78. );
  79. typedef struct _IP6_DAD_ENTRY {
  80. UINT32 Signature;
  81. LIST_ENTRY Link;
  82. UINT32 MaxTransmit;
  83. UINT32 Transmit;
  84. UINT32 Receive;
  85. UINT32 RetransTick;
  86. IP6_ADDRESS_INFO *AddressInfo;
  87. EFI_IPv6_ADDRESS Destination;
  88. IP6_DAD_CALLBACK Callback;
  89. VOID *Context;
  90. } IP6_DAD_ENTRY;
  91. typedef struct _IP6_DELAY_JOIN_LIST {
  92. LIST_ENTRY Link;
  93. UINT32 DelayTime; ///< in tick per 50 milliseconds
  94. IP6_INTERFACE *Interface;
  95. IP6_ADDRESS_INFO *AddressInfo;
  96. IP6_DAD_CALLBACK DadCallback;
  97. VOID *Context;
  98. } IP6_DELAY_JOIN_LIST;
  99. typedef struct _IP6_NEIGHBOR_ENTRY {
  100. LIST_ENTRY Link;
  101. LIST_ENTRY ArpList;
  102. INTN RefCnt;
  103. BOOLEAN IsRouter;
  104. BOOLEAN ArpFree;
  105. BOOLEAN Dynamic;
  106. EFI_IPv6_ADDRESS Neighbor;
  107. EFI_MAC_ADDRESS LinkAddress;
  108. EFI_IP6_NEIGHBOR_STATE State;
  109. UINT32 Transmit;
  110. UINT32 Ticks;
  111. LIST_ENTRY Frames;
  112. IP6_INTERFACE *Interface;
  113. IP6_ARP_CALLBACK CallBack;
  114. } IP6_NEIGHBOR_ENTRY;
  115. typedef struct _IP6_DEFAULT_ROUTER {
  116. LIST_ENTRY Link;
  117. INTN RefCnt;
  118. UINT16 Lifetime;
  119. EFI_IPv6_ADDRESS Router;
  120. IP6_NEIGHBOR_ENTRY *NeighborCache;
  121. } IP6_DEFAULT_ROUTER;
  122. typedef struct _IP6_PREFIX_LIST_ENTRY {
  123. LIST_ENTRY Link;
  124. INTN RefCnt;
  125. UINT32 ValidLifetime;
  126. UINT32 PreferredLifetime;
  127. UINT8 PrefixLength;
  128. EFI_IPv6_ADDRESS Prefix;
  129. } IP6_PREFIX_LIST_ENTRY;
  130. /**
  131. Build a array of EFI_IP6_NEIGHBOR_CACHE to be returned to the caller. The number
  132. of EFI_IP6_NEIGHBOR_CACHE is also returned.
  133. @param[in] IpInstance The pointer to IP6_PROTOCOL instance.
  134. @param[out] NeighborCount The number of returned neighbor cache entries.
  135. @param[out] NeighborCache The pointer to the array of EFI_IP6_NEIGHBOR_CACHE.
  136. @retval EFI_SUCCESS The EFI_IP6_NEIGHBOR_CACHE successfully built.
  137. @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the route table.
  138. **/
  139. EFI_STATUS
  140. Ip6BuildEfiNeighborCache (
  141. IN IP6_PROTOCOL *IpInstance,
  142. OUT UINT32 *NeighborCount,
  143. OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache
  144. );
  145. /**
  146. Build a array of EFI_IP6_ADDRESS_INFO to be returned to the caller. The number
  147. of prefix entries is also returned.
  148. @param[in] IpInstance The pointer to IP6_PROTOCOL instance.
  149. @param[out] PrefixCount The number of returned prefix entries.
  150. @param[out] PrefixTable The pointer to the array of PrefixTable.
  151. @retval EFI_SUCCESS The prefix table successfully built.
  152. @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the prefix table.
  153. **/
  154. EFI_STATUS
  155. Ip6BuildPrefixTable (
  156. IN IP6_PROTOCOL *IpInstance,
  157. OUT UINT32 *PrefixCount,
  158. OUT EFI_IP6_ADDRESS_INFO **PrefixTable
  159. );
  160. /**
  161. Allocate and initialize an IP6 default router entry.
  162. @param[in] IpSb The pointer to the IP6_SERVICE instance.
  163. @param[in] Ip6Address The IPv6 address of the default router.
  164. @param[in] RouterLifetime The lifetime associated with the default
  165. router, in units of seconds.
  166. @return NULL if it failed to allocate memory for the default router node.
  167. Otherwise, point to the created default router node.
  168. **/
  169. IP6_DEFAULT_ROUTER *
  170. Ip6CreateDefaultRouter (
  171. IN IP6_SERVICE *IpSb,
  172. IN EFI_IPv6_ADDRESS *Ip6Address,
  173. IN UINT16 RouterLifetime
  174. );
  175. /**
  176. Destroy an IP6 default router entry.
  177. @param[in] IpSb The pointer to the IP6_SERVICE instance.
  178. @param[in] DefaultRouter The to be destroyed IP6_DEFAULT_ROUTER.
  179. **/
  180. VOID
  181. Ip6DestroyDefaultRouter (
  182. IN IP6_SERVICE *IpSb,
  183. IN IP6_DEFAULT_ROUTER *DefaultRouter
  184. );
  185. /**
  186. Clean an IP6 default router list.
  187. @param[in] IpSb The pointer to the IP6_SERVICE instance.
  188. **/
  189. VOID
  190. Ip6CleanDefaultRouterList (
  191. IN IP6_SERVICE *IpSb
  192. );
  193. /**
  194. Search a default router node from an IP6 default router list.
  195. @param[in] IpSb The pointer to the IP6_SERVICE instance.
  196. @param[in] Ip6Address The IPv6 address of the to be searched default router node.
  197. @return NULL if it failed to find the matching default router node.
  198. Otherwise, point to the found default router node.
  199. **/
  200. IP6_DEFAULT_ROUTER *
  201. Ip6FindDefaultRouter (
  202. IN IP6_SERVICE *IpSb,
  203. IN EFI_IPv6_ADDRESS *Ip6Address
  204. );
  205. /**
  206. The function to be called after DAD (Duplicate Address Detection) is performed.
  207. @param[in] IsDadPassed If TRUE, the DAD operation succeed. Otherwise, the DAD operation failed.
  208. @param[in] IpIf Points to the IP6_INTERFACE.
  209. @param[in] DadEntry The DAD entry which already performed DAD.
  210. **/
  211. VOID
  212. Ip6OnDADFinished (
  213. IN BOOLEAN IsDadPassed,
  214. IN IP6_INTERFACE *IpIf,
  215. IN IP6_DAD_ENTRY *DadEntry
  216. );
  217. /**
  218. Create a DAD (Duplicate Address Detection) entry and queue it to be performed.
  219. @param[in] IpIf Points to the IP6_INTERFACE.
  220. @param[in] AddressInfo The address information which needs DAD performed.
  221. @param[in] Callback The callback routine that will be called after DAD
  222. is performed. This is an optional parameter that
  223. may be NULL.
  224. @param[in] Context The opaque parameter for a DAD callback routine.
  225. This is an optional parameter that may be NULL.
  226. @retval EFI_SUCCESS The DAD entry was created and queued.
  227. @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory to complete the
  228. operation.
  229. **/
  230. EFI_STATUS
  231. Ip6InitDADProcess (
  232. IN IP6_INTERFACE *IpIf,
  233. IN IP6_ADDRESS_INFO *AddressInfo,
  234. IN IP6_DAD_CALLBACK Callback OPTIONAL,
  235. IN VOID *Context OPTIONAL
  236. );
  237. /**
  238. Search IP6_DAD_ENTRY from the Duplicate Address Detection List.
  239. @param[in] IpSb The pointer to the IP6_SERVICE instance.
  240. @param[in] Target The address information which needs DAD performed .
  241. @param[out] Interface If not NULL, output the IP6 interface that configures
  242. the tentative address.
  243. @return NULL if failed to find the matching DAD entry.
  244. Otherwise, point to the found DAD entry.
  245. **/
  246. IP6_DAD_ENTRY *
  247. Ip6FindDADEntry (
  248. IN IP6_SERVICE *IpSb,
  249. IN EFI_IPv6_ADDRESS *Target,
  250. OUT IP6_INTERFACE **Interface OPTIONAL
  251. );
  252. /**
  253. Allocate and initialize a IP6 prefix list entry.
  254. @param[in] IpSb The pointer to IP6_SERVICE instance.
  255. @param[in] OnLinkOrAuto If TRUE, the entry is created for the on link prefix list.
  256. Otherwise, it is created for the autoconfiguration prefix list.
  257. @param[in] ValidLifetime The length of time in seconds that the prefix
  258. is valid for the purpose of on-link determination.
  259. @param[in] PreferredLifetime The length of time in seconds that addresses
  260. generated from the prefix via stateless address
  261. autoconfiguration remain preferred.
  262. @param[in] PrefixLength The prefix length of the Prefix.
  263. @param[in] Prefix The prefix address.
  264. @return NULL if it failed to allocate memory for the prefix node. Otherwise, point
  265. to the created or existing prefix list entry.
  266. **/
  267. IP6_PREFIX_LIST_ENTRY *
  268. Ip6CreatePrefixListEntry (
  269. IN IP6_SERVICE *IpSb,
  270. IN BOOLEAN OnLinkOrAuto,
  271. IN UINT32 ValidLifetime,
  272. IN UINT32 PreferredLifetime,
  273. IN UINT8 PrefixLength,
  274. IN EFI_IPv6_ADDRESS *Prefix
  275. );
  276. /**
  277. Destroy a IP6 prefix list entry.
  278. @param[in] IpSb The pointer to IP6_SERVICE instance.
  279. @param[in] PrefixEntry The to be destroyed prefix list entry.
  280. @param[in] OnLinkOrAuto If TRUE, the entry is removed from on link prefix list.
  281. Otherwise remove from autoconfiguration prefix list.
  282. @param[in] ImmediateDelete If TRUE, remove the entry directly.
  283. Otherwise, check the reference count to see whether
  284. it should be removed.
  285. **/
  286. VOID
  287. Ip6DestroyPrefixListEntry (
  288. IN IP6_SERVICE *IpSb,
  289. IN IP6_PREFIX_LIST_ENTRY *PrefixEntry,
  290. IN BOOLEAN OnLinkOrAuto,
  291. IN BOOLEAN ImmediateDelete
  292. );
  293. /**
  294. Search the list array to find an IP6 prefix list entry.
  295. @param[in] IpSb The pointer to IP6_SERVICE instance.
  296. @param[in] OnLinkOrAuto If TRUE, the search the link prefix list,
  297. Otherwise search the autoconfiguration prefix list.
  298. @param[in] PrefixLength The prefix length of the Prefix
  299. @param[in] Prefix The prefix address.
  300. @return NULL if cannot find the IP6 prefix list entry. Otherwise, return the
  301. pointer to the IP6 prefix list entry.
  302. **/
  303. IP6_PREFIX_LIST_ENTRY *
  304. Ip6FindPrefixListEntry (
  305. IN IP6_SERVICE *IpSb,
  306. IN BOOLEAN OnLinkOrAuto,
  307. IN UINT8 PrefixLength,
  308. IN EFI_IPv6_ADDRESS *Prefix
  309. );
  310. /**
  311. Release the resource in prefix list table, and destroy the list entry and
  312. corresponding addresses or route entries.
  313. @param[in] IpSb The pointer to the IP6_SERVICE instance.
  314. @param[in] ListHead The list entry head of the prefix list table.
  315. **/
  316. VOID
  317. Ip6CleanPrefixListTable (
  318. IN IP6_SERVICE *IpSb,
  319. IN LIST_ENTRY *ListHead
  320. );
  321. /**
  322. Allocate and initialize an IP6 neighbor cache entry.
  323. @param[in] IpSb The pointer to the IP6_SERVICE instance.
  324. @param[in] CallBack The callback function to be called when
  325. address resolution is finished.
  326. @param[in] Ip6Address Points to the IPv6 address of the neighbor.
  327. @param[in] LinkAddress Points to the MAC address of the neighbor.
  328. Ignored if NULL.
  329. @return NULL if failed to allocate memory for the neighbor cache entry.
  330. Otherwise, point to the created neighbor cache entry.
  331. **/
  332. IP6_NEIGHBOR_ENTRY *
  333. Ip6CreateNeighborEntry (
  334. IN IP6_SERVICE *IpSb,
  335. IN IP6_ARP_CALLBACK CallBack,
  336. IN EFI_IPv6_ADDRESS *Ip6Address,
  337. IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL
  338. );
  339. /**
  340. Search a IP6 neighbor cache entry.
  341. @param[in] IpSb The pointer to the IP6_SERVICE instance.
  342. @param[in] Ip6Address Points to the IPv6 address of the neighbor.
  343. @return NULL if it failed to find the matching neighbor cache entry.
  344. Otherwise, point to the found neighbor cache entry.
  345. **/
  346. IP6_NEIGHBOR_ENTRY *
  347. Ip6FindNeighborEntry (
  348. IN IP6_SERVICE *IpSb,
  349. IN EFI_IPv6_ADDRESS *Ip6Address
  350. );
  351. /**
  352. Free a IP6 neighbor cache entry and remove all the frames on the address
  353. resolution queue that pass the FrameToCancel. That is, either FrameToCancel
  354. is NULL, or it returns true for the frame.
  355. @param[in] IpSb The pointer to the IP6_SERVICE instance.
  356. @param[in] NeighborCache The to be free neighbor cache entry.
  357. @param[in] SendIcmpError If TRUE, send out ICMP error.
  358. @param[in] FullFree If TRUE, remove the neighbor cache entry.
  359. Otherwise remove the pending frames.
  360. @param[in] IoStatus The status returned to the cancelled frames'
  361. callback function.
  362. @param[in] FrameToCancel Function to select which frame to cancel.
  363. This is an optional parameter that may be NULL.
  364. @param[in] Context Opaque parameter to the FrameToCancel.
  365. Ignored if FrameToCancel is NULL.
  366. @retval EFI_INVALID_PARAMETER The input parameter is invalid.
  367. @retval EFI_SUCCESS The operation finished successfully.
  368. **/
  369. EFI_STATUS
  370. Ip6FreeNeighborEntry (
  371. IN IP6_SERVICE *IpSb,
  372. IN IP6_NEIGHBOR_ENTRY *NeighborCache,
  373. IN BOOLEAN SendIcmpError,
  374. IN BOOLEAN FullFree,
  375. IN EFI_STATUS IoStatus,
  376. IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
  377. IN VOID *Context OPTIONAL
  378. );
  379. /**
  380. Add Neighbor cache entries. It is a work function for EfiIp6Neighbors().
  381. @param[in] IpSb The IP6 service binding instance.
  382. @param[in] TargetIp6Address Pointer to Target IPv6 address.
  383. @param[in] TargetLinkAddress Pointer to link-layer address of the target. Ignored if NULL.
  384. @param[in] Timeout Time in 100-ns units that this entry will remain in the neighbor
  385. cache. It will be deleted after Timeout. A value of zero means that
  386. the entry is permanent. A non-zero value means that the entry is
  387. dynamic.
  388. @param[in] Override If TRUE, the cached link-layer address of the matching entry will
  389. be overridden and updated; if FALSE, and if a
  390. corresponding cache entry already existed, EFI_ACCESS_DENIED
  391. will be returned.
  392. @retval EFI_SUCCESS The neighbor cache entry has been added.
  393. @retval EFI_OUT_OF_RESOURCES Could not add the entry to the neighbor cache
  394. due to insufficient resources.
  395. @retval EFI_NOT_FOUND TargetLinkAddress is NULL.
  396. @retval EFI_ACCESS_DENIED The to-be-added entry is already defined in the neighbor cache,
  397. and that entry is tagged as un-overridden (when DeleteFlag
  398. is FALSE).
  399. **/
  400. EFI_STATUS
  401. Ip6AddNeighbor (
  402. IN IP6_SERVICE *IpSb,
  403. IN EFI_IPv6_ADDRESS *TargetIp6Address,
  404. IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
  405. IN UINT32 Timeout,
  406. IN BOOLEAN Override
  407. );
  408. /**
  409. Delete or update Neighbor cache entries. It is a work function for EfiIp6Neighbors().
  410. @param[in] IpSb The IP6 service binding instance.
  411. @param[in] TargetIp6Address Pointer to Target IPv6 address.
  412. @param[in] TargetLinkAddress Pointer to link-layer address of the target. Ignored if NULL.
  413. @param[in] Timeout Time in 100-ns units that this entry will remain in the neighbor
  414. cache. It will be deleted after Timeout. A value of zero means that
  415. the entry is permanent. A non-zero value means that the entry is
  416. dynamic.
  417. @param[in] Override If TRUE, the cached link-layer address of the matching entry will
  418. be overridden and updated; if FALSE, and if a
  419. corresponding cache entry already existed, EFI_ACCESS_DENIED
  420. will be returned.
  421. @retval EFI_SUCCESS The neighbor cache entry has been updated or deleted.
  422. @retval EFI_NOT_FOUND This entry is not in the neighbor cache.
  423. **/
  424. EFI_STATUS
  425. Ip6DelNeighbor (
  426. IN IP6_SERVICE *IpSb,
  427. IN EFI_IPv6_ADDRESS *TargetIp6Address,
  428. IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
  429. IN UINT32 Timeout,
  430. IN BOOLEAN Override
  431. );
  432. /**
  433. Process the Neighbor Solicitation message. The message may be sent for Duplicate
  434. Address Detection or Address Resolution.
  435. @param[in] IpSb The IP service that received the packet.
  436. @param[in] Head The IP head of the message.
  437. @param[in] Packet The content of the message with IP head removed.
  438. @retval EFI_SUCCESS The packet processed successfully.
  439. @retval EFI_INVALID_PARAMETER The packet is invalid.
  440. @retval EFI_ICMP_ERROR The packet indicates that DAD is failed.
  441. @retval Others Failed to process the packet.
  442. **/
  443. EFI_STATUS
  444. Ip6ProcessNeighborSolicit (
  445. IN IP6_SERVICE *IpSb,
  446. IN EFI_IP6_HEADER *Head,
  447. IN NET_BUF *Packet
  448. );
  449. /**
  450. Process the Neighbor Advertisement message.
  451. @param[in] IpSb The IP service that received the packet.
  452. @param[in] Head The IP head of the message.
  453. @param[in] Packet The content of the message with IP head removed.
  454. @retval EFI_SUCCESS The packet processed successfully.
  455. @retval EFI_INVALID_PARAMETER The packet is invalid.
  456. @retval EFI_ICMP_ERROR The packet indicates that DAD is failed.
  457. @retval Others Failed to process the packet.
  458. **/
  459. EFI_STATUS
  460. Ip6ProcessNeighborAdvertise (
  461. IN IP6_SERVICE *IpSb,
  462. IN EFI_IP6_HEADER *Head,
  463. IN NET_BUF *Packet
  464. );
  465. /**
  466. Process the Router Advertisement message according to RFC4861.
  467. @param[in] IpSb The IP service that received the packet.
  468. @param[in] Head The IP head of the message.
  469. @param[in] Packet The content of the message with the IP head removed.
  470. @retval EFI_SUCCESS The packet processed successfully.
  471. @retval EFI_INVALID_PARAMETER The packet is invalid.
  472. @retval EFI_OUT_OF_RESOURCES Insufficient resources to complete the operation.
  473. @retval Others Failed to process the packet.
  474. **/
  475. EFI_STATUS
  476. Ip6ProcessRouterAdvertise (
  477. IN IP6_SERVICE *IpSb,
  478. IN EFI_IP6_HEADER *Head,
  479. IN NET_BUF *Packet
  480. );
  481. /**
  482. Process the ICMPv6 redirect message. Find the instance, then update
  483. its route cache.
  484. @param[in] IpSb The IP6 service binding instance that received
  485. the packet.
  486. @param[in] Head The IP head of the received ICMPv6 packet.
  487. @param[in] Packet The content of the ICMPv6 redirect packet with
  488. the IP head removed.
  489. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  490. @retval EFI_OUT_OF_RESOURCES Insufficient resources to complete the
  491. operation.
  492. @retval EFI_SUCCESS Successfully updated the route caches.
  493. **/
  494. EFI_STATUS
  495. Ip6ProcessRedirect (
  496. IN IP6_SERVICE *IpSb,
  497. IN EFI_IP6_HEADER *Head,
  498. IN NET_BUF *Packet
  499. );
  500. /**
  501. Generate router solicit message and send it out to Destination Address or
  502. All Router Link Local scope multicast address.
  503. @param[in] IpSb The IP service to send the packet.
  504. @param[in] Interface If not NULL, points to the IP6 interface to send
  505. the packet.
  506. @param[in] SourceAddress If not NULL, the source address of the message.
  507. @param[in] DestinationAddress If not NULL, the destination address of the message.
  508. @param[in] SourceLinkAddress If not NULL, the MAC address of the source.
  509. A source link-layer address option will be appended
  510. to the message.
  511. @retval EFI_OUT_OF_RESOURCES Insufficient resources to complete the operation.
  512. @retval EFI_SUCCESS The router solicit message was successfully sent.
  513. **/
  514. EFI_STATUS
  515. Ip6SendRouterSolicit (
  516. IN IP6_SERVICE *IpSb,
  517. IN IP6_INTERFACE *Interface OPTIONAL,
  518. IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
  519. IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL,
  520. IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
  521. );
  522. /**
  523. Generate the Neighbor Solicitation message and send it to the Destination Address.
  524. @param[in] IpSb The IP service to send the packet
  525. @param[in] SourceAddress The source address of the message.
  526. @param[in] DestinationAddress The destination address of the message.
  527. @param[in] TargetIp6Address The IP address of the target of the solicitation.
  528. It must not be a multicast address.
  529. @param[in] SourceLinkAddress The MAC address for the sender. If not NULL,
  530. a source link-layer address option will be appended
  531. to the message.
  532. @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
  533. @retval EFI_OUT_OF_RESOURCES Insufficient resources to complete the
  534. operation.
  535. @retval EFI_SUCCESS The Neighbor Advertise message was successfully sent.
  536. **/
  537. EFI_STATUS
  538. Ip6SendNeighborSolicit (
  539. IN IP6_SERVICE *IpSb,
  540. IN EFI_IPv6_ADDRESS *SourceAddress,
  541. IN EFI_IPv6_ADDRESS *DestinationAddress,
  542. IN EFI_IPv6_ADDRESS *TargetIp6Address,
  543. IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
  544. );
  545. /**
  546. Set the interface's address. This will trigger the DAD process for the
  547. address to set. To set an already set address, the lifetimes wil be
  548. updated to the new value passed in.
  549. @param[in] Interface The interface to set the address.
  550. @param[in] Ip6Addr The interface's to be assigned IPv6 address.
  551. @param[in] IsAnycast If TRUE, the unicast IPv6 address is anycast.
  552. Otherwise, it is not anycast.
  553. @param[in] PrefixLength The prefix length of the Ip6Addr.
  554. @param[in] ValidLifetime The valid lifetime for this address.
  555. @param[in] PreferredLifetime The preferred lifetime for this address.
  556. @param[in] DadCallback The caller's callback to trigger when DAD finishes.
  557. This is an optional parameter that may be NULL.
  558. @param[in] Context The context that will be passed to DadCallback.
  559. This is an optional parameter that may be NULL.
  560. @retval EFI_SUCCESS The interface is scheduled to be configured with
  561. the specified address.
  562. @retval EFI_OUT_OF_RESOURCES Failed to set the interface's address due to
  563. lack of resources.
  564. **/
  565. EFI_STATUS
  566. Ip6SetAddress (
  567. IN IP6_INTERFACE *Interface,
  568. IN EFI_IPv6_ADDRESS *Ip6Addr,
  569. IN BOOLEAN IsAnycast,
  570. IN UINT8 PrefixLength,
  571. IN UINT32 ValidLifetime,
  572. IN UINT32 PreferredLifetime,
  573. IN IP6_DAD_CALLBACK DadCallback OPTIONAL,
  574. IN VOID *Context OPTIONAL
  575. );
  576. /**
  577. The heartbeat timer of ND module in IP6_TIMER_INTERVAL_IN_MS milliseconds.
  578. This time routine handles DAD module and neighbor state transition.
  579. It is also responsible for sending out router solicitations.
  580. @param[in] Event The IP6 service instance's heartbeat timer.
  581. @param[in] Context The IP6 service instance.
  582. **/
  583. VOID
  584. EFIAPI
  585. Ip6NdFasterTimerTicking (
  586. IN EFI_EVENT Event,
  587. IN VOID *Context
  588. );
  589. /**
  590. The heartbeat timer of ND module in 1 second. This time routine handles following
  591. things: 1) maintain default router list; 2) maintain prefix options;
  592. 3) maintain route caches.
  593. @param[in] IpSb The IP6 service binding instance.
  594. **/
  595. VOID
  596. Ip6NdTimerTicking (
  597. IN IP6_SERVICE *IpSb
  598. );
  599. /**
  600. Callback function when address resolution is finished. It will cancel
  601. all the queued frames if the address resolution failed, or transmit them
  602. if the request succeeded.
  603. @param[in] Context The context of the callback, a pointer to IP6_NEIGHBOR_ENTRY.
  604. **/
  605. VOID
  606. Ip6OnArpResolved (
  607. IN VOID *Context
  608. );
  609. /**
  610. Update the ReachableTime in IP6 service binding instance data, in milliseconds.
  611. @param[in, out] IpSb Points to the IP6_SERVICE.
  612. **/
  613. VOID
  614. Ip6UpdateReachableTime (
  615. IN OUT IP6_SERVICE *IpSb
  616. );
  617. #endif