Class NetConvert
This class provides various static functions for fixing Little-Endian/Big-Endian byte ordering issues.
Inherited Members
Namespace: SipLib.Dtls
Assembly: SipLib.dll
Syntax
public class NetConvert
Methods
| Edit this page View SourceDoReverseEndian(int)
Reverses the byte order of an int (32 bit signed integer)
Declaration
public static int DoReverseEndian(int x)
Parameters
Type | Name | Description |
---|---|---|
int | x | Input int |
Returns
Type | Description |
---|---|
int | Returns an int with the byte order reversed |
DoReverseEndian(ushort)
Reverses the byte-order of a UInt16 (unsigned 16 bit integer0
Declaration
public static ushort DoReverseEndian(ushort x)
Parameters
Type | Name | Description |
---|---|---|
ushort | x | Input UInt16 |
Returns
Type | Description |
---|---|
ushort | Returns a UInt16 with the byte order reversed |
DoReverseEndian(uint)
Reverses the byte-order of a uint (32 bit unsigned integer)
Declaration
public static uint DoReverseEndian(uint x)
Parameters
Type | Name | Description |
---|---|---|
uint | x | Input uint |
Returns
Type | Description |
---|---|
uint | Returns a uint with the byte order reversed. |
DoReverseEndian(ulong)
Reverses the byte order of a ulong (unsigned 64 bit integer)
Declaration
public static ulong DoReverseEndian(ulong x)
Parameters
Type | Name | Description |
---|---|---|
ulong | x | Input ulong |
Returns
Type | Description |
---|---|
ulong | Returns a ulong with the byte order reversed |
EndianFlip(uint)
Reverses the endianness of a UInt32.
Declaration
public static uint EndianFlip(uint val)
Parameters
Type | Name | Description |
---|---|---|
uint | val | The value to flip. |
Returns
Type | Description |
---|---|
uint | The same value but with the endianness flipped. |
GetBytes(ushort)
Get a buffer representing the unsigned 16 bit integer in network byte (big endian) order.
Declaration
public static byte[] GetBytes(ushort val)
Parameters
Type | Name | Description |
---|---|---|
ushort | val | The value to convert. |
Returns
Type | Description |
---|---|
byte[] | A buffer representing the value in network order |
GetBytes(uint)
Get a buffer representing the 32 bit unsigned integer in network byte (big endian) order.
Declaration
public static byte[] GetBytes(uint val)
Parameters
Type | Name | Description |
---|---|---|
uint | val | The value to convert. |
Returns
Type | Description |
---|---|
byte[] | A buffer representing the value in network order |
GetBytes(ulong)
Get a buffer representing the 64 bit unsigned integer in network byte (big endian) order.
Declaration
public static byte[] GetBytes(ulong val)
Parameters
Type | Name | Description |
---|---|---|
ulong | val | The value to convert. |
Returns
Type | Description |
---|---|
byte[] | A buffer representing the value in network order |
ParseUInt16(byte[], int)
Parse a UInt16 from a network buffer using network byte order.
Declaration
public static ushort ParseUInt16(byte[] buffer, int posn)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | The buffer to parse the value from. |
int | posn | The position in the buffer to start the parse from. |
Returns
Type | Description |
---|---|
ushort | A UInt16 value. |
ParseUInt32(byte[], int)
Parse a UInt32 from a network buffer using network byte order.
Declaration
public static uint ParseUInt32(byte[] buffer, int posn)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | The buffer to parse the value from. |
int | posn | The position in the buffer to start the parse from. |
Returns
Type | Description |
---|---|
uint | A UInt32 value. |
ParseUInt64(byte[], int)
Parse a UInt64 from a network buffer using network byte order.
Declaration
public static ulong ParseUInt64(byte[] buffer, int posn)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | The buffer to parse the value from. |
int | posn | The position in the buffer to start the parse from. |
Returns
Type | Description |
---|---|
ulong | A UInt64 value. |
ToBuffer(ushort, byte[], int)
Writes a UInt16 value to a network buffer using network byte order.
Declaration
public static void ToBuffer(ushort val, byte[] buffer, int posn)
Parameters
Type | Name | Description |
---|---|---|
ushort | val | The value to write to the buffer. |
byte[] | buffer | The buffer to write the value to. |
int | posn | The start position in the buffer to write the value at. |
ToBuffer(uint, byte[], int)
Writes a UInt32 value to a network buffer using network byte order.
Declaration
public static void ToBuffer(uint val, byte[] buffer, int posn)
Parameters
Type | Name | Description |
---|---|---|
uint | val | The value to write to the buffer. |
byte[] | buffer | The buffer to write the value to. |
int | posn | The start position in the buffer to write the value at. |
ToBuffer(ulong, byte[], int)
Writes a UInt64 value to a network buffer using network byte order.
Declaration
public static void ToBuffer(ulong val, byte[] buffer, int posn)
Parameters
Type | Name | Description |
---|---|---|
ulong | val | The value to write to the buffer. |
byte[] | buffer | The buffer to write the value to. |
int | posn | The start position in the buffer to write the value at. |