예제 #1
0
ANSC_STATUS
CosaDmlDiGetFirstUseDate
    (
        ANSC_HANDLE                 hContext,
        char*                       pValue,
        PULONG                      pulSize
    )
{
    UtopiaContext ctx;
    int rc = -1;
    char firstUseDate[64];

    if (!Utopia_Init(&ctx))
        return ERR_UTCTX_INIT;

    rc = Utopia_Get_First_Use_Date(&ctx,firstUseDate);

    Utopia_Free(&ctx,0);

    //    fprintf(stderr, "<RT> rc=%d, First Use Date = '%s'\n", rc, firstUseDate);

    if(rc || firstUseDate[0] == '\0') _ansc_sprintf(firstUseDate, "2013-11-22T00:00:00");

    AnscCopyString(pValue,firstUseDate);
    *pulSize = AnscSizeOfString(pValue);
    
    return ANSC_STATUS_SUCCESS;
}
예제 #2
0
ANSC_STATUS
CosaDmlDiGetProvisioningCode
    (
        ANSC_HANDLE                 hContext,
        char*                       pValue,
        ULONG*                      pulSize
    )
{
#if 0
    UtopiaContext ctx;
    int rc = -1;
    char temp[64];

    if (!Utopia_Init(&ctx))
        return ERR_UTCTX_INIT;

    rc = Utopia_Get_Prov_Code(&ctx,temp);

    Utopia_Free(&ctx,0);
    AnscCopyString(pValue,temp);
    *pulSize = AnscSizeOfString(pValue);
#endif

// Provisioning Code sent to ACS is Serial Number of the device
#ifdef _COSA_DRG_TPG_
    plat_GetFlashValue("unitsn", unitsn);
    sprintf(pValue, "%c%c%c%c%c%c%c",unitsn[0],unitsn[1],unitsn[2],unitsn[3],unitsn[4],unitsn[5],unitsn[6]);
#elif _COSA_INTEL_USG_ARM_

    if (platform_hal_GetSerialNumber(pValue) != RETURN_OK )
        return ANSC_STATUS_FAILURE;
#endif
    *pulSize = AnscSizeOfString(pValue);
    return ANSC_STATUS_SUCCESS; 
}
static int 
RLog_LoadConf(PCOSA_DML_RLOG conf)
{
    UtopiaContext ctx;
    char param[256];

    if (!Utopia_Init(&ctx))
        return -1;

    memset(conf, 0, sizeof(*conf));

    Utopia_RawGet(&ctx, NULL, RLOG_CFG_ENABLE, param, sizeof(param));
    if (atoi(param) == 1)
        conf->Enable = TRUE;
    else
        conf->Enable = FALSE;

    Utopia_RawGet(&ctx, NULL, RLOG_CFG_HOST, conf->Host, sizeof(conf->Host));

    Utopia_RawGet(&ctx, NULL, RLOG_CFG_PORT, param, sizeof(param));
    conf->Port = atoi(param);
    
    /* could not change */
    conf->Protocol = COSA_DML_RLOG_PROTO_UDP;
    snprintf(conf->Patterns, sizeof(conf->Patterns), "*.*");

    Utopia_Free(&ctx, 0);
    return 0;
}
예제 #4
0
/**********************************************************************

    caller:     self

    prototype:

       ANSC_STATUS
       CosaDmlNeighdiscIfSetCfg
          (
                ANSC_HANDLE                 hContext,
                PCOSA_DML_NEIGHDISC_IF_CFG         pCfg
            );

    Description:
    
        The API the NEIGHDISC configuration. 
        
    Arguments:
                ANSC_HANDLE                 hContext,
                PCOSA_DML_NEIGHDISC_IF_CFG         pCfg

    Return:
        The status of the operation.

**********************************************************************/
ANSC_STATUS
CosaDmlNeighdiscIfSetCfg
    (
        ANSC_HANDLE                 hContext,
        PCOSA_DML_NEIGHDISC_IF_CFG         pCfg
    )
{
    UtopiaContext utctx = {0};
    char out[256] = {0};

    if ( g_neighdisc_interface.Cfg.InstanceNumber != pCfg->InstanceNumber )
        return ANSC_STATUS_CANT_FIND;   

    /*handle syscfg stuff*/
    if (!Utopia_Init(&utctx))
        return ANSC_STATUS_FAILURE;
    
    if (!AnscEqualString(pCfg->Alias, g_neighdisc_interface.Cfg.Alias, TRUE))
        Utopia_RawSet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_alias",pCfg->Alias);        

    if (pCfg->RetransTimer != g_neighdisc_interface.Cfg.RetransTimer)
    {
        sprintf(out, "%d", pCfg->RetransTimer);
        Utopia_RawSet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_RetransTimer",out);        

        /*this is so called backend implementation*/
        _write_sysctl_file(RetransTimer_SYSCTL_FILE, pCfg->RetransTimer);
    }

    if (pCfg->RtrSolicitationInterval != g_neighdisc_interface.Cfg.RtrSolicitationInterval)
    {
        sprintf(out, "%d", pCfg->RtrSolicitationInterval);
        Utopia_RawSet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_RtrSolicitationInterval",out);        

        /*this is so called backend implementation*/
        /*RtrSolicitationInterval is in the unit of millisecond, but kernel wants seconds.*/
        _write_sysctl_file(RtrSolicitationInterval_SYSCTL_FILE, 
                           (pCfg->RtrSolicitationInterval/1000 ? pCfg->RtrSolicitationInterval/1000:1));
    }

    if (pCfg->MaxRtrSolicitations != g_neighdisc_interface.Cfg.MaxRtrSolicitations)
    {
        sprintf(out, "%d", pCfg->MaxRtrSolicitations);
        Utopia_RawSet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_MaxRtrSolicitations",out);        

        /*this is so called backend implementation*/
        _write_sysctl_file(MaxRtrSolicitations_SYSCTL_FILE, pCfg->MaxRtrSolicitations);
    }

    Utopia_Free(&utctx,1);                    


    AnscCopyMemory(&g_neighdisc_interface.Cfg, pCfg, sizeof(*pCfg));

    return ANSC_STATUS_SUCCESS;   
}
예제 #5
0
ANSC_STATUS
CosaDmlDiSetProvisioningCode
    (
        ANSC_HANDLE                 hContext,
        char*                       pProvisioningCode
    )
{
    UtopiaContext ctx;
    int rc = -1;

    if (!Utopia_Init(&ctx))
        return ERR_UTCTX_INIT;

    rc = Utopia_Set_Prov_Code(&ctx,pProvisioningCode);

    Utopia_Free(&ctx,!rc);

    return ANSC_STATUS_SUCCESS;
}
static int 
RLog_SaveConf(const PCOSA_DML_RLOG conf)
{
    UtopiaContext ctx;
    char param[256];

    if (!Utopia_Init(&ctx))
        return -1;

    if (conf->Enable)
        Utopia_RawSet(&ctx, NULL, RLOG_CFG_ENABLE, "1");
    else
        Utopia_RawSet(&ctx, NULL, RLOG_CFG_ENABLE, "0");

    Utopia_RawSet(&ctx, NULL, RLOG_CFG_HOST, conf->Host);

    snprintf(param, sizeof(param), "%d", conf->Port);
    Utopia_RawSet(&ctx, NULL, RLOG_CFG_PORT, param);

    Utopia_Free(&ctx, 1);
    return 0;
}
예제 #7
0
ANSC_STATUS
CosaDmlNeighdiscIfGetEntry
    (
        ANSC_HANDLE                 hContext,
        ULONG                       ulIndex,
        PCOSA_DML_NEIGHDISC_IF_FULL        pEntry
    )
{
    UtopiaContext utctx = {0};
    char out[256] = {0};
    int  need_write = 0;

    if (!Utopia_Init(&utctx))
        return ANSC_STATUS_FAILURE;

    memset(out, 0, sizeof(out));
    Utopia_RawGet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_inst_num",out,sizeof(out));
    if (!out[0] || !(atoi(out)))
    {
        /*the first time system boots up*/
        need_write = 1;
        strcpy(out, "1");
        Utopia_RawSet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_inst_num",out);
    }
    g_neighdisc_interface.Cfg.InstanceNumber = atoi(out);

    memset(out, 0, sizeof(out));
    Utopia_RawGet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_alias",out,sizeof(out));
    if (!out[0])
    {
        /*the first time system boots up*/
        need_write = 1;
        strcpy(out, "InterfaceSetting1");
        Utopia_RawSet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_alias",out);
    }
    safe_strcpy(g_neighdisc_interface.Cfg.Alias, out, sizeof(g_neighdisc_interface.Cfg.Alias));

    /*we don't support writing to these variables*/
    g_neighdisc_interface.Cfg.bEnabled   = TRUE;
    g_neighdisc_interface.Cfg.bNUDEnable = TRUE;
    g_neighdisc_interface.Cfg.bRSEnable  = TRUE;

    Utopia_RawGet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_RetransTimer",out,sizeof(out));
    if (!out[0] || !(atoi(out)))
        g_neighdisc_interface.Cfg.RetransTimer = 1000;
    else
        g_neighdisc_interface.Cfg.RetransTimer = atoi(out);

    Utopia_RawGet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_RtrSolicitationInterval",out,sizeof(out));
    if (!out[0] || !(atoi(out)))
        g_neighdisc_interface.Cfg.RtrSolicitationInterval = 4000;
    else
        g_neighdisc_interface.Cfg.RtrSolicitationInterval = atoi(out);

    Utopia_RawGet(&utctx,NULL,SYSCFG_FORMAT_NEIGHDISC_IF"_MaxRtrSolicitations",out,sizeof(out));
    if (!out[0] || !(atoi(out)))
        g_neighdisc_interface.Cfg.MaxRtrSolicitations = 3;
    else
        g_neighdisc_interface.Cfg.MaxRtrSolicitations = atoi(out);

    Utopia_Free(&utctx,need_write);                    

    AnscCopyMemory(pEntry, &g_neighdisc_interface, sizeof(*pEntry));

    /*handle backend*/
    _apply_kernel_params(&pEntry->Cfg);

    return ANSC_STATUS_SUCCESS;
}