Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
6.4 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name :
  4. localq.hxx
  5. Abstract:
  6. This module defines the RemoteQ class
  7. Author:
  8. Rohan Phillips ( Rohanp ) 11-Dec-1995
  9. Project:
  10. SMTP Server DLL
  11. Revision History:
  12. --*/
  13. #ifndef _REMOTE_QUEUE_HXX_
  14. #define _REMOTE_QUEUE_HXX_
  15. /************************************************************
  16. * Include Headers
  17. ************************************************************/
  18. /************************************************************
  19. * Symbolic Constants
  20. ************************************************************/
  21. #include "asynccon.hxx"
  22. #include <smtpevent.h>
  23. /************************************************************
  24. * Type Definitions
  25. ************************************************************/
  26. BOOL AsyncCopyMailToDropDir(
  27. ISMTPConnection *pISMTPConnection,
  28. const char * DropDirectory,
  29. SMTP_SERVER_INSTANCE * pParentInst
  30. );
  31. #define DNS_RESOLVER_RECORD_VALID_SIGNATURE 'uRRD'
  32. #define DNS_RESOLVER_RECORD_INVALID_SIGNATURE 'fRRD'
  33. class DNS_RESOLVER_RECORD;
  34. //
  35. // A wrapper class for iterating through the hosts in the basic dns resolver record
  36. // returned by the dns resolution sink. The wrapper clubs together the index (of the
  37. // current destination host) with the resolver record, as they always are used in
  38. // conjunction.
  39. //
  40. class DNS_RESOLVER_RECORD
  41. {
  42. private:
  43. IDnsResolverRecord *pIDnsResolverRecord;
  44. DWORD iDnsResolverRecord;
  45. DWORD m_signature;
  46. public:
  47. DNS_RESOLVER_RECORD()
  48. : pIDnsResolverRecord(NULL),
  49. iDnsResolverRecord(0),
  50. m_signature(DNS_RESOLVER_RECORD_VALID_SIGNATURE)
  51. {
  52. TraceFunctEnterEx((LPARAM) this, "DNS_RESOLVER_RECORD::DNS_RESOLVER_RECORD");
  53. DebugTrace((LPARAM) this, "Creating DNS_RESOLVER_RECORD = 0x%08x", this);
  54. }
  55. ~DNS_RESOLVER_RECORD()
  56. {
  57. TraceFunctEnterEx((LPARAM) this, "DNS_RESOLVER_RECORD::~DNS_RESOLVER_RECORD");
  58. DebugTrace((LPARAM) this, "Destructing DNS_RESOLVER_RECORD = 0x%08x", this);
  59. if(pIDnsResolverRecord)
  60. pIDnsResolverRecord->Release();
  61. m_signature = DNS_RESOLVER_RECORD_INVALID_SIGNATURE;
  62. }
  63. void SetDnsResolverRecord(IDnsResolverRecord *pIDns) { pIDnsResolverRecord = pIDns; }
  64. void ResetCounter() { iDnsResolverRecord = 0; }
  65. HRESULT HrGetNextDestinationHost(LPSTR *ppszHostName, DWORD *pdwAddr)
  66. { return pIDnsResolverRecord->GetItem( iDnsResolverRecord++, ppszHostName, pdwAddr ); }
  67. };
  68. class REMOTE_QUEUE : public PERSIST_QUEUE
  69. {
  70. public:
  71. REMOTE_QUEUE(SMTP_SERVER_INSTANCE * pSmtpInst) : PERSIST_QUEUE(pSmtpInst) {};
  72. virtual void BeforeDelete(void){DROP_COUNTER (GetParentInst(), RemoteQueueLength);}
  73. virtual BOOL ProcessQueueEvents(ISMTPConnection *pISMTPConnection);
  74. virtual BOOL InsertEntry(IN OUT PERSIST_QUEUE_ENTRY * pEntry, QUEUE_SIG Qsig = SIGNAL, QUEUE_POSITION Qpos = QUEUE_TAIL)
  75. {
  76. return PERSIST_QUEUE::InsertEntry (pEntry, Qsig, Qpos);
  77. }
  78. virtual PQUEUE_ENTRY PopQEntry(void)
  79. {
  80. //Decrement our counter
  81. DROP_COUNTER(GetParentInst(), RemoteQueueLength);
  82. return PERSIST_QUEUE::PopQEntry ();
  83. }
  84. virtual void DropRetryCounter(void) {DROP_COUNTER(GetParentInst(), RemoteRetryQueueLength);}
  85. virtual void BumpRetryCounter(void) {BUMP_COUNTER(GetParentInst(), RemoteRetryQueueLength);}
  86. virtual DWORD GetRetryMinutes(void) {return GetParentInst()->GetRemoteRetryMinutes();}
  87. BOOL MakeATQConnection(
  88. SMTPDNS_RECS * pDnsRec,
  89. SOCKET socket,
  90. DWORD IpAddress,
  91. ISMTPConnection *pISMTPConnection,
  92. DWORD Options,
  93. LPSTR pszSSLVerificationName);
  94. void HandleFailedConnection (ISMTPConnection *pISMTPConnection, DWORD dwConnectionStatus = CONNECTION_STATUS_FAILED);
  95. BOOL StartAsyncConnect(const char * HostName,
  96. ISMTPConnection *pISMTPConnection,
  97. DWORD DomainOptions,
  98. BOOL fUseSmartHostAfterFail);
  99. BOOL ConnectToNextResolverHost( CAsyncMx * pThisQ );
  100. BOOL CopyMailToDropDir(ISMTPConnection *pISMTPConnection, const char * DropDirectory);
  101. HANDLE CreateDropFile(const char * DropDir, char * szDropFile);
  102. BOOL ReStartAsyncConnections(SMTPDNS_RECS * pDnsRecs, ISMTPConnection * pISMTPConnection, DWORD DomainParams, LPSTR pszSSLVerificationName);
  103. private:
  104. BOOL ConnectToResolverHost( const char * HostName,
  105. LPSTR MyFQDNName,
  106. ISMTPConnection *pISMTPConnection,
  107. DWORD DomainOptions,
  108. BOOL fUseSmartHostAfterFail,
  109. DNS_RESOLVER_RECORD *pDNS_RESOLVER_RECORD);
  110. BOOL BeginInitializeAsyncDnsQuery( LPSTR pszHostName,
  111. LPSTR pszFQDN,
  112. ISMTPConnection *pISMTPConnection,
  113. DWORD dwDnsFlags,
  114. DWORD DomainOptions,
  115. BOOL fUseSmartHostAfterFail,
  116. DNS_RESOLVER_RECORD *pDNS_RESOLVER_RECORD,
  117. const char * pszSSLVerificationName );
  118. BOOL BeginInitializeAsyncConnect( PSMTPDNS_RECS pDnsRec,
  119. ISMTPConnection *pISMTPConnection,
  120. DWORD DomainOptions,
  121. DNS_RESOLVER_RECORD *pDNS_RESOLVER_RECORD,
  122. const char * pszSSLVerificationName );
  123. BOOL CheckIfAllRcptsHandled( IMailMsgRecipients *pIMsgRecips, DWORD *RcptIndexList, DWORD NumRcpts );
  124. HRESULT SetAllRcptsHandled( IMailMsgRecipients *pIMsgRecips, DWORD *RcptIndexList, DWORD NumRcpts );
  125. };
  126. VOID InternetCompletion(PVOID pvContext, DWORD cbWritten,
  127. DWORD dwCompletionStatus, OVERLAPPED * lpo);
  128. BOOL DnsQueryAsync(
  129. SMTP_SERVER_INSTANCE *pServiceInstance,
  130. LPSTR pszHostName,
  131. LPSTR pszFQDN,
  132. ISMTPConnection *pISMTPConnection,
  133. DWORD dwDnsFlags,
  134. DWORD DomainOptions,
  135. BOOL fUseSmartHostAfterFail,
  136. DNS_RESOLVER_RECORD *pDNS_RESOLVER_RECORD,
  137. const char * pszSSLVerificationName,
  138. BOOL fUdp);
  139. #endif