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.

295 lines
8.7 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. sda.h
  5. Abstract:
  6. This module contains session data area and related data structures.
  7. Author:
  8. Jameel Hyder (microsoft!jameelh)
  9. Revision History:
  10. 25 Apr 1992 Initial Version
  11. Notes: Tab stop: 4
  12. --*/
  13. #ifndef _SDA_
  14. #define _SDA_
  15. // sda_Flags values
  16. #define SDA_USER_NOT_LOGGEDIN 0x0000 //
  17. #define SDA_USER_LOGIN_PARTIAL 0x0001 // Encrypted logon is half-way done
  18. #define SDA_USER_LOGGEDIN 0x0002
  19. #define SDA_LOGIN_MASK 0x0003
  20. #define SDA_REQUEST_IN_PROCESS 0x0004 // A request is being processed
  21. #define SDA_REPLY_IN_PROCESS 0x0008 // A reply has been posted
  22. #define SDA_NAMEXSPACE_IN_USE 0x0010 // NameXSpace is in use by reply processing
  23. #define SDA_DEREF_VOLUME 0x0020 // Dereference volume before reply
  24. #define SDA_DEREF_OFORK 0x0040 // Dereference open-fork before reply
  25. #define SDA_LOGIN_FAILED 0x0080 // Funky stuff for AFP 2.1 Chooser
  26. #define SDA_CLIENT_CLOSE 0x0100 // Set if the close if hapenning from the client side
  27. #define SDA_QUEUE_IF_DPC 0x0200 // Copied from the dispatch table (see afpapi.c)
  28. #define SDA_SESSION_CLOSED 0x0400 // If set, do not close session in deref.
  29. #define SDA_SESSION_CLOSE_COMP 0x0800 // If set, close completion called for this session
  30. #define SDA_SESSION_OVER_TCP 0x1000 // this is an AFP/TCP session
  31. #define SDA_SESSION_NOTIFY_SENT 0x2000 // Server Notification sent to this sda
  32. #define SDA_CLOSING 0x8000 // Session is marked to die
  33. // sda_ClientType values
  34. #define SDA_CLIENT_GUEST NO_USER_AUTHENT
  35. #define SDA_CLIENT_CLEARTEXT CLEAR_TEXT_AUTHENT
  36. #define SDA_CLIENT_MSUAM_V1 CUSTOM_UAM_V1
  37. #define SDA_CLIENT_MSUAM_V2 CUSTOM_UAM_V2
  38. #define SDA_CLIENT_RANDNUM RANDNUM_EXCHANGE
  39. #define SDA_CLIENT_TWOWAY TWOWAY_EXCHANGE
  40. #define SDA_CLIENT_ADMIN AFP_NUM_UAMS
  41. #define MAX_REQ_ENTRIES 7
  42. #define MAX_REQ_ENTRIES_PLUS_1 8 // used to allocate space 1 DWORD more
  43. // than required. The first entry is
  44. // used to store pointer to VolDesc
  45. // or ConnDesc. The extra DWORD is used
  46. // to accomodate 64-bit pointer if we
  47. // have one
  48. #define MAX_VAR_ENTRIES 3
  49. #define SESSION_CHECK_TIME 60 // In seconds
  50. #define SESSION_WARN_TIME SESSION_CHECK_TIME * 10
  51. // SDA_SIZE is the total size allocated to the SDA pointer
  52. // This includes sizeof(SDA) plus additional buffer allocated for
  53. // copying strings into. This extra space is allocated after the
  54. // first sizeof(SDA) bytes. The size is purely a ball-park figure
  55. // The original design does not mention why the total space was 384
  56. // Currently we are doubling the space to accomodate 64-bit stuff
  57. #ifdef _WIN64
  58. #define SDA_SIZE (((768 - POOL_OVERHEAD)+7) & 0xfffffff8)
  59. #else
  60. #define SDA_SIZE (((450 - POOL_OVERHEAD)+7) & 0xfffffff8)
  61. #endif
  62. // Linked list of deferred request packets. If the session is already
  63. // processing a request, then subsequent requests are queued. These
  64. // are always handled in a FIFO order.
  65. typedef struct _DeferredRequestQueue
  66. {
  67. LIST_ENTRY drq_Link;
  68. PREQUEST drq_pRequest;
  69. } DFRDREQQ, *PDFRDREQQ;
  70. /*
  71. * This is the per-session data area. This is allocated whenever a listen is
  72. * posted. At that point it is in the outstanding session list. When the listen
  73. * is completed, it moves to the active session list.
  74. */
  75. #if DBG
  76. #define SDA_SIGNATURE *(DWORD *)"SDA"
  77. #define VALID_SDA(pSda) (((pSda) != NULL) && \
  78. ((pSda)->Signature == SDA_SIGNATURE))
  79. #else
  80. #define VALID_SDA(pSda) ((pSda) != NULL)
  81. #endif
  82. typedef struct _SessDataArea
  83. {
  84. #if DBG
  85. DWORD Signature;
  86. #endif
  87. struct _SessDataArea * sda_Next; // link to next session in session list
  88. AFP_SPIN_LOCK sda_Lock; // Lock for manipulating certain SDA
  89. // fields
  90. DWORD sda_Flags; // Bit mask of the SDA states
  91. LONG sda_RefCount; // Count of references to this SDA
  92. PASP_XPORT_ENTRIES sda_XportTable; // pointer to ASP's or DSI's entry points
  93. DWORD sda_MaxWriteSize; // 64000 for TCP/IP, 4624 for Appletalk
  94. PVOID sda_SessHandle; // Asp Session handle
  95. PREQUEST sda_Request; // Current request
  96. HANDLE sda_UserToken; // Logon token for this user.
  97. PSID sda_UserSid; // SID representing owner
  98. PSID sda_GroupSid; // SID representing primary group
  99. PTOKEN_GROUPS sda_pGroups; // List of groups this user is member of
  100. #ifdef INHERIT_DIRECTORY_PERMS
  101. DWORD sda_UID; // User Id corres. to sda_UserSid
  102. DWORD sda_GID; // Group Id corres. to sda_GroupSid
  103. #else
  104. PISECURITY_DESCRIPTOR sda_pSecDesc; // Security descriptor used by directory
  105. // Creation API
  106. DWORD sda_Dummy; // For alignment
  107. #endif
  108. PANSI_STRING sda_Message; // The actual message in macintosh ansi
  109. // The above field is used only for
  110. // client specific message. Broadcast
  111. // messages are stored in a global area
  112. UNICODE_STRING sda_WSName; // Workstation name of logged in user
  113. UNICODE_STRING sda_UserName; // User name
  114. UNICODE_STRING sda_DomainName; // DomainName for Login/ChgPwd
  115. #ifdef PROFILING
  116. TIME sda_ApiStartTime; // Time stamp when Api req. was recvd.
  117. TIME sda_QueueTime; // Time spent waiting for worker thread
  118. #endif
  119. DWORD sda_SessionId; // Session Id for use by admin APIs
  120. AFPTIME sda_TimeLoggedOn; // Time when session established
  121. // in macintosh time
  122. DWORD sda_tTillKickOff; // # of seconds before this session will
  123. // be kicked off
  124. struct _ConnDesc * sda_pConnDesc; // List of connections by this session
  125. struct _OpenForkSession sda_OpenForkSess;
  126. // List of open files by this session
  127. LONG sda_cOpenVolumes; // Number of volumes mounted (admin api)
  128. LONG sda_cOpenForks; // Number of forks opened (admin api)
  129. DWORD sda_MaxOForkRefNum; // High-water mark of the fork-ref num assigned
  130. BYTE sda_AfpFunc; // AFP API in execution for FSP
  131. BYTE sda_AfpSubFunc; // Sub function code used by some APIs
  132. BYTE sda_ClientVersion; // AFP Version of the client s/w
  133. // AFP_VER_20
  134. // AFP_VER_21
  135. BYTE sda_ClientType; // One of SDA_CLIENT_XXXX
  136. BYTE sda_PathType; // For all path based calls
  137. USHORT sda_SizeNameXSpace; // Constant, initialized once
  138. USHORT sda_ReplySize; // Size of the reply buffer
  139. #define sda_ReadStatus sda_SecUtilResult
  140. NTSTATUS sda_SecUtilResult; // Result of scurity utitility call
  141. PSID sda_SecUtilSid; // Name to Sid translation. Should be
  142. // freed if non-null.
  143. // The incoming packet is copied here. The parameters from the RequestBuf
  144. // are un-marshalled into this. Each API structures this differently. Make
  145. // sure sda_Name and sda_ReqBlock are together and next to each other AND
  146. // in this order. The code in afpapi.c depends on this while clearing this.
  147. // The extra DWORD is used in cases where the first entry is reused to
  148. // stored pointer values. On 64-bit architecture we require 2 DWORD at
  149. // the start of the ReqBlock.
  150. DWORD sda_ReqBlock[MAX_REQ_ENTRIES_PLUS_1];
  151. ANSI_STRING sda_Name[MAX_VAR_ENTRIES];
  152. #define sda_Name1 sda_Name[0]
  153. #define sda_Name2 sda_Name[1]
  154. #define sda_Name3 sda_Name[2]
  155. #define sda_IOBuf sda_ReplyBuf
  156. #define sda_IOSize sda_ReplySize
  157. PBYTE sda_ReplyBuf; // Reply Buffer (variable size)
  158. AFPAPIWORKER sda_WorkerRoutine; // Api Worker
  159. WORK_ITEM sda_WorkItem; // For queueing up to worker threads
  160. PBYTE sda_Challenge; // Challenge from MSV1_0
  161. LIST_ENTRY sda_DeferredQueue; // Queue of deferred requests
  162. PBYTE sda_NameBuf; // Space is allocated for variable
  163. // part of request buffer here.
  164. PBYTE sda_NameXSpace;
  165. } SDA, *PSDA;
  166. GLOBAL AFP_SPIN_LOCK AfpSdaLock EQU {0};// Lock for session list
  167. GLOBAL PSDA AfpSessionList EQU NULL;
  168. // Linked-List of sessions
  169. // These values are subject to tuning.
  170. GLOBAL LONG AfpNumSessions EQU 0;
  171. GLOBAL UNICODE_STRING AfpDefaultWksta EQU {0, 0, NULL};
  172. extern
  173. NTSTATUS
  174. AfpSdaInit(
  175. VOID
  176. );
  177. extern
  178. VOID
  179. AfpSdaDeInit(
  180. VOID
  181. );
  182. extern
  183. PSDA FASTCALL
  184. AfpSdaCreateNewSession(
  185. IN PVOID SessionHandle,
  186. IN BOOLEAN fOverTcp
  187. );
  188. extern
  189. VOID FASTCALL
  190. afpQueueDeferredRequest(
  191. IN PSDA pSda,
  192. IN PREQUEST pRequest
  193. );
  194. extern
  195. PSDA FASTCALL
  196. AfpSdaReferenceSessionById(
  197. IN DWORD SessId
  198. );
  199. extern
  200. PSDA FASTCALL
  201. AfpSdaReferenceSessionByPointer(
  202. IN PSDA pSda
  203. );
  204. extern
  205. VOID FASTCALL
  206. AfpSdaDereferenceSession(
  207. IN PSDA pSda
  208. );
  209. extern
  210. AFPSTATUS FASTCALL
  211. AfpSdaCloseSession(
  212. IN PSDA pSda
  213. );
  214. extern
  215. AFPSTATUS
  216. AfpAdmWSessionClose(
  217. IN OUT PVOID Inbuf OPTIONAL,
  218. IN LONG OutBufLen OPTIONAL,
  219. OUT PVOID Outbuf OPTIONAL
  220. );
  221. extern
  222. AFPSTATUS FASTCALL
  223. AfpSdaCheckSession(
  224. IN PVOID pContext
  225. );
  226. extern
  227. VOID FASTCALL
  228. AfpKillSessionsOverProtocol(
  229. IN BOOLEAN fAppletalkSessions
  230. );
  231. extern
  232. VOID FASTCALL
  233. afpUpdateDiskQuotaInfo(
  234. IN struct _ConnDesc * pConnDesc
  235. );
  236. #ifdef _SDA_LOCALS
  237. LOCAL DWORD afpNextSessionId = 1;
  238. LOCAL AFPSTATUS FASTCALL
  239. afpCloseSessionAndFreeSda(
  240. IN PSDA pSda
  241. );
  242. #endif // _SDA_LOCALS
  243. #endif // _SDA_