Ejemplo n.º 1
0
        public static void Set(
            ref IPHeader header,
            IPv4Address sourceAddress,
            IPv4Address desAddress,
            Protocol protocol)
        {
            header._SourceAddress = sourceAddress;

            header._DesAddress = desAddress;


            header._IPHeader64_96._Protocol = (byte)protocol;

            header.CalculationHeaderChecksum();
        }
Ejemplo n.º 2
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.º 3
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));
        }
Ejemplo n.º 4
0
 public IPv4EndPoint(IPv4Address address, ushort port)
 {
     Address = address;
     Port    = port;
 }