Export libwireshark symbols using WS_DLL_PUBLIC define
[jlayton/wireshark.git] / epan / dissectors / packet-windows-common.h
1 /* packet-windows-common.h
2  * Declarations for dissecting various Windows data types
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __PACKET_WINDOWS_COMMON_H__
26 #define __PACKET_WINDOWS_COMMON_H__
27
28 #include "ws_symbol_export.h"
29
30 /* Win32 errors.
31  * These defines specify the WERR error codes often encountered in ms DCE/RPC
32  * interfaces (those that do not return NT status that is)
33  *
34  * The list is generated from the samba doserr.h file by running :
35 (echo "#include \"doserr.h\"";echo "#define W_ERROR(x) x";cat doserr.h | grep "^#define WERR" | grep -v "FOOBAR" | sed -e "s/^#define[ \t]//" | while read WERR junk;do echo int foo${WERR}=${WERR}";" ; done ) | cpp | grep "^int foo" | sed -e "s/^int foo/#define /" -e "s/=/ /" -e "s/;$//"
36  */
37 #define WERR_OK 0
38 #define WERR_BADFUNC 1
39 #define WERR_BADFILE 2
40 #define WERR_ACCESS_DENIED 5
41 #define WERR_BADFID 6
42 #define WERR_NOMEM 8
43 #define WERR_GENERAL_FAILURE 31
44 #define WERR_NOT_SUPPORTED 50
45 #define WERR_BAD_NETPATH 53
46 #define WERR_UNEXP_NET_ERR 59
47 #define WERR_PRINTQ_FULL 61
48 #define WERR_NO_SPOOL_SPACE 62
49 #define WERR_NO_SUCH_SHARE 67
50 #define WERR_FILE_EXISTS 80
51 #define WERR_BAD_PASSWORD 86
52 #define WERR_INVALID_PARAM 87
53 #define WERR_INSUFFICIENT_BUFFER 122
54 #define WERR_INVALID_NAME 123
55 #define WERR_UNKNOWN_LEVEL 124
56 #define WERR_OBJECT_PATH_INVALID 161
57 #define WERR_ALREADY_EXISTS 183
58 #define WERR_NO_MORE_ITEMS 259
59 #define WERR_MORE_DATA 234
60 #define WERR_CAN_NOT_COMPLETE 1003
61 #define WERR_NOT_FOUND 1168
62 #define WERR_INVALID_COMPUTERNAME 1210
63 #define WERR_INVALID_DOMAINNAME 1212
64 #define WERR_UNKNOWN_REVISION 1305
65 #define WERR_REVISION_MISMATCH 1306
66 #define WERR_INVALID_OWNER 1307
67 #define WERR_NO_SUCH_PRIVILEGE 1313
68 #define WERR_PRIVILEGE_NOT_HELD 1314
69 #define WERR_NO_SUCH_USER 1317
70 #define WERR_INVALID_SECURITY_DESCRIPTOR 1338
71 #define WERR_NO_SUCH_DOMAIN 1355
72 #define WERR_NO_SYSTEM_RESOURCES 1450
73 #define WERR_SERVER_UNAVAILABLE 1722
74 #define WERR_INVALID_FORM_NAME 1902
75 #define WERR_INVALID_FORM_SIZE 1903
76 #define WERR_ALREADY_SHARED 2118
77 #define WERR_BUF_TOO_SMALL 2123
78 #define WERR_JOB_NOT_FOUND 2151
79 #define WERR_DEST_NOT_FOUND 2152
80 #define WERR_NOT_LOCAL_DOMAIN 2320
81 #define WERR_DEVICE_NOT_AVAILABLE 4319
82 #define WERR_STATUS_MORE_ENTRIES 0x0105
83 #define WERR_PRINTER_DRIVER_ALREADY_INSTALLED 1795
84 #define WERR_UNKNOWN_PORT 1796
85 #define WERR_UNKNOWN_PRINTER_DRIVER 1797
86 #define WERR_UNKNOWN_PRINTPROCESSOR 1798
87 #define WERR_INVALID_SEPARATOR_FILE 1799
88 #define WERR_INVALID_PRIORITY 1800
89 #define WERR_INVALID_PRINTER_NAME 1801
90 #define WERR_PRINTER_ALREADY_EXISTS 1802
91 #define WERR_INVALID_PRINTER_COMMAND 1803
92 #define WERR_INVALID_DATATYPE 1804
93 #define WERR_INVALID_ENVIRONMENT 1805
94 #define WERR_SESSION_NOT_FOUND 2312
95 #define WERR_FID_NOT_FOUND 2314
96 #define WERR_UNKNOWN_PRINT_MONITOR 3000
97 #define WERR_PRINTER_DRIVER_IN_USE 3001
98 #define WERR_SPOOL_FILE_NOT_FOUND 3002
99 #define WERR_SPL_NO_STARTDOC 3003
100 #define WERR_SPL_NO_ADDJOB 3004
101 #define WERR_PRINT_PROCESSOR_ALREADY_INSTALLED 3005
102 #define WERR_PRINT_MONITOR_ALREADY_INSTALLED 3006
103 #define WERR_INVALID_PRINT_MONITOR 3007
104 #define WERR_PRINT_MONITOR_IN_USE 3008
105 #define WERR_PRINTER_HAS_JOBS_QUEUED 3009
106 #define WERR_CLASS_NOT_REGISTERED 0x40154
107 #define WERR_NO_SHUTDOWN_IN_PROGRESS 0x45c
108 #define WERR_SHUTDOWN_ALREADY_IN_PROGRESS 0x45b
109 #define WERR_NET_NAME_NOT_FOUND (2100)+210
110 #define WERR_DEVICE_NOT_SHARED (2100)+211
111 #define WERR_DFS_NO_SUCH_VOL (2100)+562
112 #define WERR_DFS_NO_SUCH_SHARE (2100)+565
113 #define WERR_DFS_NO_SUCH_SERVER (2100)+573
114 #define WERR_DFS_INTERNAL_ERROR (2100)+590
115 #define WERR_DFS_CANT_CREATE_JUNCT (2100)+569
116 #define WERR_DS_SERVICE_BUSY 0x0000200e
117 #define WERR_DS_SERVICE_UNAVAILABLE 0x0000200f
118 #define WERR_DS_NO_SUCH_OBJECT 0x00002030
119 #define WERR_DS_OBJ_NOT_FOUND 0x0000208d
120 #define WERR_DS_DRA_INVALID_PARAMETER 0x000020f5
121 #define WERR_DS_DRA_BAD_DN 0x000020f7
122 #define WERR_DS_DRA_BAD_NC 0x000020f8
123 #define WERR_DS_DRA_INTERNAL_ERROR 0x000020fa
124 #define WERR_DS_DRA_OUT_OF_MEM 0x000020fe
125 #define WERR_DS_SINGLE_VALUE_CONSTRAINT 0x00002081
126 #define WERR_DS_DRA_DB_ERROR 0x00002103
127 #define WERR_DS_DRA_NO_REPLICA 0x00002104
128 #define WERR_DS_DRA_ACCESS_DENIED 0x00002105
129 #define WERR_DS_DNS_LOOKUP_FAILURE 0x0000214c
130 #define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX 0x00002150
131 #define WERR_SEC_E_ALGORITHM_MISMATCH 0x80090331
132
133 extern const value_string WERR_errors[];
134
135
136 /*
137  * DOS error codes used by other dissectors.
138  * At least some of these are from the SMB X/Open spec, as errors for
139  * the ERRDOS error class, but they might be error codes returned from
140  * DOS.
141  */
142 #define SMBE_badfunc 1             /* Invalid function (or system call) */
143 #define SMBE_badfile 2             /* File not found (pathname error) */
144 #define SMBE_badpath 3             /* Directory not found */
145 #define SMBE_nofids 4              /* Too many open files */
146 #define SMBE_noaccess 5            /* Access denied */
147 #define SMBE_badfid 6              /* Invalid fid */
148 #define SMBE_badmcb 7              /* Memory control blocks destroyed */
149 #define SMBE_nomem 8               /* Out of memory */
150 #define SMBE_badmem 9              /* Invalid memory block address */
151 #define SMBE_badenv 10             /* Invalid environment */
152 #define SMBE_badformat 11          /* Invalid format */
153 #define SMBE_badaccess 12          /* Invalid open mode */
154 #define SMBE_baddata 13            /* Invalid data (only from ioctl call) */
155 #define SMBE_res 14
156 #define SMBE_baddrive 15           /* Invalid drive */
157 #define SMBE_remcd 16              /* Attempt to delete current directory */
158 #define SMBE_diffdevice 17         /* rename/move across different filesystems */
159 #define SMBE_nofiles 18            /* no more files found in file search */
160 #define SMBE_badshare 32           /* Share mode on file conflict with open mode */
161 #define SMBE_lock 33               /* Lock request conflicts with existing lock */
162 #define SMBE_unsup 50              /* Request unsupported, returned by Win 95, RJS 20Jun98 */
163 #define SMBE_nosuchshare 67        /* Share does not exist */
164 #define SMBE_filexists 80          /* File in operation already exists */
165 #define SMBE_invalidparam 87       /* Invalid parameter */
166 #define SMBE_cannotopen 110        /* Cannot open the file specified */
167 #define SMBE_insufficientbuffer 122/* Insufficient buffer size */
168 #define SMBE_invalidname 123       /* Invalid name */
169 #define SMBE_unknownlevel 124      /* Unknown info level */
170 #define SMBE_alreadyexists 183     /* File already exists */
171 #define SMBE_badpipe 230           /* Named pipe invalid */
172 #define SMBE_pipebusy 231          /* All instances of pipe are busy */
173 #define SMBE_pipeclosing 232       /* named pipe close in progress */
174 #define SMBE_notconnected 233      /* No process on other end of named pipe */
175 #define SMBE_moredata 234          /* More data to be returned */
176 #define SMBE_nomoreitems 259       /* No more items */
177 #define SMBE_baddirectory 267      /* Invalid directory name in a path. */
178 #define SMBE_eas_didnt_fit 275     /* Extended attributes didn't fit */
179 #define SMBE_eas_nsup 282          /* Extended attributes not supported */
180 #define SMBE_notify_buf_small 1022 /* Buffer too small to return change notify. */
181 #define SMBE_serverunavailable 1722/* Server unavailable */
182 #define SMBE_unknownipc 2142
183 #define SMBE_noipc 66              /* don't support ipc */
184
185 /* These errors seem to be only returned by the NT printer driver system */
186
187 #define SMBE_invalidowner 1307  /* Invalid security descriptor owner */
188 #define SMBE_invalidsecuritydescriptor 1338 /* Invalid security descriptor */
189 #define SMBE_unknownprinterdriver 1797 /* Unknown printer driver */
190 #define SMBE_invalidprintername 1801   /* Invalid printer name */
191 #define SMBE_printeralreadyexists 1802 /* Printer already exists */
192 #define SMBE_invaliddatatype 1804      /* Invalid datatype */
193 #define SMBE_invalidenvironment 1805   /* Invalid environment */
194 #define SMBE_invalidformsize    1903   /* Invalid form size */
195 #define SMBE_printerdriverinuse 3001   /* Printer driver in use */
196
197 extern const value_string DOS_errors[];
198
199 /*
200  * NT error codes used by other dissectors.
201  */
202 extern const value_string NT_errors[];
203
204 extern const value_string ms_country_codes[];
205
206 WS_DLL_PUBLIC
207 int dissect_nt_64bit_time(tvbuff_t *tvb, proto_tree *tree, int offset, int hf_date);
208
209
210 /*
211  *  SIDs and RIDs
212  */
213
214 typedef struct _sid_strings {
215         const char* sid;
216         const char* name;
217 } sid_strings;
218
219 /* Dissect a NT SID.  Label it with 'name' and return a string version
220  * of the SID in the 'sid_str' parameter which has a packet lifetime
221  * scope and should NOT be freed by the caller. hf_sid can be -1 if
222  * the caller doesnt care what name is used and then "nt.sid" will be
223  * the default instead. If the caller wants a more appropriate hf
224  * field, it will just pass a FT_STRING hf field here
225  */
226
227 WS_DLL_PUBLIC
228 int dissect_nt_sid(tvbuff_t *tvb, int offset, proto_tree *parent_tree, 
229                    const char *name, char **sid_str, int hf_sid);
230
231 /* 
232  * Stuff for dissecting NT access masks 
233  */
234
235 /*
236  * Access mask values
237  */
238
239 /* Generic rights */
240
241 #define GENERIC_RIGHTS_MASK    0xF0000000
242
243 #define GENERIC_ALL_ACCESS     0x10000000
244 #define GENERIC_EXECUTE_ACCESS 0x20000000
245 #define GENERIC_WRITE_ACCESS   0x40000000
246 #define GENERIC_READ_ACCESS    0x80000000
247
248 /* Misc/reserved */
249
250 #define ACCESS_SACL_ACCESS     0x00800000
251 #define SYSTEM_SECURITY_ACCESS 0x01000000
252 #define MAXIMUM_ALLOWED_ACCESS 0x02000000
253
254 /* Standard rights */
255
256 #define STANDARD_RIGHTS_MASK 0x00FF0000
257
258 #define DELETE_ACCESS        0x00010000
259 #define READ_CONTROL_ACCESS  0x00020000
260 #define WRITE_DAC_ACCESS     0x00040000
261 #define WRITE_OWNER_ACCESS   0x00080000
262 #define SYNCHRONIZE_ACCESS   0x00100000
263
264 /* Specific rights */
265
266 #define SPECIFIC_RIGHTS_MASK 0x0000FFFF /* Specific rights defined per-object */
267
268 typedef void (nt_access_mask_fn_t)(tvbuff_t *tvb, gint offset,
269                                    proto_tree *tree, guint32 access);
270
271 /* Map generic access permissions to specific permissions */
272
273 struct generic_mapping {
274         guint32 generic_read;
275         guint32 generic_write;
276         guint32 generic_execute;
277         guint32 generic_all;
278 };
279
280 /* Map standard access permissions to specific permissions */
281
282 struct standard_mapping {
283         guint32 std_read;
284         guint32 std_write;
285         guint32 std_execute;
286         guint32 std_all;
287 };
288
289 struct access_mask_info {
290         const char *specific_rights_name;
291         nt_access_mask_fn_t *specific_rights_fn;
292         struct generic_mapping *generic_mapping;
293         struct standard_mapping *standard_mapping;
294 };
295
296 int
297 dissect_nt_access_mask(tvbuff_t *tvb, gint offset, packet_info *pinfo,
298                        proto_tree *tree, guint8 *drep, int hfindex,
299                        struct access_mask_info *ami,
300                        guint32 *perms);
301
302 int
303 dissect_nt_sec_desc(tvbuff_t *tvb, int offset, packet_info *pinfo,
304                     proto_tree *parent_tree, guint8 *drep,
305                     gboolean len_supplied, int len,
306                     struct access_mask_info *ami);
307
308 void
309 proto_do_register_windows_common(int proto_smb);
310
311 int
312 dissect_nt_security_information(tvbuff_t *tvb, int offset, proto_tree *parent_tree);
313
314 #endif
315