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 Group Management Protocol (IGMP)                           */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define NX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "nx_api.h"
29 #include "nx_igmp.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _nx_igmp_loopback_disable                           PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function disables loopback for all subsequent IGMP groups      */
45 /*    joined by the host.                                                 */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    ip_ptr                                IP instance pointer           */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    None                                                                */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    Application Code                                                    */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
68 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*                                                                        */
71 /**************************************************************************/
_nx_igmp_loopback_disable(NX_IP * ip_ptr)72 UINT  _nx_igmp_loopback_disable(NX_IP *ip_ptr)
73 {
74 
75 #ifndef NX_DISABLE_IPV4
76 
77 
78     /* If trace is enabled, insert this event into the trace buffer.  */
79     NX_TRACE_IN_LINE_INSERT(NX_TRACE_IGMP_LOOPBACK_DISABLE, ip_ptr, 0, 0, 0, NX_TRACE_IGMP_EVENTS, 0, 0);
80 
81     /* Obtain the IP mutex so we can search the multicast join list.  */
82     tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
83 
84     /* Clear the global IGMP loopback flag.  All subsequent IGMP group join
85        requests will have loopback disabled.  */
86     ip_ptr -> nx_ip_igmp_global_loopback_enable =  NX_FALSE;
87 
88     /* Release the protection over the IP instance.  */
89     tx_mutex_put(&(ip_ptr -> nx_ip_protection));
90 
91     /* Return a successful status!  */
92     return(NX_SUCCESS);
93 #else /* NX_DISABLE_IPV4  */
94     NX_PARAMETER_NOT_USED(ip_ptr);
95 
96     return(NX_NOT_SUPPORTED);
97 #endif /* !NX_DISABLE_IPV4  */
98 }
99 
100