ANSC_STATUS
CosaDdnsRegDelDdnsInfo
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hCosaContext
    )
{
    ANSC_STATUS                     returnStatus      = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_DDNS            pMyObject         = (PCOSA_DATAMODEL_DDNS     )hThisObject;
    PCOSA_CONTEXT_LINK_OBJECT       pCosaContext      = (PCOSA_CONTEXT_LINK_OBJECT)hCosaContext;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoDdns   = (PPOAM_IREP_FOLDER_OBJECT )pCosaContext->hPoamIrepUpperFo;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoDdnsSp = (PPOAM_IREP_FOLDER_OBJECT )pCosaContext->hPoamIrepFo;

    if ( !pPoamIrepFoDdns || !pPoamIrepFoDdnsSp )
    {
        return ANSC_STATUS_FAILURE;
    }
    else
    {
        pPoamIrepFoDdns->EnableFileSync((ANSC_HANDLE)pPoamIrepFoDdns, FALSE);
    }

    if ( TRUE )
    {
        pPoamIrepFoDdnsSp->Close((ANSC_HANDLE)pPoamIrepFoDdnsSp);
        
        pPoamIrepFoDdns->DelFolder
            (
                (ANSC_HANDLE)pPoamIrepFoDdns, 
                pPoamIrepFoDdnsSp->GetFolderName((ANSC_HANDLE)pPoamIrepFoDdnsSp)
            );

        AnscFreeMemory(pPoamIrepFoDdnsSp);
    }

    pPoamIrepFoDdns->EnableFileSync((ANSC_HANDLE)pPoamIrepFoDdns, TRUE);

    return ANSC_STATUS_SUCCESS;
}
Esempio n. 2
0
ANSC_STATUS
CosaRARegDelInfo
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hCosaContext
    )
{
    ANSC_STATUS                     returnStatus      = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_RA              pMyObject         = (PCOSA_DATAMODEL_RA )hThisObject;
    PCOSA_CONTEXT_LINK_OBJECT       pCosaContext      = (PCOSA_CONTEXT_LINK_OBJECT)hCosaContext;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepUpperFo  = (PPOAM_IREP_FOLDER_OBJECT )pCosaContext->hPoamIrepUpperFo;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFo       = (PPOAM_IREP_FOLDER_OBJECT )pCosaContext->hPoamIrepFo;

    if ( !pPoamIrepUpperFo || !pPoamIrepFo )
    {
        return ANSC_STATUS_FAILURE;
    }
    else
    {
        pPoamIrepUpperFo->EnableFileSync((ANSC_HANDLE)pPoamIrepUpperFo, FALSE);
    }

    if ( TRUE )
    {
        pPoamIrepFo->Close((ANSC_HANDLE)pPoamIrepFo);
        
        pPoamIrepUpperFo->DelFolder
            (
                (ANSC_HANDLE)pPoamIrepUpperFo, 
                pPoamIrepFo->GetFolderName((ANSC_HANDLE)pPoamIrepFo)
            );

        pPoamIrepUpperFo->EnableFileSync((ANSC_HANDLE)pPoamIrepUpperFo, TRUE);

        AnscFreeMemory((ANSC_HANDLE)pPoamIrepFo);
    }

    return ANSC_STATUS_SUCCESS;
}
Esempio n. 3
0
ANSC_STATUS
CosaNatRegSetNatInfo
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus        = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_NAT             pMyObject           = (PCOSA_DATAMODEL_NAT     )hThisObject;

    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoNat      = (PPOAM_IREP_FOLDER_OBJECT)pMyObject->hIrepFolderNat;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoNatPt    = (PPOAM_IREP_FOLDER_OBJECT)NULL;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoEnumNat  = (PPOAM_IREP_FOLDER_OBJECT)NULL;
    PCOSA_CONTEXT_LINK_OBJECT       pCosaNatContext     = NULL;
    PCOSA_DML_NAT_PMAPPING          pCosaNat            = NULL;
    PCOSA_DML_NAT_PTRIGGER          pCosaNatPt          = NULL;

    PSINGLE_LINK_ENTRY              pSLinkEntry         = (PSINGLE_LINK_ENTRY      )NULL;
    PSLAP_VARIABLE                  pSlapVariable       = NULL;
    ULONG                           ulEntryCount        = 0;
    ULONG                           ulIndex             = 0;
    ULONG                           uInstanceNumber     = 0;
    char*                           pAliasNat           = NULL;
    char*                           pFolderName         = NULL;
    char                            FolderName[16]      = {0};


    if ( !pPoamIrepFoNat )
    {
        return ANSC_STATUS_FAILURE;
    }
    else
    {
        pPoamIrepFoNat->EnableFileSync((ANSC_HANDLE)pPoamIrepFoNat, FALSE);
    }

    if ( TRUE )
    {
        pPoamIrepFoNat->Clear((ANSC_HANDLE)pPoamIrepFoNat);

        SlapAllocVariable(pSlapVariable);

        if ( !pSlapVariable )
        {
            returnStatus = ANSC_STATUS_RESOURCES;

            goto  EXIT1;
        }
    }

    /* This is saved structure for Nat
        *****************************************
              <Nat>
                  <PortMapping>
                      <1>
                           <alias>xxx</>
                           <bNew>false</>
                     </1>
                     <2>
                          <alias>xxx</>
                          <bNew>false</>
                     </2>
                </PortMapping>
            </Nat>
      ******************************************/

    pSLinkEntry = AnscSListGetFirstEntry(&pMyObject->NatPMappingList);

    while ( pSLinkEntry )
    {
        /* create nat.{i} */

        pCosaNatContext = ACCESS_COSA_CONTEXT_LINK_OBJECT(pSLinkEntry);
        pSLinkEntry       = AnscSListGetNextEntry(pSLinkEntry);

        pCosaNat = (PCOSA_DML_NAT_PMAPPING)pCosaNatContext->hContext;

        if ( !pCosaNatContext->bNew )
        {
            continue;
        }

        _ansc_sprintf(FolderName, "%d", pCosaNat->InstanceNumber);

        pPoamIrepFoEnumNat =
            pPoamIrepFoNat->AddFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoNat,
                    FolderName,
                    0
                );

        if ( !pPoamIrepFoEnumNat )
        {
            continue;
        }

        /* add  nat.{i}.Alias */
        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_string;
            pSlapVariable->Variant.varString = AnscCloneString(pCosaNat->Alias);

            returnStatus =
                pPoamIrepFoEnumNat->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoEnumNat,
                        COSA_DML_RR_NAME_NATAlias,
                        SYS_REP_RECORD_TYPE_ASTR,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        /* add  nat.{i}.bNew */
        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_bool;
            pSlapVariable->Variant.varBool   = pCosaNatContext->bNew;

            returnStatus =
                pPoamIrepFoEnumNat->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoEnumNat,
                        COSA_DML_RR_NAME_NATbNew,
                        SYS_REP_RECORD_TYPE_BOOL,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }


        /*release some resource */
        pPoamIrepFoEnumNat->Remove((ANSC_HANDLE)pPoamIrepFoEnumNat);
        pPoamIrepFoEnumNat = NULL;
    }

    /* For PortTrigger */

    /* This is saved structure for Nat
        *****************************************
              <Nat>
                  <PortTrigger>
                      <NextInsNumber>xxx</>
                      <1>
                           <alias>xxx</>
                           <bNew>true</>
                     </1>
                     <2>
                          <alias>xxx</>
                          <bNew>true</>
                     </2>
                </PortTrigger>
            </Nat>
      ******************************************/

    pPoamIrepFoNatPt =
            pPoamIrepFoNat->AddFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoNat,
                    COSA_IREP_FOLDER_NAME_PORTTRIGGER,
                    0
                );

    if ( !pPoamIrepFoNatPt )
    {
        returnStatus = ANSC_STATUS_FAILURE;

        goto EXIT1;
    }

    /* Save next instance number for port trigger */
    if ( TRUE )
    {
        pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_uint32;
        pSlapVariable->Variant.varUint32 = pMyObject->ulPtNextInstanceNumber;

        returnStatus =
            pPoamIrepFoNatPt->AddRecord
                (
                    (ANSC_HANDLE)pPoamIrepFoNatPt,
                    COSA_DML_RR_NAME_NATNextInsNumber,
                    SYS_REP_RECORD_TYPE_UINT,
                    SYS_RECORD_CONTENT_DEFAULT,
                    pSlapVariable,
                    0
                );

        SlapCleanVariable(pSlapVariable);
        SlapInitVariable (pSlapVariable);
    }

    pSLinkEntry = AnscSListGetFirstEntry(&pMyObject->NatPTriggerList);

    while ( pSLinkEntry )
    {
        /* create nat.PortTrigger.{i} */

        pCosaNatContext = ACCESS_COSA_CONTEXT_LINK_OBJECT(pSLinkEntry);
        pSLinkEntry       = AnscSListGetNextEntry(pSLinkEntry);

        pCosaNatPt = (PCOSA_DML_NAT_PTRIGGER)pCosaNatContext->hContext;

        if ( !pCosaNatContext->bNew )
        {
            continue;
        }

        _ansc_sprintf(FolderName, "%d", pCosaNatPt->InstanceNumber);

        pPoamIrepFoEnumNat =
            pPoamIrepFoNatPt->AddFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoNatPt,
                    FolderName,
                    0
                );

        if ( !pPoamIrepFoEnumNat )
        {
            continue;
        }

        /* add  PortTrigger.{i}.Alias */
        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_string;
            pSlapVariable->Variant.varString = AnscCloneString(pCosaNatPt->Alias);

            returnStatus =
                pPoamIrepFoEnumNat->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoEnumNat,
                        COSA_DML_RR_NAME_NATAlias,
                        SYS_REP_RECORD_TYPE_ASTR,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        /* add  PortTrigger.{i}.bNew */
        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_bool;
            pSlapVariable->Variant.varBool   = pCosaNatContext->bNew;

            returnStatus =
                pPoamIrepFoEnumNat->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoEnumNat,
                        COSA_DML_RR_NAME_NATbNew,
                        SYS_REP_RECORD_TYPE_BOOL,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }


        /*release some resource */
        pPoamIrepFoEnumNat->Remove((ANSC_HANDLE)pPoamIrepFoEnumNat);
        pPoamIrepFoEnumNat = NULL;
    }


EXIT1:
    if ( pSlapVariable )
    {
        SlapFreeVariable(pSlapVariable);
        pSlapVariable = NULL;
    }

    if ( pPoamIrepFoEnumNat )
        pPoamIrepFoEnumNat->Remove((ANSC_HANDLE)pPoamIrepFoEnumNat);

    pPoamIrepFoNat->EnableFileSync((ANSC_HANDLE)pPoamIrepFoNat, TRUE);

    return returnStatus;
}
Esempio n. 4
0
ANSC_STATUS
CosaNatInitialize
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus     = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_NAT             pMyObject        = (PCOSA_DATAMODEL_NAT)hThisObject;
    PSLAP_VARIABLE                  pSlapVariable    = (PSLAP_VARIABLE             )NULL;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoCOSA  = NULL;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoNat   = NULL;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoNatPt = NULL;

    /* Call Initiation */
    returnStatus = CosaDmlNatInit(NULL, NULL, CosaNatGen);
    if ( returnStatus != ANSC_STATUS_SUCCESS )
    {
        return returnStatus;
    }

    /* Initiation all functions */
    AnscSListInitializeHeader( &pMyObject->NatPMappingList );
    AnscSListInitializeHeader( &pMyObject->NatPTriggerList );
    pMyObject->MaxInstanceNumber        = 0;
    pMyObject->ulPtNextInstanceNumber   = 1;
    pMyObject->PreviousVisitTime        = 0;

    /*Create NAT folder in configuration */
    pPoamIrepFoCOSA = (PPOAM_IREP_FOLDER_OBJECT)g_GetRegistryRootFolder(g_pDslhDmlAgent);

    if ( !pPoamIrepFoCOSA )
    {
        returnStatus = ANSC_STATUS_FAILURE;

        goto  EXIT;
    }

    pPoamIrepFoNat =
        (PPOAM_IREP_FOLDER_OBJECT)pPoamIrepFoCOSA->GetFolder
            (
                (ANSC_HANDLE)pPoamIrepFoCOSA,
                COSA_IREP_FOLDER_NAME_NAT
            );

    if ( !pPoamIrepFoNat )
    {
        pPoamIrepFoCOSA->EnableFileSync((ANSC_HANDLE)pPoamIrepFoCOSA, FALSE);

        pPoamIrepFoNat =
            pPoamIrepFoCOSA->AddFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoCOSA,
                    COSA_IREP_FOLDER_NAME_NAT,
                    0
                );

        pPoamIrepFoCOSA->EnableFileSync((ANSC_HANDLE)pPoamIrepFoCOSA, TRUE);
    }

    if ( !pPoamIrepFoNat )
    {
        returnStatus = ANSC_STATUS_FAILURE;

        goto  EXIT;
    }
    else
    {
        pMyObject->hIrepFolderNat = (ANSC_HANDLE)pPoamIrepFoNat;
    }

    pPoamIrepFoNatPt =
        (PPOAM_IREP_FOLDER_OBJECT)pPoamIrepFoNat->GetFolder
            (
                (ANSC_HANDLE)pPoamIrepFoNat,
                COSA_IREP_FOLDER_NAME_PORTTRIGGER
            );

    if ( !pPoamIrepFoNatPt )
    {
        /* pPoamIrepFoCOSA->EnableFileSync((ANSC_HANDLE)pPoamIrepFoCOSA, FALSE); */

        pPoamIrepFoNatPt =
            pPoamIrepFoCOSA->AddFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoNat,
                    COSA_IREP_FOLDER_NAME_PORTTRIGGER,
                    0
                );

        /* pPoamIrepFoCOSA->EnableFileSync((ANSC_HANDLE)pPoamIrepFoCOSA, TRUE); */
    }

    if ( !pPoamIrepFoNatPt )
    {
        returnStatus = ANSC_STATUS_FAILURE;

        goto  EXIT;
    }
    else
    {
        pMyObject->hIrepFolderNatPt = (ANSC_HANDLE)pPoamIrepFoNatPt;
    }

    /* Retrieve the next instance number for Port Trigger */

    if ( TRUE )
    {
        if ( pPoamIrepFoNatPt )
        {
            pSlapVariable =
                (PSLAP_VARIABLE)pPoamIrepFoNatPt->GetRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoNatPt,
                        COSA_DML_RR_NAME_NATNextInsNumber,
                        NULL
                    );

            if ( pSlapVariable )
            {
                pMyObject->ulPtNextInstanceNumber = pSlapVariable->Variant.varUint32;

                SlapFreeVariable(pSlapVariable);
            }
        }
    }

    CosaDmlNatGetLanIP(NULL);

    /* Sync with backend */
    CosaDmlNatGetDmz(NULL, &pMyObject->Dmz);

    CosaNatSyncPortTrigger((ANSC_HANDLE)pMyObject);

    /* We need get NextInstanceNumber from backend. By the way, the whole tree
            was created. Moreover, we also need get delay-added entry and put them
            into our tree. */
    CosaNatRegGetNatInfo((ANSC_HANDLE)pMyObject);

EXIT:

    return returnStatus;
}
ANSC_STATUS
CosaDdnsRegAddDdnsInfo
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hCosaContext
    )
{
    ANSC_STATUS                     returnStatus      = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_DDNS            pMyObject         = (PCOSA_DATAMODEL_DDNS     )hThisObject;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoDdns   = (PPOAM_IREP_FOLDER_OBJECT )pMyObject->hIrepFolderDdns;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoDdnsSp = (PPOAM_IREP_FOLDER_OBJECT )NULL;
    PCOSA_CONTEXT_LINK_OBJECT       pCosaContext      = (PCOSA_CONTEXT_LINK_OBJECT)hCosaContext;
    PCOSA_DML_DDNS_SERVICE          pDdnsService      = (PCOSA_DML_DDNS_SERVICE   )pCosaContext->hContext;
    PSLAP_VARIABLE                  pSlapVariable     = (PSLAP_VARIABLE           )NULL;

    if ( !pPoamIrepFoDdns )
    {
        return ANSC_STATUS_FAILURE;
    }
    else
    {
        pPoamIrepFoDdns->EnableFileSync((ANSC_HANDLE)pPoamIrepFoDdns, FALSE);
    }

    if ( TRUE )
    {
        SlapAllocVariable(pSlapVariable);

        if ( !pSlapVariable )
        {
            returnStatus = ANSC_STATUS_RESOURCES;

            goto  EXIT1;
        }
    }

    if ( TRUE )
    {
        returnStatus = 
            pPoamIrepFoDdns->DelRecord
                (
                    (ANSC_HANDLE)pPoamIrepFoDdns,
                    COSA_DML_RR_NAME_DdnsServiceNextInsNumber
                );

        pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_uint32;
        pSlapVariable->Variant.varUint32 = pMyObject->ulNextInstance;

        returnStatus =
            pPoamIrepFoDdns->AddRecord
                (
                    (ANSC_HANDLE)pPoamIrepFoDdns,
                    COSA_DML_RR_NAME_DdnsServiceNextInsNumber,
                    SYS_REP_RECORD_TYPE_UINT,
                    SYS_RECORD_CONTENT_DEFAULT,
                    pSlapVariable,
                    0
                );

        SlapCleanVariable(pSlapVariable);
        SlapInitVariable (pSlapVariable);
    }

    if ( TRUE )
    {
        pPoamIrepFoDdnsSp =
            pPoamIrepFoDdns->AddFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoDdns,
                    pDdnsService->Alias,
                    0
                );

        if ( !pPoamIrepFoDdnsSp )
        {
            returnStatus = ANSC_STATUS_FAILURE;

            goto  EXIT1;
        }

        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_uint32;
            pSlapVariable->Variant.varUint32 = pDdnsService->InstanceNumber;

            returnStatus =
                pPoamIrepFoDdnsSp->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoDdnsSp,
                        COSA_DML_RR_NAME_DdnsServiceInsNum,
                        SYS_REP_RECORD_TYPE_UINT,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_string;
            pSlapVariable->Variant.varString = AnscCloneString(pDdnsService->Alias);

            returnStatus =
                pPoamIrepFoDdnsSp->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoDdnsSp,
                        COSA_DML_RR_NAME_DdnsServiceAlias,
                        SYS_REP_RECORD_TYPE_ASTR,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        pCosaContext->hPoamIrepUpperFo = (ANSC_HANDLE)pPoamIrepFoDdns;
        pCosaContext->hPoamIrepFo      = (ANSC_HANDLE)pPoamIrepFoDdnsSp;
    }

EXIT1:
    
    if ( pSlapVariable )
    {
        SlapFreeVariable(pSlapVariable);
    }

    pPoamIrepFoDdns->EnableFileSync((ANSC_HANDLE)pPoamIrepFoDdns, TRUE);

    return returnStatus;
}
ANSC_STATUS
CosaUsersRegSetUserInfo
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus      = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_USERS           pMyObject         = (PCOSA_DATAMODEL_USERS   )hThisObject;
    
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoUser          = (PPOAM_IREP_FOLDER_OBJECT )pMyObject->hIrepFolderUser;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoEnumUser      = (PPOAM_IREP_FOLDER_OBJECT )NULL;
    PCOSA_CONTEXT_LINK_OBJECT       pCosaUserContext  = NULL;
    PCOSA_DML_USER                  pCosaUser         = NULL;

    PSINGLE_LINK_ENTRY              pSLinkEntry       = (PSINGLE_LINK_ENTRY       )NULL;    
    PSLAP_VARIABLE                  pSlapVariable     = NULL;
    ULONG                           ulEntryCount      = 0;
    ULONG                           ulIndex           = 0;
    ULONG                           uInstanceNumber   = 0;
    char*                           pAliasUser        = NULL;
    char*                           pFolderName       = NULL;
    char                            FolderName[16]    = {0};

    
    if ( !pPoamIrepFoUser )
    {
        return ANSC_STATUS_FAILURE;
    }
    else
    {
        pPoamIrepFoUser->EnableFileSync((ANSC_HANDLE)pPoamIrepFoUser, FALSE);
    }

    if ( TRUE )
    {
        pPoamIrepFoUser->Clear((ANSC_HANDLE)pPoamIrepFoUser);

        SlapAllocVariable(pSlapVariable);

        if ( !pSlapVariable )
        {
            returnStatus = ANSC_STATUS_RESOURCES;

            goto  EXIT1;
        }
    }

    /* This is saved structure for user
        *****************************************
              <User>
                  <NextInstanceNumber> xxx </>
                  <1>
                       <alias>xxx</>
                       <bNew>false</>
                 </1>
                 <2>
                      <alias>xxx</>
                      <bNew>false</>
                </2>
            </User>
      ****************************************************
      */

    /* add client.{i}.maxInstanceNumber  */
    if ( TRUE )
    {
        pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_uint32;
        pSlapVariable->Variant.varUint32 = pMyObject->maxInstanceOfUser;
    
        returnStatus =
            pPoamIrepFoUser->AddRecord
                (
                    (ANSC_HANDLE)pPoamIrepFoUser,
                    COSA_DML_RR_NAME_UserNextInsNunmber,
                    SYS_REP_RECORD_TYPE_UINT,
                    SYS_RECORD_CONTENT_DEFAULT,
                    pSlapVariable,
                    0
                );
    
        SlapCleanVariable(pSlapVariable);
        SlapInitVariable (pSlapVariable);
    }
    
    pSLinkEntry = AnscSListGetFirstEntry(&pMyObject->UserList);

    while ( pSLinkEntry )
    {
        /* create user.{i} */
        
        pCosaUserContext = ACCESS_COSA_CONTEXT_LINK_OBJECT(pSLinkEntry);
        pSLinkEntry       = AnscSListGetNextEntry(pSLinkEntry);

        pCosaUser = (PCOSA_DML_USER)pCosaUserContext->hContext;

        if ( !pCosaUserContext->bNew)
        {
            continue;
        }

        _ansc_sprintf(FolderName, "%d", pCosaUser->InstanceNumber);

        pPoamIrepFoEnumUser =
            pPoamIrepFoUser->AddFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoUser,
                    FolderName,
                    0
                );

        if ( !pPoamIrepFoEnumUser )
        {
            continue;
        }

        /* add  user.{i}.Username */
        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_string;
            pSlapVariable->Variant.varString = AnscCloneString(pCosaUser->Username);

            returnStatus =
                pPoamIrepFoEnumUser->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoEnumUser,
                        COSA_DML_RR_NAME_UserAlias,
                        SYS_REP_RECORD_TYPE_ASTR,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        /* add  user.{i}.bNew */
        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_bool;
            pSlapVariable->Variant.varBool   = pCosaUserContext->bNew;

            returnStatus =
                pPoamIrepFoEnumUser->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoEnumUser,
                        COSA_DML_RR_NAME_UserbNew,
                        SYS_REP_RECORD_TYPE_BOOL,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }
       

        /*release some resource */        
        pPoamIrepFoEnumUser->Remove((ANSC_HANDLE)pPoamIrepFoEnumUser);
        pPoamIrepFoEnumUser = NULL;
    }
        

EXIT1:
    if ( pSlapVariable )
    {
        SlapFreeVariable(pSlapVariable);
        pSlapVariable = NULL;
    }

    if ( pPoamIrepFoEnumUser )
        pPoamIrepFoEnumUser->Remove((ANSC_HANDLE)pPoamIrepFoEnumUser);

    pPoamIrepFoUser->EnableFileSync((ANSC_HANDLE)pPoamIrepFoUser, TRUE);

    return returnStatus;
}
ANSC_STATUS
CosaUsersInitialize
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus      = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_USERS           pMyObject         = (PCOSA_DATAMODEL_USERS)hThisObject;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoCOSA   = NULL;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoUser   = NULL;
 
    /* We need call the initiation function of backend firstly */
    returnStatus = CosaDmlUserInit( NULL, NULL );
    if ( returnStatus != ANSC_STATUS_SUCCESS )
    {
        return returnStatus;
    }

    /* Initiation all functions */
    AnscSListInitializeHeader( &pMyObject->UserList );
    pMyObject->maxInstanceOfUser    = 0;
    pMyObject->hIrepFolderUser      = NULL;
    AnscZeroMemory(pMyObject->AliasOfUser, sizeof(pMyObject->AliasOfUser));

    /*We need to get Instance Info from cosa configuration*/
    pPoamIrepFoCOSA = (PPOAM_IREP_FOLDER_OBJECT)g_GetRegistryRootFolder(g_pDslhDmlAgent);

    if ( !pPoamIrepFoCOSA )
    {
        returnStatus = ANSC_STATUS_FAILURE;

        goto  EXIT;
    }

    pPoamIrepFoUser = 
        (PPOAM_IREP_FOLDER_OBJECT)pPoamIrepFoCOSA->GetFolder
            (
                (ANSC_HANDLE)pPoamIrepFoCOSA,
                COSA_IREP_FOLDER_NAME_USER
            );

    if ( !pPoamIrepFoUser )
    {
        pPoamIrepFoCOSA->EnableFileSync((ANSC_HANDLE)pPoamIrepFoCOSA, FALSE);
    
        pPoamIrepFoUser =
            pPoamIrepFoCOSA->AddFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoCOSA,
                    COSA_IREP_FOLDER_NAME_USER,
                    0
                );

        pPoamIrepFoCOSA->EnableFileSync((ANSC_HANDLE)pPoamIrepFoCOSA, TRUE);

    }

    if ( !pPoamIrepFoUser )
    {
        returnStatus = ANSC_STATUS_FAILURE;

        goto  EXIT;
    }
    else
    {
        pMyObject->hIrepFolderUser = (ANSC_HANDLE)pPoamIrepFoUser;
    }

    /* We need get NextInstanceNumber from backend. By the way, the whole tree 
            was created. Moreover, we also need get delay-added entry and put them
            into our tree. */
    CosaUsersRegGetUserInfo((ANSC_HANDLE)pMyObject);

    /* Firstly we create the whole system from backend */
    CosaUsersBackendGetUserInfo((ANSC_HANDLE)pMyObject);

EXIT:
    
    return returnStatus;

}
Esempio n. 8
0
ANSC_STATUS
CosaRARegAddInfo
    (
        ANSC_HANDLE                 hThisObject,
        char*                       pNextInsNumName,
        ULONG                       ulNextInsNum,
        char*                       pPreffix,
        ULONG                       ulUpperInsNum,
        char*                       pAlias,
        ANSC_HANDLE                 hCosaContext
    )
{
    ANSC_STATUS                     returnStatus      = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_RA              pMyObject         = (PCOSA_DATAMODEL_RA )hThisObject;
    PCOSA_CONTEXT_LINK_OBJECT       pCosaContext      = (PCOSA_CONTEXT_LINK_OBJECT)hCosaContext;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoRAIF   = (PPOAM_IREP_FOLDER_OBJECT )pMyObject->hIrepFolderRAInterface;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoUpper  = (PPOAM_IREP_FOLDER_OBJECT )pCosaContext->hPoamIrepUpperFo;  
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFo       = (PPOAM_IREP_FOLDER_OBJECT )NULL;
    PSLAP_VARIABLE                  pSlapVariable     = (PSLAP_VARIABLE           )NULL;
    char                            FolderName[32]    = {0};

    if ( !pPoamIrepFoRAIF || !pPoamIrepFoUpper )
    {
        return ANSC_STATUS_FAILURE;
    }
    else
    {
        pPoamIrepFoRAIF->EnableFileSync((ANSC_HANDLE)pPoamIrepFoRAIF, FALSE);
    }

    if ( TRUE )
    {
        SlapAllocVariable(pSlapVariable);

        if ( !pSlapVariable )
        {
            returnStatus = ANSC_STATUS_RESOURCES;

            goto  EXIT1;
        }
    }

    _ansc_sprintf(FolderName, "%s%d", pNextInsNumName, (int)ulUpperInsNum);

    if ( TRUE )
    {
        pPoamIrepFo = (PPOAM_IREP_FOLDER_OBJECT)pPoamIrepFoRAIF->GetFolder
                        (
                            (ANSC_HANDLE)pPoamIrepFoRAIF,
                            FolderName
                        );

        if ( !pPoamIrepFo )
        {
            pPoamIrepFo = pPoamIrepFoRAIF->AddFolder
                            (
                                (ANSC_HANDLE)pPoamIrepFoRAIF,
                                FolderName,
                                0
                            );
        }
    }

    if ( TRUE )
    {
        returnStatus = pPoamIrepFo->DelRecord
                        (
                            (ANSC_HANDLE)pPoamIrepFo,
                            pNextInsNumName
                        );

        pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_uint32;
        pSlapVariable->Variant.varUint32 = ulNextInsNum;

        returnStatus = pPoamIrepFo->AddRecord
                        (
                            (ANSC_HANDLE)pPoamIrepFo,
                            pNextInsNumName,
                            SYS_REP_RECORD_TYPE_UINT,
                            SYS_RECORD_CONTENT_DEFAULT,
                            pSlapVariable,
                            0
                        );

        SlapCleanVariable(pSlapVariable);
        SlapInitVariable (pSlapVariable);
    }

    pPoamIrepFo->Remove((ANSC_HANDLE)pPoamIrepFo);
    pPoamIrepFo = NULL;

    if ( TRUE )
    {
        _ansc_sprintf(FolderName, "%s%d%d", pPreffix, (int)ulUpperInsNum, (int)pCosaContext->InstanceNumber);

        pPoamIrepFo = pPoamIrepFoUpper->AddFolder
                        (
                            (ANSC_HANDLE)pPoamIrepFoUpper,
                            FolderName,
                            0
                        );

        if ( !pPoamIrepFo )
        {
            returnStatus = ANSC_STATUS_FAILURE;

            goto  EXIT1;
        }

        if ( 0 != ulUpperInsNum )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_uint32;
            pSlapVariable->Variant.varUint32 = ulUpperInsNum;

            returnStatus = pPoamIrepFo->AddRecord
                            (
                                (ANSC_HANDLE)pPoamIrepFo,
                                COSA_DML_RR_NAME_RAIF_Upper_InsNum,
                                SYS_REP_RECORD_TYPE_UINT,
                                SYS_RECORD_CONTENT_DEFAULT,
                                pSlapVariable,
                                0
                            );
      
            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_uint32;
            pSlapVariable->Variant.varUint32 = pCosaContext->InstanceNumber;

            returnStatus = pPoamIrepFo->AddRecord
                            (
                                (ANSC_HANDLE)pPoamIrepFo,
                                COSA_DML_RR_NAME_RAIF_InsNum,
                                SYS_REP_RECORD_TYPE_UINT,
                                SYS_RECORD_CONTENT_DEFAULT,
                                pSlapVariable,
                                0
                            );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_string;
            pSlapVariable->Variant.varString = AnscCloneString(pAlias);

            returnStatus = pPoamIrepFo->AddRecord
                            (
                                (ANSC_HANDLE)pPoamIrepFo,
                                COSA_DML_RR_NAME_RAIF_Alias,
                                SYS_REP_RECORD_TYPE_ASTR,
                                SYS_RECORD_CONTENT_DEFAULT,
                                pSlapVariable,
                                0
                            );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        pCosaContext->hPoamIrepFo = (ANSC_HANDLE)pPoamIrepFo;
    }

EXIT1:
    
    if ( pSlapVariable )
    {
        SlapFreeVariable(pSlapVariable);
    }

    pPoamIrepFoRAIF->EnableFileSync((ANSC_HANDLE)pPoamIrepFoRAIF, TRUE);

    return returnStatus;
}
ANSC_STATUS
CosaTSIPSubnetRegAddInfo
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hCosaContext
    )
{
    ANSC_STATUS                     returnStatus            = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_TSIP            pMyObject               = (PCOSA_DATAMODEL_TSIP     )hThisObject;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoTSIPSubnet   = (PPOAM_IREP_FOLDER_OBJECT )pMyObject->hIrepFolderTSIPSubnet;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoTSIPSubnetSp = (PPOAM_IREP_FOLDER_OBJECT )NULL;
    PCOSA_CONTEXT_LINK_OBJECT       pCosaContext            = (PCOSA_CONTEXT_LINK_OBJECT)hCosaContext;
    PCOSA_DML_TSIP_SUBNET_ENTRY     pEntry                  = (PCOSA_DML_TSIP_SUBNET_ENTRY)pCosaContext->hContext;
    PSLAP_VARIABLE                  pSlapVariable           = (PSLAP_VARIABLE           )NULL;

    if ( !pPoamIrepFoTSIPSubnet )
    {
        return ANSC_STATUS_FAILURE;
    }
    else
    {
        pPoamIrepFoTSIPSubnet->EnableFileSync((ANSC_HANDLE)pPoamIrepFoTSIPSubnet, FALSE);
    }

    if ( TRUE )
    {
        SlapAllocVariable(pSlapVariable);

        if ( !pSlapVariable )
        {
            returnStatus = ANSC_STATUS_RESOURCES;

            goto  EXIT1;
        }
    }

    if ( TRUE )
    {
        returnStatus = 
            pPoamIrepFoTSIPSubnet->DelRecord
                (
                    (ANSC_HANDLE)pPoamIrepFoTSIPSubnet,
                    COSA_DML_RR_NAME_TSIP_SUBNETNextInsNunmber
                );

        pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_uint32;
        pSlapVariable->Variant.varUint32 = pMyObject->ulSubnetNextInsNum;

        returnStatus =
            pPoamIrepFoTSIPSubnet->AddRecord
                (
                    (ANSC_HANDLE)pPoamIrepFoTSIPSubnet,
                    COSA_DML_RR_NAME_TSIP_SUBNETNextInsNunmber,
                    SYS_REP_RECORD_TYPE_UINT,
                    SYS_RECORD_CONTENT_DEFAULT,
                    pSlapVariable,
                    0
                );

        SlapCleanVariable(pSlapVariable);
        SlapInitVariable (pSlapVariable);
    }

    if ( TRUE )
    {
        pPoamIrepFoTSIPSubnetSp =
            pPoamIrepFoTSIPSubnet->AddFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoTSIPSubnet,
                    pEntry->Alias,
                    0
                );

        if ( !pPoamIrepFoTSIPSubnetSp )
        {
            returnStatus = ANSC_STATUS_FAILURE;

            goto  EXIT1;
        }

        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_uint32;
            pSlapVariable->Variant.varUint32 = pEntry->InstanceNumber;

            returnStatus =
                pPoamIrepFoTSIPSubnetSp->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoTSIPSubnetSp,
                        COSA_DML_RR_NAME_TSIP_SUBNETInsNum,
                        SYS_REP_RECORD_TYPE_UINT,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        if ( TRUE )
        {
            pSlapVariable->Syntax            = SLAP_VAR_SYNTAX_string;
            pSlapVariable->Variant.varString = AnscCloneString(pEntry->Alias);

            returnStatus =
                pPoamIrepFoTSIPSubnetSp->AddRecord
                    (
                        (ANSC_HANDLE)pPoamIrepFoTSIPSubnetSp,
                        COSA_DML_RR_NAME_TSIP_SUBNETAlias,
                        SYS_REP_RECORD_TYPE_ASTR,
                        SYS_RECORD_CONTENT_DEFAULT,
                        pSlapVariable,
                        0
                    );

            SlapCleanVariable(pSlapVariable);
            SlapInitVariable (pSlapVariable);
        }

        pCosaContext->hPoamIrepUpperFo = (ANSC_HANDLE)pPoamIrepFoTSIPSubnet;
        pCosaContext->hPoamIrepFo      = (ANSC_HANDLE)pPoamIrepFoTSIPSubnetSp;
    }

EXIT1:
    
    if ( pSlapVariable )
    {
        SlapFreeVariable(pSlapVariable);
    }

    pPoamIrepFoTSIPSubnet->EnableFileSync((ANSC_HANDLE)pPoamIrepFoTSIPSubnet, TRUE);

    return returnStatus;
}
ANSC_STATUS
CosaBridgingRegGetInfo
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus            = ANSC_STATUS_SUCCESS;
    PCOSA_DATAMODEL_BRIDGING        pMyObject               = (PCOSA_DATAMODEL_BRIDGING    )hThisObject;
    PSLIST_HEADER                   pBridgeHead             = (PSLIST_HEADER               )&pMyObject->BridgeList;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoBRGHA        = (PPOAM_IREP_FOLDER_OBJECT    )pMyObject->hIrepFolderBRGHA;
    PPOAM_IREP_FOLDER_OBJECT        pPoamIrepFoBRGBrg       = (PPOAM_IREP_FOLDER_OBJECT    )NULL;
    PCOSA_CONTEXT_LINK_OBJECT       pCosaContext            = (PCOSA_CONTEXT_LINK_OBJECT   )NULL;
    PCOSA_CONTEXT_LINK_OBJECT       pCosaContext2           = (PCOSA_CONTEXT_LINK_OBJECT   )NULL;
    PCOSA_DML_BRG_FULL_ALL          pDmlBridge              = (PCOSA_DML_BRG_FULL_ALL      )NULL;
    PCOSA_DML_BRG_FULL_ALL          pDmlBrgEntry            = (PCOSA_DML_BRG_FULL_ALL      )NULL;
    PCOSA_DML_BRG_PORT_FULL         pPort                   = (PCOSA_DML_BRG_PORT_FULL     )NULL;
    PSLAP_VARIABLE                  pSlapVariable           = (PSLAP_VARIABLE              )NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry             = (PSINGLE_LINK_ENTRY          )NULL;
    ULONG                           ulEntryCount            = 0;
    ULONG                           ulIndex                 = 0;
    ULONG                           ulInstanceNumber        = 0;
    ULONG                           ulUpperInstanceNumber   = 0;
    char*                           pFolderName             = NULL;
    char*                           pBridgeName             = NULL;
    char*                           pAlias                  = NULL;
    BOOLEAN                         found = FALSE;
    if ( !pPoamIrepFoBRGHA )
    {
        return ANSC_STATUS_FAILURE;
    }

    /* Load the newly added but not yet commited entries */

    ulEntryCount = pPoamIrepFoBRGHA->GetFolderCount((ANSC_HANDLE)pPoamIrepFoBRGHA);

    for ( ulIndex = 0; ulIndex < ulEntryCount; ulIndex++ )
    {
        pFolderName =
            pPoamIrepFoBRGHA->EnumFolder
                (
                    (ANSC_HANDLE)pPoamIrepFoBRGHA,
                    ulIndex
                );

        if ( !pFolderName )
        {
            continue;
        }

        pPoamIrepFoBRGBrg = pPoamIrepFoBRGHA->GetFolder((ANSC_HANDLE)pPoamIrepFoBRGHA, pFolderName);

        if ( !pPoamIrepFoBRGBrg )
        {
            continue;
        }


        if ( _ansc_strstr(pFolderName, "Bridge") )
        {
            if ( TRUE )
            {
                pSlapVariable =
                    (PSLAP_VARIABLE)pPoamIrepFoBRGBrg->GetRecord
                        (
                            (ANSC_HANDLE)pPoamIrepFoBRGBrg,
                            COSA_DML_RR_NAME_Bridge_InsNum,
                            NULL
                        );

                if ( pSlapVariable )
                {
                    ulInstanceNumber = pSlapVariable->Variant.varUint32;
                    SlapFreeVariable(pSlapVariable);
                }
            }

            if ( TRUE )
            {
                pSlapVariable =
                    (PSLAP_VARIABLE)pPoamIrepFoBRGBrg->GetRecord
                        (
                            (ANSC_HANDLE)pPoamIrepFoBRGBrg,
                            COSA_DML_RR_NAME_Bridge_Alias,
                            NULL
                        );

                if ( pSlapVariable )
                {
                    pAlias = AnscCloneString(pSlapVariable->Variant.varString);
                    SlapFreeVariable(pSlapVariable);
                }
            }

            pCosaContext = (PCOSA_CONTEXT_LINK_OBJECT)AnscAllocateMemory(sizeof(COSA_CONTEXT_LINK_OBJECT));

            if ( !pCosaContext )
            {
                returnStatus = ANSC_STATUS_RESOURCES;

                goto EXIT;
            }

            pDmlBridge = (PCOSA_DML_BRG_FULL_ALL)AnscAllocateMemory(sizeof(COSA_DML_BRG_FULL_ALL));

            if ( !pDmlBridge )
            {
                AnscFreeMemory(pCosaContext);

                returnStatus = ANSC_STATUS_RESOURCES;

                goto EXIT;
            }

            AnscSListInitializeHeader(&pDmlBridge->PortList   );
            AnscSListInitializeHeader(&pDmlBridge->VLANList   );
            AnscSListInitializeHeader(&pDmlBridge->VLANPortList);

            pDmlBridge->ulNextPortInsNum = 1;
            pDmlBridge->ulNextVLANInsNum = 1;
            pDmlBridge->ulNextVLANPortInsNum = 1;
            pDmlBridge->Cfg.bAllowDelete = TRUE;
            pDmlBridge->Cfg.InstanceNumber = ulInstanceNumber;
            AnscCopyString(pDmlBridge->Cfg.Alias, pAlias);

            pCosaContext->InstanceNumber   = ulInstanceNumber;
            pCosaContext->bNew             = TRUE;
            pCosaContext->hContext         = (ANSC_HANDLE)pDmlBridge;
            pCosaContext->hParentTable     = NULL;
            pCosaContext->hPoamIrepUpperFo = (ANSC_HANDLE)pPoamIrepFoBRGHA;
            pCosaContext->hPoamIrepFo      = (ANSC_HANDLE)pPoamIrepFoBRGBrg;
            
            CosaSListPushEntryByInsNum(pBridgeHead, pCosaContext);            
        }
        else
        {
            found = FALSE;
            if ( TRUE )
            {
                pSlapVariable =
                    (PSLAP_VARIABLE)pPoamIrepFoBRGBrg->GetRecord
                        (
                            (ANSC_HANDLE)pPoamIrepFoBRGBrg,
                            COSA_DML_RR_NAME_Bridge_Upper_InsNum,
                            NULL
                        );

                if ( pSlapVariable )
                {
                    ulUpperInstanceNumber = pSlapVariable->Variant.varUint32;
                    SlapFreeVariable(pSlapVariable);
                }

                if ( ulUpperInstanceNumber != 0 )
                {
                    pSLinkEntry = AnscSListGetFirstEntry(pBridgeHead);

                    while ( pSLinkEntry )
                    {
                        pCosaContext  = ACCESS_COSA_CONTEXT_LINK_OBJECT(pSLinkEntry);
                        pSLinkEntry   = AnscSListGetNextEntry(pSLinkEntry);

                        pDmlBrgEntry  = (PCOSA_DML_BRG_FULL_ALL)pCosaContext->hContext;

                        if ( pDmlBrgEntry && (pDmlBrgEntry->Cfg.InstanceNumber == ulUpperInstanceNumber) )
                        {
                            found = TRUE;
                            break;
                        }
                    }
                }
                else
                {
                    return ANSC_STATUS_FAILURE;
                }
            }

            if (found==FALSE)
            {
                //$HL 4/29/2013
                pPoamIrepFoBRGHA->EnableFileSync((ANSC_HANDLE)pPoamIrepFoBRGHA, FALSE);
                pPoamIrepFoBRGBrg->Close((ANSC_HANDLE)pPoamIrepFoBRGBrg);
        
                pPoamIrepFoBRGHA->DelFolder
                    (
                        (ANSC_HANDLE)pPoamIrepFoBRGHA, 
                        pPoamIrepFoBRGBrg->GetFolderName((ANSC_HANDLE)pPoamIrepFoBRGBrg)
                    );

                pPoamIrepFoBRGHA->EnableFileSync((ANSC_HANDLE)pPoamIrepFoBRGHA, TRUE);

                AnscFreeMemory(pPoamIrepFoBRGBrg);
                continue;
            }
            if ( TRUE )
            {
                pSlapVariable =
                    (PSLAP_VARIABLE)pPoamIrepFoBRGBrg->GetRecord
                        (
                            (ANSC_HANDLE)pPoamIrepFoBRGBrg,
                            COSA_DML_RR_NAME_Bridge_InsNum,
                            NULL
                        );

                if ( pSlapVariable )
                {
                    ulInstanceNumber = pSlapVariable->Variant.varUint32;
                    SlapFreeVariable(pSlapVariable);
                }
            }

            if ( TRUE )
            {
                pSlapVariable =
                    (PSLAP_VARIABLE)pPoamIrepFoBRGBrg->GetRecord
                        (
                            (ANSC_HANDLE)pPoamIrepFoBRGBrg,
                            COSA_DML_RR_NAME_Bridge_Alias,
                            NULL
                        );

                if ( pSlapVariable )
                {
                    pAlias = AnscCloneString(pSlapVariable->Variant.varString);
                    SlapFreeVariable(pSlapVariable);
                }
            }

            if ( _ansc_strstr(pFolderName, "Port") )
            {
                pPort = (PCOSA_DML_BRG_PORT_FULL)AnscAllocateMemory(sizeof(COSA_DML_BRG_PORT_FULL));

                if ( !pPort )
                {
                    returnStatus = ANSC_STATUS_RESOURCES;

                    goto EXIT;
                }

                pCosaContext2 = (PCOSA_CONTEXT_LINK_OBJECT)AnscAllocateMemory(sizeof(COSA_CONTEXT_LINK_OBJECT));

                if ( !pCosaContext2 )
                {
                    AnscFreeMemory(pPort);
            
                    returnStatus = ANSC_STATUS_RESOURCES;

                    goto EXIT;
                }

                pPort->Cfg.InstanceNumber = ulInstanceNumber;
                AnscCopyString(pPort->Cfg.Alias, pAlias);
                pPort->Cfg.bAllowDelete = TRUE;
                pCosaContext2->InstanceNumber  = ulInstanceNumber;
                pCosaContext2->hContext        = (ANSC_HANDLE)pPort;
                pCosaContext2->hParentTable    = (ANSC_HANDLE)pDmlBrgEntry;
                pCosaContext2->bNew            = TRUE;
                pCosaContext2->hPoamIrepUpperFo = (ANSC_HANDLE)pPoamIrepFoBRGHA;
                pCosaContext2->hPoamIrepFo      = (ANSC_HANDLE)pPoamIrepFoBRGBrg;

                //$HL 5/1/2013
                pDmlBrgEntry->ulNextPortInsNum = ulInstanceNumber >=pDmlBrgEntry->ulNextPortInsNum ? 
                    ulInstanceNumber+1:pDmlBrgEntry->ulNextPortInsNum;
                CosaSListPushEntryByInsNum(&pDmlBrgEntry->PortList, pCosaContext2);
            }
        }
    }

EXIT:

    AnscFreeMemory(pAlias);

    return returnStatus;
}