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.

1037 lines
25 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 2001
  3. Module Name:
  4. HttpRTS.hxx
  5. Abstract:
  6. HTTP2 RTS packets support functions.
  7. Author:
  8. KamenM 09-07-01 Created
  9. Revision History:
  10. --*/
  11. #if _MSC_VER >= 1200
  12. #pragma once
  13. #endif
  14. #ifndef __HTTPRTS_HXX__
  15. #define __HTTPRTS_HXX__
  16. const int BaseRTSSizeAndPadding = FIELD_OFFSET(rpcconn_tunnel_settings, Cmd)
  17. + ConstPadN(FIELD_OFFSET(rpcconn_tunnel_settings, Cmd), 4); // 4 because it goes on the wire
  18. const int HTTPSendContextSize = sizeof(HTTP2SendContext);
  19. const int HTTPSendContextSizeAndPadding = SIZE_OF_OBJECT_AND_PADDING(HTTP2SendContext);
  20. const int BaseRTSCommandSize = FIELD_OFFSET(TunnelSettingsCommand, u);
  21. extern const int ClientAddressSizes[];
  22. inline HTTP2SendContext *GetSendContextFromRTSPacket (
  23. IN rpcconn_tunnel_settings *Packet
  24. )
  25. {
  26. ASSERT(Packet->common.PTYPE == rpc_rts);
  27. return (HTTP2SendContext *)((BYTE *)Packet - HTTPSendContextSizeAndPadding);
  28. }
  29. inline rpcconn_tunnel_settings *GetRTSPacketFromSendContext (
  30. IN HTTP2SendContext *SendContext
  31. )
  32. {
  33. return (rpcconn_tunnel_settings *)((BYTE *)SendContext + HTTPSendContextSizeAndPadding);
  34. }
  35. const rpcconn_common RTSTemplate = {
  36. OSF_RPC_V20_VERS,
  37. OSF_RPC_V20_VERS_MINOR,
  38. rpc_rts,
  39. PFC_FIRST_FRAG | PFC_LAST_FRAG,
  40. {
  41. NDR_LOCAL_CHAR_DREP | NDR_LOCAL_INT_DREP,
  42. NDR_LOCAL_FP_DREP,
  43. 0,
  44. 0
  45. },
  46. 0,
  47. 0,
  48. 0
  49. };
  50. inline void InitializeSendContextAndBaseRTS (
  51. IN HTTP2SendContext *SendContext,
  52. IN ULONG ExtraBytes
  53. )
  54. {
  55. rpcconn_tunnel_settings *RTS = GetRTSPacketFromSendContext(SendContext);
  56. #if DBG
  57. SendContext->ListEntryUsed = FALSE;
  58. #endif
  59. SendContext->maxWriteBuffer = BaseRTSSizeAndPadding + ExtraBytes;
  60. SendContext->pWriteBuffer = (BUFFER)RTS;
  61. SendContext->TrafficType = http2ttRTS;
  62. SendContext->u.SyncEvent = NULL;
  63. SendContext->Flags = 0;
  64. SendContext->UserData = 0;
  65. RpcpMemoryCopy(RTS, &RTSTemplate, sizeof(rpcconn_common));
  66. RTS->common.frag_length = BaseRTSSizeAndPadding + ExtraBytes;
  67. RTS->Flags = 0;
  68. #if DBG
  69. RTS->NumberOfSettingCommands = 0xFFFF;
  70. #endif
  71. }
  72. inline HTTP2SendContext *AllocateAndInitializeRTSPacket (
  73. IN ULONG ExtraBytes
  74. )
  75. {
  76. ULONG MemorySize;
  77. HTTP2SendContext *SendContext;
  78. MemorySize = HTTPSendContextSizeAndPadding
  79. + BaseRTSSizeAndPadding
  80. + ExtraBytes // extra space for the commands
  81. ;
  82. SendContext = (HTTP2SendContext *)RpcAllocateBuffer(MemorySize);
  83. if (SendContext)
  84. {
  85. InitializeSendContextAndBaseRTS(SendContext, ExtraBytes);
  86. }
  87. return SendContext;
  88. }
  89. #if DBG
  90. inline void VerifyValidSendContext (
  91. IN HTTP2SendContext *SendContext
  92. )
  93. {
  94. ASSERT((SendContext->TrafficType == http2ttRTS)
  95. || (SendContext->TrafficType == http2ttData)
  96. || (SendContext->TrafficType == http2ttRaw));
  97. }
  98. #else // DBG
  99. inline void VerifyValidSendContext (
  100. IN HTTP2SendContext *SendContext
  101. )
  102. {
  103. }
  104. #endif // DBG
  105. inline void FreeRTSPacket (
  106. HTTP2SendContext *SendContext
  107. )
  108. {
  109. VerifyValidSendContext(SendContext);
  110. RpcFreeBuffer(SendContext);
  111. }
  112. inline BOOL IsRTSPacket (
  113. IN BYTE *Packet
  114. )
  115. {
  116. return (((rpcconn_common *)Packet)->PTYPE == rpc_rts);
  117. }
  118. inline void FreeSendContextAndPossiblyData (
  119. IN HTTP2SendContext *SendContext
  120. )
  121. {
  122. if (SendContext->pWriteBuffer == (BYTE *)SendContext + HTTPSendContextSizeAndPadding)
  123. RpcFreeBuffer(SendContext);
  124. else
  125. {
  126. RpcFreeBuffer(SendContext->pWriteBuffer);
  127. RpcFreeBuffer(SendContext);
  128. }
  129. }
  130. inline HTTP2SendContext *AllocateAndInitializeContextFromPacket (
  131. IN BYTE *Packet,
  132. IN ULONG PacketLength
  133. )
  134. {
  135. HTTP2SendContext *SendContext;
  136. SendContext = (HTTP2SendContext *)RpcAllocateBuffer(HTTPSendContextSize);
  137. if (SendContext)
  138. {
  139. #if DBG
  140. SendContext->ListEntryUsed = FALSE;
  141. #endif
  142. SendContext->maxWriteBuffer = PacketLength;
  143. SendContext->pWriteBuffer = (BUFFER)Packet;
  144. if (IsRTSPacket(Packet))
  145. SendContext->TrafficType = http2ttRTS;
  146. else
  147. SendContext->TrafficType = http2ttData;
  148. SendContext->u.SyncEvent = NULL;
  149. SendContext->Flags = 0;
  150. SendContext->UserData = 0;
  151. }
  152. return SendContext;
  153. }
  154. inline TunnelSettingsCommand *SkipCommand (
  155. IN TunnelSettingsCommand *CurrentCommandPtr,
  156. IN int CurrentCommand
  157. )
  158. {
  159. return (TunnelSettingsCommand *)
  160. ((BYTE *)CurrentCommandPtr + BaseRTSCommandSize + SIZE_OF_RTS_CMD_AND_PADDING(CurrentCommand));
  161. }
  162. inline void CopyClientAddress (
  163. IN ChannelSettingClientAddress *TargetClientAddress,
  164. IN ChannelSettingClientAddress *SourceClientAddress
  165. )
  166. {
  167. TargetClientAddress->AddressType = SourceClientAddress->AddressType;
  168. if (SourceClientAddress->AddressType == catIPv4)
  169. {
  170. RpcpCopyIPv4Address((SOCKADDR_IN *)SourceClientAddress->u.IPv4Address,
  171. (SOCKADDR_IN *)TargetClientAddress->u.IPv4Address);
  172. }
  173. else
  174. {
  175. RpcpCopyIPv6Address((SOCKADDR_IN6 *)SourceClientAddress->u.IPv4Address,
  176. (SOCKADDR_IN6 *)TargetClientAddress->u.IPv4Address);
  177. }
  178. }
  179. BYTE *ValidateRTSPacketCommon (
  180. IN BYTE *Packet,
  181. IN ULONG PacketLength
  182. );
  183. RPC_STATUS CheckPacketForForwarding (
  184. IN BYTE *Packet,
  185. IN ULONG PacketLength,
  186. IN ForwardDestinations CurrentLocation
  187. );
  188. // N.B. To be called only on packets coming
  189. // from a trusted source (i.e. we know the Flags
  190. // field will be there). If it is not trusted,
  191. // use UntrustedIsPingPacket
  192. inline BOOL TrustedIsPingPacket (
  193. IN BYTE *Packet
  194. )
  195. {
  196. rpcconn_tunnel_settings *RTS;
  197. RTS = (rpcconn_tunnel_settings *)Packet;
  198. return RTS->Flags & RTS_FLAG_PING;
  199. }
  200. BOOL UntrustedIsPingPacket (
  201. IN BYTE *Packet,
  202. IN ULONG PacketLength
  203. );
  204. BOOL IsOtherCmdPacket (
  205. IN BYTE *Packet,
  206. IN ULONG PacketLength
  207. );
  208. BOOL IsEchoPacket (
  209. IN BYTE *Packet,
  210. IN ULONG PacketLength
  211. );
  212. HTTP2SendContext *AllocateAndInitializePingPacket (
  213. void
  214. );
  215. HTTP2SendContext *AllocateAndInitializePingPacketWithSize (
  216. IN ULONG TotalPacketSize
  217. );
  218. RPC_STATUS ParseAndFreePingPacket (
  219. IN BYTE *Packet,
  220. IN ULONG PacketLength
  221. );
  222. ULONG GetD1_A1TotalLength (
  223. void
  224. );
  225. HTTP2SendContext *AllocateAndInitializeEmptyRTS (
  226. void
  227. );
  228. RPC_STATUS ParseAndFreeEmptyRTS (
  229. IN BYTE *Packet,
  230. IN ULONG PacketLength
  231. );
  232. RPC_STATUS ParseEmptyRTS (
  233. IN BYTE *Packet,
  234. IN ULONG PacketLength
  235. );
  236. HTTP2SendContext *AllocateAndInitializeEmptyRTSWithDestination (
  237. IN ForwardDestinations Destination
  238. );
  239. RPC_STATUS ParseEmptyRTSWithDestination (
  240. IN BYTE *Packet,
  241. IN ULONG PacketLength,
  242. IN ForwardDestinations ExpectedDestination
  243. );
  244. RPC_STATUS ParseAndFreeEmptyRTSWithDestination (
  245. IN BYTE *Packet,
  246. IN ULONG PacketLength,
  247. IN ForwardDestinations ExpectedDestination
  248. );
  249. inline BOOL IsEmptyRTS (
  250. IN BYTE *Packet,
  251. IN ULONG PacketLength
  252. )
  253. {
  254. RPC_STATUS RpcStatus;
  255. RpcStatus = ParseEmptyRTS(Packet,
  256. PacketLength
  257. );
  258. return (RpcStatus == RPC_S_OK);
  259. }
  260. inline BOOL IsEmptyRTSWithDestination (
  261. IN BYTE *Packet,
  262. IN ULONG PacketLength,
  263. IN ForwardDestinations ExpectedDestination
  264. )
  265. {
  266. RPC_STATUS RpcStatus;
  267. RpcStatus = ParseEmptyRTSWithDestination(Packet,
  268. PacketLength,
  269. ExpectedDestination
  270. );
  271. return (RpcStatus == RPC_S_OK);
  272. }
  273. HTTP2SendContext *AllocateAndInitializeD1_A1 (
  274. IN ULONG ProtocolVersion,
  275. IN HTTP2Cookie *ConnectionCookie,
  276. IN HTTP2Cookie *ChannelCookie,
  277. IN ULONG ClientReceiveWindow
  278. );
  279. RPC_STATUS ParseAndFreeD1_A1 (
  280. IN BYTE *Packet,
  281. IN ULONG PacketLength,
  282. OUT ULONG *ProtocolVersion,
  283. OUT HTTP2Cookie *ConnectionCookie,
  284. OUT HTTP2Cookie *ChannelCookie,
  285. OUT ULONG *ClientReceiveWindow
  286. );
  287. HTTP2SendContext *AllocateAndInitializeD1_A2 (
  288. IN ULONG ProtocolVersion,
  289. IN HTTP2Cookie *ConnectionCookie,
  290. IN HTTP2Cookie *ChannelCookie,
  291. IN ULONG ChannelLifetime,
  292. IN ULONG ProxyReceiveWindow
  293. );
  294. RPC_STATUS ParseD1_A2 (
  295. IN BYTE *Packet,
  296. IN ULONG PacketLength,
  297. OUT ULONG *ProtocolVersion,
  298. OUT HTTP2Cookie *ConnectionCookie,
  299. OUT HTTP2Cookie *ChannelCookie,
  300. OUT ULONG *ChannelLifetime,
  301. OUT ULONG *ProxyReceiveWindow
  302. );
  303. HTTP2SendContext *AllocateAndInitializeD1_B1 (
  304. IN ULONG ProtocolVersion,
  305. IN HTTP2Cookie *ConnectionCookie,
  306. IN HTTP2Cookie *ChannelCookie,
  307. IN ULONG ChannelLifetime,
  308. IN ULONG ClientKeepAliveInterval,
  309. IN HTTP2Cookie *AssociationGroupId
  310. );
  311. RPC_STATUS ParseAndFreeD1_B1 (
  312. IN BYTE *Packet,
  313. IN ULONG PacketLength,
  314. OUT ULONG *ProtocolVersion,
  315. OUT HTTP2Cookie *ConnectionCookie,
  316. OUT HTTP2Cookie *ChannelCookie,
  317. OUT ULONG *ChannelLifetime,
  318. OUT HTTP2Cookie *AssociationGroupId,
  319. OUT ULONG *ClientKeepAliveInterval
  320. );
  321. HTTP2SendContext *AllocateAndInitializeD1_B2 (
  322. IN ULONG ProtocolVersion,
  323. IN HTTP2Cookie *ConnectionCookie,
  324. IN HTTP2Cookie *ChannelCookie,
  325. IN ULONG ReceiveWindowSize,
  326. IN ULONG ConnectionTimeout,
  327. IN HTTP2Cookie *AssociationGroupId,
  328. IN ChannelSettingClientAddress *ClientAddress
  329. );
  330. RPC_STATUS ParseD1_B2 (
  331. IN BYTE *Packet,
  332. IN ULONG PacketLength,
  333. OUT ULONG *ProtocolVersion,
  334. OUT HTTP2Cookie *ConnectionCookie,
  335. OUT HTTP2Cookie *ChannelCookie,
  336. OUT ULONG *ReceiveWindowSize,
  337. OUT ULONG *ConnectionTimeout,
  338. OUT HTTP2Cookie *AssociationGroupId,
  339. OUT ChannelSettingClientAddress *ClientAddress
  340. );
  341. typedef enum tagHTTP2FirstServerPacketType
  342. {
  343. http2fsptD1_A2 = 0,
  344. http2fsptD1_B2,
  345. http2fsptD2_A2,
  346. http2fsptD4_A4
  347. } HTTP2FirstServerPacketType;
  348. RPC_STATUS GetFirstServerPacketType (
  349. IN BYTE *Packet,
  350. IN ULONG PacketLength,
  351. OUT HTTP2FirstServerPacketType *PacketType
  352. );
  353. typedef enum tagHTTP2ClientOpenedPacketType
  354. {
  355. http2coptD2_A4 = 0,
  356. http2coptD3_A4,
  357. http2coptD4_A2, // (same as D5/A2 btw)
  358. http2coptD4_A6,
  359. http2coptD5_A6,
  360. http2coptD4_A10,
  361. http2coptD5_B3
  362. } HTTP2ClientOpenedPacketType;
  363. RPC_STATUS GetClientOpenedPacketType (
  364. IN BYTE *Packet,
  365. IN ULONG PacketLength,
  366. OUT HTTP2ClientOpenedPacketType *PacketType
  367. );
  368. typedef enum tagHTTP2ServerOpenedPacketType
  369. {
  370. http2soptD2_A6orD3_A2 = 0,
  371. http2soptD2_B1,
  372. http2soptD4_A8,
  373. http2soptD5_A8,
  374. http2soptD4_A8orD5_A8,
  375. http2soptD2_A6,
  376. http2soptD3_A2
  377. } HTTP2ServerOpenedPacketType;
  378. RPC_STATUS GetServerOpenedPacketType (
  379. IN BYTE *Packet,
  380. IN ULONG PacketLength,
  381. OUT HTTP2ServerOpenedPacketType *PacketType
  382. );
  383. typedef enum tagHTTP2OtherCmdPacketType
  384. {
  385. http2ocptKeepAliveChange = 0
  386. } HTTP2OtherCmdPacketType;
  387. RPC_STATUS GetOtherCmdPacketType (
  388. IN BYTE *Packet,
  389. IN ULONG PacketLength,
  390. OUT HTTP2OtherCmdPacketType *PacketType
  391. );
  392. typedef enum tagHTTP2ServerOutChannelOtherCmdPacketType
  393. {
  394. http2sococptFlowControl = 0,
  395. http2sococptPingTrafficSentNotify
  396. } HTTP2ServerOutChannelOtherCmdPacketType;
  397. RPC_STATUS GetServerOutChannelOtherCmdPacketType (
  398. IN BYTE *Packet,
  399. IN ULONG PacketLength,
  400. OUT HTTP2ServerOutChannelOtherCmdPacketType *PacketType
  401. );
  402. HTTP2SendContext *AllocateAndInitializeResponseHeader (
  403. void
  404. );
  405. HTTP2SendContext *AllocateAndInitializeD1_A3 (
  406. IN ULONG ProxyConnectionTimeout
  407. );
  408. RPC_STATUS ParseAndFreeD1_A3 (
  409. IN BYTE *Packet,
  410. IN ULONG PacketLength,
  411. OUT ULONG *ProxyConnectionTimeout
  412. );
  413. HTTP2SendContext *AllocateAndInitializeD1_B3 (
  414. IN ULONG ReceiveWindowSize,
  415. IN ULONG UpdatedProtocolVersion
  416. );
  417. RPC_STATUS ParseAndFreeD1_B3 (
  418. IN BYTE *Packet,
  419. IN ULONG PacketLength,
  420. OUT ULONG *ReceiveWindowSize,
  421. OUT ULONG *UpdatedProtocolVersion
  422. );
  423. HTTP2SendContext *AllocateAndInitializeD1_C1 (
  424. IN ULONG UpdatedProtocolVersion,
  425. IN ULONG InProxyReceiveWindowSize,
  426. IN ULONG InProxyConnectionTimeout
  427. );
  428. RPC_STATUS ParseD1_C1 (
  429. IN BYTE *Packet,
  430. IN ULONG PacketLength,
  431. OUT ULONG *UpdatedProtocolVersion,
  432. OUT ULONG *InProxyReceiveWindowSize,
  433. OUT ULONG *InProxyConnectionTimeout
  434. );
  435. RPC_STATUS ParseAndFreeD1_C2 (
  436. IN BYTE *Packet,
  437. IN ULONG PacketLength,
  438. OUT ULONG *UpdatedProtocolVersion,
  439. OUT ULONG *InProxyReceiveWindowSize,
  440. OUT ULONG *InProxyConnectionTimeout
  441. );
  442. HTTP2SendContext *AllocateAndInitializeD2_A1 (
  443. IN ULONG ProtocolVersion,
  444. IN HTTP2Cookie *ConnectionCookie,
  445. IN HTTP2Cookie *OldChannelCookie,
  446. IN HTTP2Cookie *InChannelCookie
  447. );
  448. HTTP2SendContext *AllocateAndInitializeD2_A1 (
  449. IN ULONG ProtocolVersion,
  450. IN HTTP2Cookie *ConnectionCookie,
  451. IN HTTP2Cookie *OldChannelCookie,
  452. IN HTTP2Cookie *NewChannelCookie
  453. );
  454. RPC_STATUS ParseAndFreeD2_A1 (
  455. IN BYTE *Packet,
  456. IN ULONG PacketLength,
  457. OUT ULONG *ProtocolVersion,
  458. OUT HTTP2Cookie *ConnectionCookie,
  459. OUT HTTP2Cookie *OldChannelCookie,
  460. OUT HTTP2Cookie *NewChannelCookie
  461. );
  462. inline HTTP2SendContext *AllocateAndInitializeD3_A1 (
  463. IN ULONG ProtocolVersion,
  464. IN HTTP2Cookie *ConnectionCookie,
  465. IN HTTP2Cookie *OldChannelCookie,
  466. IN HTTP2Cookie *NewChannelCookie
  467. )
  468. {
  469. return AllocateAndInitializeD2_A1 (
  470. ProtocolVersion,
  471. ConnectionCookie,
  472. OldChannelCookie,
  473. NewChannelCookie
  474. );
  475. }
  476. inline RPC_STATUS ParseAndFreeD3_A1 (
  477. IN BYTE *Packet,
  478. IN ULONG PacketLength,
  479. OUT ULONG *ProtocolVersion,
  480. OUT HTTP2Cookie *ConnectionCookie,
  481. OUT HTTP2Cookie *OldChannelCookie,
  482. OUT HTTP2Cookie *NewChannelCookie
  483. )
  484. {
  485. return ParseAndFreeD2_A1 (
  486. Packet,
  487. PacketLength,
  488. ProtocolVersion,
  489. ConnectionCookie,
  490. OldChannelCookie,
  491. NewChannelCookie
  492. );
  493. }
  494. HTTP2SendContext *AllocateAndInitializeD2_A2 (
  495. IN ULONG ProtocolVersion,
  496. IN HTTP2Cookie *ConnectionCookie,
  497. IN HTTP2Cookie *OldChannelCookie,
  498. IN HTTP2Cookie *NewChannelCookie,
  499. IN ULONG ReceiveWindowSize,
  500. IN ULONG ConnectionTimeout
  501. );
  502. RPC_STATUS ParseD2_A2 (
  503. IN BYTE *Packet,
  504. IN ULONG PacketLength,
  505. OUT ULONG *ProtocolVersion,
  506. OUT HTTP2Cookie *ConnectionCookie,
  507. OUT HTTP2Cookie *OldChannelCookie,
  508. OUT HTTP2Cookie *NewChannelCookie,
  509. OUT ULONG *ReceiveWindowSize,
  510. OUT ULONG *ConnectionTimeout
  511. );
  512. HTTP2SendContext *AllocateAndInitializeD2_A3 (
  513. IN ForwardDestinations Destination,
  514. IN ULONG ProtocolVersion,
  515. IN ULONG ReceiveWindowSize,
  516. IN ULONG ConnectionTimeout
  517. );
  518. BOOL IsD2_A3Packet (
  519. IN BYTE *Packet,
  520. IN ULONG PacketLength,
  521. OUT ULONG *ProtocolVersion
  522. );
  523. RPC_STATUS ParseAndFreeD2_A4 (
  524. IN BYTE *Packet,
  525. IN ULONG PacketLength,
  526. IN ForwardDestinations ExpectedDestination,
  527. OUT ULONG *ProtocolVersion,
  528. OUT ULONG *ReceiveWindowSize,
  529. OUT ULONG *ConnectionTimeout
  530. );
  531. HTTP2SendContext *AllocateAndInitializeD2_A5 (
  532. IN HTTP2Cookie *NewChannelCookie
  533. );
  534. RPC_STATUS ParseD2_A5 (
  535. IN BYTE *Packet,
  536. IN ULONG PacketLength,
  537. OUT HTTP2Cookie *NewChannelCookie
  538. );
  539. RPC_STATUS ParseAndFreeD2_A6 (
  540. IN BYTE *Packet,
  541. IN ULONG PacketLength,
  542. OUT HTTP2Cookie *NewChannelCookie
  543. );
  544. HTTP2SendContext *AllocateAndInitializeD2_B2 (
  545. IN ULONG ServerReceiveWindow
  546. );
  547. RPC_STATUS ParseAndFreeD2_B2 (
  548. IN BYTE *Packet,
  549. IN ULONG PacketLength,
  550. OUT ULONG *ServerReceiveWindow
  551. );
  552. inline HTTP2SendContext *AllocateAndInitializeD3_A2 (
  553. IN HTTP2Cookie *NewChannelCookie
  554. )
  555. {
  556. // D3/A2 is same as D2/A5 and D2/A6
  557. return AllocateAndInitializeD2_A5 (NewChannelCookie);
  558. }
  559. inline RPC_STATUS ParseAndFreeD3_A2 (
  560. IN BYTE *Packet,
  561. IN ULONG PacketLength,
  562. OUT HTTP2Cookie *NewChannelCookie
  563. )
  564. {
  565. // D3/A2 is same as D2/A5 and D2/A6
  566. return ParseAndFreeD2_A6 (Packet,
  567. PacketLength,
  568. NewChannelCookie
  569. );
  570. }
  571. inline BOOL IsD2_A4OrD3_A4 (
  572. IN BYTE *Packet,
  573. IN ULONG PacketLength
  574. )
  575. {
  576. // D3/A4 is an empty RTS with destination for the client
  577. return (IsEmptyRTSWithDestination (Packet,
  578. PacketLength,
  579. fdClient
  580. ) == FALSE);
  581. }
  582. inline RPC_STATUS ParseAndFreeD3_A4 (
  583. IN BYTE *Packet,
  584. IN ULONG PacketLength
  585. )
  586. {
  587. // D3/A4 is an empty RTS packet with destination
  588. return ParseAndFreeEmptyRTSWithDestination (Packet,
  589. PacketLength,
  590. fdClient
  591. );
  592. }
  593. inline HTTP2SendContext *AllocateAndInitializeD3_A5 (
  594. IN HTTP2Cookie *NewChannelCookie
  595. )
  596. {
  597. // D3/A5 is same as D2/A5 and D2/A6
  598. return AllocateAndInitializeD2_A5 (NewChannelCookie);
  599. }
  600. inline RPC_STATUS ParseAndFreeD3_A5 (
  601. IN BYTE *Packet,
  602. IN ULONG PacketLength,
  603. OUT HTTP2Cookie *NewChannelCookie
  604. )
  605. {
  606. // D3/A5 is same as D2/A5 and D2/A6
  607. return ParseAndFreeD2_A6 (Packet,
  608. PacketLength,
  609. NewChannelCookie
  610. );
  611. }
  612. inline HTTP2SendContext *AllocateAndInitializeD4_A1 (
  613. void
  614. )
  615. {
  616. HTTP2SendContext *SendContext;
  617. SendContext = AllocateAndInitializeEmptyRTSWithDestination (fdClient);
  618. if (SendContext)
  619. {
  620. GetRTSPacketFromSendContext(SendContext)->Flags = RTS_FLAG_RECYCLE_CHANNEL;
  621. }
  622. return SendContext;
  623. }
  624. RPC_STATUS ParseAndFreeD4_A2 (
  625. IN BYTE *Packet,
  626. IN ULONG PacketLength
  627. );
  628. ULONG GetD4_A3TotalLength (
  629. void
  630. );
  631. ULONG GetD4_A11TotalLength (
  632. void
  633. );
  634. HTTP2SendContext *AllocateAndInitializeD4_A3 (
  635. IN ULONG ProtocolVersion,
  636. IN HTTP2Cookie *ConnectionCookie,
  637. IN HTTP2Cookie *OldChannelCookie,
  638. IN HTTP2Cookie *NewChannelCookie,
  639. IN ULONG ClientReceiveWindow
  640. );
  641. RPC_STATUS ParseAndFreeD4_A3 (
  642. IN BYTE *Packet,
  643. IN ULONG PacketLength,
  644. OUT ULONG *ProtocolVersion,
  645. OUT HTTP2Cookie *ConnectionCookie,
  646. OUT HTTP2Cookie *OldChannelCookie,
  647. OUT HTTP2Cookie *NewChannelCookie,
  648. OUT ULONG *ClientReceiveWindow
  649. );
  650. RPC_STATUS ParseD4_A3 (
  651. IN BYTE *Packet,
  652. IN ULONG PacketLength,
  653. OUT ULONG *ProtocolVersion,
  654. OUT HTTP2Cookie *ConnectionCookie,
  655. OUT HTTP2Cookie *OldChannelCookie,
  656. OUT HTTP2Cookie *NewChannelCookie,
  657. OUT ULONG *ClientReceiveWindow
  658. );
  659. HTTP2SendContext *AllocateAndInitializeD4_A4 (
  660. IN ULONG ProtocolVersion,
  661. IN HTTP2Cookie *ConnectionCookie,
  662. IN HTTP2Cookie *OldChannelCookie,
  663. IN HTTP2Cookie *NewChannelCookie,
  664. IN ULONG ChannelLifetime,
  665. IN ULONG ProxyReceiveWindow,
  666. IN ULONG ProxyConnectionTimeout
  667. );
  668. RPC_STATUS ParseD4_A4 (
  669. IN BYTE *Packet,
  670. IN ULONG PacketLength,
  671. OUT ULONG *ProtocolVersion,
  672. OUT HTTP2Cookie *ConnectionCookie,
  673. OUT HTTP2Cookie *OldChannelCookie,
  674. OUT HTTP2Cookie *NewChannelCookie,
  675. OUT ULONG *ChannelLifetime,
  676. OUT ULONG *ProxyReceiveWindow,
  677. OUT ULONG *ProxyConnectionTimeout
  678. );
  679. inline HTTP2SendContext *AllocateAndInitializeD5_A4 (
  680. IN HTTP2Cookie *NewChannelCookie
  681. )
  682. {
  683. // D5/A4 is same as D3/A5
  684. return AllocateAndInitializeD3_A5 (NewChannelCookie);
  685. }
  686. inline RPC_STATUS ParseAndFreeD5_A4 (
  687. IN BYTE *Packet,
  688. IN ULONG PacketLength,
  689. OUT HTTP2Cookie *NewChannelCookie
  690. )
  691. {
  692. // D5/A4 is same as D3/A5
  693. return ParseAndFreeD3_A5 (Packet,
  694. PacketLength,
  695. NewChannelCookie
  696. );
  697. }
  698. HTTP2SendContext *AllocateAndInitializeD4_A5 (
  699. IN ForwardDestinations Destination,
  700. IN ULONG ProtocolVersion,
  701. IN ULONG ConnectionTimeout
  702. );
  703. RPC_STATUS ParseAndFreeD4_A6 (
  704. IN BYTE *Packet,
  705. IN ULONG PacketLength,
  706. IN ForwardDestinations ExpectedDestination,
  707. OUT ULONG *ProtocolVersion,
  708. OUT ULONG *ConnectionTimeout
  709. );
  710. HTTP2SendContext *AllocateAndInitializeD4_A7 (
  711. IN ForwardDestinations Destination,
  712. IN HTTP2Cookie *NewChannelCookie,
  713. IN ULONG ProtocolVersion
  714. );
  715. RPC_STATUS ParseAndFreeD4_A8 (
  716. IN BYTE *Packet,
  717. IN ULONG PacketLength,
  718. IN ForwardDestinations ExpectedDestination,
  719. OUT HTTP2Cookie *NewChannelCookie
  720. );
  721. BOOL IsNewD4_A7Packet (
  722. IN BYTE *Packet,
  723. IN ULONG PacketLength,
  724. IN ForwardDestinations ExpectedDestination,
  725. OUT ULONG *ProtocolVersion
  726. );
  727. void ConvertNewD4_A7ToD4_A8 (
  728. IN OUT BYTE *Packet,
  729. IN OUT ULONG *PacketLength
  730. );
  731. HTTP2SendContext *AllocateAndInitializeD4_A9 (
  732. void
  733. );
  734. RPC_STATUS ParseD4_A9 (
  735. IN BYTE *Packet,
  736. IN ULONG PacketLength
  737. );
  738. RPC_STATUS ParseAndFreeD4_A9 (
  739. IN BYTE *Packet,
  740. IN ULONG PacketLength
  741. );
  742. inline HTTP2SendContext *AllocateAndInitializeD4_A10 (
  743. void
  744. )
  745. {
  746. return AllocateAndInitializeD4_A9();
  747. }
  748. inline RPC_STATUS ParseD4_A10 (
  749. IN BYTE *Packet,
  750. IN ULONG PacketLength
  751. )
  752. {
  753. return ParseD4_A9 (Packet,
  754. PacketLength);
  755. }
  756. inline RPC_STATUS ParseAndFreeD4_A10 (
  757. IN BYTE *Packet,
  758. IN ULONG PacketLength
  759. )
  760. {
  761. return ParseAndFreeD4_A9 (Packet,
  762. PacketLength);
  763. }
  764. inline BOOL IsD4_A10 (
  765. IN BYTE *Packet,
  766. IN ULONG PacketLength
  767. )
  768. {
  769. return (ParseD4_A10(Packet, PacketLength) == RPC_S_OK);
  770. }
  771. inline RPC_STATUS ParseAndFreeD4_A11 (
  772. IN BYTE *Packet,
  773. IN ULONG PacketLength
  774. )
  775. {
  776. // same as D4/A10
  777. return ParseAndFreeD4_A10 (Packet,
  778. PacketLength);
  779. }
  780. HTTP2SendContext *AllocateAndInitializeD5_A5 (
  781. IN ForwardDestinations Destination
  782. );
  783. RPC_STATUS ParseD5_A6 (
  784. IN BYTE *Packet,
  785. IN ULONG PacketLength,
  786. IN ForwardDestinations ExpectedDestination
  787. );
  788. RPC_STATUS ParseAndFreeD5_A6 (
  789. IN BYTE *Packet,
  790. IN ULONG PacketLength,
  791. IN ForwardDestinations ExpectedDestination
  792. );
  793. inline BOOL IsD5_A6 (
  794. IN BYTE *Packet,
  795. IN ULONG PacketLength,
  796. IN ForwardDestinations ExpectedDestination
  797. )
  798. {
  799. return (ParseD5_A6(Packet, PacketLength, ExpectedDestination) == RPC_S_OK);
  800. }
  801. inline RPC_STATUS ParseAndFreeD5_A8 (
  802. IN BYTE *Packet,
  803. IN ULONG PacketLength,
  804. IN ForwardDestinations ExpectedDestination,
  805. OUT HTTP2Cookie *NewChannelCookie
  806. )
  807. {
  808. return ParseAndFreeD4_A8 (Packet,
  809. PacketLength,
  810. ExpectedDestination,
  811. NewChannelCookie
  812. );
  813. }
  814. HTTP2SendContext *AllocateAndInitializeD5_B1orB2 (
  815. IN BOOL IsAckOrNak
  816. );
  817. RPC_STATUS ParseAndFreeD5_B1orB2 (
  818. IN BYTE *Packet,
  819. IN ULONG PacketLength,
  820. OUT BOOL *IsAckOrNak
  821. );
  822. inline HTTP2SendContext *AllocateAndInitializeD5_B3 (
  823. void
  824. )
  825. {
  826. HTTP2SendContext *SendContext;
  827. SendContext = AllocateAndInitializeD5_B1orB2(TRUE);
  828. if (SendContext)
  829. GetRTSPacketFromSendContext(SendContext)->Flags |= RTS_FLAG_EOF;
  830. return SendContext;
  831. }
  832. RPC_STATUS ParseAndFreeD5_B3 (
  833. IN BYTE *Packet,
  834. IN ULONG PacketLength
  835. );
  836. HTTP2SendContext *AllocateAndInitializeKeepAliveChangePacket (
  837. IN ULONG NewKeepAliveInterval
  838. );
  839. RPC_STATUS ParseAndFreeKeepAliveChangePacket (
  840. IN BYTE *Packet,
  841. IN ULONG PacketLength,
  842. OUT ULONG *NewKeepAliveInterval
  843. );
  844. HTTP2SendContext *AllocateAndInitializeFlowControlAckPacket (
  845. IN ULONG BytesReceivedForAck,
  846. IN ULONG WindowForAck,
  847. IN HTTP2Cookie *CookieForChannel
  848. );
  849. HTTP2SendContext *AllocateAndInitializeFlowControlAckPacketWithDestination (
  850. IN ForwardDestinations Destination,
  851. IN ULONG BytesReceivedForAck,
  852. IN ULONG WindowForAck,
  853. IN HTTP2Cookie *CookieForChannel
  854. );
  855. RPC_STATUS ParseAndFreeFlowControlAckPacket (
  856. IN BYTE *Packet,
  857. IN ULONG PacketLength,
  858. OUT ULONG *BytesReceivedForAck,
  859. OUT ULONG *WindowForAck,
  860. OUT HTTP2Cookie *CookieForChannel
  861. );
  862. RPC_STATUS ParseAndFreeFlowControlAckPacketWithDestination (
  863. IN BYTE *Packet,
  864. IN ULONG PacketLength,
  865. IN ForwardDestinations ExpectedDestination,
  866. OUT ULONG *BytesReceivedForAck,
  867. OUT ULONG *WindowForAck,
  868. OUT HTTP2Cookie *CookieForChannel
  869. );
  870. RPC_STATUS ParseFlowControlAckPacketWithDestination (
  871. IN BYTE *Packet,
  872. IN ULONG PacketLength,
  873. IN ForwardDestinations ExpectedDestination,
  874. OUT ULONG *BytesReceivedForAck,
  875. OUT ULONG *WindowForAck,
  876. OUT HTTP2Cookie *CookieForChannel
  877. );
  878. HTTP2SendContext *AllocateAndInitializePingTrafficSentNotifyPacket (
  879. IN ULONG PingTrafficSentBytes
  880. );
  881. RPC_STATUS ParseAndFreePingTrafficSentNotifyPacket (
  882. IN BYTE *Packet,
  883. IN ULONG PacketLength,
  884. OUT ULONG *PingTrafficSentBytes
  885. );
  886. #endif // __HTTPRTS_HXX__