RDK Documentation (Open Sourced RDK Components)
Device_IP_Interface.cpp
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.cpp
22  * @brief This source file contains the APIs of device IP interface.
23  */
24 
25 /*****************************************************************************
26  * STANDARD INCLUDE FILES
27  *****************************************************************************/
28 
29 
30 /**
31 * @defgroup tr69hostif
32 * @{
33 * @defgroup hostif
34 * @{
35 **/
36 
37 
38 #include "hostIf_utils.h"
39 #include "Device_IP_Interface.h"
41 #include <ifaddrs.h>
42 #include <stdio.h>
43 #include <string.h>
44 #include <sys/types.h>
45 #include <sys/socket.h>
46 #include <sys/ioctl.h>
47 #include <net/if.h>
48 #include <netinet/in.h>
49 #include <unistd.h>
50 #include <errno.h>
51 #include "Device_IP.h"
52 #include "safec_lib.h"
53 
54 // TODO: fix potential bug with initialization, as structure definition now has a "#ifdef IPV6_SUPPORT"
55 IPInterface hostIf_IPInterface::stIPInterfaceInstance = {FALSE,FALSE,FALSE,FALSE,{"Down"},{'\0'},{'\0'},0,{'\0'},{'\0'},FALSE,0,{"Normal"},FALSE,0,
56 #ifdef IPV6_SUPPORT
57  0,
58 #endif
59  FALSE };
60 
61 GHashTable *hostIf_IPInterface::ifHash = NULL;
62 
63 int hostIf_IPInterface::set_Interface_Enable (int value)
64 {
65  LOG_ENTRY_EXIT;
66 
67  char cmd[BUFF_LENGTH] = { 0 };
68  if (FALSE == value)
69  {
70  sprintf (cmd, "ifconfig %s down", nameOfInterface);
71  //RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s(): interfaceName = %s Disabled\n",__FUNCTION__, nameOfInterface);
72  }
73  else if (TRUE == value)
74  {
75  sprintf (cmd, "ifconfig %s up", nameOfInterface);
76  //RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s(): interfaceName = %s Enabled\n",__FUNCTION__, nameOfInterface);
77  }
78 
79  return (system (cmd) < 0) ? NOK : OK;
80 }
81 
82 int hostIf_IPInterface::set_Interface_Reset (unsigned int value)
83 {
84  LOG_ENTRY_EXIT;
85 
86  if (TRUE == value)
87  {
88  char cmd[BUFF_LENGTH] = { 0 };
89 
90  sprintf (cmd, "ifdown %s", nameOfInterface);
91  if (system (cmd) < 0)
92  return NOK;
93 
94  sprintf (cmd, "ifup %s", nameOfInterface);
95  if (system (cmd) < 0)
96  return NOK;
97 
98  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s(): interfaceName = %s Reset Done\n", __FUNCTION__, nameOfInterface);
99  }
100 
101  return OK;
102 }
103 
104 int hostIf_IPInterface::set_Interface_Mtu (unsigned int value)
105 {
106  LOG_ENTRY_EXIT;
107 
108  char cmd[BUFF_LENGTH] = { 0 };
109  sprintf (cmd, "ifconfig %s mtu %d", nameOfInterface, value);
110  if (system (cmd) < 0)
111  return NOK;
112 
113  //RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s(): interfaceName = %s MaxMTUSize Set with value %u\n",__FUNCTION__, nameOfInterface,value);
114 
115  return OK;
116 }
117 
118 void hostIf_IPInterface::refreshInterfaceName ()
119 {
120  nameOfInterface[0] = 0;
121  if (NULL == hostIf_IP::getInterfaceName (dev_id, nameOfInterface))
122  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: error getting interface name for Device.IP.Interface.%d\n", __FUNCTION__, dev_id);
123 }
124 
125 /**
126  * @brief Class Constructor of the class hostIf_IPInterface.
127  *
128  * It will initialize the device id. Initialize the type and name to empty string.
129  *
130  * @param[in] dev_id Device identification number.
131  */
133  dev_id(dev_id),
134  bCalledEnable(false),
135  bCalledIPv4Enable(false),
136  bCalledIPv6Enable(false),
137  bCalledStatus(false),
138  bCalledName(false),
139  bCalledReset(false),
140  bCalledMaxMTUSize(false),
141  bCalledType(false),
142  bCalledLoopback(false),
143  bCalledIPv4AddressNumberOfEntries(false),
144  backupLoopback(false),
145  backupReset(false),
146  backupIPv4Enable(false),
147  backupIPv6Enable(false),
148  backupEnable(false),
149  backupIPv4AddressNumberOfEntries(0),
150  backupMaxMTUSize(0)
151 
152 {
153  backupType[0]='\0';
154  backupName[0]='\0';
155  backupStatus[0]='\0';
156 }
157 
158 hostIf_IPInterface* hostIf_IPInterface::getInstance(int dev_id)
159 {
160  LOG_ENTRY_EXIT;
161 
162  hostIf_IPInterface* pRet = NULL;
163 
164  if(ifHash)
165  {
166  pRet = (hostIf_IPInterface *)g_hash_table_lookup(ifHash,(gpointer) dev_id);
167  }
168  else
169  {
170  ifHash = g_hash_table_new(NULL,NULL);
171  }
172 
173  if(!pRet)
174  {
175  try {
176  pRet = new hostIf_IPInterface(dev_id);
177  } catch(int e)
178  {
179  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught exception, not able create MoCA Interface instance..\n");
180  }
181  g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
182  }
183 
184  // make sure returned instance has interface name set
185  if (pRet)
186  pRet->refreshInterfaceName ();
187 
188  return pRet;
189 }
190 
191 GList* hostIf_IPInterface::getAllInstances()
192 {
193  LOG_ENTRY_EXIT;
194 
195  if(ifHash)
196  return g_hash_table_get_keys(ifHash);
197  return NULL;
198 }
199 
200 void hostIf_IPInterface::closeInstance(hostIf_IPInterface *pDev)
201 {
202  LOG_ENTRY_EXIT;
203 
204  if(pDev)
205  {
206  g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
207  delete pDev;
208  }
209 }
210 
211 void hostIf_IPInterface::closeAllInstances()
212 {
213  LOG_ENTRY_EXIT;
214 
215  if(ifHash)
216  {
217  GList* tmp_list = g_hash_table_get_values (ifHash);
218 
219  while(tmp_list)
220  {
221  hostIf_IPInterface* pDev = (hostIf_IPInterface *)tmp_list->data;
222  tmp_list = tmp_list->next;
223  closeInstance(pDev);
224  }
225  }
226 }
227 
228 int hostIf_IPInterface::handleGetMsg (const char* pSetting, HOSTIF_MsgData_t* stMsgData)
229 {
230  LOG_ENTRY_EXIT;
231 
232  int ret = NOT_HANDLED;
233 
234  if (!strcasecmp (pSetting, "Enable"))
235  {
236  ret = get_Interface_Enable (stMsgData);
237  }
238  else if (!strcasecmp (pSetting, "IPv4Enable"))
239  {
240  ret = get_Interface_IPv4Enable (stMsgData);
241  }
242  else if (!strcasecmp (pSetting, "IPv6Enable"))
243  {
244  ret = get_Interface_IPv6Enable (stMsgData);
245  }
246  else if (!strcasecmp (pSetting, "ULAEnable"))
247  {
248  ret = get_Interface_ULAEnable (stMsgData);
249  }
250  else if (!strcasecmp (pSetting, "Status"))
251  {
252  ret = get_Interface_Status (stMsgData);
253  }
254  else if (!strcasecmp (pSetting, "Alias"))
255  {
256  ret = get_Interface_Alias (stMsgData);
257  }
258  else if (!strcasecmp (pSetting, "Name"))
259  {
260  ret = get_Interface_Name (stMsgData);
261  }
262  else if (!strcasecmp (pSetting, "LastChange"))
263  {
264  ret = get_Interface_LastChange (stMsgData);
265  }
266  else if (!strcasecmp (pSetting, "LowerLayers"))
267  {
268  ret = get_Interface_LowerLayers (stMsgData);
269  }
270  else if (!strcasecmp (pSetting, "Router"))
271  {
272  ret = get_Interface_Router (stMsgData);
273  }
274  else if (!strcasecmp (pSetting, "Reset"))
275  {
276  ret = get_Interface_Reset (stMsgData);
277  }
278  else if (!strcasecmp (pSetting, "MaxMTUSize"))
279  {
280  ret = get_Interface_MaxMTUSize (stMsgData);
281  }
282  else if (!strcasecmp (pSetting, "Type"))
283  {
284  ret = get_Interface_Type (stMsgData);
285  }
286  else if (!strcasecmp (pSetting, "Loopback"))
287  {
288  ret = get_Interface_Loopback (stMsgData);
289  }
290  else if (!strcasecmp (pSetting, "IPv4AddressNumberOfEntries"))
291  {
293  }
294 #ifdef IPV6_SUPPORT
295  else if (!strcasecmp (pSetting, "IPv6AddressNumberOfEntries"))
296  {
297  ret = get_Interface_IPv6AddressNumberOfEntries (stMsgData);
298  }
299  else if (!strcasecmp (pSetting, "IPv6PrefixNumberOfEntries"))
300  {
301  ret = get_Interface_IPv6PrefixNumberOfEntries (stMsgData);
302  }
303 #endif // IPV6_SUPPORT
304  else if (!strcasecmp (pSetting, "AutoIPEnable"))
305  {
306  ret = get_Interface_AutoIPEnable (stMsgData);
307  }
308  else
309  {
310  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d] IP : Parameter \'%s\' is Not Supported \n", __FUNCTION__, __LINE__, stMsgData->paramName);
311  stMsgData->faultCode = fcInvalidParameterName;
312  ret = NOK;
313  }
314 
315  return ret;
316 }
317 
318 int hostIf_IPInterface::handleSetMsg (const char* pSetting, HOSTIF_MsgData_t* stMsgData)
319 {
320  LOG_ENTRY_EXIT;
321 
322  int ret = NOT_HANDLED;
323 
324  if (!strcasecmp (pSetting, "Enable"))
325  {
326  ret = set_Interface_Enable (stMsgData);
327  }
328  else if (!strcasecmp (pSetting, "IPv4Enable"))
329  {
330  ret = set_Interface_IPv4Enable (stMsgData);
331  }
332  else if (!strcasecmp (pSetting, "Reset"))
333  {
334  ret = set_Interface_Reset (stMsgData);
335  }
336  else if (!strcasecmp (pSetting, "MaxMTUSize"))
337  {
338  ret = set_Interface_MaxMTUSize (stMsgData);
339  }
340  else
341  {
342  stMsgData->faultCode = fcInvalidParameterName;
343  ret = NOT_HANDLED;
344  }
345 
346  return ret;
347 }
348 
349 /****************************************************************************************************************************************************/
350 // Device.IP.Interface. Profile. Getters:
351 /****************************************************************************************************************************************************/
352 
353 /**
354  * @brief This function gets the status to enabled or disabled of an IP Interface.
355  * It provides the values such as 'true' or 'false' to Enable the status of IP interface.
356  *
357  * @param[out] stMsgData TR-069 Host interface message request.
358  * @param[in] pChanged Status of the operation.
359  *
360  * @return Returns the status of the operation.
361  *
362  * @retval OK if it is successfully fetch the data from the device.
363  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
364  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
365  */
367 {
368  LOG_ENTRY_EXIT;
369 
370  stIPInterfaceInstance.enable = isEnabled (nameOfInterface);
371 
372  if(bCalledEnable && pChanged && (backupEnable != stIPInterfaceInstance.enable))
373  {
374  *pChanged = true;
375  }
376  bCalledEnable = true;
377  backupEnable = stIPInterfaceInstance.enable;
378  put_int(stMsgData->paramValue,stIPInterfaceInstance.enable);
379  stMsgData->paramtype = hostIf_BooleanType;
380  stMsgData->paramLen = 1;
381 
382  return OK;
383 }
384 
385 /**
386  * @brief This function gets the status of the IPv4 stack attachment for an IP interface.
387  * It indicates whether or not this IP interface is attached to the IPv4
388  * stack. If set to 'true', then this interface is attached to the IPv4 stack.
389  * If set to 'false', then this interface is detached from the IPv4 stack.
390  *
391  * @note - Once detached from the IPv4 stack, the interface will now no
392  * longer be able to pass IPv4 packets, and will be operationally down
393  * unless until it attached to an enabled IPv6 stack.
394  *
395  * - For an IPv4 capable device, if IPv4Enable is not present this
396  * interface SHOULD be permanently attached to the IPv4 stack.
397  *
398  * - IPv4Enable is independent of Enable, and that to administratively
399  * enable an interface for IPv4 it is necessary for both Enable and
400  * IPv4Enable to be 'true'.
401  *
402  * @param[out] stMsgData TR-069 Host interface message request.
403  * @param[in] pChanged Status of the operation.
404  *
405  * @return Returns the status of the operation.
406  *
407  * @retval OK if it is successfully fetch the data from the device.
408  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
409  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
410  */
412 {
413  LOG_ENTRY_EXIT;
414 
415  errno_t rc = -1;
416  // Separating this out from Enable/Status as they are independent variables as per
417  // the spec: https://www.broadband-forum.org/cwmp/tr-181-2-11-0.html
418  // "Note that IPv4Enable is independent of Enable, and that to administratively enable
419  // an interface for IPv4 it is necessary for both Enable and IPv4Enable to be true."
420 
421  stIPInterfaceInstance.iPv4Enable = (getIPv4AddressNumberOfEntries () >= 1);
422 
423  // If "Enable" is false, "Status" can be marked "Down" as per this from the spec:
424  // "Enable - "Enables or disables the interface (regardless of IPv4Enable and IPv6Enable)."
425  // If both "Enable" and "IPv4Enable" are true, "Status" = Up. But if "IPv4Enable" = false,
426  // can't say "Status" = "Down"; need to also check "IPv6Enable" = false because spec says:
427  // "Once detached from the IPv4 stack, the interface will now no longer be able to
428  // pass IPv4 packets, and will be operationally down (unless also attached to an
429  // enabled IPv6 stack)."
430 // rc=strcpy_s (stIPInterfaceInstance.status,sizeof(stIPInterfaceInstance.status),
431  // stIPInterfaceInstance.enable && (stIPInterfaceInstance.iPv4Enable || stIPInterfaceInstance.iPv6Enable) ? STATE_UP : STATE_DOWN);
432  if(stIPInterfaceInstance.enable && (stIPInterfaceInstance.iPv4Enable || stIPInterfaceInstance.iPv6Enable))
433  {
434  rc=strcpy_s (stIPInterfaceInstance.status,sizeof(stIPInterfaceInstance.status),STATE_UP);
435  }
436  else
437  {
438  rc=strcpy_s (stIPInterfaceInstance.status,sizeof(stIPInterfaceInstance.status),STATE_DOWN);
439  }
440  if(rc!=EOK)
441  {
442  ERR_CHK(rc);
443  }
444  // TODO: Why write to Status when read requested on IPv4Enable?
445 
446  //RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s(): Enable: %d IPv4Enable: %d Status: %s \n",__FUNCTION__,stIPInterfaceInstance.enable,stIPInterfaceInstance.iPv4Enable,stIPInterfaceInstance.status);
447 
448  if(bCalledIPv4Enable && pChanged && (backupIPv4Enable != stIPInterfaceInstance.iPv4Enable))
449  {
450  *pChanged = true;
451  }
452  bCalledIPv4Enable = true;
453  backupIPv4Enable = stIPInterfaceInstance.iPv4Enable;
454  put_int(stMsgData->paramValue,stIPInterfaceInstance.iPv4Enable);
455  stMsgData->paramtype = hostIf_BooleanType;
456  stMsgData->paramLen = 1;
457 
458  return OK;
459 }
460 
461 int hostIf_IPInterface::get_Interface_IPv6Enable(HOSTIF_MsgData_t *stMsgData, bool *pChanged)
462 {
463  LOG_ENTRY_EXIT;
464 
465  errno_t rc = -1;
466  stIPInterfaceInstance.iPv6Enable = (getIPv6AddressNumberOfEntries () >= 1);
467 
468  //rc=strcpy_s (stIPInterfaceInstance.status,sizeof(stIPInterfaceInstance.status),
469  //stIPInterfaceInstance.enable && (stIPInterfaceInstance.iPv4Enable || stIPInterfaceInstance.iPv6Enable) ? STATE_UP : STATE_DOWN);
470  if(stIPInterfaceInstance.enable && (stIPInterfaceInstance.iPv4Enable || stIPInterfaceInstance.iPv6Enable))
471  {
472  rc=strcpy_s (stIPInterfaceInstance.status,sizeof(stIPInterfaceInstance.status),STATE_UP);
473  }
474  else
475  {
476  rc=strcpy_s (stIPInterfaceInstance.status,sizeof(stIPInterfaceInstance.status),STATE_DOWN);
477  }
478  if(rc!=EOK)
479  {
480  ERR_CHK(rc);
481  }
482 
483  // TODO: Why write to Status when read requested on IPv6Enable?
484 
485  //RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s(): Enable: %d IPv6Enable: %d Status: %s \n",__FUNCTION__,stIPInterfaceInstance.enable,stIPInterfaceInstance.iPv6Enable,stIPInterfaceInstance.status);
486 
487  if(bCalledIPv6Enable && pChanged && (backupIPv6Enable != stIPInterfaceInstance.iPv6Enable))
488  {
489  *pChanged = true;
490  }
491  bCalledIPv6Enable = true;
492  backupIPv6Enable = stIPInterfaceInstance.iPv6Enable;
493  put_int(stMsgData->paramValue,stIPInterfaceInstance.iPv6Enable);
494  stMsgData->paramtype = hostIf_BooleanType;
495  stMsgData->paramLen = 1;
496 
497  return OK;
498 }
499 
500 /**
501  * @brief This function gets the status 'enabled' or 'disabled' of ULA(Unique local address)
502  * generation for an IP Interface. It indicates the status as 'true' or 'false' of the ULA
503  * generation and use this IP interface is enabled. Currently not implemented.
504  *
505  * @param[out] stMsgData TR-069 Host interface message request.
506  * @param[in] pChanged Status of the operation.
507  *
508  * @return Returns the status of the operation.
509  *
510  * @retval OK if it is successfully fetch the data from the device.
511  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
512  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
513  */
515 {
516  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
517 
518  return NOK;
519 }
520 
521 void hostIf_IPInterface::getInterfaceOperationalState (char* operationalState)
522 {
523  LOG_ENTRY_EXIT;
524 
525  errno_t rc = -1;
526  struct ifreq ifr;
527  getActiveFlags (nameOfInterface, ifr);
528  //rc=strcpy_s (operationalState, IP_STATUS_LENGTH,(ifr.ifr_flags & IFF_UP) ? STATE_UP : STATE_DOWN);
529  if(ifr.ifr_flags & IFF_UP)
530  {
531  rc=strcpy_s (operationalState, IP_STATUS_LENGTH,STATE_UP);
532  }
533  else
534  {
535  rc=strcpy_s (operationalState, IP_STATUS_LENGTH,STATE_DOWN);
536  }
537  if(rc!=EOK)
538  {
539  ERR_CHK(rc);
540  }
541 }
542 
543 /**
544  * @brief This function gets the IP interface Status. It provides the current operational state
545  * of the Interface. Possible state are Up, Down, Unknown, Dormant, NotPresent, LowerLayerDown
546  * Error (OPTIONAL).
547  * @note <ul><li> When Enable flag is false then Status SHOULD normally be Down (or NotPresent
548  * or Error if there is a fault condition on the interface).</li>
549  * <li> When Enable is changed to true then ...
550  * <ul><li>Status SHOULD change to Up if and only if the interface is able to
551  * transmit and receive network traffic.</li>
552  * <li>Status SHOULD change to Dormant if and only if the interface is operable
553  * but is waiting for external actions before it can transmit and receive
554  * network traffic (and subsequently change to Up if still operable when the
555  * expected actions have completed).</li>
556  * <li>Status SHOULD change to LowerLayerDown if and only if the interface is
557  * prevented from entering the Up state because one or more of the
558  * interfaces beneath it is down.</li>
559  * <li>Status SHOULD remain in the Error state if there is an error or other
560  * fault condition detected on the interface.</li>
561  * <li>Status SHOULD remain in the NotPresent state if the interface has missing
562  * (typically hardware) components.</li>
563  * <li>Status SHOULD change to Unknown if the state of the interface can not be
564  * determined for some reason.</li></ul>
565  * </li></ul>
566  *
567  * @param[out] stMsgData TR-069 Host interface message request.
568  * @param[in] pChanged Status of the operation.
569  *
570  * @return Returns the status of the operation.
571  *
572  * @retval OK if it is successfully fetch the data from the device.
573  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
574  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
575  */
577 {
578  LOG_ENTRY_EXIT;
579 
580  getInterfaceOperationalState (stIPInterfaceInstance.status);
581 
582  if(bCalledStatus && pChanged && strncmp(stIPInterfaceInstance.status, backupStatus,_BUF_LEN_16 ))
583  {
584  *pChanged = true;
585  }
586  bCalledStatus = true;
587  strncpy(stMsgData->paramValue,stIPInterfaceInstance.status,TR69HOSTIFMGR_MAX_PARAM_LEN );
588  strncpy(backupStatus,stIPInterfaceInstance.status,sizeof(backupStatus) -1); //CID:136596 - Buffer size warning
589  backupStatus[sizeof(backupStatus) -1] = '\0';
590  stMsgData->paramtype = hostIf_StringType;
591  stMsgData->paramLen = strlen(stIPInterfaceInstance.status);
592 
593  return OK;
594 }
595 
596 /**
597  * @brief This function gets the instance handle for an IP Interface. It provides a non-volatile handle
598  * used to reference this IP interface instance. Alias provides a mechanism for an ACS to label this
599  * instance for future reference. Currently not implemented.
600  *
601  * @note If the CPE supports the Alias-based Addressing feature as defined in
602  * [Section 3.6.1/TR-069 Amendment 4] and described in [Appendix II/TR-069
603  * Amendment 4], the following mandatory constraints MUST be enforced:
604  * <ul><li>Its value MUST NOT be empty.</li>
605  * <li>Its value MUST start with a letter.</li>
606  * <li>If its instance object is created by the CPE, the initial
607  * value MUST start with a "cpe-" prefix.</li>
608  * <li>The CPE MUST NOT change the parameter value.</li>
609  * </ul>
610  *
611  * @param[out] stMsgData TR-069 Host interface message request.
612  * @param[in] pChanged Status of the operation.
613  *
614  * @return Returns the status of the operation.
615  *
616  * @retval OK if it is successfully fetch the data from the device.
617  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
618  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
619  */
621 {
622  return NOK;
623 }
624 
625 /**
626  * @brief This function gets the IP Interface Name.It provides the textual name of the interface as
627  * assigned by the CPE(Customer Premises Equipment).
628  *
629  * @param[out] stMsgData TR-069 Host interface message request.
630  * @param[in] pChanged Status of the operation.
631  *
632  * @return Returns the status of the operation.
633  *
634  * @retval OK if it is successfully fetch the data from the device.
635  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
636  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
637  */
639 {
640  LOG_ENTRY_EXIT;
641 
642  errno_t rc = -1;
643  rc=strcpy_s (stIPInterfaceInstance.name,sizeof(stIPInterfaceInstance.name), nameOfInterface);
644  if(rc!=EOK)
645  {
646  ERR_CHK(rc);
647  }
648 
649  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): Interface name = %s \n", __FUNCTION__, stIPInterfaceInstance.name);
650 
651  if(bCalledName && pChanged && strncmp(stIPInterfaceInstance.name, backupName,_BUF_LEN_16 ))
652  {
653  *pChanged = true;
654  }
655  bCalledName = true;
656  strncpy(stMsgData->paramValue,stIPInterfaceInstance.name,TR69HOSTIFMGR_MAX_PARAM_LEN-1 );
657  stMsgData->paramValue[TR69HOSTIFMGR_MAX_PARAM_LEN-1] = '\0';
658  strncpy(backupName,stIPInterfaceInstance.name,_BUF_LEN_16-1 );
659  backupName[_BUF_LEN_16-1] = '\0';
660  stMsgData->paramtype = hostIf_StringType;
661  stMsgData->paramLen = strlen(stIPInterfaceInstance.name);
662 
663 
664  return OK;
665 }
666 
667 /**
668  * @brief This function gets the last change of status time of the interface. It provides the accumulated
669  * time in seconds since the interface entered its current operational state. Currently not implemented.
670  *
671  * @param[out] stMsgData TR-069 Host interface message request.
672  * @param[in] pChanged Status of the operation.
673  *
674  * @return Returns the status of the operation.
675  *
676  * @retval OK if it is successfully fetch the data from the device.
677  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
678  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
679  */
681 {
682  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
683 
684  return NOK;
685 }
686 
687 /**
688  * @brief This function gets the IP Interface LowerLayers. It provides a comma-separated
689  * list (maximum length 1024) of strings. Each list item MUST be the path name of an
690  * interface object that is stacked immediately below this interface object.
691  * Currently not implemented.
692  *
693  * @note - If the referenced object is deleted, the corresponding item MUST be removed
694  * from the list.
695  * - LowerLayers MUST be an empty string and 'read-only' when Type is Loop back,
696  * Tunnel, or Tunnelled.
697  *
698  *
699  * @param[out] stMsgData TR-069 Host interface message request.
700  * @param[in] pChanged Status of the operation.
701  *
702  * @return Returns the status of the operation.
703  *
704  * @retval OK if it is successfully fetch the data from the device.
705  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
706  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
707  */
709 {
710  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
711 
712  return NOK;
713 }
714 
715 /**
716  * @brief This function gets the Router instance that is associated with an IP Interface entry.
717  * It provides the Router instance that is associated with this IP Interface entry.
718  * Currently not implemented.
719  *
720  * @note <ul>
721  * <li>The value MUST be the path name of a row in the
722  * <tt>Routing.Router</tt> table.</li>
723  * <li>If the referenced object is deleted, the parameter value MUST be
724  * set to an empty string.</li>
725  * </ul>
726  *
727  * @param[out] stMsgData TR-069 Host interface message request.
728  * @param[in] pChanged Status of the operation.
729  *
730  * @return Returns the status of the operation.
731  *
732  * @retval OK if it is successfully fetch the data from the device.
733  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
734  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
735  */
737 {
738  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
739 
740  return NOK;
741 }
742 
743 /**
744  * @brief This function gets the IP Interface Reset status. It returns 'false', regardless
745  * of the actual value.
746  *
747  * @note - The value of this parameter is not part of the device configuration and is
748  * always false when read.
749  *
750  * @param[out] stMsgData TR-069 Host interface message request.
751  * @param[in] pChanged Status of the operation.
752  *
753  * @return Returns the status of the operation.
754  *
755  * @retval OK if it is successfully fetch the data from the device.
756  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
757  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
758  */
760 {
761  LOG_ENTRY_EXIT;
762 
763  /*According to specification,When read, this parameter returns false, regardless of the actual value.*/
764  stIPInterfaceInstance.reset = FALSE;
765 
766  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): Reset: %d\n", __FUNCTION__, stIPInterfaceInstance.reset);
767 
768  if(bCalledReset && pChanged && (backupReset != stIPInterfaceInstance.reset))
769  {
770  *pChanged = true;
771  }
772  bCalledReset = true;
773  backupReset = stIPInterfaceInstance.reset;
774  put_int(stMsgData->paramValue,stIPInterfaceInstance.reset);
775  stMsgData->paramtype = hostIf_BooleanType;
776  stMsgData->paramLen = 1;
777 
778  return OK;
779 }
780 
781 /**
782  * @brief This function gets the IP Interface MaxMTUSize. It provides the maximum transmission unit (MTU),
783  * i.e. the largest allowed size of an IP packet (including IP headers, but excluding lower layer headers such as
784  * Ethernet, PPP, or PPPoE headers) that is allowed to be transmitted by or through this device.
785  *
786  * @param[out] stMsgData TR-069 Host interface message request.
787  * @param[in] pChanged Status of the operation.
788  *
789  * @return Returns the status of the operation.
790  *
791  * @retval OK if it is successfully fetch the data from the device.
792  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
793  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
794  */
796 {
797  LOG_ENTRY_EXIT;
798 
799  stIPInterfaceInstance.maxMTUSize = getMTU (nameOfInterface);
800 
801  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): MaxMTUSize: %u \n", __FUNCTION__, stIPInterfaceInstance.maxMTUSize);
802 
803  if(bCalledMaxMTUSize && pChanged && (backupMaxMTUSize != stIPInterfaceInstance.maxMTUSize))
804  {
805  *pChanged = true;
806  }
807  bCalledMaxMTUSize = true;
808  backupMaxMTUSize = stIPInterfaceInstance.maxMTUSize;
809  put_int(stMsgData->paramValue,stIPInterfaceInstance.maxMTUSize);
810  stMsgData->paramtype = hostIf_UnsignedIntType;
811  stMsgData->paramLen = 4;
812 
813  return OK;
814 }
815 
816 /**
817  * @brief This function gets the IP Interface Type. It provides the IP interface type.
818  * Possible values are Normal, Loopback, Tunnel, Tunnelled.
819  * @note For 'Loopback', 'Tunnel', and 'Tunnelled' IP interface
820  * objects, the LowerLayers parameter MUST be an empty string.
821  *
822  * @param[out] stMsgData TR-069 Host interface message request.
823  * @param[in] pChanged Status of the operation.
824  *
825  * @return Returns the status of the operation.
826  *
827  * @retval OK if it is successfully fetch the data from the device.
828  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
829  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
830  */
832 {
833  LOG_ENTRY_EXIT;
834 
835  errno_t rc = -1;
836  if (isLoopback (nameOfInterface))
837  {
838  rc=strcpy_s (stIPInterfaceInstance.type,sizeof(stIPInterfaceInstance.type), "Loopback");
839  if(rc!=EOK)
840  {
841  ERR_CHK(rc);
842  }
843  }
844  else if (0 == strncmp (nameOfInterface, "eth", 3) || 0 == strncmp (nameOfInterface, "wlan", 4))
845  {
846  rc=strcpy_s (stIPInterfaceInstance.type,sizeof(stIPInterfaceInstance.type), "Normal");
847  if(rc!=EOK)
848  {
849  ERR_CHK(rc);
850  }
851  }
852  else
853  {
854  rc=strcpy_s (stIPInterfaceInstance.type,sizeof(stIPInterfaceInstance.type), "Tunneled");
855  if(rc!=EOK)
856  {
857  ERR_CHK(rc);
858  }
859  }
860 
861  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): Type: %s \n", __FUNCTION__, stIPInterfaceInstance.type);
862 
863  if(bCalledType && pChanged && strncmp(stIPInterfaceInstance.type, backupType,_BUF_LEN_16 ))
864  {
865  *pChanged = true;
866  }
867  bCalledType = true;
868  strncpy(stMsgData->paramValue,stIPInterfaceInstance.type,TR69HOSTIFMGR_MAX_PARAM_LEN );
869  strncpy(backupType,stIPInterfaceInstance.type,_BUF_LEN_16 );
870  stMsgData->paramtype = hostIf_StringType;
871  stMsgData->paramLen = strlen(stIPInterfaceInstance.type);
872 
873  return OK;
874 }
875 
876 void hostIf_IPInterface::getActiveFlags (char* nameOfInterface, struct ifreq& ifr)
877 {
878  memset (&ifr, 0, sizeof(ifr));
879  errno_t rc = -1;
880  rc=strcpy_s (ifr.ifr_name,sizeof(ifr.ifr_name), nameOfInterface);
881  if(rc!=EOK)
882  {
883  ERR_CHK(rc);
884  }
885  int fd = socket (PF_INET, SOCK_DGRAM, IPPROTO_IP);
886  if (fd < 0) {
887  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): fd: %d, Failed due to [\'%s\' (%d)] \n", __FUNCTION__, fd, strerror(errno), errno); //CID:18636 - NEGATIVE RETURNS
888  return;
889  }
890  ioctl (fd, SIOCGIFFLAGS, &ifr);
891  close(fd);
892 }
893 
894 bool hostIf_IPInterface::isLoopback (char* nameOfInterface)
895 {
896  LOG_ENTRY_EXIT;
897 
898  struct ifreq ifr;
899  getActiveFlags (nameOfInterface, ifr);
900  return ifr.ifr_flags & IFF_LOOPBACK;
901 }
902 
903 bool hostIf_IPInterface::isEnabled (char* nameOfInterface)
904 {
905  LOG_ENTRY_EXIT;
906 
907  struct ifreq ifr;
908  getActiveFlags (nameOfInterface, ifr);
909  return ifr.ifr_flags & IFF_UP;
910 }
911 
912 int hostIf_IPInterface::getMTU (char* nameOfInterface)
913 {
914  LOG_ENTRY_EXIT;
915 
916  struct ifreq ifr;
917  memset (&ifr, 0, sizeof(ifr));
918  errno_t rc = -1;
919  rc=strcpy_s (ifr.ifr_name,sizeof(ifr.ifr_name), nameOfInterface);
920  if(rc!=EOK)
921  {
922  ERR_CHK(rc);
923  }
924  int fd = socket (PF_INET, SOCK_DGRAM, IPPROTO_IP);
925  if(fd > 0)
926  {
927  ioctl (fd, SIOCGIFMTU, &ifr);
928  close (fd);
929  }
930  else
931  {
932  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): fd: %d, Failed due to [\'%s\' (%d)] \n", __FUNCTION__,fd, strerror(errno), errno); //CID:18626 - NEGATIVE RETURNS
933  close (fd);
934  }
935  return ifr.ifr_mtu;
936 }
937 
938 /**
939  * @brief This function gets the IP interface loopback. It indicates whether or not the
940  * IP interface is a loopback interface by 'true' or 'false'.
941  *
942  * @param[out] stMsgData TR-069 Host interface message request.
943  * @param[in] pChanged Status of the operation.
944  *
945  * @return Returns the status of the operation.
946  *
947  * @retval OK if it is successfully fetch the data from the device.
948  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
949  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
950  */
952 {
953  LOG_ENTRY_EXIT;
954 
955  stIPInterfaceInstance.loopback = isLoopback (nameOfInterface);
956 
957  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): Loopback: %d \n", __FUNCTION__, stIPInterfaceInstance.loopback);
958 
959  if(bCalledLoopback && pChanged && (backupLoopback != stIPInterfaceInstance.loopback))
960  {
961  *pChanged = true;
962  }
963  bCalledLoopback = true;
964  backupLoopback = stIPInterfaceInstance.loopback;
965  put_int(stMsgData->paramValue,stIPInterfaceInstance.loopback);
966  stMsgData->paramtype = hostIf_BooleanType;
967  stMsgData->paramLen = 1;
968 
969  return OK;
970 }
971 
972 unsigned int hostIf_IPInterface::getIPAddressNumberOfEntries (sa_family_t address_family)
973 {
974  LOG_ENTRY_EXIT;
975 
976  struct ifaddrs *ifa;
977  if (getifaddrs (&ifa) == -1) {
978  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s() Failed in getifaddrs(), errno(%d) [%s].\n", __FUNCTION__, errno, strerror( errno) );
979  return 0;
980  }
981 
982  int ipAddressNumberOfEntries = 0;
983  for (struct ifaddrs *ifa_node = ifa; ifa_node; ifa_node = ifa_node->ifa_next)
984  if (ifa_node->ifa_addr->sa_family == address_family && !strcmp (ifa_node->ifa_name, nameOfInterface))
985  ipAddressNumberOfEntries++;
986 
987  freeifaddrs (ifa);
988 
989  return ipAddressNumberOfEntries;
990 }
991 
992 /** Description: Counts the number of IPv4 addresses per
993  * IP interface present in the device.
994  *
995  * \Return: Count value or '0' if error
996  *
997  */
999 {
1000  return getIPAddressNumberOfEntries (AF_INET);
1001 }
1002 
1003 /**
1004  * @brief This function gets the IP Interface IPv4AddressNumberOfEntries. It provides the number
1005  * of entries in the IPv4 Address table.
1006  *
1007  * @param[out] stMsgData TR-069 Host interface message request.
1008  * @param[in] pChanged Status of the operation.
1009  *
1010  * @return Returns the status of the operation.
1011  *
1012  * @retval OK if it is successfully fetch the data from the device.
1013  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1014  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1015  */
1017 {
1018  LOG_ENTRY_EXIT;
1019 
1020  stIPInterfaceInstance.iPv4AddressNumberOfEntries = getIPv4AddressNumberOfEntries ();
1021 
1022  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): Interface %d (%s) has [%u] IPv4 Addresses\n", __FUNCTION__, dev_id, nameOfInterface,
1023  stIPInterfaceInstance.iPv4AddressNumberOfEntries);
1024 
1025  put_int(stMsgData->paramValue,stIPInterfaceInstance.iPv4AddressNumberOfEntries);
1026  stMsgData->paramtype = hostIf_UnsignedIntType;
1027  stMsgData->paramLen = 4;
1028 
1029  return OK;
1030 }
1031 
1032 /**
1033  * Description: Counts the number of IPv6 addresses per
1034  * IP interface present in the device.
1035  *
1036  * \Return: Count value or '0' if error
1037  *
1038  */
1040 {
1041  return getIPAddressNumberOfEntries (AF_INET6);
1042 }
1043 
1044 unsigned int hostIf_IPInterface::getIPv6PrefixNumberOfEntries ()
1045 {
1046  return getIPAddressNumberOfEntries (AF_INET6);
1047 }
1048 
1049 #ifdef IPV6_SUPPORT
1050 /**
1051  *
1052  */
1053 int hostIf_IPInterface::get_Interface_IPv6AddressNumberOfEntries(HOSTIF_MsgData_t *stMsgData)
1054 {
1055  LOG_ENTRY_EXIT;
1056 
1057  stIPInterfaceInstance.iPv6AddressNumberOfEntries = getIPv6AddressNumberOfEntries ();
1058 
1059  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): Interface %d (%s) has [%u] IPv6 Addresses\n", __FUNCTION__, dev_id, nameOfInterface,
1060  stIPInterfaceInstance.iPv6AddressNumberOfEntries);
1061 
1062  put_int(stMsgData->paramValue,stIPInterfaceInstance.iPv6AddressNumberOfEntries);
1063  stMsgData->paramtype = hostIf_UnsignedIntType;
1064  stMsgData->paramLen = sizeof(unsigned int);
1065 
1066  return OK;
1067 }
1068 
1069 int hostIf_IPInterface::get_Interface_IPv6PrefixNumberOfEntries(HOSTIF_MsgData_t *stMsgData)
1070 {
1071  LOG_ENTRY_EXIT;
1072 
1073  stIPInterfaceInstance.iPv6PrefixNumberOfEntries = getIPv6PrefixNumberOfEntries ();
1074 
1075  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): Interface %d (%s) has [%u] IPv6 Prefixes\n", __FUNCTION__, dev_id, nameOfInterface,
1076  stIPInterfaceInstance.iPv6PrefixNumberOfEntries);
1077 
1078  put_int(stMsgData->paramValue,stIPInterfaceInstance.iPv6PrefixNumberOfEntries);
1079  stMsgData->paramtype = hostIf_UnsignedIntType;
1080  stMsgData->paramLen = sizeof(unsigned int);
1081 
1082  return OK;
1083 }
1084 
1085 #endif // IPV6_SUPPORT
1086 
1087 /**
1088  * @brief This function gets the status of Auto-IP on an IP Interface is 'enabled' or
1089  * 'disabled'. It indicates whether or not auto-IP is enabled for this IP interface.
1090  * Currently not implemented.
1091  *
1092  * @note <ul>
1093  * <li>This mechanism is only used with IPv4.</li>
1094  * <li>When auto-IP is enabled on an interface, an IPv4Address object
1095  * will dynamically be created and configured with auto-IP parameter
1096  * values.</li>
1097  * <li>The exact conditions under which an auto-IP address is created
1098  * (e.g. always when enabled or only in absence of dynamic IP
1099  * addressing) is implementation specific.</li>
1100  * </ul>
1101  *
1102  * @param[out] stMsgData TR-069 Host interface message request.
1103  * @param[in] pChanged Status of the operation.
1104  *
1105  * @return Returns the status of the operation.
1106  *
1107  * @retval OK if it is successfully fetch the data from the device.
1108  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1109  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1110  */
1112 {
1113  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
1114 
1115 /*
1116  stIPInterfaceInstance.autoIPEnable = (strcmp (nameOfInterface, "eth1") == 0);
1117 
1118  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "%s(): AutoIPEnable: %d\n", __FUNCTION__, stIPInterfaceInstance.autoIPEnable);
1119 
1120  if(bCalledAutoIPEnable && pChanged && (backupAutoIPEnable != stIPInterfaceInstance.autoIPEnable))
1121  {
1122  *pChanged = true;
1123  }
1124  bCalledAutoIPEnable = true;
1125  backupAutoIPEnable = stIPInterfaceInstance.autoIPEnable;
1126  put_int(stMsgData->paramValue,stIPInterfaceInstance.autoIPEnable);
1127  stMsgData->paramtype = hostIf_BooleanType;
1128  stMsgData->paramLen = 1;
1129 */
1130 
1131  return OK;
1132 }
1133 /****************************************************************************************************************************************************/
1134 // Device.IP.Interface. Profile. Setters:
1135 /****************************************************************************************************************************************************/
1136 
1137 /**
1138  * @brief This function sets the status of IP Interface 'enabled' or 'disabled'. It
1139  * enables i.e 'true' or disables i.e 'false' this IP interface regardless of
1140  * IPv4Enable and IPv6Enable. Currently not implemented.
1141  *
1142  * @param[out] stMsgData TR-069 Host interface message request.
1143  *
1144  * @return Returns the status of the operation.
1145  *
1146  * @retval OK if it is successfully fetch the data from the device.
1147  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1148  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1149  */
1150 int hostIf_IPInterface::set_Interface_Enable(HOSTIF_MsgData_t *stMsgData)
1151 {
1152  LOG_ENTRY_EXIT;
1153 
1154  set_Interface_Enable (get_boolean(stMsgData->paramValue));
1155 
1156  return OK;
1157 }
1158 
1159 /**
1160  * @brief This function attaches or detaches this IP interface to/from the IPv4 stack.
1161  * If set to 'true', then this interface is attached to the IPv4 stack. If set to 'false',
1162  * then this interface is detached from the IPv4 stack. Currently not implemented.
1163  *
1164  * @note <ul>
1165  * <li>Once detached from the IPv4 stack, the interface will now no
1166  * longer be able to pass IPv4 packets, and will be operationally down
1167  * (unless also attached to an enabled IPv6 stack).</li>
1168  *
1169  * <li>For an IPv4 capable device, if IPv4Enable is not present this
1170  * interface SHOULD be permanently attached to the IPv4 stack.</li>
1171  *
1172  * <li>IPv4Enable is independent of Enable, and that to administratively
1173  * enable an interface for IPv4 it is necessary for both Enable and
1174  * IPv4Enable to be true.</li>
1175  * </ul>
1176  *
1177  * @param[out] stMsgData TR-069 Host interface message request.
1178  *
1179  * @return Returns the status of the operation.
1180  *
1181  * @retval OK if it is successfully fetch the data from the device.
1182  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1183  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1184  */
1186 {
1187  LOG_ENTRY_EXIT;
1188 
1189  set_Interface_Enable (get_boolean (stMsgData->paramValue));
1190 
1191  return OK;
1192 }
1193 
1194 /**
1195  * @brief This function sets the status 'enabled' or 'disabled' of ULA(Unique Local Address) generation
1196  * for an IP Interface. It controls whether or not ULAs are generated and used on this interface.
1197  * Currently not implemented.
1198  *
1199  * @param[out] stMsgData TR-069 Host interface message request.
1200  *
1201  * @return Returns the status of the operation.
1202  *
1203  * @retval OK if it is successfully fetch the data from the device.
1204  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1205  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1206  */
1208 {
1209  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
1210 
1211  return NOK;
1212 }
1213 
1214 /**
1215  * @brief This function sets a non-volatile handle used to reference this IP interface instance.
1216  * Alias provides a mechanism for an ACS to label this instance for future reference.
1217  * Currently not implemented.
1218  *
1219  * @note If the CPE supports the Alias-based Addressing feature as defined in
1220  * [Section 3.6.1/TR-069 Amendment 4] and described in [Appendix II/TR-069
1221  * Amendment 4], the following mandatory constraints MUST be enforced:
1222  * <ul><li>Its value MUST NOT be empty.</li>
1223  * <li>Its value MUST start with a letter.</li>
1224  * <li>If its instance object is created by the CPE, the initial
1225  * value MUST start with a "cpe-" prefix.</li>
1226  * <li>The CPE MUST NOT change the parameter value.</li>
1227  * </ul>
1228  *
1229  * @param[out] stMsgData TR-069 Host interface message request.
1230  *
1231  * @return Returns the status of the operation.
1232  *
1233  * @retval OK if it is successfully fetch the data from the device.
1234  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1235  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1236  */
1238 {
1239  return NOK;
1240 }
1241 
1242 /**
1243  * @brief This function sets the IP Interface LowerLayers. Given a comma-separated
1244  * list (maximum length 1024) of strings, each list item being the path name of an
1245  * interface object, this function MUST stack each item in the list immediately below
1246  * this interface object. Currently not implemented.
1247  *
1248  * @note - If the referenced object is deleted, the corresponding item MUST be removed
1249  * from the list.
1250  * - LowerLayers MUST be an empty string and 'read-only' when Type is
1251  * 'Loopback', 'Tunnel', or 'Tunneled'.
1252  *
1253  * @param[out] stMsgData TR-069 Host interface message request.
1254  *
1255  * @return Returns the status of the operation.
1256  *
1257  * @retval OK if it is successfully fetch the data from the device.
1258  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1259  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1260  */
1262 {
1263  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
1264 
1265  return NOK;
1266 }
1267 
1268 /**
1269  * @brief This function sets the router instance that is associated with an IP Interface entry.
1270  * Currently not implemented.
1271  *
1272  * @note <ul>
1273  * <li>The value MUST be the path name of a row in the
1274  * <tt>Routing.Router</tt> table.</li>
1275  * <li>If the referenced object is deleted, the parameter value MUST be
1276  * set to an empty string.</li>
1277  * </ul>
1278  *
1279  * @param[out] stMsgData TR-069 Host interface message request.
1280  *
1281  * @return Returns the status of the operation.
1282  *
1283  * @retval OK if it is successfully fetch the data from the device.
1284  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1285  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1286  */
1288 {
1289  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
1290 
1291  return NOK;
1292 }
1293 
1294 /**
1295  * @brief This function sets the Reset flag to the requested value (normally 'true').
1296  * Currently not implemented.
1297  *
1298  * @note <ul>
1299  * <li>When set to <tt>true</tt>, the device MUST tear down the
1300  * existing IP connection represented by this object and establish a
1301  * new one.</li>
1302  *
1303  * <li>The device MUST initiate the reset after completion of the
1304  * current CWMP session.</li>
1305  *
1306  * <li>The device MAY delay resetting the connection in order to avoid
1307  * interruption of a user service such as an ongoing voice call.</li>
1308  *
1309  * <li>Reset on a disabled interface is a no-op (not an error).</li>
1310  * </ul>
1311  *
1312  * @param[out] stMsgData TR-069 Host interface message request.
1313  *
1314  * @return Returns the status of the operation.
1315  *
1316  * @retval OK if it is successfully fetch the data from the device.
1317  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1318  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1319  */
1320 int hostIf_IPInterface::set_Interface_Reset(HOSTIF_MsgData_t *stMsgData)
1321 {
1322  LOG_ENTRY_EXIT;
1323 
1324  set_Interface_Reset (get_boolean (stMsgData->paramValue));
1325 
1326  return OK;
1327 }
1328 
1329 /**
1330  * @brief This function sets the size of maximum transmission unit (MTU), i.e. the largest
1331  * allowed size of an IP packet (including IP headers, but excluding lower layer headers
1332  * such as Ethernet, PPP, or PPPoE headers) that is allowed to be transmitted by or through this device.
1333  * Currently not implemented.
1334  *
1335  * @param[out] stMsgData TR-069 Host interface message request.
1336  *
1337  * @return Returns the status of the operation.
1338  *
1339  * @retval OK if it is successfully fetch the data from the device.
1340  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1341  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1342  */
1344 {
1345  LOG_ENTRY_EXIT;
1346 
1347  set_Interface_Mtu (get_int (stMsgData->paramValue));
1348 
1349  return OK;
1350 }
1351 
1352 /**
1353  * @brief This function sets the IP interface LoopBack flag to 'true' or 'false'.
1354  * Currently not implemented.
1355  *
1356  * @note When set to <tt>true</tt>, the IP interface becomes a loopback interface and
1357  * the CPE MUST set Type to Loopback. In this case, the CPE MUST also set
1358  * the LowerLayers property to an empty string and fail subsequent attempts at
1359  * setting LowerLayers until the interface is no longer a loopback.
1360  *
1361  * @note Support for manipulating loopback interfaces is OPTIONAL.
1362  *
1363  * @param[out] stMsgData TR-069 Host interface message request.
1364  *
1365  * @return Returns the status of the operation.
1366  *
1367  * @retval OK if it is successfully fetch the data from the device.
1368  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1369  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1370  */
1372 {
1373  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
1374 
1375  return NOK;
1376 }
1377 
1378 /**
1379  * @brief This function sets the Auto-IP on an IP Interface status 'enable' or 'disable'.
1380  * It sets 'true' for enable and 'false' for disables the auto-IP for this IP interface.
1381  * Currently not implemented.
1382  *
1383  * @note <ul>
1384  * <li>This mechanism is only used with IPv4.</li>
1385  * <li>When auto-IP is enabled on an interface, an IPv4Address object
1386  * will dynamically be created and configured with auto-IP parameter
1387  * values.</li>
1388  * <li>The exact conditions under which an auto-IP address is created
1389  * (e.g. always when enabled or only in absence of dynamic IP
1390  * addressing) is implementation specific.</li>
1391  * </ul>
1392  *
1393  * @return Returns the status of the operation.
1394  *
1395  * @retval OK if it is successfully fetch the data from the device.
1396  * @retval ERR_INTERNAL_ERROR if not able to fetch the data.
1397  * @ingroup TR69_HOSTIF_DEVICE_INTERFACE_IP_API
1398  */
1400 {
1401  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Parameter Not Supported \n",__FUNCTION__);
1402 
1403  return NOK;
1404 }
1405 /* End of doxygen group */
1406 /**
1407  * @}
1408  */
1409 
1410 /* End of file xxx_api.c. */
1411 
1412 
1413 /** @} */
1414 /** @} */
hostIf_IPInterface::get_Interface_Router
int get_Interface_Router(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the Router instance that is associated with an IP Interface entry....
Definition: Device_IP_Interface.cpp:736
hostIf_IPInterface::get_Interface_Enable
int get_Interface_Enable(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the status to enabled or disabled of an IP Interface. It provides the values such ...
Definition: Device_IP_Interface.cpp:366
hostIf_IPInterface::get_Interface_LastChange
int get_Interface_LastChange(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the last change of status time of the interface. It provides the accumulated time ...
Definition: Device_IP_Interface.cpp:680
hostIf_IPInterface::set_Interface_MaxMTUSize
int set_Interface_MaxMTUSize(HOSTIF_MsgData_t *stMsgData)
This function sets the size of maximum transmission unit (MTU), i.e. the largest allowed size of an I...
Definition: Device_IP_Interface.cpp:1343
hostIf_IPInterface::get_Interface_Name
int get_Interface_Name(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the IP Interface Name.It provides the textual name of the interface as assigned by...
Definition: Device_IP_Interface.cpp:638
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
hostIf_IPInterface::get_Interface_Reset
int get_Interface_Reset(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get IP Interface Reset status.
Definition: Device_IP_Interface.cpp:759
Device_IP_Interface.h
The header file provides TR069 device IP interface information APIs.
hostIf_IPInterface::get_Interface_Type
int get_Interface_Type(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the IP Interface Type. It provides the IP interface type. Possible values are Norm...
Definition: Device_IP_Interface.cpp:831
hostIf_IPInterface::get_Interface_Alias
int get_Interface_Alias(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the instance handle for an IP Interface. It provides a non-volatile handle used to...
Definition: Device_IP_Interface.cpp:620
hostIf_IPInterface::get_Interface_IPv4AddressNumberOfEntries
int get_Interface_IPv4AddressNumberOfEntries(HOSTIF_MsgData_t *stMsgData)
Get the IP Interface IPv4AddressNumberOfEntries.
Definition: Device_IP_Interface.cpp:1016
hostIf_IPInterface::getIPv4AddressNumberOfEntries
unsigned int getIPv4AddressNumberOfEntries()
Definition: Device_IP_Interface.cpp:998
hostIf_IPInterface::set_Interface_IPv4Enable
int set_Interface_IPv4Enable(HOSTIF_MsgData_t *stMsgData)
Attach/Detach an IP interface to/from the IPv4 stack.
Definition: Device_IP_Interface.cpp:1185
hostIf_IPInterface::get_Interface_LowerLayers
int get_Interface_LowerLayers(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get IP Interface LowerLayers.
Definition: Device_IP_Interface.cpp:708
Device_IP_Interface_Stats.h
The header file provides TR069 device IP interface stats information APIs.
_HostIf_MsgData_t::paramtype
HostIf_ParamType_t paramtype
Definition: hostIf_tr69ReqHandler.h:177
hostIf_IP::getInterfaceName
static char * getInterfaceName(int if_index, char *if_name)
Definition: Device_IP.cpp:183
hostIf_IPInterface::get_Interface_IPv4Enable
int get_Interface_IPv4Enable(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the status of the IPv4 stack attachment for an IP interface. It indicates whether ...
Definition: Device_IP_Interface.cpp:411
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
_HostIf_MsgData_t::faultCode
faultCode_t faultCode
Definition: hostIf_tr69ReqHandler.h:179
_HostIf_MsgData_t::paramName
char paramName[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:171
hostIf_IPInterface::set_Interface_Loopback
int set_Interface_Loopback(HOSTIF_MsgData_t *stMsgData)
This function sets the IP interface LoopBack flag to 'true' or 'false'. Currently not implemented.
Definition: Device_IP_Interface.cpp:1371
Device_IP_Interface
It contains the members variables of the Device_IP_Interface structure.
Definition: Device_IP_Interface.h:97
hostIf_IPInterface::get_Interface_Status
int get_Interface_Status(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the IP interface Status. It provides the current operational state of the Interfac...
Definition: Device_IP_Interface.cpp:576
_HostIf_MsgData_t::paramValue
char paramValue[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:172
hostIf_IPInterface::set_Interface_Router
int set_Interface_Router(HOSTIF_MsgData_t *stMsgData)
This function sets the router instance that is associated with an IP Interface entry....
Definition: Device_IP_Interface.cpp:1287
Device_IP.h
The header file provides TR069 device IP information APIs.
hostIf_IPInterface::get_Interface_ULAEnable
int get_Interface_ULAEnable(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the status 'enabled' or 'disabled' of ULA(Unique local address) generation for an ...
Definition: Device_IP_Interface.cpp:514
hostIf_IPInterface::set_Interface_Alias
int set_Interface_Alias(HOSTIF_MsgData_t *stMsgData)
This function sets a non-volatile handle used to reference this IP interface instance....
Definition: Device_IP_Interface.cpp:1237
hostIf_IPInterface
This class provides the hostIf IP interface for getting IP interface information.
Definition: Device_IP_Interface.h:224
hostIf_IPInterface::set_Interface_AutoIPEnable
int set_Interface_AutoIPEnable(HOSTIF_MsgData_t *stMsgData)
This function sets the Auto-IP on an IP Interface status 'enable' or 'disable'. It sets 'true' for en...
Definition: Device_IP_Interface.cpp:1399
hostIf_IPInterface::set_Interface_LowerLayers
int set_Interface_LowerLayers(HOSTIF_MsgData_t *stMsgData)
This function sets the IP Interface LowerLayers. Given a comma-separated list (maximum length 1024) o...
Definition: Device_IP_Interface.cpp:1261
hostIf_IPInterface::get_Interface_MaxMTUSize
int get_Interface_MaxMTUSize(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the IP Interface MaxMTUSize. It provides the maximum transmission unit (MTU),...
Definition: Device_IP_Interface.cpp:795
put_int
void put_int(char *ptr, int val)
This function converts the input data to integer type.
Definition: hostIf_utils.cpp:152
hostIf_IPInterface::hostIf_IPInterface
hostIf_IPInterface(int dev_id)
Class Constructor of the class hostIf_IPInterface.
Definition: Device_IP_Interface.cpp:132
TRUE
#define TRUE
Defines for TRUE/FALSE/ENABLE flags.
Definition: wifi_common_hal.h:199
_HostIf_MsgData_t::paramLen
short paramLen
Definition: hostIf_tr69ReqHandler.h:175
hostIf_IPInterface::get_Interface_Loopback
int get_Interface_Loopback(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
This function gets the IP interface loopback. It indicates whether or not the IP interface is a loopb...
Definition: Device_IP_Interface.cpp:951
hostIf_IPInterface::get_Interface_AutoIPEnable
int get_Interface_AutoIPEnable(HOSTIF_MsgData_t *stMsgData, bool *pChanged=NULL)
Get the status (enabled/disabled) of Auto-IP on an IP Interface.
Definition: Device_IP_Interface.cpp:1111
hostIf_IPInterface::getIPv6AddressNumberOfEntries
unsigned int getIPv6AddressNumberOfEntries()
Definition: Device_IP_Interface.cpp:1039
hostIf_IPInterface::set_Interface_ULAEnable
int set_Interface_ULAEnable(HOSTIF_MsgData_t *stMsgData)
This function sets the status 'enabled' or 'disabled' of ULA(Unique Local Address) generation for an ...
Definition: Device_IP_Interface.cpp:1207