Пример #1
0
 public ushort GetChecksum(ref byte[] Packet, int start, int end, ref System.Net.IPAddress SourceAddress, ref System.Net.IPAddress DestinationAddress)
 {
     byte[] PseudoPacket;
     PseudoPacket = new byte[12 + Packet.Length];
     System.Buffer.BlockCopy(SourceAddress.GetAddressBytes(), 0, PseudoPacket, 0, 4);
     System.Buffer.BlockCopy(DestinationAddress.GetAddressBytes(), 0, PseudoPacket, 4, 4);
     PseudoPacket[8] = 0;
     PseudoPacket[9] = 17;
     System.Buffer.BlockCopy(System.BitConverter.GetBytes(System.Net.IPAddress.HostToNetworkOrder((short)Packet.Length)), 0, PseudoPacket, 10, 2);
     System.Buffer.BlockCopy(Packet, 0, PseudoPacket, 12, Packet.Length);
     return(IPPacket.GetChecksum(ref PseudoPacket, 0, PseudoPacket.Length - 1));
 }