/**********************************************************************

    prototype:

        BOOL
        CcspNsMgrCleanAll
            (
                ANSC_HANDLE                 hCcspNsMgr
            );

    description:

        This function is called to clean all the memories in the object.

    argument:   ANSC_HANDLE                                 hCcspNsMgr
                the handle of NamespaceComponent;

    return:     The status of the operation;

**********************************************************************/
BOOL
CcspNsMgrCleanAll
    (
        ANSC_HANDLE                 hCcspNsMgr
    )
{
    PCCSP_NAMESPACE_MGR_OBJECT      pMyObject         = (PCCSP_NAMESPACE_MGR_OBJECT)hCcspNsMgr;
    PSINGLE_LINK_ENTRY              pSLinkEntry       = (PSINGLE_LINK_ENTRY)NULL;
    PCCSP_NAMESPACE_COMP_OBJECT     pNsComp           = (PCCSP_NAMESPACE_COMP_OBJECT)NULL;
    PANSC_ATOM_TABLE_OBJECT         pAtomTable        = (PANSC_ATOM_TABLE_OBJECT)pMyObject->hAtomNamespace;

    /* free the namespace compoent queue */
    if ( TRUE )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->ComponentQueue);

        while ( pSLinkEntry )
        {
            pNsComp         = ACCESS_CCSP_NAMESPACE_COMP_OBJECT(pSLinkEntry);
            pSLinkEntry     = AnscQueuePopEntry(&pMyObject->ComponentQueue);

            CcspFreeNamespaceComponent( pMyObject->pContainerName, pNsComp);
        }
    }

    /* free the hash table */
    if( pAtomTable != NULL)
    {
        pAtomTable->Remove(pAtomTable);

        pMyObject->hAtomNamespace = NULL;
    }

    return TRUE;
}
ANSC_STATUS
TlsSmoDelAllSessions
(
    ANSC_HANDLE                 hThisObject
)
{
    PTLS_SESSION_MANAGER_OBJECT     pMyObject     = (PTLS_SESSION_MANAGER_OBJECT  )hThisObject;
    PTLS_SESSION_ENTRY_OBJECT       pSessionEntry = (PTLS_SESSION_ENTRY_OBJECT    )NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry   = (PSINGLE_LINK_ENTRY           )NULL;
    ULONG                           i             = 0;

    AnscAcquireLock(&pMyObject->SeoTableLock);

    for ( i = 0; i < TLS_SMO_SEO_TABLE_SIZE; i++ )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->SeoTable[i]);

        while ( pSLinkEntry )
        {
            pSessionEntry = ACCESS_TLS_SESSION_ENTRY_OBJECT(pSLinkEntry);
            pSLinkEntry   = AnscQueuePopEntry(&pMyObject->SeoTable[i]);

            pSessionEntry->Remove((ANSC_HANDLE)pSessionEntry);
        }
    }

    AnscReleaseLock(&pMyObject->SeoTableLock);

    return  ANSC_STATUS_SUCCESS;
}
/**********************************************************************

    prototype:

        BOOL
        CcspNsCompCleanAll
            (
                ANSC_HANDLE                 hCcspNsComp
            );

    description:

        This function is called to clean all the memories in the object.

    argument:   ANSC_HANDLE                                 hCcspNsComp
                the handle of NamespaceComponent;

    return:     The status of the operation;

**********************************************************************/
BOOL
CcspNsCompCleanAll
    (
        ANSC_HANDLE                 hCcspNsComp
    )
{
    PCCSP_NAMESPACE_COMP_OBJECT     pMyObject         = (PCCSP_NAMESPACE_COMP_OBJECT)hCcspNsComp;
    PSINGLE_LINK_ENTRY              pSLinkEntry       = (PSINGLE_LINK_ENTRY)NULL;
    PCCSP_NAMESPACE                 pNamespace        = (PCCSP_NAMESPACE)NULL;

    if ( TRUE )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->ParamspaceQueue);

        while ( pSLinkEntry )
        {
            pNamespace      = ACCESS_CCSP_NAMESPACE(pSLinkEntry);
            pSLinkEntry     = AnscQueuePopEntry(&pMyObject->ParamspaceQueue);

            
            AnscFreeMemory(pNamespace->pName);
            AnscFreeMemory(pNamespace);
        }
    }

    return TRUE;
}
ANSC_STATUS
Bmc2EnvcoDelAllComTerminals
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus     = ANSC_STATUS_SUCCESS;
    PBMC2_ENV_CONTROLLER_OBJECT     pMyObject        = (PBMC2_ENV_CONTROLLER_OBJECT  )hThisObject;
    PBMC2_ENV_CONTROLLER_PROPERTY   pProperty        = (PBMC2_ENV_CONTROLLER_PROPERTY)&pMyObject->Property;
    PBMC2_COM_TERMINAL_OBJECT       pBmc2ComTerminal = (PBMC2_COM_TERMINAL_OBJECT    )NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry      = (PSINGLE_LINK_ENTRY           )NULL;

    AnscAcquireLock(&pMyObject->ComtoQueueLock);

    pSLinkEntry = AnscQueuePopEntry(&pMyObject->ComtoQueue);

    while ( pSLinkEntry )
    {
        pBmc2ComTerminal = ACCESS_BMC2_COM_TERMINAL_OBJECT(pSLinkEntry);
        pSLinkEntry      = AnscQueuePopEntry(&pMyObject->ComtoQueue);

        pBmc2ComTerminal->Cancel((ANSC_HANDLE)pBmc2ComTerminal);
        pBmc2ComTerminal->Remove((ANSC_HANDLE)pBmc2ComTerminal);
    }

    AnscReleaseLock(&pMyObject->ComtoQueueLock);

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
HttpBmoDelAllHfos
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PHTTP_HEADER_FIELD              pHttpHfo     = NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry  = NULL;
    ULONG                           i            = 0;

    AnscAcquireLock(&pMyObject->HfoTableLock);

    for ( i = 0; i < HTTP_BMO_HFO_TABLE_SIZE; i++ )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->HfoTable[i]);

        while ( pSLinkEntry )
        {
            pHttpHfo    = ACCESS_HTTP_HEADER_FIELD(pSLinkEntry);
            pSLinkEntry = AnscQueuePopEntry(&pMyObject->HfoTable[i]);

            AnscFreeMemory(pHttpHfo);
        }
    }

    AnscReleaseLock(&pMyObject->HfoTableLock);

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
DslhWmpdoReset
(
    ANSC_HANDLE                 hThisObject
)
{
    ANSC_STATUS                     returnStatus   = ANSC_STATUS_SUCCESS;
    PDSLH_WMP_DATABASE_OBJECT       pMyObject      = (PDSLH_WMP_DATABASE_OBJECT  )hThisObject;
    PDSLH_WMP_DATABASE_PROPERTY     pProperty      = (PDSLH_WMP_DATABASE_PROPERTY)&pMyObject->Property;
    PDSLH_OBJ_RECORD_OBJECT         pRootObjRecord = (PDSLH_OBJ_RECORD_OBJECT    )pMyObject->hRootObjRecord;
    PDSLH_OBJ_ENTITY_OBJECT         pRootObjEntity = (PDSLH_OBJ_ENTITY_OBJECT    )pMyObject->hRootObjEntity;
    PDSLH_WMPDO_MONITOR_PARAM       pMonitorParam  = (PDSLH_WMPDO_MONITOR_PARAM  )NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry    = (PSINGLE_LINK_ENTRY         )NULL;

    pMyObject->ResetObjVarArray(hThisObject);

    if ( pMyObject->LockedEntity )
    {
        AnscFreeMemory(pMyObject->LockedEntity);

        pMyObject->LockedEntity = NULL;
    }

    if ( pMyObject->pRootObjName)
    {
        AnscFreeMemory(pMyObject->pRootObjName);

        pMyObject->pRootObjName = NULL;
    }

    if ( pRootObjRecord )
    {
        pRootObjRecord->Remove((ANSC_HANDLE)pRootObjRecord);

        pMyObject->hRootObjRecord = (ANSC_HANDLE)NULL;
    }

    if ( pRootObjEntity )
    {
        pRootObjEntity->Remove((ANSC_HANDLE)pRootObjEntity);

        pMyObject->hRootObjEntity = (ANSC_HANDLE)NULL;
    }

    AnscAcquireLock(&pMyObject->MpoQueueLock);

    pSLinkEntry = AnscQueuePopEntry(&pMyObject->MpoQueue);

    while ( pSLinkEntry )
    {
        pMonitorParam = ACCESS_DSLH_WMPDO_MONITOR_PARAM(pSLinkEntry);
        pSLinkEntry   = AnscQueuePopEntry(&pMyObject->MpoQueue);

        DslhWmpdoFreeMonitorParam(pMonitorParam);
    }

    AnscReleaseLock(&pMyObject->MpoQueueLock);

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
DslhObjroDelAllObjRecords
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus    = ANSC_STATUS_SUCCESS;
    PDSLH_OBJ_RECORD_OBJECT         pMyObject       = (PDSLH_OBJ_RECORD_OBJECT)hThisObject;
    PDSLH_OBJ_ENTITY_OBJECT         pObjEntity      = (PDSLH_OBJ_ENTITY_OBJECT)pMyObject->hDslhObjEntity;
    PDSLH_OBJ_RECORD_OBJECT         pChildObjRecord = (PDSLH_OBJ_RECORD_OBJECT)NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry     = (PSINGLE_LINK_ENTRY     )NULL;

    pSLinkEntry = AnscQueuePopEntry(&pMyObject->ObjroQueue);

    while ( pSLinkEntry )
    {
        pChildObjRecord = ACCESS_DSLH_OBJ_RECORD_OBJECT(pSLinkEntry);
        pSLinkEntry     = AnscQueuePopEntry(&pMyObject->ObjroQueue);

        pChildObjRecord->Destroy((ANSC_HANDLE)pChildObjRecord);
        pChildObjRecord->Reset  ((ANSC_HANDLE)pChildObjRecord);
        pChildObjRecord->Remove ((ANSC_HANDLE)pChildObjRecord);
    }

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
Bmc2EnvcoDelAllCommandProperties
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus         = ANSC_STATUS_SUCCESS;
    PBMC2_ENV_CONTROLLER_OBJECT     pMyObject            = (PBMC2_ENV_CONTROLLER_OBJECT  )hThisObject;
    PBMC2_ENV_CONTROLLER_PROPERTY   pProperty            = (PBMC2_ENV_CONTROLLER_PROPERTY)&pMyObject->Property;
    PBMC2_COMMAND_PROPERTY          pBmc2CommandProperty = (PBMC2_COMMAND_PROPERTY       )NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry          = (PSINGLE_LINK_ENTRY           )NULL;
    ULONG                           i                    = 0;

    AnscAcquireLock(&pMyObject->CompoTableLock);

    for ( i = 0; i < BMC2_ENVCO_COMPO_TABLE_SIZE; i++ )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->CompoTable[i]);

        while ( pSLinkEntry )
        {
            pBmc2CommandProperty = ACCESS_BMC2_COMMAND_PROPERTY(pSLinkEntry);
            pSLinkEntry          = AnscQueuePopEntry(&pMyObject->CompoTable[i]);

            Bmc2FreeCommandProperty(pBmc2CommandProperty);
        }
    }

    AnscReleaseLock(&pMyObject->CompoTableLock);

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
AnscLpccoDelAllPendingCalls
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PANSC_LPC_CONNECTOR_OBJECT      pMyObject    = (PANSC_LPC_CONNECTOR_OBJECT)hThisObject;
    PANSC_LPCCO_PENDING_CALL        pPendingCall = (PANSC_LPCCO_PENDING_CALL  )NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry  = (PSINGLE_LINK_ENTRY        )NULL;

    AnscAcquireLock(&pMyObject->PcallQueueLock);

    pSLinkEntry = AnscQueuePopEntry(&pMyObject->PcallQueue);

    while ( pSLinkEntry )
    {
        pPendingCall = ACCESS_ANSC_LPCCO_PENDING_CALL(pSLinkEntry);
        pSLinkEntry  = AnscQueuePopEntry(&pMyObject->PcallQueue);

        AnscSetEvent  (pPendingCall->CallEvent);
        AnscFreeMemory(pPendingCall);
    }

    AnscReleaseLock(&pMyObject->PcallQueueLock);

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
AnscLpccoPopAllPendingCalls
    (
        ANSC_HANDLE                 hThisObject,
        ULONG                       error_code
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PANSC_LPC_CONNECTOR_OBJECT      pMyObject    = (PANSC_LPC_CONNECTOR_OBJECT)hThisObject;
    PANSC_LPCCO_PENDING_CALL        pPendingCall = (PANSC_LPCCO_PENDING_CALL  )NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry  = (PSINGLE_LINK_ENTRY        )NULL;

    AnscAcquireLock(&pMyObject->PcallQueueLock);

    pSLinkEntry = AnscQueuePopEntry(&pMyObject->PcallQueue);

    while ( pSLinkEntry )
    {
        pPendingCall = ACCESS_ANSC_LPCCO_PENDING_CALL(pSLinkEntry);
        pSLinkEntry  = AnscQueuePopEntry(&pMyObject->PcallQueue);

        if ( TRUE )
        {
            pPendingCall->CallError     = error_code;
            pPendingCall->CallOutputBdo = (ANSC_HANDLE)NULL;

            AnscSetEvent(pPendingCall->CallEvent);
        }
    }

    AnscReleaseLock(&pMyObject->PcallQueueLock);

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
AnscLpccoDelAllPartyAddrs
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PANSC_LPC_CONNECTOR_OBJECT      pMyObject    = (PANSC_LPC_CONNECTOR_OBJECT)hThisObject;
    PANSC_LPC_PARTY_ADDR            pPartyAddr   = (PANSC_LPC_PARTY_ADDR      )NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry  = (PSINGLE_LINK_ENTRY        )NULL;
    ULONG                           i            = 0;

    AnscAcquireLock(&pMyObject->PartyTableLock);

    for ( i = 0; i < ANSC_LPCCO_PARTY_TABLE_SIZE; i++ )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->PartyTable[i]);

        while ( pSLinkEntry )
        {
            pPartyAddr  = ACCESS_ANSC_LPC_PARTY_ADDR(pSLinkEntry);
            pSLinkEntry = AnscQueuePopEntry(&pMyObject->PartyTable[i]);

            AnscFreeMemory(pPartyAddr);
        }
    }

    AnscReleaseLock(&pMyObject->PartyTableLock);

    return  ANSC_STATUS_SUCCESS;
}
ANSC_HANDLE
SlapOmoGetObjBroker
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hTokenChain
    )
{
    ANSC_STATUS                     returnStatus    = ANSC_STATUS_SUCCESS;
    PSLAP_OBJ_MAPPER_OBJECT         pMyObject       = (PSLAP_OBJ_MAPPER_OBJECT  )hThisObject;
    PSLAP_OBJ_MAPPER_PROPERTY       pProperty       = (PSLAP_OBJ_MAPPER_PROPERTY)&pMyObject->Property;
    PSLAP_OBJ_BROKER_OBJECT         pRootObjBroker  = (PSLAP_OBJ_BROKER_OBJECT  )pMyObject->hRootObjBroker;
    PSLAP_OBJ_BROKER_OBJECT         pThisObjBroker  = (PSLAP_OBJ_BROKER_OBJECT  )pRootObjBroker;
    PSLAP_OBJ_BROKER_OBJECT         pNextObjBroker  = (PSLAP_OBJ_BROKER_OBJECT  )NULL;
    PANSC_TOKEN_CHAIN               pPathTokenChain = (PANSC_TOKEN_CHAIN        )hTokenChain;
    PANSC_STRING_TOKEN              pPathToken      = NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry     = NULL;

    pSLinkEntry = AnscQueuePopEntry(&pPathTokenChain->TokensQueue);

    while ( pSLinkEntry && pThisObjBroker )
    {
        pPathToken     = ACCESS_ANSC_STRING_TOKEN(pSLinkEntry);
        pNextObjBroker =
            (PSLAP_OBJ_BROKER_OBJECT)pThisObjBroker->GetObjBroker
                (
                    (ANSC_HANDLE)pThisObjBroker,
                    pPathToken->Name
                );

        if ( pNextObjBroker )
        {
            AnscFreeMemory(pPathToken);
        }
        else
        {
            AnscQueuePushEntryAtFront(&pPathTokenChain->TokensQueue, &pPathToken->Linkage);

            break;
        }

        pThisObjBroker = pNextObjBroker;
        pSLinkEntry    = AnscQueuePopEntry(&pPathTokenChain->TokensQueue);
    }

    if ( pSLinkEntry )
    {
        return  (ANSC_HANDLE)NULL;
    }

    return  (ANSC_HANDLE)pThisObjBroker;
}
ANSC_STATUS
DslhVareoReset
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PDSLH_VAR_ENTITY_OBJECT         pMyObject    = (PDSLH_VAR_ENTITY_OBJECT)hThisObject;
    PDSLH_VAREO_TOKEN_VALUE         pTokenValue  = (PDSLH_VAREO_TOKEN_VALUE)NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry  = (PSINGLE_LINK_ENTRY     )NULL;
    ULONG                           i            = 0;

    if ( pMyObject->ParamDescr )
    {
    	DslhCwmpFreeParamDescr(pMyObject->ParamDescr);
    	pMyObject->ParamDescr = NULL;
    }

    if ( pMyObject->TokenTable )
    {
        pSLinkEntry = AnscQueuePopEntry(pMyObject->TokenTable);

        while ( pSLinkEntry )
        {
            pTokenValue = ACCESS_DSLH_VAREO_TOKEN_VALUE(pSLinkEntry);
            pSLinkEntry = AnscQueuePopEntry(pMyObject->TokenTable);

            DslhVareoFreeTokenValue(pTokenValue);
        }

        AnscFreeMemory(pMyObject->TokenTable);

        pMyObject->TokenTable = NULL;
    }

    return  ANSC_STATUS_SUCCESS;
}
ANSC_HANDLE
AnscXmlDomNodeRemoveChild
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus  = ANSC_STATUS_SUCCESS;
    PANSC_XML_DOM_NODE_OBJECT       pXmlNode      = (PANSC_XML_DOM_NODE_OBJECT)hThisObject;
    PANSC_XML_DOM_NODE_OBJECT       pChildNode    = NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry   = NULL;

    if( AnscQueueQueryDepth(&pXmlNode->ChildNodeQueue) == 0)
    {
        if( pXmlNode->ChildNodeQueue.Next.Next != NULL)
        {
            PANSC_XML_ATTRIBUTE                     pNameAttr = NULL;

            pNameAttr = (PANSC_XML_ATTRIBUTE)AnscXmlDomNodeGetFirstAttr(pXmlNode);

            if( pNameAttr == NULL || pNameAttr->StringData == NULL)
            {
                AnscXmlWarning("The child node queue of XML node is corrupted.\n");
            }
            else
            {
                AnscXmlWarning
                    (
                        "The child node queue of XML node '%s' is corrupted.\n",
                        (PCHAR)pNameAttr->StringData
                    );
            }
        }

        return NULL;
    }

    AnscAcquireXmlLock(&pXmlNode->ChildNodeQueueLock);
    pSLinkEntry = AnscQueuePopEntry(&pXmlNode->ChildNodeQueue);
    AnscReleaseXmlLock(&pXmlNode->ChildNodeQueueLock);

    if ( pSLinkEntry )
    {
        pChildNode = ACCESS_ANSC_XML_DOM_NODE_OBJECT(pSLinkEntry);
    }

    return  (ANSC_HANDLE)pChildNode;
}
ANSC_STATUS
CcspCwmpsoReset
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus   = ANSC_STATUS_SUCCESS;
    PCCSP_CWMP_SESSION_OBJECT        pMyObject      = (PCCSP_CWMP_SESSION_OBJECT  )hThisObject;
    PCCSP_CWMPSO_ASYNC_REQUEST       pWmpsoAsyncReq = (PCCSP_CWMPSO_ASYNC_REQUEST )NULL;
    PCCSP_CWMPSO_ASYNC_RESPONSE      pWmpsoAsyncRep = (PCCSP_CWMPSO_ASYNC_RESPONSE)NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry    = (PSINGLE_LINK_ENTRY        )NULL;

    pMyObject->StopRetryTimer(pMyObject);

    pMyObject->DelAllEvents    ((ANSC_HANDLE)pMyObject);
    pMyObject->DelAllParameters((ANSC_HANDLE)pMyObject);

    /*
     * Release all the async requests...
     */
    AnscAcquireLock(&pMyObject->AsyncReqQueueLock);

    pSLinkEntry = AnscQueuePopEntry(&pMyObject->AsyncReqQueue);

    while ( pSLinkEntry )
    {
        pWmpsoAsyncReq = ACCESS_CCSP_CWMPSO_ASYNC_REQUEST(pSLinkEntry);
        pSLinkEntry    = AnscQueuePopEntry(&pMyObject->AsyncReqQueue);

        /* CcspCwmpsoSignalAsyncRequest(pWmpsoAsyncReq, ANSC_STATUS_FAILURE); */
        CcspCwmpsoFreeAsyncRequest(pWmpsoAsyncReq);
    }

    AnscReleaseLock(&pMyObject->AsyncReqQueueLock);

    /*
     * Release all the saved requests...
     */
    AnscAcquireLock(&pMyObject->SavedReqQueueLock);

    pSLinkEntry = AnscQueuePopEntry(&pMyObject->SavedReqQueue);

    while ( pSLinkEntry )
    {
        pWmpsoAsyncReq = ACCESS_CCSP_CWMPSO_ASYNC_REQUEST(pSLinkEntry);
        pSLinkEntry    = AnscQueuePopEntry(&pMyObject->SavedReqQueue);

        /* CcspCwmpsoSignalAsyncRequest(pWmpsoAsyncReq, ANSC_STATUS_FAILURE); */
        CcspCwmpsoFreeAsyncRequest(pWmpsoAsyncReq);
    }

    AnscReleaseLock(&pMyObject->SavedReqQueueLock);

    /*
     * Release all the async responses...
     */
    AnscAcquireLock(&pMyObject->AsyncRepQueueLock);

    pSLinkEntry = AnscQueuePopEntry(&pMyObject->AsyncRepQueue);

    while ( pSLinkEntry )
    {
        pWmpsoAsyncRep = ACCESS_CCSP_CWMPSO_ASYNC_RESPONSE(pSLinkEntry);
        pSLinkEntry    = AnscQueuePopEntry(&pMyObject->AsyncRepQueue);

        CcspCwmpsoFreeAsyncResponse(pWmpsoAsyncRep);
    }

    AnscReleaseLock(&pMyObject->AsyncRepQueueLock);

    return  ANSC_STATUS_SUCCESS;
}
Пример #16
0
ANSC_STATUS
AnscBetoSendTask
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PANSC_BROKER_ENGINE_TCP_OBJECT  pMyObject    = (PANSC_BROKER_ENGINE_TCP_OBJECT)hThisObject;
    ansc_fd_set*                    pSendSet1    = (ansc_fd_set*                  )pMyObject->SendSocketSet;
    xskt_fd_set*                    pSendSet2    = (xskt_fd_set*                  )pMyObject->SendSocketSet;
    PANSC_BROKER_SERVER_TCP_OBJECT  pServer      = (PANSC_BROKER_SERVER_TCP_OBJECT)pMyObject->hBrokerServer;
    PANSC_BSTO_WORKER_OBJECT        pWorker      = (PANSC_BSTO_WORKER_OBJECT      )pServer->hWorker;
    PANSC_BETO_PACKET_OBJECT        pPacket      = NULL;
    PANSC_BROKER_SOCKET_TCP_OBJECT  pSocket      = NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry  = NULL;
    BOOL                            bSendable    = FALSE;
    int                             s_result     = 0;
    int                             s_error      = 0;

    AnscTrace("AnscBetoSendTask is activated ...!\n");

    /*
     * As a scalable server implemention, we shall accept as many incoming client connections as
     * possible and can only be limited by the system resources. Once the listening socket becomes
     * readable, which means an incoming connection attempt has arrived. We create a new socket
     * object and associate it with the client. This is a repeated process until the socket owner
     * closes the socket.
     */
    while ( pMyObject->bStarted )
    {
        AnscAcquireLock(&pMyObject->PacketQueueLock);
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->PacketQueue);
        AnscReleaseLock(&pMyObject->PacketQueueLock);

        if ( !pSLinkEntry )
        {
            continue;
        }
        else
        {
            pPacket = ACCESS_ANSC_BETO_PACKET_OBJECT(pSLinkEntry);
            pSocket = (PANSC_BROKER_SOCKET_TCP_OBJECT)pPacket->hSocket;
        }

	#if !defined(_ANSC_KERNEL) || !defined(_ANSC_LINUX)
        AnscAcquireLock(&pMyObject->SendSocketSetLock);
        bSendable = (pServer->Mode & ANSC_BSTO_MODE_XSOCKET)? XSKT_SOCKET_FD_ISSET(pSocket->Socket, pSendSet2) : ANSC_SOCKET_FD_ISSET(pSocket->Socket, pSendSet1);
        AnscReleaseLock(&pMyObject->SendSocketSetLock);

        if ( !bSendable )
        {
            returnStatus =
                pWorker->SendComplete
                    (
                        pWorker->hWorkerContext,
                        (ANSC_HANDLE)pSocket,
                        pPacket->hWorkerReserved,
                        ANSC_STATUS_FAILURE
                    );

            AnscFreeMemory(pPacket);

            continue;
        }
	#endif

        if ( pServer->Mode & ANSC_BSTO_MODE_XSOCKET )
        {
            s_result = _xskt_send(((XSKT_SOCKET)pSocket->Socket), pPacket->PacketBuffer, (int)pPacket->PacketSize, 0);
        }
        else
        {
            s_result = _ansc_send(pSocket->Socket, pPacket->PacketBuffer, (int)pPacket->PacketSize, 0);
        }

        if ( ((s_result == XSKT_SOCKET_ERROR) &&  (pServer->Mode & ANSC_BSTO_MODE_XSOCKET)) ||
             ((s_result == ANSC_SOCKET_ERROR) && !(pServer->Mode & ANSC_BSTO_MODE_XSOCKET)) )
        {
            s_error = (pServer->Mode & ANSC_BSTO_MODE_XSOCKET)? _xskt_get_last_error() : _ansc_get_last_error();

            returnStatus =
                pWorker->SendComplete
                    (
                        pWorker->hWorkerContext,
                        (ANSC_HANDLE)pSocket,
                        pPacket->hWorkerReserved,
                        ANSC_STATUS_FAILURE
                    );

            if ( pServer->Mode & ANSC_BSTO_MODE_AUTO_CLOSE )
            {
                pMyObject->DelSocket((ANSC_HANDLE)pMyObject, (ANSC_HANDLE)pSocket);
            }
        }
        else
        {
            returnStatus =
                pWorker->SendComplete
                    (
                        pWorker->hWorkerContext,
                        (ANSC_HANDLE)pSocket,
                        pPacket->hWorkerReserved,
                        ANSC_STATUS_SUCCESS
                    );

            pSocket->SendBytesCount += pPacket->PacketSize;
            pSocket->LastSendAt      = AnscGetTickInSeconds();
        }
    }

    AnscSetEvent(&pMyObject->SendEvent);

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
DslhObjeoReset
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus    = ANSC_STATUS_SUCCESS;
    PDSLH_OBJ_ENTITY_OBJECT         pMyObject       = (PDSLH_OBJ_ENTITY_OBJECT)hThisObject;
    PDSLH_OBJ_ENTITY_OBJECT         pChildObjEntity = (PDSLH_OBJ_ENTITY_OBJECT)NULL;
    PDSLH_VAR_ENTITY_OBJECT         pChildVarEntity = (PDSLH_VAR_ENTITY_OBJECT)NULL;
    PDSLH_OBJEO_INSTANCE            pObjeoInstance  = (PDSLH_OBJEO_INSTANCE   )NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry     = (PSINGLE_LINK_ENTRY     )NULL;
    ULONG                           i               = 0;

    /* reset the child objects/parameters */
    if ( TRUE )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->ObjInsQueue);

        while ( pSLinkEntry )
        {
            pObjeoInstance = ACCESS_DSLH_OBJEO_INSTANCE(pSLinkEntry);
            pSLinkEntry    = AnscQueuePopEntry(&pMyObject->ObjInsQueue);

            AnscFreeMemory(pObjeoInstance);
        }
    }

    if ( TRUE )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->ObjeoQueue);

        while ( pSLinkEntry )
        {
            pChildObjEntity = ACCESS_DSLH_OBJ_ENTITY_OBJECT(pSLinkEntry);
            pSLinkEntry     = AnscQueuePopEntry(&pMyObject->ObjeoQueue);

            pChildObjEntity->Reset ((ANSC_HANDLE)pChildObjEntity);
            pChildObjEntity->Remove((ANSC_HANDLE)pChildObjEntity);
        }
    }

    if ( TRUE )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->VareoTable);

        while ( pSLinkEntry )
        {
            pChildVarEntity = ACCESS_DSLH_VAR_ENTITY_OBJECT(pSLinkEntry);
            pSLinkEntry     = AnscQueuePopEntry(&pMyObject->VareoTable);

            DslhVareoReset ((ANSC_HANDLE)pChildVarEntity);
            DslhVareoRemove((ANSC_HANDLE)pChildVarEntity);
        }
    }

    /* reset itself */
    if ( pMyObject->ObjDescr )
    {
        if( pMyObject->ObjDescr->hParamArray != NULL)
        {
            AnscFreeMemory(pMyObject->ObjDescr->hParamArray);

            pMyObject->ObjDescr->hParamArray = NULL;
        }

    	DslhCwmpFreeObjectDescr(pMyObject->ObjDescr );
    	pMyObject->ObjDescr = NULL;
    }

    if ( pMyObject->LastName )
    {
        AnscFreeMemory(pMyObject->LastName);

        pMyObject->LastName = NULL;
    }

    return  ANSC_STATUS_SUCCESS;
}
Пример #18
0
/**********************************************************************

    prototype:

        BOOL
        CcspCrCleanAll
            (
                ANSC_HANDLE                 hCcspCr
            );

    description:

        This function is called to clean all the memories.

    argument:   ANSC_HANDLE                                 hCcspCr
                the handle of CCSP CR component;

    return:     The status of the operation;

**********************************************************************/
BOOL
CcspCrCleanAll
    (
        ANSC_HANDLE                 hCcspCr
    )
{
    PCCSP_CR_MANAGER_OBJECT         pMyObject         = (PCCSP_CR_MANAGER_OBJECT)hCcspCr;
    PCCSP_COMPONENT_INFO            pCompInfo         = (PCCSP_COMPONENT_INFO)NULL;
    PCCSP_REMOTE_CRINFO             pCRInfo           = (PCCSP_REMOTE_CRINFO)NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry       = (PSINGLE_LINK_ENTRY)NULL;
    PCCSP_NAMESPACE_MGR_OBJECT      pNSMgr            = (PCCSP_NAMESPACE_MGR_OBJECT)pMyObject->hCcspNamespaceMgr;

    pMyObject->bSystemReady = FALSE;

    if( pNSMgr != NULL)
    {
        CcspFreeNamespaceMgr(CCSP_CR_NAME, pMyObject->hCcspNamespaceMgr);

        pMyObject->hCcspNamespaceMgr = NULL;
    }

    if( pMyObject->pDeviceName != NULL)
    {
        CcspCrFreeMemory(pMyObject->pDeviceName);

        pMyObject->pDeviceName = NULL;
    }

    if( pMyObject->pCRName != NULL)
    {
        CcspCrFreeMemory(pMyObject->pCRName);

        pMyObject->pCRName = NULL;
    }

    if( pMyObject->pPrefix != NULL)
    {
        CcspCrFreeMemory(pMyObject->pPrefix);

        pMyObject->pPrefix = NULL;
    }

    /* delete the component infor objects */
    if ( TRUE )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->CompInfoQueue);

        while ( pSLinkEntry )
        {
            pCompInfo       = ACCESS_CCSP_COMPONENT_INFO(pSLinkEntry);
            pSLinkEntry     = AnscQueuePopEntry(&pMyObject->CompInfoQueue);

            CcspCrFreeMemory(pCompInfo->pComponentName);
            CcspCrFreeMemory(pCompInfo);
        }
    }

    if ( TRUE )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->UnknowCompInfoQueue);

        while ( pSLinkEntry )
        {
            pCompInfo       = ACCESS_CCSP_COMPONENT_INFO(pSLinkEntry);
            pSLinkEntry     = AnscQueuePopEntry(&pMyObject->UnknowCompInfoQueue);

            CcspCrFreeMemory(pCompInfo->pComponentName);
            CcspCrFreeMemory(pCompInfo);
        }
    }

    if ( TRUE )
    {
        pSLinkEntry = AnscQueuePopEntry(&pMyObject->RemoteCRQueue);

        while ( pSLinkEntry )
        {
            pCRInfo         = ACCESS_CCSP_REMOTE_CRINFO(pSLinkEntry);
            pSLinkEntry     = AnscQueuePopEntry(&pMyObject->RemoteCRQueue);

            CcspCrFreeMemory(pCRInfo->pPrefix);
            CcspCrFreeMemory(pCRInfo->pID);
            CcspCrFreeMemory(pCRInfo);
        }
    }

    return TRUE;
}
ANSC_HANDLE
SlapOmoGetObjProxy2
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hTokenChain
    )
{
    ANSC_STATUS                     returnStatus    = ANSC_STATUS_SUCCESS;
    PSLAP_OBJ_MAPPER_OBJECT         pMyObject       = (PSLAP_OBJ_MAPPER_OBJECT  )hThisObject;
    PSLAP_OBJ_MAPPER_PROPERTY       pProperty       = (PSLAP_OBJ_MAPPER_PROPERTY)&pMyObject->Property;
    PSLAP_OBJ_BROKER_OBJECT         pRootObjBroker  = (PSLAP_OBJ_BROKER_OBJECT  )pMyObject->hRootObjBroker;
    PSLAP_OBJ_BROKER_OBJECT         pThisObjBroker  = (PSLAP_OBJ_BROKER_OBJECT  )pRootObjBroker;
    PSLAP_OBJ_BROKER_OBJECT         pNextObjBroker  = (PSLAP_OBJ_BROKER_OBJECT  )NULL;
    PSLAP_OBJ_PROXY_OBJECT          pObjProxy       = (PSLAP_OBJ_PROXY_OBJECT   )NULL;
    PANSC_TOKEN_CHAIN               pPathTokenChain = (PANSC_TOKEN_CHAIN        )hTokenChain;
    PANSC_STRING_TOKEN              pPathToken      = NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry     = NULL;

    if(pThisObjBroker) /*RDKB-6244, CID-24128, null check before use*/
    {
        pObjProxy = (PSLAP_OBJ_PROXY_OBJECT	)pThisObjBroker->hSlapObjProxy;
    }

    if ( AnscQueueQueryDepth(&pPathTokenChain->TokensQueue) == 0 )
    {
        pObjProxy = (PSLAP_OBJ_PROXY_OBJECT)NULL;
    }
    else
    {
        pSLinkEntry = AnscQueuePopEntry(&pPathTokenChain->TokensQueue);

        while ( pSLinkEntry && pThisObjBroker )
        {
            pPathToken     = ACCESS_ANSC_STRING_TOKEN(pSLinkEntry);
            pNextObjBroker =
                (PSLAP_OBJ_BROKER_OBJECT)pThisObjBroker->GetObjBroker
                    (
                        (ANSC_HANDLE)pThisObjBroker,
                        pPathToken->Name
                    );

            if ( pNextObjBroker )
            {
                if ( pNextObjBroker->hSlapObjProxy )
                {
                    pObjProxy = (PSLAP_OBJ_PROXY_OBJECT)pNextObjBroker->hSlapObjProxy;
                }

                AnscFreeMemory(pPathToken);
            }
            else
            {
                AnscQueuePushEntryAtFront(&pPathTokenChain->TokensQueue, &pPathToken->Linkage);

                break;
            }

            pThisObjBroker = pNextObjBroker;
            pSLinkEntry    = AnscQueuePopEntry(&pPathTokenChain->TokensQueue);
        }

        if ( AnscQueueQueryDepth(&pPathTokenChain->TokensQueue) > 0 )
        {
            pObjProxy = (PSLAP_OBJ_PROXY_OBJECT)NULL;
        }
    }

    return  (ANSC_HANDLE)pObjProxy;
}