📄 phuser.h
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft shared
// source or premium shared source license agreement under which you licensed
// this source code. If you did not accept the terms of the license agreement,
// you are not authorized to use this source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the SOURCE.RTF on your install media or the root of your tools installation.
// THE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/*++
Module Name:
phuser.h
Abstract:
Handle of PACKET class definition
--*/
#ifndef __PHUSER_H
#define __PHUSER_H
/*+++
User header fields. (following base header)
+----------------+-------------------------------------------------------+----------+
| FIELD NAME | DESCRIPTION | SIZE |
+----------------+-------------------------------------------------------+----------+
| Source QM | Identifier of the packet originating QM. (GUID) | 16 bytes |
+----------------+-------------------------------------------------------+----------+
| Destination QM | Identifier of the destination QM. (GUID) | 16 bytes |
+----------------+-------------------------------------------------------+----------+
|QM Time-to-Queue| The packet time to reach its | |
| | destination queue (in seconds). | 4 bytes |
+----------------+-------------------------------------------------------+----------+
|QM Time-to-Live | The packet time to live until dequeued by | |
| Delta | application (in seconds, relative to TTQ) | 4 bytes |
+----------------+-------------------------------------------------------+----------+
| Sent Time | Abs time (in seconds) when packet was sent by user. | 4 bytes |
+----------------+-------------------------------------------------------+----------+
| Message ID | The message number. unique per source QM. | 4 bytes |
+----------------+-------------------------------------------------------+----------+
| Flags | A bit map of some of the packet parameters: | 4 bytes |
| | | |
| | | |
| | | |
| | 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 | |
| | 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 | |
| | +-------------------+-+-+-+-----+ | |
| | |0 0 0 0|0 0 0 0|0 0|P|S|E|Resp | | |
| | +-------------------+-+-+-+-----+ | |
| | | |
| | 1 1 1 1 1 1 | |
| | 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 | |
| | +-----+-----+---+-+---+---------+ | |
| | |Admin|Dest |Aud|R|Dlv| Hop | | |
| | +-----+-----+---+-+---+---------+ | |
| | | |
| | Bits | |
| | 0:4 Hop count. Valid values 0 to 15. | |
| | | |
| | 5:6 Delivery mode: | |
| | 0 - Guaranteed | |
| | 1 - Recoverable | |
| | 2 - On-Line | |
| | 3 - Reserved. | |
| | | |
| | 7 Routing mode | |
| | 0 - Reserved | |
| | | |
| | 8 Audit dead letter file | |
| | 9 Audit journal file | |
| | | |
| | 10:12 Destination queue type | |
| | 0 - Illigal value | |
| | 1 - Illigal value | |
| | 2 - Illigal value | |
| | 3 - Illigal value | |
| | 4 - Private at Dest..QM ( 4 bytes) | |
| | 5 - Illigal value | |
| | 6 - GUID (16 bytes) | |
| | 7 - Illigal value | |
| | | |
| | 13:15 Admin Queue type | |
| | 0 - None ( 0 bytes) | |
| | 1 - Same as Dest..Q ( 0 bytes) | |
| | 2 - Illigal value | |
| | 3 - Private at Src...QM ( 4 bytes) | |
| | 4 - Private at Dest..QM ( 4 bytes) | |
| | 5 - Illigal value | |
| | 6 - GUID (16 bytes) | |
| | 7 - Private Queue (20 bytes) | |
| | | |
| | 16:18 Response queue type | |
| | 0 - None ( 0 bytes) | |
| | 1 - Same as Dest..Q ( 0 bytes) | |
| | 2 - Same as Admin.Q ( 0 bytes) | |
| | 3 - Private at Src...QM ( 4 bytes) | |
| | 4 - Private at Dest..QM ( 4 bytes) | |
| | 5 - Private at Admin.QM ( 4 bytes) | |
| | 6 - GUID (16 bytes) | |
| | 7 - Private Queue (20 bytes) | |
| | | |
| | 19 Security section included | |
| | 0 - not included | |
| | 1 - included | |
| | | |
| | 20 Properties section included | |
| | 0 - not included | |
| | 1 - included | |
| | | |
| | 21:31 Reserved. MUST be set to zero. | |
+----------------+-------------------------------------------------------+----------+
| Destination Q | Destination Queue Description |4-16 bytes|
+----------------+-------------------------------------------------------+----------+
| Admin Queue | Admin Queue Description |0-20 bytes|
+----------------+-------------------------------------------------------+----------+
| Response Queue | Response Queue Description |0-20 bytes|
+----------------+-------------------------------------------------------+----------+
---*/
#pragma pack(push, 1)
#pragma warning(disable: 4200) // zero-sized array in struct/union (enabeld later)
//
// struct CUserHeader
//
struct CUserHeader {
private:
enum QType {
qtNone = 0, // 0 - None ( 0 bytes)
qtAdminQ = 1, // 1 - Same as Admin.Q ( 0 bytes)
qtSourceQM = 2, // 2 - Private at Src...QM ( 4 bytes)
qtDestQM = 3, // 3 - Private at Dest..QM ( 4 bytes)
qtAdminQM = 4, // 4 - Private at Admin.QM ( 4 bytes)
qtGUID = 5, // 5 - Public Queue (16 bytes)
qtPrivate = 6, // 6 - Private Queue (20 bytes)
qtDirect = 7 // 7 - Direct Queue (var size)
};
public:
inline CUserHeader(
const GUID* pSourceQM,
const GUID* pDestinationQM,
const QUEUE_FORMAT* pDestinationQueue,
const QUEUE_FORMAT* pAdminQueue,
const QUEUE_FORMAT* pResponseQueue,
ULONG ulMessageID
);
static ULONG CalcSectionSize(
const GUID* pSourceQM,
const GUID* pDestinationQM,
const GUID* pgConnectorType,
const QUEUE_FORMAT* pDestinationQueue,
const QUEUE_FORMAT* pAdminQueue,
const QUEUE_FORMAT* pResponseQueue
);
inline PCHAR GetNextSection(void) const;
inline void SetSourceQM(const GUID* pGUID);
inline const GUID* GetSourceQM(void) const;
inline void SetAddressSourceQM(const TA_ADDRESS *pa);
inline const TA_ADDRESS *GetAddressSourceQM(void) const;
inline void SetDestQM(const GUID* pGUID);
inline const GUID* GetDestQM(void) const;
inline BOOL GetDestinationQueue(QUEUE_FORMAT*) const;
inline BOOL GetAdminQueue(QUEUE_FORMAT*) const;
inline BOOL GetResponseQueue(QUEUE_FORMAT*) const;
inline void SetTimeToLiveDelta(ULONG ulTimeout);
inline ULONG GetTimeToLiveDelta(void) const;
inline void SetSentTime(ULONG ulSentTime);
inline ULONG GetSentTime(void) const;
inline void SetMessageID(const OBJECTID* MessageID);
inline void GetMessageID(OBJECTID * pMessageId) const;
inline void IncHopCount(void);
inline UCHAR GetHopCount(void) const;
inline void SetDelivery(UCHAR bDelivery);
inline UCHAR GetDelivery(void) const;
inline void SetAuditing(UCHAR bAuditing);
inline UCHAR GetAuditing(void) const;
inline void IncludeSecurity(BOOL);
inline BOOL SecurityIsIncluded(void) const;
inline void IncludeXact(BOOL);
inline BOOL IsOrdered(void) const;
inline void IncludeProperty(BOOL);
inline BOOL PropertyIsIncluded(void) const;
inline VOID IncludeSrmp(bool);
inline bool SrmpIsIncluded(VOID) const;
inline VOID IncludeEod(bool);
inline bool EodIsIncluded(VOID) const;
inline VOID IncludeEodAck(bool);
inline bool EodAckIsIncluded(VOID) const;
inline VOID IncludeSoap(bool);
inline bool SoapIsIncluded(VOID) const;
inline void SetConnectorType(const GUID*);
inline BOOL ConnectorTypeIsIncluded(void) const;
inline const GUID* GetConnectorType(void) const;
private:
static int QueueSize(ULONG, const UCHAR*);
inline BOOL GetQueue(const UCHAR*, ULONG, QUEUE_FORMAT*) const;
inline PUCHAR SetDirectQueue(PUCHAR, const WCHAR*);
private:
//
// BEGIN Network Monitor tag
//
GUID m_gSourceQM;
union {
GUID m_gDestQM;
TA_ADDRESS m_taSourceQM;
};
ULONG m_ulTimeToLiveDelta;
ULONG m_ulSentTime;
ULONG m_ulMessageID;
union {
ULONG m_ulFlags;
struct {
ULONG m_bfHopCount : 5;
ULONG m_bfDelivery : 2;
ULONG m_bfRouting : 1;
ULONG m_bfAuditing : 2;
ULONG m_bfDQT : 3;
ULONG m_bfAQT : 3;
ULONG m_bfRQT : 3;
ULONG m_bfSecurity : 1;
ULONG m_bfXact : 1;
ULONG m_bfProperties: 1;
ULONG m_bfConnectorType : 1;
ULONG m_bfMqf : 1;
ULONG m_bfPgm : 1;
ULONG m_bfSrmp : 1;
ULONG m_bfEod : 1;
ULONG m_bfEodAck : 1;
ULONG m_bfSoap : 1;
};
};
UCHAR m_abQueues[0];
//
// END Network Monitor tag
//
};
#pragma warning(default: 4200) // zero-sized array in struct/union
#pragma pack(pop)
/*======================================================================
Function:
Description:
=======================================================================*/
inline
CUserHeader::CUserHeader(
const GUID* pSourceQM,
const GUID* pDestinationQM,
const QUEUE_FORMAT* pDestinationQueue,
const QUEUE_FORMAT* pAdminQueue,
const QUEUE_FORMAT* pResponseQueue,
ULONG ulMessageID
) :
m_gSourceQM(*pSourceQM),
m_gDestQM(*pDestinationQM),
m_ulTimeToLiveDelta(INFINITE),
m_ulSentTime(0),
m_ulMessageID(ulMessageID),
m_ulFlags(0)
{
ASSERT(pSourceQM);
ASSERT(pDestinationQM);
ASSERT(pDestinationQueue);
//
// Set default flags
//
m_bfDelivery = DEFAULT_M_DELIVERY;
m_bfRouting = 0; //reserved
m_bfAuditing = DEFAULT_M_JOURNAL;
m_bfProperties = TRUE;
//
// Set Queue Information.
// Queues that are the same should *point* to same QUEUE_FORMAT
//
PUCHAR pQueue = m_abQueues;
ASSERT(ISALIGN4(pQueue));
//
// Destination Queue
//
switch (pDestinationQueue->GetType())
{
case QUEUE_FORMAT_TYPE_PUBLIC:
//
// Destination Queue is PUBLIC
//
m_bfDQT = qtGUID;
*(GUID*)pQueue = pDestinationQueue->PublicID();
pQueue += sizeof(GUID);
break;
case QUEUE_FORMAT_TYPE_PRIVATE:
//
// Destination Queue is PRIVATE
//
m_bfDQT = qtDestQM;
*(PULONG)pQueue = pDestinationQueue->PrivateID().Uniquifier;
pQueue += sizeof(ULONG);
break;
case QUEUE_FORMAT_TYPE_DIRECT:
//
// Destination queue is direct
//
m_bfDQT = qtDirect;
pQueue = SetDirectQueue(pQueue, pDestinationQueue->DirectID());
break;
default:
//
// Unexpected type, assert with no Warning level 4.
//
ASSERT(pDestinationQueue->GetType() == QUEUE_FORMAT_TYPE_DIRECT);
}
ASSERT(ISALIGN4(pQueue));
//
// Admin Queue
//
if(pAdminQueue != 0)
{
switch (pAdminQueue->GetType())
{
case QUEUE_FORMAT_TYPE_PUBLIC:
//
// Admin Queue is PUBLIC
//
m_bfAQT = qtGUID;
*(GUID*)pQueue = pAdminQueue->PublicID();
pQueue += sizeof(GUID);
break;
case QUEUE_FORMAT_TYPE_PRIVATE:
if(pAdminQueue->PrivateID().Lineage == *pSourceQM)
{
//
// Private Queue in source QM
//
m_bfAQT = qtSourceQM;
*(PULONG)pQueue = pAdminQueue->PrivateID().Uniquifier;
pQueue += sizeof(ULONG);
}
else if(
(pDestinationQueue->GetType() != QUEUE_FORMAT_TYPE_DIRECT) &&
(pAdminQueue->PrivateID().Lineage == *pDestinationQM))
{
//
// Private Queue in Destination QM
//
m_bfAQT = qtDestQM;
*(PULONG)pQueue = pAdminQueue->PrivateID().Uniquifier;
pQueue += sizeof(ULONG);
}
else
{
//
// Private Queue in some other Machine
//
m_bfAQT = qtPrivate;
*(OBJECTID*)pQueue = pAdminQueue->PrivateID();
pQueue += sizeof(OBJECTID);
}
break;
case QUEUE_FORMAT_TYPE_DIRECT:
//
// Destination queue is direct
//
m_bfAQT = qtDirect;
pQueue = SetDirectQueue(pQueue, pAdminQueue->DirectID());
break;
default:
//
// Unexpected type, assert with no Warning level 4.
//
ASSERT(pAdminQueue->GetType() == QUEUE_FORMAT_TYPE_DIRECT);
}
}
ASSERT(ISALIGN4(pQueue));
//
// Response Queue
//
if(pResponseQueue != 0)
{
if(pResponseQueue == pAdminQueue)
{
//
// Same as admin queue (private or guid)
//
m_bfRQT = qtAdminQ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -