RDK Documentation (Open Sourced RDK Components)
Device_IP_Interface_IPv6Address.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_Interface_IPv6Address.h
22  * @brief The header file provides TR069 device IPv6 interface address information APIs.
23  */
24 
25 /**
26  * @defgroup TR69_HOSTIF_DEVICE_IPv6_INTERFACE_ADDRESS TR-069 Object (Device.IP.Interface.IPv6Address)
27  * @par IPv6 address table
28  * This table contains the IP interface's IPv6 unicast addresses. There MUST be an entry for each such
29  * address, including any cast addresses.
30  *
31  * There are several ways in which entries can be added to and deleted from this table, including:
32  * - Automatically via SLAAC
33  * which covers generation of link-local addresses for all types of device and global addresses for
34  * non-router devices.
35  * - Automatically via DHCPv6
36  * which covers generation of any type of address subject to the configured DHCP server policy.
37  * - Manually via a GUI or some other local management interface.
38  * - Manually via factory default configuration.
39  * by the ACS. This table MUST NOT include entries for the Subnet-Router anycast address. Such
40  * entries would be identical to others but with a zero interface identifier, and would add no value.
41  *
42  * A loopback interface will always have address ::1 and MAY also have link-local address fe80::1.
43  * This object is based on ipAddressTable from [RFC4293].
44  * At most one entry in this table regardless of whether or not it is enabled can exist with
45  * a given value for Alias. On creation of a new table entry, the CPE MUST choose an initial
46  * value for Alias such that the new entry does not conflict with any existing entries.
47  *
48  * At most one enabled entry in this table can exist with a given value for IPAddress.
49  *
50  * @ingroup TR69_HOSTIF_DEVICE_IP
51  *
52  * @defgroup TR69_HOSTIF_DEVICE_IPv6_INTERFACE_ADDRESS_API TR-069 Object (Device.IP.Interface.IPv6Address) Public APIs
53  * Describe the details about RDK TR069 Device IPv6 Interface address APIs specifications.
54  * @ingroup TR69_HOSTIF_DEVICE_IPv6_INTERFACE_ADDRESS
55  *
56  * @defgroup TR69_HOSTIF_DEVICE_IPv6_INTERFACE_ADDRESS_CLASSES TR-069 Object (Device.IP.Interface.IPv6Address) Public Classes
57  * Describe the details about classes used in TR069 Device IPv6 Interface address.
58  * @ingroup TR69_HOSTIF_DEVICE_IPv6_INTERFACE_ADDRESS
59  *
60  * @defgroup TR69_HOSTIF_DEVICE_IPv6_INTERFACE_ADDRESS_DSSTRUCT TR-069 Object (Device.IP.Interface.IPv6Address) Public DataStructure
61  * Describe the details about data structure used in TR069 Device IPv6 Interface address.
62  * @ingroup TR69_HOSTIF_DEVICE_IPv6_INTERFACE_ADDRESS
63  */
64 
65 #ifndef DEVICE_IP_INTERFACE_IPV6ADDRESS_H_
66 #define DEVICE_IP_INTERFACE_IPV6ADDRESS_H_
67 
68 /*****************************************************************************
69  * TR069-SPECIFIC INCLUDE FILES
70  *****************************************************************************/
71 #include "hostIf_main.h"
72 #include "hostIf_tr69ReqHandler.h"
73 #include "hostIf_utils.h"
74 #include "hostIf_updateHandler.h"
75 #include <net/if.h>
76 
77 /**
78  * @brief This class provides the hostIf IP interface for getting IPv6 interface information.
79  * @ingroup TR69_HOSTIF_DEVICE_IPv6_INTERFACE_ADDRESS_CLASSES
80  */
82 
83  static GHashTable *ifHash;
84  static GMutex *m_mutex;
85 
86  int dev_id;
87  char nameOfInterface[IF_NAMESIZE];
88 
89  bool bCalledEnable;
90  bool bCalledStatus;
91  bool bCalledIPAddress;
92  bool bCalledOrigin;
93 
94  bool backupIPv6AddressEnable;
95  char backupIPv6AddressStatus[BUFF_LENGTH_16];
96  char backupIPv6AddressIPAddress[BUFF_LENGTH_64];
97  char backupIPv6AddressOrigin[BUFF_LENGTH_32];
98 
99  bool backupIPv6PrefixEnable;
100  char backupIPv6PrefixStatus[BUFF_LENGTH_16];
101  char backupIPv6PrefixPrefix[BUFF_LENGTH_64];
102  char backupIPv6PrefixOrigin[BUFF_LENGTH_32];
103 
104  static const char* PREFERRED;
105  static const char* DEPRECATED;
106  static const char* INVALID;
107  static const char* INACCESSIBLE;
108  static const char* UNKNOWN;
109  static const char* TENTATIVE;
110  static const char* DUPLICATE;
111  static const char* OPTIMISTIC;
112 
113  static const char* AUTOCONFIGURED;
114  static const char* DHCPv6;
115  static const char* WELLKNOWN;
116  static const char* STATIC;
117  static const char* PREFIXDELEGATION;
118  static const char* ROUTERADVERTISEMENT;
119  static const char* CHILD;
120  static const char* INAPPLICABLE;
121 
122  hostIf_IPv6Address(int dev_id);
124 
125  int getIPv6AddressAndMask (int instance, struct in6_addr& in6_address, struct in6_addr& in6_mask);
126  int getIPv6Prefix (int instance, struct in6_addr& in6_prefix_address, unsigned int& prefix_length);
127  static bool isLinkLocalAddress (const struct in6_addr& in6_address);
128 
129  bool get_ipv6address_lifetime (unsigned int instance, char* search_string, long int& lifetime);
130  bool get_ipv6address_preferred_lifetime (unsigned int instance, long int& preferred_lifetime);
131  bool get_ipv6address_valid_lifetime (unsigned int instance, long int& valid_lifetime);
132  void convert_lifetime_to_string (long int t, char* lifetime);
133 
134  int setIp(int interfaceNo, char *value);
135  int removeIp(int interfaceNo, char *value);
136  void refreshInterfaceName ();
137  int get_IPv6Prefix_Origin (int instance, char* origin);
138  int get_IPv6Prefix_StaticType (int instance, char* staticType);
139  int get_IPv6Prefix_ParentPrefix (int instance, char* parentPrefix);
140  int get_IPv6Prefix_ChildPrefixBits (int instance, char* childPrefixBits);
141 
142 public:
143 
144  static hostIf_IPv6Address* getInstance(int dev_id);
145  static GList* getAllInstances();
146  static void closeInstance(hostIf_IPv6Address*);
147  static void closeAllInstances();
148 
149  int handleGetMsg (const char* pSubSetting, int subInstanceNumber, HOSTIF_MsgData_t* stMsgData, bool isAddress);
150  int handleSetMsg (const char* pSubSetting, int subInstanceNumber, HOSTIF_MsgData_t* stMsgData, bool isAddress);
151 
152  int get_IPv6Address_Enable(HOSTIF_MsgData_t *stMsgData,int subInstanceNo, bool *pChanged = NULL);
153 
154  int get_IPv6Address_Status(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
155 
156  int get_IPv6Address_IPAddressStatus (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
157 
158  int get_IPv6Address_Alias(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
159 
160  int get_IPv6Address_IPAddress(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
161 
162  int get_IPv6Address_Origin(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
163 
164  int get_IPv6Address_Prefix (HOSTIF_MsgData_t *stMsgData,int subInstanceNo, bool *pChanged = NULL);
165  int get_IPv6Address_PreferredLifetime (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
166  int get_IPv6Address_ValidLifetime (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
167  int get_IPv6Address_Anycast (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
168 
169  int get_IPv6Prefix_Enable (HOSTIF_MsgData_t *stMsgData,int subInstanceNo, bool *pChanged = NULL);
170  int get_IPv6Prefix_Status (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
171  int get_IPv6Prefix_PrefixStatus (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
172  int get_IPv6Prefix_Alias (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
173  int get_IPv6Prefix_Prefix (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
174  int get_IPv6Prefix_Origin (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
175  int get_IPv6Prefix_StaticType (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
176  int get_IPv6Prefix_ParentPrefix (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
177  int get_IPv6Prefix_ChildPrefixBits (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
178  int get_IPv6Prefix_OnLink (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
179  int get_IPv6Prefix_Autonomous (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
180  int get_IPv6Prefix_PreferredLifetime (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
181  int get_IPv6Prefix_ValidLifetime (HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged = NULL);
182 
183  /* End of TR_069_DEVICE_IP_IPV6ADDRESS_GETTER_API doxygen group */
184  /**
185  * @}
186  */
187 
188  /**
189  *
190  * \section dev_ip_ipv6address_setter TR-069 Device.IP.Interface.IPv6Address object Setter API
191  *
192  * This is the setter group of API for the <b>Device.IP.Interface.{i}.IPv6Address.{j}</b> object.
193  *
194  * The interface for all functions is identical and is described here.
195  *
196  * @param[in] *name This is the complete path name of the parameter extracted from
197  * soap message, e.g. ::set_Device_IP_Interface_IPv6Address_Enable.
198  * In this case, the path is "Device.IP.Interface.{i}.IPv6Address.{j}.Enable".
199  * @param[in] *type Data type of parameter defined for TR-069. This is same as the
200  * data type used in the Xi3 data-model.xml file.
201  * (see parameter.h)
202  * @param[in] *value This is the value to which the parameter requested by the ACS
203  * must be set.
204  * (see paramaccess.h)
205  *
206  * @return The status of the operation.
207  * @retval OK If parameter requested was successfully fetched. (Same as <b>NO_ERROR</b>).
208  * @retval NO_ERROR If parameter requested was successfully fetched. (Same as <b>OK</b>).
209  * @retval DIAG_ERROR Diagnostic error.
210  * @retval ERR_??? Appropriate error value otherwise (see dimark_globals.h).
211  *
212  * @todo Clarify description of DIAG_ERROR.
213  *
214  * @{
215  */
216 
217  /**
218  * @brief Enable/Disable an IP Interface IPv6 Address.
219  *
220  * This function enables or disables this IPv6 address.
221  *
222  * See @ref dev_ip_ipv6address_setter
223  *
224  */
225  int set_IPv6Address_Enable(HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
226 
227  /**
228  * @brief Set the instance handle for an IPv6 Address of an IP Interface.
229  *
230  * This function sets a non-volatile handle used to reference this IPv6 address
231  * instance of this IP interface. Alias provides a mechanism for an ACS to label this
232  * instance for future reference.
233  *
234  * @note If the CPE supports the Alias-based Addressing feature as defined in
235  * [Section 3.6.1/TR-069 Amendment 4] and described in [Appendix II/TR-069
236  * Amendment 4], the following mandatory constraints MUST be enforced:
237  * <ul><li>Its value MUST NOT be empty.</li>
238  * <li>Its value MUST start with a letter.</li>
239  * <li>If its instance object is created by the CPE, the initial
240  * value MUST start with a "cpe-" prefix.</li>
241  * <li>The CPE MUST NOT change the parameter value.</li>
242  * </ul>
243  * @par
244  *
245  * See @ref dev_ip_ipv6address_setter
246  *
247  */
248 
249  int set_IPv6Address_Alias(HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
250 
251  /**
252  * @brief Set an IP Interface IPv6 Address.
253  *
254  * This function sets the IPv6 address.
255  *
256  * @note This parameter can only be modified if the Origin is <tt>Static</tt>.
257  *
258  * See @ref dev_ip_ipv6address_setter
259  *
260  */
261 
262  int set_IPv6Address_IPAddress(HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
263 
264  /* End of TR_069_DEVICE_IP_IPV6ADDRESS_SETTER_API doxygen group */
265  /**
266  * @}
267  */
268 
269  int set_IPv6Address_Prefix (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
270  int set_IPv6Address_PreferredLifetime (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
271  int set_IPv6Address_ValidLifetime (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
272  int set_IPv6Address_Anycast (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
273 
274  /* IPv6Prefix profile set methods */
275  int set_IPv6Prefix_Enable (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
276  int set_IPv6Prefix_Alias (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
277  int set_IPv6Prefix_Prefix (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
278  int set_IPv6Prefix_StaticType (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
279  int set_IPv6Prefix_ParentPrefix (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
280  int set_IPv6Prefix_ChildPrefixBits (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
281  int set_IPv6Prefix_OnLink (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
282  int set_IPv6Prefix_Autonomous (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
283  int set_IPv6Prefix_PreferredLifetime (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
284  int set_IPv6Prefix_ValidLifetime (HOSTIF_MsgData_t *stMsgData, int subInstanceNo);
285 };
286 
287 
288 #endif /* DEVICE_IP_INTERFACE_IPV6ADDRESS_H_ */
hostIf_IPv6Address::set_IPv6Address_Enable
int set_IPv6Address_Enable(HOSTIF_MsgData_t *stMsgData, int subInstanceNo)
Enable/Disable an IP Interface IPv6 Address.
Definition: Device_IP_Interface_IPv6Address.cpp:1813
hostIf_IPv6Address::set_IPv6Address_Alias
int set_IPv6Address_Alias(HOSTIF_MsgData_t *stMsgData, int subInstanceNo)
Set the instance handle for an IPv6 Address of an IP Interface.
Definition: Device_IP_Interface_IPv6Address.cpp:1844
hostIf_IPv6Address::isLinkLocalAddress
static bool isLinkLocalAddress(const struct in6_addr &in6_address)
tests if an IPv6 address is link-local.
Definition: Device_IP_Interface_IPv6Address.cpp:485
hostIf_IPv6Address::get_IPv6Address_IPAddress
int get_IPv6Address_IPAddress(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function provides the IPv6 address.
Definition: Device_IP_Interface_IPv6Address.cpp:863
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_IPv6Address::get_ipv6address_lifetime
bool get_ipv6address_lifetime(unsigned int instance, char *search_string, long int &lifetime)
Definition: Device_IP_Interface_IPv6Address.cpp:1105
hostIf_main.h
hostIf_main API.
hostIf_IPv6Address::get_ipv6address_valid_lifetime
bool get_ipv6address_valid_lifetime(unsigned int instance, long int &valid_lifetime)
Definition: Device_IP_Interface_IPv6Address.cpp:1191
hostIf_IPv6Address
This class provides the hostIf IP interface for getting IPv6 interface information.
Definition: Device_IP_Interface_IPv6Address.h:81
hostIf_IPv6Address::get_IPv6Address_Origin
int get_IPv6Address_Origin(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function provides the addressing method used to assign the IP address. The Possible enum vlaues.
Definition: Device_IP_Interface_IPv6Address.cpp:911
hostIf_IPv6Address::get_IPv6Address_Status
int get_IPv6Address_Status(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function provides the status of this IPv6Address table entry. Possible values.
Definition: Device_IP_Interface_IPv6Address.cpp:695
hostIf_IPv6Address::get_IPv6Address_Alias
int get_IPv6Address_Alias(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function provides a non-volatile handle used to reference this IPv6 address instance of this IP ...
Definition: Device_IP_Interface_IPv6Address.cpp:840
hostIf_IPv6Address::get_IPv6Address_Enable
int get_IPv6Address_Enable(HOSTIF_MsgData_t *stMsgData, int subInstanceNo, bool *pChanged=NULL)
This function provides the value 'true' or 'false' for Enable status of IPv6 address.
Definition: Device_IP_Interface_IPv6Address.cpp:653
hostIf_IPv6Address::get_ipv6address_preferred_lifetime
bool get_ipv6address_preferred_lifetime(unsigned int instance, long int &preferred_lifetime)
Definition: Device_IP_Interface_IPv6Address.cpp:1176
hostIf_IPv6Address::set_IPv6Address_IPAddress
int set_IPv6Address_IPAddress(HOSTIF_MsgData_t *stMsgData, int subInstanceNo)
Set an IP Interface IPv6 Address.
Definition: Device_IP_Interface_IPv6Address.cpp:1866