Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions nanoFramework.System.Net/IPAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public class IPAddress
/// </summary>
public static readonly IPAddress Loopback = new IPAddress(0x000000000100007F);

[Diagnostics.DebuggerBrowsable(Diagnostics.DebuggerBrowsableState.Never)]
internal long _address;
internal long Address;

[Diagnostics.DebuggerBrowsable(Diagnostics.DebuggerBrowsableState.Never)]
private AddressFamily _family = AddressFamily.InterNetwork;
Expand Down Expand Up @@ -63,7 +62,7 @@ public IPAddress(long newAddress)
throw new ArgumentOutOfRangeException();
}

_address = newAddress;
Address = newAddress;

// default to InterNetwork
_family = AddressFamily.InterNetwork;
Expand All @@ -79,7 +78,7 @@ public IPAddress(byte[] address)
{
_family = AddressFamily.InterNetwork;
// need to offset address by 4 (1st are family, 2nd are port
_address = ((address[3 + 4] << 24 | address[2 + 4] << 16 | address[1 + 4] << 8 | address[0 + 4]) & 0x0FFFFFFFF);
Address = ((address[3 + 4] << 24 | address[2 + 4] << 16 | address[1 + 4] << 8 | address[0 + 4]) & 0x0FFFFFFFF);
}
else if (address[0] == (byte)AddressFamily.InterNetworkV6)
{
Expand Down Expand Up @@ -108,7 +107,7 @@ public override bool Equals(object obj)

if (obj == null) return false;

return this._address == addr._address;
return this.Address == addr.Address;
}

/// <summary>
Expand All @@ -119,10 +118,10 @@ public byte[] GetAddressBytes()
{
return new byte[]
{
(byte)(_address),
(byte)(_address >> 8),
(byte)(_address >> 16),
(byte)(_address >> 24)
(byte)(Address),
(byte)(Address >> 8),
(byte)(Address >> 16),
(byte)(Address >> 24)
};
}

Expand Down Expand Up @@ -180,13 +179,13 @@ public static IPAddress Parse(string ipString)
/// </remarks>
public override string ToString()
{
return ((byte)(_address)).ToString() +
return ((byte)(Address)).ToString() +
"." +
((byte)(_address >> 8)).ToString() +
((byte)(Address >> 8)).ToString() +
"." +
((byte)(_address >> 16)).ToString() +
((byte)(Address >> 16)).ToString() +
"." +
((byte)(_address >> 24)).ToString();
((byte)(Address >> 24)).ToString();
}

/// <summary>
Expand Down Expand Up @@ -223,7 +222,7 @@ internal IPAddress Snapshot()
switch (_family)
{
case AddressFamily.InterNetwork:
return new IPAddress(_address);
return new IPAddress(Address);

//case AddressFamily.InterNetworkV6:
// return new IPAddress(m_Numbers, (uint)m_ScopeId);
Expand Down
8 changes: 4 additions & 4 deletions nanoFramework.System.Net/IPEndPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ public override SocketAddress Serialize()
buffer[2] = unchecked((byte)(_port >> 8));
buffer[3] = unchecked((byte)(_port));

buffer[4] = unchecked((byte)(_address._address));
buffer[5] = unchecked((byte)(_address._address >> 8));
buffer[6] = unchecked((byte)(_address._address >> 16));
buffer[7] = unchecked((byte)(_address._address >> 24));
buffer[4] = unchecked((byte)(_address.Address));
buffer[5] = unchecked((byte)(_address.Address >> 8));
buffer[6] = unchecked((byte)(_address.Address >> 16));
buffer[7] = unchecked((byte)(_address.Address >> 24));

return socketAddress;
}
Expand Down
8 changes: 4 additions & 4 deletions nanoFramework.System.Net/SocketAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ internal SocketAddress(IPAddress ipAddress)
//else
{
// IPv4 Address serialization
m_Buffer[4] = unchecked((byte)(ipAddress._address));
m_Buffer[5] = unchecked((byte)(ipAddress._address >> 8));
m_Buffer[6] = unchecked((byte)(ipAddress._address >> 16));
m_Buffer[7] = unchecked((byte)(ipAddress._address >> 24));
m_Buffer[4] = unchecked((byte)(ipAddress.Address));
m_Buffer[5] = unchecked((byte)(ipAddress.Address >> 8));
m_Buffer[6] = unchecked((byte)(ipAddress.Address >> 16));
m_Buffer[7] = unchecked((byte)(ipAddress.Address >> 24));
}
}

Expand Down