ANSC_STATUS AnscLpccoTcpSendHello ( ANSC_HANDLE hThisObject, ANSC_HANDLE hSocket ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PANSC_LPCCO_TCP_OBJECT pMyObject = (PANSC_LPCCO_TCP_OBJECT )hThisObject; PANSC_DAEMON_SERVER_TCP_OBJECT pDaemonServer = (PANSC_DAEMON_SERVER_TCP_OBJECT)pMyObject->hDaemonServer; PANSC_BROKER_SERVER_TCP_OBJECT pBrokerServer = (PANSC_BROKER_SERVER_TCP_OBJECT)pMyObject->hBrokerServer; PANSC_BROKER_SOCKET_TCP_OBJECT pBrokerSocket = (PANSC_BROKER_SOCKET_TCP_OBJECT)hSocket; PIMCP_HEADER pImcpHeader = (PIMCP_HEADER )NULL; PIMCP_HELLO_MESSAGE pImcpHelloMessage = (PIMCP_HELLO_MESSAGE )NULL; ULONG ulImcpMsgSize = (ULONG )0; if ( TRUE ) { ulImcpMsgSize = sizeof(IMCP_HEADER) + sizeof(IMCP_HELLO_MESSAGE) + AnscSizeOfString(pMyObject->PartyName); pImcpHeader = (PIMCP_HEADER)AnscAllocateMemory(ulImcpMsgSize); if ( !pImcpHeader ) { return ANSC_STATUS_RESOURCES; } else { ImcpSetMsgType (pImcpHeader, IMCP_MESSAGE_TYPE_HELLO ); ImcpSetMsgLength(pImcpHeader, ulImcpMsgSize - sizeof(IMCP_HEADER)); pImcpHelloMessage = (PIMCP_HELLO_MESSAGE)ImcpGetMsgData(pImcpHeader); } ImcpHelloSetPartyAddrValue(pImcpHelloMessage, pMyObject->MyAddress.Value); ImcpHelloSetPartyPort (pImcpHelloMessage, pMyObject->MyPort ); ImcpHelloSetPartyName (pImcpHelloMessage, pMyObject->PartyName ); } returnStatus = pBrokerSocket->Send ( (ANSC_HANDLE)pBrokerSocket, pImcpHeader, ulImcpMsgSize, (ANSC_HANDLE)NULL ); AnscFreeMemory(pImcpHeader); return returnStatus; }
ANSC_STATUS HttpSpoPrvwoProcessSync ( ANSC_HANDLE hThisObject, ANSC_HANDLE hSocket, PVOID buffer, ULONG ulSize, ANSC_HANDLE hQueryContext ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PHTTP_SIMPLE_PROXY_OBJECT pMyObject = (PHTTP_SIMPLE_PROXY_OBJECT )hThisObject; PHTTP_SIMPLE_PROXY_PROPERTY pProperty = (PHTTP_SIMPLE_PROXY_PROPERTY )&pMyObject->Property; PANSC_SIMPLE_PROXY_TCP_OBJECT pSimpleProxy = (PANSC_SIMPLE_PROXY_TCP_OBJECT )pMyObject->hSimpleProxy; PHTTP_SBC_INTERFACE pSbcIf = (PHTTP_SBC_INTERFACE )pMyObject->hSbcIf; PANSC_DAEMON_SOCKET_TCP_OBJECT pClientSocket = (PANSC_DAEMON_SOCKET_TCP_OBJECT)hSocket; PANSC_BROKER_SOCKET_TCP_OBJECT pServerSocket = (PANSC_BROKER_SOCKET_TCP_OBJECT)NULL; PANSC_BUFFER_DESCRIPTOR pBufferDesp = (PANSC_BUFFER_DESCRIPTOR )pClientSocket->GetBufferContext((ANSC_HANDLE)pClientSocket); PHTTP_PROXY_SESSION_OBJECT pSession = NULL; ULONG ulPsoQmode = (ULONG)hQueryContext; BOOL bFinishSocket = FALSE; AnscAcquireLock(&pMyObject->SyncLock); pSession = (PHTTP_PROXY_SESSION_OBJECT)pClientSocket->GetClientContext((ANSC_HANDLE)pClientSocket); if ( !pSession ) { AnscReleaseLock(&pMyObject->SyncLock); pClientSocket->Finish((ANSC_HANDLE)pClientSocket); return ANSC_STATUS_SUCCESS; } else { pSession->AcquireAccess((ANSC_HANDLE)pSession); } AnscReleaseLock(&pMyObject->SyncLock); switch ( ulPsoQmode ) { case HTTP_PSO_QMODE_FORWARD : pServerSocket = (PANSC_BROKER_SOCKET_TCP_OBJECT)pSession->GetServerSocket((ANSC_HANDLE)pSession); if ( !pServerSocket) { bFinishSocket = TRUE; returnStatus = ANSC_STATUS_INTERNAL_ERROR; break; } else { returnStatus = pServerSocket->Send ( (ANSC_HANDLE)pServerSocket, buffer, ulSize, (ANSC_HANDLE)NULL ); } pBufferDesp->BlockSize = 0; break; case HTTP_PSO_QMODE_PROCESS : pClientSocket->SetBufferContext ( (ANSC_HANDLE)pClientSocket, NULL, 0, (ANSC_HANDLE)NULL ); returnStatus = pSession->RecvFromClient ( (ANSC_HANDLE)pSession, buffer, ulSize, (ANSC_HANDLE)pBufferDesp ); if ( pSession->GetSessionState((ANSC_HANDLE)pSession) == HTTP_PSO_STATE_FINISHED ) { bFinishSocket = TRUE; break; } break; default : returnStatus = ANSC_STATUS_UNAPPLICABLE; break; } pSession->ReleaseAccess((ANSC_HANDLE)pSession); if ( bFinishSocket ) { pClientSocket->Finish((ANSC_HANDLE)pClientSocket); } return returnStatus; }
ANSC_STATUS AnscLpccoTcpSendRequest ( ANSC_HANDLE hThisObject, ANSC_HANDLE hSocket, void* buffer, ULONG ulSize, ULONG ulSeqNumber, ULONG ulReqType ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PANSC_LPCCO_TCP_OBJECT pMyObject = (PANSC_LPCCO_TCP_OBJECT )hThisObject; PANSC_DAEMON_SERVER_TCP_OBJECT pDaemonServer = (PANSC_DAEMON_SERVER_TCP_OBJECT)pMyObject->hDaemonServer; PANSC_BROKER_SERVER_TCP_OBJECT pBrokerServer = (PANSC_BROKER_SERVER_TCP_OBJECT)pMyObject->hBrokerServer; PANSC_BROKER_SOCKET_TCP_OBJECT pBrokerSocket = (PANSC_BROKER_SOCKET_TCP_OBJECT)hSocket; void* pMessageBuffer = (void* )NULL; ULONG ulBufferSize = (ULONG )0; PIMCP_HEADER pImcpHeader = (PIMCP_HEADER )NULL; PIMCP_REQUEST_MESSAGE pImcpRequestMessage = (PIMCP_REQUEST_MESSAGE )NULL; ULONG ulImcpMsgSize = (ULONG )sizeof(IMCP_HEADER) + sizeof(IMCP_REQUEST_MESSAGE) + ulSize; if ( buffer && ulSize ) { pImcpHeader = (PIMCP_HEADER )((ULONG)buffer - sizeof(IMCP_REQUEST_MESSAGE) - sizeof(IMCP_HEADER)); pImcpRequestMessage = (PIMCP_REQUEST_MESSAGE)((ULONG)buffer - sizeof(IMCP_REQUEST_MESSAGE)); } else { ulBufferSize = sizeof(IMCP_HEADER) + sizeof(IMCP_REQUEST_MESSAGE); pMessageBuffer = AnscAllocateMemory(ulBufferSize); if ( !pMessageBuffer ) { return ANSC_STATUS_RESOURCES; } else { pImcpHeader = (PIMCP_HEADER )pMessageBuffer; pImcpRequestMessage = (PIMCP_REQUEST_MESSAGE)ImcpGetMsgData(pImcpHeader); } } if ( TRUE ) { ImcpSetMsgType (pImcpHeader, IMCP_MESSAGE_TYPE_REQUEST ); ImcpSetMsgLength (pImcpHeader, ulImcpMsgSize - sizeof(IMCP_HEADER)); ImcpRequestSetSeqNumber(pImcpRequestMessage, ulSeqNumber ); ImcpRequestSetReqType (pImcpRequestMessage, ulReqType ); ImcpRequestSetReqSize (pImcpRequestMessage, ulSize ); } returnStatus = pBrokerSocket->Send ( (ANSC_HANDLE)pBrokerSocket, pImcpHeader, ulImcpMsgSize, (ANSC_HANDLE)NULL ); if ( pMessageBuffer ) { AnscFreeMemory(pMessageBuffer); } return returnStatus; }