C# Класс SnmpSharpNet.IpAddress

Наследование: OctetString, IComparable, ICloneable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
ClassA int
ClassB int
ClassC int
ClassD int
ClassE int
InvalidClass int

Открытые методы

Метод Описание
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.

Описание методов

BuildMaskFromBits() публичный статический Метод

Build a subnet mask from bit count value
public static BuildMaskFromBits ( int bits ) : IpAddress
bits int Number of subnet mask bits
Результат IpAddress

Clone() публичный Метод

Clone current object.
public Clone ( ) : Object
Результат System.Object

CompareTo() публичный Метод

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
Результат int

Equals() публичный Метод

Compare 2 IpAddress objects.
public Equals ( object obj ) : bool
obj object object to compare against
Результат bool

GetBroadcastAddress() публичный Метод

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
Результат IpAddress

GetClass() публичный Метод

Return network class of the IP address
public GetClass ( ) : int
Результат int

GetHashCode() публичный Метод

Return hash representing the value of this object
public GetHashCode ( ) : int
Результат int

GetMaskBits() публичный Метод

Returns number of subnet bits in the mask. Subnet bits are bits set to value 0 in the subnet mask.
public GetMaskBits ( ) : int
Результат int

GetSubnetAddress() публичный Метод

Return subnet address of the IP address in this object and supplied subnet mask
public GetSubnetAddress ( IpAddress mask ) : IpAddress
mask IpAddress Subnet mask
Результат IpAddress

Increment() публичный Метод

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
Результат IpAddress

Invert() публичный Метод

Inverts IP address value. All 0s are converted to 1s and 1s to 0s
public Invert ( ) : IpAddress
Результат IpAddress

IpAddress() публичный Метод

Constructs a default object with a length of zero. See the super class constructor for more details.
public IpAddress ( ) : System
Результат System

IpAddress() публичный Метод

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.
Результат System

IpAddress() публичный Метод

Copy constructor.
public IpAddress ( OctetString second ) : System
second OctetString The object to copy
Результат System

IpAddress() публичный Метод

Constructor
Construct the IpAddress class from supplied IPAddress value.
public IpAddress ( System inetAddr ) : System
inetAddr System IP Address to use to initialize the object.
Результат System

IpAddress() публичный Метод

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
Результат System

IpAddress() публичный Метод

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) ///
Результат System

IpAddress() публичный Метод

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
Результат System

IsIP() публичный статический Метод

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
Результат bool

IsValidMask() публичный Метод

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
Результат bool

NetworkMask() публичный Метод

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
Результат IpAddress

ReverseByteOrder() публичный статический Метод

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
Результат uint

Set() публичный Метод

Set class value from the IPAddress argument
public Set ( IPAddress ipaddr ) : void
ipaddr System.Net.IPAddress Type: class instance
Результат void

Set() публичный Метод

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
Результат void

Set() публичный Метод

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
Результат void

ToString() публичный Метод

Returns the application string as a dotted decimal represented IP address.
public ToString ( ) : System.String
Результат System.String

ToUInt32() публичный Метод

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
Результат System.UInt32

decode() публичный Метод

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
Результат int

Описание свойств

ClassA публичное статическое свойство

Class A IP address
public static int ClassA
Результат int

ClassB публичное статическое свойство

Class B IP address
public static int ClassB
Результат int

ClassC публичное статическое свойство

Class C IP address
public static int ClassC
Результат int

ClassD публичное статическое свойство

Class D IP address
public static int ClassD
Результат int

ClassE публичное статическое свойство

Class E IP address
public static int ClassE
Результат int

InvalidClass публичное статическое свойство

Invalid IP address class
public static int InvalidClass
Результат int