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 (IPv6)                                            */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 
22 #define NX_SOURCE_CODE
23 
24 /* Include necessary system files.  */
25 
26 #include "nx_api.h"
27 #include "nx_ipv6.h"
28 #if defined(NX_ENABLE_IPV6_MULTICAST) && defined(FEATURE_NX_IPV6)
29 #include "nx_ip.h"
30 
31 /* Bring in externs for caller checking code.  */
32 
33 NX_CALLER_CHECKING_EXTERNS
34 #endif /* NX_ENABLE_IPV6_MULTICAST && FEATURE_NX_IPV6 */
35 
36 /**************************************************************************/
37 /*                                                                        */
38 /*  FUNCTION                                               RELEASE        */
39 /*                                                                        */
40 /*    _nxde_ipv6_multicast_interface_leave                PORTABLE C      */
41 /*                                                           6.1          */
42 /*  AUTHOR                                                                */
43 /*                                                                        */
44 /*    Yuxin Zhou, Microsoft Corporation                                   */
45 /*                                                                        */
46 /*  DESCRIPTION                                                           */
47 /*                                                                        */
48 /*    This service checks for errors in the IPv6 multicast leave call.    */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    ip_ptr                                IP instance pointer           */
53 /*    group_address                         IPv6 multicast address        */
54 /*    interface_index                       Index to phyical interface    */
55 /*                                                                        */
56 /*  OUTPUT                                                                */
57 /*                                                                        */
58 /*    status                                Completion status             */
59 /*                                                                        */
60 /*  CALLS                                                                 */
61 /*                                                                        */
62 /*    IPv6_Address_Type                     Obtain IPv6 address type      */
63 /*    _nxd_ipv6_multicast_interface_leave   Actual IPv6 multicast leave   */
64 /*                                            function                    */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    Application                                                         */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
75 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_nxde_ipv6_multicast_interface_leave(NX_IP * ip_ptr,NXD_ADDRESS * group_address,UINT interface_index)79 UINT  _nxde_ipv6_multicast_interface_leave(NX_IP *ip_ptr, NXD_ADDRESS *group_address, UINT interface_index)
80 {
81 
82 #if defined(NX_ENABLE_IPV6_MULTICAST) && defined(FEATURE_NX_IPV6)
83 UINT status;
84 
85     /* Check for invalid input pointers.  */
86     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (group_address == NX_NULL))
87     {
88         return(NX_PTR_ERROR);
89     }
90 
91     /* Check for invalid input parameter.  */
92     if ((IPv6_Address_Type(group_address -> nxd_ip_address.v6) & IPV6_ADDRESS_MULTICAST) != IPV6_ADDRESS_MULTICAST)
93     {
94         return(NX_IP_ADDRESS_ERROR);
95     }
96 
97     /* Validate the interface. */
98     if (interface_index >= NX_MAX_PHYSICAL_INTERFACES)
99     {
100         return(NX_INVALID_INTERFACE);
101     }
102 
103     /* Check for appropriate caller.  */
104     NX_THREADS_ONLY_CALLER_CHECKING
105 
106     /* Call actual IPv6 enable function.  */
107     status =  _nxd_ipv6_multicast_interface_leave(ip_ptr, group_address, interface_index);
108 
109     /* Return completion status.  */
110     return(status);
111 
112 #else /* ! NX_ENABLE_IPV6_MULTICAST */
113     NX_PARAMETER_NOT_USED(ip_ptr);
114     NX_PARAMETER_NOT_USED(group_address);
115     NX_PARAMETER_NOT_USED(interface_index);
116 
117     return(NX_NOT_SUPPORTED);
118 
119 #endif /* NX_ENABLE_IPV6_MULTICAST && FEATURE_NX_IPV6 */
120 }
121 
122