public static int GenerateSequenceNumber(IPv4 localHost, IPv4 remoteHost, ushort localPort, ushort remotePort) { // No MD5 for now so perform a weak hash long isn = DateTime.UtcNow.Ticks; snBase = snBase + 2287 * snBase; isn += snBase; int i = 0; foreach (byte b in localHost.GetAddressBytes()) { isn ^= ((long)b) << i; i += 8; } foreach (byte b in localHost.GetAddressBytes()) { isn ^= ((long)b) << i; i += 8; } isn += (localPort << 16) | remotePort; return((int)((isn >> 32) ^ isn)); }
public int Pack(byte[] !dstBuffer, ref int offset) { dstBuffer[offset++] = option; dstBuffer[offset++] = (byte)payloadLength; byte[] b = address.GetAddressBytes(); dstBuffer[offset++] = b[0]; dstBuffer[offset++] = b[1]; dstBuffer[offset++] = b[2]; dstBuffer[offset++] = b[3]; return(payloadLength + 2); }
public byte[] GetAddressBytes() { return(m_addr.GetAddressBytes()); }