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