Commit 9fc934bc authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent 34ce48d6
......@@ -12,6 +12,32 @@ namespace Packets
get { return _kind; }
}
public bool Equals(DataLink other)
{
return Kind == other.Kind;
}
public override bool Equals(object obj)
{
return (obj is DataLink &&
Equals((DataLink)obj));
}
public static bool operator ==(DataLink dataLink1, DataLink dataLink2)
{
return dataLink1.Equals(dataLink2);
}
public static bool operator !=(DataLink dataLink1, DataLink dataLink2)
{
return !(dataLink1 == dataLink2);
}
public override int GetHashCode()
{
return _kind.GetHashCode();
}
private readonly DataLinkKind _kind;
}
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ namespace Packets
System.Buffer.BlockCopy(_buffer, StartOffset, buffer, offset, Length);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
protected byte[] Buffer
{
get { return _buffer; }
......
......@@ -2,6 +2,7 @@ namespace Packets
{
public enum EthernetType : ushort
{
None,
IpV4 = 0x0800,
Arp = 0x0806,
Ieee802_1Q = 0x8100,
......
......@@ -23,6 +23,32 @@ namespace Packets
return new IpV4Address(result);
}
public bool Equals(IpV4Address other)
{
return ToUInt() == other.ToUInt();
}
public override bool Equals(object obj)
{
return (obj is IpV4Address &&
Equals((IpV4Address)obj));
}
public static bool operator ==(IpV4Address ipV4Address1, IpV4Address ipV4Address2)
{
return ipV4Address1.Equals(ipV4Address2);
}
public static bool operator !=(IpV4Address ipV4Address1, IpV4Address ipV4Address2)
{
return !(ipV4Address1 == ipV4Address2);
}
public override int GetHashCode()
{
return _value.GetHashCode();
}
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder(15);
......
using System;
using System.Globalization;
namespace Packets
{
......@@ -27,9 +28,41 @@ namespace Packets
_b6 = Convert.ToByte(hexes[5], 16);
}
public bool Equals(MacAddress other)
{
return _b1 == other._b1 &&
_b2 == other._b2 &&
_b3 == other._b3 &&
_b4 == other._b4 &&
_b5 == other._b5 &&
_b6 == other._b6;
}
public override bool Equals(object obj)
{
return (obj is MacAddress &&
Equals((MacAddress)obj));
}
public static bool operator ==(MacAddress macAddress1, MacAddress macAddress2)
{
return macAddress1.Equals(macAddress2);
}
public static bool operator !=(MacAddress macAddress1, MacAddress macAddress2)
{
return !(macAddress1 == macAddress2);
}
public override int GetHashCode()
{
return (_b1 + (_b2 << 8) + (_b3 << 16) + (_b4 << 24)).GetHashCode() ^
(_b5 + (_b6 << 8)).GetHashCode();
}
public override string ToString()
{
return string.Format("{0:X2}:{1:X2}:{2:X2}:{3:X2}:{4:X2}:{5:X2}", _b1, _b2, _b3, _b4, _b5, _b6);
return string.Format(CultureInfo.InvariantCulture, "{0:X2}:{1:X2}:{2:X2}:{3:X2}:{4:X2}:{5:X2}", _b1, _b2, _b3, _b4, _b5, _b6);
}
internal void Write(byte[] buffer, int offset)
......
......@@ -33,6 +33,7 @@ namespace Packets
get { return _dataLink; }
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public byte[] Buffer
{
get { return _data; }
......
......@@ -30,6 +30,7 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design#CA1028</CodeAnalysisRules>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
......
using System.Reflection;
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
......@@ -34,3 +35,5 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.*")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly:CLSCompliant(false)]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment