Mercurial > hg > orthanc
comparison Core/DicomNetworking/DicomAssociation.cpp @ 3896:210af28c4087 transcoding
merge
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 07 May 2020 11:32:15 +0200 |
parents | ea1d32861cfc |
children |
comparison
equal
deleted
inserted
replaced
3895:37cf1889667a | 3896:210af28c4087 |
---|---|
257 "No presentation context was proposed"); | 257 "No presentation context was proposed"); |
258 } | 258 } |
259 | 259 |
260 LOG(INFO) << "Opening a DICOM SCU connection from AET \"" | 260 LOG(INFO) << "Opening a DICOM SCU connection from AET \"" |
261 << parameters.GetLocalApplicationEntityTitle() | 261 << parameters.GetLocalApplicationEntityTitle() |
262 << "\" to AET \"" << parameters.GetRemoteApplicationEntityTitle() | 262 << "\" to AET \"" << parameters.GetRemoteModality().GetApplicationEntityTitle() |
263 << "\" on host " << parameters.GetRemoteHost() | 263 << "\" on host " << parameters.GetRemoteModality().GetHost() |
264 << ":" << parameters.GetRemotePort() | 264 << ":" << parameters.GetRemoteModality().GetPortNumber() |
265 << " (manufacturer: " << EnumerationToString(parameters.GetRemoteManufacturer()) << ")"; | 265 << " (manufacturer: " << EnumerationToString(parameters.GetRemoteModality().GetManufacturer()) << ")"; |
266 | 266 |
267 CheckConnecting(parameters, ASC_initializeNetwork(NET_REQUESTOR, 0, /*opt_acse_timeout*/ acseTimeout, &net_)); | 267 CheckConnecting(parameters, ASC_initializeNetwork(NET_REQUESTOR, 0, /*opt_acse_timeout*/ acseTimeout, &net_)); |
268 CheckConnecting(parameters, ASC_createAssociationParameters(¶ms_, /*opt_maxReceivePDULength*/ ASC_DEFAULTMAXPDU)); | 268 CheckConnecting(parameters, ASC_createAssociationParameters(¶ms_, /*opt_maxReceivePDULength*/ ASC_DEFAULTMAXPDU)); |
269 | 269 |
270 // Set this application's title and the called application's title in the params | 270 // Set this application's title and the called application's title in the params |
271 CheckConnecting(parameters, ASC_setAPTitles( | 271 CheckConnecting(parameters, ASC_setAPTitles( |
272 params_, parameters.GetLocalApplicationEntityTitle().c_str(), | 272 params_, parameters.GetLocalApplicationEntityTitle().c_str(), |
273 parameters.GetRemoteApplicationEntityTitle().c_str(), NULL)); | 273 parameters.GetRemoteModality().GetApplicationEntityTitle().c_str(), NULL)); |
274 | 274 |
275 // Set the network addresses of the local and remote entities | 275 // Set the network addresses of the local and remote entities |
276 char localHost[HOST_NAME_MAX]; | 276 char localHost[HOST_NAME_MAX]; |
277 gethostname(localHost, HOST_NAME_MAX - 1); | 277 gethostname(localHost, HOST_NAME_MAX - 1); |
278 | 278 |
282 _snprintf | 282 _snprintf |
283 #else | 283 #else |
284 snprintf | 284 snprintf |
285 #endif | 285 #endif |
286 (remoteHostAndPort, HOST_NAME_MAX - 1, "%s:%d", | 286 (remoteHostAndPort, HOST_NAME_MAX - 1, "%s:%d", |
287 parameters.GetRemoteHost().c_str(), parameters.GetRemotePort()); | 287 parameters.GetRemoteModality().GetHost().c_str(), |
288 parameters.GetRemoteModality().GetPortNumber()); | |
288 | 289 |
289 CheckConnecting(parameters, ASC_setPresentationAddresses(params_, localHost, remoteHostAndPort)); | 290 CheckConnecting(parameters, ASC_setPresentationAddresses(params_, localHost, remoteHostAndPort)); |
290 | 291 |
291 // Set various options | 292 // Set various options |
292 CheckConnecting(parameters, ASC_setTransportLayerType(params_, /*opt_secureConnection*/ false)); | 293 CheckConnecting(parameters, ASC_setTransportLayerType(params_, /*opt_secureConnection*/ false)); |
337 AddAccepted(pc->abstractSyntax, transferSyntax, pc->presentationContextID); | 338 AddAccepted(pc->abstractSyntax, transferSyntax, pc->presentationContextID); |
338 } | 339 } |
339 else | 340 else |
340 { | 341 { |
341 LOG(WARNING) << "Unknown transfer syntax received from AET \"" | 342 LOG(WARNING) << "Unknown transfer syntax received from AET \"" |
342 << parameters.GetRemoteApplicationEntityTitle() | 343 << parameters.GetRemoteModality().GetApplicationEntityTitle() |
343 << "\": " << pc->acceptedTransferSyntax; | 344 << "\": " << pc->acceptedTransferSyntax; |
344 } | 345 } |
345 } | 346 } |
346 | 347 |
347 pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l); | 348 pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l); |
350 | 351 |
351 if (accepted_.empty()) | 352 if (accepted_.empty()) |
352 { | 353 { |
353 throw OrthancException(ErrorCode_NoPresentationContext, | 354 throw OrthancException(ErrorCode_NoPresentationContext, |
354 "Unable to negotiate a presentation context with AET \"" + | 355 "Unable to negotiate a presentation context with AET \"" + |
355 parameters.GetRemoteApplicationEntityTitle() + "\""); | 356 parameters.GetRemoteModality().GetApplicationEntityTitle() + "\""); |
356 } | 357 } |
357 } | 358 } |
358 | 359 |
359 void DicomAssociation::Close() | 360 void DicomAssociation::Close() |
360 { | 361 { |
515 info += ")"; | 516 info += ")"; |
516 } | 517 } |
517 | 518 |
518 throw OrthancException(ErrorCode_NetworkProtocol, | 519 throw OrthancException(ErrorCode_NetworkProtocol, |
519 "DicomAssociation - " + command + " to AET \"" + | 520 "DicomAssociation - " + command + " to AET \"" + |
520 parameters.GetRemoteApplicationEntityTitle() + | 521 parameters.GetRemoteModality().GetApplicationEntityTitle() + |
521 "\": " + info); | 522 "\": " + info); |
522 } | 523 } |
523 } | 524 } |
524 | 525 |
525 | 526 |
602 /** | 603 /** |
603 * Send the "EVENT_REPORT_RQ" request | 604 * Send the "EVENT_REPORT_RQ" request |
604 **/ | 605 **/ |
605 | 606 |
606 LOG(INFO) << "Reporting modality \"" | 607 LOG(INFO) << "Reporting modality \"" |
607 << parameters.GetRemoteApplicationEntityTitle() | 608 << parameters.GetRemoteModality().GetApplicationEntityTitle() |
608 << "\" about storage commitment transaction: " << transactionUid | 609 << "\" about storage commitment transaction: " << transactionUid |
609 << " (" << successSopClassUids.size() << " successes, " | 610 << " (" << successSopClassUids.size() << " successes, " |
610 << failedSopClassUids.size() << " failures)"; | 611 << failedSopClassUids.size() << " failures)"; |
611 const DIC_US messageId = association.GetDcmtkAssociation().nextMsgID++; | 612 const DIC_US messageId = association.GetDcmtkAssociation().nextMsgID++; |
612 | 613 |
652 &association.GetDcmtkAssociation(), UID_StorageCommitmentPushModelSOPClass); | 653 &association.GetDcmtkAssociation(), UID_StorageCommitmentPushModelSOPClass); |
653 if (presID == 0) | 654 if (presID == 0) |
654 { | 655 { |
655 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " | 656 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " |
656 "Unable to send N-EVENT-REPORT request to AET: " + | 657 "Unable to send N-EVENT-REPORT request to AET: " + |
657 parameters.GetRemoteApplicationEntityTitle()); | 658 parameters.GetRemoteModality().GetApplicationEntityTitle()); |
658 } | 659 } |
659 | 660 |
660 if (!DIMSE_sendMessageUsingMemoryData( | 661 if (!DIMSE_sendMessageUsingMemoryData( |
661 &association.GetDcmtkAssociation(), presID, &message, NULL /* status detail */, | 662 &association.GetDcmtkAssociation(), presID, &message, NULL /* status detail */, |
662 &dataset, NULL /* callback */, NULL /* callback context */, | 663 &dataset, NULL /* callback */, NULL /* callback context */, |
680 NULL /* no statusDetail */).good() || | 681 NULL /* no statusDetail */).good() || |
681 message.CommandField != DIMSE_N_EVENT_REPORT_RSP) | 682 message.CommandField != DIMSE_N_EVENT_REPORT_RSP) |
682 { | 683 { |
683 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " | 684 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " |
684 "Unable to read N-EVENT-REPORT response from AET: " + | 685 "Unable to read N-EVENT-REPORT response from AET: " + |
685 parameters.GetRemoteApplicationEntityTitle()); | 686 parameters.GetRemoteModality().GetApplicationEntityTitle()); |
686 } | 687 } |
687 | 688 |
688 const T_DIMSE_N_EventReportRSP& content = message.msg.NEventReportRSP; | 689 const T_DIMSE_N_EventReportRSP& content = message.msg.NEventReportRSP; |
689 if (content.MessageIDBeingRespondedTo != messageId || | 690 if (content.MessageIDBeingRespondedTo != messageId || |
690 !(content.opts & O_NEVENTREPORT_AFFECTEDSOPCLASSUID) || | 691 !(content.opts & O_NEVENTREPORT_AFFECTEDSOPCLASSUID) || |
694 std::string(content.AffectedSOPInstanceUID) != UID_StorageCommitmentPushModelSOPInstance || | 695 std::string(content.AffectedSOPInstanceUID) != UID_StorageCommitmentPushModelSOPInstance || |
695 content.DataSetType != DIMSE_DATASET_NULL) | 696 content.DataSetType != DIMSE_DATASET_NULL) |
696 { | 697 { |
697 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " | 698 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " |
698 "Badly formatted N-EVENT-REPORT response from AET: " + | 699 "Badly formatted N-EVENT-REPORT response from AET: " + |
699 parameters.GetRemoteApplicationEntityTitle()); | 700 parameters.GetRemoteModality().GetApplicationEntityTitle()); |
700 } | 701 } |
701 | 702 |
702 if (content.DimseStatus != 0 /* success */) | 703 if (content.DimseStatus != 0 /* success */) |
703 { | 704 { |
704 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " | 705 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " |
705 "The request cannot be handled by remote AET: " + | 706 "The request cannot be handled by remote AET: " + |
706 parameters.GetRemoteApplicationEntityTitle()); | 707 parameters.GetRemoteModality().GetApplicationEntityTitle()); |
707 } | 708 } |
708 } | 709 } |
709 | 710 |
710 association.Close(); | 711 association.Close(); |
711 } | 712 } |
765 /** | 766 /** |
766 * Send the "N_ACTION_RQ" request | 767 * Send the "N_ACTION_RQ" request |
767 **/ | 768 **/ |
768 | 769 |
769 LOG(INFO) << "Request to modality \"" | 770 LOG(INFO) << "Request to modality \"" |
770 << parameters.GetRemoteApplicationEntityTitle() | 771 << parameters.GetRemoteModality().GetApplicationEntityTitle() |
771 << "\" about storage commitment for " << sopClassUids.size() | 772 << "\" about storage commitment for " << sopClassUids.size() |
772 << " instances, with transaction UID: " << transactionUid; | 773 << " instances, with transaction UID: " << transactionUid; |
773 const DIC_US messageId = association.GetDcmtkAssociation().nextMsgID++; | 774 const DIC_US messageId = association.GetDcmtkAssociation().nextMsgID++; |
774 | 775 |
775 { | 776 { |
799 &association.GetDcmtkAssociation(), UID_StorageCommitmentPushModelSOPClass); | 800 &association.GetDcmtkAssociation(), UID_StorageCommitmentPushModelSOPClass); |
800 if (presID == 0) | 801 if (presID == 0) |
801 { | 802 { |
802 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " | 803 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " |
803 "Unable to send N-ACTION request to AET: " + | 804 "Unable to send N-ACTION request to AET: " + |
804 parameters.GetRemoteApplicationEntityTitle()); | 805 parameters.GetRemoteModality().GetApplicationEntityTitle()); |
805 } | 806 } |
806 | 807 |
807 if (!DIMSE_sendMessageUsingMemoryData( | 808 if (!DIMSE_sendMessageUsingMemoryData( |
808 &association.GetDcmtkAssociation(), presID, &message, NULL /* status detail */, | 809 &association.GetDcmtkAssociation(), presID, &message, NULL /* status detail */, |
809 &dataset, NULL /* callback */, NULL /* callback context */, | 810 &dataset, NULL /* callback */, NULL /* callback context */, |
827 NULL /* no statusDetail */).good() || | 828 NULL /* no statusDetail */).good() || |
828 message.CommandField != DIMSE_N_ACTION_RSP) | 829 message.CommandField != DIMSE_N_ACTION_RSP) |
829 { | 830 { |
830 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " | 831 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " |
831 "Unable to read N-ACTION response from AET: " + | 832 "Unable to read N-ACTION response from AET: " + |
832 parameters.GetRemoteApplicationEntityTitle()); | 833 parameters.GetRemoteModality().GetApplicationEntityTitle()); |
833 } | 834 } |
834 | 835 |
835 const T_DIMSE_N_ActionRSP& content = message.msg.NActionRSP; | 836 const T_DIMSE_N_ActionRSP& content = message.msg.NActionRSP; |
836 if (content.MessageIDBeingRespondedTo != messageId || | 837 if (content.MessageIDBeingRespondedTo != messageId || |
837 !(content.opts & O_NACTION_AFFECTEDSOPCLASSUID) || | 838 !(content.opts & O_NACTION_AFFECTEDSOPCLASSUID) || |
841 std::string(content.AffectedSOPInstanceUID) != UID_StorageCommitmentPushModelSOPInstance || | 842 std::string(content.AffectedSOPInstanceUID) != UID_StorageCommitmentPushModelSOPInstance || |
842 content.DataSetType != DIMSE_DATASET_NULL) | 843 content.DataSetType != DIMSE_DATASET_NULL) |
843 { | 844 { |
844 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " | 845 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " |
845 "Badly formatted N-ACTION response from AET: " + | 846 "Badly formatted N-ACTION response from AET: " + |
846 parameters.GetRemoteApplicationEntityTitle()); | 847 parameters.GetRemoteModality().GetApplicationEntityTitle()); |
847 } | 848 } |
848 | 849 |
849 if (content.DimseStatus != 0 /* success */) | 850 if (content.DimseStatus != 0 /* success */) |
850 { | 851 { |
851 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " | 852 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " |
852 "The request cannot be handled by remote AET: " + | 853 "The request cannot be handled by remote AET: " + |
853 parameters.GetRemoteApplicationEntityTitle()); | 854 parameters.GetRemoteModality().GetApplicationEntityTitle()); |
854 } | 855 } |
855 } | 856 } |
856 | 857 |
857 association.Close(); | 858 association.Close(); |
858 } | 859 } |