Ejemplo n.º 1
0
        public static void Set(
            ref TCPHeader header,
            IPv4Address sourceAddress,
            ushort sourcePort,
            IPv4Address desAddress,
            ushort desPort,
            Span <byte> headerAndData)
        {
            header._SourcePort = Meth.AsBigEndian(sourcePort);

            header._DesPort = Meth.AsBigEndian(desPort);

            var ph = new PseudoHeader(
                sourceAddress,
                desAddress,
                Protocol.TCP,
                (ushort)headerAndData.Length);

            header._Checksum = 0;

            header._Checksum = Meth.AsBigEndian(Meth.CalculationHeaderChecksum(ph, headerAndData));
        }
Ejemplo n.º 2
0
        public static void Set(
            ref TCPHeader header,
            IPv4Address sourceAddress,
            ushort sourcePort,
            IPv4Address desAddress,
            ushort desPort,
            TCPFlag tcpFlag,
            ushort windowSize,
            uint sequenceNumber,
            uint acknowledgmentNumber,
            Span <byte> headerAndData)
        {
            header = new TCPHeader();

            header._SourcePort = Meth.AsBigEndian(sourcePort);

            header._DesPort = Meth.AsBigEndian(desPort);

            header._SequenceNumber = Meth.AsBigEndian(sequenceNumber);

            header._AcknowledgmentNumber = Meth.AsBigEndian(acknowledgmentNumber);

            header._WindowSize = Meth.AsBigEndian(windowSize);

            header._TCPHeader12_14._Byte_0 = (byte)(5 << 4);

            header._TCPHeader12_14._Byte_1 = (byte)tcpFlag;

            var ph = new PseudoHeader(
                sourceAddress,
                desAddress,
                Protocol.TCP,
                (ushort)headerAndData.Length);

            header._Checksum = Meth.AsBigEndian(Meth.CalculationHeaderChecksum(ph, headerAndData));
        }