Noble Connect
Add relays and punchthrough to Mirror or UNet
NobleConnect.Stun.AttributeMappedAddress Class Reference

Mapped Address Attribute. Holds an IPAddress and port. More...

Inherits NobleConnect.Stun.Attribute.

Inherited by NobleConnect.Stun.AttributeXORMappedAddress.

Public Member Functions

 AttributeMappedAddress (AttributeType attributeType, ushort port, IPAddress ipAddress)
 Construct an AttributeMappedAddress of the provided AttributeType using the provided ip address and port More...
 
 AttributeMappedAddress (AttributeType type, byte[] buffer, ref int offset, ReadOnlyByteArray transactionID)
 Construct an AttributeMappedAddress from the provided byte array More...
 
override void SerializeValues (BufferView buffer, ReadOnlyByteArray transactionID)
 Transform family, ip, and port into ArraySegments of bytes to be sent over the network. More...
 
virtual void SerializePort (BufferView buffer)
 Serialize the Port value. More...
 
virtual void SerializeIPAddress (BufferView buffer)
 Serialize the IP Address value. More...
 
virtual void SerializeIPv6Address (BufferView buffer, ReadOnlyByteArray transactionID)
 Serialize the IPv6 Address value. More...
 
override ushort GetValueSize ()
 Get the serialized size of the attribute values More...
 
- Public Member Functions inherited from NobleConnect.Stun.Attribute
 Attribute (AttributeType type)
 Construct an Attribute of the provided AttributeType More...
 
 Attribute (AttributeType type, ref int offset)
 
void Serialize (BufferView buffer, ReadOnlyByteArray transactionID)
 Convert this attribute to a bunch of bytes and add them to the provided buffer More...
 
ushort GetSize ()
 

Static Public Member Functions

static ushort DeserializePort (byte[] buffer, int offset)
 Realize the Port value. More...
 
static IPAddress DeserializeIP (byte[] buffer, int offset)
 Realize the IP Address value. More...
 
static IPAddress DeserializeIPv6 (byte[] buffer, int offset, ReadOnlyByteArray transactionID)
 Realize the IPv6 Address value. More...
 
- Static Public Member Functions inherited from NobleConnect.Stun.Attribute
static ushort DeserializeLength (byte[] buffer, ref int offset)
 Read the Attribute length from a byte array. More...
 
static ushort GetNumPaddingBytes (int length)
 Calculate padding based on length More...
 

Public Attributes

readonly ushort port
 The Port as an unsigned short More...
 
readonly ReadOnlyCollection< byte > addressBytes
 The IPAddress as bytes More...
 
readonly AddressFamily addressFamily
 The AddressFamily More...
 
- Public Attributes inherited from NobleConnect.Stun.Attribute
readonly AttributeType attributeType
 The AttributeType of this Attribute More...
 

Properties

IPAddress IPAddress [get]
 
IPEndPoint IPEndPoint [get]
 

Additional Inherited Members

- Static Public Attributes inherited from NobleConnect.Stun.Attribute
const int HEADER_SIZE = 4
 

Detailed Description

Mapped Address Attribute. Holds an IPAddress and port.

See 5389 Section 15.3 for details. 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0 0 0 0 0 0 0 0| Family | Port | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | Address(32 bits or 128 bits) | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The address family can take on the following values: 0x01:IPv4 0x02:IPv6

The first 8 bits of the MAPPED-ADDRESS MUST are ignored. These bits are present for aligning on 32-bit boundaries. This attribute is used only by servers for achieving backwards compatibility with RFC 3489 clients.

Constructor & Destructor Documentation

◆ AttributeMappedAddress() [1/2]

NobleConnect.Stun.AttributeMappedAddress.AttributeMappedAddress ( AttributeType  attributeType,
ushort  port,
IPAddress  ipAddress 
)

Construct an AttributeMappedAddress of the provided AttributeType using the provided ip address and port

This is called when constructing an Attribute to send to a Stun server.

Parameters
attributeType
ipAddress
port

◆ AttributeMappedAddress() [2/2]

NobleConnect.Stun.AttributeMappedAddress.AttributeMappedAddress ( AttributeType  type,
byte[]  buffer,
ref int  offset,
ReadOnlyByteArray  transactionID 
)

Construct an AttributeMappedAddress from the provided byte array

This is called when deserializing an AttributeMappedAddress received from a Stun server.

Parameters
type
buffer
offset

Member Function Documentation

◆ DeserializeIP()

static IPAddress NobleConnect.Stun.AttributeMappedAddress.DeserializeIP ( byte[]  buffer,
int  offset 
)
static

Realize the IP Address value.

This is virtual because XORMAppedAddress overrides it to perform decoding

◆ DeserializeIPv6()

static IPAddress NobleConnect.Stun.AttributeMappedAddress.DeserializeIPv6 ( byte[]  buffer,
int  offset,
ReadOnlyByteArray  transactionID 
)
static

Realize the IPv6 Address value.

This is virtual because XORMAppedAddress overrides it to perform decoding

◆ DeserializePort()

static ushort NobleConnect.Stun.AttributeMappedAddress.DeserializePort ( byte[]  buffer,
int  offset 
)
static

Realize the Port value.

This is virtual because XORMAppedAddress overrides it to perform decoding

◆ GetValueSize()

override ushort NobleConnect.Stun.AttributeMappedAddress.GetValueSize ( )
virtual

Get the serialized size of the attribute values

Returns
2 bytes for family plus 2 bytes for port plus 4 bytes for IPv4 address or 16 bytes for IPv6 address.

Reimplemented from NobleConnect.Stun.Attribute.

◆ SerializeIPAddress()

virtual void NobleConnect.Stun.AttributeMappedAddress.SerializeIPAddress ( BufferView  buffer)
virtual

Serialize the IP Address value.

This is virtual because XORMAppedAddress overrides it to perform decoding

Reimplemented in NobleConnect.Stun.AttributeXORMappedAddress.

◆ SerializeIPv6Address()

virtual void NobleConnect.Stun.AttributeMappedAddress.SerializeIPv6Address ( BufferView  buffer,
ReadOnlyByteArray  transactionID 
)
virtual

Serialize the IPv6 Address value.

This is virtual because XORMAppedAddress overrides it to perform decoding

Reimplemented in NobleConnect.Stun.AttributeXORMappedAddress.

◆ SerializePort()

virtual void NobleConnect.Stun.AttributeMappedAddress.SerializePort ( BufferView  buffer)
virtual

Serialize the Port value.

This is virtual because XORMAppedAddress overrides it to perform decoding

Reimplemented in NobleConnect.Stun.AttributeXORMappedAddress.

◆ SerializeValues()

override void NobleConnect.Stun.AttributeMappedAddress.SerializeValues ( BufferView  buffer,
ReadOnlyByteArray  transactionID 
)
virtual

Transform family, ip, and port into ArraySegments of bytes to be sent over the network.

Reimplemented from NobleConnect.Stun.Attribute.

Member Data Documentation

◆ addressBytes

readonly ReadOnlyCollection<byte> NobleConnect.Stun.AttributeMappedAddress.addressBytes

The IPAddress as bytes

◆ addressFamily

readonly AddressFamily NobleConnect.Stun.AttributeMappedAddress.addressFamily

The AddressFamily

◆ port

readonly ushort NobleConnect.Stun.AttributeMappedAddress.port

The Port as an unsigned short

Property Documentation

◆ IPAddress

IPAddress NobleConnect.Stun.AttributeMappedAddress.IPAddress
get

◆ IPEndPoint

IPEndPoint NobleConnect.Stun.AttributeMappedAddress.IPEndPoint
get