RDK Documentation (Open Sourced RDK Components)
Device_IP_ActivePort.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_ActivePort.h
21  * @brief The header file provides TR069 device IP active port information APIs.
22  */
23 
24 /**
25  * @defgroup TR69_HOSTIF_DEVICE_IP_ACTIVEPORT TR-069 Object (Device.IP.ActivePort.Interface)
26  * This table lists the ports on which TCP connections are listening or established.
27  * At most one entry in this table can exist with all the same values for
28  * - LocalIPAddress
29  * - LocalPort
30  * - RemoteIPAddress
31  * - RemotePort.
32  * @ingroup TR69_HOSTIF_DEVICE_IP
33  *
34  * @defgroup TR69_HOSTIF_DEVICE_IP_ACTIVEPORT_API TR-069 Object (Device.IP.ActivePort.Interface.{i}) Public APIs
35  * Describe the details about TR-069 Device IP active port APIs specifications.
36  * @ingroup TR69_HOSTIF_DEVICE_IP_ACTIVEPORT
37  *
38  * @defgroup TR69_HOSTIF_DEVICE_IP_ACTIVEPORT_CLASSES TR-069 Object (Device.IP.ActivePort.Interface.{i}) Public Classes
39  * Describe the details about classes used in TR-069 Device IP active port.
40  * @ingroup TR69_HOSTIF_DEVICE_IP_ACTIVEPORT
41  *
42  * @defgroup TR69_HOSTIF_DEVICE_IP_ACTIVEPORT_DSSTRUCT TR-069 Object (Device.IP.ActivePort.Interface.{i}) Public DataStructure
43  * Describe the details about data structure used in TR-069 Device IP active port.
44  * @ingroup TR69_HOSTIF_DEVICE_IP_ACTIVEPORT
45  */
46 
47 
48 /**
49 * @defgroup tr69hostif
50 * @{
51 * @defgroup hostif
52 * @{
53 **/
54 
55 
56 #ifndef DEVICE_IP_ACTIVEPORT_H_
57 #define DEVICE_IP_ACTIVEPORT_H_
58 
59 /*****************************************************************************
60  * TR069-SPECIFIC INCLUDE FILES
61  *****************************************************************************/
62 #include "hostIf_main.h"
63 #include "hostIf_tr69ReqHandler.h"
64 #include "hostIf_utils.h"
65 #include "hostIf_updateHandler.h"
66 
67 #define _LENGTH_PARAMETER 64
68 #define _LENGTH_IPADDR 16
69 #define _LENGTH_STATUS 12
70 #define _HEX_STATE_LEN 3
71 #define _BUF_LEN 1024
72 
73 
74 /** @defgroup TR_069_DEVICE_IP_ACTIVEPORT_API TR-069 Device.IP.ActivePort object API.
75  * @ingroup TR_069_DEVICE_IP_API
76  *
77  * The Device.IP.ActivePort table lists the ports on which TCP connections are listening
78  * or established.
79  *
80  * @note At most one entry in this table can exist with all the same values for
81  * LocalIPAddress, LocalPort, RemoteIPAddress and RemotePort.
82  *
83  */
84 
85 /** @addtogroup TR_069_DEVICE_IP_ACTIVEPORT_GETTER_API TR-069 Device.IP.ActivePort Getter API.
86  * @ingroup TR_069_DEVICE_IP_ACTIVEPORT_API
87  *
88  * \section dev_ipactiveport_getter TR-069 Device.IP.ActivePort object Getter API
89  *
90  * This is the getter group of API for the <b>Device.IP.ActivePort.{i}</b> object.
91  *
92  * The interface for all functions is identical and is described here.
93  *
94  * @param[in] *name This is the complete path name of the parameter extracted from
95  * soap message, e.g. ::get_Device_IP_ActivePort_LocalIPAddress.
96  * In this case, the path is "Device.IP.ActivePort.{i}.LocalIPAddress".
97  * @param[in] *type Data type of parameter defined for TR-069. This is same as the
98  * data type used in the Xi3 data-model.xml file.
99  * (see parameter.h)
100  * @param[out] *value This is the value of the parameter requested by the ACS.
101  * (see paramaccess.h)
102  *
103  * @return The status of the operation.
104  * @retval OK If parameter requested was successfully fetched. (Same as <b>NO_ERROR</b>).
105  * @retval NO_ERROR If parameter requested was successfully fetched. (Same as <b>OK</b>).
106  * @retval DIAG_ERROR Diagnostic error.
107  * @retval ERR_??? Appropriate error value otherwise (see dimark_globals.h).
108  *
109  * @todo Clarify description of DIAG_ERROR.
110  *
111  * @{
112  */
113 
114 /**
115  * @addtogroup TR69_HOSTIF_DEVICE_IP_ACTIVEPORT_DSSTRUCT
116  * @{
117  */
118 
119 /**
120  * @brief The structure holds the required parameters such as local ipaddress, localport, remoteIpAddress
121  * etc.. for the device ip of the active port.
122  */
124 
125  char localIpAddress[_LENGTH_IPADDR];
126  unsigned int localPort;
127  char remoteIpAddress[_LENGTH_IPADDR];
128  unsigned int remotePort;
129  char status[_LENGTH_STATUS];
130 };
131 /** @} */ //End of the Doxygen tag TR69_HOSTIF_DEVICE_IP_ACTIVEPORT_DSSTRUCT
132 
133 /**
134  * @brief This class provides the hostIf IP active port for getting IP active port information.
135  * @ingroup TR69_HOSTIF_DEVICE_IP_ACTIVEPORT_CLASSES
136  */
137 class hostIf_IPActivePort {
138 
139  static GHashTable *ifHash;
140 
141  static GMutex *m_mutex;
142 
143  static struct Device_IP_ActivePort activePort;
144 
145  int dev_id;
146 
147  bool bCalledLocalIPAddress;
148  bool bCalledLocalPort;
149  bool bCalledRemoteIPAddress;
150  bool bCalledRemotePort;
151  bool bCalledStatus;
152 
153  char backupLocalIPAddress[_LENGTH_IPADDR];
154  char backupRemoteIPAddress[_LENGTH_IPADDR];
155  char backupStatus[_LENGTH_IPADDR];
156  unsigned int backupLocalPort;
157  unsigned int backupRemotePort;
158 
159  hostIf_IPActivePort(int dev_id);
160 
161  ~hostIf_IPActivePort() {};
162 
163  int getActivePortsFields(unsigned int activePortNo);
164 
165 public:
166 
167  static hostIf_IPActivePort *getInstance(int dev_id);
168 
169  static void closeInstance(hostIf_IPActivePort *);
170 
171  static GList* getAllInstances();
172 
173  static void closeAllInstances();
174 
175  static void getLock();
176 
177  static void releaseLock();
178 
179 
180 
181  int handleGetMsg (const char* pSetting, HOSTIF_MsgData_t* stMsgData);
182 
183 
184  int get_Device_IP_ActivePort_LocalIPAddress(HOSTIF_MsgData_t *, bool *pChanged = NULL);
185 
186 
187  int get_Device_IP_ActivePort_LocalPort(HOSTIF_MsgData_t *, bool *pChanged = NULL);
188 
189 
190  int get_Device_IP_ActivePort_RemoteIPAddress(HOSTIF_MsgData_t *, bool *pChanged = NULL);
191 
192 
193  int get_Device_IP_ActivePort_RemotePort(HOSTIF_MsgData_t *, bool *pChanged = NULL);
194 
195 
196  int get_Device_IP_ActivePort_Status(HOSTIF_MsgData_t *, bool *pChanged = NULL);
197 
198  /* End of TR_069_DEVICE_IP_ACTIVEPORT_GETTER_API doxygen group */
199  /**
200  * @}
201  */
202 };
203 
204 #endif /* DEVICE_IP_ACTIVEPORT_H_ */
205 
206 
207 /** @} */
208 /** @} */
hostIf_IPActivePort::get_Device_IP_ActivePort_RemoteIPAddress
int get_Device_IP_ActivePort_RemoteIPAddress(HOSTIF_MsgData_t *, bool *pChanged=NULL)
This function gets the remote IP Address of the established connection. It provides the remote IP add...
Definition: Device_IP_ActivePort.cpp:332
hostIf_IPActivePort
This class provides the hostIf IP active port for getting IP active port information.
Definition: Device_IP_ActivePort.cpp:53
hostIf_IPActivePort::get_Device_IP_ActivePort_RemotePort
int get_Device_IP_ActivePort_RemotePort(HOSTIF_MsgData_t *, bool *pChanged=NULL)
This function gets the remote port number of the established connection. It provides the remote port ...
Definition: Device_IP_ActivePort.cpp:365
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_main.h
hostIf_main API.
hostIf_IPActivePort::get_Device_IP_ActivePort_LocalIPAddress
int get_Device_IP_ActivePort_LocalIPAddress(HOSTIF_MsgData_t *, bool *pChanged=NULL)
This function gets the local IP Address of the connection.
Definition: Device_IP_ActivePort.cpp:266
hostIf_IPActivePort::get_Device_IP_ActivePort_LocalPort
int get_Device_IP_ActivePort_LocalPort(HOSTIF_MsgData_t *, bool *pChanged=NULL)
This function gets the local port number of the connection.
Definition: Device_IP_ActivePort.cpp:298
Device_IP_ActivePort
The structure holds the required parameters such as local ipaddress, localport, remoteIpAddress etc....
Definition: Device_IP_ActivePort.h:123
hostIf_IPActivePort::get_Device_IP_ActivePort_Status
int get_Device_IP_ActivePort_Status(HOSTIF_MsgData_t *, bool *pChanged=NULL)
This function gets the current operational status of the connection. The possible values are 'LISTEN'...
Definition: Device_IP_ActivePort.cpp:395
hostIf_IPActivePort::hostIf_IPActivePort
hostIf_IPActivePort(int dev_id)
Class Constructor of the class hostIf_IPActivePort.
Definition: Device_IP_ActivePort.cpp:129