Leaked source code of windows server 2003
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.

193 lines
5.1 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. // IPv6 has two long forms:
  36. // FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
  37. // or
  38. // FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:XXX.XXX.XXX.XXX
  39. // The second is the longer, and is 45 characters
  40. const UINT IPv6_MAXIMUM_RAW_NAME = 45;
  41. const UINT IPX_MAXIMUM_PRETTY_NAME = 48; // MS servers limited to 15, but..
  42. const UINT IPX_MAXIMUM_RAW_NAME = 22; // ~NNNNNNNNAAAAAAAAAAAA
  43. const UINT IPX_MAXIMUM_ENDPOINT = 6; // 65535
  44. const UINT NB_MAXIMUM_NAME = 16; // 16 byte address, last byte is endpoint
  45. const UINT NB_MAXIMUM_ENDPOINT = 4; // 0-255
  46. const UINT NBP_MAXIMUM_NAME = 66; // AT NBP 'computer name'@'zone'
  47. const UINT NBP_MAXIMUM_ENDPOINT = 23; // 32 characters - 'DceDspRpc + null
  48. const UINT VNS_MAXIMUM_NAME = 64; // <31>@<15>@<15> + null
  49. const UINT VNS_MAXIMUM_ENDPOINT = 6; // 65535
  50. const UINT MQ_MAXIMUM_PRETTY_NAME = 256; // See mq.h
  51. const UINT MQ_MAXIMUM_RAW_NAME = 256; //
  52. const UINT MQ_MAXIMUM_ENDPOINT = 128; // Big...
  53. const UINT CDP_MAXIMUM_PRETTY_NAME = 256; // DNS limit
  54. const UINT CDP_MAXIMUM_RAW_NAME = 11; // 2^32
  55. const UINT CDP_MAXIMUM_ENDPOINT = 6; // 65535
  56. //
  57. // Global state
  58. //
  59. //
  60. // List and lock protecting the list of addresses which currently
  61. // don't have a pending connect/listen/accept.
  62. //
  63. extern CRITICAL_SECTION AddressListLock;
  64. extern BASE_ADDRESS *AddressList;
  65. //
  66. // The IO completion port for all async IO.
  67. //
  68. extern HANDLE RpcCompletionPort;
  69. extern HANDLE InactiveRpcCompletionPort;
  70. extern HANDLE *RpcCompletionPorts;
  71. extern long *CompletionPortHandleLoads;
  72. extern UINT gPostSize;
  73. //
  74. // Message parsing stuff
  75. //
  76. struct CONN_RPC_HEADER
  77. {
  78. unsigned char rpc_vers;
  79. unsigned char rpc_vers_minor;
  80. unsigned char ptype;
  81. unsigned char pfc_flags;
  82. unsigned char drep[4];
  83. unsigned short frag_length;
  84. unsigned short auth_length;
  85. unsigned long call_id;
  86. };
  87. typedef unsigned short p_context_id_t;
  88. struct CONN_RPC_FAULT
  89. {
  90. struct CONN_RPC_HEADER common;
  91. unsigned long alloc_hint;
  92. p_context_id_t p_cont_id;
  93. unsigned char alert_count;
  94. unsigned char reserved;
  95. unsigned long status;
  96. unsigned long reserved2;
  97. };
  98. typedef CONN_RPC_HEADER *PCONN_RPC_HEADER;
  99. inline
  100. USHORT MessageLength(PCONN_RPC_HEADER phdr)
  101. {
  102. USHORT length = phdr->frag_length;
  103. if ( (phdr->drep[0] & NDR_LITTLE_ENDIAN) == 0)
  104. {
  105. length = RpcpByteSwapShort(length);
  106. }
  107. return(length);
  108. }
  109. #ifdef _M_IA64
  110. // Used in BASE_CONNECTION::ProcessRead where the second packet in
  111. // a coalesced read may start on unaligned boundary.
  112. inline
  113. USHORT MessageLengthUnaligned(CONN_RPC_HEADER UNALIGNED *phdr)
  114. {
  115. USHORT length = phdr->frag_length;
  116. if ( (phdr->drep[0] & NDR_LITTLE_ENDIAN) == 0)
  117. {
  118. length = RpcpByteSwapShort(length);
  119. }
  120. return(length);
  121. }
  122. #endif // _M_IA64
  123. inline rpc_ptype_t MessageType(PCONN_RPC_HEADER phdr)
  124. {
  125. return( (rpc_ptype_t) phdr->ptype);
  126. }
  127. //
  128. // Common connection oriented functions
  129. //
  130. extern RPC_STATUS CO_SubmitRead(PCONNECTION);
  131. extern RPC_STATUS CO_SubmitSyncRead(PCONNECTION, BUFFER *, PUINT);
  132. //
  133. // Externally (runtime) callable connection oriented functions
  134. //
  135. extern RPC_STATUS RPC_ENTRY CO_Send(RPC_TRANSPORT_CONNECTION, UINT, BUFFER, PVOID);
  136. extern RPC_STATUS RPC_ENTRY CO_Recv(RPC_TRANSPORT_CONNECTION);
  137. extern RPC_STATUS RPC_ENTRY CO_SyncRecv(RPC_TRANSPORT_CONNECTION, BUFFER *, PUINT, DWORD);
  138. extern RPC_STATUS RPC_ENTRY CO_SyncRecv_Avrf(RPC_TRANSPORT_CONNECTION, BUFFER *, PUINT, DWORD);
  139. // NMP_ functions used externally
  140. extern RPC_STATUS RPC_ENTRY
  141. NMP_Close(
  142. IN RPC_TRANSPORT_CONNECTION,
  143. IN BOOL
  144. );
  145. #endif // __CONTRANS_HXX