示例#1
0
        /// <summary>
        ///     Write the contents of this packet to a stream
        /// </summary>
        /// <param name="stream">Destination stream</param>
        public void WriteToStream(Stream stream)
        {
            using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                bw.Write(this.OrganizationCode);
                bw.Write(ByteOrder.HostToNetworkOrder(this.ProtocolID));
            }

            this.Payload.WriteToStream(stream);
        }
示例#2
0
 /// <summary>
 ///     Write the contents of this packet to a stream
 /// </summary>
 /// <param name="stream">Destination stream</param>
 public void WriteToStream(Stream stream)
 {
     using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
     {
         bw.Write(ByteOrder.HostToNetworkOrder(this.SourcePort));
         bw.Write(ByteOrder.HostToNetworkOrder(this.DestPort));
         bw.Write(ByteOrder.HostToNetworkOrder(this.TotalLength));
         bw.Write(ByteOrder.HostToNetworkOrder(this.Checksum));
     }
     this.Payload.WriteToStream(stream);
 }
        /// <summary>
        ///     Write the contents of this packet to a stream
        /// </summary>
        /// <param name="stream">Destination stream</param>
        public void WriteToStream(Stream stream)
        {
            using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                bw.Write(this.Version);
                bw.Write(this.Type);
                bw.Write(ByteOrder.HostToNetworkOrder(this.BodyLength));
            }

            this.Payload.WriteToStream(stream);
        }
        /// <summary>
        ///     Write the contents of this packet to a stream
        /// </summary>
        /// <param name="stream">Destination stream</param>
        public void WriteToStream(Stream stream)
        {
            using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                bw.Write(this.DstMac, 0, 6);
                bw.Write(this.SrcMac, 0, 6);
                bw.Write(ByteOrder.HostToNetworkOrder(this.EtherType));
            }

            this.Payload.WriteToStream(stream);
        }
示例#5
0
        /// <summary>
        ///     Write the contents of this packet to a stream
        /// </summary>
        /// <param name="stream">Destination stream</param>
        public void WriteToStream(Stream stream)
        {
            using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                bw.Write(this.Type);
                bw.Write(this.Code);

                bw.Write(ByteOrder.HostToNetworkOrder(this.Checksum));
                bw.Write(ByteOrder.HostToNetworkOrder(this.ID));
                bw.Write(ByteOrder.HostToNetworkOrder(this.Sequence));

                bw.Write(this.Data);
            }
        }
示例#6
0
 /// <summary>
 ///     Write the contents of this packet to a stream
 /// </summary>
 /// <param name="stream">Destination stream</param>
 public void WriteToStream(Stream stream)
 {
     using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
     {
         bw.Write(ByteOrder.HostToNetworkOrder(this.SourcePort));
         bw.Write(ByteOrder.HostToNetworkOrder(this.DestPort));
         bw.Write(ByteOrder.HostToNetworkOrder(this.SeqNumber));
         bw.Write(ByteOrder.HostToNetworkOrder(this.AckNumber));
         bw.Write((byte)(this.DataOffset << 4 | this.Reserved));
         bw.Write((byte)this.Flags.Data);
         bw.Write(ByteOrder.HostToNetworkOrder(this.WindowSize));
         bw.Write(ByteOrder.HostToNetworkOrder(this.Checksum));
         bw.Write(ByteOrder.HostToNetworkOrder(this.UrgentPointer));
         bw.Write(this.OptionsAndPadding);
     }
     this.Payload.WriteToStream(stream);
 }
 /// <summary>
 ///     Write the contents of this packet to a stream
 /// </summary>
 /// <param name="stream">Destination stream</param>
 public void WriteToStream(Stream stream)
 {
     using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
     {
         bw.Write(this.KeyDescriptorType);
         bw.Write(ByteOrder.HostToNetworkOrder(this.KeyInformation));
         bw.Write(ByteOrder.HostToNetworkOrder(this.KeyLength));
         bw.Write(this.ReplayCounter);
         bw.Write(this.Nonce);
         bw.Write(this.IV);
         bw.Write(this.RSC);
         bw.Write(this.ID);
         bw.Write(this.MIC);
         bw.Write(ByteOrder.HostToNetworkOrder(this.DataLen));
         bw.Write(this.Data);
     }
 }
示例#8
0
 /// <summary>
 ///     Write the contents of this packet to a stream
 /// </summary>
 /// <param name="stream">Destination stream</param>
 public void WriteToStream(Stream stream)
 {
     using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
     {
         bw.Write((byte)((this.Version << 4) | this.HeaderLength));
         bw.Write(this.DifferentiatedServices);
         bw.Write(ByteOrder.HostToNetworkOrder(this.TotalLength));
         bw.Write(ByteOrder.HostToNetworkOrder(this.ID));
         bw.Write(ByteOrder.HostToNetworkOrder((UInt16)this.flagsAndFragOff.Data)); //Highly suspect
         bw.Write(this.TTL);
         bw.Write(this.Protocol);
         bw.Write(ByteOrder.HostToNetworkOrder(this.HeaderChecksum));
         bw.Write(this.SourceAddress.GetAddressBytes()); //Is the endianness proper?
         bw.Write(this.DestAddress.GetAddressBytes());   //Is the endianness proper?
         bw.Write(this.OptionsAndPadding);
     }
     this.Payload.WriteToStream(stream);
 }
示例#9
0
        /// <summary>
        ///     Write the contents of this packet to a stream
        /// </summary>
        /// <param name="stream">Destination stream</param>
        public void WriteToStream(Stream stream)
        {
            using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                bw.Write(ByteOrder.HostToNetworkOrder(this.HType));
                bw.Write(ByteOrder.HostToNetworkOrder(this.PType));
                bw.Write(this.HLen);
                bw.Write(this.PLen);

                bw.Write(ByteOrder.HostToNetworkOrder(this.Operation));

                bw.Write(this.SenderHardwareAddress);

                bw.Write(this.SenderProtocolAddress);

                bw.Write(this.TargetHardwareAddress);

                bw.Write(this.TargetProtocolAddress);
            }
        }
示例#10
0
        /// <summary>
        ///     Write the contents of this packet to a stream
        /// </summary>
        /// <param name="stream">Destination stream</param>
        public void WriteToStream(Stream stream)
        {
            using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                bw.Write((byte)this.FrameControlVersionTypeAndSubtype.Data);
                bw.Write((byte)this.FrameControlFlags.Data);
                bw.Write(this.DurationID);
                if (!this.ToDS)
                {
                    bw.Write(this.Destination);

                    if (!this.FromDS)
                    {
                        bw.Write(this.Source);
                        bw.Write(this.BSSID);
                    }
                    else
                    {
                        bw.Write(this.BSSID);
                        bw.Write(this.Source);
                    }
                    bw.Write(this.SequenceControl); //Was HTNO, wireshark disagrees
                }
                else
                {
                    if (!this.FromDS)
                    {
                        bw.Write(this.BSSID);
                        bw.Write(this.Source);
                        bw.Write(this.Destination);
                        bw.Write(this.SequenceControl); //Was HTNO, wireshark disagrees
                    }
                    else
                    {
                        bw.Write(this.Receiver);
                        bw.Write(this.Transmitter);
                        bw.Write(this.Destination);
                        bw.Write(this.SequenceControl); //Was HTNO, wireshark disagrees
                        bw.Write(this.Source);
                    }
                }

                if (this.FrameType == (int)FrameTypes.Data && this.SubType == (int)DataSubTypes.QoS)
                {
                    bw.Write(this.QosControl);
                }

                if (this.FrameType == (int)FrameTypes.Data && this.Protected)
                {
                    bw.Write(this.CCMP_WEP_Data);
                }
            }

            this.Payload.WriteToStream(stream);

            using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                if (this.IsWep)
                {
                    bw.Write(ByteOrder.HostToNetworkOrder(this.WEP_ICV));
                }

                if (this.FrameCheckSequence != 0)
                {
                    bw.Write(this.FrameCheckSequence);
                }
            }
        }