public void Reset() { lock (_sync) { _last_update = DateTime.UtcNow; _last_called_request_update = DateTime.UtcNow; _local_cert = new WriteOnceX509(); _remote_cert = new WriteOnceX509(); DHEWithCertificateAndCAsInHash = new WriteOnceIdempotent <MemBlock>(); DHEWithCertificateAndCAsOutHash = new WriteOnceIdempotent <MemBlock>(); DHEWithCertificateHash = new WriteOnceIdempotent <MemBlock>(); RDHE = new WriteOnceIdempotent <MemBlock>(); RemoteCookie = new WriteOnceIdempotent <MemBlock>(); _ldhe = null; _hash_verified = false; _called_enable = 0; _receiving = true; _sending = true; } UpdateState(States.Active, States.Updating); }
///<summary>This is called when we want to reset the state of the SA after ///an equivalent time of two timeouts has occurred.</summary> public bool Reset() { lock (_sync) { DateTime now = DateTime.UtcNow; // State is not reset if: // - It has been done within the past 120 seconds // - This is closed // - A packet has been received since the last SA check if ((_last_update != DateTime.MinValue && _last_update.AddSeconds(120) > now && State != States.Active) || _closed == 1 || (_receiving && State == States.Active)) { return(false); } _last_update = DateTime.UtcNow; _last_called_request_update = DateTime.UtcNow; _local_cert = new WriteOnceX509(); _remote_cert = new WriteOnceX509(); DHEWithCertificateAndCAsInHash = new WriteOnceIdempotent <MemBlock>(); DHEWithCertificateAndCAsOutHash = new WriteOnceIdempotent <MemBlock>(); DHEWithCertificateHash = new WriteOnceIdempotent <MemBlock>(); RDHE = new WriteOnceIdempotent <MemBlock>(); RemoteCookie = new WriteOnceIdempotent <MemBlock>(); _ldhe = null; _hash_verified = false; _called_enable = 0; _receiving = true; _sending = true; _just_created = true; } UpdateState(States.Active, States.Updating); return(true); }