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.

Afficher le fichier Open project: brandonprry/Potato Class Usage Examples

Méthodes publiques

Свойство Type Description
MasterBrowserName string
SmbserverName string

Méthodes publiques

Méthode 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

Méthode 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 méthode

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
Résultat bool

FirstCalledName() public méthode

public FirstCalledName ( ) : string
Résultat string

GetAddress() public méthode

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[]
Résultat byte[]

GetAllByAddress() public static méthode

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
Résultat SharpCifs.Netbios.NbtAddress[]

GetAllByAddress() public static méthode

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
Résultat SharpCifs.Netbios.NbtAddress[]

GetAllByAddress() public static méthode

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
Résultat SharpCifs.Netbios.NbtAddress[]

GetAllByName() public static méthode

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

GetByName() public static méthode

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
Résultat NbtAddress

GetByName() public static méthode

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
Résultat NbtAddress

GetByName() public static méthode

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

GetHashCode() public méthode

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
Résultat int

GetHostAddress() public méthode

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

GetHostName() public méthode

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
Résultat string

GetHosts() public static méthode

public static GetHosts ( ) : SharpCifs.Netbios.NbtAddress[]
Résultat SharpCifs.Netbios.NbtAddress[]

GetInetAddress() public méthode

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

GetLocalHost() public static méthode

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
Résultat NbtAddress

GetLocalName() public static méthode

public static GetLocalName ( ) : Name
Résultat Name

GetMacAddress() public méthode

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[]
Résultat byte[]

GetNameType() public méthode

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
Résultat int

GetNodeType() public méthode

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
Résultat int

GetWinsAddress() public static méthode

public static GetWinsAddress ( ) : IPAddress
Résultat System.Net.IPAddress

IsActive() public méthode

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

IsBeingDeleted() public méthode

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
Résultat bool

IsGroupAddress() public méthode

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
Résultat bool

IsInConflict() public méthode

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
Résultat bool

IsPermanent() public méthode

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
Résultat bool

IsWins() public static méthode

public static IsWins ( IPAddress svr ) : bool
svr IPAddress
Résultat bool

NextCalledName() public méthode

public NextCalledName ( ) : string
Résultat string

ToString() public méthode

Returns the string representaion of this address.
public ToString ( ) : string
Résultat 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
Résultat 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
Résultat string