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_join                             PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Yuxin Zhou, Microsoft Corporation                                   */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    Joins 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 /*    nx_icmpv6_process_ra                                                */
66 /*    nxd_ipv6_enable                                                     */
67 /*    nxd_ipv6_address_set                                                */
68 /*                                                                        */
69 /*  RELEASE HISTORY                                                       */
70 /*                                                                        */
71 /*    DATE              NAME                      DESCRIPTION             */
72 /*                                                                        */
73 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
74 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
75 /*                                            resulting in version 6.1    */
76 /*                                                                        */
77 /**************************************************************************/
_nx_ipv6_multicast_join(NX_IP * ip_ptr,ULONG * multicast_addr,NX_INTERFACE * nx_interface)78 UINT _nx_ipv6_multicast_join(NX_IP *ip_ptr, ULONG *multicast_addr, NX_INTERFACE *nx_interface)
79 {
80 
81 NX_IP_DRIVER driver_request;
82 
83 
84     /* Construct a driver command. */
85     driver_request.nx_ip_driver_ptr = ip_ptr;
86     driver_request.nx_ip_driver_command = NX_LINK_MULTICAST_JOIN;
87     driver_request.nx_ip_driver_physical_address_msw = 0x00003333;
88     driver_request.nx_ip_driver_physical_address_lsw = multicast_addr[3];
89     driver_request.nx_ip_driver_interface = nx_interface;
90 
91     /* Obtain the IP mutex so we can search the multicast join list.  */
92     tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
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