Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1020 lines
23 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. *(ULONG *)(&TargetClientAddress->u.IPv4Address)
  171. = *(ULONG *)(&SourceClientAddress->u.IPv4Address);
  172. }
  173. else
  174. {
  175. RpcpMemoryCopy(TargetClientAddress->u.IPv6Address,
  176. SourceClientAddress->u.IPv6Address,
  177. MAX_IPv6_ADDRESS_SIZE
  178. );
  179. }
  180. }
  181. BYTE *ValidateRTSPacketCommon (
  182. IN BYTE *Packet,
  183. IN ULONG PacketLength
  184. );
  185. RPC_STATUS CheckPacketForForwarding (
  186. IN BYTE *Packet,
  187. IN ULONG PacketLength,
  188. IN ForwardDestinations CurrentLocation
  189. );
  190. // N.B. To be called only on packets coming
  191. // from a trusted source (i.e. we know the Flags
  192. // field will be there). If it is not trusted,
  193. // use UntrustedIsPingPacket
  194. inline BOOL TrustedIsPingPacket (
  195. IN BYTE *Packet
  196. )
  197. {
  198. rpcconn_tunnel_settings *RTS;
  199. RTS = (rpcconn_tunnel_settings *)Packet;
  200. return RTS->Flags & RTS_FLAG_PING;
  201. }
  202. BOOL UntrustedIsPingPacket (
  203. IN BYTE *Packet,
  204. IN ULONG PacketLength
  205. );
  206. BOOL IsOtherCmdPacket (
  207. IN BYTE *Packet,
  208. IN ULONG PacketLength
  209. );
  210. BOOL IsEchoPacket (
  211. IN BYTE *Packet,
  212. IN ULONG PacketLength
  213. );
  214. HTTP2SendContext *AllocateAndInitializePingPacket (
  215. void
  216. );
  217. HTTP2SendContext *AllocateAndInitializePingPacketWithSize (
  218. IN ULONG TotalPacketSize
  219. );
  220. RPC_STATUS ParseAndFreePingPacket (
  221. IN BYTE *Packet,
  222. IN ULONG PacketLength
  223. );
  224. ULONG GetD1_A1TotalLength (
  225. void
  226. );
  227. HTTP2SendContext *AllocateAndInitializeEmptyRTS (
  228. void
  229. );
  230. RPC_STATUS ParseAndFreeEmptyRTS (
  231. IN BYTE *Packet,
  232. IN ULONG PacketLength
  233. );
  234. RPC_STATUS ParseEmptyRTS (
  235. IN BYTE *Packet,
  236. IN ULONG PacketLength
  237. );
  238. HTTP2SendContext *AllocateAndInitializeEmptyRTSWithDestination (
  239. IN ForwardDestinations Destination
  240. );
  241. RPC_STATUS ParseEmptyRTSWithDestination (
  242. IN BYTE *Packet,
  243. IN ULONG PacketLength,
  244. IN ForwardDestinations ExpectedDestination
  245. );
  246. RPC_STATUS ParseAndFreeEmptyRTSWithDestination (
  247. IN BYTE *Packet,
  248. IN ULONG PacketLength,
  249. IN ForwardDestinations ExpectedDestination
  250. );
  251. inline BOOL IsEmptyRTS (
  252. IN BYTE *Packet,
  253. IN ULONG PacketLength
  254. )
  255. {
  256. RPC_STATUS RpcStatus;
  257. RpcStatus = ParseEmptyRTS(Packet,
  258. PacketLength
  259. );
  260. return (RpcStatus == RPC_S_OK);
  261. }
  262. inline BOOL IsEmptyRTSWithDestination (
  263. IN BYTE *Packet,
  264. IN ULONG PacketLength,
  265. IN ForwardDestinations ExpectedDestination
  266. )
  267. {
  268. RPC_STATUS RpcStatus;
  269. RpcStatus = ParseEmptyRTSWithDestination(Packet,
  270. PacketLength,
  271. ExpectedDestination
  272. );
  273. return (RpcStatus == RPC_S_OK);
  274. }
  275. HTTP2SendContext *AllocateAndInitializeD1_A1 (
  276. IN ULONG ProtocolVersion,
  277. IN HTTP2Cookie *ConnectionCookie,
  278. IN HTTP2Cookie *ChannelCookie,
  279. IN ULONG ClientReceiveWindow
  280. );
  281. RPC_STATUS ParseAndFreeD1_A1 (
  282. IN BYTE *Packet,
  283. IN ULONG PacketLength,
  284. OUT ULONG *ProtocolVersion,
  285. OUT HTTP2Cookie *ConnectionCookie,
  286. OUT HTTP2Cookie *ChannelCookie,
  287. OUT ULONG *ClientReceiveWindow
  288. );
  289. HTTP2SendContext *AllocateAndInitializeD1_A2 (
  290. IN ULONG ProtocolVersion,
  291. IN HTTP2Cookie *ConnectionCookie,
  292. IN HTTP2Cookie *ChannelCookie,
  293. IN ULONG ChannelLifetime,
  294. IN ULONG ProxyReceiveWindow
  295. );
  296. RPC_STATUS ParseD1_A2 (
  297. IN BYTE *Packet,
  298. IN ULONG PacketLength,
  299. OUT ULONG *ProtocolVersion,
  300. OUT HTTP2Cookie *ConnectionCookie,
  301. OUT HTTP2Cookie *ChannelCookie,
  302. OUT ULONG *ChannelLifetime,
  303. OUT ULONG *ProxyReceiveWindow
  304. );
  305. HTTP2SendContext *AllocateAndInitializeD1_B1 (
  306. IN ULONG ProtocolVersion,
  307. IN HTTP2Cookie *ConnectionCookie,
  308. IN HTTP2Cookie *ChannelCookie,
  309. IN ULONG ChannelLifetime,
  310. IN ULONG ClientKeepAliveInterval,
  311. IN HTTP2Cookie *AssociationGroupId
  312. );
  313. RPC_STATUS ParseAndFreeD1_B1 (
  314. IN BYTE *Packet,
  315. IN ULONG PacketLength,
  316. OUT ULONG *ProtocolVersion,
  317. OUT HTTP2Cookie *ConnectionCookie,
  318. OUT HTTP2Cookie *ChannelCookie,
  319. OUT ULONG *ChannelLifetime,
  320. OUT HTTP2Cookie *AssociationGroupId,
  321. OUT ULONG *ClientKeepAliveInterval
  322. );
  323. HTTP2SendContext *AllocateAndInitializeD1_B2 (
  324. IN ULONG ProtocolVersion,
  325. IN HTTP2Cookie *ConnectionCookie,
  326. IN HTTP2Cookie *ChannelCookie,
  327. IN ULONG ReceiveWindowSize,
  328. IN ULONG ConnectionTimeout,
  329. IN HTTP2Cookie *AssociationGroupId,
  330. IN ChannelSettingClientAddress *ClientAddress
  331. );
  332. RPC_STATUS ParseD1_B2 (
  333. IN BYTE *Packet,
  334. IN ULONG PacketLength,
  335. OUT ULONG *ProtocolVersion,
  336. OUT HTTP2Cookie *ConnectionCookie,
  337. OUT HTTP2Cookie *ChannelCookie,
  338. OUT ULONG *ReceiveWindowSize,
  339. OUT ULONG *ConnectionTimeout,
  340. OUT HTTP2Cookie *AssociationGroupId,
  341. OUT ChannelSettingClientAddress *ClientAddress
  342. );
  343. typedef enum tagHTTP2FirstServerPacketType
  344. {
  345. http2fsptD1_A2 = 0,
  346. http2fsptD1_B2,
  347. http2fsptD2_A2,
  348. http2fsptD4_A4
  349. } HTTP2FirstServerPacketType;
  350. RPC_STATUS GetFirstServerPacketType (
  351. IN BYTE *Packet,
  352. IN ULONG PacketLength,
  353. OUT HTTP2FirstServerPacketType *PacketType
  354. );
  355. typedef enum tagHTTP2ClientOpenedPacketType
  356. {
  357. http2coptD2_A4 = 0,
  358. http2coptD3_A4,
  359. http2coptD4_A2, // (same as D5/A2 btw)
  360. http2coptD4_A6,
  361. http2coptD5_A6,
  362. http2coptD4_A10,
  363. http2coptD5_B3
  364. } HTTP2ClientOpenedPacketType;
  365. RPC_STATUS GetClientOpenedPacketType (
  366. IN BYTE *Packet,
  367. IN ULONG PacketLength,
  368. OUT HTTP2ClientOpenedPacketType *PacketType
  369. );
  370. typedef enum tagHTTP2ServerOpenedPacketType
  371. {
  372. http2soptD2_A6orD3_A2 = 0,
  373. http2soptD2_B1,
  374. http2soptD4_A8,
  375. http2soptD5_A8,
  376. http2soptD4_A8orD5_A8,
  377. http2soptD2_A6,
  378. http2soptD3_A2
  379. } HTTP2ServerOpenedPacketType;
  380. RPC_STATUS GetServerOpenedPacketType (
  381. IN BYTE *Packet,
  382. IN ULONG PacketLength,
  383. OUT HTTP2ServerOpenedPacketType *PacketType
  384. );
  385. typedef enum tagHTTP2OtherCmdPacketType
  386. {
  387. http2ocptKeepAliveChange = 0
  388. } HTTP2OtherCmdPacketType;
  389. RPC_STATUS GetOtherCmdPacketType (
  390. IN BYTE *Packet,
  391. IN ULONG PacketLength,
  392. OUT HTTP2OtherCmdPacketType *PacketType
  393. );
  394. typedef enum tagHTTP2ServerOutChannelOtherCmdPacketType
  395. {
  396. http2sococptFlowControl = 0,
  397. http2sococptPingTrafficSentNotify
  398. } HTTP2ServerOutChannelOtherCmdPacketType;
  399. RPC_STATUS GetServerOutChannelOtherCmdPacketType (
  400. IN BYTE *Packet,
  401. IN ULONG PacketLength,
  402. OUT HTTP2ServerOutChannelOtherCmdPacketType *PacketType
  403. );
  404. HTTP2SendContext *AllocateAndInitializeResponseHeader (
  405. void
  406. );
  407. HTTP2SendContext *AllocateAndInitializeD1_A3 (
  408. IN ULONG ProxyConnectionTimeout
  409. );
  410. RPC_STATUS ParseAndFreeD1_A3 (
  411. IN BYTE *Packet,
  412. IN ULONG PacketLength,
  413. OUT ULONG *ProxyConnectionTimeout
  414. );
  415. HTTP2SendContext *AllocateAndInitializeD1_B3 (
  416. IN ULONG ReceiveWindowSize,
  417. IN ULONG UpdatedProtocolVersion
  418. );
  419. RPC_STATUS ParseAndFreeD1_B3 (
  420. IN BYTE *Packet,
  421. IN ULONG PacketLength,
  422. OUT ULONG *ReceiveWindowSize,
  423. OUT ULONG *UpdatedProtocolVersion
  424. );
  425. HTTP2SendContext *AllocateAndInitializeD1_C1 (
  426. IN ULONG UpdatedProtocolVersion,
  427. IN ULONG InProxyReceiveWindowSize,
  428. IN ULONG InProxyConnectionTimeout
  429. );
  430. RPC_STATUS ParseD1_C1 (
  431. IN BYTE *Packet,
  432. IN ULONG PacketLength,
  433. OUT ULONG *UpdatedProtocolVersion,
  434. OUT ULONG *InProxyReceiveWindowSize,
  435. OUT ULONG *InProxyConnectionTimeout
  436. );
  437. RPC_STATUS ParseAndFreeD1_C2 (
  438. IN BYTE *Packet,
  439. IN ULONG PacketLength,
  440. OUT ULONG *UpdatedProtocolVersion,
  441. OUT ULONG *InProxyReceiveWindowSize,
  442. OUT ULONG *InProxyConnectionTimeout
  443. );
  444. HTTP2SendContext *AllocateAndInitializeD2_A1 (
  445. IN ULONG ProtocolVersion,
  446. IN HTTP2Cookie *ConnectionCookie,
  447. IN HTTP2Cookie *OldChannelCookie,
  448. IN HTTP2Cookie *InChannelCookie
  449. );
  450. HTTP2SendContext *AllocateAndInitializeD2_A1 (
  451. IN ULONG ProtocolVersion,
  452. IN HTTP2Cookie *ConnectionCookie,
  453. IN HTTP2Cookie *OldChannelCookie,
  454. IN HTTP2Cookie *NewChannelCookie
  455. );
  456. RPC_STATUS ParseAndFreeD2_A1 (
  457. IN BYTE *Packet,
  458. IN ULONG PacketLength,
  459. OUT ULONG *ProtocolVersion,
  460. OUT HTTP2Cookie *ConnectionCookie,
  461. OUT HTTP2Cookie *OldChannelCookie,
  462. OUT HTTP2Cookie *NewChannelCookie
  463. );
  464. inline HTTP2SendContext *AllocateAndInitializeD3_A1 (
  465. IN ULONG ProtocolVersion,
  466. IN HTTP2Cookie *ConnectionCookie,
  467. IN HTTP2Cookie *OldChannelCookie,
  468. IN HTTP2Cookie *NewChannelCookie
  469. )
  470. {
  471. return AllocateAndInitializeD2_A1 (
  472. ProtocolVersion,
  473. ConnectionCookie,
  474. OldChannelCookie,
  475. NewChannelCookie
  476. );
  477. }
  478. inline RPC_STATUS ParseAndFreeD3_A1 (
  479. IN BYTE *Packet,
  480. IN ULONG PacketLength,
  481. OUT ULONG *ProtocolVersion,
  482. OUT HTTP2Cookie *ConnectionCookie,
  483. OUT HTTP2Cookie *OldChannelCookie,
  484. OUT HTTP2Cookie *NewChannelCookie
  485. )
  486. {
  487. return ParseAndFreeD2_A1 (
  488. Packet,
  489. PacketLength,
  490. ProtocolVersion,
  491. ConnectionCookie,
  492. OldChannelCookie,
  493. NewChannelCookie
  494. );
  495. }
  496. HTTP2SendContext *AllocateAndInitializeD2_A2 (
  497. IN ULONG ProtocolVersion,
  498. IN HTTP2Cookie *ConnectionCookie,
  499. IN HTTP2Cookie *OldChannelCookie,
  500. IN HTTP2Cookie *NewChannelCookie,
  501. IN ULONG ReceiveWindowSize,
  502. IN ULONG ConnectionTimeout
  503. );
  504. RPC_STATUS ParseD2_A2 (
  505. IN BYTE *Packet,
  506. IN ULONG PacketLength,
  507. OUT ULONG *ProtocolVersion,
  508. OUT HTTP2Cookie *ConnectionCookie,
  509. OUT HTTP2Cookie *OldChannelCookie,
  510. OUT HTTP2Cookie *NewChannelCookie,
  511. OUT ULONG *ReceiveWindowSize,
  512. OUT ULONG *ConnectionTimeout
  513. );
  514. HTTP2SendContext *AllocateAndInitializeD2_A3 (
  515. IN ForwardDestinations Destination,
  516. IN ULONG ProtocolVersion,
  517. IN ULONG ReceiveWindowSize,
  518. IN ULONG ConnectionTimeout
  519. );
  520. RPC_STATUS ParseAndFreeD2_A4 (
  521. IN BYTE *Packet,
  522. IN ULONG PacketLength,
  523. IN ForwardDestinations ExpectedDestination,
  524. OUT ULONG *ProtocolVersion,
  525. OUT ULONG *ReceiveWindowSize,
  526. OUT ULONG *ConnectionTimeout
  527. );
  528. HTTP2SendContext *AllocateAndInitializeD2_A5 (
  529. IN HTTP2Cookie *NewChannelCookie
  530. );
  531. RPC_STATUS ParseD2_A5 (
  532. IN BYTE *Packet,
  533. IN ULONG PacketLength,
  534. OUT HTTP2Cookie *NewChannelCookie
  535. );
  536. RPC_STATUS ParseAndFreeD2_A6 (
  537. IN BYTE *Packet,
  538. IN ULONG PacketLength,
  539. OUT HTTP2Cookie *NewChannelCookie
  540. );
  541. HTTP2SendContext *AllocateAndInitializeD2_B2 (
  542. IN ULONG ServerReceiveWindow
  543. );
  544. RPC_STATUS ParseAndFreeD2_B2 (
  545. IN BYTE *Packet,
  546. IN ULONG PacketLength,
  547. OUT ULONG *ServerReceiveWindow
  548. );
  549. inline HTTP2SendContext *AllocateAndInitializeD3_A2 (
  550. IN HTTP2Cookie *NewChannelCookie
  551. )
  552. {
  553. // D3/A2 is same as D2/A5 and D2/A6
  554. return AllocateAndInitializeD2_A5 (NewChannelCookie);
  555. }
  556. inline RPC_STATUS ParseAndFreeD3_A2 (
  557. IN BYTE *Packet,
  558. IN ULONG PacketLength,
  559. OUT HTTP2Cookie *NewChannelCookie
  560. )
  561. {
  562. // D3/A2 is same as D2/A5 and D2/A6
  563. return ParseAndFreeD2_A6 (Packet,
  564. PacketLength,
  565. NewChannelCookie
  566. );
  567. }
  568. inline BOOL IsD2_A4OrD3_A4 (
  569. IN BYTE *Packet,
  570. IN ULONG PacketLength
  571. )
  572. {
  573. // D3/A4 is an empty RTS with destination for the client
  574. return (IsEmptyRTSWithDestination (Packet,
  575. PacketLength,
  576. fdClient
  577. ) == FALSE);
  578. }
  579. inline RPC_STATUS ParseAndFreeD3_A4 (
  580. IN BYTE *Packet,
  581. IN ULONG PacketLength
  582. )
  583. {
  584. // D3/A4 is an empty RTS packet with destination
  585. return ParseAndFreeEmptyRTSWithDestination (Packet,
  586. PacketLength,
  587. fdClient
  588. );
  589. }
  590. inline HTTP2SendContext *AllocateAndInitializeD3_A5 (
  591. IN HTTP2Cookie *NewChannelCookie
  592. )
  593. {
  594. // D3/A5 is same as D2/A5 and D2/A6
  595. return AllocateAndInitializeD2_A5 (NewChannelCookie);
  596. }
  597. inline RPC_STATUS ParseAndFreeD3_A5 (
  598. IN BYTE *Packet,
  599. IN ULONG PacketLength,
  600. OUT HTTP2Cookie *NewChannelCookie
  601. )
  602. {
  603. // D3/A5 is same as D2/A5 and D2/A6
  604. return ParseAndFreeD2_A6 (Packet,
  605. PacketLength,
  606. NewChannelCookie
  607. );
  608. }
  609. inline HTTP2SendContext *AllocateAndInitializeD4_A1 (
  610. void
  611. )
  612. {
  613. HTTP2SendContext *SendContext;
  614. SendContext = AllocateAndInitializeEmptyRTSWithDestination (fdClient);
  615. if (SendContext)
  616. {
  617. GetRTSPacketFromSendContext(SendContext)->Flags = RTS_FLAG_RECYCLE_CHANNEL;
  618. }
  619. return SendContext;
  620. }
  621. RPC_STATUS ParseAndFreeD4_A2 (
  622. IN BYTE *Packet,
  623. IN ULONG PacketLength
  624. );
  625. ULONG GetD4_A3TotalLength (
  626. void
  627. );
  628. ULONG GetD4_A11TotalLength (
  629. void
  630. );
  631. HTTP2SendContext *AllocateAndInitializeD4_A3 (
  632. IN ULONG ProtocolVersion,
  633. IN HTTP2Cookie *ConnectionCookie,
  634. IN HTTP2Cookie *OldChannelCookie,
  635. IN HTTP2Cookie *NewChannelCookie,
  636. IN ULONG ClientReceiveWindow
  637. );
  638. RPC_STATUS ParseAndFreeD4_A3 (
  639. IN BYTE *Packet,
  640. IN ULONG PacketLength,
  641. OUT ULONG *ProtocolVersion,
  642. OUT HTTP2Cookie *ConnectionCookie,
  643. OUT HTTP2Cookie *OldChannelCookie,
  644. OUT HTTP2Cookie *NewChannelCookie,
  645. OUT ULONG *ClientReceiveWindow
  646. );
  647. RPC_STATUS ParseD4_A3 (
  648. IN BYTE *Packet,
  649. IN ULONG PacketLength,
  650. OUT ULONG *ProtocolVersion,
  651. OUT HTTP2Cookie *ConnectionCookie,
  652. OUT HTTP2Cookie *OldChannelCookie,
  653. OUT HTTP2Cookie *NewChannelCookie,
  654. OUT ULONG *ClientReceiveWindow
  655. );
  656. HTTP2SendContext *AllocateAndInitializeD4_A4 (
  657. IN ULONG ProtocolVersion,
  658. IN HTTP2Cookie *ConnectionCookie,
  659. IN HTTP2Cookie *OldChannelCookie,
  660. IN HTTP2Cookie *NewChannelCookie,
  661. IN ULONG ChannelLifetime,
  662. IN ULONG ProxyReceiveWindow,
  663. IN ULONG ProxyConnectionTimeout
  664. );
  665. RPC_STATUS ParseD4_A4 (
  666. IN BYTE *Packet,
  667. IN ULONG PacketLength,
  668. OUT ULONG *ProtocolVersion,
  669. OUT HTTP2Cookie *ConnectionCookie,
  670. OUT HTTP2Cookie *OldChannelCookie,
  671. OUT HTTP2Cookie *NewChannelCookie,
  672. OUT ULONG *ChannelLifetime,
  673. OUT ULONG *ProxyReceiveWindow,
  674. OUT ULONG *ProxyConnectionTimeout
  675. );
  676. inline HTTP2SendContext *AllocateAndInitializeD5_A4 (
  677. IN HTTP2Cookie *NewChannelCookie
  678. )
  679. {
  680. // D5/A4 is same as D3/A5
  681. return AllocateAndInitializeD3_A5 (NewChannelCookie);
  682. }
  683. inline RPC_STATUS ParseAndFreeD5_A4 (
  684. IN BYTE *Packet,
  685. IN ULONG PacketLength,
  686. OUT HTTP2Cookie *NewChannelCookie
  687. )
  688. {
  689. // D5/A4 is same as D3/A5
  690. return ParseAndFreeD3_A5 (Packet,
  691. PacketLength,
  692. NewChannelCookie
  693. );
  694. }
  695. HTTP2SendContext *AllocateAndInitializeD4_A5 (
  696. IN ForwardDestinations Destination,
  697. IN ULONG ProtocolVersion,
  698. IN ULONG ConnectionTimeout
  699. );
  700. RPC_STATUS ParseAndFreeD4_A6 (
  701. IN BYTE *Packet,
  702. IN ULONG PacketLength,
  703. IN ForwardDestinations ExpectedDestination,
  704. OUT ULONG *ProtocolVersion,
  705. OUT ULONG *ConnectionTimeout
  706. );
  707. HTTP2SendContext *AllocateAndInitializeD4_A7 (
  708. IN ForwardDestinations Destination,
  709. IN HTTP2Cookie *NewChannelCookie
  710. );
  711. RPC_STATUS ParseAndFreeD4_A8 (
  712. IN BYTE *Packet,
  713. IN ULONG PacketLength,
  714. IN ForwardDestinations ExpectedDestination,
  715. OUT HTTP2Cookie *NewChannelCookie
  716. );
  717. HTTP2SendContext *AllocateAndInitializeD4_A9 (
  718. void
  719. );
  720. RPC_STATUS ParseD4_A9 (
  721. IN BYTE *Packet,
  722. IN ULONG PacketLength
  723. );
  724. RPC_STATUS ParseAndFreeD4_A9 (
  725. IN BYTE *Packet,
  726. IN ULONG PacketLength
  727. );
  728. inline HTTP2SendContext *AllocateAndInitializeD4_A10 (
  729. void
  730. )
  731. {
  732. return AllocateAndInitializeD4_A9();
  733. }
  734. inline RPC_STATUS ParseD4_A10 (
  735. IN BYTE *Packet,
  736. IN ULONG PacketLength
  737. )
  738. {
  739. return ParseD4_A9 (Packet,
  740. PacketLength);
  741. }
  742. inline RPC_STATUS ParseAndFreeD4_A10 (
  743. IN BYTE *Packet,
  744. IN ULONG PacketLength
  745. )
  746. {
  747. return ParseAndFreeD4_A9 (Packet,
  748. PacketLength);
  749. }
  750. inline BOOL IsD4_A10 (
  751. IN BYTE *Packet,
  752. IN ULONG PacketLength
  753. )
  754. {
  755. return (ParseD4_A10(Packet, PacketLength) == RPC_S_OK);
  756. }
  757. inline RPC_STATUS ParseAndFreeD4_A11 (
  758. IN BYTE *Packet,
  759. IN ULONG PacketLength
  760. )
  761. {
  762. // same as D4/A10
  763. return ParseAndFreeD4_A10 (Packet,
  764. PacketLength);
  765. }
  766. HTTP2SendContext *AllocateAndInitializeD5_A5 (
  767. IN ForwardDestinations Destination
  768. );
  769. RPC_STATUS ParseD5_A6 (
  770. IN BYTE *Packet,
  771. IN ULONG PacketLength,
  772. IN ForwardDestinations ExpectedDestination
  773. );
  774. RPC_STATUS ParseAndFreeD5_A6 (
  775. IN BYTE *Packet,
  776. IN ULONG PacketLength,
  777. IN ForwardDestinations ExpectedDestination
  778. );
  779. inline BOOL IsD5_A6 (
  780. IN BYTE *Packet,
  781. IN ULONG PacketLength,
  782. IN ForwardDestinations ExpectedDestination
  783. )
  784. {
  785. return (ParseD5_A6(Packet, PacketLength, ExpectedDestination) == RPC_S_OK);
  786. }
  787. inline RPC_STATUS ParseAndFreeD5_A8 (
  788. IN BYTE *Packet,
  789. IN ULONG PacketLength,
  790. IN ForwardDestinations ExpectedDestination,
  791. OUT HTTP2Cookie *NewChannelCookie
  792. )
  793. {
  794. return ParseAndFreeD4_A8 (Packet,
  795. PacketLength,
  796. ExpectedDestination,
  797. NewChannelCookie
  798. );
  799. }
  800. HTTP2SendContext *AllocateAndInitializeD5_B1orB2 (
  801. IN BOOL IsAckOrNak
  802. );
  803. RPC_STATUS ParseAndFreeD5_B1orB2 (
  804. IN BYTE *Packet,
  805. IN ULONG PacketLength,
  806. OUT BOOL *IsAckOrNak
  807. );
  808. inline HTTP2SendContext *AllocateAndInitializeD5_B3 (
  809. void
  810. )
  811. {
  812. HTTP2SendContext *SendContext;
  813. SendContext = AllocateAndInitializeD5_B1orB2(TRUE);
  814. if (SendContext)
  815. GetRTSPacketFromSendContext(SendContext)->Flags |= RTS_FLAG_EOF;
  816. return SendContext;
  817. }
  818. RPC_STATUS ParseAndFreeD5_B3 (
  819. IN BYTE *Packet,
  820. IN ULONG PacketLength
  821. );
  822. HTTP2SendContext *AllocateAndInitializeKeepAliveChangePacket (
  823. IN ULONG NewKeepAliveInterval
  824. );
  825. RPC_STATUS ParseAndFreeKeepAliveChangePacket (
  826. IN BYTE *Packet,
  827. IN ULONG PacketLength,
  828. OUT ULONG *NewKeepAliveInterval
  829. );
  830. HTTP2SendContext *AllocateAndInitializeFlowControlAckPacket (
  831. IN ULONG BytesReceivedForAck,
  832. IN ULONG WindowForAck,
  833. IN HTTP2Cookie *CookieForChannel
  834. );
  835. HTTP2SendContext *AllocateAndInitializeFlowControlAckPacketWithDestination (
  836. IN ForwardDestinations Destination,
  837. IN ULONG BytesReceivedForAck,
  838. IN ULONG WindowForAck,
  839. IN HTTP2Cookie *CookieForChannel
  840. );
  841. RPC_STATUS ParseAndFreeFlowControlAckPacket (
  842. IN BYTE *Packet,
  843. IN ULONG PacketLength,
  844. OUT ULONG *BytesReceivedForAck,
  845. OUT ULONG *WindowForAck,
  846. OUT HTTP2Cookie *CookieForChannel
  847. );
  848. RPC_STATUS ParseAndFreeFlowControlAckPacketWithDestination (
  849. IN BYTE *Packet,
  850. IN ULONG PacketLength,
  851. IN ForwardDestinations ExpectedDestination,
  852. OUT ULONG *BytesReceivedForAck,
  853. OUT ULONG *WindowForAck,
  854. OUT HTTP2Cookie *CookieForChannel
  855. );
  856. RPC_STATUS ParseFlowControlAckPacketWithDestination (
  857. IN BYTE *Packet,
  858. IN ULONG PacketLength,
  859. IN ForwardDestinations ExpectedDestination,
  860. OUT ULONG *BytesReceivedForAck,
  861. OUT ULONG *WindowForAck,
  862. OUT HTTP2Cookie *CookieForChannel
  863. );
  864. HTTP2SendContext *AllocateAndInitializePingTrafficSentNotifyPacket (
  865. IN ULONG PingTrafficSentBytes
  866. );
  867. RPC_STATUS ParseAndFreePingTrafficSentNotifyPacket (
  868. IN BYTE *Packet,
  869. IN ULONG PacketLength,
  870. OUT ULONG *PingTrafficSentBytes
  871. );
  872. #endif // __HTTPRTS_HXX__