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.

2617 lines
62 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. Module Name:
  4. RpcTrans.hxx
  5. Abstract:
  6. Interface to transport (network protocol) used by the RPC runtime.
  7. Each protocol supported by RPC must implement this interface.
  8. Environment:
  9. User mode Windows NT, Windows 95 and PPC Macintosh.
  10. Author:
  11. Mario Goertzel [MarioGo]
  12. Revision History:
  13. MarioGo 10/22/1996 Based on old, sync transport interface
  14. EdwardR 07/09/1997 Added support for message transports (Falcon).
  15. --*/
  16. #ifndef __RPC_TRANS_HXX
  17. #define __RPC_TRANS_HXX
  18. const INT INVALID_PROTOCOL_ID = 0;
  19. const INT TCP = 1;
  20. #ifdef SPX_ON
  21. const INT SPX = 2;
  22. #endif
  23. const INT NMP = 3;
  24. #ifdef NETBIOS_ON
  25. const INT NBF = 4; // Netbios flavors
  26. const INT NBT = 5;
  27. const INT NBI = 6;
  28. #endif
  29. #ifdef APPLETALK_ON
  30. const INT DSP = 7;
  31. #endif
  32. const INT LRPC = 8;
  33. const INT HTTP = 9;
  34. const INT UDP = 10;
  35. const INT IPX = 11;
  36. const INT CDP = 12; // Cluster Datagram Protocol
  37. #ifdef NCADG_MQ_ON
  38. const INT MSMQ = 13;
  39. #endif
  40. const INT TCP_IPv6 = 14;
  41. const INT HTTPv2 = 15; // this is a special ID that does not go into
  42. // the usual ID scheme. It is used in few places
  43. // to differentiate b/n HTTP and HTTP2
  44. // Used to print lots of transport debug spew.
  45. //#define MAJOR_TRANS_DEBUG
  46. // The runtime and transport DLL must share the same version number
  47. const unsigned short RPC_TRANSPORT_INTERFACE_VERSION = 0x2004;
  48. #if defined(_RPCRT4_) && !defined(_RPCTRANS_)
  49. typedef PVOID BUFFER;
  50. #else
  51. typedef PUCHAR BUFFER;
  52. #endif
  53. //
  54. // When an IO completes an event it returned to the runtime.
  55. // Usually it will be one of connection/datagram | one of client/server
  56. // | one of send/receive. Example CONNECTION|SERVER|SEND indicates
  57. // that a send completed on a server-side connection.
  58. //
  59. //
  60. typedef UINT RPC_TRANSPORT_EVENT;
  61. const UINT CONNECTION = 0x0;
  62. const UINT DATAGRAM = 0x1;
  63. const UINT CLIENT = 0x0;
  64. const UINT SERVER = 0x4;
  65. const UINT SEND = 0x0;
  66. const UINT RECEIVE = 0x8;
  67. // there is some subtle namespace partitioning here. Complex_T will
  68. // be used only by HTTP2's connections, which we know are not
  69. // datagram or address. Therefore, the values 17 and 18, used
  70. // as RuntimePosted and NewAddress do not conflict with Complex_T
  71. // connections
  72. const UINT COMPLEX_T = 0x10;
  73. // Internal to transport - these bits should not be
  74. // set in any events which reach the RPC runtime.
  75. const UINT TRANSPORT = 0x10;
  76. const UINT ADDRESS = 0x2;
  77. // Masks for switching on a given event flag
  78. const UINT PROTO_MASK = 0x0003;
  79. const UINT TYPE_MASK = 0x0004;
  80. const UINT IO_MASK = 0x0008;
  81. // Event posted by the RPC runtime via POST_EVENT
  82. // and the context is whatever context the runtime
  83. // passed into POST_EVENT
  84. const UINT RuntimePosted = 0x11;
  85. const UINT NewAddress = 0x12;
  86. const UINT LastRuntimeConstant = COMPLEX_T | SERVER | RECEIVE;
  87. // Predefine events - these are the only combinations
  88. // that the transport interface can return.
  89. const UINT ConnectionServerReceive = CONNECTION | SERVER | RECEIVE;
  90. const UINT ConnectionServerSend = CONNECTION | SERVER | SEND;
  91. const UINT ConnectionClientReceive = CONNECTION | CLIENT | RECEIVE;
  92. const UINT ConnectionClientSend = CONNECTION | CLIENT | SEND;
  93. const UINT DatagramServerReceive = DATAGRAM | SERVER | RECEIVE;
  94. const UINT DatagramServerSend = DATAGRAM | SERVER | SEND;
  95. const UINT DatagramClientReceive = DATAGRAM | CLIENT | RECEIVE;
  96. const UINT DatagramClientSend = DATAGRAM | CLIENT | SEND;
  97. // Protocol or Endpoint ID's. These are associated with
  98. // the endpoint entry in the tower and are what the runtime
  99. // sees last before calling the transport interface.
  100. const INT TCP_TOWER_ID = 0x07; // TCP/IP protocol
  101. const INT UDP_TOWER_ID = 0x08; // UDP/IP protocol
  102. const INT LRPC_TOWER_ID = 0x09; // Used for debugging only - never goes
  103. // on the wire or in any tower. We just
  104. // use this number to be able to uniquely
  105. // identify all protocols with a single
  106. // number.
  107. const INT CDP_TOWER_ID = 0x00; // CDP/IP protocol
  108. #ifdef SPX_ON
  109. const INT SPX_TOWER_ID = 0x0C; // Netware SPX protocol
  110. #endif
  111. #ifdef IPX_ON
  112. const INT IPX_TOWER_ID = 0x0E; // Netware IPX protocol
  113. #endif
  114. const INT NMP_TOWER_ID = 0x0F; // Microsoft (SMB) named pipes
  115. #ifdef NETBIOS_ON
  116. const INT NB_TOWER_ID = 0x12; // Netbios protocol
  117. #endif
  118. #ifdef APPLETALK_ON
  119. const INT DSP_TOWER_ID = 0x16; // Appletalk datastream protocol
  120. const INT DDP_TOWER_ID = 0x17; // Appletalk datagram protocol
  121. #endif
  122. //const INT SPP_TOWER_ID = 0x1A; // Banyan stream protocol - no longer supported
  123. #ifdef NCADG_MQ_ON
  124. const INT MQ_TOWER_ID = 0x1D; // Falcon protocol
  125. #endif
  126. const INT HTTP_TOWER_ID = 0x1F; // HTTP protocol
  127. typedef HANDLE RPC_TRANSPORT_CONNECTION; // Server or client connection
  128. typedef HANDLE RPC_TRANSPORT_ADDRESS; // Server listening object
  129. extern "C" {
  130. typedef void (*RUNTIME_EVENT_FN)(PVOID Context);
  131. typedef RPC_STATUS
  132. (RPC_ENTRY * PROCESS_CALLS)
  133. (
  134. IN INT Timeout,
  135. OUT RPC_TRANSPORT_EVENT *pEvent,
  136. OUT RPC_STATUS *pEventStatus,
  137. OUT PVOID *ppEventContext,
  138. OUT UINT *pBufferLength,
  139. OUT BUFFER *pBuffer,
  140. OUT PVOID *ppSourceContext
  141. );
  142. /*++
  143. Routine Description:
  144. This routine waits for any async IO to complete for all protocols
  145. within a transport DLL. It maybe called by multiple threads at a
  146. time. A minimum of one thread should always be calling this function
  147. for each DLL.
  148. Note: async clients with no outstanding IO may allow the
  149. last thread to timeout and only call this function again
  150. when a new call is started.
  151. Note: During calls to this API in connection oriented servers
  152. a callback to I_RpcTransServerNewConnection() may occur.
  153. Arguments:
  154. Timeout - Milliseconds to block or INFINITE (-1)
  155. pEvent - Indicates what sort of IO event has completed (finished)
  156. pEventStatus - Indicates the status of the IO event.
  157. RPC_S_OK - IO completed normally
  158. RPC_P_RECEIVE_FAILED - Some kind of receive failed.
  159. RPC_P_SEND_FAILED - CO_SEND failed and the connection has been aborted.
  160. RPC_P_OVERSIZED_PACKET - Datagram received a packet that was larger
  161. then the buffer size. (Partial datagram in buffer).
  162. RPC_P_ENDPOINT_CLOSED - ASync datagram client endpoint closed.
  163. RPC_P_CONNECTION_CLOSED - Transport closed a connection due
  164. to some internal resource issue.
  165. ppEventContext -
  166. An RPC_TRANSPORT_CONNECTION object for all Connection events
  167. An RPC_TRANSPORT_ENDPOINT for Datagram receive events.
  168. pBuffer - Will contain the sent or received buffer
  169. pBufferLength - The size of the data sent/received in pBuffer
  170. ppSourceContext - For connection sends this is SendContext parameter
  171. passed into the Send() call.
  172. For datagram this is the sources address (DG_TRANSPORT_ADDRESS)
  173. of the packet.
  174. Return Value:
  175. RPC_S_OK - IO completed successfully or with an error. See pEventStatus.
  176. RPC_P_TIMEOUT - Timeout period expired no IP completed.
  177. --*/
  178. typedef VOID
  179. (RPC_ENTRY * LISTEN_FOR_PNP_NOTIFICATIONS)
  180. (
  181. );
  182. typedef VOID
  183. (RPC_ENTRY * START_PNP_NOTIFICATIONS)
  184. (
  185. );
  186. typedef RPC_STATUS
  187. (RPC_ENTRY *TOWER_CONSTRUCT)
  188. (
  189. IN PCHAR Protseq,
  190. IN PCHAR NetworkAddress,
  191. IN PCHAR Endpoint,
  192. OUT PUSHORT Floors,
  193. OUT PULONG ByteCount,
  194. OUT PUCHAR *Tower
  195. );
  196. /*++
  197. Routine Description:
  198. Constructs a OSF tower for the protocol, network address and endpoint.
  199. Arguments:
  200. Protseq - The protocol for the tower.
  201. NetworkAddress - The network address to be encoded in the tower.
  202. Endpoint - The endpoint to be encoded in the tower.
  203. Floors - The number of twoer floors it encoded into the tower.
  204. ByteCount - The size of the "upper-transport-specific" tower that
  205. is encoded by this call.
  206. Tower - The encoded "upper tower" that is encoded by this call.
  207. This caller is responsible for freeing this memory.
  208. Return Value:
  209. RPC_S_OK
  210. RPC_S_OUT_OF_MEMORY
  211. RPC_S_OUT_OF_RESOURCES
  212. --*/
  213. typedef RPC_STATUS
  214. (RPC_ENTRY *TOWER_EXPLODE)
  215. (
  216. IN BYTE *Tower,
  217. IN BYTE *UpperBound,
  218. IN ULONG RemainingFloors,
  219. OUT PCHAR *Protseq,
  220. OUT PCHAR *NetworkAddress,
  221. OUT PCHAR *Endpoint
  222. );
  223. /*++
  224. Routine Description:
  225. Decodes an OSF transport "upper tower" for the runtime.
  226. Arguments:
  227. Tower - The encoded "upper tower" to decode
  228. UpperBound - the first invalid byte after the end of the buffer
  229. RemainingFloors - the number of floors remaning.
  230. Protseq - The protseq encoded in the Tower
  231. Does not need to be freed by the caller.
  232. NetworkAddress - The network address encoded in the Tower
  233. Must be freed by the caller.
  234. Endpoint - The endpoint encoded in the Tower.
  235. Must be freed by the caller.
  236. Return Value:
  237. RPC_S_OK
  238. RPC_S_OUT_OF_MEMORY
  239. --*/
  240. typedef RPC_STATUS
  241. (RPC_ENTRY *POST_EVENT)
  242. (
  243. IN DWORD Type,
  244. IN PVOID Context
  245. );
  246. /*++
  247. Routine Description:
  248. Posts an event to the completion port. This will complete
  249. with an event type of RuntimePosted, event status RPC_S_OK
  250. and event context of Context.
  251. Arguments:
  252. Context - Context associated with the event
  253. Return Value:
  254. RPC_S_OK
  255. RPC_S_OUT_OF_RESOURCES
  256. RPC_S_OUT_OF_MEMORY
  257. --*/
  258. #pragma warning(push)
  259. #pragma warning(disable:4200) // nonstandard extension: zero-length array
  260. typedef struct
  261. {
  262. UINT Count;
  263. RPC_CHAR *NetworkAddresses[];
  264. } NETWORK_ADDRESS_VECTOR;
  265. #pragma warning(pop) // nonstandard extension: zero-length array
  266. typedef NETWORK_ADDRESS_VECTOR *
  267. (RPC_ENTRY *SERVER_GET_NETWORK_ADDRESS_VECTOR)
  268. (
  269. IN RPC_TRANSPORT_ADDRESS ThisAddress
  270. );
  271. /*++
  272. Routine Description:
  273. Returns an array of network addresses listened-on by the
  274. transport address.
  275. Arguments:
  276. ThisAddress - Transport address to retrieve the array from.
  277. Return Value:
  278. The vecrot of addresses listened-on by the transport address object.
  279. --*/
  280. } // extern "C"
  281. // This is the "base class" for each of the two types of transport
  282. // interfaces, connection and datagram. Each transport interface DLL
  283. // supports these common function and has only one implementation of
  284. // the ProcessCalls method.
  285. //
  286. // NOTE: Any changes here MUST also be made in BOTH the datagram and connection
  287. // specific transport interface definitions.
  288. struct RPC_TRANSPORT_INTERFACE_HEADER
  289. {
  290. UINT TransInterfaceVersion; // Compiled in version
  291. USHORT TransId; // OSF DCE Tower ID for the protocol (eg TCP)
  292. USHORT TransAddrId; // OSF DCE Tower ID for the address format (eg IP)
  293. const RPC_CHAR *ProtocolSequence; // DCE RPC Protseq
  294. const PCHAR WellKnownEndpoint; // Well known endpoint mapper endpoint
  295. PROCESS_CALLS ProcessCalls;
  296. #ifndef NO_PLUG_AND_PLAY
  297. START_PNP_NOTIFICATIONS PnpNotify;
  298. LISTEN_FOR_PNP_NOTIFICATIONS PnpListen;
  299. #endif
  300. TOWER_CONSTRUCT TowerConstruct;
  301. TOWER_EXPLODE TowerExplode;
  302. POST_EVENT PostEvent ;
  303. BOOL fDatagram;
  304. SERVER_GET_NETWORK_ADDRESS_VECTOR GetNetworkAddressVector;
  305. };
  306. //
  307. // Connection specific interface
  308. //
  309. extern "C" {
  310. typedef RPC_STATUS
  311. (RPC_ENTRY *CO_CLIENT_INITIALIZE)
  312. (
  313. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  314. IN RPC_CHAR * NetworkAddress,
  315. IN RPC_CHAR * NetworkOptions,
  316. IN BOOL fAsync
  317. );
  318. typedef void
  319. (RPC_ENTRY *CO_CLIENT_INITCOMPLETE)
  320. (
  321. IN RPC_TRANSPORT_CONNECTION ThisConnection
  322. );
  323. typedef RPC_STATUS
  324. (RPC_ENTRY *CO_CLIENT_OPEN)
  325. (
  326. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  327. IN RPC_CHAR * ProtocolSequence,
  328. IN RPC_CHAR * NetworkAddress,
  329. IN RPC_CHAR * Endpoint,
  330. IN RPC_CHAR * NetworkOptions,
  331. IN UINT ConnTimeout,
  332. IN UINT SendBufferSize,
  333. IN UINT RecvBufferSize,
  334. IN OUT PVOID ResolverHint,
  335. IN BOOL fHintInitialized,
  336. IN ULONG CallTimeout,
  337. IN ULONG AdditionalTransportCredentialsType, OPTIONAL
  338. IN void *AdditionalCredentials OPTIONAL
  339. );
  340. /*++
  341. Routine Description:
  342. Opens a new client connection to the server specified.
  343. Arguments:
  344. ThisConnection - Pointer to uninitialzied memory large enough
  345. for the transports connection object. Used in future
  346. calls on the same connection.
  347. ProtocolSequence -
  348. NetworkAddress -
  349. Endpoint -
  350. NetworkOptions - (Optional)
  351. ConnTimeout - connection timeout in runtime units
  352. SendBufferSize -
  353. RecvBufferSize - (Both optional) Specifies the size of the send/recv
  354. transport buffers (or window).
  355. ResolverHint - storage (of ResolveHintSize in the interface) for transport.
  356. state.
  357. fHintInitialize - If TRUE, the ResolveHint has previous passed into
  358. open and the runtime wants to connect to the same server as it
  359. connected to the first time.
  360. If FALSE, the ResolveHint is not initialized and the runtime is
  361. willing to connect to any server.
  362. CallTimeout - the call timeout in milliseconds
  363. TransportCredentials - optional transport credentials
  364. Return Value:
  365. RPC_S_OK - Success
  366. RPC_S_OUT_OF_MEMORY
  367. RPC_S_OUT_OF_RESOURCES
  368. RPC_S_INVALID_NETWORK_OPTIONS
  369. RPC_S_SERVER_UNAVAILABLE
  370. RPC_S_INVALID_ENDPOINT_FORMAT
  371. RPC_S_ACCESS_DENIED
  372. RPC_S_CALL_CANCELLED
  373. --*/
  374. typedef RPC_STATUS
  375. (RPC_ENTRY *CO_ABORT)
  376. (
  377. IN RPC_TRANSPORT_CONNECTION ThisConnection
  378. );
  379. /*++
  380. Routine Description:
  381. This is the first step is destroying a client or server connection.
  382. This can be called at most once on any connection. Call this function
  383. guarantees that all outstanding IO on the connection will complete
  384. either successfully or with an error.
  385. Note: Sometimes when a transport call fails it will abort the connection.
  386. Arguments:
  387. ThisConnection - The connection to abort.
  388. Return Value:
  389. RPC_S_OK
  390. --*/
  391. typedef RPC_STATUS
  392. (RPC_ENTRY *CO_CLOSE)
  393. (
  394. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  395. IN BOOL fDontFlush
  396. );
  397. /*++
  398. Routine Description:
  399. Closes a connection which has not outstanding IO pending on it.
  400. This must be exactly once on every connection opened.
  401. If a connection has outstanding IO then call Abort() and wait
  402. for the IO to fail.
  403. Arguments:
  404. ThisConnection - The connection to cleanup.
  405. Return Value:
  406. RPC_S_OK
  407. --*/
  408. typedef RPC_STATUS
  409. (RPC_ENTRY *CO_SEND)
  410. (
  411. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  412. IN UINT Length,
  413. IN BUFFER Buffer,
  414. IN PVOID SendContext
  415. );
  416. /*++
  417. Routine Description:
  418. Submits a send of the buffer on the connection. Will complete with
  419. ConnectionServerSend or ConnectionClientSend event either when
  420. the data has been sent on the network or when the send fails.
  421. Arguments:
  422. ThisConnection - The connection to send the data on.
  423. Length - The length of the data to send.
  424. Buffer - The data to send.
  425. SendContext - A buffer of at least SendContextSize bytes
  426. which will be used during the call and returned
  427. when the send completes.
  428. Return Value:
  429. RPC_S_OK
  430. RPC_S_OUT_OF_MEMORY - Connection valid
  431. RPC_S_OUT_OF_RESOURCES - Connection valid
  432. RPC_P_SEND_FAILED - Connection aborted
  433. --*/
  434. typedef RPC_STATUS
  435. (RPC_ENTRY *CO_RECV)
  436. (
  437. IN RPC_TRANSPORT_CONNECTION ThisConnection
  438. );
  439. /*++
  440. Routine Description:
  441. Submits a receive on the connection. Will complete with a
  442. ConnectionServerReceive or ConnectionClientReceive event
  443. either when a PDU arrives or when the receive fails.
  444. Arguments:
  445. ThisConnection - The connection to wait on.
  446. Return Value:
  447. RPC_P_IO_PENDING - Success
  448. RPC_P_RECEIVE_FAILED - Connection aborted.
  449. --*/
  450. typedef RPC_STATUS
  451. (RPC_ENTRY *CO_SYNC_SEND)
  452. (
  453. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  454. IN UINT Length,
  455. IN BUFFER Buffer,
  456. IN BOOL fDisableShutdownCheck,
  457. IN BOOL fDisableCancelCheck,
  458. IN ULONG Timeout
  459. );
  460. /*++
  461. Routine Description:
  462. Transmits the buffer (PDU) to the other side of the connection. May
  463. block while the data is transmitted.
  464. Arguments:
  465. ThisConnection - The connection to send the data on.
  466. Length - The length of the data to send.
  467. Buffer - The data to send.
  468. fDisableShutdownCheck - Normally FALSE, when true this disables
  469. the transport check for async shutdown PDUs. This is needed
  470. when sending the third leg.
  471. Return Value:
  472. RPC_S_OK
  473. RPC_S_OUT_OF_MEMORY - Connection valid
  474. RPC_S_OUT_OF_RESOURCES - Connection valid
  475. RPC_P_SEND_FAILED - Connection aborted
  476. --*/
  477. typedef RPC_STATUS
  478. (RPC_ENTRY *CO_CLIENT_SYNC_SEND_RECV)
  479. (
  480. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  481. IN UINT InputBufferSize,
  482. IN BUFFER InputBuffer,
  483. OUT PUINT OutputBufferSize,
  484. OUT BUFFER *pOutputBuffer
  485. );
  486. /*++
  487. Routine Description:
  488. Sends a request to the server of the connection and waits for
  489. a reply. This is the same as calling CO_SYNC_SEND followed
  490. by CO_SYNC_RECV but might be faster. It is assumed that if
  491. this function is available from the transport it will always
  492. be used.
  493. Arguments:
  494. ThisConnection - The client connection to transfer the data on.
  495. InputBufferSize - The size in bytes of the data in InputBuffer
  496. InputBuffer - The data to send to the server
  497. OutputBufferSize - On output, the size of the reply message.
  498. pOutputBuffer - On output, the reply PDU.
  499. Return Value:
  500. RPC_S_OK - Success
  501. RPC_P_SEND_FAILED - Connection aborted, no data transmitted.
  502. RPC_P_RECEIVE_FAILED - Connection aborted, data may have been transmitted.
  503. --*/
  504. typedef RPC_STATUS
  505. (RPC_ENTRY *CO_CLIENT_SYNC_RECV)
  506. (
  507. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  508. OUT BUFFER *pBuffer,
  509. OUT PUINT pBufferSize,
  510. IN ULONG Timeout
  511. );
  512. /*++
  513. Routine Description:
  514. Receive the next PDU to arrive at the connection.
  515. Arguments:
  516. ThisConnection - The connection to read from.
  517. pBuffer - If successful, points to a buffer containing the next PDU.
  518. pBufferSize - If successful, contains the length of the message.
  519. dwTimeout - the amount of time to wait for the receive. If -1, we wait
  520. infinitely.
  521. Return Value:
  522. RPC_S_OK
  523. RPC_S_OUT_OF_MEMORY - Connection not aborted, no data received.
  524. RPC_S_OUT_OF_RESOURCES - Connection not aborted, no data received.
  525. RPC_P_RECEIVE_FAILED - Connection aborted.
  526. RPC_P_CONNECTION_SHUTDOWN - Graceful close from server, connection aborted.
  527. RPC_S_CALL_CANCELLED - Cancel event signaled and wait timed out; connection aborted.
  528. --*/
  529. // Keepalive timeout can be specified either in the RPC's runtime scale
  530. // of a relative time from 0 to 10 (for the client) or as the number of
  531. // milliseconds between keepalive packets (for the server).
  532. enum KEEPALIVE_TIMEOUT_UNITS
  533. {
  534. tuMilliseconds,
  535. tuRuntime
  536. };
  537. union KEEPALIVE_TIMEOUT
  538. {
  539. ULONG Milliseconds;
  540. ULONG RuntimeUnits;
  541. };
  542. typedef RPC_STATUS
  543. (RPC_ENTRY *CO_TURN_ON_OFF_KEEPALIVES)
  544. (
  545. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  546. IN BOOL TurnOn,
  547. IN BOOL bProtectIO,
  548. IN KEEPALIVE_TIMEOUT_UNITS Units,
  549. IN OUT KEEPALIVE_TIMEOUT KATime,
  550. IN ULONG KAInterval /*= 5000*/ OPTIONAL
  551. );
  552. /*++
  553. Routine Description:
  554. Turns on or off keep alives at a rate appropriate for that transport. Used
  555. to prevent hangs of async calls.
  556. Arguments:
  557. ThisConnection - The connection to turn keep alives on on.
  558. TurnOn - if non-zero, keep alives are turned on. If zero, keep alives
  559. are turned off.
  560. bProtectIO - Determines whether the setting the timeout will be protected with
  561. a call to StartingOtherIO. TRUE on the server, FALSE on the client.
  562. Units - is the itmeout specified in the relative scale or in milliseconds
  563. KATime - how much to wait before sending first keep alive
  564. KAInterval - the keepalive interval
  565. Return Value:
  566. RPC_S_OK or RPC_S_* / Win32 errors on failure
  567. --*/
  568. typedef void
  569. (RPC_ENTRY *CO_FREE_RESOLVER_HINT)
  570. (
  571. IN void *ResolverHint
  572. );
  573. /*++
  574. Routine Description:
  575. Gives the transport a chance to free any data associated with the resolver hint.
  576. Arguments:
  577. ResolverHint - pointer to the resolver hint
  578. Return Value:
  579. --*/
  580. typedef RPC_STATUS
  581. (RPC_ENTRY *CO_COPY_RESOLVER_HINT)
  582. (
  583. IN void *TargetResolverHint,
  584. IN void *SourceResolverHint,
  585. IN BOOL SourceWillBeAbandoned
  586. );
  587. /*++
  588. Routine Description:
  589. Tells the transport to copy the resolver hint from Source to Target
  590. Arguments:
  591. TargetResolverHint - pointer to the target resolver hint
  592. SourceResolverHint - pointer to the source resolver hint
  593. SourceWillBeAbandoned - non-zero if the source hint was in temporary
  594. location and will be abandoned. Zero otherwise.
  595. Return Value:
  596. if SourceWillBeAbandoned is specified, this function is guaranteed
  597. to return RPC_S_OK. Otherwise, it may return RPC_S_OUT_OF_MEMORY as well.
  598. --*/
  599. typedef int
  600. (RPC_ENTRY *CO_COMPARE_RESOLVER_HINT)
  601. (
  602. IN void *ResolverHint1,
  603. IN void *ResolverHint2
  604. );
  605. /*++
  606. Routine Description:
  607. Tells the transport to compare the given 2 resolver hints
  608. Arguments:
  609. ResolverHint1 - pointer to the first resolver hint
  610. ResolverHint2 - pointer to the second resolver hint
  611. Return Value:
  612. (same semantics as memcmp)
  613. 0 - the resolver hints are equal
  614. non-zero - the resolver hints are not equal
  615. --*/
  616. typedef RPC_STATUS
  617. (RPC_ENTRY *CO_SET_LAST_BUFFER_TO_FREE)
  618. (
  619. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  620. IN void *Buffer
  621. );
  622. /*++
  623. Routine Description:
  624. Before the last send runtime may call this to tell the transport
  625. what buffer to free when the send is done.
  626. Arguments:
  627. ThisConnection - connection to act on.
  628. Buffer - the buffer to free
  629. Return Value:
  630. RPC_S_OK - the value was accepted.
  631. RPC_S_CANNOT_SUPPORT - the transport doesn't support this functionality.
  632. If this value is returned, ownership of the buffer remains with the
  633. transport.
  634. --*/
  635. #define MAX_PROTOCOLS 16
  636. typedef RPC_STATUS
  637. (RPC_ENTRY *CO_SERVER_LISTEN)
  638. (
  639. IN RPC_TRANSPORT_ADDRESS ThisAddress,
  640. IN RPC_CHAR *NetworkAddress,
  641. IN OUT RPC_CHAR **ppEndpoint,
  642. IN UINT PendingQueueSize,
  643. IN OPTIONAL PVOID SecurityDescriptor,
  644. IN ULONG EndpointFlags,
  645. IN ULONG NICFlags
  646. );
  647. /*++
  648. Routine Description:
  649. This routine allocates a transport endpoint (port/socket/pipe) to
  650. receive new client connections on. If successful a call to
  651. CompleteListen() will cause new connection callbacks to the
  652. RPC runtime for the newly created address.
  653. Arguments:
  654. ThisAddress - A pointer to uninitialized memory large enough to
  655. hold the transport address object.
  656. pEndpoint - The endpoint to listen on. Pointer to NULL for
  657. dynamic endpoints. Does not need to be freed by the
  658. RPC runtime.
  659. PendingQueueSize - A hint passed into the RPC runtime as the
  660. MaxCalls parameter to RpcServerUse*Protseq*(). It is intended
  661. as a hint in buffer allocations for new connections.
  662. SecurityDescriptor - NT security descriptor passed into
  663. RpcServerUseProtseq*. Optional, only by named pipes.
  664. EndpointFlags - Application flags passed into RPC via
  665. RpcServerUseProtseq*Ex.
  666. NICFlags - Application flags passed into RPC via
  667. RpcServerUseProtseq*Ex.
  668. ppNetworkAddressVector - A vector of network addresses listened
  669. to by the call. This parameter does not need to freed, will
  670. not and should not be changed.
  671. Return Value:
  672. RPC_S_OK - Success
  673. RPC_S_OUT_OF_MEMORY
  674. RPC_S_OUT_OF_RESOURCES
  675. RPC_S_INVALID_ENDPOINT_FORMAT
  676. RPC_S_INVALID_SECURITY_DESC
  677. RPC_S_CANT_CREATE_ENDPOINT
  678. --*/
  679. typedef void
  680. (RPC_ENTRY *CO_SERVER_ABORT_LISTEN)
  681. (
  682. IN RPC_TRANSPORT_ADDRESS ThisAddress
  683. );
  684. /*++
  685. Routine Description:
  686. Destroys on a newly, successfully created RPC_TRANS_ADDRESS which
  687. for some reason known only to the runtime will not be used.
  688. Arguments:
  689. ThisAddress - The address to destroy.
  690. Return Value:
  691. Must succeed.
  692. --*/
  693. typedef void
  694. (RPC_ENTRY *CO_SERVER_COMPLETE_LISTEN)
  695. (
  696. IN RPC_TRANSPORT_ADDRESS ThisAddress
  697. );
  698. /*++
  699. Routine Description:
  700. Called when the runtime is actually ready for new connection
  701. callbacks to start on the address. This call cannot fail since
  702. the runtime can't undo the operation at this point.
  703. Arguments:
  704. ThisAddress - The address the runtime is now ready to receive
  705. connections on.
  706. Return Value:
  707. Must succeed.
  708. --*/
  709. typedef RPC_STATUS
  710. (RPC_ENTRY *CO_SERVER_QUERY_ADDRESS)
  711. (
  712. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  713. OUT RPC_CHAR **pClientAddress
  714. );
  715. /*++
  716. Routine Description:
  717. Returns the raw network address of the client to the connection.
  718. Arguments:
  719. ThisConnection - A server connection object.
  720. pClientAddress - Pointer to a unicode string allocated
  721. via I_RpcAllocate from the transport interface.
  722. Return Value:
  723. RPC_S_OK
  724. RPC_S_OUT_OF_MEMORY
  725. RPC_S_OUT_OF_RESOURCES
  726. --*/
  727. typedef RPC_STATUS
  728. (RPC_ENTRY *CO_SERVER_QUERY_LOCAL_ADDRESS)
  729. (
  730. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  731. IN OUT void *Buffer,
  732. IN OUT unsigned long *BufferSize,
  733. OUT unsigned long *AddressFormat
  734. );
  735. /*++
  736. Routine Description:
  737. Returns the raw local network address of the connection.
  738. Arguments:
  739. ThisConnection - A server connection object.
  740. Buffer - The buffer that will receive the output address
  741. BufferSize - the size of the supplied Buffer on input. On output the
  742. number of bytes written to the buffer. If the buffer is too small
  743. to receive all the output data, ERROR_MORE_DATA is returned,
  744. nothing is written to the buffer, and BufferSize is set to
  745. the size of the buffer needed to return all the data.
  746. AddressFormat - a constant indicating the format of the returned address.
  747. Currently supported are RPC_P_ADDR_FORMAT_TCP_IPV4 and
  748. RPC_P_ADDR_FORMAT_TCP_IPV6.
  749. Return Value:
  750. RPC_S_OK, ERROR_MORE_DATA, RPC_S_* or Win32 error codes.
  751. --*/
  752. const int RPC_CLIENT_PROCESS_IDENTIFIER_ULONGLONG_ARRAY_SIZE = 0x10;
  753. const int RPC_CLIENT_PROCESS_IDENTIFIER_ULONG_ARRAY_SIZE = 0x20;
  754. class RPC_CLIENT_PROCESS_IDENTIFIER
  755. {
  756. public:
  757. inline void
  758. Set (
  759. IN RPC_CLIENT_PROCESS_IDENTIFIER *ClientProcess
  760. );
  761. inline void
  762. ZeroOut (
  763. void
  764. );
  765. inline int
  766. Compare (
  767. IN RPC_CLIENT_PROCESS_IDENTIFIER *ClientProcess
  768. );
  769. inline BOOL
  770. IsNull (
  771. void
  772. );
  773. inline ULONGLONG
  774. GetDebugULongLong1 (
  775. void
  776. );
  777. inline ULONGLONG
  778. GetDebugULongLong2 (
  779. void
  780. );
  781. inline ULONG
  782. GetDebugULong1 (
  783. void
  784. );
  785. inline ULONG
  786. GetDebugULong2 (
  787. void
  788. );
  789. inline BOOL
  790. IsLocal (
  791. void
  792. );
  793. // defined in wstrans.cxx to avoid general runtime dependency on
  794. // IPv6 headers
  795. void
  796. SetIPv6ClientIdentifier (
  797. IN void *Buffer,
  798. IN size_t BufferSize,
  799. IN BOOL fLocal
  800. );
  801. inline void
  802. SetIPv4ClientIdentifier (
  803. IN ULONG Addr,
  804. IN BOOL fLocal
  805. );
  806. void
  807. SetHTTP2ClientIdentifier (
  808. IN void *Buffer,
  809. IN size_t BufferSize,
  810. IN BOOL fLocal
  811. );
  812. inline void
  813. SetNMPClientIdentifier (
  814. IN FILE_PIPE_CLIENT_PROCESS_BUFFER *ClientId,
  815. IN BOOL fLocal
  816. );
  817. inline void
  818. SetIPXClientIdentifier (
  819. IN void *Buffer,
  820. IN size_t BufferSize,
  821. IN BOOL fLocal
  822. );
  823. private:
  824. BOOL fLocal;
  825. BOOL ZeroPadding; // if member wise initialization is done,
  826. // this must be set to 0. This allows callers
  827. // to call memcmp for the whole object.
  828. // provide storage for 0x80 bytes. This is the max client id
  829. // (the client id of an IPv6 client address)
  830. union
  831. {
  832. ULONGLONG ULongLongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONGLONG_ARRAY_SIZE];
  833. ULONG ULongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONG_ARRAY_SIZE];
  834. } u;
  835. };
  836. void
  837. RPC_CLIENT_PROCESS_IDENTIFIER::Set (
  838. IN RPC_CLIENT_PROCESS_IDENTIFIER *ClientProcess
  839. )
  840. /*++
  841. Routine Description:
  842. Initialize the client process identifier from another client
  843. process identifier
  844. Arguments:
  845. ClientProcess - a pointer to the other client process
  846. Return Value:
  847. --*/
  848. {
  849. RpcpMemoryCopy(this, ClientProcess, sizeof(RPC_CLIENT_PROCESS_IDENTIFIER));
  850. }
  851. void
  852. RPC_CLIENT_PROCESS_IDENTIFIER::ZeroOut (
  853. void
  854. )
  855. /*++
  856. Routine Description:
  857. Zero out a RPC_CLIENT_PROCESS_IDENTIFIED.
  858. Arguments:
  859. Return Value:
  860. --*/
  861. {
  862. RpcpMemorySet(this, 0, sizeof(RPC_CLIENT_PROCESS_IDENTIFIER));
  863. }
  864. int
  865. RPC_CLIENT_PROCESS_IDENTIFIER::Compare (
  866. IN RPC_CLIENT_PROCESS_IDENTIFIER *ClientProcess
  867. )
  868. /*++
  869. Routine Description:
  870. Compare two RPC_CLIENT_PROCESS_IDENTIFIED structs.
  871. Arguments:
  872. ClientProcess - a pointer to the ClientProcess ID to compare to
  873. Return Value:
  874. non-zero - the Client Process Ids are different.
  875. 0 - the Client process Ids are the same
  876. --*/
  877. {
  878. return RpcpMemoryCompare(this, ClientProcess, sizeof(RPC_CLIENT_PROCESS_IDENTIFIER));
  879. }
  880. BOOL
  881. RPC_CLIENT_PROCESS_IDENTIFIER::IsNull (
  882. void
  883. )
  884. /*++
  885. Routine Description:
  886. Utility function to check whether the ClientId portion is NULL.
  887. N.B. the function does not check for the fLocal flag!
  888. Arguments:
  889. Return Value:
  890. TRUE - the ClientId of the ClientProcess is all zeroes.
  891. FALSE - at least one element of the ClientId is non-zero
  892. --*/
  893. {
  894. int i;
  895. #if defined(_WIN64)
  896. for (i = 0; i < RPC_CLIENT_PROCESS_IDENTIFIER_ULONGLONG_ARRAY_SIZE; i ++)
  897. {
  898. if (u.ULongLongClientId[i] != 0)
  899. return FALSE;
  900. }
  901. #else
  902. for (i = 0; i < RPC_CLIENT_PROCESS_IDENTIFIER_ULONG_ARRAY_SIZE; i ++)
  903. {
  904. if (u.ULongClientId[i] != 0)
  905. return FALSE;
  906. }
  907. #endif
  908. return TRUE;
  909. }
  910. ULONGLONG
  911. RPC_CLIENT_PROCESS_IDENTIFIER::GetDebugULongLong1 (
  912. void
  913. )
  914. /*++
  915. Routine Description:
  916. Returns the first ULONGLONG from the ClientProcess identifier
  917. Used for debugging.
  918. Arguments:
  919. Return Value:
  920. the value used for debugging
  921. --*/
  922. {
  923. return u.ULongLongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONGLONG_ARRAY_SIZE - 2];
  924. }
  925. ULONGLONG
  926. RPC_CLIENT_PROCESS_IDENTIFIER::GetDebugULongLong2 (
  927. void
  928. )
  929. /*++
  930. Routine Description:
  931. Returns the second ULONGLONG from the ClientProcess identifier
  932. Used for debugging.
  933. Arguments:
  934. Return Value:
  935. the value used for debugging
  936. --*/
  937. {
  938. return u.ULongLongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONGLONG_ARRAY_SIZE - 1];
  939. }
  940. ULONG
  941. RPC_CLIENT_PROCESS_IDENTIFIER::GetDebugULong1 (
  942. void
  943. )
  944. /*++
  945. Routine Description:
  946. Returns the first ULONG from the ClientProcess identifier
  947. Used for debugging.
  948. Arguments:
  949. Return Value:
  950. the value used for debugging
  951. --*/
  952. {
  953. return u.ULongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONG_ARRAY_SIZE - 2];
  954. }
  955. ULONG
  956. RPC_CLIENT_PROCESS_IDENTIFIER::GetDebugULong2 (
  957. void
  958. )
  959. /*++
  960. Routine Description:
  961. Returns the second ULONG from the ClientProcess identifier
  962. Used for debugging.
  963. Arguments:
  964. Return Value:
  965. the value used for debugging
  966. --*/
  967. {
  968. return u.ULongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONG_ARRAY_SIZE - 1];
  969. }
  970. void
  971. RPC_CLIENT_PROCESS_IDENTIFIER::SetIPv4ClientIdentifier (
  972. IN ULONG Addr,
  973. IN BOOL fLocal
  974. )
  975. /*++
  976. Routine Description:
  977. IPv4 servers can use this to store their IP address in
  978. the client identifier.
  979. Arguments:
  980. Addr - IPv4 address
  981. fLocal - TRUE if the client is guaranteed to be Local. False otherwise.
  982. Return Value:
  983. --*/
  984. {
  985. this->fLocal = fLocal;
  986. u.ULongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONG_ARRAY_SIZE - 1] = Addr;
  987. }
  988. void
  989. RPC_CLIENT_PROCESS_IDENTIFIER::SetNMPClientIdentifier (
  990. IN FILE_PIPE_CLIENT_PROCESS_BUFFER *ClientId,
  991. IN BOOL fLocal
  992. )
  993. /*++
  994. Routine Description:
  995. Stores a client identifier as returned by the named pipes
  996. primitives
  997. Arguments:
  998. ClientId - the buffer the named pipe driver (NPFS or SVR)
  999. returned.
  1000. fLocal - TRUE if the client is guaranteed to be Local. False otherwise.
  1001. Return Value:
  1002. --*/
  1003. {
  1004. this->fLocal = fLocal;
  1005. #if defined(_WIN64) || defined(BUILD_WOW6432)
  1006. u.ULongLongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONGLONG_ARRAY_SIZE - 2] = (ULONGLONG)ClientId->ClientSession;
  1007. u.ULongLongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONGLONG_ARRAY_SIZE - 1] = (ULONGLONG)ClientId->ClientProcess;
  1008. #else
  1009. u.ULongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONG_ARRAY_SIZE - 2] = (ULONG)ClientId->ClientSession;
  1010. u.ULongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONG_ARRAY_SIZE - 1] = (ULONG)ClientId->ClientProcess;
  1011. #endif
  1012. }
  1013. void
  1014. RPC_CLIENT_PROCESS_IDENTIFIER::SetIPXClientIdentifier (
  1015. IN void *Buffer,
  1016. IN size_t BufferSize,
  1017. IN BOOL fLocal)
  1018. /*++
  1019. Routine Description:
  1020. IPX servers can use this to store their client address in
  1021. the client identifier.
  1022. Arguments:
  1023. Buffer - the buffer with the client identifier
  1024. BufferSize - the size of the data in buffer
  1025. fLocal - TRUE if the client is guaranteed to be Local. False otherwise.
  1026. Return Value:
  1027. --*/
  1028. {
  1029. ASSERT(BufferSize <= sizeof(u.ULongClientId));
  1030. this->fLocal = fLocal;
  1031. RpcpMemoryCopy(((unsigned char *)(&u.ULongClientId[RPC_CLIENT_PROCESS_IDENTIFIER_ULONG_ARRAY_SIZE])) - BufferSize, Buffer, BufferSize);
  1032. }
  1033. BOOL
  1034. RPC_CLIENT_PROCESS_IDENTIFIER::IsLocal (
  1035. void
  1036. )
  1037. /*++
  1038. Routine Description:
  1039. Returns TRUE if the client process identifier is for a local process.
  1040. Arguments:
  1041. Return Value:
  1042. TRUE - the client process is guaranteed to be local.
  1043. FALSE - the client process is either remote, or it is not known
  1044. whether the client process is local or remote.
  1045. --*/
  1046. {
  1047. return fLocal;
  1048. }
  1049. // represents a client IP address. Internally, it is a SOCKADDR_IN or SOCKADDR_IN6.
  1050. // It's up to the transport to fill it in correctly. The runtime doesn't care
  1051. class RPC_CLIENT_IP_ADDRESS
  1052. {
  1053. public:
  1054. BYTE Data[32];
  1055. ULONG DataSize;
  1056. void ZeroOut (void);
  1057. };
  1058. typedef RPC_STATUS
  1059. (RPC_ENTRY *CO_SERVER_QUERY_CLIENT_ID)
  1060. (
  1061. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  1062. OUT RPC_CLIENT_PROCESS_IDENTIFIER *pClientId
  1063. );
  1064. /*++
  1065. Routine Description:
  1066. For transport which support security this returns the ID of the
  1067. client process.
  1068. This API is optional and not support on most protocols.
  1069. Arguments:
  1070. ThisConnection - Server connection to the client in question.
  1071. pClientId - Will return the ID of the client connection/process.
  1072. Return Value:
  1073. RPC_S_OK
  1074. RPC_S_OUT_OF_RESOURCES
  1075. --*/
  1076. typedef RPC_STATUS
  1077. (RPC_ENTRY *CO_SERVER_QUERY_CLIENT_IP_ADDRESS)
  1078. (
  1079. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  1080. IN OUT RPC_CLIENT_IP_ADDRESS *ClientIpAddress
  1081. );
  1082. /*++
  1083. Routine Description:
  1084. Tries to retrieve the IP address and port of the caller. Caller
  1085. fills in what it can.
  1086. This API is optional.
  1087. Arguments:
  1088. ThisConnection - Server connection to the client in question.
  1089. ClientIpAddress - Will return the IP address of the client
  1090. Return Value:
  1091. RPC_S_OK
  1092. RPC_S_OUT_OF_RESOURCES
  1093. --*/
  1094. typedef RPC_STATUS
  1095. (RPC_ENTRY *CO_SERVER_IMPERSONATE)
  1096. (
  1097. IN RPC_TRANSPORT_CONNECTION ThisConnection
  1098. );
  1099. /*++
  1100. Routine Description:
  1101. For protocols which support security this impersonates the client.
  1102. Arguments:
  1103. ThisConnection - The server connection to the client to be impersonated.
  1104. Return Value:
  1105. RPC_S_OK
  1106. RPC_S_NO_CONTEXT_AVAILABLE
  1107. --*/
  1108. typedef RPC_STATUS
  1109. (RPC_ENTRY *CO_SERVER_REVERT)
  1110. (
  1111. IN RPC_TRANSPORT_CONNECTION ThisConnection
  1112. );
  1113. /*++
  1114. Routine Description:
  1115. Maybe called on a thread which has previously, successfully called
  1116. CO_SERVER_IMPERSONATE on the same connection.
  1117. Resets the threads token to that of the server process.
  1118. Arguments:
  1119. ThisConnection - The connection previously impersonated on this thread.
  1120. Return Value:
  1121. RPC_S_OK
  1122. --*/
  1123. extern RPC_STATUS RPC_ENTRY
  1124. COMMON_PostRuntimeEvent(
  1125. IN DWORD Type,
  1126. IN PVOID Context
  1127. );
  1128. } // extern "C"
  1129. // Connection oriented transport interface
  1130. struct RPC_CONNECTION_TRANSPORT
  1131. {
  1132. //
  1133. // RPC_TRANSPORT_INTERFACE_HEADER definitions
  1134. //
  1135. UINT TransInterfaceVersion;
  1136. USHORT TransId;
  1137. USHORT TransAddrId;
  1138. RPC_CHAR *ProtocolSequence;
  1139. PCHAR WellKnownEndpoint;
  1140. PROCESS_CALLS ProcessCalls;
  1141. #ifndef NO_PLUG_AND_PLAY
  1142. START_PNP_NOTIFICATIONS PnpNotify;
  1143. LISTEN_FOR_PNP_NOTIFICATIONS PnpListen;
  1144. #endif
  1145. TOWER_CONSTRUCT TowerConstruct;
  1146. TOWER_EXPLODE TowerExplode;
  1147. POST_EVENT PostEvent ;
  1148. BOOL fDatagram;
  1149. SERVER_GET_NETWORK_ADDRESS_VECTOR GetNetworkAddressVector;
  1150. //
  1151. // Connection specific interface
  1152. //
  1153. UINT AddressSize;
  1154. UINT ClientConnectionSize;
  1155. UINT ServerConnectionSize;
  1156. UINT SendContextSize;
  1157. UINT ResolverHintSize;
  1158. UINT MaximumFragmentSize;
  1159. CO_CLIENT_INITIALIZE Initialize;
  1160. CO_CLIENT_INITCOMPLETE InitComplete;
  1161. // Operations on client-side connections
  1162. CO_CLIENT_OPEN Open;
  1163. CO_CLIENT_SYNC_SEND_RECV SyncSendRecv; OPTIONAL
  1164. CO_CLIENT_SYNC_RECV SyncRecv;
  1165. // Operations on connecitons
  1166. CO_ABORT Abort;
  1167. CO_CLOSE Close;
  1168. CO_SEND Send;
  1169. CO_RECV Recv;
  1170. CO_SYNC_SEND SyncSend;
  1171. // Client side explicit keep alive operations
  1172. CO_TURN_ON_OFF_KEEPALIVES TurnOnOffKeepAlives;
  1173. // Server only startup APIs
  1174. CO_SERVER_LISTEN Listen;
  1175. CO_SERVER_ABORT_LISTEN AbortListen;
  1176. CO_SERVER_COMPLETE_LISTEN CompleteListen;
  1177. // Operations on sever-side connections
  1178. CO_SERVER_QUERY_ADDRESS QueryClientAddress; OPTIONAL
  1179. CO_SERVER_QUERY_LOCAL_ADDRESS QueryLocalAddress; OPTIONAL
  1180. // Server-side security related APIs
  1181. CO_SERVER_QUERY_CLIENT_ID QueryClientId;
  1182. CO_SERVER_QUERY_CLIENT_IP_ADDRESS QueryClientIpAddress; OPTIONAL
  1183. CO_SERVER_IMPERSONATE ImpersonateClient; OPTIONAL
  1184. CO_SERVER_REVERT RevertToSelf; OPTIONAL
  1185. // Resolver hint APIs
  1186. CO_FREE_RESOLVER_HINT FreeResolverHint; OPTIONAL
  1187. CO_COPY_RESOLVER_HINT CopyResolverHint; OPTIONAL
  1188. CO_COMPARE_RESOLVER_HINT CompareResolverHint; OPTIONAL
  1189. // Misc. APIs
  1190. CO_SET_LAST_BUFFER_TO_FREE SetLastBufferToFree; OPTIONAL
  1191. };
  1192. // Datagram specific transport interface
  1193. typedef struct tagDatagramTransportPair
  1194. {
  1195. HANDLE RemoteAddress;
  1196. HANDLE LocalAddress;
  1197. } DatagramTransportPair;
  1198. typedef HANDLE DG_TRANSPORT_ENDPOINT; // Listening/sending object
  1199. typedef HANDLE DG_TRANSPORT_ADDRESS; // Destination/source address
  1200. struct DG_ENDPOINT_STATS
  1201. {
  1202. unsigned long PreferredPduSize;
  1203. unsigned long MaxPduSize;
  1204. unsigned long MaxPacketSize;
  1205. unsigned long ReceiveBufferSize;
  1206. };
  1207. extern "C" {
  1208. typedef RPC_STATUS
  1209. (RPC_ENTRY *DG_SEND)
  1210. (
  1211. IN DG_TRANSPORT_ENDPOINT SourceEndpoint,
  1212. IN DG_TRANSPORT_ADDRESS DestinationAddress,
  1213. IN BUFFER Header,
  1214. IN UINT HeaderLength,
  1215. IN BUFFER Body,
  1216. IN UINT BodyLength,
  1217. IN BUFFER Trailer,
  1218. IN UINT TrailerLength
  1219. );
  1220. /*++
  1221. Routine Description:
  1222. Sends the complete packet (Header+Body+Trailer) to the destination
  1223. address from the source endpoint. Replys, if any, will then come back
  1224. to the source endpoint.
  1225. Arguments:
  1226. SourceEndpoint - Client or server endpoint object to send from.
  1227. DestinationAddress - The address to send the packet to.
  1228. Header - First part of the data.
  1229. HeaderLength - The number of bytes of Header to send.
  1230. Body - The main (bulk) of the data to send.
  1231. BodyLength - The number of bytes of Body to send.
  1232. Trailer - The last part of the data to send.
  1233. TrailerLength - The number of bytes of Trailer to send.
  1234. Return Value:
  1235. RPC_S_OK
  1236. RPC_S_OUT_OF_RESOURCES
  1237. RPC_P_SEND_FAILED
  1238. --*/
  1239. typedef RPC_STATUS
  1240. (RPC_ENTRY *DG_CLIENT_OPEN_ENDPOINT)
  1241. (
  1242. IN DG_TRANSPORT_ENDPOINT Endpoint,
  1243. IN BOOL fAsync,
  1244. IN DWORD Flags,
  1245. IN DG_TRANSPORT_ENDPOINT ServerEndpoint OPTIONAL
  1246. );
  1247. /*++
  1248. Routine Description:
  1249. Creates a local endpoint object which can be used to send
  1250. and receive packets.
  1251. Arguments:
  1252. Endpoint - Storage for the transport endpoint object.
  1253. fAsync - TRUE - Transport should post and manage receives
  1254. which complete via ProcessCalls.
  1255. FALSE - Runtime will use Send and SyncRecv only
  1256. Flags - endpoint flags, one of RPC_C_USE_INTERNET_PORT or
  1257. RPC_C_USE_INTRANET_PORT
  1258. Return Value:
  1259. RPC_S_OK
  1260. RPC_S_OUT_OF_MEMORY
  1261. RPC_S_OUT_OF_RESOURCES
  1262. --*/
  1263. typedef RPC_STATUS
  1264. (RPC_ENTRY *DG_CLIENT_INITIALIZE_ADDRESS)
  1265. (
  1266. OUT DG_TRANSPORT_ADDRESS Address,
  1267. IN RPC_CHAR *NetworkAddress,
  1268. IN RPC_CHAR *Endpoint,
  1269. IN BOOL fUseCache,
  1270. IN BOOL fBroadcast
  1271. );
  1272. /*++
  1273. Routine Description:
  1274. Initializes a address object for sending to a server.
  1275. Arguments:
  1276. Address - Storage for the address
  1277. NetworkAddress - The address of the server or 0 if local
  1278. Endpoint - The endpoint of the server
  1279. fBroadcast - If TURE, NetworkAddress is ignored and a
  1280. transport-specific broadcast address is used.
  1281. fUseCache - If TRUE then the transport may use a cached
  1282. value from a previous call on the same NetworkAddress.
  1283. Return Value:
  1284. RPC_S_OK - Success, name resolved
  1285. RPC_P_FOUND_IN_CACHE - Success, returned only if fUseCache is TRUE
  1286. and the was name found in local cache.
  1287. RPC_P_MATCHED_CACHE - Partial success, fUseCache is FALSE and the
  1288. result of the lookup was the same as the value previously
  1289. in the cache.
  1290. RPC_S_OUT_OF_MEMORY
  1291. RPC_S_OUT_OF_RESOURCES
  1292. RPC_S_INVALID_ENDPOINT_FORMAT
  1293. RPC_S_SERVER_UNAVAILABLE
  1294. --*/
  1295. typedef RPC_STATUS
  1296. (RPC_ENTRY *DG_CLIENT_CLOSE)
  1297. (
  1298. IN DG_TRANSPORT_ENDPOINT Endpoint
  1299. );
  1300. /*++
  1301. Routine Description:
  1302. Closes a client endpoint object when it will no longer be needed.
  1303. Note: For async endpoint this doesn't actually destroy the endpoint,
  1304. but it will eventually cause a thread waiting in ProcessCalls
  1305. to get back an RPC_P_ENDPOINT_CLOSED completion for the endpoint.
  1306. In the meantime it is possible for new packets to arrive at the
  1307. endpoint.
  1308. Arguments:
  1309. Endpoing - The endpoint that should be closed.
  1310. Return Value:
  1311. RPC_S_OK - Sync endpoints
  1312. RPC_P_IO_PENDING - Async endpoints
  1313. --*/
  1314. typedef RPC_STATUS
  1315. (RPC_ENTRY *DG_CLIENT_SYNC_RECV)
  1316. (
  1317. IN DG_TRANSPORT_ENDPOINT Endpoint,
  1318. OUT DG_TRANSPORT_ADDRESS *pAddress,
  1319. OUT PUINT pBufferLength,
  1320. OUT BUFFER *pBuffer,
  1321. IN LONG Timeout
  1322. );
  1323. /*++
  1324. Routine Description:
  1325. Used to wait for a datagram from a server. Returns the data
  1326. returned and the ADDRESS of the machine which replied.
  1327. Arguments:
  1328. Endpoint - The endpoint to receive from.
  1329. pAddress - A block of memory which will contain the server's
  1330. address on completion.
  1331. BufferLength - The size of Buffer on input, the size of the
  1332. datagram received on output.
  1333. Timeout - Milliseconds to wait for a datagram.
  1334. Return Value:
  1335. RPC_S_OK
  1336. RPC_P_OVERSIZE_PACKET - Datagram > BufferLength arrived,
  1337. first BufferLength bytes of Buffer contain the partial datagram.
  1338. RPC_P_RECEIVE_FAILED
  1339. RPC_P_TIMEOUT
  1340. --*/
  1341. typedef RPC_STATUS
  1342. (RPC_ENTRY *DG_SERVER_LISTEN)
  1343. (
  1344. IN OUT DG_TRANSPORT_ENDPOINT ServerEndpoint,
  1345. IN RPC_CHAR *NetworkAddress,
  1346. IN OUT RPC_CHAR **Endpoint,
  1347. IN void *SecurityDescriptor,
  1348. IN ULONG EndpointFlags,
  1349. IN ULONG NICFlags
  1350. );
  1351. /*++
  1352. Routine Description:
  1353. Creates a server endpoint object to receive packets. New
  1354. packets won't actually arrive until CompleteListen is
  1355. called.
  1356. Arguments:
  1357. ServerEndpoint - Storage for the server endpoint object.
  1358. Endpoint - The endpoint to listen on or a pointer to 0 if
  1359. the transport should choose the address.
  1360. Contains the endpoint listened to on output. The
  1361. caller should free this.
  1362. EndpointFlags - Application flags passed into RPC via
  1363. RpcServerUseProtseq*Ex.
  1364. NICFlags - Application flags passed into RPC via
  1365. RpcServerUseProtseq*Ex.
  1366. pNetworkAddresses - A vector of the network addresses
  1367. listened on by this call. This vector does
  1368. not need to be freed.
  1369. Return Value:
  1370. RPC_S_OK - Success
  1371. RPC_S_INVALID_ENDPOINT_FORMAT
  1372. RPC_S_DUPLICATE_ENDPOINT
  1373. RPC_S_CANT_CREATE_ENDPOINT
  1374. RPC_S_OUT_OF_MEMORY
  1375. RPC_S_OUT_OF_RESOURCES
  1376. --*/
  1377. typedef void
  1378. (RPC_ENTRY *DG_SERVER_ABORT_LISTEN)
  1379. (
  1380. IN RPC_TRANSPORT_ADDRESS ThisEndpoint
  1381. );
  1382. /*++
  1383. Routine Description:
  1384. Destroys on a newly, successfully created server endpoint
  1385. for some reason known only to the runtime will not be used.
  1386. Arguments:
  1387. ThisEndpoint - The endpoint to destroy.
  1388. Return Value:
  1389. Must succeed.
  1390. --*/
  1391. typedef void
  1392. (RPC_ENTRY *DG_SERVER_COMPLETE_LISTEN)
  1393. (
  1394. IN DG_TRANSPORT_ENDPOINT ThisAddress
  1395. );
  1396. /*++
  1397. Routine Description:
  1398. Called when the runtime is actually ready for packets to be
  1399. completed (received) on this endpoint. This call cannot fail since
  1400. the runtime can't undo the operation at this point.
  1401. Arguments:
  1402. ThisAddress - The address the runtime is now ready to receive
  1403. connections on.
  1404. Return Value:
  1405. Must succeed.
  1406. --*/
  1407. typedef RPC_STATUS
  1408. (RPC_ENTRY *DG_QUERY_ADDRESS)
  1409. (
  1410. IN DG_TRANSPORT_ADDRESS ThisAddress,
  1411. OUT RPC_CHAR *AddressString
  1412. );
  1413. /*++
  1414. Routine Description:
  1415. Converts the network address of a DG_TRANSPORT_ADDRESS into a string.
  1416. Arguments:
  1417. ThisAddress - The transport address containing the network address.
  1418. AddressString - Storage for the string form of the network address.
  1419. Note: This buffer is assumed to be <AddressSize> bytes.
  1420. Return Value:
  1421. RPC_S_OK
  1422. --*/
  1423. typedef RPC_STATUS
  1424. (RPC_ENTRY *DG_QUERY_ENDPOINT_STATS)
  1425. (
  1426. IN DG_TRANSPORT_ADDRESS ThisAddress,
  1427. OUT DG_ENDPOINT_STATS * pStats
  1428. );
  1429. /*++
  1430. Routine Description:
  1431. Returns the endpoint's receive buffer length and max PDU sizes.
  1432. Arguments:
  1433. ThisAddress - The transport address containing the network address.
  1434. pStats - a structure to fill with stats
  1435. Return Value:
  1436. RPC_S_OK
  1437. --*/
  1438. typedef RPC_STATUS
  1439. (RPC_ENTRY *DG_QUERY_ENDPOINT)
  1440. (
  1441. IN DG_TRANSPORT_ADDRESS ThisAddress,
  1442. OUT RPC_CHAR *EndpointString
  1443. );
  1444. /*++
  1445. Routine Description:
  1446. Converts the endpoint of a DG_TRANSPORT_ADDRESS into a string.
  1447. Arguments:
  1448. ThisAddress - The transport address containing the endpoint.
  1449. AddressString - Storage for the string form of the endpoint.
  1450. Note: This buffer is assumed to be <EndpointStringSize> bytes.
  1451. Return Value:
  1452. RPC_S_OK
  1453. --*/
  1454. typedef RPC_STATUS
  1455. (RPC_ENTRY * DG_CLIENT_INIT_OPTIONS)
  1456. (
  1457. IN void *pvTransportOptions
  1458. );
  1459. typedef RPC_STATUS
  1460. (RPC_ENTRY * DG_CLIENT_SET_OPTION)
  1461. (
  1462. IN void *pvTransportOptions,
  1463. IN ULONG Option,
  1464. IN ULONG_PTR OptionValue
  1465. );
  1466. typedef RPC_STATUS
  1467. (RPC_ENTRY * DG_CLIENT_INQ_OPTION)
  1468. (
  1469. IN void *pvTransportOptions,
  1470. IN ULONG Option,
  1471. OUT ULONG_PTR * pOptionValue
  1472. );
  1473. typedef RPC_STATUS
  1474. (RPC_ENTRY * DG_CLIENT_IMPLEMENT_OPTIONS)
  1475. (
  1476. IN DG_TRANSPORT_ENDPOINT pEndpoint,
  1477. IN void *pvTransportOptions
  1478. );
  1479. typedef BOOL
  1480. (RPC_ENTRY * DG_SERVER_ALLOW_RECEIVES)
  1481. (
  1482. IN DG_TRANSPORT_ENDPOINT pEndpoint,
  1483. IN BOOL fAllowReceives,
  1484. IN BOOL fCancelPendingIos
  1485. );
  1486. typedef RPC_STATUS
  1487. (RPC_ENTRY * DG_SERVER_INQUIRE_AUTH_CLIENT)
  1488. (
  1489. IN void *pClientEndpoint,
  1490. OUT RPC_CHAR **ppPrincipal,
  1491. OUT SID **ppSid,
  1492. OUT ULONG *pulAuthenLevel,
  1493. OUT ULONG *pulAuthnService,
  1494. OUT ULONG *pulAuthzService
  1495. );
  1496. typedef RPC_STATUS
  1497. (RPC_ENTRY *DG_SERVER_FORWARD_PACKET)
  1498. (
  1499. IN DG_TRANSPORT_ENDPOINT SourceEndpoint,
  1500. IN BUFFER Header,
  1501. IN UINT HeaderLength,
  1502. IN BUFFER Body,
  1503. IN UINT BodyLength,
  1504. IN BUFFER Trailer,
  1505. IN UINT TrailerLength,
  1506. IN CHAR *Endpoint
  1507. );
  1508. /*++
  1509. Routine Description:
  1510. A special form of DG_SEND which takes an string endpoint
  1511. to send to rather then a full DG_TRANSPORT_ADDRESS.
  1512. The packet is forwarded to the local machine.
  1513. Arguments:
  1514. SourceEndpoint - The endpoint to send from.
  1515. Headers - TrailerLength - Same as DG_SEND above
  1516. Endpoint - The string form of the endpoint to send to.
  1517. Return Value:
  1518. RPC_S_OK
  1519. --*/
  1520. }
  1521. struct RPC_DATAGRAM_TRANSPORT
  1522. {
  1523. //
  1524. // Common RPC_TRANSPORT_INTERFACE_HEADER definitions
  1525. //
  1526. UINT TransInterfaceVersion;
  1527. USHORT TransId;
  1528. USHORT TransAddrId;
  1529. RPC_CHAR *ProtocolSequence;
  1530. PCHAR WellKnownEndpoint;
  1531. PROCESS_CALLS ProcessCalls;
  1532. #ifndef NO_PLUG_AND_PLAY
  1533. START_PNP_NOTIFICATIONS PnpNotify;
  1534. LISTEN_FOR_PNP_NOTIFICATIONS PnpListen;
  1535. #endif
  1536. TOWER_CONSTRUCT TowerConstruct;
  1537. TOWER_EXPLODE TowerExplode;
  1538. POST_EVENT PostEvent ;
  1539. BOOL fDatagram;
  1540. SERVER_GET_NETWORK_ADDRESS_VECTOR GetNetworkAddressVector;
  1541. //
  1542. // Datagram specific
  1543. //
  1544. UINT ServerEndpointSize;
  1545. UINT ClientEndpointSize;
  1546. UINT AddressSize;
  1547. UINT EndpointStringSize;
  1548. UINT AddressStringSize;
  1549. UINT BasePduSize;
  1550. UINT ExpectedPduSize;
  1551. DG_SEND Send;
  1552. DG_CLIENT_OPEN_ENDPOINT OpenEndpoint;
  1553. DG_CLIENT_INITIALIZE_ADDRESS InitializeAddress;
  1554. DG_CLIENT_CLOSE Close;
  1555. DG_CLIENT_SYNC_RECV SyncReceive;
  1556. DG_SERVER_LISTEN Listen;
  1557. DG_SERVER_ABORT_LISTEN AbortListen;
  1558. DG_SERVER_COMPLETE_LISTEN CompleteListen;
  1559. DG_SERVER_FORWARD_PACKET ForwardPacket;
  1560. DG_QUERY_ADDRESS QueryAddress;
  1561. DG_QUERY_ENDPOINT QueryEndpoint;
  1562. DG_QUERY_ENDPOINT_STATS QueryEndpointStats;
  1563. BOOL IsMessageTransport; // ncadg_mq message transport.
  1564. UINT OptionsSize; // Endpoint options.
  1565. DG_CLIENT_INIT_OPTIONS InitOptions;
  1566. DG_CLIENT_SET_OPTION SetOption;
  1567. DG_CLIENT_INQ_OPTION InqOption;
  1568. DG_CLIENT_IMPLEMENT_OPTIONS ImplementOptions;
  1569. DG_SERVER_ALLOW_RECEIVES AllowReceives;
  1570. DG_SERVER_INQUIRE_AUTH_CLIENT InquireAuthClient;
  1571. };
  1572. typedef RPC_TRANSPORT_INTERFACE_HEADER *RPC_TRANSPORT_INTERFACE;
  1573. typedef RPC_TRANSPORT_INTERFACE
  1574. (RPC_ENTRY *TRANSPORT_LOAD)(const RPC_CHAR *Protseq);
  1575. typedef HANDLE (RPC_ENTRY *FuncGetHandleForThread)(void);
  1576. typedef void (RPC_ENTRY *FuncReleaseHandleForThread)(HANDLE);
  1577. //
  1578. // Exports from the RPC runtime; used by the transport interface
  1579. //
  1580. extern "C" {
  1581. //
  1582. // Memory management APIs
  1583. //
  1584. // rpcdcep.h - I_RpcAllocate
  1585. // rpcdcep.h - I_RpcFree
  1586. // Connection allocation functions are called on either
  1587. // client-side or server-side connections during the
  1588. // receive path. Buffers must be 0 mod 8.
  1589. RPCRTAPI
  1590. BUFFER
  1591. RPC_ENTRY
  1592. I_RpcTransConnectionAllocatePacket(
  1593. RPC_TRANSPORT_CONNECTION ThisConnection,
  1594. UINT Size
  1595. );
  1596. RPCRTAPI
  1597. void
  1598. RPC_ENTRY
  1599. I_RpcTransConnectionFreePacket(
  1600. RPC_TRANSPORT_CONNECTION ThisConnection,
  1601. BUFFER Ptr
  1602. );
  1603. RPCRTAPI
  1604. RPC_STATUS
  1605. RPC_ENTRY
  1606. I_RpcTransConnectionReallocPacket(
  1607. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  1608. IN BUFFER *ppBuffer,
  1609. IN UINT OldSize,
  1610. IN UINT NewSize
  1611. );
  1612. RPCRTAPI
  1613. BUFFER
  1614. RPC_ENTRY
  1615. I_RpcTransServerAllocatePacket(
  1616. RPC_TRANSPORT_CONNECTION ThisConnection,
  1617. UINT Size
  1618. );
  1619. RPCRTAPI
  1620. void
  1621. RPC_ENTRY
  1622. I_RpcTransServerFreePacket(
  1623. RPC_TRANSPORT_CONNECTION ThisConnection,
  1624. BUFFER Ptr
  1625. );
  1626. RPCRTAPI
  1627. RPC_STATUS
  1628. RPC_ENTRY
  1629. I_RpcTransServerReallocPacket(
  1630. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  1631. IN BUFFER *ppBuffer,
  1632. IN UINT OldSize,
  1633. IN UINT NewSize
  1634. );
  1635. RPCRTAPI
  1636. RPC_STATUS
  1637. RPC_ENTRY
  1638. I_RpcTransDatagramAllocate(
  1639. IN RPC_TRANSPORT_ADDRESS ThisAddress,
  1640. OUT BUFFER *pBuffer,
  1641. OUT PUINT pBufferLength,
  1642. OUT DatagramTransportPair **pAddressPair
  1643. );
  1644. RPCRTAPI
  1645. RPC_STATUS
  1646. RPC_ENTRY
  1647. I_RpcTransDatagramAllocate2(
  1648. IN RPC_TRANSPORT_ADDRESS ThisAddress,
  1649. OUT BUFFER *pBuffer,
  1650. IN OUT PUINT pBufferLength,
  1651. OUT DG_TRANSPORT_ADDRESS *pAddress
  1652. );
  1653. RPCRTAPI
  1654. RPC_STATUS
  1655. RPC_ENTRY
  1656. I_RpcTransDatagramFree(
  1657. IN RPC_TRANSPORT_ADDRESS ThisAddress,
  1658. IN BUFFER Buffer
  1659. );
  1660. //
  1661. // Thread APIs
  1662. //
  1663. RPCRTAPI
  1664. PVOID
  1665. RPC_ENTRY
  1666. I_RpcTransProtectThread (
  1667. void
  1668. );
  1669. RPCRTAPI
  1670. void
  1671. RPC_ENTRY
  1672. I_RpcTransUnprotectThread (
  1673. IN PVOID Thread
  1674. );
  1675. //
  1676. // Runtime supplied per thread events.
  1677. //
  1678. RPCRTAPI
  1679. HANDLE
  1680. RPC_ENTRY
  1681. I_RpcTransGetThreadEvent(
  1682. );
  1683. //
  1684. // Misc connection oriented callbacks
  1685. //
  1686. RPCRTAPI
  1687. RPC_STATUS
  1688. RPC_ENTRY
  1689. I_RpcTransIoCancelled(
  1690. IN RPC_TRANSPORT_CONNECTION ThisConnection,
  1691. OUT PDWORD pTimeoutInMilliseconds
  1692. );
  1693. RPCRTAPI
  1694. BOOL
  1695. RPC_ENTRY
  1696. I_RpcTransPingServer(
  1697. IN RPC_TRANSPORT_CONNECTION ThisConnection
  1698. ) ;
  1699. RPCRTAPI
  1700. RPC_TRANSPORT_CONNECTION
  1701. RPC_ENTRY
  1702. I_RpcTransServerNewConnection (
  1703. IN RPC_TRANSPORT_ADDRESS ThisAddress
  1704. );
  1705. //
  1706. // Support for selective binding
  1707. //
  1708. struct FIREWALL_INFO_ENTRY {
  1709. // The IP address of this table entry.
  1710. DWORD Address;
  1711. // Set when the IP address has been initialized.
  1712. BOOL fInitialized;
  1713. // TRUE if this address is enabled and RPC will listen on it.
  1714. // FALSE otherwise.
  1715. BOOL fEnabled;
  1716. // TRUE if the IP address for this entry was not in the table
  1717. // before the last call to initialize the table.
  1718. // FALSE otherwise.
  1719. //
  1720. // After each update to the table, we will walk the list of transport
  1721. // addresses and initialize objects that do not yet have network addresses.
  1722. // Net addresses from entries with this flag will be assigned to transport
  1723. // addresses.
  1724. BOOL fNewAddress;
  1725. };
  1726. struct FIREWALL_INFO {
  1727. DWORD NumAddresses;
  1728. FIREWALL_INFO_ENTRY Entries[1];
  1729. };
  1730. extern FIREWALL_INFO *pFirewallTable;
  1731. extern BOOL fFirewallTableFullyInitialized;
  1732. extern DWORD FirewallTableNumActiveEntries;
  1733. RPCRTAPI
  1734. BOOL
  1735. RPC_ENTRY
  1736. DoFirewallInit (
  1737. void
  1738. );
  1739. RPCRTAPI
  1740. void
  1741. RPC_ENTRY
  1742. DoFirewallUpdate (
  1743. void
  1744. );
  1745. RPCRTAPI
  1746. FIREWALL_INFO *
  1747. RPC_ENTRY
  1748. GetFirewallTableCopy (
  1749. void
  1750. );
  1751. RPC_TRANSPORT_INTERFACE
  1752. TransportLoad (
  1753. IN const RPC_CHAR * RpcProtocolSequence
  1754. );
  1755. #define SU_TRANS_CONN 'o'
  1756. #define EV_ABORT 'R'
  1757. void RPC_ENTRY
  1758. I_RpcLogEvent (
  1759. IN unsigned char Subject,
  1760. IN unsigned char Verb,
  1761. IN void * SubjectPointer,
  1762. IN void * ObjectPointer,
  1763. IN unsigned Data,
  1764. IN BOOL fCaptureStackTrace,
  1765. IN int AdditionalFramesToSkip
  1766. );
  1767. //
  1768. // constants for CallTestHook
  1769. //
  1770. #define TH_X_DG_SEND MAKE_TEST_HOOK_ID( TH_TRANS_BASE, 1 )
  1771. // args:
  1772. // hook ID
  1773. // pointer to NCA_PACKET_HEADER
  1774. // pointer to DWORD status variable
  1775. // nonzero status will be returned to caller w/o sending a packet
  1776. #define TH_X_DG_SYNC_RECV MAKE_TEST_HOOK_ID( TH_TRANS_BASE, 2 )
  1777. // args:
  1778. // hook ID
  1779. // pointer to DG_TRANSPORT_ENDPOINT
  1780. // pointer to DWORD status variable
  1781. // nonzero status will be returned to caller w/o receiving
  1782. //
  1783. // Call to allocate an IP port. This allows control of dynamic port
  1784. // allocation by the RPC runtime.
  1785. //
  1786. RPCRTAPI
  1787. RPC_STATUS
  1788. RPC_ENTRY
  1789. I_RpcServerAllocateIpPort(
  1790. IN ULONG Flags,
  1791. OUT USHORT *pPort
  1792. );
  1793. void
  1794. I_RpcTransVerifyServerRuntimeCallFromContext(
  1795. void *SendContext
  1796. );
  1797. void
  1798. I_RpcTransVerifyClientRuntimeCallFromContext(
  1799. void *SendContext
  1800. );
  1801. BOOL
  1802. I_RpcTransIsClientConnectionExclusive(
  1803. void *RuntimeConnection
  1804. );
  1805. RPC_STATUS
  1806. I_RpcTransCertMatchPrincipalName(
  1807. PCCERT_CONTEXT Context,
  1808. RPC_CHAR PrincipalName[]
  1809. );
  1810. RPC_HTTP_TRANSPORT_CREDENTIALS_W *
  1811. I_RpcTransGetHttpCredentials (
  1812. const IN RPC_HTTP_TRANSPORT_CREDENTIALS_W *SourceCredentials
  1813. );
  1814. void I_RpcTransFreeHttpCredentials (
  1815. IN RPC_HTTP_TRANSPORT_CREDENTIALS_W *SourceCredentials
  1816. );
  1817. RPCRTAPI
  1818. RPC_STATUS
  1819. RPC_ENTRY
  1820. HTTP2IISDirectReceive (
  1821. IN void *Context
  1822. );
  1823. RPCRTAPI
  1824. RPC_STATUS
  1825. RPC_ENTRY
  1826. HTTP2DirectReceive (
  1827. IN void *Context,
  1828. OUT BYTE **ReceivedBuffer,
  1829. OUT ULONG *ReceivedBufferLength,
  1830. OUT void **RuntimeConnection,
  1831. OUT BOOL *IsServer
  1832. );
  1833. RPCRTAPI
  1834. RPC_STATUS
  1835. RPC_ENTRY
  1836. HTTP2WinHttpDirectReceive (
  1837. IN void *Context,
  1838. OUT BYTE **ReceivedBuffer,
  1839. OUT ULONG *ReceivedBufferLength,
  1840. OUT void **RuntimeConnection
  1841. );
  1842. RPCRTAPI
  1843. RPC_STATUS
  1844. RPC_ENTRY
  1845. HTTP2WinHttpDirectSend (
  1846. IN void *Context,
  1847. OUT BYTE **SentBuffer,
  1848. OUT void **SendContext
  1849. );
  1850. RPCRTAPI
  1851. void
  1852. RPC_ENTRY
  1853. HTTP2WinHttpDelayedReceive (
  1854. IN void *Context
  1855. );
  1856. RPCRTAPI
  1857. RPC_STATUS
  1858. RPC_ENTRY
  1859. HTTP2PlugChannelDirectSend (
  1860. IN void *Context
  1861. );
  1862. RPCRTAPI
  1863. RPC_STATUS
  1864. RPC_ENTRY
  1865. HTTP2FlowControlChannelDirectSend (
  1866. IN void *Context,
  1867. OUT BOOL *IsServer,
  1868. OUT BOOL *SendToRuntime,
  1869. OUT void **SendContext,
  1870. OUT BUFFER *Buffer,
  1871. OUT UINT *BufferLength
  1872. );
  1873. RPCRTAPI
  1874. RPC_STATUS
  1875. RPC_ENTRY
  1876. HTTP2ChannelDataOriginatorDirectSend (
  1877. IN void *Context,
  1878. OUT BOOL *IsServer,
  1879. OUT void **SendContext,
  1880. OUT BUFFER *Buffer,
  1881. OUT UINT *BufferLength
  1882. );
  1883. RPCRTAPI
  1884. void
  1885. RPC_ENTRY
  1886. HTTP2TimerReschedule (
  1887. IN void *Context
  1888. );
  1889. RPCRTAPI
  1890. void
  1891. RPC_ENTRY
  1892. HTTP2AbortConnection (
  1893. IN void *Context
  1894. );
  1895. RPCRTAPI
  1896. void
  1897. RPC_ENTRY
  1898. HTTP2RecycleChannel (
  1899. IN void *Context
  1900. );
  1901. RPC_STATUS
  1902. HTTP2ProcessComplexTReceive (
  1903. IN OUT void **Connection,
  1904. IN RPC_STATUS EventStatus,
  1905. IN ULONG Bytes,
  1906. OUT BUFFER *Buffer,
  1907. OUT UINT *BufferLength
  1908. );
  1909. RPC_STATUS
  1910. HTTP2ProcessComplexTSend (
  1911. IN void *SendContext,
  1912. IN RPC_STATUS EventStatus,
  1913. OUT BUFFER *Buffer
  1914. );
  1915. RPCRTAPI
  1916. RPC_STATUS
  1917. RPC_ENTRY
  1918. HTTP2TestHook (
  1919. IN SystemFunction001Commands FunctionCode,
  1920. IN void *InData,
  1921. OUT void *OutData
  1922. );
  1923. // Note: Gathered send support.
  1924. //
  1925. // Scatter/gather support is a common hardware feature of networking
  1926. // devices. Gather support is often useful for both DG and CO RPC.
  1927. //
  1928. // Not all networking programming APIs, for example winsock 1.x, support
  1929. // the feature, for example winsock 1.x.
  1930. //
  1931. // When possible transport implementer's should implement gathered sends,
  1932. // but the following assumptions can be made for those who cannot support
  1933. // gathered sends:
  1934. //
  1935. // Sends will consist of three (3) buffers: Header, Body and Trailer.
  1936. //
  1937. // The following rules are maintained by the RPC runtime:
  1938. // - All three buffer remain valid until the send completes.
  1939. // - Header and Trailer are small in size
  1940. // - sizeof(Header) bytes *before* the Body pointer are valid
  1941. // and maybe used during the send. But must be restored when
  1942. // the send completes (with or without an error.)
  1943. // - sizeof(Trailer) bytes *after* the Body pointer are valid
  1944. // and maybe used during the send. But must be restored when
  1945. // the send completes (with or without an error.)
  1946. //
  1947. // Scattered recv support is interesting in some protocols but it is
  1948. // not practical to simulate scattered recv's in the transport. Since
  1949. // the CO header is variable in length
  1950. } // extern "C"
  1951. #endif // __RPC_TRANS_HXX