static int
GrePsmSet(const char *param, const char *value)
{
    if (PSM_Set_Record_Value2(g_MessageBusHandle, g_GetSubsystemPrefix(g_pDslhDmlAgent),
                (char *)param, ccsp_string, (char *)value) != CCSP_SUCCESS)
        return -1;
    return 0;
}
static int 
DmSetBool(const char *param, BOOL value)
{
    parameterValStruct_t val[1];
    char crname[256], *fault = NULL;
    int err;

    val[0].parameterName  = param;
    val[0].parameterValue = (value ? "true" : "false");
    val[0].type           = ccsp_boolean;

    snprintf(crname, sizeof(crname), "%s%s", g_GetSubsystemPrefix(g_pDslhDmlAgent), CCSP_DBUS_INTERFACE_CR);

    if ((err = CcspBaseIf_SetRemoteParameterValue(g_MessageBusHandle, 
                crname, param, g_GetSubsystemPrefix(g_pDslhDmlAgent), 0, 0xFFFF, val, 1, 1, &fault)) != CCSP_SUCCESS)

    if (fault)
        AnscFreeMemory(fault);

    return (err == CCSP_SUCCESS) ? 0 : -1;
}
static int
GrePsmGet(const char *param, char *value, int size)
{
    char *val;
    CCSP_MESSAGE_BUS_INFO *businfo;

    if (PSM_Get_Record_Value2(g_MessageBusHandle, g_GetSubsystemPrefix(g_pDslhDmlAgent),
                (char *)param, NULL, &val) != CCSP_SUCCESS)
        return -1;

    snprintf(value, size, "%s", val);

    businfo = g_MessageBusHandle;
    businfo->freefunc(val);
    return 0;
}
static int
PsmGet(const char *param, char *value, int size)
{
    char *val = NULL;

    if (PSM_Get_Record_Value2(g_MessageBusHandle, g_GetSubsystemPrefix(g_pDslhDmlAgent),
                (char *)param, NULL, &val) != CCSP_SUCCESS)
        return -1;
    
    if(val) {
        snprintf(value, size, "%s", val);
        ((CCSP_MESSAGE_BUS_INFO *)g_MessageBusHandle)->freefunc(val);
    }
    else return -1;

    return 0;
}
static int CGre_PsmGetInsNums(const char *obj, unsigned int insList[], unsigned int *insCnt)
{
    unsigned int *list, cnt;
    CCSP_MESSAGE_BUS_INFO *businfo;

    if (PsmGetNextLevelInstances(g_MessageBusHandle, g_GetSubsystemPrefix(g_pDslhDmlAgent), 
                (char *)obj, &cnt, &list) != CCSP_SUCCESS)
        return -1;

    if (cnt > *insCnt) {
        businfo = g_MessageBusHandle;
        businfo->freefunc(list);
        return -1;
    }

    *insCnt = cnt;
    memcpy(insList, list, sizeof(unsigned int) * cnt);

    businfo = g_MessageBusHandle;
    businfo->freefunc(list);
    return 0;
}
Пример #6
0
int ANSC_EXPORT_API
COSA_Init
    (
        ULONG                       uMaxVersionSupported,
        void*                       hCosaPlugInfo         /* PCOSA_PLUGIN_INFO passed in by the caller */
    )
{
    PCOSA_PLUGIN_INFO               pPlugInfo                   = (PCOSA_PLUGIN_INFO                 )hCosaPlugInfo;
    COSAGetParamValueStringProc     pGetStringProc              = (COSAGetParamValueStringProc       )NULL;
    COSAGetParamValueUlongProc      pGetParamValueUlongProc     = (COSAGetParamValueUlongProc        )NULL;
    COSAGetCommonHandleProc         pGetCHProc                  = (COSAGetCommonHandleProc           )NULL;
    COSAValidateHierarchyInterfaceProc
                                    pValInterfaceProc           = (COSAValidateHierarchyInterfaceProc)NULL;
    COSAGetHandleProc               pGetRegistryRootFolder      = (COSAGetHandleProc                 )NULL;
    COSAGetInstanceNumberByIndexProc
                                    pGetInsNumberByIndexProc    = (COSAGetInstanceNumberByIndexProc  )NULL;
    COSAGetHandleProc               pGetMessageBusHandleProc    = (COSAGetHandleProc                 )NULL;
    COSAGetInterfaceByNameProc      pGetInterfaceByNameProc     = (COSAGetInterfaceByNameProc        )NULL;

    if ( uMaxVersionSupported < THIS_PLUGIN_VERSION )
    {
      /* this version is not supported */
        return -1;
    }

    pPlugInfo->uPluginVersion       = THIS_PLUGIN_VERSION;
    g_pDslhDmlAgent                 = pPlugInfo->hDmlAgent;

    /* register the back-end apis for the data model */

    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "X_CISCO_COM_ARP_GetParamBoolValue",  X_CISCO_COM_ARP_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "X_CISCO_COM_ARP_GetParamIntValue",  X_CISCO_COM_ARP_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "X_CISCO_COM_ARP_GetParamUlongValue",  X_CISCO_COM_ARP_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "X_CISCO_COM_ARP_GetParamStringValue",  X_CISCO_COM_ARP_GetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "ARPTable_GetEntryCount",  ARPTable_GetEntryCount);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "ARPTable_GetEntry",  ARPTable_GetEntry);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "ARPTable_IsUpdated",  ARPTable_IsUpdated);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "ARPTable_Synchronize",  ARPTable_Synchronize);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "ARPTable_GetParamBoolValue",  ARPTable_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "ARPTable_GetParamIntValue",  ARPTable_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "ARPTable_GetParamUlongValue",  ARPTable_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "ARPTable_GetParamStringValue",  ARPTable_GetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_GetParamBoolValue",  IPPing_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_GetParamIntValue",  IPPing_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_GetParamUlongValue",  IPPing_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_GetParamStringValue",  IPPing_GetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_SetParamBoolValue",  IPPing_SetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_SetParamIntValue",  IPPing_SetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_SetParamUlongValue",  IPPing_SetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_SetParamStringValue",  IPPing_SetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_Validate",  IPPing_Validate);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_Commit",  IPPing_Commit);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "IPPing_Rollback",  IPPing_Rollback);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_GetParamBoolValue",  TraceRoute_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_GetParamIntValue",  TraceRoute_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_GetParamUlongValue",  TraceRoute_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_GetParamStringValue",  TraceRoute_GetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_SetParamBoolValue",  TraceRoute_SetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_SetParamIntValue",  TraceRoute_SetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_SetParamUlongValue",  TraceRoute_SetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_SetParamStringValue",  TraceRoute_SetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_Validate",  TraceRoute_Validate);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_Commit",  TraceRoute_Commit);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "TraceRoute_Rollback",  TraceRoute_Rollback);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "RouteHops_GetEntryCount",  RouteHops_GetEntryCount);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "RouteHops_GetEntry",  RouteHops_GetEntry);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "RouteHops_IsUpdated",  RouteHops_IsUpdated);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "RouteHops_Synchronize",  RouteHops_Synchronize);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "RouteHops_GetParamBoolValue",  RouteHops_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "RouteHops_GetParamIntValue",  RouteHops_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "RouteHops_GetParamUlongValue",  RouteHops_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "RouteHops_GetParamStringValue",  RouteHops_GetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_GetParamBoolValue",  DownloadDiagnostics_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_GetParamIntValue",  DownloadDiagnostics_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_GetParamUlongValue",  DownloadDiagnostics_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_GetParamStringValue",  DownloadDiagnostics_GetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_SetParamBoolValue",  DownloadDiagnostics_SetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_SetParamIntValue",  DownloadDiagnostics_SetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_SetParamUlongValue",  DownloadDiagnostics_SetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_SetParamStringValue",  DownloadDiagnostics_SetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_Validate",  DownloadDiagnostics_Validate);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_Commit",  DownloadDiagnostics_Commit);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "DownloadDiagnostics_Rollback",  DownloadDiagnostics_Rollback);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_GetParamBoolValue",  UploadDiagnostics_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_GetParamIntValue",  UploadDiagnostics_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_GetParamUlongValue",  UploadDiagnostics_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_GetParamStringValue",  UploadDiagnostics_GetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_SetParamBoolValue",  UploadDiagnostics_SetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_SetParamIntValue",  UploadDiagnostics_SetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_SetParamUlongValue",  UploadDiagnostics_SetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_SetParamStringValue",  UploadDiagnostics_SetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_Validate",  UploadDiagnostics_Validate);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_Commit",  UploadDiagnostics_Commit);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UploadDiagnostics_Rollback",  UploadDiagnostics_Rollback);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_GetParamBoolValue",  UDPEchoConfig_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_GetParamIntValue",  UDPEchoConfig_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_GetParamUlongValue",  UDPEchoConfig_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_GetParamStringValue",  UDPEchoConfig_GetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_SetParamBoolValue",  UDPEchoConfig_SetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_SetParamIntValue",  UDPEchoConfig_SetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_SetParamUlongValue",  UDPEchoConfig_SetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_SetParamStringValue",  UDPEchoConfig_SetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_Validate",  UDPEchoConfig_Validate);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_Commit",  UDPEchoConfig_Commit);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "UDPEchoConfig_Rollback",  UDPEchoConfig_Rollback);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "X_RDKCENTRAL-COM_SpeedTest_GetParamBoolValue",  SpeedTest_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "X_RDKCENTRAL-COM_SpeedTest_SetParamBoolValue",  SpeedTest_SetParamBoolValue);

    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_GetParamBoolValue",  NSLookupDiagnostics_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_GetParamIntValue",  NSLookupDiagnostics_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_GetParamUlongValue",  NSLookupDiagnostics_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_GetParamStringValue",  NSLookupDiagnostics_GetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_SetParamBoolValue",  NSLookupDiagnostics_SetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_SetParamIntValue",  NSLookupDiagnostics_SetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_SetParamUlongValue",  NSLookupDiagnostics_SetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_SetParamStringValue",  NSLookupDiagnostics_SetParamStringValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_Validate",  NSLookupDiagnostics_Validate);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_Commit",  NSLookupDiagnostics_Commit);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "NSLookupDiagnostics_Rollback",  NSLookupDiagnostics_Rollback);

    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "Result_GetEntryCount",  Result_GetEntryCount);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "Result_GetEntry",  Result_GetEntry);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "Result_IsUpdated",  Result_IsUpdated);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "Result_Synchronize",  Result_Synchronize);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "Result_GetParamBoolValue",  Result_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "Result_GetParamIntValue",  Result_GetParamIntValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "Result_GetParamUlongValue",  Result_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "Result_GetParamStringValue",  Result_GetParamStringValue);

    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "LogBackup_GetParamBoolValue",  LogBackup_GetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "LogBackup_SetParamBoolValue",  LogBackup_SetParamBoolValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "LogBackup_GetParamUlongValue",  LogBackup_GetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "LogBackup_SetParamUlongValue",  LogBackup_SetParamUlongValue);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "LogBackup_Validate",  LogBackup_Validate);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "LogBackup_Commit",  LogBackup_Commit);
    pPlugInfo->RegisterFunction(pPlugInfo->hContext, "LogBackup_Rollback",  LogBackup_Rollback);    

    
    pGetCHProc = (COSAGetCommonHandleProc)pPlugInfo->AcquireFunction("COSAGetDiagPluginInfo");

    if( pGetCHProc != NULL)
    {
        g_pCosaDiagPluginInfo = pGetCHProc(NULL);
    }
    else
    {
        goto EXIT;
    }

    pGetStringProc = (COSAGetParamValueStringProc)pPlugInfo->AcquireFunction("COSAGetParamValueString");

    if( pGetStringProc != NULL)
    {
        g_GetParamValueString = pGetStringProc;
    }
    else
    {
        goto EXIT;
    }

    pGetParamValueUlongProc = (COSAGetParamValueUlongProc)pPlugInfo->AcquireFunction("COSAGetParamValueUlong");

    if( pGetParamValueUlongProc != NULL)
    {
        g_GetParamValueUlong = pGetParamValueUlongProc;
    }
    else
    {
        goto EXIT;
    }

    pValInterfaceProc = (COSAValidateHierarchyInterfaceProc)pPlugInfo->AcquireFunction("COSAValidateHierarchyInterface");

    if ( pValInterfaceProc )
    {
        g_ValidateInterface = pValInterfaceProc;
    }
    else
    {
        goto EXIT;
    }

#ifndef _ANSC_WINDOWSNT
#ifdef _SOFTWAREMODULES_SUPPORT_NAF
    CosaSoftwareModulesInit(hCosaPlugInfo);
#endif
#endif

    pGetRegistryRootFolder = (COSAGetHandleProc)pPlugInfo->AcquireFunction("COSAGetRegistryRootFolder");

    if ( pGetRegistryRootFolder != NULL )
    {
        g_GetRegistryRootFolder = pGetRegistryRootFolder;
    }
    else
    {
        printf("!!! haha, catcha !!!\n");
        goto EXIT;
    }

    pGetInsNumberByIndexProc = (COSAGetInstanceNumberByIndexProc)pPlugInfo->AcquireFunction("COSAGetInstanceNumberByIndex");

    if ( pGetInsNumberByIndexProc != NULL )
    {
        g_GetInstanceNumberByIndex = pGetInsNumberByIndexProc;
    }
    else
    {
        goto EXIT;
    }

    pGetInterfaceByNameProc = (COSAGetInterfaceByNameProc)pPlugInfo->AcquireFunction("COSAGetInterfaceByName");

    if ( pGetInterfaceByNameProc != NULL )
    {
        g_GetInterfaceByName = pGetInterfaceByNameProc;
    }
    else
    {
        goto EXIT;
    }

    g_pTadCcdIf = g_GetInterfaceByName(g_pDslhDmlAgent, CCSP_CCD_INTERFACE_NAME);

    if ( !g_pTadCcdIf )
    {
        CcspTraceError(("g_pTadCcdIf is NULL !\n"));

        goto EXIT;
    }

    /* Get Message Bus Handle */
    g_GetMessageBusHandle = (PFN_CCSPCCDM_APPLY_CHANGES)pPlugInfo->AcquireFunction("COSAGetMessageBusHandle");
    if ( g_GetMessageBusHandle == NULL )
    {
        goto EXIT;
    }

    g_MessageBusHandle = (ANSC_HANDLE)g_GetMessageBusHandle(g_pDslhDmlAgent);
    if ( g_MessageBusHandle == NULL )
    {
        goto EXIT;
    }
    g_MessageBusHandle_Irep = g_MessageBusHandle;

    g_GetSubsystemPrefix = (COSAGetSubsystemPrefixProc)pPlugInfo->AcquireFunction("COSAGetSubsystemPrefix");
    if ( g_GetSubsystemPrefix != NULL )
    {
        char*  tmpSubsystemPrefix;

        if ( tmpSubsystemPrefix = g_GetSubsystemPrefix(g_pDslhDmlAgent) )
        {
            AnscCopyString(g_SubSysPrefix_Irep, tmpSubsystemPrefix);
        }
    }

    /* Create backend framework */
    g_pCosaBEManager = (PCOSA_BACKEND_MANAGER_OBJECT)CosaBackEndManagerCreate();

    if ( g_pCosaBEManager && g_pCosaBEManager->Initialize )
    {
        g_pCosaBEManager->hCosaPluginInfo = pPlugInfo;

        g_pCosaBEManager->Initialize   ((ANSC_HANDLE)g_pCosaBEManager);
    }

    if (diag_init() != DIAG_ERR_OK)
        goto EXIT;

    return  0;

EXIT:

    return -1;

}
Пример #7
0
int ANSC_EXPORT_API
COSA_Init
    (
        ULONG                       uMaxVersionSupported, 
        void*                       hCosaPlugInfo         /* PCOSA_PLUGIN_INFO passed in by the caller */
    )
{
    PCOSA_PLUGIN_INFO               pPlugInfo                   = (PCOSA_PLUGIN_INFO                 )hCosaPlugInfo;
    COSAGetParamValueByPathNameProc pGetParamValueByPathNameProc = (COSAGetParamValueByPathNameProc)NULL;
    COSASetParamValueByPathNameProc pSetParamValueByPathNameProc = (COSASetParamValueByPathNameProc)NULL;
    COSAGetParamValueStringProc     pGetStringProc              = (COSAGetParamValueStringProc       )NULL;
    COSAGetParamValueUlongProc      pGetParamValueUlongProc     = (COSAGetParamValueUlongProc        )NULL;
    COSAGetParamValueIntProc        pGetParamValueIntProc       = (COSAGetParamValueIntProc          )NULL;
    COSAGetParamValueBoolProc       pGetParamValueBoolProc      = (COSAGetParamValueBoolProc         )NULL;
    COSASetParamValueStringProc     pSetStringProc              = (COSASetParamValueStringProc       )NULL;
    COSASetParamValueUlongProc      pSetParamValueUlongProc     = (COSASetParamValueUlongProc        )NULL;
    COSASetParamValueIntProc        pSetParamValueIntProc       = (COSASetParamValueIntProc          )NULL;
    COSASetParamValueBoolProc       pSetParamValueBoolProc      = (COSASetParamValueBoolProc         )NULL;
    COSAGetInstanceNumbersProc      pGetInstanceNumbersProc     = (COSAGetInstanceNumbersProc        )NULL;

    COSAGetCommonHandleProc         pGetCHProc                  = (COSAGetCommonHandleProc           )NULL;
    COSAValidateHierarchyInterfaceProc 
                                    pValInterfaceProc           = (COSAValidateHierarchyInterfaceProc)NULL;
    COSAGetHandleProc               pGetRegistryRootFolder      = (COSAGetHandleProc                 )NULL;
    COSAGetInstanceNumberByIndexProc
                                    pGetInsNumberByIndexProc    = (COSAGetInstanceNumberByIndexProc  )NULL;
    COSAGetHandleProc               pGetMessageBusHandleProc    = (COSAGetHandleProc                 )NULL;
    COSAGetInterfaceByNameProc      pGetInterfaceByNameProc     = (COSAGetInterfaceByNameProc        )NULL;
    ULONG                           ret                         = 0;

    if ( uMaxVersionSupported < THIS_PLUGIN_VERSION )
    {
      /* this version is not supported */
        return -1;
    }   
    
    pPlugInfo->uPluginVersion       = THIS_PLUGIN_VERSION;
    g_pDslhDmlAgent                 = pPlugInfo->hDmlAgent;

/*
    pGetCHProc = (COSAGetCommonHandleProc)pPlugInfo->AcquireFunction("COSAGetDiagPluginInfo");

    if( pGetCHProc != NULL)
    {
        g_pCosaDiagPluginInfo = pGetCHProc(NULL);   
    }
    else
    {
        goto EXIT;
    }
*/
    pGetParamValueByPathNameProc = (COSAGetParamValueByPathNameProc)pPlugInfo->AcquireFunction("COSAGetParamValueByPathName");

    if( pGetParamValueByPathNameProc != NULL)
    {
        g_GetParamValueByPathNameProc = pGetParamValueByPathNameProc;   
    }
    else
    {
        goto EXIT;
    }

    pSetParamValueByPathNameProc = (COSASetParamValueByPathNameProc)pPlugInfo->AcquireFunction("COSASetParamValueByPathName");

    if( pSetParamValueByPathNameProc != NULL)
    {
        g_SetParamValueByPathNameProc = pSetParamValueByPathNameProc;   
    }
    else
    {
        goto EXIT;
    }

    pGetStringProc = (COSAGetParamValueStringProc)pPlugInfo->AcquireFunction("COSAGetParamValueString");

    if( pGetStringProc != NULL)
    {
        g_GetParamValueString = pGetStringProc;   
    }
    else
    {
        goto EXIT;
    }

    pGetParamValueUlongProc = (COSAGetParamValueUlongProc)pPlugInfo->AcquireFunction("COSAGetParamValueUlong");

    if( pGetParamValueUlongProc != NULL)
    {
        g_GetParamValueUlong = pGetParamValueUlongProc;   
    }
    else
    {
        goto EXIT;
    }


    pGetParamValueIntProc = (COSAGetParamValueUlongProc)pPlugInfo->AcquireFunction("COSAGetParamValueInt");

    if( pGetParamValueIntProc != NULL)
    {
        g_GetParamValueInt = pGetParamValueIntProc;   
    }
    else
    {
        goto EXIT;
    }

    pGetParamValueBoolProc = (COSAGetParamValueBoolProc)pPlugInfo->AcquireFunction("COSAGetParamValueBool");

    if( pGetParamValueBoolProc != NULL)
    {
        g_GetParamValueBool = pGetParamValueBoolProc;   
    }
    else
    {
        goto EXIT;
    }

    pSetStringProc = (COSASetParamValueStringProc)pPlugInfo->AcquireFunction("COSASetParamValueString");

    if( pSetStringProc != NULL)
    {
        g_SetParamValueString = pSetStringProc;   
    }
    else
    {
        goto EXIT;
    }

    pSetParamValueUlongProc = (COSASetParamValueUlongProc)pPlugInfo->AcquireFunction("COSASetParamValueUlong");

    if( pSetParamValueUlongProc != NULL)
    {
        g_SetParamValueUlong = pSetParamValueUlongProc;   
    }
    else
    {
        goto EXIT;
    }


    pSetParamValueIntProc = (COSASetParamValueIntProc)pPlugInfo->AcquireFunction("COSASetParamValueInt");

    if( pSetParamValueIntProc != NULL)
    {
        g_SetParamValueInt = pSetParamValueIntProc;   
    }
    else
    {
        goto EXIT;
    }

    pSetParamValueBoolProc = (COSASetParamValueBoolProc)pPlugInfo->AcquireFunction("COSASetParamValueBool");

    if( pSetParamValueBoolProc != NULL)
    {
        g_SetParamValueBool = pSetParamValueBoolProc;   
    }
    else
    {
        goto EXIT;
    }

    pGetInstanceNumbersProc = (COSAGetInstanceNumbersProc)pPlugInfo->AcquireFunction("COSAGetInstanceNumbers");

    if( pGetInstanceNumbersProc != NULL)
    {
        g_GetInstanceNumbers = pGetInstanceNumbersProc;   
    }
    else
    {
        goto EXIT;
    }

    pValInterfaceProc = (COSAValidateHierarchyInterfaceProc)pPlugInfo->AcquireFunction("COSAValidateHierarchyInterface");

    if ( pValInterfaceProc )
    {
        g_ValidateInterface = pValInterfaceProc;
    }
    else
    {
        goto EXIT;
    }
/*
#ifndef _ANSC_WINDOWSNT
#ifdef _SOFTWAREMODULES_SUPPORT_NAF    
    CosaSoftwareModulesInit(hCosaPlugInfo);
#endif
#endif
*/
    pGetRegistryRootFolder = (COSAGetHandleProc)pPlugInfo->AcquireFunction("COSAGetRegistryRootFolder");

    if ( pGetRegistryRootFolder != NULL )
    {
        g_GetRegistryRootFolder = pGetRegistryRootFolder;
    }
    else
    {
        printf("!!! haha, catcha !!!\n");
        goto EXIT;
    }

    pGetInsNumberByIndexProc = (COSAGetInstanceNumberByIndexProc)pPlugInfo->AcquireFunction("COSAGetInstanceNumberByIndex");

    if ( pGetInsNumberByIndexProc != NULL )
    {
        g_GetInstanceNumberByIndex = pGetInsNumberByIndexProc;
    }
    else
    {
        goto EXIT;
    }

    pGetInterfaceByNameProc = (COSAGetInterfaceByNameProc)pPlugInfo->AcquireFunction("COSAGetInterfaceByName");

    if ( pGetInterfaceByNameProc != NULL )
    {
        g_GetInterfaceByName = pGetInterfaceByNameProc;
    }
    else
    {
        goto EXIT;
    }

    g_pPnmCcdIf = g_GetInterfaceByName(g_pDslhDmlAgent, CCSP_CCD_INTERFACE_NAME);

    if ( !g_pPnmCcdIf )
    {
        CcspTraceError(("g_pPnmCcdIf is NULL !\n"));

        goto EXIT;
    }

    g_RegisterCallBackAfterInitDml = (COSARegisterCallBackAfterInitDmlProc)pPlugInfo->AcquireFunction("COSARegisterCallBackAfterInitDml");

    if ( !g_RegisterCallBackAfterInitDml )
    {
        goto EXIT;
    }

    g_COSARepopulateTable = (COSARepopulateTableProc)pPlugInfo->AcquireFunction("COSARepopulateTable");

    if ( !g_COSARepopulateTable )
    {
        goto EXIT;
    }

    /* Get Message Bus Handle */
    g_GetMessageBusHandle = (PFN_CCSPCCDM_APPLY_CHANGES)pPlugInfo->AcquireFunction("COSAGetMessageBusHandle");
    if ( g_GetMessageBusHandle == NULL )
    {
        goto EXIT;
    }

    g_MessageBusHandle = (ANSC_HANDLE)g_GetMessageBusHandle(g_pDslhDmlAgent);
    if ( g_MessageBusHandle == NULL )
    {
        goto EXIT;
    }
    g_MessageBusHandle_Irep = g_MessageBusHandle;
    
    /* Get Subsystem prefix */
    g_GetSubsystemPrefix = (COSAGetSubsystemPrefixProc)pPlugInfo->AcquireFunction("COSAGetSubsystemPrefix");
    if ( g_GetSubsystemPrefix != NULL )
    {
        char*   tmpSubsystemPrefix;
        
        if ( tmpSubsystemPrefix = g_GetSubsystemPrefix(g_pDslhDmlAgent) )
        {
            AnscCopyString(g_SubSysPrefix_Irep, tmpSubsystemPrefix);
        }

        /* retrieve the subsystem prefix */
        g_SubsystemPrefix = g_GetSubsystemPrefix(g_pDslhDmlAgent);
    }

    /* Create backend framework */
    g_pCosaBEManager = (PCOSA_BACKEND_MANAGER_OBJECT)CosaBackEndManagerCreate();

    if ( g_pCosaBEManager && g_pCosaBEManager->Initialize )
    {
        g_pCosaBEManager->hCosaPluginInfo = pPlugInfo;

        g_pCosaBEManager->Initialize   ((ANSC_HANDLE)g_pCosaBEManager);
    }
    
    return  0;

EXIT:

    return -1;
    
}