1 /* UNIX SMBlib NetBIOS implementation
6 Copyright (C) Richard Sharpe 1996
7 Copyright 2006 The FreeRADIUS server project
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <freeradius-devel/ident.h>
28 RCSIDH(smblib_common_h, "$Id$")
30 /* To get the error class we want the first 8 bits */
31 /* Because we just grab 4bytes from the SMB header, we have to re-order */
32 /* here, but it makes the NtStatus part easier in future */
34 #define SMBlib_Error_Class(p) (p & 0x000000FF)
36 /* To get the error code, we want the bottom 16 bits */
38 #define SMBlib_Error_Code(p) (((unsigned int)p & 0xFFFF0000) >>16)
40 /* Error CLASS codes and etc ... */
42 #define SMBC_SUCCESS 0
43 #define SMBC_ERRDOS 0x01
44 #define SMBC_ERRSRV 0x02
45 #define SMBC_ERRHRD 0x03
46 #define SMBC_ERRCMD 0xFF
48 /* Success error codes */
50 #define SMBS_BUFFERED 0x54
51 #define SMBS_LOGGED 0x55
52 #define SMBS_DISPLAYED 0x56
54 /* ERRDOS Error codes */
56 #define SMBD_badfunc 0x01
57 #define SMBD_badfile 0x02
58 #define SMBD_badpath 0x03
59 #define SMBD_nofids 0x04
60 #define SMBD_noaccess 0x05
61 #define SMBD_badfid 0x06
62 #define SMBD_badmcb 0x07
63 #define SMBD_nomem 0x08
64 #define SMBD_badmem 0x09
65 #define SMBD_badenv 0x0A
66 #define SMBD_badformat 0x0B
67 #define SMBD_badaccess 0x0C
68 #define SMBD_baddata 0x0D
69 #define SMBD_reserved 0x0E
70 #define SMBD_baddrive 0x0F
71 #define SMBD_remcd 0x10
72 #define SMBD_diffdevice 0x11
73 #define SMBD_nofiles 0x12
74 #define SMBD_badshare 0x20
75 #define SMBD_errlock 0x21
76 #define SMBD_filexists 0x50
78 /* Server errors ... */
80 #define SMBV_error 0x01 /* Generic error */
81 #define SMBV_badpw 0x02
82 #define SMBV_badtype 0x03
83 #define SMBV_access 0x04
84 #define SMBV_invnid 0x05
85 #define SMBV_invnetname 0x06
86 #define SMBV_invdevice 0x07
87 #define SMBV_qfull 0x31
88 #define SMBV_qtoobig 0x32
89 #define SMBV_qeof 0x33
90 #define SMBV_invpfid 0x34
91 #define SMBV_paused 0x51
92 #define SMBV_msgoff 0x52
93 #define SMBV_noroom 0x53
94 #define SMBV_rmuns 0x57
95 #define SMBV_nosupport 0xFFFF
97 /* Hardware error codes ... */
99 #define SMBH_nowrite 0x13
100 #define SMBH_badunit 0x14
101 #define SMBH_notready 0x15
102 #define SMBH_badcmd 0x16
103 #define SMBH_data 0x17
104 #define SMBH_badreq 0x18
105 #define SMBH_seek 0x19
106 #define SMBH_badmedia 0x1A
107 #define SMBH_badsector 0x1B
108 #define SMBH_nopaper 0x1C
109 #define SMBH_write 0x1D
110 #define SMBH_read 0x1E
111 #define SMBH_general 0x1F
112 #define SMBH_badshare 0x20
114 /* Access mode defines ... */
116 #define SMB_AMODE_WTRU 0x4000
117 #define SMB_AMODE_NOCACHE 0x1000
118 #define SMB_AMODE_COMPAT 0x0000
119 #define SMB_AMODE_DENYRWX 0x0010
120 #define SMB_AMODE_DENYW 0x0020
121 #define SMB_AMODE_DENYRX 0x0030
122 #define SMB_AMODE_DENYNONE 0x0040
123 #define SMB_AMODE_OPENR 0x0000
124 #define SMB_AMODE_OPENW 0x0001
125 #define SMB_AMODE_OPENRW 0x0002
126 #define SMB_AMODE_OPENX 0x0003
127 #define SMB_AMODE_FCBOPEN 0x00FF
128 #define SMB_AMODE_LOCUNKN 0x0000
129 #define SMB_AMODE_LOCMSEQ 0x0100
130 #define SMB_AMODE_LOCMRAN 0x0200
131 #define SMB_AMODE_LOCRAL 0x0300
133 /* File attribute encoding ... */
135 #define SMB_FA_ORD 0x00
136 #define SMB_FA_ROF 0x01
137 #define SMB_FA_HID 0x02
138 #define SMB_FA_SYS 0x04
139 #define SMB_FA_VOL 0x08
140 #define SMB_FA_DIR 0x10
141 #define SMB_FA_ARC 0x20
143 /* Define the protocol types ... */
145 #define SMB_P_Unknown -1 /* Hmmm, is this smart? */
147 #define SMB_P_CorePlus 1
148 #define SMB_P_DOSLanMan1 2
149 #define SMB_P_LanMan1 3
150 #define SMB_P_DOSLanMan2 4
151 #define SMB_P_LanMan2 5
152 #define SMB_P_DOSLanMan2_1 6
153 #define SMB_P_LanMan2_1 7
156 /* SMBlib return codes */
157 /* We want something that indicates whether or not the return code was a */
158 /* remote error, a local error in SMBlib or returned from lower layer ... */
159 /* Wonder if this will work ... */
160 /* SMBlibE_Remote = 1 indicates remote error */
161 /* SMBlibE_ values < 0 indicate local error with more info available */
162 /* SMBlibE_ values >1 indicate local from SMBlib code errors? */
164 #define SMBlibE_Success 0
165 #define SMBlibE_Remote 1 /* Remote error, get more info from con */
166 #define SMBlibE_BAD -1
167 #define SMBlibE_LowerLayer 2 /* Lower layer error */
168 #define SMBlibE_NotImpl 3 /* Function not yet implemented */
169 #define SMBlibE_ProtLow 4 /* Protocol negotiated does not support req */
170 #define SMBlibE_NoSpace 5 /* No space to allocate a structure */
171 #define SMBlibE_BadParam 6 /* Bad parameters */
172 #define SMBlibE_NegNoProt 7 /* None of our protocols was liked */
173 #define SMBlibE_SendFailed 8 /* Sending an SMB failed */
174 #define SMBlibE_RecvFailed 9 /* Receiving an SMB failed */
175 #define SMBlibE_GuestOnly 10 /* Logged in as guest */
176 #define SMBlibE_CallFailed 11 /* Call remote end failed */
177 #define SMBlibE_ProtUnknown 12 /* Protocol unknown */
178 #define SMBlibE_NoSuchMsg 13 /* Keep this up to date */
180 typedef struct { /* A structure for a Dirent */
182 unsigned char resume_key[21]; /* Don't touch this */
183 unsigned char file_attributes; /* Attributes of file */
184 unsigned int date_time; /* date and time of last mod */
186 char filename[13]; /* The name of the file */