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_igmp.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _nx_igmp_info_get PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function retrieves various IGMP information associated with */
44 /* the specified IP instance. */
45 /* */
46 /* INPUT */
47 /* */
48 /* ip_ptr IP instance pointer */
49 /* igmp_reports_sent Destination for the number */
50 /* of IGMP reports sent */
51 /* igmp_queries_received Destination for the number */
52 /* of IGMP queries received */
53 /* igmp_checksum_errors Destination for the number */
54 /* of IGMP checksum errors */
55 /* current_groups_joined Destination for the number */
56 /* of IGMP multicast groups */
57 /* currently joined */
58 /* */
59 /* OUTPUT */
60 /* */
61 /* status Completion status */
62 /* */
63 /* CALLS */
64 /* */
65 /* tx_mutex_get Obtain protection mutex */
66 /* tx_mutex_put Release protection mutex */
67 /* */
68 /* CALLED BY */
69 /* */
70 /* Application Code */
71 /* */
72 /* RELEASE HISTORY */
73 /* */
74 /* DATE NAME DESCRIPTION */
75 /* */
76 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
77 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
78 /* resulting in version 6.1 */
79 /* */
80 /**************************************************************************/
_nx_igmp_info_get(NX_IP * ip_ptr,ULONG * igmp_reports_sent,ULONG * igmp_queries_received,ULONG * igmp_checksum_errors,ULONG * current_groups_joined)81 UINT _nx_igmp_info_get(NX_IP *ip_ptr, ULONG *igmp_reports_sent, ULONG *igmp_queries_received,
82 ULONG *igmp_checksum_errors, ULONG *current_groups_joined)
83 {
84
85 #ifndef NX_DISABLE_IPV4
86
87
88 /* If trace is enabled, insert this event into the trace buffer. */
89 NX_TRACE_IN_LINE_INSERT(NX_TRACE_IGMP_INFO_GET, ip_ptr, ip_ptr -> nx_ip_igmp_reports_sent, ip_ptr -> nx_ip_igmp_queries_received, ip_ptr -> nx_ip_igmp_groups_joined, NX_TRACE_IGMP_EVENTS, 0, 0);
90
91 /* Obtain protection on this IP instance. */
92 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
93
94 /* Determine if IGMP reports sent is wanted. */
95 if (igmp_reports_sent)
96 {
97
98 /* Return the number of IGMP reports sent by this IP instance. */
99 *igmp_reports_sent = ip_ptr -> nx_ip_igmp_reports_sent;
100 }
101
102 /* Determine if IGMP queries received is wanted. */
103 if (igmp_queries_received)
104 {
105
106 /* Return the number of IGMP queries received by this IP instance. */
107 *igmp_queries_received = ip_ptr -> nx_ip_igmp_queries_received;
108 }
109
110 /* Determine if IGMP checksum errors is wanted. */
111 if (igmp_checksum_errors)
112 {
113
114 /* Return the number of IGMP checksum errors by this IP instance. */
115 *igmp_checksum_errors = ip_ptr -> nx_ip_igmp_checksum_errors;
116 }
117
118 /* Determine if the number of IGMP multicast groups joined is wanted. */
119 if (current_groups_joined)
120 {
121
122 /* Return the number of IGMP multicast groups joined is wanted. */
123 *current_groups_joined = ip_ptr -> nx_ip_igmp_groups_joined;
124 }
125
126 /* Release the protection. */
127 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
128
129 /* Return a successful status! */
130 return(NX_SUCCESS);
131 #else /* NX_DISABLE_IPV4 */
132 NX_PARAMETER_NOT_USED(ip_ptr);
133 NX_PARAMETER_NOT_USED(igmp_reports_sent);
134 NX_PARAMETER_NOT_USED(igmp_queries_received);
135 NX_PARAMETER_NOT_USED(igmp_checksum_errors);
136 NX_PARAMETER_NOT_USED(current_groups_joined);
137
138 return(NX_NOT_SUPPORTED);
139 #endif /* !NX_DISABLE_IPV4 */
140 }
141
142