RDK Documentation (Open Sourced RDK Components)
Device_MoCA_Interface_Stats.cpp
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 2018 RDK Management
6  * Copyright 2018 Broadcom Inc.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19 */
20 
21 /**
22  * @file Device_MoCA_Interface_Stats.c
23  *
24  * @brief MoCA_Interface_Stats API Implementation.
25  *
26  * This is the implementation of the MoCA_Interface API.
27  *
28  * @par Document
29  * TBD Relevant design or API documentation.
30  *
31  */
32 
33 /** @addtogroup MoCA_Interface Implementation
34  * This is the implementation of the Device Public API.
35  * @{
36  */
37 
38 /*****************************************************************************
39  * STANDARD INCLUDE FILES
40  *****************************************************************************/
41 
42 
43 
44 /*MoCA include files*/
46 #include "rdk_moca_hal.h"
47 
48 MoCAInterfaceStats* MoCAInterfaceStats::pInstance = NULL;
49 
50 MoCAInterfaceStats::MoCAInterfaceStats(int _dev_id):
51  m_i32DevID(0),
52  m_ulBytesSent(0),
53  m_ulBytesReceived(0),
54  m_ulPacketsSent(0),
55  m_ulPacketsReceived(0),
56  m_ulErrorsSent(0),
57  m_ulErrorsReceived(0),
58  m_ulUnicastPacketsSent(0),
59  m_ulUnicastPacketsReceived(0),
60  m_ulDiscardPacketsSent(0),
61  m_ulDiscardPacketsReceived(0),
62  m_ulMulticastPacketsSent(0),
63  m_ulMulticastPacketsReceived(0),
64  m_ulBroadcastPacketsSent(0),
65  m_ulBroadcastPacketsReceived(0),
66  m_ui32UnknownProtoPacketsReceived(0)
67 {
68  m_i32DevID = _dev_id;
69 }
70 
71 
72 MoCAInterfaceStats* MoCAInterfaceStats::getInstance()
73 {
74  if(NULL == pInstance)
75  {
76  try {
77  pInstance = new MoCAInterfaceStats(0);
78  } catch(int e) {
79  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught exception, not able create MoCA Interface Status instance..\n");
80  }
81  }
82  return pInstance;
83 }
84 
85 
86 /****************************************************************************************************************************************************/
87 // Device.MoCA.Interfacei.Stats Table Profile. Getters:
88 /****************************************************************************************************************************************************/
89 
91 {
92  int ret = NOK;
93  stMsgData->paramtype = hostIf_UnsignedLongType;
94  stMsgData->paramLen=sizeof(unsigned long);
95 
96  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
97  if(rmh) {
98  uint32_t response;
99  if(RMH_SUCCESS == RMH_Stats_GetTxTotalBytes(rmh, &response)) {
100  put_int(stMsgData->paramValue, response);
101  ret = OK;
102  }
103  }
104  return ret;
105 }
107 {
108  int ret = NOK;
109  stMsgData->paramtype = hostIf_UnsignedLongType;
110  stMsgData->paramLen=sizeof(unsigned long);
111 
112  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
113  if(rmh) {
114  uint32_t response;
115  if(RMH_SUCCESS == RMH_Stats_GetRxTotalBytes(rmh, &response)) {
116  put_int(stMsgData->paramValue, response);
117  ret = OK;
118  }
119  }
120  return ret;
121 }
122 
124 {
125  int ret = NOK;
126  stMsgData->paramtype = hostIf_UnsignedLongType;
127  stMsgData->paramLen=sizeof(unsigned long);
128 
129  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
130  if(rmh) {
131  uint32_t response;
132  if(RMH_SUCCESS == RMH_Stats_GetTxTotalPackets(rmh, &response)) {
133  put_int(stMsgData->paramValue, response);
134  ret = OK;
135  }
136  }
137  return ret;
138 }
140 {
141  int ret = NOK;
142  stMsgData->paramtype = hostIf_UnsignedLongType;
143  stMsgData->paramLen=sizeof(unsigned long);
144 
145  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
146  if(rmh) {
147  uint32_t response;
148  if(RMH_SUCCESS == RMH_Stats_GetRxTotalPackets(rmh, &response)) {
149  put_int(stMsgData->paramValue, response);
150  ret = OK;
151  }
152  }
153  return ret;
154 }
156 {
157  int ret = NOK;
158  stMsgData->paramtype = hostIf_UnsignedLongType;
159  stMsgData->paramLen=sizeof(unsigned long);
160 
161  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
162  if(rmh) {
163  uint32_t response;
164  if(RMH_SUCCESS == RMH_Stats_GetTxTotalErrors(rmh, &response)) {
165  put_int(stMsgData->paramValue, response);
166  ret = OK;
167  }
168  }
169  return ret;
170 }
171 
173 {
174  int ret = NOK;
175  stMsgData->paramtype = hostIf_UnsignedLongType;
176  stMsgData->paramLen=sizeof(unsigned long);
177 
178  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
179  if(rmh) {
180  uint32_t response;
181  if(RMH_SUCCESS == RMH_Stats_GetRxTotalErrors(rmh, &response)) {
182  put_int(stMsgData->paramValue, response);
183  ret = OK;
184  }
185  }
186  return ret;
187 }
188 
190 {
191  int ret = NOK;
192  stMsgData->paramtype = hostIf_UnsignedLongType;
193  stMsgData->paramLen=sizeof(unsigned long);
194 
195  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
196  if(rmh) {
197  uint32_t response;
198  if(RMH_SUCCESS == RMH_Stats_GetTxUnicastPackets(rmh, &response)) {
199  put_int(stMsgData->paramValue, response);
200  ret = OK;
201  }
202  }
203  return ret;
204 }
206 {
207  int ret = NOK;
208  stMsgData->paramtype = hostIf_UnsignedLongType;
209  stMsgData->paramLen=sizeof(unsigned long);
210 
211  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
212  if(rmh) {
213  uint32_t response;
214  if(RMH_SUCCESS == RMH_Stats_GetRxUnicastPackets(rmh, &response)) {
215  put_int(stMsgData->paramValue, response);
216  ret = OK;
217  }
218  }
219  return ret;
220 }
222 {
223  int ret = NOK;
224  stMsgData->paramtype = hostIf_UnsignedLongType;
225  stMsgData->paramLen=sizeof(unsigned long);
226 
227  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
228  if(rmh) {
229  uint32_t response;
230  if(RMH_SUCCESS == RMH_Stats_GetTxDroppedPackets(rmh, &response)) {
231  put_int(stMsgData->paramValue, response);
232  ret = OK;
233  }
234  }
235  return ret;
236 }
238 {
239  int ret = NOK;
240  stMsgData->paramtype = hostIf_UnsignedLongType;
241  stMsgData->paramLen=sizeof(unsigned long);
242 
243  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
244  if(rmh) {
245  uint32_t response;
246  if(RMH_SUCCESS == RMH_Stats_GetRxDroppedPackets(rmh, &response)) {
247  put_int(stMsgData->paramValue, response);
248  ret = OK;
249  }
250  }
251  return ret;
252 }
254 {
255  int ret = NOK;
256  stMsgData->paramtype = hostIf_UnsignedLongType;
257  stMsgData->paramLen=sizeof(unsigned long);
258 
259  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
260  if(rmh) {
261  uint32_t response;
262  if(RMH_SUCCESS == RMH_Stats_GetTxMulticastPackets(rmh, &response)) {
263  put_int(stMsgData->paramValue, response);
264  ret = OK;
265  }
266  }
267  return ret;
268 }
269 
271 {
272  int ret = NOK;
273  stMsgData->paramtype = hostIf_UnsignedLongType;
274  stMsgData->paramLen=sizeof(unsigned long);
275 
276  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
277  if(rmh) {
278  uint32_t response;
279  if(RMH_SUCCESS == RMH_Stats_GetRxMulticastPackets(rmh, &response)) {
280  put_int(stMsgData->paramValue, response);
281  ret = OK;
282  }
283  }
284  return ret;
285 }
286 
288 {
289  int ret = NOK;
290  stMsgData->paramtype = hostIf_UnsignedLongType;
291  stMsgData->paramLen=sizeof(unsigned long);
292 
293  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
294  if(rmh) {
295  uint32_t response;
296  if(RMH_SUCCESS == RMH_Stats_GetTxBroadcastPackets(rmh, &response)) {
297  put_int(stMsgData->paramValue, response);
298  ret = OK;
299  }
300  }
301  return ret;
302 }
304 {
305  int ret = NOK;
306  stMsgData->paramtype = hostIf_UnsignedLongType;
307  stMsgData->paramLen=sizeof(unsigned long);
308 
309  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
310  if(rmh) {
311  uint32_t response;
312  if(RMH_SUCCESS == RMH_Stats_GetRxBroadcastPackets(rmh, &response)) {
313  put_int(stMsgData->paramValue, response);
314  ret = OK;
315  }
316  }
317  return ret;
318 }
320 {
321  int ret = NOK;
322  stMsgData->paramtype = hostIf_UnsignedLongType;
323  stMsgData->paramLen=sizeof(unsigned long);
324 
325  const RMH_Handle rmh = (RMH_Handle)MoCADevice::getRmhContext();
326  if(rmh) {
327  uint32_t response;
328  if(RMH_SUCCESS == RMH_Stats_GetRxUnknownProtocolPackets(rmh, &response)) {
329  put_int(stMsgData->paramValue, response);
330  ret = OK;
331  }
332  }
333  return ret;
334 }
335 /* End of doxygen group */
336 /**
337  * @}
338  */
339 
340 /* End of file xxx_api.c. */
MoCAInterfaceStats::get_ErrorsReceived
int get_ErrorsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of inbound packets that contained errors preventing them from being delivered to...
Definition: Device_MoCA_Interface_Stats.cpp:172
RMH_Stats_GetRxMulticastPackets
RMH_Result RMH_Stats_GetRxMulticastPackets(const RMH_Handle handle, uint32_t *response)
Return the number of multicast packets received by this node.
MoCAInterfaceStats::get_DiscardPacketsSent
int get_DiscardPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of outbound packets which were chosen to be discarded even though no errors had ...
Definition: Device_MoCA_Interface_Stats.cpp:221
RMH_Stats_GetTxBroadcastPackets
RMH_Result RMH_Stats_GetTxBroadcastPackets(const RMH_Handle handle, uint32_t *response)
Return the number of broadcast packets transmitted by this node.
RMH_Stats_GetTxTotalErrors
RMH_Result RMH_Stats_GetTxTotalErrors(const RMH_Handle handle, uint32_t *response)
Return the total number of transmit errors by this node.
RMH_Stats_GetTxMulticastPackets
RMH_Result RMH_Stats_GetTxMulticastPackets(const RMH_Handle handle, uint32_t *response)
Return the number of multicast packets transmitted by this node.
MoCAInterfaceStats::get_BytesReceived
int get_BytesReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of bytes received on the MoCA interface, including framing characters.
Definition: Device_MoCA_Interface_Stats.cpp:106
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
MoCAInterfaceStats::get_PacketsSent
int get_PacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of packets transmitted out of the MoCA interface.
Definition: Device_MoCA_Interface_Stats.cpp:123
MoCAInterfaceStats::get_UnknownProtoPacketsReceived
int get_UnknownProtoPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of packets received via the MoCA interface which were discarded because of an un...
Definition: Device_MoCA_Interface_Stats.cpp:319
MoCAInterfaceStats::get_UnicastPacketsSent
int get_UnicastPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of packets requested for transmission which were not addressed to a multicast or...
Definition: Device_MoCA_Interface_Stats.cpp:189
RMH_Stats_GetRxTotalErrors
RMH_Result RMH_Stats_GetRxTotalErrors(const RMH_Handle handle, uint32_t *response)
Return the total number of received errors by this node.
RMH
Definition: librmh.h:57
MoCAInterfaceStats
Definition: Device_MoCA_Interface_Stats.h:109
RMH_Stats_GetTxDroppedPackets
RMH_Result RMH_Stats_GetTxDroppedPackets(const RMH_Handle handle, uint32_t *response)
Return the number of packets this node has dropped before transmitting.
_HostIf_MsgData_t::paramtype
HostIf_ParamType_t paramtype
Definition: hostIf_tr69ReqHandler.h:177
RMH_Stats_GetTxUnicastPackets
RMH_Result RMH_Stats_GetTxUnicastPackets(const RMH_Handle handle, uint32_t *response)
Return the number of unicast packets transmitted by this node.
RMH_Stats_GetTxTotalBytes
RMH_Result RMH_Stats_GetTxTotalBytes(const RMH_Handle handle, uint32_t *response)
Return the total number of bytes transmitted by this node.
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
MoCAInterfaceStats::get_BytesSent
int get_BytesSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of bytes transmitted out of the MoCA interface, including framing characters.
Definition: Device_MoCA_Interface_Stats.cpp:90
MoCAInterfaceStats::get_BroadcastPacketsSent
int get_BroadcastPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of packets that higher-level protocols requested for transmission and which were...
Definition: Device_MoCA_Interface_Stats.cpp:287
RMH_Stats_GetRxTotalBytes
RMH_Result RMH_Stats_GetRxTotalBytes(const RMH_Handle handle, uint32_t *response)
Return the total number of bytes received by this node.
MoCAInterfaceStats::get_PacketsReceived
int get_PacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of packets received on the MoCA interface.
Definition: Device_MoCA_Interface_Stats.cpp:139
RMH_Stats_GetRxDroppedPackets
RMH_Result RMH_Stats_GetRxDroppedPackets(const RMH_Handle handle, uint32_t *response)
Return the number of packets this node has dropped after receiving.
MoCAInterfaceStats::get_UnicastPacketsReceived
int get_UnicastPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of received packets, delivered by this layer to a higher layer,...
Definition: Device_MoCA_Interface_Stats.cpp:205
RMH_Stats_GetTxTotalPackets
RMH_Result RMH_Stats_GetTxTotalPackets(const RMH_Handle handle, uint32_t *response)
Return the total number of packets transmitted by this node.
RMH_Stats_GetRxBroadcastPackets
RMH_Result RMH_Stats_GetRxBroadcastPackets(const RMH_Handle handle, uint32_t *response)
Return the number of broadcast packets received by this node.
MoCAInterfaceStats::get_ErrorsSent
int get_ErrorsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of outbound packets that could not be transmitted because of errors.
Definition: Device_MoCA_Interface_Stats.cpp:155
RMH_Stats_GetRxTotalPackets
RMH_Result RMH_Stats_GetRxTotalPackets(const RMH_Handle handle, uint32_t *response)
Return the total number of packets received by this node.
MoCAInterfaceStats::get_BroadcastPacketsReceived
int get_BroadcastPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of received packets, delivered by this layer to a higher layer,...
Definition: Device_MoCA_Interface_Stats.cpp:303
_HostIf_MsgData_t::paramValue
char paramValue[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:172
RMH_Stats_GetRxUnknownProtocolPackets
RMH_Result RMH_Stats_GetRxUnknownProtocolPackets(const RMH_Handle handle, uint32_t *response)
Return the number of unknown packets received by this node.
RMH_Stats_GetRxUnicastPackets
RMH_Result RMH_Stats_GetRxUnicastPackets(const RMH_Handle handle, uint32_t *response)
Return the number of unicast packets received by this node.
MoCAInterfaceStats::get_MulticastPacketsSent
int get_MulticastPacketsSent(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of packets that higher-level protocols requested for transmission and which were...
Definition: Device_MoCA_Interface_Stats.cpp:253
Device_MoCA_Interface_Stats.h
TR-069 Device.Moca.Interface.Stats object Public API.
MoCAInterfaceStats::get_DiscardPacketsReceived
int get_DiscardPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of inbound packets which were chosen to be discarded even though no errors had b...
Definition: Device_MoCA_Interface_Stats.cpp:237
put_int
void put_int(char *ptr, int val)
This function converts the input data to integer type.
Definition: hostIf_utils.cpp:152
MoCAInterfaceStats::get_MulticastPacketsReceived
int get_MulticastPacketsReceived(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the total number of received packets, delivered by this layer to a higher layer,...
Definition: Device_MoCA_Interface_Stats.cpp:270
_HostIf_MsgData_t::paramLen
short paramLen
Definition: hostIf_tr69ReqHandler.h:175