Esempio n. 1
0
        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));
        }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 public byte[] GetAddressBytes()
 {
     return(m_addr.GetAddressBytes());
 }