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
25 changes: 1 addition & 24 deletions source/nanoFramework.System.Net/DNS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,7 @@ public static IPHostEntry GetHostEntry(string hostNameOrAddress)

for (int i = 0; i < cAddresses; i++)
{
byte[] address = addresses[i];

SocketAddress sockAddress = new SocketAddress(address);

AddressFamily family;

//if(SystemInfo.IsBigEndian)
////{
// family = (AddressFamily)((address[0] << 8) | address[1]);
//}
//else
{
family = (AddressFamily)((address[1] << 8) | address[0]);
}
//port address[2-3]

if (family == AddressFamily.InterNetwork)
{
//This only works with IPv4 addresses

uint ipAddr = (uint)((address[7] << 24) | (address[6] << 16) | (address[5] << 8) | (address[4]));

ipAddresses[i] = new IPAddress((long)ipAddr);
}
ipAddresses[i] = new IPAddress(addresses[i]);
}

ipHostEntry.hostName = canonicalName;
Expand Down
12 changes: 9 additions & 3 deletions source/nanoFramework.System.Net/IPAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ public IPAddress(long newAddress)
/// <param name="address"></param>
public IPAddress(byte[] address)
{
if (address.Length == IPv4AddressBytes)
if (address[0] == (byte)AddressFamily.InterNetwork)
{
_family = AddressFamily.InterNetwork;
_address = ((address[3] << 24 | address[2] << 16 | address[1] << 8 | address[0]) & 0x0FFFFFFFF);
// 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);
}
else
else if (address[0] == (byte)AddressFamily.InterNetworkV6)
{
_family = AddressFamily.InterNetworkV6;

Expand All @@ -89,6 +90,11 @@ public IPAddress(byte[] address)
_numbers[i] = (ushort)(address[i * 2] * 256 + address[i * 2 + 1]);
}
}
else
{
// unsupported address family
throw new NotSupportedException();
}
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion source/nanoFramework.System.Net/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

////////////////////////////////////////////////////////////////
// update this whenever the native assembly signature changes //
[assembly: AssemblyNativeVersion("1.1.0.0")]
[assembly: AssemblyNativeVersion("1.1.1.0")]
////////////////////////////////////////////////////////////////

// Setting ComVisible to false makes the types in this assembly not visible
Expand Down
11 changes: 4 additions & 7 deletions source/nanoFramework.System.Net/Sockets/Socket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,20 @@ private EndPoint GetEndPoint(bool fLocal)
m_localEndPoint = new IPEndPoint(IPAddress.Any, 0);
}

byte[] address = null;
EndPoint endPoint = null;

if (fLocal)
{
NativeSocket.getsockname(this, out address);
NativeSocket.getsockname(this, out endPoint);
}
else
{
NativeSocket.getpeername(this, out address);
NativeSocket.getpeername(this, out endPoint);
}

SocketAddress socketAddress = new SocketAddress(address);
ep = m_localEndPoint.Create(socketAddress);

if (fLocal)
{
m_localEndPoint = ep;
m_localEndPoint = endPoint;
}

return ep;
Expand Down
8 changes: 4 additions & 4 deletions source/nanoFramework.System.Net/Sockets/SocketsNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ internal class NativeSocket
public static extern void shutdown(object socket, int how, out int err);

[MethodImpl(MethodImplOptions.InternalCall)]
public static extern int sendto(object socket, byte[] buf, int offset, int count, int flags, int timeout_ms, EndPoint address);
public static extern int sendto(object socket, byte[] buf, int offset, int count, int flags, int timeout_ms, EndPoint endPoint);

[MethodImpl(MethodImplOptions.InternalCall)]
public static extern int recvfrom(object socket, byte[] buf, int offset, int count, int flags, int timeout_ms, ref EndPoint address);
public static extern int recvfrom(object socket, byte[] buf, int offset, int count, int flags, int timeout_ms, ref EndPoint endPoint);

[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void getpeername(object socket, out byte[] address);
public static extern void getpeername(object socket, out EndPoint endPoint);

[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void getsockname(object socket, out byte[] address);
public static extern void getsockname(object socket, out EndPoint endPoint);

[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void getsockopt(object socket, int level, int optname, byte[] optval);
Expand Down
2 changes: 1 addition & 1 deletion source/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.1.0-preview.{height}",
"version": "1.1.1-preview.{height}",
"release": {
"branchName" : "release-v{version}",
"versionIncrement" : "minor",
Expand Down