C# Class SnmpSharpNet.IpAddress

Inheritance: OctetString, IComparable, ICloneable
Afficher le fichier Open project: griffina/SnmpSharpNet Class Usage Examples

Méthodes publiques

Свойство Type Description
ClassA int
ClassB int
ClassC int
ClassD int
ClassE int
InvalidClass int

Méthodes publiques

Méthode Description
BuildMaskFromBits ( int bits ) : IpAddress

Build a subnet mask from bit count value

Clone ( ) : Object

Clone current object.

CompareTo ( object obj ) : int

Compare value against IPAddress, byte array, UInt32, IpAddress of OctetString class value.

Equals ( object obj ) : bool

Compare 2 IpAddress objects.

GetBroadcastAddress ( IpAddress mask ) : IpAddress

Returns broadcast address for the objects IP and supplied subnet mask. Subnet mask validity is not confirmed before performing the new value calculation so you should make sure parameter is a valid subnet mask by using IpAddress.IsValidMask method. Broadcast address is calculated by changing every bit in the subnet mask that is set to value 0 into 1 in the address value.

GetClass ( ) : int

Return network class of the IP address

GetHashCode ( ) : int

Return hash representing the value of this object

GetMaskBits ( ) : int

Returns number of subnet bits in the mask. Subnet bits are bits set to value 0 in the subnet mask.

GetSubnetAddress ( IpAddress mask ) : IpAddress

Return subnet address of the IP address in this object and supplied subnet mask

Increment ( UInt32 count ) : IpAddress

Increment IP address contained in the object by specific number and return the result as a new class.

Invert ( ) : IpAddress

Inverts IP address value. All 0s are converted to 1s and 1s to 0s

IpAddress ( ) : System

Constructs a default object with a length of zero. See the super class constructor for more details.

IpAddress ( IpAddress second ) : System

Copy constructor. Constructs a duplicate object based on the passed application string object.

IpAddress ( OctetString second ) : System

Copy constructor.

IpAddress ( System inetAddr ) : System

Constructor

Construct the IpAddress class from supplied IPAddress value.

IpAddress ( UInt32 inetAddr ) : System

Constructor

Initialize IpAddress class with the IP address value represented as 32-bit unsigned integer value

IpAddress ( byte data ) : System

Constructs an Application String with the passed data. The data is managed by the base class.

IpAddress ( string inetAddr ) : System

Constructs the class and initializes the value to the supplied IP address. See comments in IpAddress.Set(string) method for details.

IsIP ( string val ) : bool

Check if supplied string contains a valid IP address. Valid IP address contains 3 full stops (".") and 4 numeric values in range 0 to 255.

Written to address slow performance of IPAddress.TryParse

IsValidMask ( ) : bool

Checks if the value of the object is a valid subnet mask. Subnet mask is a value of consecutive bits with value of 1. If a bit is found with a value of 0 followed (immediately or anywhere else before the end of the value) by a 1, then subnet mask value is not valid.

NetworkMask ( ) : IpAddress

Returns network mask for the class value

Each IpAddress belongs to one of the 5 classes, A, B, C, D or E. D network class are multicast addresses and E is experimental class. Because D and E are not "real" network classes and as such don't have a network mask, only classes A, B and C will return a valid subnet mask. Classes D and E will return a null reference.

ReverseByteOrder ( uint val ) : uint

Reverse int value byte order. Static function in IPAddress class doesn't work the way I expected it (didn't troubleshoot) so here is another implementation. Reversing byte order is needed because network encoded IP address is presented in big-endian format. Intel based computers encode values in little-endian form so to perform numerical operations on received IP address values you will need to convert them from big to little-endian format. By the same token, if you wish to transmit data using IP address value calculated on the local system, you will need to convert it to big-endian prior to transmission.

Set ( IPAddress ipaddr ) : void

Set class value from the IPAddress argument

Set ( String value ) : void

Sets the class value to the IP address parsed from the string parameter.

Class value will be set with the parsed dotted decimal IP address in the parameter or if string parameter does not represent an IP address, DNS resolution will be performed. Note: DNS resolution is performed using System.Net.Dns.GetHostEntry(string) and can result in a longer then expected delay in this function. In applications where responsiveness is important, name resolution should be performed using async methods available and result passed to this method.

Set ( UInt32 ipvalue ) : void

Set class value from 32-bit unsigned integer value representation of the IP address value

ToString ( ) : System.String

Returns the application string as a dotted decimal represented IP address.

ToUInt32 ( ) : UInt32

Network byte order IP address

Convert internal byte array representation of the IP address into a network byte order (most significant byte first) unsigned integer value. To use the returned value in mathematical operations, you will need to change it to host byte order on little endian systems (all i386 compatible systems). To do that, call static method IpAddress.ReverseByteOrder().

decode ( byte buffer, int offset ) : int

Decode ASN.1 encoded IP address value.

Method Details

BuildMaskFromBits() public static méthode

Build a subnet mask from bit count value
public static BuildMaskFromBits ( int bits ) : IpAddress
bits int Number of subnet mask bits
Résultat IpAddress

Clone() public méthode

Clone current object.
public Clone ( ) : Object
Résultat System.Object

CompareTo() public méthode

Compare value against IPAddress, byte array, UInt32, IpAddress of OctetString class value.
public CompareTo ( object obj ) : int
obj object Type: or byte or or or
Résultat int

Equals() public méthode

Compare 2 IpAddress objects.
public Equals ( object obj ) : bool
obj object object to compare against
Résultat bool

GetBroadcastAddress() public méthode

Returns broadcast address for the objects IP and supplied subnet mask. Subnet mask validity is not confirmed before performing the new value calculation so you should make sure parameter is a valid subnet mask by using IpAddress.IsValidMask method. Broadcast address is calculated by changing every bit in the subnet mask that is set to value 0 into 1 in the address value.
public GetBroadcastAddress ( IpAddress mask ) : IpAddress
mask IpAddress Subnet mask to apply to the object
Résultat IpAddress

GetClass() public méthode

Return network class of the IP address
public GetClass ( ) : int
Résultat int

GetHashCode() public méthode

Return hash representing the value of this object
public GetHashCode ( ) : int
Résultat int

GetMaskBits() public méthode

Returns number of subnet bits in the mask. Subnet bits are bits set to value 0 in the subnet mask.
public GetMaskBits ( ) : int
Résultat int

GetSubnetAddress() public méthode

Return subnet address of the IP address in this object and supplied subnet mask
public GetSubnetAddress ( IpAddress mask ) : IpAddress
mask IpAddress Subnet mask
Résultat IpAddress

Increment() public méthode

Increment IP address contained in the object by specific number and return the result as a new class.
public Increment ( UInt32 count ) : IpAddress
count System.UInt32 Number to increment IP address with
Résultat IpAddress

Invert() public méthode

Inverts IP address value. All 0s are converted to 1s and 1s to 0s
public Invert ( ) : IpAddress
Résultat IpAddress

IpAddress() public méthode

Constructs a default object with a length of zero. See the super class constructor for more details.
public IpAddress ( ) : System
Résultat System

IpAddress() public méthode

Copy constructor. Constructs a duplicate object based on the passed application string object.
IpAddress argument is null
public IpAddress ( IpAddress second ) : System
second IpAddress The object to copy.
Résultat System

IpAddress() public méthode

Copy constructor.
public IpAddress ( OctetString second ) : System
second OctetString The object to copy
Résultat System

IpAddress() public méthode

Constructor
Construct the IpAddress class from supplied IPAddress value.
public IpAddress ( System inetAddr ) : System
inetAddr System IP Address to use to initialize the object.
Résultat System

IpAddress() public méthode

Constructor
Initialize IpAddress class with the IP address value represented as 32-bit unsigned integer value
public IpAddress ( UInt32 inetAddr ) : System
inetAddr System.UInt32 32-bit unsigned integer representation of an IP Address
Résultat System

IpAddress() public méthode

Constructs an Application String with the passed data. The data is managed by the base class.
public IpAddress ( byte data ) : System
data byte The application string to manage (UTF-8) ///
Résultat System

IpAddress() public méthode

Constructs the class and initializes the value to the supplied IP address. See comments in IpAddress.Set(string) method for details.
public IpAddress ( string inetAddr ) : System
inetAddr string IP address encoded as a string or host name
Résultat System

IsIP() public static méthode

Check if supplied string contains a valid IP address. Valid IP address contains 3 full stops (".") and 4 numeric values in range 0 to 255.
Written to address slow performance of IPAddress.TryParse
public static IsIP ( string val ) : bool
val string String value
Résultat bool

IsValidMask() public méthode

Checks if the value of the object is a valid subnet mask. Subnet mask is a value of consecutive bits with value of 1. If a bit is found with a value of 0 followed (immediately or anywhere else before the end of the value) by a 1, then subnet mask value is not valid.
public IsValidMask ( ) : bool
Résultat bool

NetworkMask() public méthode

Returns network mask for the class value
Each IpAddress belongs to one of the 5 classes, A, B, C, D or E. D network class are multicast addresses and E is experimental class. Because D and E are not "real" network classes and as such don't have a network mask, only classes A, B and C will return a valid subnet mask. Classes D and E will return a null reference.
public NetworkMask ( ) : IpAddress
Résultat IpAddress

ReverseByteOrder() public static méthode

Reverse int value byte order. Static function in IPAddress class doesn't work the way I expected it (didn't troubleshoot) so here is another implementation. Reversing byte order is needed because network encoded IP address is presented in big-endian format. Intel based computers encode values in little-endian form so to perform numerical operations on received IP address values you will need to convert them from big to little-endian format. By the same token, if you wish to transmit data using IP address value calculated on the local system, you will need to convert it to big-endian prior to transmission.
public static ReverseByteOrder ( uint val ) : uint
val uint Integer value to reverse
Résultat uint

Set() public méthode

Set class value from the IPAddress argument
public Set ( IPAddress ipaddr ) : void
ipaddr System.Net.IPAddress Type: class instance
Résultat void

Set() public méthode

Sets the class value to the IP address parsed from the string parameter.
Class value will be set with the parsed dotted decimal IP address in the parameter or if string parameter does not represent an IP address, DNS resolution will be performed. Note: DNS resolution is performed using System.Net.Dns.GetHostEntry(string) and can result in a longer then expected delay in this function. In applications where responsiveness is important, name resolution should be performed using async methods available and result passed to this method.
Thrown when DNS resolution of the parameter value has failed.
public Set ( String value ) : void
value String IP address encoded as a string or host name
Résultat void

Set() public méthode

Set class value from 32-bit unsigned integer value representation of the IP address value
public Set ( UInt32 ipvalue ) : void
ipvalue System.UInt32 IP address value as 32-bit unsigned integer value
Résultat void

ToString() public méthode

Returns the application string as a dotted decimal represented IP address.
public ToString ( ) : System.String
Résultat System.String

ToUInt32() public méthode

Network byte order IP address
Convert internal byte array representation of the IP address into a network byte order (most significant byte first) unsigned integer value. To use the returned value in mathematical operations, you will need to change it to host byte order on little endian systems (all i386 compatible systems). To do that, call static method IpAddress.ReverseByteOrder().
public ToUInt32 ( ) : UInt32
Résultat System.UInt32

decode() public méthode

Decode ASN.1 encoded IP address value.
Parsed data length is not 4 bytes long Parsed data is not in IpAddress format
public decode ( byte buffer, int offset ) : int
buffer byte BER encoded data buffer
offset int Offset in the array to start parsing from
Résultat int

Property Details

ClassA public_oe static_oe property

Class A IP address
public static int ClassA
Résultat int

ClassB public_oe static_oe property

Class B IP address
public static int ClassB
Résultat int

ClassC public_oe static_oe property

Class C IP address
public static int ClassC
Résultat int

ClassD public_oe static_oe property

Class D IP address
public static int ClassD
Résultat int

ClassE public_oe static_oe property

Class E IP address
public static int ClassE
Résultat int

InvalidClass public_oe static_oe property

Invalid IP address class
public static int InvalidClass
Résultat int