ANSC_STATUS
CosaDml_GreIfGetStatus(ULONG ins, COSA_DML_GRE_STATUS *st)
{
    char status[64];
    ULONG size = sizeof(status);
    char greNetworkInterface[256];
    char tmpPath[256];

    if (ins != 1 || !st)
        return ANSC_STATUS_FAILURE;

    if (GrePsmGetStr(GRE_PARAM_GREIF, ins, greNetworkInterface, sizeof(greNetworkInterface)) != 0)
        return ANSC_STATUS_FAILURE;
    snprintf(tmpPath, sizeof(tmpPath), "%sStatus", greNetworkInterface);

    if (g_GetParamValueString(g_pDslhDmlAgent, tmpPath, status, &size) != 0)
        return ANSC_STATUS_FAILURE;

    if (strcmp(status, "Up") == 0)
        *st = COSA_DML_GRE_STATUS_UP;
    else if (strcmp(status, "Down") == 0 || strcmp(status, "LowerLayerDown") == 0)
        *st = COSA_DML_GRE_STATUS_DOWN;
    else if (strcmp(status, "Error") == 0)
        *st = COSA_DML_GRE_STATUS_ERROR;
    else
        return ANSC_STATUS_FAILURE;

    return ANSC_STATUS_SUCCESS;
}
예제 #2
0
BOOL
IPv6rdIF_SetParamStringValue(
        ANSC_HANDLE hInsContext,
        char        *ParamName,
        char        *pString
        )
{
    PCOSA_CONTEXT_LINK_OBJECT       pLinkObject = (PCOSA_CONTEXT_LINK_OBJECT)hInsContext;
    PCOSA_DML_IPV6RD_IF             pEntry = (PCOSA_DML_IPV6RD_IF)pLinkObject->hContext;
    char v4addr[16];
    ULONG addlen;
    char tmp[128];

    if (!pLinkObject || !pEntry)
        return FALSE;

    if (AnscEqualString(ParamName, "Alias", TRUE))
    {
        AnscCopyString(pEntry->Alias, pString);
        return TRUE;
    }
    else if (AnscEqualString(ParamName, "BorderRelayIPv4Addresses", TRUE))
    {
        AnscCopyString(pEntry->BorderRelayIPv4Addr, pString);
        return TRUE;
    }
    else if (AnscEqualString(ParamName, "SPIPv6Prefix", TRUE))
    {
        AnscCopyString(pEntry->SPIPv6Prefix, pString);
        return TRUE;
    }
    else if (AnscEqualString(ParamName, "AddressSource", TRUE))
    {
        if (!pString || _ansc_strlen(pString) == 0)
        {
            AnscCopyString(pEntry->AddressSource, "");
            return TRUE;
        }

        addlen = sizeof(v4addr);
        _ansc_sprintf(tmp, "%sIPAddress", pString);
        if (g_GetParamValueString(g_pDslhDmlAgent, tmp, v4addr, &addlen) != 0)
        {
            CcspTraceWarning(("IPv6rdIF_SetParamStringValue: fail to get %s\n", tmp));
            return FALSE;
        }

        AnscCopyString(pEntry->AddressSource, v4addr);
        /* AnscCopyString(pEntry->AddressSource, pString); */
        return TRUE;
    }

    return FALSE;
}
ANSC_STATUS
CosaDml_GreIfGetConnEndpoint(ULONG ins, char *ep, ULONG size)
{
    char greNetworkInterface[256];
    char tmpPath[256];

    if (ins != 1 || !ep)
        return ANSC_STATUS_FAILURE;

    if (GrePsmGetStr(GRE_PARAM_GREIF, ins, greNetworkInterface, sizeof(greNetworkInterface)) != 0)
        return ANSC_STATUS_FAILURE;
    snprintf(tmpPath, sizeof(tmpPath), "%sRemoteEndpoint", greNetworkInterface);

    if (g_GetParamValueString(g_pDslhDmlAgent, tmpPath, ep, &size) != 0)
        return ANSC_STATUS_FAILURE;

    return ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
CosaDml_GreIfGetLocalInterfaces(ULONG ins, char *ifs, ULONG size)
{
    char *brlist, *br, *delim, *start, *sp;
    ULONG ptInsList[16], ptInsCnt = 16;
    char dm[1024], dmval[1024 + 1];
    ULONG dmsize;
    int i;
    char *tif;

    if (ins != 1 || !ifs)
        return ANSC_STATUS_FAILURE;

    memset(ifs, 0, size);

    if ((brlist = GetAssoBridge(ins)) == NULL)
        return ANSC_STATUS_FAILURE;

    /* for each bridge */
    for (start = brlist, delim = ",";
            (br = strtok_r(start, delim, &sp)) != NULL;
            start = NULL) {

        AnscTraceDebug(("Bridge: %s\n", br));

        /* for each port */
        snprintf(dm, sizeof(dm), "%sPort.", br);
        if (g_GetInstanceNumbers(dm, ptInsList, &ptInsCnt) != ANSC_STATUS_SUCCESS) {
            AnscTraceError(("Fail to get port ins numbers\n"));
            continue;
        }

        AnscTraceDebug(("  Port Num: %lu\n", ptInsCnt));

        for (i = 0; i < ptInsCnt; i++) {
            /* skip management port */
            snprintf(dm, sizeof(dm), "%sPort.%d.ManagementPort", br, ptInsList[i]);
            if (g_GetParamValueBool(g_pDslhDmlAgent, dm)) {
                AnscTraceDebug(("  Skip Port[%d], it's a management port\n", ptInsList[i]));
                continue;
            }

            /* skip upstream port (GRE IF) */
            dmsize = sizeof(dmval) - 1;
            snprintf(dm, sizeof(dm), "%sPort.%d.LowerLayers", br, ptInsList[i]);
            if (g_GetParamValueString(g_pDslhDmlAgent, dm, dmval, &dmsize) != 0 
                    || strstr(dmval, "Device.WiFi.SSID") == NULL) {
                AnscTraceDebug(("  Skip Port[%d]: %s\n", ptInsList[i], dmval));
                continue;
            }

            /* XXX: MultiLAN DM do not use "." for object path */
            if (strlen(dmval) && dmval[strlen(dmval) - 1] != '.' && strlen(dmval) < sizeof(dmval) - 1) {
                //AnscTraceDebug(("  Adding '.' to local if path\n"));
                strcat(dmval, ".");
            }

            /* add it to list */
            AnscTraceDebug(("  Add Port[%d] `%s/%s` to Local IF\n", ptInsList[i], dm, dmval));
            //if (strlen(ifs)) {
            if (!start || strlen(ifs)) { /* Local If and Bridge are 1:1 mapping, we need "," */
                snprintf(ifs +  strlen(ifs), size - strlen(ifs), ",%s", dmval);
            } else {
                snprintf(ifs +  strlen(ifs), size - strlen(ifs), "%s", dmval);
            }
        }
    }

    free(brlist);

    AnscTraceDebug(("  Local IFs: %s\n", ifs));

    //if (GrePsmGetStr(GRE_PARAM_LOCALIFS, ins, ifs, size) != 0)
    //    return ANSC_STATUS_FAILURE;

    return ANSC_STATUS_SUCCESS;
}
예제 #5
0
BOOL
IPv6rdIF_SetParamStringValue(
        ANSC_HANDLE hInsContext,
        char        *ParamName,
        char        *pString
        )
{
    PCOSA_CONTEXT_LINK_OBJECT       pLinkObject = (PCOSA_CONTEXT_LINK_OBJECT)hInsContext;
    PCOSA_DML_IPV6RD_IF             pEntry = (PCOSA_DML_IPV6RD_IF)pLinkObject->hContext;
    char v4addr[16];
    ULONG addlen;
    char tmp[128];
    ANSC_STATUS ret=ANSC_STATUS_FAILURE;

    if (!pLinkObject || !pEntry)
        return FALSE;

    if (AnscEqualString(ParamName, "Alias", TRUE))
    {
    char wrapped_inputparam[256]={0};
	ret=isValidInput(pString,wrapped_inputparam, AnscSizeOfString(pString), sizeof( wrapped_inputparam ));
	if(ANSC_STATUS_SUCCESS != ret)
	    return FALSE;

        AnscCopyString(pEntry->Alias, wrapped_inputparam);
        return TRUE;
    }
    else if (AnscEqualString(ParamName, "BorderRelayIPv4Addresses", TRUE))
    {
    char wrapped_inputparam[256]={0};
	ret=isValidInput(pString,wrapped_inputparam, AnscSizeOfString(pString), sizeof( wrapped_inputparam ));
	if(ANSC_STATUS_SUCCESS != ret)
	    return FALSE;
        AnscCopyString(pEntry->BorderRelayIPv4Addr, wrapped_inputparam);
        return TRUE;
    }
    else if (AnscEqualString(ParamName, "SPIPv6Prefix", TRUE))
    {
    char wrapped_inputparam[256]={0};
	ret=isValidInput(pString,wrapped_inputparam, AnscSizeOfString(pString), sizeof( wrapped_inputparam ));
	if(ANSC_STATUS_SUCCESS != ret)
	    return FALSE;

        AnscCopyString(pEntry->SPIPv6Prefix, wrapped_inputparam);
        return TRUE;
    }
    else if (AnscEqualString(ParamName, "AddressSource", TRUE))
    {
    char wrapped_inputparam[256]={0};
	ret=isValidInput(pString,wrapped_inputparam, AnscSizeOfString(pString), sizeof( wrapped_inputparam ));
	if(ANSC_STATUS_SUCCESS != ret)
	    return FALSE;

        if (( '\0' == wrapped_inputparam[ 0 ] ) || \
			( _ansc_strlen(wrapped_inputparam) == 0) 
		   )
        {
            AnscCopyString(pEntry->AddressSource, "");
            return TRUE;
        }

        addlen = sizeof(v4addr);
        _ansc_sprintf(tmp, "%sIPAddress", wrapped_inputparam);
        if (g_GetParamValueString(g_pDslhDmlAgent, tmp, v4addr, &addlen) != 0)
        {
            CcspTraceWarning(("IPv6rdIF_SetParamStringValue: fail to get %s\n", tmp));
            return FALSE;
        }

        AnscCopyString(pEntry->AddressSource, v4addr);
        /* AnscCopyString(pEntry->AddressSource, pString); */
        return TRUE;
    }

    return FALSE;
}
void SetVideoServiceConfig()
{
    int ret = ANSC_STATUS_SUCCESS;
    BOOL isBridgeMode = FALSE;
    char bval[2] = {0};
    char pMoCAComponentName[64]="eRT.com.cisco.spvtg.ccsp.moca";
    char pComponentPath[64]="/com/cisco/spvtg/ccsp/moca";
    char *paramNames[]={"Device.MoCA.Interface.1.Enable"};
    char buf[5] = {0};
    char FirewallLevel[32] = {0};
    ULONG len = 0;

    len = sizeof(FirewallLevel);
    ret = g_GetParamValueString(g_pDslhDmlAgent, "Device.X_CISCO_COM_Security.Firewall.FirewallLevel", FirewallLevel, &len );
    if(ret != ANSC_STATUS_SUCCESS)
    {
        pthread_mutex_lock(&g_videoservice_mutex);
        videoServiceEnableInProgress = FALSE;   
        pthread_mutex_unlock(&g_videoservice_mutex);
        AnscTraceError(("[%s] VideoService : Fail to get Firewall Level \n", __FUNCTION__));
        return;
    } 

    if(!strcmp(FirewallLevel, "High"))
    {
        ret = g_SetParamValueString("Device.X_CISCO_COM_Security.Firewall.FirewallLevel", "Medium");
        if(ret != ANSC_STATUS_SUCCESS)
        {
            pthread_mutex_lock(&g_videoservice_mutex);
            videoServiceEnableInProgress = FALSE;   
            pthread_mutex_unlock(&g_videoservice_mutex);
            AnscTraceError(("[%s] VideoService : Fail to set Firewall Level to Medium\n", __FUNCTION__));
            return;
        }
        else
        {
            CcspTraceWarning(("Firewall Level being set to MEDIUM when VIDEOSERVICE is ENABLED\n"));
        }     
    }

    ret = is_usg_in_bridge_mode(&isBridgeMode);
    if ( ret == ANSC_STATUS_SUCCESS )
    {
        if(isBridgeMode)
        {
            ret = g_SetParamValueString("Device.X_CISCO_COM_DeviceControl.LanManagementEntry.1.LanMode","router");
            if(ret != ANSC_STATUS_SUCCESS)
            {
                pthread_mutex_lock(&g_videoservice_mutex);
                videoServiceEnableInProgress = FALSE;   
                pthread_mutex_unlock(&g_videoservice_mutex);
                AnscTraceError(("[%s] VideoService : Fail to set Disable Bridge Mode \n", __FUNCTION__));
                return;
            }
            else
            {
                CcspTraceWarning(("Bridge Mode being DISABLED when VIDEOSERVICE is ENABLED\n"));
            }            
        }
    }
    else
    {
        pthread_mutex_lock(&g_videoservice_mutex);
        videoServiceEnableInProgress = FALSE;   
        pthread_mutex_unlock(&g_videoservice_mutex);
        AnscTraceError(("[%s] VideoService : Fail to query bridge mode \n", __FUNCTION__));
        return;
    }


    syscfg_get( NULL, "moca_enabled", buf, sizeof(buf));
    if( buf != NULL )
    {
        if (strcmp(buf,"0") == 0)
        {
            parameterValStruct_t  value = {"Device.MoCA.Interface.1.Enable", "true", ccsp_boolean};
            char compo[256] = "eRT.com.cisco.spvtg.ccsp.moca";
            char bus[256] = "/com/cisco/spvtg/ccsp/moca";
            char* faultParam = NULL;
            int ret1 = CCSP_FAILURE;

            CCSP_MESSAGE_BUS_INFO *bus_info = (CCSP_MESSAGE_BUS_INFO *)bus_handle;

            ret1 = CcspBaseIf_setParameterValues(
                      bus_handle,
                      compo,
                      bus,
                      0,
                      0,
                      &value,
                      1,
                      TRUE,
                      &faultParam
                      );

            if(ret1 != CCSP_SUCCESS)
            {
                if(faultParam)
                {
                    bus_info->freefunc(faultParam);
                }

                pthread_mutex_lock(&g_videoservice_mutex);
                videoServiceEnableInProgress = FALSE;   
                pthread_mutex_unlock(&g_videoservice_mutex);
                CcspTraceError(("RDK_LOG_ERROR,  [%s] VideoService MoCA Enable FAILED: Failed ret %d\n",__FUNCTION__,ret1));
                return;
            }
            else
            {
                CcspTraceWarning(("MoCA is being ENABLED when VIDEOSERVICE is ENABLED\n"));
            }
        }
    }

    pthread_mutex_lock(&g_videoservice_mutex);
    videoServiceEnableInProgress = FALSE;                          
    pthread_mutex_unlock(&g_videoservice_mutex);
}