RDK Documentation (Open Sourced RDK Components)
Device_IP_Interface_Stats.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 /**
20  * @file Device_IP_Interface_Stats.h
21  * @brief The header file provides TR069 device IP interface stats information APIs.
22  */
23 
24 /**
25  * @defgroup TR69_HOSTIF_DEVICE_IP_INTERFACE_STATS TR-069 Object (Device.IP.Interface.Stats)
26  * @par Throughput statistics for this interface.
27  * The CPE MUST reset the interface's Stats parameters unless otherwise stated in individual object
28  * or parameter descriptions either
29  * - when the interface becomes operationally down due to a previous administrative down
30  * i.e. the interface's Status parameter transitions to a down state after the interface is disabled or
31  * - when the interface becomes administratively up i.e. the interface's Enable parameter transitions
32  * from false to true.
33  * @ingroup TR69_HOSTIF_DEVICE_IP
34  *
35  * @defgroup TR69_HOSTIF_DEVICE_IP_INTERFACE_STATS_API TR-069 Object (Device.IP.Interface.Stats) Public APIs
36  * Describe the details about TR069 Device IP Interface stats APIs specifications.
37  * @ingroup TR69_HOSTIF_DEVICE_IP_INTERFACE_STATS
38  *
39  * @defgroup TR69_HOSTIF_DEVICE_IP_INTERFACE_STATS_CLASSES TR-069 Object (Device.IP.Interface.Stats) Public Classes
40  * Describe the details about classes used in TR069 Device IP Interface stats.
41  * @ingroup TR69_HOSTIF_DEVICE_IP_INTERFACE_STATS
42  *
43  * @defgroup TR69_HOSTIF_DEVICE_IP_INTERFACE_STATS_DSSTRUCT TR-069 Object (Device.IP.Interface.Stats) Public DataStructure
44  * Describe the details about data structure used in TR069 Device IP Interface stats.
45  * @ingroup TR69_HOSTIF_DEVICE_IP_INTERFACE_STATS
46  */
47 
48 
49 /**
50 * @defgroup tr69hostif
51 * @{
52 * @defgroup hostif
53 * @{
54 **/
55 
56 
57 #ifndef DEVICE_IP_INTERFACE_STATS_H_
58 #define DEVICE_IP_INTERFACE_STATS_H_
59 
60 /*****************************************************************************
61  * TR069-SPECIFIC INCLUDE FILES
62  *****************************************************************************/
63 #include "hostIf_main.h"
64 #include "hostIf_tr69ReqHandler.h"
65 #include "hostIf_utils.h"
66 #include "hostIf_updateHandler.h"
67 
68 #define _LENGTH_PARAMETER 64
69 #define _PATH_SYS_CLASS_NET "/sys/class/net/"
70 
71 /**
72  * @addtogroup TR69_HOSTIF_DEVICE_IP_INTERFACE_STATS_DSSTRUCT
73  * @{
74  */
75 /**
76  * @brief It contains the members variables of the Device_IP_Interface_stats structure.
77  */
78 typedef struct Device_IP_Interface_Stats {
79  unsigned long bytesSent;
80  unsigned long bytesReceived;
81  unsigned long packetsSent;
82  unsigned long packetsReceived;
83  unsigned long errorsSent;
84  unsigned long errorsReceived;
85  unsigned long unicastPacketsSent;
86  unsigned long unicastPacketsReceived;
87  unsigned long discardPacketsSent;
88  unsigned long discardPacketsReceived;
89  unsigned long multicastPacketsSent;
90  unsigned long multicastPacketsReceived;
91  unsigned long broadcastPacketsSent;
92  unsigned long broadcastPacketsReceived;
93  unsigned long unknownProtoPacketsReceived;
95 
96 /** @defgroup TR_069_DEVICE_IP_INTERFACE_STATS_API TR-069 Device.IP.Interface.Stats object API.
97  * @ingroup TR_069_DEVICE_IP_INTERFACE_API
98  *
99  * The Device.IP.Interface.Stats is the throughput statistics for this interface.
100  *
101  * The CPE MUST reset the interface's Stats parameters (unless otherwise stated in
102  * individual object or parameter descriptions) either when the interface becomes
103  * operationally down due to a previous administrative down (i.e. the interface's
104  * Status parameter transitions to a down state after the interface is disabled) or
105  * when the interface becomes administratively up (i.e. the interface's Enable parameter
106  * transitions from false to true).
107  *
108  */
109 
110 /** @addtogroup TR_069_DEVICE_IP_INTERFACE_STATS_GETTER_API TR-069 Device.IP.Interface.Stats Getter API.
111  * @ingroup TR_069_DEVICE_IP_INTERFACE_STATS_API
112  *
113  * \section dev_ip_stats_getter TR-069 Device.IP.Interface.Stats object Getter API
114  *
115  * This is the getter group of API for the <b>Device.IP.Interface.{i}.Stats</b> object.
116  *
117  * The interface for all functions is identical and is described here.
118  *
119  * @param[in] *name This is the complete path name of the parameter extracted from
120  * soap message, e.g. ::get_Device_IP_Interface_Stats_BytesSent.
121  * In this case, the path is "Device.IP.Interface.{i}.Stats.BytesSent".
122  * @param[in] *type Data type of parameter defined for TR-069. This is same as the
123  * data type used in the Xi3 data-model.xml file.
124  * (see parameter.h)
125  * @param[out] *value This is the value of the parameter requested by the ACS.
126  * (see paramaccess.h)
127  *
128  * @return The status of the operation.
129  * @retval OK If parameter requested was successfully fetched. (Same as <b>NO_ERROR</b>).
130  * @retval NO_ERROR If parameter requested was successfully fetched. (Same as <b>OK</b>).
131  * @retval DIAG_ERROR Diagnostic error.
132  * @retval ERR_??? Appropriate error value otherwise (see dimark_globals.h).
133  *
134  * @todo Clarify description of DIAG_ERROR.
135  *
136  * @{
137  */
138 
139 /**
140  * @brief This class provides the hostIf IP interface stats for getting IP interface stats information.
141  * @ingroup TR69_HOSTIF_DEVICE_IP_INTERFACE_STATS_CLASSES
142  */
144 
145  static GHashTable *ifHash;
146 
147  static GMutex *m_mutex;
148 
149  static IPInterfaceStats curntIpStat;
150 
151  int dev_id;
152  char nameOfInterface[IF_NAMESIZE];
153 
154  hostIf_IPInterfaceStats(int dev_id);
156 
157  void refreshInterfaceName ();
158  int getSysClassNetStatistic (char* statistic, unsigned long* result);
159 
160  int backupBytesSent;
161  int backupBytesReceived;
162  int backupPacketsSent;
163  int backupPacketsReceived;
164  int backupErrorsSent;
165  int backupErrorsReceived;
166  int backupUnicastPacketsSent;
167  int backupUnicastPacketsReceived;
168  int backupDiscardPacketsSent;
169  int backupDiscardPacketsReceived;
170  int backupMulticastPacketsSent;
171  int backupMulticastPacketsReceived;
172  int backupBroadcastPacketsSent;
173  int backupBroadcastPacketsReceived;
174  int backupUnknownProtoPacketsReceived;
175  bool bCalledBytesSent;
176  bool bCalledBytesReceived;
177  bool bCalledPacketsSent;
178  bool bCalledPacketsReceived;
179  bool bCalledErrorsSent;
180  bool bCalledErrorsReceived;
181  bool bCalledUnicastPacketsSent;
182  bool bCalledUnicastPacketsReceived;
183  bool bCalledDiscardPacketsSent;
184  bool bCalledDiscardPacketsReceived;
185  bool bCalledMulticastPacketsSent;
186  bool bCalledMulticastPacketsReceived;
187  bool bCalledBroadcastPacketsSent;
188  bool bCalledBroadcastPacketsReceived;
189  bool bCalledUnknownProtoPacketsReceived;
190 
191 public:
192 
193  static hostIf_IPInterfaceStats* getInstance(int dev_id);
194 
195  static void closeInstance(hostIf_IPInterfaceStats*);
196 
197  static GList* getAllInstances();
198 
199  static void closeAllInstances();
200 
201  static void getLock();
202 
203  static void releaseLock();
204 
205  int handleGetMsg (const char* pSetting, HOSTIF_MsgData_t* stMsgData);
206 
207 
208  int get_Device_IP_Interface_Stats_BytesSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
209 
210 
211  int get_Device_IP_Interface_Stats_BytesReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
212 
213  /**
214  * @brief Get the number of packets sent on the IP Interface.
215  *
216  * This function provides the total number of packets transmitted out of the interface.
217  *
218  * See @ref dev_ip_stats_getter
219  *
220  */
221 
222  int get_Device_IP_Interface_Stats_PacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
223 
224 
225  int get_Device_IP_Interface_Stats_PacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
226 
227 
228  int get_Device_IP_Interface_Stats_ErrorsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
229 
230 
231  int get_Device_IP_Interface_Stats_ErrorsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
232 
233 
234  int get_Device_IP_Interface_Stats_UnicastPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
235 
236 
237  int get_Device_IP_Interface_Stats_UnicastPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
238 
239 
240  int get_Device_IP_Interface_Stats_DiscardPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
241 
242 
243  int get_Device_IP_Interface_Stats_DiscardPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
244 
245 
246  int get_Device_IP_Interface_Stats_MulticastPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
247 
248 
249  int get_Device_IP_Interface_Stats_MulticastPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
250 
251 
252  int get_Device_IP_Interface_Stats_BroadcastPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
253 
254 
255  int get_Device_IP_Interface_Stats_BroadcastPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged = NULL);
256 
257 
259 
260  /* End of TR_069_DEVICE_IP_INTERFACE_STATS_GETTER_API doxygen group */
261  /**
262  * @}
263  */
264 
265 };
266 
267 #endif /* DEVICE_IP_INTERFACE_STATS_H_ */
268 
269 
270 /** @} */
271 /** @} */
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_UnicastPacketsReceived
int get_Device_IP_Interface_Stats_UnicastPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of unicast packets received on the IP Interface. Provides the total num...
Definition: Device_IP_Interface_Stats.cpp:510
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_BroadcastPacketsReceived
int get_Device_IP_Interface_Stats_BroadcastPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of broadcast packets received on the IP interface. It provides the tota...
Definition: Device_IP_Interface_Stats.cpp:711
hostIf_IPInterfaceStats::hostIf_IPInterfaceStats
hostIf_IPInterfaceStats(int dev_id)
Class Constructor of the class hostIf_IPInterfaceStats.
Definition: Device_IP_Interface_Stats.cpp:146
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_UnicastPacketsSent
int get_Device_IP_Interface_Stats_UnicastPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of unicast packets for which a request to send on the IP Interface was ...
Definition: Device_IP_Interface_Stats.cpp:478
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_PacketsReceived
int get_Device_IP_Interface_Stats_PacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the total number of packets received on the IP Interface.
Definition: Device_IP_Interface_Stats.cpp:379
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_DiscardPacketsReceived
int get_Device_IP_Interface_Stats_DiscardPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of discarded inbound packets on the IP Interface. It provides the total...
Definition: Device_IP_Interface_Stats.cpp:578
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_UnknownProtoPacketsReceived
int get_Device_IP_Interface_Stats_UnknownProtoPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of Packets of unidentified protocol received on the IP Interface....
Definition: Device_IP_Interface_Stats.cpp:743
hostIf_main.h
hostIf_main API.
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_BytesReceived
int get_Device_IP_Interface_Stats_BytesReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of bytes received on the IP Interface. It provides the total number of ...
Definition: Device_IP_Interface_Stats.cpp:318
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_BroadcastPacketsSent
int get_Device_IP_Interface_Stats_BroadcastPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of broadcast packets sent on the IP Interface. It provides the total nu...
Definition: Device_IP_Interface_Stats.cpp:676
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_PacketsSent
int get_Device_IP_Interface_Stats_PacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the number of packets sent on the IP Interface.
Definition: Device_IP_Interface_Stats.cpp:349
IPInterfaceStats
struct Device_IP_Interface_Stats IPInterfaceStats
It contains the members variables of the Device_IP_Interface_stats structure.
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_DiscardPacketsSent
int get_Device_IP_Interface_Stats_DiscardPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of discarded outbound packets on the IP Interface. It provides the tota...
Definition: Device_IP_Interface_Stats.cpp:544
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_ErrorsReceived
int get_Device_IP_Interface_Stats_ErrorsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of receive errors on the IP Interface. It provides the total number of ...
Definition: Device_IP_Interface_Stats.cpp:445
hostIf_IPInterfaceStats
This class provides the hostIf IP interface stats for getting IP interface stats information.
Definition: Device_IP_Interface_Stats.h:143
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_BytesSent
int get_Device_IP_Interface_Stats_BytesSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of bytes sent on the IP Interface. It provides the total number of byte...
Definition: Device_IP_Interface_Stats.cpp:287
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_MulticastPacketsReceived
int get_Device_IP_Interface_Stats_MulticastPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of Multicast Packets received on the IP Interface. It provides the tota...
Definition: Device_IP_Interface_Stats.cpp:642
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_MulticastPacketsSent
int get_Device_IP_Interface_Stats_MulticastPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of Multicast Packets sent on the IP Interface. It provides the total nu...
Definition: Device_IP_Interface_Stats.cpp:610
hostIf_IPInterfaceStats::get_Device_IP_Interface_Stats_ErrorsSent
int get_Device_IP_Interface_Stats_ErrorsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the number of send errors on the IP Interface. It provides the total number of out...
Definition: Device_IP_Interface_Stats.cpp:413
Device_IP_Interface_Stats
It contains the members variables of the Device_IP_Interface_stats structure.
Definition: Device_IP_Interface_Stats.h:78