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.

187 lines
4.7 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. Module Name:
  4. cotrans.hxx
  5. Abstract:
  6. Common datatypes for connection oriented server transports
  7. based on io completion ports.
  8. Author:
  9. Mario Goertzel [MarioGo]
  10. Revision History:
  11. MarioGo 4/12/1996 Bits 'n pieces
  12. --*/
  13. #ifndef __COTRANS_HXX
  14. #define __COTRANS_HXX
  15. const UINT CO_MIN_RECV = 1024;
  16. //
  17. // Protocol buffer sizes
  18. //
  19. const INT TCP_MAX_SEND = 5840; // Four full ethernet frames
  20. //const INT TCP_MAX_SEND = 1024; // Four full ethernet frames
  21. const INT SPX_MAX_SEND = 5808; // Four full ethernet frames
  22. const INT NMP_MAX_SEND = 4280; // NP(IPX) 1386 + 2*1449/transact.
  23. const INT NBF_MAX_SEND = 4088; // PERF REVIEW
  24. const INT NBT_MAX_SEND = 4088; // PERF REVIEW
  25. const INT NBI_MAX_SEND = 4088; // PERF REVIEW
  26. const INT DSP_MAX_SEND = 4088; // PERF REVIEW: optimize
  27. const INT SPP_MAX_SEND = 4088; // PERF REVIEW
  28. const INT HTTP_MAX_SEND = 4088; // PERF REVIEW
  29. //
  30. // Protocol address and endpoint max sizes including null.
  31. //
  32. const UINT IP_MAXIMUM_PRETTY_NAME = 256; // DNS limit
  33. const UINT IP_MAXIMUM_RAW_NAME = 16; // xxx.xxx.xxx.xxx
  34. const UINT IP_MAXIMUM_ENDPOINT = 6; // 65535
  35. const UINT IPv6_MAXIMUM_RAW_NAME = 38; // FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
  36. const UINT IPX_MAXIMUM_PRETTY_NAME = 48; // MS servers limited to 15, but..
  37. const UINT IPX_MAXIMUM_RAW_NAME = 22; // ~NNNNNNNNAAAAAAAAAAAA
  38. const UINT IPX_MAXIMUM_ENDPOINT = 6; // 65535
  39. const UINT NB_MAXIMUM_NAME = 16; // 16 byte address, last byte is endpoint
  40. const UINT NB_MAXIMUM_ENDPOINT = 4; // 0-255
  41. const UINT NBP_MAXIMUM_NAME = 66; // AT NBP 'computer name'@'zone'
  42. const UINT NBP_MAXIMUM_ENDPOINT = 23; // 32 characters - 'DceDspRpc + null
  43. const UINT VNS_MAXIMUM_NAME = 64; // <31>@<15>@<15> + null
  44. const UINT VNS_MAXIMUM_ENDPOINT = 6; // 65535
  45. const UINT MQ_MAXIMUM_PRETTY_NAME = 256; // See mq.h
  46. const UINT MQ_MAXIMUM_RAW_NAME = 256; //
  47. const UINT MQ_MAXIMUM_ENDPOINT = 128; // Big...
  48. const UINT CDP_MAXIMUM_PRETTY_NAME = 256; // DNS limit
  49. const UINT CDP_MAXIMUM_RAW_NAME = 11; // 2^32
  50. const UINT CDP_MAXIMUM_ENDPOINT = 6; // 65535
  51. //
  52. // Global state
  53. //
  54. //
  55. // List and lock protecting the list of addresses which currently
  56. // don't have a pending connect/listen/accept.
  57. //
  58. extern CRITICAL_SECTION AddressListLock;
  59. extern BASE_ADDRESS *AddressList;
  60. //
  61. // The IO completion port for all async IO.
  62. //
  63. extern HANDLE RpcCompletionPort;
  64. extern HANDLE InactiveRpcCompletionPort;
  65. extern HANDLE *RpcCompletionPorts;
  66. extern long *CompletionPortHandleLoads;
  67. extern UINT gPostSize;
  68. //
  69. // Message parsing stuff
  70. //
  71. struct CONN_RPC_HEADER
  72. {
  73. unsigned char rpc_vers;
  74. unsigned char rpc_vers_minor;
  75. unsigned char ptype;
  76. unsigned char pfc_flags;
  77. unsigned char drep[4];
  78. unsigned short frag_length;
  79. unsigned short auth_length;
  80. unsigned long call_id;
  81. };
  82. typedef unsigned short p_context_id_t;
  83. struct CONN_RPC_FAULT
  84. {
  85. struct CONN_RPC_HEADER common;
  86. unsigned long alloc_hint;
  87. p_context_id_t p_cont_id;
  88. unsigned char alert_count;
  89. unsigned char reserved;
  90. unsigned long status;
  91. unsigned long reserved2;
  92. };
  93. typedef CONN_RPC_HEADER *PCONN_RPC_HEADER;
  94. inline
  95. USHORT MessageLength(PCONN_RPC_HEADER phdr)
  96. {
  97. USHORT length = phdr->frag_length;
  98. if ( (phdr->drep[0] & NDR_LITTLE_ENDIAN) == 0)
  99. {
  100. length = RpcpByteSwapShort(length);
  101. }
  102. return(length);
  103. }
  104. #ifdef _M_IA64
  105. // Used in BASE_CONNECTION::ProcessRead where the second packet in
  106. // a coalesced read may start on unaligned boundary.
  107. inline
  108. USHORT MessageLengthUnaligned(CONN_RPC_HEADER UNALIGNED *phdr)
  109. {
  110. USHORT length = phdr->frag_length;
  111. if ( (phdr->drep[0] & NDR_LITTLE_ENDIAN) == 0)
  112. {
  113. length = RpcpByteSwapShort(length);
  114. }
  115. return(length);
  116. }
  117. #endif // _M_IA64
  118. inline rpc_ptype_t MessageType(PCONN_RPC_HEADER phdr)
  119. {
  120. return( (rpc_ptype_t) phdr->ptype);
  121. }
  122. //
  123. // Common connection oriented functions
  124. //
  125. extern RPC_STATUS CO_SubmitRead(PCONNECTION);
  126. extern RPC_STATUS CO_SubmitSyncRead(PCONNECTION, BUFFER *, PUINT);
  127. //
  128. // Externally (runtime) callable connection oriented functions
  129. //
  130. extern RPC_STATUS RPC_ENTRY CO_Send(RPC_TRANSPORT_CONNECTION, UINT, BUFFER, PVOID);
  131. extern RPC_STATUS RPC_ENTRY CO_Recv(RPC_TRANSPORT_CONNECTION);
  132. extern RPC_STATUS RPC_ENTRY CO_SyncRecv(RPC_TRANSPORT_CONNECTION, BUFFER *, PUINT, DWORD);
  133. // NMP_ functions used externally
  134. extern RPC_STATUS RPC_ENTRY
  135. NMP_Close(
  136. IN RPC_TRANSPORT_CONNECTION,
  137. IN BOOL
  138. );
  139. #endif // __CONTRANS_HXX