C# Class SharpCifs.Netbios.NbtAddress

This class represents a NetBIOS over TCP/IP address.
This class represents a NetBIOS over TCP/IP address. Under normal conditions, users of jCIFS need not be concerned with this class as name resolution and session services are handled internally by the smb package.

Applications can use the methods getLocalHost, getByName, and getAllByAddress to create a new NbtAddress instance. This class is symmetric with System.Net.IPAddress .

About NetBIOS: The NetBIOS name service is a dynamic distributed service that allows hosts to resolve names by broadcasting a query, directing queries to a server such as Samba or WINS. NetBIOS is currently the primary networking layer for providing name service, datagram service, and session service to the Microsoft Windows platform. A NetBIOS name can be 15 characters long and hosts usually registers several names on the network. From a Windows command prompt you can see what names a host registers with the nbtstat command.

 C:\>nbtstat -a 192.168.1.15 NetBIOS Remote Machine Name Table Name               Type         Status --------------------------------------------- JMORRIS2        <00>  UNIQUE      Registered BILLING-NY      <00>  GROUP       Registered JMORRIS2        <03>  UNIQUE      Registered JMORRIS2        <20>  UNIQUE      Registered BILLING-NY      <1E>  GROUP       Registered JMORRIS         <03>  UNIQUE      Registered MAC Address = 00-B0-34-21-FA-3B 

The hostname of this machine is JMORRIS2. It is a member of the group(a.k.a workgroup and domain) BILLING-NY. To obtain an System.Net.IPAddress for a host one might do:

 InetAddress addr = NbtAddress.getByName( "jmorris2" ).getInetAddress(); 

From a UNIX platform with Samba installed you can perform similar diagnostics using the nmblookup utility.

Exibir arquivo Open project: brandonprry/Potato Class Usage Examples

Public Properties

Property Type Description
MasterBrowserName string
SmbserverName string

Public Methods

Method Description
Equals ( object obj ) : bool

Determines if this address is equal two another.

Determines if this address is equal two another. Only the IP Addresses are compared. Similar to the GetHashCode() method, the comparison is based on the integer IP address and not the string representation.

FirstCalledName ( ) : string
GetAddress ( ) : byte[]

Returns the raw IP address of this NbtAddress.

Returns the raw IP address of this NbtAddress. The result is in network byte order: the highest order byte of the address is in getAddress()[0].

GetAllByAddress ( NbtAddress addr ) : SharpCifs.Netbios.NbtAddress[]

Retrieve all addresses of a host by it's address.

Retrieve all addresses of a host by it's address. NetBIOS hosts can have many names for a given IP address. The name and IP address make the NetBIOS address. This provides a way to retrieve the other names for a host with the same IP address.

GetAllByAddress ( string host ) : SharpCifs.Netbios.NbtAddress[]

Retrieve all addresses of a host by it's address.

Retrieve all addresses of a host by it's address. NetBIOS hosts can have many names for a given IP address. The name and IP address make the NetBIOS address. This provides a way to retrieve the other names for a host with the same IP address.

GetAllByAddress ( string host, int type, string scope ) : SharpCifs.Netbios.NbtAddress[]

Retrieve all addresses of a host by it's address.

Retrieve all addresses of a host by it's address. NetBIOS hosts can have many names for a given IP address. The name and IP address make the NetBIOS address. This provides a way to retrieve the other names for a host with the same IP address. See GetByName(string) for a description of type and scope.

GetAllByName ( string host, int type, string scope, IPAddress svr ) : SharpCifs.Netbios.NbtAddress[]
GetByName ( string host ) : NbtAddress

Determines the address of a host given it's host name.

Determines the address of a host given it's host name. The name can be a NetBIOS name like "freto" or an IP address like "192.168.1.15". It cannot be a DNS name; the analygous Jcifs.UniAddress or System.Net.IPAddress getByName methods can be used for that.

GetByName ( string host, int type, string scope ) : NbtAddress

Determines the address of a host given it's host name.

Determines the address of a host given it's host name. NetBIOS names also have a type. Types(aka Hex Codes) are used to distiquish the various services on a host. <a href="../../../nbtcodes.html">Here is a fairly complete list of NetBIOS hex codes. Scope is not used but is still functional in other NetBIOS products and so for completeness it has been implemented. A scope of null or "" signifies no scope.

GetByName ( string host, int type, string scope, IPAddress svr ) : NbtAddress
GetHashCode ( ) : int

Returns a hashcode for this IP address.

Returns a hashcode for this IP address. The hashcode comes from the IP address and is not generated from the string representation. So because NetBIOS nodes can have many names, all names associated with an IP will have the same hashcode.

GetHostAddress ( ) : string

Returns this IP adress as a string in the form "%d.%d.%d.%d".

GetHostName ( ) : string

The hostname of this address.

The hostname of this address. If the hostname is null the local machines IP address is returned.

GetHosts ( ) : SharpCifs.Netbios.NbtAddress[]
GetInetAddress ( ) : IPAddress

To convert this address to an InetAddress.

To convert this address to an InetAddress.

GetLocalHost ( ) : NbtAddress

Retrieves the local host address.

Retrieves the local host address.

GetLocalName ( ) : Name
GetMacAddress ( ) : byte[]

Retrieves the MAC address of the remote network interface.

Retrieves the MAC address of the remote network interface. Samba returns all zeros.

GetNameType ( ) : int

Returned the hex code associated with this name(e.g.

Returned the hex code associated with this name(e.g. 0x20 is for the file service)

GetNodeType ( ) : int

Checks the node type of this address.

Checks the node type of this address.

GetWinsAddress ( ) : IPAddress
IsActive ( ) : bool

Determines if this address is active.

Determines if this address is active.

IsBeingDeleted ( ) : bool

Determines if this address in the process of being deleted.

Determines if this address in the process of being deleted.

IsGroupAddress ( ) : bool

Determines if the address is a group address.

Determines if the address is a group address. This is also known as a workgroup name or group name.

IsInConflict ( ) : bool

Determines if this address in conflict with another address.

Determines if this address in conflict with another address.

IsPermanent ( ) : bool

Determines if this address is set to be permanent.

Determines if this address is set to be permanent.

IsWins ( IPAddress svr ) : bool
NextCalledName ( ) : string
ToString ( ) : string

Returns the string representaion of this address.

Private Methods

Method Description
CacheAddress ( Name hostName, NbtAddress addr ) : void
CacheAddress ( Name hostName, NbtAddress addr, long expiration ) : void
CacheAddressArray ( NbtAddress addrs ) : void
CheckData ( ) : void
CheckLookupTable ( Name name ) : object
CheckNodeStatusData ( ) : void
DoNameQuery ( Name name, IPAddress svr ) : NbtAddress
GetCachedAddress ( Name hostName ) : NbtAddress
NbtAddress ( ) : System
NbtAddress ( Name hostName, int address, bool groupName, int nodeType ) : System
NbtAddress ( Name hostName, int address, bool groupName, int nodeType, bool isBeingDeleted, bool isInConflict, bool isActive, bool isPermanent, byte macAddress ) : System
SwitchWins ( ) : IPAddress
UpdateLookupTable ( Name name ) : void

Method Details

Equals() public method

Determines if this address is equal two another.
Determines if this address is equal two another. Only the IP Addresses are compared. Similar to the GetHashCode() method, the comparison is based on the integer IP address and not the string representation.
public Equals ( object obj ) : bool
obj object
return bool

FirstCalledName() public method

public FirstCalledName ( ) : string
return string

GetAddress() public method

Returns the raw IP address of this NbtAddress.
Returns the raw IP address of this NbtAddress. The result is in network byte order: the highest order byte of the address is in getAddress()[0].
public GetAddress ( ) : byte[]
return byte[]

GetAllByAddress() public static method

Retrieve all addresses of a host by it's address.
Retrieve all addresses of a host by it's address. NetBIOS hosts can have many names for a given IP address. The name and IP address make the NetBIOS address. This provides a way to retrieve the other names for a host with the same IP address.
if address cannot be resolved
public static GetAllByAddress ( NbtAddress addr ) : SharpCifs.Netbios.NbtAddress[]
addr NbtAddress the address to query
return SharpCifs.Netbios.NbtAddress[]

GetAllByAddress() public static method

Retrieve all addresses of a host by it's address.
Retrieve all addresses of a host by it's address. NetBIOS hosts can have many names for a given IP address. The name and IP address make the NetBIOS address. This provides a way to retrieve the other names for a host with the same IP address.
if there is an error resolving the name ///
public static GetAllByAddress ( string host ) : SharpCifs.Netbios.NbtAddress[]
host string hostname to lookup all addresses for
return SharpCifs.Netbios.NbtAddress[]

GetAllByAddress() public static method

Retrieve all addresses of a host by it's address.
Retrieve all addresses of a host by it's address. NetBIOS hosts can have many names for a given IP address. The name and IP address make the NetBIOS address. This provides a way to retrieve the other names for a host with the same IP address. See GetByName(string) for a description of type and scope.
if there is an error resolving the name ///
public static GetAllByAddress ( string host, int type, string scope ) : SharpCifs.Netbios.NbtAddress[]
host string hostname to lookup all addresses for
type int the hexcode of the name
scope string the scope of the name
return SharpCifs.Netbios.NbtAddress[]

GetAllByName() public static method

public static GetAllByName ( string host, int type, string scope, IPAddress svr ) : SharpCifs.Netbios.NbtAddress[]
host string
type int
scope string
svr System.Net.IPAddress
return SharpCifs.Netbios.NbtAddress[]

GetByName() public static method

Determines the address of a host given it's host name.
Determines the address of a host given it's host name. The name can be a NetBIOS name like "freto" or an IP address like "192.168.1.15". It cannot be a DNS name; the analygous Jcifs.UniAddress or System.Net.IPAddress getByName methods can be used for that.
if there is an error resolving the name ///
public static GetByName ( string host ) : NbtAddress
host string hostname to resolve
return NbtAddress

GetByName() public static method

Determines the address of a host given it's host name.
Determines the address of a host given it's host name. NetBIOS names also have a type. Types(aka Hex Codes) are used to distiquish the various services on a host. <a href="../../../nbtcodes.html">Here is a fairly complete list of NetBIOS hex codes. Scope is not used but is still functional in other NetBIOS products and so for completeness it has been implemented. A scope of null or "" signifies no scope.
if there is an error resolving the name ///
public static GetByName ( string host, int type, string scope ) : NbtAddress
host string the name to resolve
type int the hex code of the name
scope string the scope of the name
return NbtAddress

GetByName() public static method

public static GetByName ( string host, int type, string scope, IPAddress svr ) : NbtAddress
host string
type int
scope string
svr System.Net.IPAddress
return NbtAddress

GetHashCode() public method

Returns a hashcode for this IP address.
Returns a hashcode for this IP address. The hashcode comes from the IP address and is not generated from the string representation. So because NetBIOS nodes can have many names, all names associated with an IP will have the same hashcode.
public GetHashCode ( ) : int
return int

GetHostAddress() public method

Returns this IP adress as a string in the form "%d.%d.%d.%d".
public GetHostAddress ( ) : string
return string

GetHostName() public method

The hostname of this address.
The hostname of this address. If the hostname is null the local machines IP address is returned.
public GetHostName ( ) : string
return string

GetHosts() public static method

public static GetHosts ( ) : SharpCifs.Netbios.NbtAddress[]
return SharpCifs.Netbios.NbtAddress[]

GetInetAddress() public method

To convert this address to an InetAddress.
To convert this address to an InetAddress.
public GetInetAddress ( ) : IPAddress
return System.Net.IPAddress

GetLocalHost() public static method

Retrieves the local host address.
Retrieves the local host address.
/// This is not likely as the IP returned /// by InetAddress should be available ///
public static GetLocalHost ( ) : NbtAddress
return NbtAddress

GetLocalName() public static method

public static GetLocalName ( ) : Name
return Name

GetMacAddress() public method

Retrieves the MAC address of the remote network interface.
Retrieves the MAC address of the remote network interface. Samba returns all zeros.
/// if the host cannot be resolved to /// determine the MAC address. ///
public GetMacAddress ( ) : byte[]
return byte[]

GetNameType() public method

Returned the hex code associated with this name(e.g.
Returned the hex code associated with this name(e.g. 0x20 is for the file service)
public GetNameType ( ) : int
return int

GetNodeType() public method

Checks the node type of this address.
Checks the node type of this address.
if the host cannot be resolved to find out. ///
public GetNodeType ( ) : int
return int

GetWinsAddress() public static method

public static GetWinsAddress ( ) : IPAddress
return System.Net.IPAddress

IsActive() public method

Determines if this address is active.
Determines if this address is active.
if the host cannot be resolved to find out. ///
public IsActive ( ) : bool
return bool

IsBeingDeleted() public method

Determines if this address in the process of being deleted.
Determines if this address in the process of being deleted.
if the host cannot be resolved to find out. ///
public IsBeingDeleted ( ) : bool
return bool

IsGroupAddress() public method

Determines if the address is a group address.
Determines if the address is a group address. This is also known as a workgroup name or group name.
if the host cannot be resolved to find out. ///
public IsGroupAddress ( ) : bool
return bool

IsInConflict() public method

Determines if this address in conflict with another address.
Determines if this address in conflict with another address.
if the host cannot be resolved to find out. ///
public IsInConflict ( ) : bool
return bool

IsPermanent() public method

Determines if this address is set to be permanent.
Determines if this address is set to be permanent.
if the host cannot be resolved to find out. ///
public IsPermanent ( ) : bool
return bool

IsWins() public static method

public static IsWins ( IPAddress svr ) : bool
svr IPAddress
return bool

NextCalledName() public method

public NextCalledName ( ) : string
return string

ToString() public method

Returns the string representaion of this address.
public ToString ( ) : string
return string

Property Details

MasterBrowserName public_oe static_oe property

This is a special name for querying the master browser that serves the list of hosts found in "Network Neighborhood".
This is a special name for querying the master browser that serves the list of hosts found in "Network Neighborhood".
public static string MasterBrowserName
return string

SmbserverName public_oe static_oe property

A special generic name specified when connecting to a host for which a name is not known.
A special generic name specified when connecting to a host for which a name is not known. Not all servers respond to this name.
public static string SmbserverName
return string