ANSC_STATUS HttpWcsoSetPeerName ( ANSC_HANDLE hThisObject, char* name ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PHTTP_WEBC_SESSION_OBJECT pMyObject = (PHTTP_WEBC_SESSION_OBJECT )hThisObject; PANSC_SIMPLE_CLIENT_TCP_OBJECT pScto = (PANSC_SIMPLE_CLIENT_TCP_OBJECT)pMyObject->hTcpSimpleClient; PHTTP_WEBC_SESSION_PROPERTY pProperty = (PHTTP_WEBC_SESSION_PROPERTY)&pMyObject->Property; AnscZeroMemory(pProperty->PeerName, ANSC_DOMAIN_NAME_SIZE); AnscCopyString(pProperty->PeerName, name ); _ansc_strncpy(pScto->HostName, name, WEB_MAX_HOST_NAME_SIZE); pScto->HostName[WEB_MAX_HOST_NAME_SIZE] = 0; return ANSC_STATUS_SUCCESS; }
ANSC_STATUS CcspCwmpStunmoRegGetStunInfo ( ANSC_HANDLE hThisObject ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PCCSP_CWMP_STUN_MANAGER_OBJECT pMyObject = (PCCSP_CWMP_STUN_MANAGER_OBJECT )hThisObject; PCCSP_CWMP_CPE_CONTROLLER_OBJECT pCcspCwmpCpeController = (PCCSP_CWMP_CPE_CONTROLLER_OBJECT)pMyObject->hCcspCwmpCpeController; PCCSP_CWMP_STUN_INFO pCcspCwmpStunInfo = (PCCSP_CWMP_STUN_INFO )&pMyObject->CcspCwmpStunInfo; CCSP_STRING pValue; /* retrieve STUN settings from MS FC */ pCcspCwmpStunInfo->UDPConnectionRequestAddressNotificationLimit = 0; pCcspCwmpStunInfo->STUNEnable = CcspManagementServer_GetSTUNEnable ( pCcspCwmpCpeController->PANameWithPrefix ); pValue = CcspManagementServer_GetSTUNServerAddress ( pCcspCwmpCpeController->PANameWithPrefix ); AnscZeroMemory(pCcspCwmpStunInfo->STUNServerAddress, 257); if ( pValue ) { _ansc_strncpy(pCcspCwmpStunInfo->STUNServerAddress, pValue, 256); CcspTr069PaFreeMemory(pValue); } pCcspCwmpStunInfo->STUNServerPort = (USHORT)CcspManagementServer_GetSTUNServerPort ( pCcspCwmpCpeController->PANameWithPrefix ); pValue = CcspManagementServer_GetSTUNUsername ( pCcspCwmpCpeController->PANameWithPrefix ); AnscZeroMemory(pCcspCwmpStunInfo->STUNUsername, 257); if ( pValue ) { _ansc_strncpy(pCcspCwmpStunInfo->STUNUsername, pValue, 256); CcspTr069PaFreeMemory(pValue); } pValue = CcspManagementServer_GetSTUNPassword ( pCcspCwmpCpeController->PANameWithPrefix ); AnscZeroMemory(pCcspCwmpStunInfo->STUNPassword, 257); if ( pValue ) { _ansc_strncpy(pCcspCwmpStunInfo->STUNPassword, pValue, 256); CcspTr069PaFreeMemory(pValue); } pCcspCwmpStunInfo->STUNMaximumKeepAlivePeriod = CcspManagementServer_GetSTUNMaximumKeepAlivePeriod ( pCcspCwmpCpeController->PANameWithPrefix ); pCcspCwmpStunInfo->STUNMinimumKeepAlivePeriod = CcspManagementServer_GetSTUNMinimumKeepAlivePeriod ( pCcspCwmpCpeController->PANameWithPrefix ); pCcspCwmpStunInfo->NATDetected = CcspManagementServer_GetNATDetected ( pCcspCwmpCpeController->PANameWithPrefix ); return returnStatus; }
ANSC_STATUS CosaUsersBackendGetUserInfo ( ANSC_HANDLE hThisObject ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PCOSA_DATAMODEL_USERS pMyObject = (PCOSA_DATAMODEL_USERS)hThisObject; PCOSA_DML_USER pCosaUser = NULL; ULONG clientCount = 0; ULONG count = 0; ULONG ulIndex = 0; PCOSA_CONTEXT_LINK_OBJECT pUserCxtLink = NULL; PCOSA_CONTEXT_LINK_OBJECT pUserCxtLink2 = NULL; PCOSA_CONTEXT_LINK_OBJECT pCxtLink = NULL; BOOL bNeedSave = FALSE; /* Get Users.user.{i} */ clientCount = CosaDmlUserGetNumberOfEntries(NULL); for ( ulIndex = 0; ulIndex < clientCount; ulIndex++ ) { pCosaUser = (PCOSA_DML_USER)AnscAllocateMemory( sizeof(COSA_DML_USER) ); if ( !pCosaUser ) { break; } USERS_USER_SET_DEFAULTVALUE(pCosaUser); pCosaUser->NumOfFailedAttempts=0; returnStatus = CosaDmlUserGetEntry(NULL, ulIndex, pCosaUser); if ( returnStatus != ANSC_STATUS_SUCCESS ) { AnscFreeMemory(pCosaUser); break; } if (ulIndex == 2) { char buff[128]={'\0'}; syscfg_get( NULL, "hash_password_3",buff, sizeof(buff)); if( buff[0] != '\0' && pCosaUser->HashedPassword[0]== '\0') { _ansc_strncpy(pCosaUser->HashedPassword,buff,sizeof(pCosaUser->HashedPassword)); } } #if defined(_COSA_FOR_BCI_) if (ulIndex == 1) { char buff[128]={'\0'}; syscfg_get( NULL, "hash_password_2",buff, sizeof(buff)); if( buff[0] != '\0' && pCosaUser->HashedPassword[0]== '\0') { _ansc_strncpy(pCosaUser->HashedPassword,buff,sizeof(pCosaUser->HashedPassword)); } pCosaUser->LockOutRemainingTime = 0 ; memset(buff,0,sizeof(buff)); syscfg_get( NULL, "PasswordLockoutAttempts", buff, sizeof(buff)); if( atoi ( buff ) != 10 ) { memset(buff,0,sizeof(buff)); sprintf(buff, "%d", 10); syscfg_set(NULL, "PasswordLockoutAttempts", buff) ; syscfg_commit() ; } memset(buff,0,sizeof(buff)); syscfg_get( NULL, "NumOfFailedAttempts_2", buff, sizeof(buff)); if( buff[0] != '\0' ) { pCosaUser->NumOfFailedAttempts = atoi(buff) ; } memset(buff,0,sizeof(buff)); syscfg_get( NULL, "PasswordLoginCounts_2", buff, sizeof(buff)); if( buff[0] != '\0' ) { pCosaUser->LoginCounts = atoi(buff) ; } } #endif pUserCxtLink = (PCOSA_CONTEXT_LINK_OBJECT)AnscAllocateMemory( sizeof(COSA_CONTEXT_LINK_OBJECT) ); if ( !pUserCxtLink ) { AnscFreeMemory(pCosaUser); break; } COSA_CONTEXT_LINK_INITIATION_CONTENT(pUserCxtLink) pUserCxtLink->hContext = (ANSC_HANDLE)pCosaUser; pUserCxtLink->bNew = FALSE; if ( !pCosaUser->InstanceNumber ) { if ( !++pMyObject->maxInstanceOfUser ) { pMyObject->maxInstanceOfUser = 1; } bNeedSave = TRUE; pCosaUser->InstanceNumber = pMyObject->maxInstanceOfUser; pUserCxtLink->InstanceNumber = pCosaUser->InstanceNumber; _ansc_sprintf(pCosaUser->Username, "Username%d", pCosaUser->InstanceNumber); returnStatus = CosaDmlUserSetValues ( NULL, ulIndex, pCosaUser->InstanceNumber ); if ( returnStatus != ANSC_STATUS_SUCCESS ) { AnscFreeMemory(pCosaUser); AnscFreeMemory(pUserCxtLink); break; } /* Put into our list */ CosaSListPushEntryByInsNum(&pMyObject->UserList, pUserCxtLink); } else { pUserCxtLink->InstanceNumber = pCosaUser->InstanceNumber; if ( pMyObject->maxInstanceOfUser < pUserCxtLink->InstanceNumber ) { pMyObject->maxInstanceOfUser = pUserCxtLink->InstanceNumber; bNeedSave = TRUE; } /* if this entry is in link tree already because it's the parent of delay_added table. */ pUserCxtLink2 = (PCOSA_CONTEXT_LINK_OBJECT)CosaSListGetEntryByInsNum(&pMyObject->UserList, pUserCxtLink->InstanceNumber); if ( !pUserCxtLink2 ) { CosaSListPushEntryByInsNum(&pMyObject->UserList, pUserCxtLink); } else { AnscFreeMemory( pUserCxtLink2->hContext ); pUserCxtLink2->hContext = (ANSC_HANDLE)pCosaUser; if ( pUserCxtLink2->bNew ) { pUserCxtLink2->bNew = FALSE; bNeedSave = TRUE; } AnscFreeMemory(pUserCxtLink); pUserCxtLink = pUserCxtLink2; pUserCxtLink2 = NULL; } } } /* Max InstanceNumber is changed. Save now.*/ if (bNeedSave) { CosaUsersRegSetUserInfo(pMyObject); } return returnStatus; }
ULONG Pam_GetParamStringValue ( ANSC_HANDLE hInsContext, char* ParamName, char* pValue, ULONG* pulSize ) { int iReturnValue = 0; PCOSA_CONTEXT_LINK_OBJECT pCosaContext = (PCOSA_CONTEXT_LINK_OBJECT)hInsContext; char IpIfObjName[128] = {0}; ULONG IpIfObjNameSize = 0; ULONG ulInstNum = 0; char Buffer[128] = {0}; ULONG BufferSize = 0; CcspTraceInfo(("[%s] -- '%s', pValue addr: 0x%x, pulSize addr: 0x%x \n", __FUNCTION__, ParamName, pValue, pulSize)); IpIfObjNameSize = sizeof(IpIfObjName) - 1; /* check the parameter name and return the corresponding value */ if( AnscEqualString(ParamName, "FirstUpstreamIpInterface", TRUE)) { /* We hardcode the value here temporarily. In the future, if LowerLayers mechanism works well, we can change back*/ /* AnscCopyString(pValue, "Device.IP.Interface.1."); *pulSize = _ansc_strlen("Device.IP.Interface.1."); return 0; */ if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(TRUE, IpIfObjName, &IpIfObjNameSize) ) { if ( IpIfObjNameSize < *pulSize ) { AnscCopyString(pValue, IpIfObjName); *pulSize = IpIfObjNameSize; return 0; } else { *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } else if( AnscEqualString(ParamName, "FirstDownstreamIpInterface", TRUE)) { /* We hardcode the value here temporarily. In the future, if LowerLayers mechanism works well, we can change back*/ /* AnscCopyString(pValue, "Device.IP.Interface.4."); *pulSize = _ansc_strlen("Device.IP.Interface.4."); return 0; */ // CcspTraceInfo(("Pam_GetParamStringValue -- FirstDownstreamIpInterface case\n")); if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(FALSE, IpIfObjName, &IpIfObjNameSize) ) { // CcspTraceInfo(("Pam_GetParamStringValue -- '%s' Pam_GetFirstIpInterfaceObjectName ret success\n", ParamName)); CcspTraceInfo(("[%s] -- '%s' IpIfObjNameSize: %d, pulSize: %d\n", __FUNCTION__, ParamName, IpIfObjNameSize, *pulSize)); if ( IpIfObjNameSize < *pulSize ) { AnscCopyString(pValue, IpIfObjName); CcspTraceInfo(("[%s] -- pValue: %s\n", __FUNCTION__, pValue)); *pulSize = IpIfObjNameSize; return 0; } else { *pulSize = IpIfObjNameSize; return 1; } } else { CcspTraceInfo(("[%s] -- '%s' Pam_GetFirstIpInterfaceObjectName ret failed\n", __FUNCTION__, ParamName)); return -1; } } else if( AnscEqualString(ParamName, "FirstUpstreamIpv4Address", TRUE)) { if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(TRUE, IpIfObjName, &IpIfObjNameSize) ) { _ansc_strcat(IpIfObjName, "IPv4Address."); ulInstNum = CosaGetInstanceNumberByIndex(IpIfObjName, 0); if ( ulInstNum == 0 ) { return -1; } else { _ansc_sprintf(Buffer, "%d.", ulInstNum); _ansc_strcat(IpIfObjName, Buffer); _ansc_strcat(IpIfObjName, "IPAddress"); } BufferSize = sizeof(Buffer); iReturnValue = CosaGetParamValueString(IpIfObjName, Buffer, &BufferSize); if ( iReturnValue != 0 ) { CcspTraceWarning(("Pam_GetParamStringValue -- failed to retrieve IP address, error code %d!\n", iReturnValue)); return -1; } if ( BufferSize < *pulSize ) { AnscCopyString(pValue, Buffer); *pulSize = IpIfObjNameSize; return 0; } else { _ansc_strncpy(pValue, Buffer, *pulSize); *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } else if( AnscEqualString(ParamName, "FirstUpstreamIpv4SubnetMask", TRUE)) { if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(TRUE, IpIfObjName, &IpIfObjNameSize) ) { _ansc_strcat(IpIfObjName, "IPv4Address."); ulInstNum = CosaGetInstanceNumberByIndex(IpIfObjName, 0); if ( ulInstNum == 0 ) { return -1; } else { _ansc_sprintf(Buffer, "%d.", ulInstNum); _ansc_strcat(IpIfObjName, Buffer); _ansc_strcat(IpIfObjName, "SubnetMask"); } BufferSize = sizeof(Buffer); iReturnValue = CosaGetParamValueString(IpIfObjName, Buffer, &BufferSize); if ( iReturnValue != 0 ) { CcspTraceWarning(("Pam_GetParamStringValue -- failed to retrieve subnet mask, error code %d!\n", iReturnValue)); return -1; } if ( BufferSize < *pulSize ) { AnscCopyString(pValue, Buffer); *pulSize = IpIfObjNameSize; return 0; } else { _ansc_strncpy(pValue, Buffer, *pulSize); *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } else if( AnscEqualString(ParamName, "FirstDownstreamIpv4Address", TRUE)) { if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(FALSE, IpIfObjName, &IpIfObjNameSize) ) { _ansc_strcat(IpIfObjName, "IPv4Address."); ulInstNum = CosaGetInstanceNumberByIndex(IpIfObjName, 0); if ( ulInstNum == 0 ) { return -1; } else { _ansc_sprintf(Buffer, "%d.", ulInstNum); _ansc_strcat(IpIfObjName, Buffer); _ansc_strcat(IpIfObjName, "IPAddress"); } BufferSize = sizeof(Buffer); iReturnValue = CosaGetParamValueString(IpIfObjName, Buffer, &BufferSize); if ( iReturnValue != 0 ) { CcspTraceWarning(("Pam_GetParamStringValue -- failed to retrieve IP address, error code %d!\n", iReturnValue)); return -1; } if ( BufferSize < *pulSize ) { AnscCopyString(pValue, Buffer); *pulSize = IpIfObjNameSize; return 0; } else { _ansc_strncpy(pValue, Buffer, *pulSize); *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } else if( AnscEqualString(ParamName, "FirstDownstreamIpv4SubnetMask", TRUE)) { if ( ANSC_STATUS_SUCCESS == Pam_GetFirstIpInterfaceObjectName(FALSE, IpIfObjName, &IpIfObjNameSize) ) { _ansc_strcat(IpIfObjName, "IPv4Address."); ulInstNum = CosaGetInstanceNumberByIndex(IpIfObjName, 0); if ( ulInstNum == 0 ) { return -1; } else { _ansc_sprintf(Buffer, "%d.", ulInstNum); _ansc_strcat(IpIfObjName, Buffer); _ansc_strcat(IpIfObjName, "SubnetMask"); } BufferSize = sizeof(Buffer); iReturnValue = CosaGetParamValueString(IpIfObjName, Buffer, &BufferSize); if ( iReturnValue != 0 ) { CcspTraceWarning(("Pam_GetParamStringValue -- failed to retrieve subnet mask, error code %d!\n", iReturnValue)); return -1; } if ( BufferSize < *pulSize ) { AnscCopyString(pValue, Buffer); *pulSize = IpIfObjNameSize; return 0; } else { _ansc_strncpy(pValue, Buffer, *pulSize); *pulSize = IpIfObjNameSize; return 1; } } else { return -1; } } /* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */ return -1; }