/// <summary>
        /// Connection to a remote DICOM application via TLS.
        /// </summary>
        /// <param name="assoc"></param>
        /// <param name="handler"></param>
        /// <returns></returns>
        public static DicomClient ConnectTLS(AssociationParameters assoc, IDicomClientHandler handler)
        {
            DicomClient client = new DicomClient(assoc, handler);

            client.ConnectTLS();
            return(client);
        }
        protected AssociationParameters(AssociationParameters parameters)
        {
            DisableNagle = NetworkSettings.Default.DisableNagle;
            RemoteMaxOperationsPerformed = 1;
            RemoteMaxOperationsInvoked   = 1;
            TotalDimseReceived           = 0;
            TotalBytesSent         = 0;
            TotalBytesRead         = 0;
            ApplicationContextName = parameters.ApplicationContextName;
            CalledAE               = parameters.CalledAE;
            CallingAE              = parameters.CallingAE;
            ImplementationClass    = parameters.ImplementationClass;
            ImplementationVersion  = parameters.ImplementationVersion;
            LocalEndPoint          = parameters.LocalEndPoint;
            LocalMaximumPduLength  = parameters.LocalMaximumPduLength;
            RemoteMaximumPduLength = parameters.RemoteMaximumPduLength;
            ReadTimeout            = parameters.ReadTimeout;
            ReceiveBufferSize      = parameters.ReceiveBufferSize;
            RemoteEndPoint         = parameters.RemoteEndPoint;
            SendBufferSize         = parameters.SendBufferSize;
            WriteTimeout           = parameters.WriteTimeout;
            ConnectTimeout         = parameters.ConnectTimeout;

            foreach (byte id in parameters._presContexts.Keys)
            {
                AddPresentationContext(id, parameters._presContexts[id].AbstractSyntax);

                foreach (TransferSyntax ts in parameters._presContexts[id].GetTransfers())
                {
                    AddTransferSyntax(id, ts);
                }

                SetRoleSelect(id, parameters._presContexts[id].GetRoleSelect());
            }
        }
Beispiel #3
0
        private static bool NegotiateAssociation(AssociationParameters cp, ServerAssociationParameters sp)
        {
            foreach (DicomPresContext clientContext in cp.GetPresentationContexts())
            {
                TransferSyntax selectedSyntax = null;
                foreach (DicomPresContext serverContext in sp.GetPresentationContexts())
                {
                    if (clientContext.AbstractSyntax.Uid.Equals(serverContext.AbstractSyntax.Uid))
                    {
                        foreach (TransferSyntax ts in serverContext.GetTransfers())
                        {
                            if (clientContext.HasTransfer(ts))
                            {
                                selectedSyntax = ts;
                                break;
                            }
                        }
                    }

                    if (selectedSyntax != null)
                    {
                        break;
                    }
                }

                if (selectedSyntax != null)
                {
                    clientContext.ClearTransfers();
                    clientContext.AddTransfer(selectedSyntax);
                    clientContext.SetResult(DicomPresContextResult.Accept);
                }
                else
                {
                    // No contexts accepted, set if abstract or transfer syntax reject
                    clientContext.SetResult(0 == sp.FindAbstractSyntax(clientContext.AbstractSyntax)
                                                ? DicomPresContextResult.RejectAbstractSyntaxNotSupported
                                                : DicomPresContextResult.RejectTransferSyntaxesNotSupported);
                }
            }
            bool anyValidContexts = false;

            foreach (DicomPresContext clientContext in cp.GetPresentationContexts())
            {
                if (clientContext.Result == DicomPresContextResult.Accept)
                {
                    anyValidContexts = true;
                    break;
                }
            }
            if (anyValidContexts == false)
            {
                return(false);
            }

            return(true);
        }
 private DicomClient(AssociationParameters assoc, IDicomClientHandler handler)
 {
     _remoteEndPoint = assoc.RemoteEndPoint;
     _socket         = null;
     _network        = null;
     _closedEvent    = null;
     _timeout        = 10;
     _handler        = handler;
     _assoc          = assoc;
 }
 protected override void OnReceiveAssociateAccept(AssociationParameters association)
 {
     try
     {
         _handler.OnReceiveAssociateAccept(this, association as ClientAssociationParameters);
     }
     catch (Exception e)
     {
         OnUserException(e, "Unexpected exception on OnReceiveAssociateAccept");
     }
 }
Beispiel #6
0
 public AAssociateAC(AssociationParameters assoc)
 {
     _assoc = assoc;
 }