smblib-common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* UNIX SMBlib NetBIOS implementation
10 
11  Version 1.0
12  SMBlib Common Defines
13 
14  Copyright (C) Richard Sharpe 1996
15 */
16 
17 /*
18  This program is free software; you can redistribute it and/or modify
19  it under the terms of the GNU General Public License as published by
20  the Free Software Foundation; either version 2 of the License, or
21  (at your option) any later version.
22 
23  This program is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU General Public License for more details.
27 
28  You should have received a copy of the GNU General Public License
29  along with this program; if not, write to the Free Software
30  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 */
32 
33 #ifndef SQUID_LIB_SMBLIB_SMBLIB_COMMON_H
34 #define SQUID_LIB_SMBLIB_SMBLIB_COMMON_H
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* To get the error class we want the first 8 bits */
41 /* Because we just grab 4bytes from the SMB header, we have to re-order */
42 /* here, but it makes the NtStatus part easier in future */
43 
44 #define SMBlib_Error_Class(p) (p & 0x000000FF)
45 
46 /* To get the error code, we want the bottom 16 bits */
47 
48 #define SMBlib_Error_Code(p) (((unsigned int)p & 0xFFFF0000) >>16)
49 
50 /* Error CLASS codes and etc ... */
51 
52 #define SMBC_SUCCESS 0
53 #define SMBC_ERRDOS 0x01
54 #define SMBC_ERRSRV 0x02
55 #define SMBC_ERRHRD 0x03
56 #define SMBC_ERRCMD 0xFF
57 
58 /* Success error codes */
59 
60 #define SMBS_BUFFERED 0x54
61 #define SMBS_LOGGED 0x55
62 #define SMBS_DISPLAYED 0x56
63 
64 /* ERRDOS Error codes */
65 
66 #define SMBD_badfunc 0x01
67 #define SMBD_badfile 0x02
68 #define SMBD_badpath 0x03
69 #define SMBD_nofids 0x04
70 #define SMBD_noaccess 0x05
71 #define SMBD_badfid 0x06
72 #define SMBD_badmcb 0x07
73 #define SMBD_nomem 0x08
74 #define SMBD_badmem 0x09
75 #define SMBD_badenv 0x0A
76 #define SMBD_badformat 0x0B
77 #define SMBD_badaccess 0x0C
78 #define SMBD_baddata 0x0D
79 #define SMBD_reserved 0x0E
80 #define SMBD_baddrive 0x0F
81 #define SMBD_remcd 0x10
82 #define SMBD_diffdevice 0x11
83 #define SMBD_nofiles 0x12
84 #define SMBD_badshare 0x20
85 #define SMBD_errlock 0x21
86 #define SMBD_filexists 0x50
87 
88 /* Server errors ... */
89 
90 #define SMBV_error 0x01 /* Generic error */
91 #define SMBV_badpw 0x02
92 #define SMBV_badtype 0x03
93 #define SMBV_access 0x04
94 #define SMBV_invnid 0x05
95 #define SMBV_invnetname 0x06
96 #define SMBV_invdevice 0x07
97 #define SMBV_qfull 0x31
98 #define SMBV_qtoobig 0x32
99 #define SMBV_qeof 0x33
100 #define SMBV_invpfid 0x34
101 #define SMBV_paused 0x51
102 #define SMBV_msgoff 0x52
103 #define SMBV_noroom 0x53
104 #define SMBV_rmuns 0x57
105 #define SMBV_nosupport 0xFFFF
106 
107 /* Hardware error codes ... */
108 
109 #define SMBH_nowrite 0x13
110 #define SMBH_badunit 0x14
111 #define SMBH_notready 0x15
112 #define SMBH_badcmd 0x16
113 #define SMBH_data 0x17
114 #define SMBH_badreq 0x18
115 #define SMBH_seek 0x19
116 #define SMBH_badmedia 0x1A
117 #define SMBH_badsector 0x1B
118 #define SMBH_nopaper 0x1C
119 #define SMBH_write 0x1D
120 #define SMBH_read 0x1E
121 #define SMBH_general 0x1F
122 #define SMBH_badshare 0x20
123 
124 /* Access mode defines ... */
125 
126 #define SMB_AMODE_WTRU 0x4000
127 #define SMB_AMODE_NOCACHE 0x1000
128 #define SMB_AMODE_COMPAT 0x0000
129 #define SMB_AMODE_DENYRWX 0x0010
130 #define SMB_AMODE_DENYW 0x0020
131 #define SMB_AMODE_DENYRX 0x0030
132 #define SMB_AMODE_DENYNONE 0x0040
133 #define SMB_AMODE_OPENR 0x0000
134 #define SMB_AMODE_OPENW 0x0001
135 #define SMB_AMODE_OPENRW 0x0002
136 #define SMB_AMODE_OPENX 0x0003
137 #define SMB_AMODE_FCBOPEN 0x00FF
138 #define SMB_AMODE_LOCUNKN 0x0000
139 #define SMB_AMODE_LOCMSEQ 0x0100
140 #define SMB_AMODE_LOCMRAN 0x0200
141 #define SMB_AMODE_LOCRAL 0x0300
142 
143 /* File attribute encoding ... */
144 
145 #define SMB_FA_ORD 0x00
146 #define SMB_FA_ROF 0x01
147 #define SMB_FA_HID 0x02
148 #define SMB_FA_SYS 0x04
149 #define SMB_FA_VOL 0x08
150 #define SMB_FA_DIR 0x10
151 #define SMB_FA_ARC 0x20
152 
153 /* Define the protocol types ... */
154 
155 #define SMB_P_Unknown -1 /* Hmmm, is this smart? */
156 #define SMB_P_Core 0
157 #define SMB_P_CorePlus 1
158 #define SMB_P_DOSLanMan1 2
159 #define SMB_P_LanMan1 3
160 #define SMB_P_DOSLanMan2 4
161 #define SMB_P_LanMan2 5
162 #define SMB_P_DOSLanMan2_1 6
163 #define SMB_P_LanMan2_1 7
164 #define SMB_P_NT1 8
165 
166 /* SMBlib return codes */
167 /* We want something that indicates whether or not the return code was a */
168 /* remote error, a local error in SMBlib or returned from lower layer ... */
169 /* Wonder if this will work ... */
170 /* SMBlibE_Remote = 1 indicates remote error */
171 /* SMBlibE_ values < 0 indicate local error with more info available */
172 /* SMBlibE_ values >1 indicate local from SMBlib code errors? */
173 
174 #define SMBlibE_Success 0
175 #define SMBlibE_Remote 1 /* Remote error, get more info from con */
176 #define SMBlibE_BAD -1
177 #define SMBlibE_LowerLayer 2 /* Lower layer error */
178 #define SMBlibE_NotImpl 3 /* Function not yet implemented */
179 #define SMBlibE_ProtLow 4 /* Protocol negotiated does not support req */
180 #define SMBlibE_NoSpace 5 /* No space to allocate a structure */
181 #define SMBlibE_BadParam 6 /* Bad parameters */
182 #define SMBlibE_NegNoProt 7 /* None of our protocols was liked */
183 #define SMBlibE_SendFailed 8 /* Sending an SMB failed */
184 #define SMBlibE_RecvFailed 9 /* Receiving an SMB failed */
185 #define SMBlibE_GuestOnly 10 /* Logged in as guest */
186 #define SMBlibE_CallFailed 11 /* Call remote end failed */
187 #define SMBlibE_ProtUnknown 12 /* Protocol unknown */
188 #define SMBlibE_NoSuchMsg 13 /* Keep this up to date */
189 
190 /* the default SMB protocols supported by this library. */
191 extern const char *SMB_Prots[];
192 
193 typedef struct { /* A structure for a Dirent */
194 
195  unsigned char resume_key[21]; /* Don't touch this */
196  unsigned char file_attributes; /* Attributes of file */
197  unsigned int date_time; /* date and time of last mod */
198  unsigned int size;
199  char filename[13]; /* The name of the file */
200 
201 } SMB_CP_dirent;
202 
204 
206 
207 /* A Tree_Structure */
208 
210 
213  char path[129];
214  char device_type[20];
215  int mbs; /* Local MBS */
216  int tid;
217 
218 };
219 
221  SMB_Handle_Type Next_Con, Prev_Con; /* Next and previous conn */
222  int protocol; /* What is the protocol */
223  int prot_IDX; /* And what is the index */
224  void *Trans_Connect; /* The connection */
225 
226  /* All these strings should be malloc'd */
227 
228  char service[80], username[80], password[80], desthost[80], sock_options[80];
229  char address[80], myname[80];
230 
231  SMB_Tree_Handle first_tree, last_tree; /* List of trees on this server */
232 
233  int gid; /* Group ID, do we need it? */
234  int mid; /* Multiplex ID? We might need one per con */
235  int pid; /* Process ID */
236 
237  int uid; /* Authenticated user id. */
238 
239  /* It is pretty clear that we need to bust some of */
240  /* these out into a per TCon record, as there may */
241  /* be multiple TCon's per server, etc ... later */
242 
243  int port; /* port to use in case not default, this is a TCPism! */
244 
245  int max_xmit; /* Max xmit permitted by server */
246  int Security; /* 0 = share, 1 = user */
247  int Raw_Support; /* bit 0 = 1 = Read Raw supported, 1 = 1 Write raw */
248  int encrypt_passwords; /* 1 = do , 0 = don't */
250  unsigned int SessionKey, Capabilities;
251  int SvrTZ; /* Server Time Zone */
253  char Encrypt_Key[80], Domain[80], PDomain[80], OSName[80], LMType[40];
254  char Svr_OS[80], Svr_LMType[80], Svr_PDom[80];
255 };
256 
257 #ifdef __cplusplus
258 }
259 #endif
260 #endif /* SQUID_LIB_SMBLIB_SMBLIB_COMMON_H */
261 
SMB_Tree_Handle last_tree
char Encrypt_Key[80]
struct SMB_Connect_Def * SMB_Handle_Type
SMB_Tree_Handle prev
unsigned int size
SMB_Tree_Handle first_tree
struct SMB_Tree_Structure * SMB_Tree_Handle
SMB_Handle_Type Prev_Con
const char * SMB_Prots[]
Definition: find_password.c:29
unsigned int Capabilities
SMB_Handle_Type con
unsigned int SessionKey
unsigned int date_time
unsigned char file_attributes
SMB_Handle_Type Next_Con
char sock_options[80]
SMB_Tree_Handle next
char Svr_LMType[80]

 

Introduction

Documentation

Support

Miscellaneous