Exemple #1
0
        internal static void WriteHeader(byte[] buffer, int offset, ushort sourcePort, ushort destinationPort, uint sequenceNumber, uint acknowledgmentNumber, TcpControlBits controlBits, ushort window, ushort urgentPointer, TcpOptions options)
        {
            int num = 20 + options.BytesLength;

            TransportDatagram.WriteHeader(buffer, offset, sourcePort, destinationPort);
            ByteArrayExtensions.Write(buffer, offset + 4, sequenceNumber, Endianity.Big);
            ByteArrayExtensions.Write(buffer, offset + 8, acknowledgmentNumber, Endianity.Big);
            ByteArrayExtensions.Write(buffer, offset + 12, (ushort)((TcpControlBits)(num / 4 << 12) | controlBits), Endianity.Big);
            ByteArrayExtensions.Write(buffer, offset + 14, window, Endianity.Big);
            ByteArrayExtensions.Write(buffer, offset + 18, urgentPointer, Endianity.Big);
            options.Write(buffer, offset + 20);
        }
Exemple #2
0
        internal static void WriteHeader(byte[] buffer, int offset,
                                         ushort sourcePort, ushort destinationPort,
                                         uint sequenceNumber, uint acknowledgmentNumber,
                                         TcpControlBits controlBits, ushort window, ushort urgentPointer,
                                         TcpOptions options)
        {
            int headerLength = HeaderMinimumLength + options.BytesLength;

            WriteHeader(buffer, offset, sourcePort, destinationPort);
            buffer.Write(offset + Offset.SequenceNumber, sequenceNumber, Endianity.Big);
            buffer.Write(offset + Offset.AcknowledgmentNumber, acknowledgmentNumber, Endianity.Big);
            buffer.Write(offset + Offset.HeaderLengthAndFlags, (ushort)(((ushort)((headerLength / 4) << 12)) | (ushort)controlBits), Endianity.Big);
            buffer.Write(offset + Offset.Window, window, Endianity.Big);
            buffer.Write(offset + Offset.UrgentPointer, urgentPointer, Endianity.Big);
            options.Write(buffer, offset + Offset.Options);
        }