/// <summary> /// Initializes a new instance of the IcmpPacket class using the specified /// values. /// </summary> /// <param name="type">The ICMP type of the packet.</param> /// <param name="code">The subtype to the type of the packet.</param> /// <param name="data">The data to transfer as part of the ICMP /// packet.</param> /// <exception cref="ArgumentNullException">Thrown if the data parameter /// is null.</exception> public IcmpPacket(IcmpType type, IcmpCode code, byte[] data) { data.ThrowIfNull("data"); Type = type; Code = code; // Many ICMP packets include the IP header and the first 8 bytes of // an IP packet as data. Data = data; Checksum = ComputeChecksum(this); }
/// <summary> /// Private constructor used for deserialization. /// </summary> private IcmpPacket(IcmpType type, IcmpCode code, ushort checksum, byte[] data) { data.ThrowIfNull("data"); Type = type; Code = code; Checksum = checksum; Data = data; }