示例#1
0
 /// <summary>
 /// True iff the two ARP layers have equal protocol type, operation and addresses.
 /// </summary>
 /// <param name="other">The ARP layer to compare the layer to.</param>
 /// <returns>True iff the two layers are equal.</returns>
 public bool Equals(ArpLayer other)
 {
     return(other != null &&
            ProtocolType == other.ProtocolType && Operation == other.Operation &&
            SenderHardwareAddress.SequenceEqual(other.SenderHardwareAddress) &&
            SenderProtocolAddress.SequenceEqual(other.SenderProtocolAddress) &&
            TargetHardwareAddress.SequenceEqual(other.TargetHardwareAddress) &&
            TargetProtocolAddress.SequenceEqual(other.TargetProtocolAddress));
 }
示例#2
0
 /// <summary>
 /// Returns a hash code for the layer.
 /// The hash code is a XOR of a combination of the protocol type and operation and the hash codes of the layer length and data link.
 /// </summary>
 public override int GetHashCode()
 {
     return(base.GetHashCode() ^
            BitSequence.Merge((ushort)ProtocolType, (ushort)Operation).GetHashCode() ^
            SenderHardwareAddress.BytesSequenceGetHashCode() ^
            SenderProtocolAddress.BytesSequenceGetHashCode() ^
            TargetHardwareAddress.BytesSequenceGetHashCode() ^
            TargetProtocolAddress.BytesSequenceGetHashCode());
 }
示例#3
0
 public override int GetHashCode()
 {
     unchecked
     {
         const int prime  = 13121;
         int       result = base.GetHashCode();
         result = prime * result + HardwareAddressLength;
         result = prime * result + HardwareType;
         result = prime * result + OpCode;
         result = prime * result + ProtocolAddressLength;
         result = prime * result + ProtocolType;
         result = prime * result + SenderHardwareAddress.GetArrayHashCode();
         result = prime * result + SenderProtocolAddress.GetArrayHashCode();
         result = prime * result + TargetHardwareAddress.GetArrayHashCode();
         result = prime * result + TargetProtocolAddress.GetArrayHashCode();
         return(result);
     }
 }