RDK Documentation (Open Sourced RDK Components)
Device_IP.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 /**
21  * @file Device_IP.h
22  * @brief The header file provides TR069 device IP information APIs.
23  */
24 
25 /**
26  * @defgroup TR69_HOSTIF_DEVICE_IP TR-069 Object (Device.IP)
27  * IP interface table models the layer 3 IP interface. Each IP interface can be attached to
28  * the IPv4 and/or IPv6 stack. The interface's IP addresses and prefixes are listed in the IPv4Address,
29  * IPv6Address and IPv6Prefix tables.
30  *
31  * @note Note that support for manipulating Loopback interfaces is OPTIONAL, so the implementation MAY choose
32  * not to create (or allow the ACS to create) Interface instances of type Loopback.
33  *
34  * - When the ACS administratively disables the interface, i.e. sets Enable to false, the interface's
35  * automatically-assigned IP addresses and prefixes MAY be retained.
36  * - When the ACS administratively enables the interface, i.e. sets Enable to true, these IP
37  * addresses and prefixes MUST be refreshed.
38  *
39  * It's up to the implementation to decide exactly what this means:
40  * It SHOULD take all reasonable steps to refresh everything but if it is unable, for example,
41  * to refresh a prefix that still has a significant lifetime, it might well choose to retain
42  * rather than discard it.
43  *
44  * @ingroup TR69_HOSTIF_PROFILE
45  * @defgroup TR69_HOSTIF_DEVICE_IP_INTERFACE TR-069 Object (Device.IP.Object)
46  * IP object that contains the Interface, ActivePort, and Diagnostics objects.
47  * @ingroup TR69_HOSTIF_DEVICE_IP
48  * @defgroup TR69_HOSTIF_DEVICE_IP_INTERFACE_API TR-069 Object (Device.IP.Object.{i}) Public APIs
49  * Describe the details about TR69 Device IP interface APIs specifications.
50  * @ingroup TR69_HOSTIF_DEVICE_IP_INTERFACE
51  *
52  * @defgroup TR69_HOSTIF_DEVICE_IP_INTERFACE_CLASSES TR-069 Object (Device.IP.Object.{i}) Public Classes
53  * Describe the details about classes used in TR69 Device IP interface.
54  * @ingroup TR69_HOSTIF_DEVICE_IP_INTERFACE
55  *
56  * @defgroup TR69_HOSTIF_DEVICE_IP_INTERFACE_DSSTRUCT TR-069 Object (Device.IP.Object.{i}) Public DataStructure
57  * Describe the details about data structure used in TR69 Device IP interface.
58  * @ingroup TR69_HOSTIF_DEVICE_IP_INTERFACE
59  *
60  */
61 
62 /**
63 * @defgroup tr69hostif
64 * @{
65 * @defgroup hostif
66 * @{
67 **/
68 
69 
70 
71 #ifndef DEVICE_IP_H_
72 #define DEVICE_IP_H_
73 
74 /*****************************************************************************
75  * TR069-SPECIFIC INCLUDE FILES
76  *****************************************************************************/
77 
78 #include "hostIf_main.h"
79 #include "hostIf_tr69ReqHandler.h"
80 #include "hostIf_utils.h"
81 #include "hostIf_updateHandler.h"
82 
83 
84 
85 #define LENGTH 16
86 
87 /**
88  * @addtogroup TR69_HOSTIF_DEVICE_IP_INTERFACE_DSSTRUCT
89  * @{
90  */
91 
92 /**
93  * @enum EIPMembers
94  * @brief These values are the members of the EIPMembers.
95  */
96 typedef enum EIPMembers
97 {
98  eIpIPv4Capable=0,
99  eIpIPv4Enable,
100  eIpIPv4Status,
101  eIpULAPrefix,
102  eIpInterfaceNumberOfEntries,
103  eIpActivePortNumberOfEntries
104 }
105 EIPMembers;
106 
107 /**
108  * @brief It contains the members variables of the IP structure.
109  */
110 typedef struct Device_IP
111 {
112  bool iPv4Capable;
113  bool iPv4Enable;
114  char iPv4Status[LENGTH];
115  char uLAPrefix[LENGTH];
116  unsigned int interfaceNumberOfEntries;
117  unsigned int activePortNumberOfEntries;
118 } IP;
119 /** @} */ //End of the Doxygen tag TR69_HOSTIF_DEVICE_IP_INTERFACE_DSSTRUCT
120 
121 /** @defgroup TR_069_DEVICE_IP_API TR-069 Device.IP object API.
122  * @ingroup TR_069_API
123  *
124  * The Device.IP object is the IP object that contains the Interface, ActivePort,
125  * and Diagnostics objects.
126  */
127 
128 /** @addtogroup TR_069_DEVICE_IP_GETTER_API TR-069 Device.IP Getter API.
129  * @ingroup TR_069_DEVICE_IP_API
130  *
131  * \section dev_ip_getter TR-069 Device.IP object Getter API
132  *
133  * This is the getter group of API for the <b>Device.IP</b> object.
134  *
135  * The interface for all functions is identical and is described here.
136  *
137  * @param[in] *name This is the complete path name of the parameter extracted from
138  * soap message, e.g. ::get_Device_IP_IPv4Capable.
139  * In this case, the path is "Device.IP.IPv4Capable".
140  * @param[in] *type Data type of parameter defined for TR-069. This is same as the
141  * data type used in the Xi3 data-model.xml file.
142  * (see parameter.h)
143  * @param[out] *value This is the value of the parameter requested by the ACS.
144  * (see paramaccess.h)
145  *
146  * @return The status of the operation.
147  * @retval OK If parameter requested was successfully fetched. (Same as <b>NO_ERROR</b>).
148  * @retval NO_ERROR If parameter requested was successfully fetched. (Same as <b>OK</b>).
149  * @retval DIAG_ERROR Diagnostic error.
150  * @retval ERR_??? Appropriate error value otherwise (see dimark_globals.h).
151  *
152  * @todo Clarify description of DIAG_ERROR.
153  *
154  * @{
155  */
156 
157 
158 /**
159  * @brief This class provides the hostIf IP interface for getting IP interface information.
160  * @ingroup TR69_HOSTIF_DEVICE_IP_INTERFACE_CLASSES
161  */
162 class hostIf_IP {
163 
164  static GHashTable *ifHash;
165 
166  static GMutex *m_mutex;
167 
168  static IP stIPInstance;
169 
170  static char* cmd_NumOfActivePorts;
171 
172  static GHashTable *m_notifyHash;
173 
174  int dev_id;
175 
176  hostIf_IP(int dev_id);
177 
178  ~hostIf_IP();
179 
180  bool bCalledIPv4Capable;
181  bool bCalledIPv4Enable;
182  bool bCalledIPv4Status;
183  bool bCalledInterfaceNumberOfEntries;
184  bool bCalledActivePortNumberOfEntries;
185 
186  bool backupIPv4Capable;
187  bool backupIPv4Enable;
188  int backupInterfaceNumberOfEntries;
189  int backupActivePortNumberOfEntries;
190  char backupIPv4Status[_BUF_LEN_16];
191 
192  static unsigned int getInterfaceNumberOfEntries(void);
193  static unsigned int getPhysicalInterfaceNumberOfEntries (struct if_nameindex* phy_if_list);
194  static unsigned int getVirtualInterfaceNumberOfEntries (struct if_nameindex* phy_if_list);
195  static char* getVirtualInterfaceName (struct if_nameindex *phy_if_list, unsigned int virtual_if_index, char* virtual_if_name);
196 
197 public:
198 
199  static hostIf_IP* getInstance(int dev_id);
200 
201  static void closeInstance(hostIf_IP*);
202 
203  static GList* getAllInstances();
204 
205  static void closeAllInstances();
206 
207  static void getLock();
208 
209  static void releaseLock();
210 
211  static char* getInterfaceName (int if_index, char* if_name);
212 
213  static unsigned int getNumOfActivePorts(void);
214 
215  static int get_Device_IP_Fields(EIPMembers ipMem);
216 
217  static GHashTable* getNotifyHash();
218 
219 
220  int handleGetMsg (HOSTIF_MsgData_t* stMsgData);
221  int handleSetMsg (HOSTIF_MsgData_t* stMsgData);
222 
223  /**
224  * @brief Get the IPv4 capability of a device.
225  *
226  * This function indicates whether or not the device is IPv4 capable (<tt>true</tt>)
227  * or not (<tt>false</tt>).
228  *
229  * See @ref dev_ip_getter
230  *
231  */
232  int get_Device_IP_IPv4Capable(HOSTIF_MsgData_t *, bool *pChanged = NULL);
233 
234  /**
235  * @brief Get the status (enabled/disabled) of the IPv4 stack on a device.
236  *
237  * This function provides the status (enabled/disabled) of the IPv4 stack, and so the
238  * use of IPv4 on the device. This affects only layer 3 and above.
239  *
240  * @note When <tt>false</tt>, IP interfaces that had been operationally up and
241  * passing IPv4 packets will now no longer be able to do so, and will be
242  * operationally down (unless also attached to an enabled IPv6 stack).
243  *
244  * See @ref dev_ip_getter
245  *
246  */
247  int get_Device_IP_IPv4Enable(HOSTIF_MsgData_t *, bool *pChanged = NULL);
248 
249 
250  int get_Device_IP_IPv4Status(HOSTIF_MsgData_t *, bool *pChanged = NULL);
251 
252 
253  int get_Device_IP_ULAPrefix(HOSTIF_MsgData_t *, bool *pChanged = NULL);
254 
255  /**
256  * @brief Get the number of entries in the Interface table.
257  *
258  * This function provides the number of entries in the Interface table of the device.
259  *
260  * See @ref dev_ip_getter
261  *
262  */
263 
265 
266  /**
267  * @brief Get the number of entries in the ActivePort table.
268  *
269  * This function provides the number of entries in the ActivePort table of the device.
270  *
271  * See @ref dev_ip_getter
272  *
273  */
274 
276 
277  /* End of TR_069_DEVICE_IP_GETTER_API doxygen group */
278  /**
279  * @}
280  */
281 
282  /** @addtogroup TR_069_DEVICE_IP_SETTER_API TR-069 Device.IP Setter API.
283  * @ingroup TR_069_DEVICE_IP_API
284  *
285  * \section dev_ip_setter TR-069 Device.IP object Setter API
286  *
287  * This is the setter group of API for the <b>Device.IP</b> object.
288  *
289  * The interface for all functions is identical and is described here.
290  *
291  * @param[in] *name This is the complete path name of the parameter extracted from
292  * soap message, e.g. ::set_Device_IP_IPv4Enable.
293  * In this case, the path is "Device.IP.IPv4Enable".
294  * @param[in] *type Data type of parameter defined for TR-069. This is same as the
295  * data type used in the Xi3 data-model.xml file.
296  * (see parameter.h)
297  * @param[in] *value This is the value to which the parameter requested by the ACS
298  * must be set.
299  * (see paramaccess.h)
300  *
301  * @return The status of the operation.
302  * @retval OK If parameter requested was successfully updated. (Same as <b>NO_ERROR</b>).
303  * @retval NO_ERROR If parameter requested was successfully updated. (Same as <b>OK</b>).
304  * @retval DIAG_ERROR Diagnostic error.
305  * @retval ERR_??? Appropriate error value otherwise (see dimark_globals.h).
306  *
307  * @todo Clarify description of DIAG_ERROR.
308  *
309  * @{
310  */
311 
312 
313  /**
314  * @brief Set the status (enabled/disabled) of the IPv4 stack on a device.
315  *
316  * This function sets the status (enabled/disabled) of the IPv4 stack, and so the
317  * use of IPv4 on the device. This affects only layer 3 and above.
318  *
319  * @note When <tt>false</tt>, IP interfaces that had been operationally up and
320  * passing IPv4 packets will now no longer be able to do so, and will be
321  * operationally down (unless also attached to an enabled IPv6 stack).
322  *
323  * See @ref dev_ip_setter
324  *
325  */
326 
328 
329 
331 
332  /* End of TR_069_DEVICE_IP_SETTER_API doxygen group */
333  /**
334  * @}
335  */
336 };
337 
338 #endif /* DEVICE_IP_H_ */
339 
340 
341 /** @} */
342 /** @} */
hostIf_IP::set_Device_IP_IPv4Enable
int set_Device_IP_IPv4Enable(HOSTIF_MsgData_t *)
Set the status (enabled/disabled) of the IPv4 stack on a device.
Definition: Device_IP.cpp:685
hostIf_IP::get_Device_IP_ULAPrefix
int get_Device_IP_ULAPrefix(HOSTIF_MsgData_t *, bool *pChanged=NULL)
Get the ULA(Unique Local Address)/48 prefix for a device. This function provides the ULA /48 prefix o...
Definition: Device_IP.cpp:634
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_IP::getNumOfActivePorts
static unsigned int getNumOfActivePorts(void)
Definition: Device_IP.cpp:364
hostIf_IP::set_Device_IP_ULAPrefix
int set_Device_IP_ULAPrefix(HOSTIF_MsgData_t *)
This function sets the ULA /48 prefix of the device. This is the IPv6 address prefix and can be any I...
Definition: Device_IP.cpp:733
hostIf_IP
This class provides the hostIf IP interface for getting IP interface information.
Definition: Device_IP.h:162
hostIf_main.h
hostIf_main API.
hostIf_IP::get_Device_IP_InterfaceNumberOfEntries
static int get_Device_IP_InterfaceNumberOfEntries(HOSTIF_MsgData_t *)
Get the number of entries in the Interface table.
Definition: Device_IP.cpp:641
hostIf_IP::hostIf_IP
hostIf_IP(int dev_id)
Class Constructor of the class hostIf_IP.
Definition: Device_IP.cpp:63
Device_IP
It contains the members variables of the IP structure.
Definition: Device_IP.h:110
hostIf_IP::getInterfaceNumberOfEntries
static unsigned int getInterfaceNumberOfEntries(void)
Definition: Device_IP.cpp:216
hostIf_IP::getInterfaceName
static char * getInterfaceName(int if_index, char *if_name)
Definition: Device_IP.cpp:183
hostIf_IP::get_Device_IP_IPv4Capable
int get_Device_IP_IPv4Capable(HOSTIF_MsgData_t *, bool *pChanged=NULL)
Get the IPv4 capability of a device.
Definition: Device_IP.cpp:542
IP
struct Device_IP IP
It contains the members variables of the IP structure.
hostIf_IP::get_Device_IP_IPv4Enable
int get_Device_IP_IPv4Enable(HOSTIF_MsgData_t *, bool *pChanged=NULL)
Get the status (enabled/disabled) of the IPv4 stack on a device.
Definition: Device_IP.cpp:570
hostIf_IP::getVirtualInterfaceNumberOfEntries
static unsigned int getVirtualInterfaceNumberOfEntries(struct if_nameindex *phy_if_list)
Definition: Device_IP.cpp:254
hostIf_IP::getVirtualInterfaceName
static char * getVirtualInterfaceName(struct if_nameindex *phy_if_list, unsigned int virtual_if_index, char *virtual_if_name)
Definition: Device_IP.cpp:304
EIPMembers
EIPMembers
These values are the members of the EIPMembers.
Definition: Device_IP.h:96
hostIf_IP::get_Device_IP_ActivePortNumberOfEntries
static int get_Device_IP_ActivePortNumberOfEntries(HOSTIF_MsgData_t *)
Get the number of entries in the ActivePort table.
Definition: Device_IP.cpp:652
hostIf_IP::get_Device_IP_IPv4Status
int get_Device_IP_IPv4Status(HOSTIF_MsgData_t *, bool *pChanged=NULL)
This function gets the status of the IPv4 stack on a device. It indicates the status of the IPv4 stac...
Definition: Device_IP.cpp:599