Windows NT 4.0 source code leak
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.

360 lines
7.3 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. osfpcket.hxx
  5. Abstract:
  6. This file contains the packet formats for the OSF Connection Oriented
  7. RPC protocol.
  8. Author:
  9. Michael Montague (mikemon) 23-Jul-1990
  10. Revision History:
  11. 07-Mar-1992 mikemon
  12. Added comments and cleaned it up.
  13. --*/
  14. #ifndef __OSFPCKET_HXX__
  15. #define __OSFPCKET_HXX__
  16. #define OSF_RPC_V20_VERS 5
  17. #define OSF_RPC_V20_VERS_MINOR 0
  18. typedef enum
  19. {
  20. rpc_request = 0,
  21. rpc_response = 2,
  22. rpc_fault = 3,
  23. rpc_bind = 11,
  24. rpc_bind_ack = 12,
  25. rpc_bind_nak = 13,
  26. rpc_alter_context = 14,
  27. rpc_alter_context_resp = 15,
  28. rpc_auth_3 = 16,
  29. rpc_shutdown = 17,
  30. rpc_remote_alert = 18,
  31. rpc_orphaned = 19
  32. } rpc_ptype_t;
  33. #define PFC_FIRST_FRAG 0x01
  34. #define PFC_LAST_FRAG 0x02
  35. #define PFC_PENDING_ALERT 0x04
  36. // 0x08 reserved
  37. #define PFC_CONC_MPX 0x10
  38. #define PFC_DID_NOT_EXECUTE 0x20
  39. #define PFC_MAYBE 0x40
  40. #define PFC_OBJECT_UUID 0x80
  41. typedef struct
  42. {
  43. unsigned short length;
  44. unsigned char port_spec[1];
  45. } port_any_t;
  46. typedef unsigned short p_context_id_t;
  47. typedef struct
  48. {
  49. GUID if_uuid;
  50. unsigned long if_version;
  51. } p_syntax_id_t;
  52. typedef struct
  53. {
  54. p_context_id_t p_cont_id;
  55. unsigned char n_transfer_syn;
  56. unsigned char reserved;
  57. p_syntax_id_t abstract_syntax;
  58. p_syntax_id_t transfer_syntaxes[1];
  59. } p_cont_elem_t;
  60. typedef struct
  61. {
  62. unsigned char n_context_elem;
  63. unsigned char reserved;
  64. unsigned short reserved2;
  65. p_cont_elem_t p_cont_elem[1];
  66. } p_cont_list_t;
  67. typedef unsigned short p_cont_def_result_t;
  68. #define acceptance 0
  69. #define user_rejection 1
  70. #define provider_rejection 2
  71. typedef unsigned short p_provider_reason_t;
  72. #define reason_not_specified 0
  73. #define abstract_syntax_not_supported 1
  74. #define proposed_transfer_syntaxes_not_supported 2
  75. #define local_limit_exceeded 3
  76. typedef unsigned short p_reject_reason_t;
  77. #define reason_not_specified_reject 0
  78. #define temporary_congestion 1
  79. #define local_limit_exceeded_reject 2
  80. #define protocol_version_not_supported 4
  81. #define authentication_type_not_recognized 8
  82. #define invalid_checksum 9
  83. typedef struct
  84. {
  85. p_cont_def_result_t result;
  86. p_provider_reason_t reason;
  87. p_syntax_id_t transfer_syntax;
  88. } p_result_t;
  89. typedef struct
  90. {
  91. unsigned char n_results;
  92. unsigned char reserved;
  93. unsigned short reserved2;
  94. p_result_t p_results[1];
  95. } p_result_list_t;
  96. typedef struct
  97. {
  98. unsigned char major;
  99. unsigned char minor;
  100. } version_t;
  101. typedef version_t p_rt_version_t;
  102. typedef struct
  103. {
  104. unsigned char n_protocols;
  105. p_rt_version_t p_protocols[1];
  106. } p_rt_versions_supported_t;
  107. typedef struct
  108. {
  109. unsigned char rpc_vers;
  110. unsigned char rpc_vers_minor;
  111. unsigned char PTYPE;
  112. unsigned char pfc_flags;
  113. unsigned char drep[4];
  114. unsigned short frag_length;
  115. unsigned short auth_length;
  116. unsigned long call_id;
  117. } rpcconn_common;
  118. typedef struct
  119. {
  120. rpcconn_common common;
  121. unsigned short max_xmit_frag;
  122. unsigned short max_recv_frag;
  123. unsigned long assoc_group_id;
  124. } rpcconn_bind;
  125. #if defined(WIN32RPC) || defined(MAC)
  126. #pragma pack(2)
  127. #endif // WIN32RPC
  128. typedef struct
  129. {
  130. rpcconn_common common;
  131. unsigned short max_xmit_frag;
  132. unsigned short max_recv_frag;
  133. unsigned long assoc_group_id;
  134. unsigned short sec_addr_length;
  135. } rpcconn_bind_ack;
  136. #if defined(WIN32RPC) || defined(MAC)
  137. #pragma pack()
  138. #endif // WIN32RPC
  139. typedef struct
  140. {
  141. rpcconn_common common;
  142. p_reject_reason_t provider_reject_reason;
  143. p_rt_versions_supported_t versions;
  144. } rpcconn_bind_nak;
  145. typedef struct
  146. {
  147. rpcconn_common common;
  148. unsigned char auth_type;
  149. unsigned char auth_level;
  150. #ifndef WIN32RPC
  151. unsigned short pad;
  152. #endif // WIN32RPC
  153. } rpcconn_auth3;
  154. typedef rpcconn_bind rpcconn_alter_context;
  155. typedef struct
  156. {
  157. rpcconn_common common;
  158. unsigned short max_xmit_frag;
  159. unsigned short max_recv_frag;
  160. unsigned long assoc_group_id;
  161. unsigned short sec_addr_length;
  162. unsigned short pad;
  163. } rpcconn_alter_context_resp;
  164. typedef struct
  165. {
  166. rpcconn_common common;
  167. unsigned long alloc_hint;
  168. p_context_id_t p_cont_id;
  169. unsigned short opnum;
  170. } rpcconn_request;
  171. typedef struct
  172. {
  173. rpcconn_common common;
  174. unsigned long alloc_hint;
  175. p_context_id_t p_cont_id;
  176. unsigned char alert_count;
  177. unsigned char reserved;
  178. } rpcconn_response;
  179. typedef struct
  180. {
  181. rpcconn_common common;
  182. unsigned long alloc_hint;
  183. p_context_id_t p_cont_id;
  184. unsigned char alert_count;
  185. unsigned char reserved;
  186. unsigned long status;
  187. unsigned long reserved2;
  188. } rpcconn_fault;
  189. typedef struct
  190. {
  191. unsigned char auth_type;
  192. unsigned char auth_level;
  193. unsigned char auth_pad_length;
  194. unsigned char auth_reserved;
  195. unsigned long auth_context_id;
  196. } sec_trailer;
  197. #define MUST_RECV_FRAG_SIZE 2048
  198. #define NDR_DREP_ASCII 0x00
  199. #define NDR_DREP_EBCDIC 0x01
  200. #define NDR_DREP_CHARACTER_MASK 0x0F
  201. #define NDR_DREP_BIG_ENDIAN 0x00
  202. #define NDR_DREP_LITTLE_ENDIAN 0x10
  203. #define NDR_DREP_ENDIAN_MASK 0xF0
  204. #define NDR_DREP_IEEE 0x00
  205. #define NDR_DREP_VAX 0x01
  206. #define NDR_DREP_CRAY 0x02
  207. #define NDR_DREP_IBM 0x03
  208. #ifdef MAC
  209. #define NDR_LOCAL_CHAR_DREP NDR_DREP_ASCII
  210. #define NDR_LOCAL_INT_DREP NDR_DREP_BIG_ENDIAN
  211. #define NDR_LOCAL_FP_DREP NDR_DREP_IEEE
  212. #else
  213. #define NDR_LOCAL_CHAR_DREP NDR_DREP_ASCII
  214. #define NDR_LOCAL_INT_DREP NDR_DREP_LITTLE_ENDIAN
  215. #define NDR_LOCAL_FP_DREP NDR_DREP_IEEE
  216. #endif
  217. /*++
  218. Routine Description:
  219. This macro determines whether or not we need to do endian data
  220. conversion.
  221. Argument:
  222. drep - Supplies the four byte data representation.
  223. Return Value:
  224. A value of non-zero indicates that endian data conversion needs to
  225. be performed.
  226. --*/
  227. #define DataConvertEndian(drep) \
  228. ( (drep[0] & NDR_DREP_ENDIAN_MASK) != NDR_LOCAL_INT_DREP )
  229. /*++
  230. Routine Description:
  231. This macro determines whether or not we need to do character data
  232. conversion.
  233. Argument:
  234. drep - Supplies the four byte data representation.
  235. Return Value:
  236. A value of non-zero indicates that character data conversion needs to
  237. be performed.
  238. --*/
  239. #define DataConvertCharacter(drep) \
  240. ( (drep[0] & NDR_DREP_CHARACTER_MASK) != NDR_LOCAL_CHAR_DREP)
  241. void
  242. ConstructPacket (
  243. IN OUT rpcconn_common PAPI * Packet,
  244. IN unsigned char PacketType,
  245. IN unsigned int PacketLength
  246. );
  247. RPC_STATUS
  248. ValidatePacket (
  249. IN rpcconn_common PAPI * Packet,
  250. IN unsigned int PacketLength
  251. );
  252. #define ByteSwapLong(Value) \
  253. Value = ( (((Value) & 0xFF000000) >> 24) \
  254. | (((Value) & 0x00FF0000) >> 8) \
  255. | (((Value) & 0x0000FF00) << 8) \
  256. | (((Value) & 0x000000FF) << 24))
  257. #define ByteSwapShort(Value) \
  258. Value = ( (((Value) & 0x00FF) << 8) \
  259. | (((Value) & 0xFF00) >> 8))
  260. void
  261. ByteSwapSyntaxId (
  262. IN p_syntax_id_t PAPI * SyntaxId
  263. );
  264. void
  265. ConvertStringEbcdicToAscii (
  266. IN unsigned char * String
  267. );
  268. extern unsigned long __RPC_FAR
  269. MapToNcaStatusCode (
  270. IN RPC_STATUS RpcStatus
  271. );
  272. extern RPC_STATUS __RPC_FAR
  273. MapFromNcaStatusCode (
  274. IN unsigned long NcaStatus
  275. );
  276. #ifdef DEBUGRPC
  277. #ifndef NTENV
  278. extern void
  279. DumpPacket ( // Dump a packet to standard output.
  280. IN rpcconn_common PAPI * Packet
  281. );
  282. #endif // NTENV
  283. #endif // DEBUGRPC
  284. #endif // __OSFPCKET_HXX__