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.

129 lines
2.5 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation
  6. //
  7. // File: ktcontext.h
  8. //
  9. // Contents: Kerberos Tunneller context management prototypes &
  10. // definitions for the context structure.
  11. //
  12. // History: 28-Jun-2001 t-ryanj Created
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef __KTCONTEXT_H__
  16. #define __KTCONTEXT_H__
  17. #include <Winsock2.h>
  18. #include <Mswsock.h>
  19. #include <wininet.h>
  20. #include "ktdebug.h"
  21. //
  22. // _KTSTATUS defines different phases in the lifecycle of a session
  23. //
  24. enum _KTSTATUS {
  25. KT_SOCK_CONNECT,
  26. KT_SOCK_READ,
  27. KT_HTTP_WRITE,
  28. KT_HTTP_READ,
  29. KT_SOCK_WRITE,
  30. };
  31. //
  32. // KTBUFFER provides a chain of buffers to be used in read operations,
  33. // then can be coalesced for a write operation.
  34. //
  35. typedef struct _KTBUFFER {
  36. struct _KTBUFFER *next;
  37. ULONG buflen;
  38. ULONG bytesused;
  39. #pragma warning(disable:4200)
  40. BYTE buffer[];
  41. #pragma warning(default:4200)
  42. } KTBUFFER, *PKTBUFFER;
  43. //
  44. // Note that since the KTCONTEXT structure has an OVERLAPPED as its first
  45. // member, it in effect extends OVERLAPPED, and a ptr can be passed as an
  46. // LPOVERLAPPED to various i/o functions.
  47. //
  48. #define KTCONTEXT_BUFFER_LENGTH 128
  49. typedef struct _KTCONTEXT {
  50. //
  51. // Contexts are kept track of in a doubly linked list, so they can
  52. // be reliably destroyed
  53. //
  54. struct _KTCONTEXT *next;
  55. struct _KTCONTEXT *prev;
  56. //
  57. // this overlapped struct must be first
  58. //
  59. OVERLAPPED ol;
  60. //
  61. // Keeps track of the status of this session
  62. //
  63. _KTSTATUS Status;
  64. //
  65. // Socket context
  66. //
  67. SOCKET sock;
  68. DWORD ExpectedLength;
  69. ULONG TotalBytes;
  70. ULONG PduValue;
  71. //
  72. // Http context
  73. //
  74. LPBYTE pbProxies; /* in MULTI_SZ format */
  75. HINTERNET hConnect;
  76. HINTERNET hRequest;
  77. //
  78. // Buffers
  79. //
  80. PKTBUFFER buffers;
  81. PKTBUFFER emptybuf;
  82. } KTCONTEXT, *PKTCONTEXT;
  83. BOOL
  84. KtInitContexts(
  85. VOID
  86. );
  87. VOID
  88. KtCleanupContexts(
  89. VOID
  90. );
  91. PKTCONTEXT
  92. KtAcquireContext(
  93. IN SOCKET sock,
  94. IN ULONG size
  95. );
  96. VOID
  97. KtReleaseContext(
  98. IN PKTCONTEXT pContext
  99. );
  100. BOOL
  101. KtCoalesceBuffers(
  102. IN PKTCONTEXT pContext
  103. );
  104. BOOL
  105. KtGetMoreSpace(
  106. IN PKTCONTEXT pContext,
  107. IN ULONG size
  108. );
  109. #endif // __KTCONTEXT_H__