tests: Use real tempfile in pt_util-t
[openafs.git] / src / WINNT / afsrdr / user / RDRPipe.h
1 /*
2  * Copyright (c) 2008 Secure Endpoints, Inc.
3  * Copyright (c) 2009-2011 Your File System, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * - Redistributions of source code must retain the above copyright notice,
10  *   this list of conditions and the following disclaimer.
11  * - Redistributions in binary form must reproduce the above copyright notice,
12  *   this list of conditions and the following disclaimer in the documentation
13  *   and/or other materials provided with the distribution.
14  * - Neither the name of Secure Endpoints Inc. nor the names of its contributors
15  *   may be used to endorse or promote products derived from this software without
16  *   specific prior written permission from Secure Endpoints, Inc. and
17  *   Your File System, Inc.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 extern void RDR_InitPipe(void);
33
34 extern void RDR_ShutdownPipe(void);
35
36 extern DWORD RDR_SetupPipe( ULONG index, cm_fid_t *parentFid, cm_fid_t *rootFid,
37                             WCHAR *Name, DWORD NameLength,
38                             cm_user_t *userp);
39
40 extern void RDR_CleanupPipe(ULONG index);
41
42 extern DWORD RDR_Pipe_Read(ULONG index, ULONG BufferLength, void *MappedBuffer,
43                            ULONG *pBytesProcessed, cm_req_t *reqp, cm_user_t *userp);
44
45 extern DWORD RDR_Pipe_Write(ULONG index, ULONG BufferLength, void *MappedBuffer,
46                             cm_req_t *reqp, cm_user_t *userp);
47
48 extern DWORD RDR_Pipe_QueryInfo( ULONG index, ULONG InfoClass,
49                                  ULONG BufferLength, void *MappedBuffer,
50                                  ULONG *pBytesProcessed, cm_req_t *reqp, cm_user_t *userp);
51
52 extern DWORD RDR_Pipe_SetInfo( ULONG index, ULONG InfoClass,
53                                ULONG BufferLength, void *MappedBuffer,
54                                cm_req_t *reqp, cm_user_t *userp);
55
56 #ifdef RDR_PIPE_PRIVATE
57 typedef struct RDR_pipe {
58     struct RDR_pipe *next, *prev;
59     ULONG             index;
60     wchar_t           name[MAX_PATH];
61     cm_fid_t          parentFid;
62     cm_fid_t          rootFid;
63     cm_scache_t      *parentScp;
64     afs_uint32        flags;
65     afs_uint32        devstate;
66     msrpc_conn        rpc_conn;
67
68     /* input side */
69     char *inDatap;                      /* current position
70                                          * in input parameter block */
71     char *inAllocp;                     /* allocated input parameter block */
72     afs_uint32 inCopied;                /* # of input bytes copied in so far
73                                          * by write calls */
74     /* output side */
75     char *outDatap;                     /* output results assembled so far */
76     char *outAllocp;                    /* output results assembled so far */
77     afs_uint32 outCopied;               /* # of output bytes copied back so far */
78 } RDR_pipe_t;
79
80 /* flags for smb_ioctl_t */
81 #define RDR_PIPEFLAG_DATAIN     1       /* reading data from client to server */
82 #define RDR_PIPEFLAG_LOGON      2       /* got tokens from integrated logon */
83 #define RDR_PIPEFLAG_USEUTF8    4       /* this request is using UTF-8 strings */
84 #define RDR_PIPEFLAG_DATAOUT    8       /* sending data from server to client */
85
86 #define RDR_PIPEFLAG_RPC                0x0010
87 #define RDR_PIPEFLAG_MESSAGE_MODE       0x0020
88 #define RDR_PIPEFLAG_BLOCKING           0x0040
89 #define RDR_PIPEFLAG_INCALL             0x0080
90
91 /* Device state constants */
92 #define RDR_DEVICESTATE_READASBYTESTREAM    0x0000
93 #define RDR_DEVICESTATE_READMSGFROMPIPE     0x0100
94 #define RDR_DEVICESTATE_BYTESTREAMPIPE      0x0000
95 #define RDR_DEVICESTATE_MESSAGEMODEPIPE     0x0400
96 #define RDR_DEVICESTATE_PIPECLIENTEND       0x0000
97 #define RDR_DEVICESTATE_PIPESERVEREND       0x4000
98 #define RDR_DEVICESTATE_BLOCKING            0x8000
99
100 #define RDR_PIPE_MAXDATA        65536
101
102 /* procedure implementing an pipe */
103 typedef long (RDR_pipeProc_t)(RDR_pipe_t *, struct cm_user *userp);
104
105 extern RDR_pipe_t *RDR_FindPipe(ULONG index, int locked);
106
107 /*
108  * DDK Data Structures
109  *
110  * This is a userland module and does not include DDK headers.
111  * Replicate the DDK Data Structures required for pipe handling
112  * based on [MS-FSC]: File System Control Codes
113  *   http://msdn.microsoft.com/en-us/library/cc231987%28v=PROT.13%29.aspx
114  */
115 typedef enum _FILE_INFORMATION_CLASS {
116     FileDirectoryInformation         = 1,
117     FileFullDirectoryInformation,   // 2
118     FileBothDirectoryInformation,   // 3
119     FileBasicInformation,           // 4
120     FileStandardInformation,        // 5
121     FileInternalInformation,        // 6
122     FileEaInformation,              // 7
123     FileAccessInformation,          // 8
124     FileNameInformation,            // 9
125     FileRenameInformation,          // 10
126     FileLinkInformation,            // 11
127     FileNamesInformation,           // 12
128     FileDispositionInformation,     // 13
129     FilePositionInformation,        // 14
130     FileFullEaInformation,          // 15
131     FileModeInformation,            // 16
132     FileAlignmentInformation,       // 17
133     FileAllInformation,             // 18
134     FileAllocationInformation,      // 19
135     FileEndOfFileInformation,       // 20
136     FileAlternateNameInformation,   // 21
137     FileStreamInformation,          // 22
138     FilePipeInformation,            // 23
139     FilePipeLocalInformation,       // 24
140     FilePipeRemoteInformation,      // 25
141     FileMailslotQueryInformation,   // 26
142     FileMailslotSetInformation,     // 27
143     FileCompressionInformation,     // 28
144     FileObjectIdInformation,        // 29
145     FileCompletionInformation,      // 30
146     FileMoveClusterInformation,     // 31
147     FileQuotaInformation,           // 32
148     FileReparsePointInformation,    // 33
149     FileNetworkOpenInformation,     // 34
150     FileAttributeTagInformation,    // 35
151     FileTrackingInformation,        // 36
152     FileIdBothDirectoryInformation, // 37
153     FileIdFullDirectoryInformation, // 38
154     FileValidDataLengthInformation, // 39
155     FileShortNameInformation,       // 40
156     FileIoCompletionNotificationInformation, // 41
157     FileIoStatusBlockRangeInformation,       // 42
158     FileIoPriorityHintInformation,           // 43
159     FileSfioReserveInformation,              // 44
160     FileSfioVolumeInformation,               // 45
161     FileHardLinkInformation,                 // 46
162     FileProcessIdsUsingFileInformation,      // 47
163     FileNormalizedNameInformation,           // 48
164     FileNetworkPhysicalNameInformation,      // 49
165     FileIdGlobalTxDirectoryInformation,      // 50
166     FileIsRemoteDeviceInformation,           // 51
167     FileAttributeCacheInformation,           // 52
168     FileNumaNodeInformation,                 // 53
169     FileStandardLinkInformation,             // 54
170     FileRemoteProtocolInformation,           // 55
171     FileMaximumInformation
172 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
173
174 typedef struct _FILE_BASIC_INFORMATION {
175     LARGE_INTEGER CreationTime;
176     LARGE_INTEGER LastAccessTime;
177     LARGE_INTEGER LastWriteTime;
178     LARGE_INTEGER ChangeTime;
179     ULONG FileAttributes;
180 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
181
182 typedef struct _FILE_STANDARD_INFORMATION {
183     LARGE_INTEGER AllocationSize;
184     LARGE_INTEGER EndOfFile;
185     ULONG NumberOfLinks;
186     BOOLEAN DeletePending;
187     BOOLEAN IsDirectory;
188 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
189
190 typedef struct _FILE_NAME_INFORMATION {
191     ULONG FileNameLength;
192     WCHAR FileName[1];
193 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
194
195 typedef struct _FILE_PIPE_INFORMATION {
196      ULONG ReadMode;
197      ULONG CompletionMode;
198 } FILE_PIPE_INFORMATION, *PFILE_PIPE_INFORMATION;
199
200 typedef struct _FILE_PIPE_LOCAL_INFORMATION {
201      ULONG NamedPipeType;
202      ULONG NamedPipeConfiguration;
203      ULONG MaximumInstances;
204      ULONG CurrentInstances;
205      ULONG InboundQuota;
206      ULONG ReadDataAvailable;
207      ULONG OutboundQuota;
208      ULONG WriteQuotaAvailable;
209      ULONG NamedPipeState;
210      ULONG NamedPipeEnd;
211 } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
212
213 typedef struct _FILE_PIPE_REMOTE_INFORMATION {
214      LARGE_INTEGER CollectDataTime;
215      ULONG MaximumCollectionCount;
216 } FILE_PIPE_REMOTE_INFORMATION, *PFILE_PIPE_REMOTE_INFORMATION;
217
218 #define FILE_PIPE_BYTE_STREAM_TYPE          0x00000000
219 #define FILE_PIPE_MESSAGE_TYPE              0x00000001
220
221 #define FILE_PIPE_ACCEPT_REMOTE_CLIENTS     0x00000000
222 #define FILE_PIPE_REJECT_REMOTE_CLIENTS     0x00000002
223 #define FILE_PIPE_TYPE_VALID_MASK           0x00000003
224
225 #define FILE_PIPE_QUEUE_OPERATION           0x00000000
226 #define FILE_PIPE_COMPLETE_OPERATION        0x00000001
227
228 #define FILE_PIPE_BYTE_STREAM_MODE          0x00000000
229 #define FILE_PIPE_MESSAGE_MODE              0x00000001
230
231 #define FILE_PIPE_INBOUND                   0x00000000
232 #define FILE_PIPE_OUTBOUND                  0x00000001
233 #define FILE_PIPE_FULL_DUPLEX               0x00000002
234
235 #define FILE_PIPE_DISCONNECTED_STATE        0x00000001
236 #define FILE_PIPE_LISTENING_STATE           0x00000002
237 #define FILE_PIPE_CONNECTED_STATE           0x00000003
238 #define FILE_PIPE_CLOSING_STATE             0x00000004
239
240 #define FILE_PIPE_CLIENT_END                0x00000000
241 #define FILE_PIPE_SERVER_END                0x00000001
242
243 #define FILE_PIPE_READ_DATA                 0x00000000
244 #define FILE_PIPE_WRITE_SPACE               0x00000001
245 #endif
246