2 Multicast Listener Discovery support routines.
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 Create a IP6_MLD_GROUP list entry node and record to IP6 service binding data.
15 @param[in, out] IpSb Points to IP6 service binding instance.
16 @param[in] MulticastAddr The IPv6 multicast address to be recorded.
17 @param[in] DelayTimer The maximum allowed delay before sending a responding
18 report, in units of milliseconds.
19 @return The created IP6_ML_GROUP list entry or NULL.
24 IN OUT IP6_SERVICE
*IpSb
,
25 IN EFI_IPv6_ADDRESS
*MulticastAddr
,
31 NET_CHECK_SIGNATURE (IpSb
, IP6_SERVICE_SIGNATURE
);
32 ASSERT (MulticastAddr
!= NULL
&& IP6_IS_MULTICAST (MulticastAddr
));
34 Entry
= AllocatePool (sizeof (IP6_MLD_GROUP
));
37 Entry
->DelayTimer
= DelayTimer
;
38 Entry
->SendByUs
= FALSE
;
39 IP6_COPY_ADDRESS (&Entry
->Address
, MulticastAddr
);
40 InsertTailList (&IpSb
->MldCtrl
.Groups
, &Entry
->Link
);
47 Search a IP6_MLD_GROUP list entry node from a list array.
49 @param[in] IpSb Points to IP6 service binding instance.
50 @param[in] MulticastAddr The IPv6 multicast address to be searched.
52 @return The found IP6_ML_GROUP list entry or NULL.
58 IN EFI_IPv6_ADDRESS
*MulticastAddr
64 NET_CHECK_SIGNATURE (IpSb
, IP6_SERVICE_SIGNATURE
);
65 ASSERT (MulticastAddr
!= NULL
&& IP6_IS_MULTICAST (MulticastAddr
));
67 NET_LIST_FOR_EACH (Entry
, &IpSb
->MldCtrl
.Groups
) {
68 Group
= NET_LIST_USER_STRUCT (Entry
, IP6_MLD_GROUP
, Link
);
69 if (EFI_IP6_EQUAL (MulticastAddr
, &Group
->Address
)) {
78 Count the number of IP6 multicast groups that are mapped to the
79 same MAC address. Several IP6 multicast address may be mapped to
82 @param[in] MldCtrl The MLD control block to search in.
83 @param[in] Mac The MAC address to search.
85 @return The number of the IP6 multicast group that mapped to the same
91 IN IP6_MLD_SERVICE_DATA
*MldCtrl
,
92 IN EFI_MAC_ADDRESS
*Mac
101 NET_LIST_FOR_EACH (Entry
, &MldCtrl
->Groups
) {
102 Group
= NET_LIST_USER_STRUCT (Entry
, IP6_MLD_GROUP
, Link
);
104 if (NET_MAC_EQUAL (&Group
->Mac
, Mac
, sizeof (EFI_MAC_ADDRESS
))) {
113 Generate MLD report message and send it out to MulticastAddr.
115 @param[in] IpSb The IP service to send the packet.
116 @param[in] Interface The IP interface to send the packet.
117 If NULL, a system interface will be selected.
118 @param[in] MulticastAddr The specific IPv6 multicast address to which
119 the message sender is listening.
121 @retval EFI_OUT_OF_RESOURCES There are not sufficient resources to complete the
123 @retval EFI_SUCCESS The MLD report message was successfully sent out.
128 IN IP6_SERVICE
*IpSb
,
129 IN IP6_INTERFACE
*Interface OPTIONAL
,
130 IN EFI_IPv6_ADDRESS
*MulticastAddr
133 IP6_MLD_HEAD
*MldHead
;
141 UINT16 PseudoChecksum
;
143 NET_CHECK_SIGNATURE (IpSb
, IP6_SERVICE_SIGNATURE
);
144 ASSERT (MulticastAddr
!= NULL
&& IP6_IS_MULTICAST (MulticastAddr
));
147 // Generate the packet to be sent
148 // IPv6 basic header + Hop by Hop option + MLD message
152 Status
= Ip6FillHopByHop (NULL
, &OptionLen
, IP6_ICMP
);
153 ASSERT (Status
== EFI_BUFFER_TOO_SMALL
);
155 PayloadLen
= (UINT16
)(OptionLen
+ sizeof (IP6_MLD_HEAD
));
156 Packet
= NetbufAlloc (sizeof (EFI_IP6_HEADER
) + (UINT32
)PayloadLen
);
157 if (Packet
== NULL
) {
158 return EFI_OUT_OF_RESOURCES
;
162 // Create the basic IPv6 header.
163 // RFC3590: Use link-local address as source address if it is available,
164 // otherwise use the unspecified address.
168 Head
.PayloadLength
= HTONS (PayloadLen
);
169 Head
.NextHeader
= IP6_HOP_BY_HOP
;
171 IP6_COPY_ADDRESS (&Head
.DestinationAddress
, MulticastAddr
);
174 // If Link-Local address is not ready, we use unspecified address.
176 IP6_COPY_ADDRESS (&Head
.SourceAddress
, &IpSb
->LinkLocalAddr
);
178 NetbufReserve (Packet
, sizeof (EFI_IP6_HEADER
));
181 // Fill a IPv6 Router Alert option in a Hop-by-Hop Options Header
183 Options
= NetbufAllocSpace (Packet
, (UINT32
)OptionLen
, FALSE
);
184 ASSERT (Options
!= NULL
);
185 Status
= Ip6FillHopByHop (Options
, &OptionLen
, IP6_ICMP
);
186 if (EFI_ERROR (Status
)) {
193 // Fill in MLD message - Report
195 MldHead
= (IP6_MLD_HEAD
*)NetbufAllocSpace (Packet
, sizeof (IP6_MLD_HEAD
), FALSE
);
196 ASSERT (MldHead
!= NULL
);
197 ZeroMem (MldHead
, sizeof (IP6_MLD_HEAD
));
198 MldHead
->Head
.Type
= ICMP_V6_LISTENER_REPORT
;
199 MldHead
->Head
.Code
= 0;
200 IP6_COPY_ADDRESS (&MldHead
->Group
, MulticastAddr
);
202 HeadChecksum
= NetblockChecksum ((UINT8
*)MldHead
, sizeof (IP6_MLD_HEAD
));
203 PseudoChecksum
= NetIp6PseudoHeadChecksum (
205 &Head
.DestinationAddress
,
207 sizeof (IP6_MLD_HEAD
)
210 MldHead
->Head
.Checksum
= (UINT16
) ~NetAddChecksum (HeadChecksum
, PseudoChecksum
);
213 // Transmit the packet
215 return Ip6Output (IpSb
, Interface
, NULL
, Packet
, &Head
, NULL
, 0, Ip6SysPacketSent
, NULL
);
219 Generate MLD Done message and send it out to MulticastAddr.
221 @param[in] IpSb The IP service to send the packet.
222 @param[in] MulticastAddr The specific IPv6 multicast address to which
223 the message sender is ceasing to listen.
225 @retval EFI_OUT_OF_RESOURCES There are not sufficient resources to complete the
227 @retval EFI_SUCCESS The MLD report message was successfully sent out.
232 IN IP6_SERVICE
*IpSb
,
233 IN EFI_IPv6_ADDRESS
*MulticastAddr
236 IP6_MLD_HEAD
*MldHead
;
243 EFI_IPv6_ADDRESS Destination
;
245 UINT16 PseudoChecksum
;
247 NET_CHECK_SIGNATURE (IpSb
, IP6_SERVICE_SIGNATURE
);
248 ASSERT (MulticastAddr
!= NULL
&& IP6_IS_MULTICAST (MulticastAddr
));
251 // Generate the packet to be sent
252 // IPv6 basic header + Hop by Hop option + MLD message
256 Status
= Ip6FillHopByHop (NULL
, &OptionLen
, IP6_ICMP
);
257 ASSERT (Status
== EFI_BUFFER_TOO_SMALL
);
259 PayloadLen
= (UINT16
)(OptionLen
+ sizeof (IP6_MLD_HEAD
));
260 Packet
= NetbufAlloc (sizeof (EFI_IP6_HEADER
) + (UINT32
)PayloadLen
);
261 if (Packet
== NULL
) {
262 return EFI_OUT_OF_RESOURCES
;
266 // Create the basic IPv6 header.
270 Head
.PayloadLength
= HTONS (PayloadLen
);
271 Head
.NextHeader
= IP6_HOP_BY_HOP
;
275 // If Link-Local address is not ready, we use unspecified address.
277 IP6_COPY_ADDRESS (&Head
.SourceAddress
, &IpSb
->LinkLocalAddr
);
279 Ip6SetToAllNodeMulticast (TRUE
, IP6_LINK_LOCAL_SCOPE
, &Destination
);
280 IP6_COPY_ADDRESS (&Head
.DestinationAddress
, &Destination
);
282 NetbufReserve (Packet
, sizeof (EFI_IP6_HEADER
));
285 // Fill a IPv6 Router Alert option in a Hop-by-Hop Options Header
287 Options
= NetbufAllocSpace (Packet
, (UINT32
)OptionLen
, FALSE
);
288 ASSERT (Options
!= NULL
);
289 Status
= Ip6FillHopByHop (Options
, &OptionLen
, IP6_ICMP
);
290 if (EFI_ERROR (Status
)) {
297 // Fill in MLD message - Done
299 MldHead
= (IP6_MLD_HEAD
*)NetbufAllocSpace (Packet
, sizeof (IP6_MLD_HEAD
), FALSE
);
300 ASSERT (MldHead
!= NULL
);
301 ZeroMem (MldHead
, sizeof (IP6_MLD_HEAD
));
302 MldHead
->Head
.Type
= ICMP_V6_LISTENER_DONE
;
303 MldHead
->Head
.Code
= 0;
304 IP6_COPY_ADDRESS (&MldHead
->Group
, MulticastAddr
);
306 HeadChecksum
= NetblockChecksum ((UINT8
*)MldHead
, sizeof (IP6_MLD_HEAD
));
307 PseudoChecksum
= NetIp6PseudoHeadChecksum (
309 &Head
.DestinationAddress
,
311 sizeof (IP6_MLD_HEAD
)
314 MldHead
->Head
.Checksum
= (UINT16
) ~NetAddChecksum (HeadChecksum
, PseudoChecksum
);
317 // Transmit the packet
319 return Ip6Output (IpSb
, NULL
, NULL
, Packet
, &Head
, NULL
, 0, Ip6SysPacketSent
, NULL
);
323 Init the MLD data of the IP6 service instance. Configure
324 MNP to receive ALL SYSTEM multicast.
326 @param[in] IpSb The IP6 service whose MLD is to be initialized.
328 @retval EFI_OUT_OF_RESOURCES There are not sufficient resourcet to complete the
330 @retval EFI_SUCCESS The MLD module successfully initialized.
338 EFI_IPv6_ADDRESS AllNodes
;
339 IP6_MLD_GROUP
*Group
;
343 // Join the link-scope all-nodes multicast address (FF02::1).
344 // This address is started in Idle Listener state and never transitions to
345 // another state, and never sends a Report or Done for that address.
348 Ip6SetToAllNodeMulticast (FALSE
, IP6_LINK_LOCAL_SCOPE
, &AllNodes
);
350 Group
= Ip6CreateMldEntry (IpSb
, &AllNodes
, (UINT32
)IP6_INFINIT_LIFETIME
);
352 return EFI_OUT_OF_RESOURCES
;
355 Status
= Ip6GetMulticastMac (IpSb
->Mnp
, &AllNodes
, &Group
->Mac
);
356 if (EFI_ERROR (Status
)) {
361 // Configure MNP to receive all-nodes multicast
363 Status
= IpSb
->Mnp
->Groups (IpSb
->Mnp
, TRUE
, &Group
->Mac
);
364 if (EFI_ERROR (Status
) && (Status
!= EFI_ALREADY_STARTED
)) {
371 RemoveEntryList (&Group
->Link
);
377 Add a group address to the array of group addresses.
378 The caller should make sure that no duplicated address
379 existed in the array.
381 @param[in, out] IpInstance Points to an IP6_PROTOCOL instance.
382 @param[in] Group The IP6 multicast address to add.
384 @retval EFI_OUT_OF_RESOURCES There are not sufficient resources to complete
386 @retval EFI_SUCCESS The address is added to the group address array.
391 IN OUT IP6_PROTOCOL
*IpInstance
,
392 IN EFI_IPv6_ADDRESS
*Group
395 EFI_IPv6_ADDRESS
*GroupList
;
397 NET_CHECK_SIGNATURE (IpInstance
, IP6_PROTOCOL_SIGNATURE
);
398 ASSERT (Group
!= NULL
&& IP6_IS_MULTICAST (Group
));
400 IpInstance
->GroupCount
++;
402 GroupList
= AllocatePool (IpInstance
->GroupCount
* sizeof (EFI_IPv6_ADDRESS
));
403 if (GroupList
== NULL
) {
404 return EFI_OUT_OF_RESOURCES
;
407 if (IpInstance
->GroupCount
> 1) {
408 ASSERT (IpInstance
->GroupList
!= NULL
);
412 IpInstance
->GroupList
,
413 (IpInstance
->GroupCount
- 1) * sizeof (EFI_IPv6_ADDRESS
)
416 FreePool (IpInstance
->GroupList
);
419 IP6_COPY_ADDRESS (GroupList
+ (IpInstance
->GroupCount
- 1), Group
);
421 IpInstance
->GroupList
= GroupList
;
427 Remove a group address from the array of group addresses.
428 Although the function doesn't assume the byte order of Group,
429 the network byte order is used by the caller.
431 @param[in, out] IpInstance Points to an IP6_PROTOCOL instance.
432 @param[in] Group The IP6 multicast address to remove.
434 @retval EFI_NOT_FOUND Cannot find the to be removed group address.
435 @retval EFI_SUCCESS The group address was successfully removed.
440 IN OUT IP6_PROTOCOL
*IpInstance
,
441 IN EFI_IPv6_ADDRESS
*Group
447 Count
= IpInstance
->GroupCount
;
449 for (Index
= 0; Index
< Count
; Index
++) {
450 if (EFI_IP6_EQUAL (IpInstance
->GroupList
+ Index
, Group
)) {
455 if (Index
== Count
) {
456 return EFI_NOT_FOUND
;
459 while (Index
< Count
- 1) {
460 IP6_COPY_ADDRESS (IpInstance
->GroupList
+ Index
, IpInstance
->GroupList
+ Index
+ 1);
464 ASSERT (IpInstance
->GroupCount
> 0);
465 IpInstance
->GroupCount
--;
471 Join the multicast group on behalf of this IP6 service binding instance.
473 @param[in] IpSb The IP6 service binding instance.
474 @param[in] Interface Points to an IP6_INTERFACE structure.
475 @param[in] Address The group address to join.
477 @retval EFI_SUCCESS Successfully join the multicast group.
478 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
479 @retval Others Failed to join the multicast group.
484 IN IP6_SERVICE
*IpSb
,
485 IN IP6_INTERFACE
*Interface
,
486 IN EFI_IPv6_ADDRESS
*Address
489 IP6_MLD_GROUP
*Group
;
492 Group
= Ip6FindMldEntry (IpSb
, Address
);
499 // Repeat the report once or twice after short delays [Unsolicited Report Interval] (default:10s)
500 // Simulate this operation as a Multicast-Address-Specific Query was received for that address.
502 Group
= Ip6CreateMldEntry (IpSb
, Address
, IP6_UNSOLICITED_REPORT_INTERVAL
);
504 return EFI_OUT_OF_RESOURCES
;
507 Group
->SendByUs
= TRUE
;
509 Status
= Ip6GetMulticastMac (IpSb
->Mnp
, Address
, &Group
->Mac
);
510 if (EFI_ERROR (Status
)) {
514 Status
= IpSb
->Mnp
->Groups (IpSb
->Mnp
, TRUE
, &Group
->Mac
);
515 if (EFI_ERROR (Status
) && (Status
!= EFI_ALREADY_STARTED
)) {
520 // Send unsolicited report when a node starts listening to a multicast address
522 Status
= Ip6SendMldReport (IpSb
, Interface
, Address
);
523 if (EFI_ERROR (Status
)) {
530 RemoveEntryList (&Group
->Link
);
536 Leave the IP6 multicast group.
538 @param[in] IpSb The IP6 service binding instance.
539 @param[in] Address The group address to leave.
541 @retval EFI_NOT_FOUND The IP6 service instance isn't in the group.
542 @retval EFI_SUCCESS Successfully leave the multicast group..
543 @retval Others Failed to leave the multicast group.
548 IN IP6_SERVICE
*IpSb
,
549 IN EFI_IPv6_ADDRESS
*Address
552 IP6_MLD_GROUP
*Group
;
555 Group
= Ip6FindMldEntry (IpSb
, Address
);
557 return EFI_NOT_FOUND
;
561 // If more than one instance is in the group, decrease
562 // the RefCnt then return.
564 if ((Group
->RefCnt
> 0) && (--Group
->RefCnt
> 0)) {
569 // If multiple IP6 group addresses are mapped to the same
570 // multicast MAC address, don't configure the MNP to leave
573 if (Ip6FindMac (&IpSb
->MldCtrl
, &Group
->Mac
) == 1) {
574 Status
= IpSb
->Mnp
->Groups (IpSb
->Mnp
, FALSE
, &Group
->Mac
);
575 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
581 // Send a leave report if we are the last node to report
583 if (Group
->SendByUs
) {
584 Status
= Ip6SendMldDone (IpSb
, Address
);
585 if (EFI_ERROR (Status
)) {
590 RemoveEntryList (&Group
->Link
);
597 Worker function for EfiIp6Groups(). The caller
598 should make sure that the parameters are valid.
600 @param[in] IpInstance The IP6 child to change the setting.
601 @param[in] JoinFlag TRUE to join the group, otherwise leave it.
602 @param[in] GroupAddress The target group address. If NULL, leave all
605 @retval EFI_ALREADY_STARTED Wants to join the group, but is already a member of it
606 @retval EFI_OUT_OF_RESOURCES Failed to allocate sufficient resources.
607 @retval EFI_DEVICE_ERROR Failed to set the group configuration.
608 @retval EFI_SUCCESS Successfully updated the group setting.
609 @retval EFI_NOT_FOUND Try to leave the group which it isn't a member.
614 IN IP6_PROTOCOL
*IpInstance
,
616 IN EFI_IPv6_ADDRESS
*GroupAddress OPTIONAL
622 EFI_IPv6_ADDRESS
*Group
;
624 IpSb
= IpInstance
->Service
;
627 ASSERT (GroupAddress
!= NULL
);
629 for (Index
= 0; Index
< IpInstance
->GroupCount
; Index
++) {
630 if (EFI_IP6_EQUAL (IpInstance
->GroupList
+ Index
, GroupAddress
)) {
631 return EFI_ALREADY_STARTED
;
635 Status
= Ip6JoinGroup (IpSb
, IpInstance
->Interface
, GroupAddress
);
636 if (!EFI_ERROR (Status
)) {
637 return Ip6CombineGroups (IpInstance
, GroupAddress
);
644 // Leave the group. Leave all the groups if GroupAddress is NULL.
646 for (Index
= IpInstance
->GroupCount
; Index
> 0; Index
--) {
647 Group
= IpInstance
->GroupList
+ (Index
- 1);
649 if ((GroupAddress
== NULL
) || EFI_IP6_EQUAL (Group
, GroupAddress
)) {
650 Status
= Ip6LeaveGroup (IpInstance
->Service
, Group
);
651 if (EFI_ERROR (Status
)) {
655 Ip6RemoveGroup (IpInstance
, Group
);
657 if (IpInstance
->GroupCount
== 0) {
659 FreePool (IpInstance
->GroupList
);
660 IpInstance
->GroupList
= NULL
;
663 if (GroupAddress
!= NULL
) {
669 return ((GroupAddress
!= NULL
) ? EFI_NOT_FOUND
: EFI_SUCCESS
);
673 Set a random value of the delay timer for the multicast address from the range
674 [0, Maximum Response Delay]. If a timer for any address is already
675 running, it is reset to the new random value only if the requested
676 Maximum Response Delay is less than the remaining value of the
677 running timer. If the Query packet specifies a Maximum Response
678 Delay of zero, each timer is effectively set to zero, and the action
679 specified below for timer expiration is performed immediately.
681 @param[in] IpSb The IP6 service binding instance.
682 @param[in] MaxRespDelay The Maximum Response Delay, in milliseconds.
683 @param[in] MulticastAddr The multicast address.
684 @param[in, out] Group Points to a IP6_MLD_GROUP list entry node.
686 @retval EFI_SUCCESS The delay timer is successfully updated or
687 timer expiration is performed immediately.
688 @retval Others Failed to send out MLD report message.
692 Ip6UpdateDelayTimer (
693 IN IP6_SERVICE
*IpSb
,
694 IN UINT16 MaxRespDelay
,
695 IN EFI_IPv6_ADDRESS
*MulticastAddr
,
696 IN OUT IP6_MLD_GROUP
*Group
702 // If the Query packet specifies a Maximum Response Delay of zero, perform timer
703 // expiration immediately.
705 if (MaxRespDelay
== 0) {
706 Group
->DelayTimer
= 0;
707 return Ip6SendMldReport (IpSb
, NULL
, MulticastAddr
);
710 Delay
= (UINT32
)(MaxRespDelay
/ 1000);
713 // Sets a delay timer to a random value selected from the range [0, Maximum Response Delay]
714 // If a timer is already running, resets it if the request Maximum Response Delay
715 // is less than the remaining value of the running timer.
717 if ((Group
->DelayTimer
== 0) || (Delay
< Group
->DelayTimer
)) {
718 Group
->DelayTimer
= Delay
/ 4294967295UL * NET_RANDOM (NetRandomInitSeed ());
725 Process the Multicast Listener Query message.
727 @param[in] IpSb The IP service that received the packet.
728 @param[in] Head The IP head of the MLD query packet.
729 @param[in] Packet The content of the MLD query packet with IP head
732 @retval EFI_SUCCESS The MLD query packet processed successfully.
733 @retval EFI_INVALID_PARAMETER The packet is invalid.
734 @retval Others Failed to process the packet.
739 IN IP6_SERVICE
*IpSb
,
740 IN EFI_IP6_HEADER
*Head
,
744 EFI_IPv6_ADDRESS AllNodes
;
745 IP6_MLD_GROUP
*Group
;
746 IP6_MLD_HEAD MldPacket
;
750 Status
= EFI_INVALID_PARAMETER
;
753 // Check the validity of the packet, generic query or specific query
755 if (!NetIp6IsUnspecifiedAddr (&Head
->SourceAddress
) && !NetIp6IsLinkLocalAddr (&Head
->SourceAddress
)) {
759 if ((Head
->HopLimit
!= 1) || !IP6_IS_MULTICAST (&Head
->DestinationAddress
)) {
764 // The Packet points to MLD report raw data without Hop-By-Hop option.
766 NetbufCopy (Packet
, 0, sizeof (IP6_MLD_HEAD
), (UINT8
*)&MldPacket
);
767 MldPacket
.MaxRespDelay
= NTOHS (MldPacket
.MaxRespDelay
);
769 Ip6SetToAllNodeMulticast (FALSE
, IP6_LINK_LOCAL_SCOPE
, &AllNodes
);
770 if (!EFI_IP6_EQUAL (&Head
->DestinationAddress
, &AllNodes
)) {
772 // Receives a Multicast-Address-Specific Query, check it firstly
774 if (!EFI_IP6_EQUAL (&Head
->DestinationAddress
, &MldPacket
.Group
)) {
779 // The node is not listening but it receives the specific query. Just return.
781 Group
= Ip6FindMldEntry (IpSb
, &MldPacket
.Group
);
783 Status
= EFI_SUCCESS
;
787 Status
= Ip6UpdateDelayTimer (
789 MldPacket
.MaxRespDelay
,
797 // Receives a General Query, sets a delay timer for each multicast address it is listening
799 NET_LIST_FOR_EACH (Entry
, &IpSb
->MldCtrl
.Groups
) {
800 Group
= NET_LIST_USER_STRUCT (Entry
, IP6_MLD_GROUP
, Link
);
801 Status
= Ip6UpdateDelayTimer (IpSb
, MldPacket
.MaxRespDelay
, &Group
->Address
, Group
);
802 if (EFI_ERROR (Status
)) {
807 Status
= EFI_SUCCESS
;
815 Process the Multicast Listener Report message.
817 @param[in] IpSb The IP service that received the packet.
818 @param[in] Head The IP head of the MLD report packet.
819 @param[in] Packet The content of the MLD report packet with IP head
822 @retval EFI_SUCCESS The MLD report packet processed successfully.
823 @retval EFI_INVALID_PARAMETER The packet is invalid.
827 Ip6ProcessMldReport (
828 IN IP6_SERVICE
*IpSb
,
829 IN EFI_IP6_HEADER
*Head
,
833 IP6_MLD_HEAD MldPacket
;
834 IP6_MLD_GROUP
*Group
;
837 Status
= EFI_INVALID_PARAMETER
;
840 // Validate the incoming message, if invalid, drop it.
842 if (!NetIp6IsUnspecifiedAddr (&Head
->SourceAddress
) && !NetIp6IsLinkLocalAddr (&Head
->SourceAddress
)) {
846 if ((Head
->HopLimit
!= 1) || !IP6_IS_MULTICAST (&Head
->DestinationAddress
)) {
851 // The Packet points to MLD report raw data without Hop-By-Hop option.
853 NetbufCopy (Packet
, 0, sizeof (IP6_MLD_HEAD
), (UINT8
*)&MldPacket
);
854 if (!EFI_IP6_EQUAL (&Head
->DestinationAddress
, &MldPacket
.Group
)) {
858 Group
= Ip6FindMldEntry (IpSb
, &MldPacket
.Group
);
864 // The report is sent by another node, stop its own timer relates to the multicast address and clear
867 if (!Group
->SendByUs
) {
868 Group
->DelayTimer
= 0;
871 Status
= EFI_SUCCESS
;
879 The heartbeat timer of MLD module. It sends out a solicited MLD report when
882 @param[in] IpSb The IP6 service binding instance.
890 IP6_MLD_GROUP
*Group
;
894 // Send solicited report when timer expires
896 NET_LIST_FOR_EACH (Entry
, &IpSb
->MldCtrl
.Groups
) {
897 Group
= NET_LIST_USER_STRUCT (Entry
, IP6_MLD_GROUP
, Link
);
898 if ((Group
->DelayTimer
> 0) && (--Group
->DelayTimer
== 0)) {
899 Ip6SendMldReport (IpSb
, NULL
, &Group
->Address
);