Exemplo n.º 1
0
/**
 *
 * Method Name:  RTCPReportingAlarm()
 *
 *
 * Inputs:   IRTCPConnection *piRTCPConnection
 *                                   - Interface to associated RTCP Connection
 *           IRTCPSession    *piRTCPSession
 *                                   - Interface to associated RTCP Session
 *
 * Outputs:  None
 *
 * Returns:  None
 *
 * Description: The ReportAlarm() event method shall inform the recipient of
 *              the expiration of reporting period.  This event usually causes
 *              RTCP Reports to be sent out on the associated session.
 *
 * Usage Notes:
 *
 */
void CRTCPSession::RTCPReportingAlarm(IRTCPConnection     *piRTCPConnection,
                                      IRTCPSession        *piRTCPSession)
{

    // Send the event with the correpsonding info.
    ((IRTCPSession *)this)->AddRef();
    m_piRTCPNotify->RTCPReportingAlarm(piRTCPConnection, (IRTCPSession *)this);

#if RTCP_DEBUG /* [ */
    if(bPingtelDebug)
    {
        osPrintf("*** RTCP REPORTING ALARM ****\n");
        osPrintf("\t ON SESSION ==> %d\n", GetSessionID());
        osPrintf("\t TO SSRC  ==> %u\n\n", piRTCPConnection->GetRemoteSSRC());
    }
#endif /* RTCP_DEBUG ] */
}
Exemplo n.º 2
0
/**
 *
 * Method Name:  ReassignSSRC
 *
 *
 * Inputs:   unsigned long  ulSSRC     - Source ID
 *           unsigned char *puchReason - Optional Reason for SSRC Reassignment
 *
 * Outputs:  None
 *
 * Returns:  void
 *
 * Description: Reassigns the Source Identifier associated with an RTP session
 *              due to collision detection and resolution.  Calling of this
 *              method shall result in the resetting of the SSRC IDs of
 *              associated Sender, Receiver, and SDES Reports.
 *
 * Usage Notes:
 *
 *
 *
 */
void CRTCPSession::ReassignSSRC(unsigned long ulSSRC,
                                unsigned char *puchReason)
{
#if RTCP_DEBUG /* [ */
    if(bPingtelDebug)
    {
        osPrintf("*** SSRC REASSIGNED ****\n");
        osPrintf("\t ON SESSION ==> %d\n", GetSessionID());
        osPrintf("\t NEW SSRC    ==> %u\n", ulSSRC);
        osPrintf("\t REASON     ==> %s\n", puchReason);
    }
#endif /* RTCP_DEBUG ] */

    // Reset all connections first
    ResetAllConnections(puchReason);

    // Set new Session SSRC
    m_ulSSRC = ulSSRC;

    // Check the each entry of the connection list
    CRTCPConnection *poRTCPConnection = GetFirstEntry();

    // Iterate through the list until all entries have been exhausted
    while(poRTCPConnection != NULL)
    {
        // Bump Reference Count of Connection Object
        poRTCPConnection->AddRef();

        // Get Render Interface
        IRTCPRender *piRTCPRender = poRTCPConnection->GetRenderInterface();

        // Instruct the Render filter of the new SSRC.
        // It will take care of the reset
        piRTCPRender->ReassignSSRC(ulSSRC);

        // Release Render Interface
        piRTCPRender->Release();

        // Release Reference to Connection Object
        poRTCPConnection->Release();

        // Get the next connection from the list
        poRTCPConnection = GetNextEntry();
    }

}
   bool
   SpamAssassinClient::SendFileContents_(const String &sFilename)
   {
      String logMessage;
      logMessage.Format(_T("Sending message to SpamAssassin. Session %d, File: %s"), GetSessionID(), sFilename.c_str());
      LOG_DEBUG(logMessage);

      File oFile;
      
      try
      {
         oFile.Open(sFilename, File::OTReadOnly);
      }
      catch (...)
      {
         String sErrorMsg;
         sErrorMsg.Format(_T("Could not send file %s via socket since the file could not be opened."), sFilename.c_str());

         ErrorManager::Instance()->ReportError(ErrorManager::High, 5019, "SMTPClientConnection::SendFileContents_", sErrorMsg);
         return false;
      }

      const int maxIterations = 100000;
      for (int i = 0; i < maxIterations; i++)
      {
         std::shared_ptr<ByteBuffer> pBuf = oFile.ReadChunk(20000);

         if (pBuf->GetSize() == 0)
            break;

         BYTE *pSendBuffer = (BYTE*) pBuf->GetBuffer();
         size_t iSendBufferSize = pBuf->GetSize();

         EnqueueWrite(pBuf);
      }

      EnqueueShutdownSend();

      // Request the response...
      EnqueueRead("");
      
      return true;
   }
Exemplo n.º 4
0
/**
 *
 * Method Name:  UpdatedSDES()
 *
 *
 * Inputs:   IGetSrcDescription *piGetSrcDescription
 *                              - Interface to the new Source Description info
 *           unsigned long       ulChangeMask
 *                                - The SDES fields that were subject to change
 *           IRTCPConnection    *piRTCPConnection
 *                                - Interface to associated RTCP Connection
 *           IRTCPSession       *piRTCPSession
 *                                - Interface to associated RTCP Session
 *
 * Outputs:  None
 *
 * Returns:  None
 *
 * Description: The UpdateSDES() event method shall inform the RTCP Session of
 *              a new Source Description and shall include the SSRC ID and the
 *              IGetSrcDescription interface for accessing the contents of this
 *              new Source Description.  The RTCP Session shall forward this
 *              SDES Report to other RTCP Connections in the session while
 *              acting as a Mixer.  It shall also forward the event to the RTC
 *              Manager for distribution to other subscribers.
 *
 * Usage Notes:
 *
 */
void CRTCPSession::UpdatedSDES(IGetSrcDescription *piGetSrcDescription,
                               unsigned long       ulChangeMask,
                               IRTCPConnection    *piRTCPConnection,
                               IRTCPSession       *piRTCPSession)
{

    // Now forward this event to the RTC Manager so that it can be dispatched
    //  to subscribers with matching interests
    ((IRTCPSession *)this)->AddRef();
    m_piRTCPNotify->UpdatedSDES(piGetSrcDescription,
                        ulChangeMask, piRTCPConnection, (IRTCPSession *)this);

#if RTCP_DEBUG /* [ */
    if(bPingtelDebug)
    {
        osPrintf("*** SDES UPDATE RECEIVED ****\n");
        osPrintf("\t ON SESSION ==> %d\n", GetSessionID());
        osPrintf("\t FROM SSRC  ==> %u\n", piGetSrcDescription->GetSSRC());

        unsigned char uchFieldBuffer[MAX_ENTRYSIZE];
        unsigned long ulFieldID;

        if(!ulChangeMask)
        {
            osPrintf("\t\tNO CHANGES PRESENT IN THIS SDES REPORT\n\n");
            return;
        }

        osPrintf("\t\t******************************************\n");

        while(ulChangeMask)
        {
            ulChangeMask = piGetSrcDescription->GetFieldChange(ulChangeMask,
                                                  &ulFieldID, uchFieldBuffer);
            osPrintf("\t\tSDES REPORT ==>  TYPE %s ** CONTENT %s\n",
                               suchSDESFieldNames[ulFieldID], uchFieldBuffer);
        }
        osPrintf("\t\t******************************************\n\n");

    }
#endif /* RTCP_DEBUG ] */
}
Exemplo n.º 5
0
/**
 *
 * Method Name:  ReceiverReportReceived()
 *
 *
 * Inputs:   IGetReceiverStatistics *piGetReceiverStatistics
 *                                    - Interface to the Receiver Statistics
 *           IRTCPConnection        *piRTCPConnection
 *                                    - Interface to associated RTCP Connection
 *           IRTCPSession           *piRTCPSession
 *                                    - Interface to associated RTCP Session
 *
 * Outputs:  None
 *
 * Returns:  None
 *
 * Description: The ReceiverReportReceived() event method shall inform the
 *              recipient of a change in Receiver Statistics and shall include
 *              the IGetReceiverStatistics interface for accessing the contents
 *              of this updated Receiver Report. This event shall be forwarded
 *              to the RTC Manager for distribution to other subscribers.
 *
 * Usage Notes:
 *
 */
void CRTCPSession::ReceiverReportReceived(
                              IGetReceiverStatistics *piGetReceiverStatistics,
                              IRTCPConnection        *piRTCPConnection,
                              IRTCPSession           *piRTCPSession)
{

    // Now forward this event to the RTC Manager so that it can be dispatched
    //  to subscribers with matching interests
    ((IRTCPSession *)this)->AddRef();
    m_piRTCPNotify->ReceiverReportReceived(piGetReceiverStatistics,
                                      piRTCPConnection, (IRTCPSession *)this);

#if RTCP_DEBUG /* [ */
    if(bPingtelDebug)
    {
        unsigned long ulFractionalLoss, ulCumulativeLoss, ulHighestSequenceNo,
                      ulInterarrivalJitter, ulSRTimestamp, ulPacketDelay;

        osPrintf("*** RECEIVED REPORT RECEIVED ****\n");
        osPrintf("\t ON SESSION ==> %d\n", GetSessionID());
        osPrintf("\t FROM SSRC  ==> %u\n", piGetReceiverStatistics->GetSSRC());

        piGetReceiverStatistics->GetReceiverStatistics(&ulFractionalLoss,
                                                       &ulCumulativeLoss,
                                                       &ulHighestSequenceNo,
                                                       &ulInterarrivalJitter,
                                                       &ulSRTimestamp,
                                                       &ulPacketDelay);

        osPrintf("\t\t******************************************\n");
        osPrintf("\t\tFRACTIONAL LOSS IS     ==> %u\n",  ulFractionalLoss);
        osPrintf("\t\tCUMULATIVE LOSS IS     ==> %u\n",  ulCumulativeLoss);
        osPrintf("\t\tHIGH SEQUENCE # IS     ==> %u\n",  ulHighestSequenceNo);
        osPrintf("\t\tINTERARRIVAL JITTER IS ==> %u\n",  ulInterarrivalJitter);
        osPrintf("\t\tLAST SR TIMESTAMP IS   ==> %u\n",  ulSRTimestamp);
        osPrintf("\t\tREPORT DELAY           ==> %u\n",  ulPacketDelay);
        osPrintf("\t\t******************************************\n\n");
    }
#endif /* RTCP_DEBUG ] */

}
Exemplo n.º 6
0
/**
 *
 * Method Name:  ByeReportSent()
 *
 *
 * Inputs:   IGetByeInfo     *piGetByeInfo
 *                         - Interface used to retrieve Bye Report information
 *           IRTCPConnection *piRTCPConnection
 *                                   - Interface to associated RTCP Connection
 *           IRTCPSession    *piRTCPSession
 *                                   - Interface to associated RTCP Session
 *
 * Outputs:  None
 *
 * Returns:  None
 *
 * Description: The ByeReportSent() event method shall inform the recipient of
 *              a newly transmitted BYE Report and shall include the SSRC ID
 *              and reason to identify the connection and the cause of
 *              termination.
 *
 * Usage Notes:
 *
 */
void CRTCPSession::ByeReportSent(IGetByeInfo     *piGetByeInfo,
                                 IRTCPConnection *piRTCPConnection,
                                 IRTCPSession    *piRTCPSession)
{

    // Forward this event to the RTC Manager so that it can be dispatched
    //  to subscribers with matching interests
    ((IRTCPSession *)this)->AddRef();
    m_piRTCPNotify->ByeReportSent(piGetByeInfo,
                                      piRTCPConnection, (IRTCPSession *)this);

#if RTCP_DEBUG /* [ */
    if(bPingtelDebug)
    {
        osPrintf("*** BYE REPORT SENT ****\n");
        osPrintf("\t ON SESSION ==> %d\n", GetSessionID());
        osPrintf("\t TO SSRC  ==> %u\n\n", piRTCPConnection->GetRemoteSSRC());

        unsigned char uchReason[MAX_ENTRYSIZE];

        osPrintf("\t\t******************************************\n");
        unsigned long aulCSRCs[32];
        piGetByeInfo->GetReason(uchReason);
        osPrintf("\t\tBYE REPORT ==>  REASON IS %s\n", uchReason);

        unsigned long ulCSRCs = piGetByeInfo->GetCSRC(aulCSRCs);
        if(ulCSRCs == 0)
            osPrintf("\t\tBYE REPORT ==>  NO AFFECTED CSRCS\n");
        else
        {
            osPrintf("\t\tBYE REPORT ==>  AFFECTED CSRCS ARE ");
            for(unsigned long ulCount; ulCount < ulCSRCs; ulCount++)
                osPrintf("%u ", aulCSRCs[ulCount]);
            osPrintf("\n");
        }
        osPrintf("\t\t******************************************\n");

    }
#endif /* RTCP_DEBUG ] */

}
Exemplo n.º 7
0
   void 
   POP3Connection::_LogClientCommand(const String &sClientData) const
   //---------------------------------------------------------------------------()
   // DESCRIPTION:
   // Logs one client command.
   //---------------------------------------------------------------------------()
   {
      if (!Logger::Instance()->GetLogPOP3())
         return;

      String sLogData = sClientData;

      // Remove any password from the log.
      PasswordRemover::Remove(PasswordRemover::PRPOP3, sLogData);

      // Append
      sLogData = "RECEIVED: " + sLogData;
      sLogData.Replace(_T("\r\n"), _T("[nl]"));

      LOG_POP3(GetSessionID(), GetIPAddressString(), sLogData);      
   }
Exemplo n.º 8
0
	void ClientSession::H_Read_Header(const boost::system::error_code& error)
	{
		if (!error)
		{
		//async_read 保证将数据读取完毕后才会调用回调函数
            LOG(INFO)<<"ClientSession :: Send to Root OK!";
            LOG(INFO)<< "ClientSession :: begin read header again... ";
			boost::asio::async_read(_socket_,
				boost::asio::buffer(&_header_,sizeof(struct  HeadStructMessage)),
				boost::bind(&ClientSession::H_Read_Proto, this,
				boost::asio::placeholders::error));
		}
		else
		{
#ifdef DEBUG
			cout<<"error in rootserver"<<endl;
#endif
			g_session_manager->Recycle(GetSessionID());
		}

	}
Exemplo n.º 9
0
   void
   SpamAssassinClient::ParseData(shared_ptr<ByteBuffer> pBuf)
   {
      if (!m_pResult)
      {
         String logMessage;
         logMessage.Format(_T("Parsing response from SpamAssassin. Session %d"), GetSessionID());
         LOG_DEBUG(logMessage);

         m_pResult = shared_ptr<File>(new File);
         m_pResult->Open(FileUtilities::GetTempFileName(), File::OTAppend);

         m_iSpamDSize = _ParseFirstBuffer(pBuf);
      }

      // Append output to the file
      DWORD dwWritten = 0;
      m_pResult->Write(pBuf, dwWritten);

      PostReceive();
   }
   void
   SMTPClientConnection::LogSentCommand_(const String &sData)
   {
      if (!(Logger::Instance()->GetLogMask() & Logger::LSSMTP))
         return;

      String sLogData = sData;

      if (current_state_ == PASSWORDSENT)
      {
         // Password has been sent. Remove from log.
         sLogData = "***";
      }

      // Append
      sLogData = "SENT: " + sLogData;
      
      sLogData.TrimRight(_T("\r\n"));

      LOG_SMTP_CLIENT(GetSessionID(), GetIPAddressString(), sLogData);
   }
Exemplo n.º 11
0
void CRequestContext::x_UpdateStdPassThroughProp(CTempString name) const
{
    if (name.empty()  ||  NStr::EqualNocase(name, kPassThrough_Sid)) {
        if ( IsSetSessionID() ) {
            x_SetPassThroughProp(kPassThrough_Sid, GetSessionID(), false);
        }
        else {
            x_ResetPassThroughProp(kPassThrough_Sid, false);
        }
    }
    if (name.empty()  ||  NStr::EqualNocase(name, kPassThrough_ClientIp)) {
        if ( IsSetClientIP() ) {
            x_SetPassThroughProp(kPassThrough_ClientIp, GetClientIP(), false);
        }
        else {
            x_ResetPassThroughProp(kPassThrough_ClientIp, false);
        }
    }
    if (name.empty()  ||  NStr::EqualNocase(name, kPassThrough_Dtab)) {
        if ( IsSetDtab() ) {
            x_SetPassThroughProp(kPassThrough_Dtab, GetDtab(), false);
        }
        else {
            x_ResetPassThroughProp(kPassThrough_Dtab, false);
        }
    }
    if (name.empty()  ||  NStr::EqualNocase(name, kPassThrough_Phid)) {
        if ( IsSetHitID() ) {
            string sub_phid = const_cast<CRequestContext&>(*this).GetCurrentSubHitID();
            if ( sub_phid.empty() ) {
                sub_phid = const_cast<CRequestContext&>(*this).GetNextSubHitID();
            }
            x_SetPassThroughProp(kPassThrough_Phid, sub_phid, false);
        }
        else {
            x_ResetPassThroughProp(kPassThrough_Phid, false);
        }
    }
}
Exemplo n.º 12
0
   bool
   SpamAssassinClient::_SendFileContents(const String &sFilename)
   {
      String logMessage;
      logMessage.Format(_T("Sending message to SpamAssassin. Session %d, File: %s"), GetSessionID(), sFilename);
      LOG_DEBUG(logMessage);

      File oFile;
      if (!oFile.Open(sFilename, File::OTReadOnly))
      {
         String sErrorMsg;
         sErrorMsg.Format(_T("Could not send file %s via socket since it does not exist."), sFilename);

         ErrorManager::Instance()->ReportError(ErrorManager::High, 5019, "SMTPClientConnection::_SendFileContents", sErrorMsg);

         return false;
      }

      const int maxIterations = 100000;
      for (int i = 0; i < maxIterations; i++)
      {
         shared_ptr<ByteBuffer> pBuf = oFile.ReadChunk(20000);

         if (!pBuf)
            break;

         BYTE *pSendBuffer = (BYTE*) pBuf->GetBuffer();
         int iSendBufferSize = pBuf->GetSize();

         SendData(pBuf);
      }

      PostShutdown(TCPConnection::ShutdownSend);

      // Request the response...
      PostBufferReceive();
      
      return true;
   }
Exemplo n.º 13
0
wstring CWaveSession::SerializeRequest(CWaveRequest * lpRequest)
{
	ASSERT(lpRequest != NULL);

	// Prepare the request basics.

	Json::Value vRoot(Json::objectValue);

	vRoot[L"a"] = Json::Value(GetSessionID());
	vRoot[L"r"] = Json::Value(Format(L"%x", m_nNextRequestID++));
	vRoot[L"t"] = Json::Value(lpRequest->GetType());
	vRoot[L"p"] = Json::Value(Json::objectValue);

	// Let the request object write the parameters.

	lpRequest->CreateRequest(vRoot[L"p"]);

	// Get the encoded JSON data.

	Json::FastWriter vWriter;

	return vWriter.write(vRoot);
}
Exemplo n.º 14
0
/**
 *
 * Method Name:  SDESReportSent()
 *
 *
 * Inputs:   IGetSrcDescription *piGetSrcDescription
 *                                 - Interface to the local Source Description
 *           IRTCPConnection    *piRTCPConnection
 *                                 - Interface to associated RTCP Connection
 *           IRTCPSession       *piRTCPSession
 *                                 - Interface to associated RTCP Session
 *
 * Outputs:  None
 *
 * Returns:  None
 *
 * Description: The SDESReportSent() event method shall inform the recipient
 *              of a newly transmitted SDES Report and shall include the
 *              IGetSrcDescription interface for accessing the contents of
 *              this transmitted SDES Report.
 *
 * Usage Notes:
 *
 */
void CRTCPSession::SDESReportSent(IGetSrcDescription *piGetSrcDescription,
                                  IRTCPConnection    *piRTCPConnection,
                                  IRTCPSession       *piRTCPSession)
{

    // Forward this event to the RTC Manager so that it can be dispatched to
    //  subscribers with matching interests
    ((IRTCPSession *)this)->AddRef();
    m_piRTCPNotify->SDESReportSent(piGetSrcDescription,
                                      piRTCPConnection, (IRTCPSession *)this);

#if RTCP_DEBUG /* [ */
    if(bPingtelDebug)
    {
        osPrintf("*** SDES REPORT SENT ****\n");
        osPrintf("\t ON SESSION ==> %d\n", GetSessionID());
        osPrintf("\t TO SSRC    ==> %u\n", piRTCPConnection->GetRemoteSSRC());

        unsigned char uchFieldBuffer[MAX_ENTRYSIZE];
        unsigned long ulFieldID;
        unsigned long ulChangeMask = piGetSrcDescription->GetChanges();

        osPrintf("\t\t******************************************\n");

        while(ulChangeMask)
        {
            ulChangeMask = piGetSrcDescription->GetFieldChange(ulChangeMask,
                                                  &ulFieldID, uchFieldBuffer);
            osPrintf("\t\tSDES REPORT ==>  TYPE %s ** CONTENT %s\n",
                               suchSDESFieldNames[ulFieldID], uchFieldBuffer);
        }
        osPrintf("\t\t******************************************\n\n");

    }
#endif /* RTCP_DEBUG ] */
}
Exemplo n.º 15
0
	void ClientSession::H_New_Search_Session(const boost::system::error_code& error ,
            SearchProtoMessage msg,char * content_buf_ptr)
	{
		if (!error)
		{
		//根据任务类型创建新的session,然后再继续监听接下来的连接的请求
            string  path = _WriteToFile_(content_buf_ptr, _pic_len_) ; 
            LOG(INFO)<<"ClientSession :: file path "<<path; 
			SearchSession * session = g_session_manager->CreateSession<SearchSession>( msg , path ,GetSessionID());
            if(content_buf_ptr != NULL)
            {
                delete []content_buf_ptr;
                content_buf_ptr = NULL;
            }
            session->Start();
            WritePacket();
		}
		else
		{
            LOG(ERROR)<< "ClientSession :: Read file content Error"<<error.message();
			g_session_manager->Recycle(GetSessionID());
		}

	}
Exemplo n.º 16
0
 void 
 TCPConnection::ReportDebugMessage(const String &message, const boost::system::error_code &error)
 {
    String formattedMessage;
    formattedMessage.Format(_T("%s Remote IP: %s, Session: %d, Code: %d, Message: %s"), message.c_str(), SafeGetIPAddress().c_str(), GetSessionID(), error.value(), String(error.message()).c_str());
    LOG_DEBUG(formattedMessage);
 }
Exemplo n.º 17
0
   void
   SMTPClientConnection::InternalParseData(const AnsiString  &Request)
   {
      LOG_DEBUG("SMTPClientConnection::_ParseASCII()");

      String sData = "RECEIVED: " + Request;
      LOG_SMTP_CLIENT(GetSessionID(), GetIPAddress().ToString(), sData);

      // Below 3 lines is fix of the problem that occurs when the remote server answers
      // with 2 line in his welcome message.
      String sMinus = "-";
      if ((Request.GetLength() > 3) && (Request.GetAt(3) == sMinus.GetAt(0)))
      {
         LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 1");
         return;
      }

      int lFirstSpace = Request.Find(" ");
   
      AnsiString sFirstWordTemp;
      if (lFirstSpace < 0)
         sFirstWordTemp = Request;
      else
         sFirstWordTemp = Request.Mid(0, lFirstSpace);
      sFirstWordTemp.MakeUpper();
      int iCode = atoi(sFirstWordTemp);

      // We should not update all recipient's if we've just sent a
      // RCPT TO. We should only update the specific one we've just
      // sent to.
      // 
      // Also, we should not update state if we've just sent QUIT to
      // the server. At the time we send QUIT, the message has already
      // been either accepted for delivery and rejected. Any error after
      // this isn't relvat.
      if (m_CurrentState != RCPTTOSENT && m_CurrentState != QUITSENT)
      {
         if (IsPermanentNegative(iCode))
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
            _SendQUIT();
            return;
         }
         else if (IsTransientNegative(iCode))
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
            _SendQUIT();
            return;
         }
      }
   
      switch (m_CurrentState)
      {
      case SENDUSERNAME:
         _ProtocolSendUsername();
         break;
      case SENDPASSWORD:
         _ProtocolSendPassword();
         break;
      case PASSWORDCHECK:
         if (!_ProtocolPassswordCheck(iCode, Request))
         {
            // Authentication failed. We have just sent
            // a quit command.
            return;
         }

         break;
      }
      
      if (m_CurrentState == HELO)
      {
         if (iCode == 220)
         {
			   String sComputerName = Utilities::ComputerName(); 
      
            if (m_bUseSMTPAuth)
            {
               _SendData("EHLO " + sComputerName);
               _SetState(EHLOSENT);
            }
            else
            {
               _SendData("HELO " + sComputerName);
               _SetState(HELOSENT);
            }
        
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 2");

            return ;
         }
         else
         {
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 3");
            _UpdateAllRecipientsWithError(iCode, Request, false);
            _SendQUIT();
            return;
         }
      }

      if (m_CurrentState == EHLOSENT)
      {
         // Ask the server to initiate login process.
         _SendData("AUTH LOGIN");
         _SetState(SENDUSERNAME);
         return ;
      }

      if (m_CurrentState == HELOSENT)
      {
         if (IsPositiveCompletion(iCode))
         {
            // --- Server accepted HELO. Go to HEADER/MAILFROM state.
            _SetState(MAILFROM);
         }
	      else
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
         }
      }
   

      if (m_CurrentState == MAILFROM)
      {
         String sFrom = m_pDeliveryMessage->GetFromAddress();
         String sData = "MAIL FROM:<" + sFrom + ">";
         _SendData(sData);
         m_CurrentState = MAILFROMSENT;
         LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 4");
         return;
      }

      if (m_CurrentState == MAILFROMSENT)
      {
         if (IsPositiveCompletion(iCode))
         {
            // --- Server accepted mail from. Go to header/rcpt to state.
            m_CurrentState = RCPTTO;
         }
         else
         {
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 5");
            _UpdateAllRecipientsWithError(iCode, Request, false);
         }

      }

      if (m_CurrentState == RCPTTO)
      {
         LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 6");

         shared_ptr<MessageRecipient> pRecipient = _GetNextRecipient();
         if (!pRecipient) 
         {
            _SendQUIT();
            return;
         }
         
         String sRecipient = pRecipient->GetAddress();
         String sData = "RCPT TO:<" + sRecipient + ">";
         _SendData(sData);
         m_CurrentState = RCPTTOSENT;

         return;

      }

      if (m_CurrentState == RCPTTOSENT)
      {
         if (m_iCurRecipient < m_vecRecipients.size())
         {
            if (IsPositiveCompletion(iCode))
            {
               _actualRecipients.insert(m_vecRecipients[m_iCurRecipient]);
            }
            else
            {
               _UpdateRecipientWithError(iCode, Request, m_vecRecipients[m_iCurRecipient], false);
            }
         }

         shared_ptr<MessageRecipient> pRecipient = _GetNextRecipient();
         if (pRecipient)
         {
            // Send next recipient.
            _SendData("RCPT TO:<" + pRecipient->GetAddress() + ">");
            m_CurrentState = RCPTTOSENT;
         }
         else
         {
            if (_actualRecipients.size() == 0)
            {
               _SendQUIT();
               return;
            }
            
            m_CurrentState = DATAQUESTION;
         }
      }

      if (m_CurrentState == DATAQUESTION)
      {
         _SendData("DATA");
         m_CurrentState = DATA;
         LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 7");
         return;
      }

      if (m_CurrentState == DATA)
      {
         if (IsPositiveIntermediate(iCode))
         {
            // Send the data!
            const String fileName = PersistentMessage::GetFileName(m_pDeliveryMessage);
            LOG_DEBUG("SMTPClientConnection::~_BEFORE SendFile");
            _StartSendFile(fileName);
            LOG_DEBUG("SMTPClientConnection::~_AFTER SendFile");
            return;
         }
      }

      if (m_CurrentState == DATASENT)
      {
            LOG_DEBUG("SMTPClientConnection::~_BEFORE SendQUIT");
         _SendQUIT();
            LOG_DEBUG("SMTPClientConnection::~_AFTER SendQUIT");

         if (IsPositiveCompletion(iCode))
         {
            _UpdateSuccessfulRecipients();
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 9");
            return;
         }
         else
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 10");
         }

         return;
      }

      if (m_CurrentState == QUITSENT)
      {     
         // We just received a reply on our QUIT. Time to disconnect.
         m_bPendingDisconnect = true;
         PostDisconnect();
      }
   }
Exemplo n.º 18
0
/**
 *
 * Method Name:  RTCPConnectionStopped()
 *
 *
 * Inputs:   IRTCPConnection *piRTCPConnection
 *                                   - Interface to associated RTCP Connection
 *           IRTCPSession    *piRTCPSession
 *                                   - Interface to associated RTCP Session
 *
 * Outputs:  None
 *
 * Returns:  None
 *
 * Description: The RTCPConnectionStopped() event method shall inform the
 *              recipient of the imminent suspension of an RTCP outbound
 *              connection.  This will allow whatever connection related
 *              operations to be suspended until it again resumes.
 *
 * Usage Notes:
 *
 */
void CRTCPSession::RTCPConnectionStopped(IRTCPConnection *piRTCPConnection,
                                         IRTCPSession    *piRTCPSession)
{
    unsigned long aulCSRC[MAX_CONNECTIONS];
    unsigned long ulCSRCs = 0;
    CRTCPConnection *poRTCPConnection;

    // Get the associated RTCP Connection object from the collection list
    if((poRTCPConnection = GetEntry(RTCPConnectionComparitor,
                                   (void *)piRTCPConnection)) != NULL)
    {
#if RTCP_DEBUG /* [ */
        if(bPingtelDebug)
        {
            osPrintf("*** RTCP CONNECTION STOPPED ****\n");
            osPrintf("\t ON SESSION ==> %d\n", GetSessionID());
            osPrintf("\t TO SSRC    ==> %u\n",
                                           piRTCPConnection->GetRemoteSSRC());
        }
#endif /* RTCP_DEBUG ] */

        // Check whether the session is acting as an Audio Mixer.  If so,
        // We should include these sites into our contributing source list.
        if(m_etMixerMode == MIXER_ENABLED)
        {
            // Check each entry of the connection list
            CRTCPConnection *poPeerConnection = GetFirstEntry();

            // Iterate through the list until all entries have been exhausted
            for(ulCSRCs = 0; poPeerConnection != NULL; ulCSRCs++)
            {
                // Bump Reference Count of Connection Object
                poPeerConnection->AddRef();

                // Get the SSRC ID of the connection
                aulCSRC[ulCSRCs] = poPeerConnection->GetRemoteSSRC();

                // Check that we are not adding the Remote SSRC of the
                //  connection being terminated.  If so, we will backup the
                //  CSRC count
                if(poPeerConnection->GetRemoteSSRC() == aulCSRC[ulCSRCs])
                    ulCSRCs--;

                // Release Reference to Connection Object
                poPeerConnection->Release();

                // Get the next connection from the list
                poPeerConnection = GetNextEntry();
            }
        }

        // Bump Reference Count of Connection Object
        poRTCPConnection->AddRef();

        poRTCPConnection->GenerateRTCPReports(
          (unsigned char *)"Normal Connection Termination", aulCSRC, ulCSRCs);

        // Release Reference to Connection Object
        poRTCPConnection->Release();

    }

}