// Public overriden methods // override public SecurityAssociation CheckForSecurityAssociation(ISender sender) { DtlsAssociation sa = null; _sender_to_sa.TryGetValue(sender, out sa); return(sa); }
// Protected methods /// <summary></summary> protected bool NoSuchSA(ISender return_path, int remote_id, bool start, out DtlsAssociation sa) { sa = new DtlsAssociation(return_path, _ch, PType, new Ssl(_ctx), start); sa.StateChangeEvent += SAStateChange; sa.RemoteID = remote_id; return(true); }
override protected void RemoveSA(SecurityAssociation sa) { DtlsAssociation dsa = sa as DtlsAssociation; if (dsa == null) { throw new Exception("SecurityAssociation is not a DtlsAssociation: " + sa); } _rwl.AcquireWriterLock(Timeout.Infinite); _sender_to_sa.Remove(dsa.Sender); _rwl.ReleaseWriterLock(); _it.Remove(dsa.LocalID); }
override public SecurityAssociation CreateSecurityAssociation(ISender sender) { DtlsAssociation sa = null; if (_sender_to_sa.TryGetValue(sender, out sa)) { return(sa); } if (NoSuchSA(sender, 0, true, out sa)) { DtlsAssociation tmpsa = sa; bool close = false; lock (_sender_to_sa) { if (_sender_to_sa.TryGetValue(sender, out sa)) { close = true; } else { _sender_to_sa.Add(sender, tmpsa); } } if (close) { tmpsa.Close("Duplicate"); } else { sa = tmpsa; _it.Add(sa); sa.Subscribe(this, null); sa.Handshake(); } } return(sa); }