1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
// This code is derived from jcifs smb client library <jcifs at samba dot org>
// Ported by J. Arturo <webmaster at komodosoft dot net>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System.IO;
namespace SharpCifs.Netbios
{
public class NbtException : IOException
{
public const int Success = 0;
public const int ErrNamSrvc = unchecked(0x01);
public const int ErrSsnSrvc = unchecked(0x02);
public const int FmtErr = unchecked(0x1);
public const int SrvErr = unchecked(0x2);
public const int ImpErr = unchecked(0x4);
public const int RfsErr = unchecked(0x5);
public const int ActErr = unchecked(0x6);
public const int CftErr = unchecked(0x7);
public const int ConnectionRefused = -1;
public const int NotListeningCalled = unchecked(0x80);
public const int NotListeningCalling = unchecked(0x81);
public const int CalledNotPresent = unchecked(0x82);
public const int NoResources = unchecked(0x83);
public const int Unspecified = unchecked(0x8F);
public int ErrorClass;
public int ErrorCode;
// error classes
// name service error codes
// session service error codes
public static string GetErrorString(int errorClass, int errorCode)
{
string result = string.Empty;
switch (errorClass)
{
case Success:
{
result += "SUCCESS";
break;
}
case ErrNamSrvc:
{
result += "ERR_NAM_SRVC/";
switch (errorCode)
{
case FmtErr:
{
result += "FMT_ERR: Format Error";
goto default;
}
default:
{
result += "Unknown error code: " + errorCode;
break;
}
}
break;
}
case ErrSsnSrvc:
{
result += "ERR_SSN_SRVC/";
switch (errorCode)
{
case ConnectionRefused:
{
result += "Connection refused";
break;
}
case NotListeningCalled:
{
result += "Not listening on called name";
break;
}
case NotListeningCalling:
{
result += "Not listening for calling name";
break;
}
case CalledNotPresent:
{
result += "Called name not present";
break;
}
case NoResources:
{
result += "Called name present, but insufficient resources";
break;
}
case Unspecified:
{
result += "Unspecified error";
break;
}
default:
{
result += "Unknown error code: " + errorCode;
break;
}
}
break;
}
default:
{
result += "unknown error class: " + errorClass;
break;
}
}
return result;
}
public NbtException(int errorClass, int errorCode) : base(GetErrorString(errorClass
, errorCode))
{
this.ErrorClass = errorClass;
this.ErrorCode = errorCode;
}
public override string ToString()
{
return "errorClass=" + ErrorClass + ",errorCode=" + ErrorCode + ",errorString="
+ GetErrorString(ErrorClass, ErrorCode);
}
}
}
|