1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** NetX Component                                                        */
16 /**                                                                       */
17 /**   Internet Protocol (IP)                                              */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define NX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "nx_api.h"
28 #ifdef FEATURE_NX_IPV6
29 #include "nx_ip.h"
30 #include "nx_ipv6.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _nx_ipv6_multicast_leave                            PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Yuxin Zhou, Microsoft Corporation                                   */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    Leave IPv6 multicast group. This is an internal function.  The      */
46 /*    caller must hold the IP protection (mutex).                         */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    ip_ptr                                IP instance pointer           */
51 /*    multicast_address                     IPv6 multicast address        */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    status                                Completion status             */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    tx_mutex_get                          Obtain protection mutex       */
60 /*    tx_mutex_put                          Release protection mutex      */
61 /*    (ip_link_driver)                      Device driver entry point     */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    _nxd_ipv6_address_delete                                            */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
72 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
73 /*                                            resulting in version 6.1    */
74 /*                                                                        */
75 /**************************************************************************/
_nx_ipv6_multicast_leave(NX_IP * ip_ptr,ULONG * multicast_addr,NX_INTERFACE * nx_interface)76 UINT _nx_ipv6_multicast_leave(NX_IP *ip_ptr, ULONG *multicast_addr, NX_INTERFACE *nx_interface)
77 {
78 
79 NX_IP_DRIVER driver_request;
80 
81 
82     /* Construct a driver command. */
83     driver_request.nx_ip_driver_ptr = ip_ptr;
84     driver_request.nx_ip_driver_command = NX_LINK_MULTICAST_LEAVE;
85     driver_request.nx_ip_driver_physical_address_msw = 0x00003333;
86     driver_request.nx_ip_driver_physical_address_lsw = multicast_addr[3];
87     driver_request.nx_ip_driver_interface = nx_interface;
88 
89     /* Obtain the IP mutex so we can search the multicast join list.  */
90     tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
91 
92 
93     /* Call the device driver with the driver request. */
94     (nx_interface -> nx_interface_link_driver_entry)(&driver_request);
95 
96     /* Release the protection over the IP instance.  */
97     tx_mutex_put(&(ip_ptr -> nx_ip_protection));
98 
99     /*lint -e{644} suppress variable might not be initialized, since "nx_ip_driver_status" was initialized in nx_interface_link_driver_entry. */
100     return(driver_request.nx_ip_driver_status);
101 }
102 #endif /* FEATURE_NX_IPV6 */
103 
104