| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 | // 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  USAusing 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);		}	}}
 |