C# Class Lidgren.Network.Authentication.NetUtility

Utility methods
Show file Open project: SleeplessByte/lidgren-srp6a Class Usage Examples

Public Methods

Method Description
ArraysEqual ( Byte ba1, Byte ba2 ) : System.Boolean

Checks if Arrays are Equal

BitsToHoldUInt ( uint value ) : int

Returns how many bits are necessary to hold a certain number

BytesToHoldBits ( int numBits ) : int

Returns how many bytes are required to hold a certain number of bits

GetMacAddress ( ) : System.Net.NetworkInformation.PhysicalAddress

Returns the physical (MAC) address for the first usable network interface

GetMyAddress ( IPAddress &mask ) : IPAddress

Gets my local IP address (not necessarily external) and subnet mask

IsLocal ( IPAddress remote ) : bool

Returns true if the IPAddress supplied is on the same subnet as this host

IsLocal ( IPEndPoint endpoint ) : bool

Returns true if the IPEndPoint supplied is on the same subnet as this host

JoinArrays ( Byte b1, Byte b2 ) : Byte[]

Joins two arrays using Buffer.Blockcopy

JoinArrays ( System byteArrays ) : Byte[]

Joins all arrays in arraylist using MemoryStream

Resolve ( string ipOrHost ) : IPAddress

Get IPv4 address from notation (xxx.xxx.xxx.xxx) or hostname

Resolve ( string ipOrHost, int port ) : IPEndPoint

Get IPv4 endpoint from notation (xxx.xxx.xxx.xxx) or hostname and port number

ToByteArray ( String hexString ) : byte[]

Convert a hexadecimal string to a byte array

ToHexString ( byte data ) : string

Create a hex string from an array of bytes

ToHexString ( long data ) : string

Create a hex string from an Int64 value

ToHumanReadable ( long bytes ) : string

Converts a number of bytes to a shorter, more readable string representation

Private Methods

Method Description
CompareElements ( byte one, byte two ) : bool
GetNetworkInterface ( ) : NetworkInterface
SortMembersList ( System list ) : void
SwapByteOrder ( UInt32 value ) : UInt32
SwapByteOrder ( System.UInt64 value ) : System.UInt64

Method Details

ArraysEqual() public static method

Checks if Arrays are Equal
public static ArraysEqual ( Byte ba1, Byte ba2 ) : System.Boolean
ba1 Byte
ba2 Byte
return System.Boolean

BitsToHoldUInt() public static method

Returns how many bits are necessary to hold a certain number
public static BitsToHoldUInt ( uint value ) : int
value uint
return int

BytesToHoldBits() public static method

Returns how many bytes are required to hold a certain number of bits
public static BytesToHoldBits ( int numBits ) : int
numBits int
return int

GetMacAddress() public static method

Returns the physical (MAC) address for the first usable network interface
public static GetMacAddress ( ) : System.Net.NetworkInformation.PhysicalAddress
return System.Net.NetworkInformation.PhysicalAddress

GetMyAddress() public static method

Gets my local IP address (not necessarily external) and subnet mask
public static GetMyAddress ( IPAddress &mask ) : IPAddress
mask System.Net.IPAddress
return System.Net.IPAddress

IsLocal() public static method

Returns true if the IPAddress supplied is on the same subnet as this host
public static IsLocal ( IPAddress remote ) : bool
remote System.Net.IPAddress
return bool

IsLocal() public static method

Returns true if the IPEndPoint supplied is on the same subnet as this host
public static IsLocal ( IPEndPoint endpoint ) : bool
endpoint System.Net.IPEndPoint
return bool

JoinArrays() public static method

Joins two arrays using Buffer.Blockcopy
public static JoinArrays ( Byte b1, Byte b2 ) : Byte[]
b1 Byte
b2 Byte
return Byte[]

JoinArrays() public static method

Joins all arrays in arraylist using MemoryStream
public static JoinArrays ( System byteArrays ) : Byte[]
byteArrays System list of arrays to join
return Byte[]

Resolve() public static method

Get IPv4 address from notation (xxx.xxx.xxx.xxx) or hostname
public static Resolve ( string ipOrHost ) : IPAddress
ipOrHost string
return System.Net.IPAddress

Resolve() public static method

Get IPv4 endpoint from notation (xxx.xxx.xxx.xxx) or hostname and port number
public static Resolve ( string ipOrHost, int port ) : IPEndPoint
ipOrHost string
port int
return System.Net.IPEndPoint

ToByteArray() public static method

Convert a hexadecimal string to a byte array
public static ToByteArray ( String hexString ) : byte[]
hexString String
return byte[]

ToHexString() public static method

Create a hex string from an array of bytes
public static ToHexString ( byte data ) : string
data byte
return string

ToHexString() public static method

Create a hex string from an Int64 value
public static ToHexString ( long data ) : string
data long
return string

ToHumanReadable() public static method

Converts a number of bytes to a shorter, more readable string representation
public static ToHumanReadable ( long bytes ) : string
bytes long
return string