src/main/src/netsrvmgrUtiles.cpp
/**
 * @fn netSrvMgrUtiles::triggerDhcpLease(const char* operation, const char* interface)
 * @brief Triggers a "renew" or "release and renew" of DHCP lease on specified interface.
 * If DHCP lease renew is requested, the specified interface may be NULL in which case
 * a DHCP lease renew will be triggered for all interfaces running the DHCPv4 client.
 * If DHCP lease release and renew is requested, the specified interface must not be NULL.
 *
 * @param[in] operation DHCP lease operation to perform ("renew" or "release and renew")
 * @param[in] interface interface (wlan0, eth0, etc.) to perform DHCP lease operation on
 */
@fn netSrvMgrUtiles::triggerDhcpLease(const char* operation, const char* interface)
@brief Triggers a "renew" or "release and renew" of DHCP lease on specified interface.
If DHCP lease renew is requested, the specified interface may be NULL in which case
a DHCP lease renew will be triggered for all interfaces running the DHCPv4 client.
If DHCP lease release and renew is requested, the specified interface must not be NULL.

@param[in] operation DHCP lease operation to perform ("renew" or "release and renew")
@param[in] interface interface (wlan0, eth0, etc.) to perform DHCP lease operation on
@fn netSrvMgrUtiles :: triggerDhcpLease ( const char * operation const char * interface ) @brief Triggers a " renew " or " release and renew " of DHCP lease on specified interface . If DHCP lease renew is requested the specified interface may be NULL in which case a DHCP lease renew will be triggered for all interfaces running the DHCPv4 client . If DHCP lease release and renew is requested the specified interface must not be NULL . @param [ in ] operation DHCP lease operation to perform ( " renew " or " release and renew " ) @param [ in ] interface interface ( wlan0 eth0 etc . ) to perform DHCP lease operation on
void netSrvMgrUtiles::triggerDhcpLease(const char* operation, const char* interface)
{
    char command[200];
    snprintf (command, sizeof(command), "%s %s %s 2>&1",
            TRIGGER_DHCP_LEASE_FILE, operation, interface ? interface : "");
    RDK_LOG (RDK_LOG_INFO, LOG_NMGR, "[%s] Executing command [%s]\n", __FUNCTION__, command);
    char scriptLogOutputLine[256];
    FILE *fp = popen (command, "r");
    if (fp == NULL)
    {
        RDK_LOG (RDK_LOG_ERROR, LOG_NMGR, "[%s] Failed to execute command [%s]\n", __FUNCTION__, command);
        return;
    }
    while (fgets (scriptLogOutputLine, sizeof (scriptLogOutputLine), fp) != NULL)
    {
        RDK_LOG (RDK_LOG_INFO, LOG_NMGR, "[%s] %s", __FUNCTION__, scriptLogOutputLine);
    }
    int pclose_status = pclose (fp);
    int status = WEXITSTATUS (pclose_status);
    RDK_LOG (RDK_LOG_INFO, LOG_NMGR, "[%s] Exit code [%d] from command [%s]\n", __FUNCTION__, status, command);
}
void netSrvMgrUtiles :: triggerDhcpLease ( const char * operation , const char * interface ) { char command [ 200 ] ; snprintf ( command , sizeof ( command ) , " " , TRIGGER_DHCP_LEASE_FILE , operation , interface ? interface : " " ) ; RDK_LOG ( RDK_LOG_INFO , LOG_NMGR , " \n " , __FUNCTION__ , command ) ; char scriptLogOutputLine [ 256 ] ; FILE * fp = popen ( command , " " ) ; if ( fp == NULL ) { RDK_LOG ( RDK_LOG_ERROR , LOG_NMGR , " \n " , __FUNCTION__ , command ) ; return ; } while ( fgets ( scriptLogOutputLine , sizeof ( scriptLogOutputLine ) , fp ) != NULL ) { RDK_LOG ( RDK_LOG_INFO , LOG_NMGR , " " , __FUNCTION__ , scriptLogOutputLine ) ; } int pclose_status = pclose ( fp ) ; int status = WEXITSTATUS ( pclose_status ) ; RDK_LOG ( RDK_LOG_INFO , LOG_NMGR , " \n " , __FUNCTION__ , status , command ) ; }
@fn netSrvMgrUtiles::triggerDhcpLease(const char* operation, const char* interface)
 @brief Triggers a "renew" or "release and renew" of DHCP lease on specified interface.
@fn netSrvMgrUtiles :: triggerDhcpLease ( const char * operation const char * interface ) @brief Triggers a " renew " or " release and renew " of DHCP lease on specified interface .
// log script output at INFO level