public static TreeViewItem ICMPTreeViewItem(IcmpDatagram icmpDatagram)
 {
     var item = new TreeViewItem()
     {
         DataContext = icmpDatagram,
         HeaderTemplate = (Helpers.GetResourceItem()["icmpItem"] as DataTemplate)
     };
     item.Items.Add(new TreeViewItem { Header = string.Format("Payload : {0}", icmpDatagram.Payload.ToHexadecimalString()) });
     return item;
 }
Пример #2
0
 /// <summary>
 /// Finalizes the layer data in the buffer.
 /// Used for the ICMP checksum.
 /// </summary>
 /// <param name="buffer">The buffer to finalize the layer in.</param>
 /// <param name="offset">The offset in the buffer the layer starts.</param>
 /// <param name="payloadLength">The length of the layer's payload (the number of bytes after the layer in the packet).</param>
 /// <param name="nextLayer">The layer that comes after this layer. null if this is the last layer.</param>
 public sealed override void Finalize(byte[] buffer, int offset, int payloadLength, ILayer nextLayer)
 {
     IcmpDatagram.WriteChecksum(buffer, offset, Length + payloadLength, Checksum);
 }
Пример #3
0
 protected sealed override void Write(byte[] buffer, int offset)
 {
     IcmpDatagram.WriteHeader(buffer, offset, MessageType, CodeValue, Variable);
     WritePayload(buffer, offset + IcmpDatagram.HeaderLength);
 }
Пример #4
0
 private ushort CalculateChecksum()
 {
     return(IcmpDatagram.CalculateChecksum(this.Buffer, this.StartOffset, this.Length));
 }
Пример #5
0
        internal static void WriteChecksum(byte[] buffer, int offset, int length, ushort?checksum)
        {
            ushort?nullable = checksum;
            ushort num      = !(nullable.HasValue ? new int?((int)nullable.GetValueOrDefault()) : new int?()).HasValue ? IcmpDatagram.CalculateChecksum(buffer, offset, length) : checksum.Value;

            ByteArrayExtensions.Write(buffer, offset + 2, num, Endianity.Big);
        }
Пример #6
0
 protected override sealed void Write(byte[] buffer, int offset)
 {
     IcmpDatagram.WriteHeader(buffer, offset, this.MessageType, this.CodeValue, this.Variable);
     this.WritePayload(buffer, offset + 8);
 }