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