2 Unix SMB/Netbios implementation.
4 Copyright (C) Andrew Tridgell 1998
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 extern int DEBUGLEVEL;
29 /* error code stuff - put together by Merik Karman
30 merik@blackadder.dsh.oz.au */
39 /* Dos Error Messages */
40 err_code_struct dos_msgs[] = {
41 {"ERRbadfunc",1,"Invalid function."},
42 {"ERRbadfile",2,"File not found."},
43 {"ERRbadpath",3,"Directory invalid."},
44 {"ERRnofids",4,"No file descriptors available"},
45 {"ERRnoaccess",5,"Access denied."},
46 {"ERRbadfid",6,"Invalid file handle."},
47 {"ERRbadmcb",7,"Memory control blocks destroyed."},
48 {"ERRnomem",8,"Insufficient server memory to perform the requested function."},
49 {"ERRbadmem",9,"Invalid memory block address."},
50 {"ERRbadenv",10,"Invalid environment."},
51 {"ERRbadformat",11,"Invalid format."},
52 {"ERRbadaccess",12,"Invalid open mode."},
53 {"ERRbaddata",13,"Invalid data."},
54 {"ERR",14,"reserved."},
55 {"ERRbaddrive",15,"Invalid drive specified."},
56 {"ERRremcd",16,"A Delete Directory request attempted to remove the server's current directory."},
57 {"ERRdiffdevice",17,"Not same device."},
58 {"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."},
59 {"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
60 {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
61 {"ERRnosuchshare", 67, "You specified an invalid share name"},
62 {"ERRfilexists",80,"The file named in a Create Directory, Make New File or Link request already exists."},
63 {"ERRbadpipe",230,"Pipe invalid."},
64 {"ERRpipebusy",231,"All instances of the requested pipe are busy."},
65 {"ERRpipeclosing",232,"Pipe close in progress."},
66 {"ERRnotconnected",233,"No process on other end of pipe."},
67 {"ERRmoredata",234,"There is more data to be returned."},
68 {"ERRinvgroup",2455,"Invalid workgroup (try the -W option)"},
71 /* Server Error Messages */
72 err_code_struct server_msgs[] = {
73 {"ERRerror",1,"Non-specific error code."},
74 {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
75 {"ERRbadtype",3,"reserved."},
76 {"ERRaccess",4,"The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."},
77 {"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
78 {"ERRinvnetname",6,"Invalid network name in tree connect."},
79 {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
80 {"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
81 {"ERRqtoobig",50,"Print queue full -- no space."},
82 {"ERRqeof",51,"EOF on print queue dump."},
83 {"ERRinvpfid",52,"Invalid print file FID."},
84 {"ERRsmbcmd",64,"The server did not recognize the command received."},
85 {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
86 {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
87 {"ERRreserved",68,"reserved."},
88 {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
89 {"ERRreserved",70,"reserved."},
90 {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
91 {"ERRpaused",81,"Server is paused."},
92 {"ERRmsgoff",82,"Not receiving messages."},
93 {"ERRnoroom",83,"No room to buffer message."},
94 {"ERRrmuns",87,"Too many remote user names."},
95 {"ERRtimeout",88,"Operation timed out."},
96 {"ERRnoresource",89,"No resources currently available for request."},
97 {"ERRtoomanyuids",90,"Too many UIDs active on this session."},
98 {"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
99 {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
100 {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
101 {"ERRcontmpx",252,"Continue in MPX mode."},
102 {"ERRreserved",253,"reserved."},
103 {"ERRreserved",254,"reserved."},
104 {"ERRnosupport",0xFFFF,"Function not supported."},
107 /* Hard Error Messages */
108 err_code_struct hard_msgs[] = {
109 {"ERRnowrite",19,"Attempt to write on write-protected diskette."},
110 {"ERRbadunit",20,"Unknown unit."},
111 {"ERRnotready",21,"Drive not ready."},
112 {"ERRbadcmd",22,"Unknown command."},
113 {"ERRdata",23,"Data error (CRC)."},
114 {"ERRbadreq",24,"Bad request structure length."},
115 {"ERRseek",25 ,"Seek error."},
116 {"ERRbadmedia",26,"Unknown media type."},
117 {"ERRbadsector",27,"Sector not found."},
118 {"ERRnopaper",28,"Printer out of paper."},
119 {"ERRwrite",29,"Write fault."},
120 {"ERRread",30,"Read fault."},
121 {"ERRgeneral",31,"General failure."},
122 {"ERRbadshare",32,"An open conflicts with an existing open."},
123 {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
124 {"ERRwrongdisk",34,"The wrong disk was found in a drive."},
125 {"ERRFCBUnavail",35,"No FCBs are available to process request."},
126 {"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
134 err_code_struct *err_msgs;
137 {0x01,"ERRDOS",dos_msgs},
138 {0x02,"ERRSRV",server_msgs},
139 {0x03,"ERRHRD",hard_msgs},
140 {0x04,"ERRXOS",NULL},
141 {0xE1,"ERRRMX1",NULL},
142 {0xE2,"ERRRMX2",NULL},
143 {0xE3,"ERRRMX3",NULL},
144 {0xFF,"ERRCMD",NULL},
148 /****************************************************************************
149 return a SMB error string from a SMB buffer
150 ****************************************************************************/
151 char *smb_errstr(char *inbuf)
154 int class = CVAL(inbuf,smb_rcls);
155 int num = SVAL(inbuf,smb_err);
158 for (i=0;err_classes[i].class;i++)
159 if (err_classes[i].code == class)
161 if (err_classes[i].err_msgs)
163 err_code_struct *err = err_classes[i].err_msgs;
164 for (j=0;err[j].name;j++)
165 if (num == err[j].code)
168 slprintf(ret, sizeof(ret) - 1, "%s - %s (%s)",err_classes[i].class,
169 err[j].name,err[j].message);
171 slprintf(ret, sizeof(ret) - 1, "%s - %s",err_classes[i].class,err[j].name);
176 slprintf(ret, sizeof(ret) - 1, "%s - %d",err_classes[i].class,num);
180 slprintf(ret, sizeof(ret) - 1, "Error: Unknown error (%d,%d)",class,num);