RDK Documentation (Open Sourced RDK Components)
Device_IP_Interface_IPv4Address.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_IPv4Address.h
21  * @brief The header file provides TR069 device IPv4 interface address information APIs.
22  */
23 
24 /**
25  * @defgroup TR69_HOSTIF_DEVICE_IP_IPv4_INTERFACE_ADDRESS TR-069 Object (Device.IP.Interface.IPv4Address)
26  *
27  * @par IPv4 address table
28  * Entries are auto-created and auto-deleted as IP addresses are added and deleted via
29  * - DHCP
30  * - auto-IP or
31  * - IPCP
32  * Static entries are created and configured by the ACS.
33  * - At most one entry in this table regardless of whether or not it is enabled can exist with a
34  * given value for Alias. On creation of a new table entry, the CPE MUST choose an initial value
35  * for Alias such that the new entry does not conflict with any existing entries.
36  * - At most one enabled entry in this table can exist with the same values for IPAddress and SubnetMask.
37  *
38  * @ingroup TR69_HOSTIF_DEVICE_IP
39  *
40  * @defgroup TR69_HOSTIF_DEVICE_IP_IPv4_INTERFACE_ADDRESS_API TR-069 Object (Device.IP.Interface.IPv4Address) Public APIs
41  * Describe the details about TR-069 Device IPv4 Interface address APIs specifications.
42  * @ingroup TR69_HOSTIF_DEVICE_IP_IPv4_INTERFACE_ADDRESS
43  *
44  * @defgroup TR69_HOSTIF_DEVICE_IP_IPv4_INTERFACE_ADDRESS_CLASSES TR-069 Object (Device.IP.Interface.IPv4Address) Public Classes
45  * Describe the details about classes used in TR069 Device IPv4 Interface address.
46  * @ingroup TR69_HOSTIF_DEVICE_IP_IPv4_INTERFACE_ADDRESS
47  *
48  * @defgroup TR69_HOSTIF_DEVICE_IP_IPv4_INTERFACE_ADDRESS_STRUCT TR-069 Object (Device.IP.Interface.IPv4Address) Public DataStructure
49  * Describe the details about data structure used in TR069 Device IPv4 Interface address.
50  * @ingroup TR69_HOSTIF_DEVICE_IP_IPv4_INTERFACE_ADDRESS
51  */
52 
53 
54 /**
55 * @defgroup tr69hostif
56 * @{
57 * @defgroup hostif
58 * @{
59 **/
60 
61 
62 #ifndef DEVICE_IP_INTERFACE_IPV4ADDRESS_H_
63 #define DEVICE_IP_INTERFACE_IPV4ADDRESS_H_
64 
65 /*****************************************************************************
66  * TR069-SPECIFIC INCLUDE FILES
67  *****************************************************************************/
68 #include "hostIf_main.h"
69 #include "hostIf_tr69ReqHandler.h"
70 #include "hostIf_utils.h"
71 #include "hostIf_updateHandler.h"
72 #include <net/if.h>
73 
74 
75 /** @defgroup TR_069_DEVICE_IP_INTERFACE_IPV4ADDRESS_API TR-069 Device.IP.Interface.IPv4Address object API.
76  * @ingroup TR_069_DEVICE_IP_INTERFACE_API
77  *
78  * The Device.IP.Interface.IPv4Address is the table of IPv4 Addresses. Entries are
79  * auto-created and auto-deleted as IP addresses are added and deleted via DHCP,
80  * auto-IP, or IPCP. Static entries are created and configured by the ACS.
81  *
82  * @note <ul>
83  * <li>At most one entry in this table (regardless of whether or not it
84  * is enabled) can exist with a given value for Alias. On creation of a
85  * new table entry, the CPE MUST choose an initial value for Alias such
86  * that the new entry does not conflict with any existing entries.</li>
87  *
88  * <li>At most one enabled entry in this table can exist with the same
89  * values for IPAddress and SubnetMask.</li>
90  * </ul>
91  *
92  */
93 
94 /** @addtogroup TR_069_DEVICE_IP_INTERFACE_IPV4ADDRESS_GETTER_API TR-069 Device.IP.Interface.IPv4Address Getter API.
95  * @ingroup TR_069_DEVICE_IP_INTERFACE_IPV4ADDRESS_API
96  *
97  * \section dev_ip_ipv4address_getter TR-069 Device.IP.Interface.IPv4Address object Getter API
98  *
99  * This is the getter group of API for the <b>Device.IP.Interface.{i}.IPv4Address.{j}</b> object.
100  *
101  * The interface for all functions is identical and is described here.
102  *
103  * @param[in] *name This is the complete path name of the parameter extracted from
104  * soap message, e.g. ::get_Device_IP_Interface_IPv4Address_Enable.
105  * In this case, the path is "Device.IP.Interface.{i}.IPv4Address.{j}.Enable".
106  * @param[in] *type Data type of parameter defined for TR-069. This is same as the
107  * data type used in the Xi3 data-model.xml file.
108  * (see parameter.h)
109  * @param[out] *value This is the value of the parameter requested by the ACS.
110  * (see paramaccess.h)
111  *
112  * @return The status of the operation.
113  * @retval OK If parameter requested was successfully fetched. (Same as <b>NO_ERROR</b>).
114  * @retval NO_ERROR If parameter requested was successfully fetched. (Same as <b>OK</b>).
115  * @retval DIAG_ERROR Diagnostic error.
116  * @retval ERR_??? Appropriate error value otherwise (see dimark_globals.h).
117  *
118  * @todo Clarify description of DIAG_ERROR.
119  *
120  * @{
121  */
122 
123 /**
124  * @brief This class provides the hostIf IPv4 interface address for getting interface address information.
125  * @ingroup TR69_HOSTIF_DEVICE_IP_IPv4_INTERFACE_ADDRESS_CLASSES
126  */
128 
129  static GHashTable *ifHash;
130  static GMutex *m_mutex;
131 
132  int dev_id;
133  char nameOfInterface[IF_NAMESIZE];
134 
135  bool bCalledEnable;
136  bool bCalledStatus;
137  bool bCalledIPAddress;
138  bool bCalledSubnetMask;
139  bool bCalledAddressingType;
140 
141  bool backupEnable;
142  char backupStatus[BUFF_LENGTH_16];
143 // char backupAlias[TR69HOSTIFMGR_MAX_PARAM_LEN];
144  char backupIPAddress[BUFF_LENGTH_64];
145  char backupSubnetMask[BUFF_LENGTH_64];
146  char backupAddressingType[BUFF_LENGTH_16];
147 
148  hostIf_IPv4Address(int dev_id);
149  ~hostIf_IPv4Address() {};
150 
151  void refreshInterfaceName ();
152  int getIPv4AddressAndMask (int instance, struct in_addr& in_address, struct in_addr& in_mask);
153  static bool isLinkLocalAddress (const struct in_addr& in_address);
154  bool hasPhysicalInterfaceAs (char* phy_if_name);
155  int setIpOrMask(int interfaceNo, char *value, const char* ipOrMask);
156 
157 public:
158 
159  static hostIf_IPv4Address* getInstance(int dev_id);
160  static GList* getAllInstances();
161  static void closeInstance(hostIf_IPv4Address*);
162  static void closeAllInstances();
163 
164  static void getLock();
165  static void releaseLock();
166 
167  int handleGetMsg (const char* pSubSetting, int subInstanceNumber, HOSTIF_MsgData_t* stMsgData);
168  int handleSetMsg (const char* pSubSetting, int subInstanceNumber, HOSTIF_MsgData_t* stMsgData);
169 
170  /**
171  * @brief Get status (enabled/disabled) of IPv4 address.
172  *
173  * This function provides the value (<tt>true/false</tt>) of the Enable status of this
174  * IPv4 address.
175  *
176  * See @ref dev_ip_ipv4address_getter
177  *
178  */
179  int get_IPv4Address_Enable(HOSTIF_MsgData_t *stMsgData,int subInstanceNo, bool *pChanged = NULL);
180 
181  int get_IPv4Address_Status(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
182 
183  int get_IPv4Address_Alias(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
184 
185  int get_IPv4Address_IPAddress(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
186 
187  int get_IPv4Address_SubnetMask(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
188 
189  int get_IPv4Address_AddressingType(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
190 
191  /* End of TR_069_DEVICE_IP_IPV4ADDRESS_GETTER_API doxygen group */
192  /**
193  * @}
194  */
195 
196  /** @addtogroup TR_069_DEVICE_IP_IPV4ADDRESS_SETTER_API TR-069 Device.IP.Interface.IPv4Address Setter API.
197  * @ingroup TR_069_DEVICE_IP_INTERFACE_IPV4ADDRESS_API
198  *
199  * \section dev_ip_ipv4address_setter TR-069 Device.IP.Interface.IPv4Address object Setter API
200  *
201  * This is the setter group of API for the <b>Device.IP.Interface.{i}.IPv4Address.{j}</b> object.
202  *
203  * The interface for all functions is identical and is described here.
204  *
205  * @param[in] *name This is the complete path name of the parameter extracted from
206  * soap message, e.g. ::set_Device_IP_Interface_IPv4Address_Enable.
207  * In this case, the path is "Device.IP.Interface.{i}.IPv4Address.{j}.Enable".
208  * @param[in] *type Data type of parameter defined for TR-069. This is same as the
209  * data type used in the Xi3 data-model.xml file.
210  * (see parameter.h)
211  * @param[in] *value This is the value to which the parameter requested by the ACS
212  * must be set.
213  * (see paramaccess.h)
214  *
215  * @return The status of the operation.
216  * @retval OK If parameter requested was successfully fetched. (Same as <b>NO_ERROR</b>).
217  * @retval NO_ERROR If parameter requested was successfully fetched. (Same as <b>OK</b>).
218  * @retval DIAG_ERROR Diagnostic error.
219  * @retval ERR_??? Appropriate error value otherwise (see dimark_globals.h).
220  *
221  * @todo Clarify description of DIAG_ERROR.
222  *
223  * @{
224  */
225 
226  int set_IPv4Address_Enable(HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
227 
228  int set_IPv4Address_Alias(HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
229 
230  int set_IPv4Address_IPAddress(HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
231 
232  int set_IPv4Address_SubnetMask(HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
233 
234  /* End of TR_069_DEVICE_IP_IPV4ADDRESS_SETTER_API doxygen group */
235  /**
236  * @}
237  */
238 };
239 
240 
241 #endif /* DEVICE_IP_INTERFACE_IPV4ADDRESS_H_ */
242 
243 
244 /** @} */
245 /** @} */
hostIf_IPv4Address::set_IPv4Address_SubnetMask
int set_IPv4Address_SubnetMask(HOSTIF_MsgData_t *stMsgData, int subInstanceNo)
This function sets an IP Interface IPv4Address Subnet Mask of an IPv4 address.
Definition: Device_IP_Interface_IPv4Address.cpp:756
hostIf_IPv4Address::get_IPv4Address_IPAddress
int get_IPv4Address_IPAddress(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function used to get an IP Interface IPv4 IP Address.
Definition: Device_IP_Interface_IPv4Address.cpp:446
hostIf_IPv4Address::isLinkLocalAddress
static bool isLinkLocalAddress(const struct in_addr &in_address)
tests if an IPv4 address is link-local.
Definition: Device_IP_Interface_IPv4Address.cpp:521
hostIf_IPv4Address::set_IPv4Address_Alias
int set_IPv4Address_Alias(HOSTIF_MsgData_t *stMsgData, int subInstanceNo)
This function sets a non-volatile handle used to reference this IPv4 address instance of this IP inte...
Definition: Device_IP_Interface_IPv4Address.cpp:712
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_main.h
hostIf_main API.
hostIf_IPv4Address
This class provides the hostIf IPv4 interface address for getting interface address information.
Definition: Device_IP_Interface_IPv4Address.h:127
hostIf_IPv4Address::set_IPv4Address_Enable
int set_IPv4Address_Enable(HOSTIF_MsgData_t *stMsgData, int subInstanceNo)
This function sets the device IP Interface IPv4 Address to 'Enable' or 'Disable'.
Definition: Device_IP_Interface_IPv4Address.cpp:658
hostIf_IPv4Address::get_IPv4Address_AddressingType
int get_IPv4Address_AddressingType(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function gets an IP Interface IPv4 Address AddressingType assign the IP address....
Definition: Device_IP_Interface_IPv4Address.cpp:551
hostIf_IPv4Address::get_IPv4Address_Status
int get_IPv4Address_Status(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function gets the status of an IPv4 Address table entry. It provides the status of this IPv4Addr...
Definition: Device_IP_Interface_IPv4Address.cpp:354
hostIf_IPv4Address::set_IPv4Address_IPAddress
int set_IPv4Address_IPAddress(HOSTIF_MsgData_t *stMsgData, int subInstanceNo)
This function sets an IP Interface IPv4 Address.
Definition: Device_IP_Interface_IPv4Address.cpp:733
hostIf_IPv4Address::get_IPv4Address_Enable
int get_IPv4Address_Enable(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
Get status (enabled/disabled) of IPv4 address.
Definition: Device_IP_Interface_IPv4Address.cpp:313
hostIf_IPv4Address::hostIf_IPv4Address
hostIf_IPv4Address(int dev_id)
Class Constructor of the class hostIf_IPv4Address.
Definition: Device_IP_Interface_IPv4Address.cpp:124
hostIf_IPv4Address::get_IPv4Address_Alias
int get_IPv4Address_Alias(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function gets the instance handle for an IPv4 Address of an IP Interface. It provides a non-vola...
Definition: Device_IP_Interface_IPv4Address.cpp:423
hostIf_IPv4Address::get_IPv4Address_SubnetMask
int get_IPv4Address_SubnetMask(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function gets an IP Interface IPv4 Address SubnetMask.
Definition: Device_IP_Interface_IPv4Address.cpp:487