public static void Set(ref IPHeader header, IPData ipData, ushort count)
        {
            header = new IPHeader();

            ushort allLength = GetAllLength(count);

            header._IPHeader0_32._Version_HeaderLength = 0b0100_0101;


            header._IPHeader0_32._AllLegnth = Meth.AsBigEndian(allLength);

            header._IPHeader64_96._Protocol = (byte)ipData.Protocol;

            header._IPHeader64_96._TTL = 128;

            header._SourceAddress = ipData.SourceAddress;

            header._DesAddress = ipData.DesAddress;

            header._IPHeader32_64._16Flag = Meth.GetCount();

            header._IPHeader32_64._Frag = 0x40;


            header.CalculationHeaderChecksum();
        }
        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();
        }
示例#3
0
        public static ushort CalculationHeaderChecksum(ref IPHeader header)
        {
            uint sum = AddStructSum(ref header);

            return(AsSum(sum));
        }