diff --git a/source/Cosmos.HAL2/Network/MACAddress.cs b/source/Cosmos.HAL2/Network/MACAddress.cs
index 073e82917..73b50b167 100644
--- a/source/Cosmos.HAL2/Network/MACAddress.cs
+++ b/source/Cosmos.HAL2/Network/MACAddress.cs
@@ -33,7 +33,9 @@ namespace Cosmos.HAL.Network
public MACAddress(byte[] address)
{
if (address == null || address.Length != 6)
+ {
throw new ArgumentException("MACAddress is null or has wrong length", "address");
+ }
bytes[0] = address[0];
bytes[1] = address[1];
@@ -52,7 +54,9 @@ namespace Cosmos.HAL.Network
public MACAddress(byte[] buffer, int offset)
{
if (buffer == null || buffer.Length < (offset + 6))
+ {
throw new ArgumentException("buffer does not contain enough data starting at offset", "buffer");
+ }
bytes[0] = buffer[offset];
bytes[1] = buffer[offset + 1];
@@ -95,7 +99,9 @@ namespace Cosmos.HAL.Network
return 0;
}
else
+ {
throw new ArgumentException("obj is not a MACAddress", "obj");
+ }
}
public override bool Equals(object obj)
@@ -112,17 +118,19 @@ namespace Cosmos.HAL.Network
bytes[5] == other.bytes[5];
}
else
+ {
throw new ArgumentException("obj is not a MACAddress", "obj");
+ }
}
public override int GetHashCode()
{
- return (GetType().AssemblyQualifiedName + "|" + this.ToString()).GetHashCode();
+ return (GetType().AssemblyQualifiedName + "|" + ToString()).GetHashCode();
}
- public UInt64 ToNumber()
+ public ulong ToNumber()
{
- return (UInt64)((bytes[0] << 40) | (bytes[1] << 32) | (bytes[2] << 24) | (bytes[3] << 16) |
+ return (ulong)((bytes[0] << 40) | (bytes[1] << 32) | (bytes[2] << 24) | (bytes[3] << 16) |
(bytes[4] << 8) | (bytes[5] << 0));
}
@@ -133,23 +141,23 @@ namespace Cosmos.HAL.Network
aChars[aIndex + 1] = xChars[aByte & 0xF];
}
- public UInt32 to32BitNumber()
+ public uint To32BitNumber()
{
- return (UInt32)((bytes[0] << 40) | (bytes[1] << 32) | (bytes[2] << 24) | (bytes[3] << 16) |
+ return (uint)((bytes[0] << 40) | (bytes[1] << 32) | (bytes[2] << 24) | (bytes[3] << 16) |
(bytes[4] << 8) | (bytes[5] << 0));
}
- private UInt32 hash;
+ private uint hash;
///
/// Hash value for this mac. Used to uniquely identify each mac
///
- public UInt32 Hash
+ public uint Hash
{
get
{
if (hash == 0)
{
- hash = to32BitNumber();
+ hash = To32BitNumber();
}
return hash;
@@ -171,7 +179,7 @@ namespace Cosmos.HAL.Network
PutByte(xChars, 12, bytes[4]);
xChars[14] = ':';
PutByte(xChars, 15, bytes[5]);
- return new String(xChars);
+ return new string(xChars);
}
}
}
diff --git a/source/Cosmos.System2/Network/ARP/ARPCache.cs b/source/Cosmos.System2/Network/ARP/ARPCache.cs
index b963d1c25..1d09564f6 100644
--- a/source/Cosmos.System2/Network/ARP/ARPCache.cs
+++ b/source/Cosmos.System2/Network/ARP/ARPCache.cs
@@ -19,7 +19,7 @@ namespace Cosmos.System.Network.ARP
///
/// Cache.
///
- private static Dictionary cache;
+ public static Dictionary cache;
///
/// Ensure cache exists.
@@ -55,11 +55,7 @@ namespace Cosmos.System.Network.ARP
internal static void Update(IPv4.Address ipAddress, MACAddress macAddress)
{
ensureCacheExists();
- if (ipAddress == null)
- {
- global::System.Console.Write("");
- }
- UInt32 ip_hash = ipAddress.Hash;
+ uint ip_hash = ipAddress.Hash;
if (ip_hash == 0)
{
return;
diff --git a/source/Cosmos.System2/Network/Config/DNSConfig.cs b/source/Cosmos.System2/Network/Config/DNSConfig.cs
index 9fd9b44d6..7967b580f 100644
--- a/source/Cosmos.System2/Network/Config/DNSConfig.cs
+++ b/source/Cosmos.System2/Network/Config/DNSConfig.cs
@@ -21,9 +21,9 @@ namespace Cosmos.System.Network.Config
///
public static void Add(Address nameserver)
{
- foreach (var ns in DNSNameservers)
+ for (int i = 0; i < DNSNameservers.Count; i++)
{
- if (ns.address.ToString() == nameserver.address.ToString())
+ if (DNSNameservers[i].address.Equals(nameserver))
{
return;
}
diff --git a/source/Cosmos.System2/Network/IPV4/ICMPClient.cs b/source/Cosmos.System2/Network/IPV4/ICMPClient.cs
index c95f0dbd5..fcc348cf9 100644
--- a/source/Cosmos.System2/Network/IPV4/ICMPClient.cs
+++ b/source/Cosmos.System2/Network/IPV4/ICMPClient.cs
@@ -47,7 +47,7 @@ namespace Cosmos.System.Network.IPv4
///
/// IP Hash.
/// ICMPClient
- internal static ICMPClient Client(uint iphash)
+ internal static ICMPClient GetClient(uint iphash)
{
if (clients.ContainsKey(iphash) == true)
{
diff --git a/source/Cosmos.System2/Network/IPV4/UDP/DNS/DNSPacket.cs b/source/Cosmos.System2/Network/IPV4/UDP/DNS/DNSPacket.cs
index 2cff9a0af..2f8aba053 100644
--- a/source/Cosmos.System2/Network/IPV4/UDP/DNS/DNSPacket.cs
+++ b/source/Cosmos.System2/Network/IPV4/UDP/DNS/DNSPacket.cs
@@ -61,7 +61,7 @@ namespace Cosmos.System.Network.IPv4.UDP.DNS
{
DNSPacket dns_packet = new DNSPacket(packetData);
- DnsClient receiver = (DnsClient)UdpClient.Client(dns_packet.DestinationPort);
+ DnsClient receiver = (DnsClient)UdpClient.GetClient(dns_packet.DestinationPort);
if (receiver != null)
{
receiver.receiveData(dns_packet);
diff --git a/source/Cosmos.System2/Network/IPv4/ICMPPacket.cs b/source/Cosmos.System2/Network/IPv4/ICMPPacket.cs
index f237e2a38..0e5d5cedf 100644
--- a/source/Cosmos.System2/Network/IPv4/ICMPPacket.cs
+++ b/source/Cosmos.System2/Network/IPv4/ICMPPacket.cs
@@ -42,7 +42,7 @@ namespace Cosmos.System.Network.IPv4
switch (icmp_packet.ICMP_Type)
{
case 0:
- ICMPClient receiver = ICMPClient.Client(icmp_packet.SourceIP.Hash);
+ ICMPClient receiver = ICMPClient.GetClient(icmp_packet.SourceIP.Hash);
if (receiver != null)
{
receiver.receiveData(icmp_packet);
diff --git a/source/Cosmos.System2/Network/IPv4/UDP/UDPPacket.cs b/source/Cosmos.System2/Network/IPv4/UDP/UDPPacket.cs
index 64a3ba3fd..a77dc2bbb 100644
--- a/source/Cosmos.System2/Network/IPv4/UDP/UDPPacket.cs
+++ b/source/Cosmos.System2/Network/IPv4/UDP/UDPPacket.cs
@@ -46,7 +46,7 @@ namespace Cosmos.System.Network.IPv4.UDP
return;
}
- UdpClient receiver = UdpClient.Client(udp_packet.DestinationPort);
+ UdpClient receiver = UdpClient.GetClient(udp_packet.DestinationPort);
if (receiver != null)
{
receiver.receiveData(udp_packet);
diff --git a/source/Cosmos.System2/Network/IPv4/UDP/UdpClient.cs b/source/Cosmos.System2/Network/IPv4/UDP/UdpClient.cs
index 6bd463d32..dd9e459cd 100644
--- a/source/Cosmos.System2/Network/IPv4/UDP/UdpClient.cs
+++ b/source/Cosmos.System2/Network/IPv4/UDP/UdpClient.cs
@@ -54,7 +54,7 @@ namespace Cosmos.System.Network.IPv4.UDP
///
/// Destination port.
/// UdpClient
- internal static UdpClient Client(ushort destPort)
+ internal static UdpClient GetClient(ushort destPort)
{
if (clients.ContainsKey((uint)destPort) == true)
{