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 Group Management Protocol (IGMP)                           */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define NX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "nx_api.h"
28 #include "nx_ip.h"
29 #include "nx_igmp.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _nx_igmp_enable                                     PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function enables the IGMP management component for the         */
45 /*    specified IP instance.                                              */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    ip_ptr                                IP instance pointer           */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    tx_event_flags_set                    Set deferred IGMP enable      */
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_enable(NX_IP * ip_ptr)72 UINT  _nx_igmp_enable(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_ENABLE, ip_ptr, 0, 0, 0, NX_TRACE_IGMP_EVENTS, 0, 0);
80 
81 
82 #ifndef NX_DISABLE_IGMPV2
83 
84     /* Set the IGMP protocol to the default version supported by NetX, IGMPv2. */
85 
86     ip_ptr -> nx_ip_igmp_router_version = NX_IGMP_HOST_VERSION_2;
87 
88 #endif
89 
90     /* Setup the IGMP packet receive routine, which enables the IGMP component.  */
91     ip_ptr -> nx_ip_igmp_packet_receive =  _nx_igmp_packet_receive;
92 
93     /* Setup the IGMP periodic processing routine, which enables the IGMP component.  */
94     ip_ptr -> nx_ip_igmp_periodic_processing =  _nx_igmp_periodic_processing;
95 
96     /* Setup the IGMP queue processing routine, which processes deferred IGMP
97        requests.  */
98     ip_ptr -> nx_ip_igmp_queue_process =  _nx_igmp_queue_process;
99 
100     /* Wakeup IP helper thread to process the IGMP deferred enable.  */
101     tx_event_flags_set(&(ip_ptr -> nx_ip_events), NX_IP_IGMP_ENABLE_EVENT, TX_OR);
102 
103     /* Return a successful status!  */
104     return(NX_SUCCESS);
105 #else /* NX_DISABLE_IPV4  */
106     NX_PARAMETER_NOT_USED(ip_ptr);
107 
108     return(NX_NOT_SUPPORTED);
109 #endif /* !NX_DISABLE_IPV4  */
110 }
111 
112