annotate Core/DicomNetworking/Internals/CommandDispatcher.cpp @ 3349:ef18ea68a362

merge
author Alain Mazy <alain@mazy.be>
date Thu, 18 Apr 2019 15:52:56 +0200
parents 6e42d676401c
children 1bcc35e4615a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1806
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1164
diff changeset
4 * Department, University Hospital of Liege, Belgium
3060
4e43e67f8ecf preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2786
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
11 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
12 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
13 * program give permission to link the code of its release with the
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
16 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
20 * you do not wish to do so, delete this exception statement from your
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
21 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
22 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
766
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
34
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
35
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
36 /*=========================================================================
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
37
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
38 This file is based on portions of the following project:
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
39
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
40 Program: DCMTK 3.6.0
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
41 Module: http://dicom.offis.de/dcmtk.php.en
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
42
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
43 Copyright (C) 1994-2011, OFFIS e.V.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
44 All rights reserved.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
45
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
46 This software and supporting documentation were developed by
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
47
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
48 OFFIS e.V.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
49 R&D Division Health
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
50 Escherweg 2
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
51 26121 Oldenburg, Germany
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
52
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
53 Redistribution and use in source and binary forms, with or without
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
54 modification, are permitted provided that the following conditions
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
55 are met:
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
56
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
57 - Redistributions of source code must retain the above copyright
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
58 notice, this list of conditions and the following disclaimer.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
59
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
60 - Redistributions in binary form must reproduce the above copyright
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
61 notice, this list of conditions and the following disclaimer in the
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
62 documentation and/or other materials provided with the distribution.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
63
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
64 - Neither the name of OFFIS nor the names of its contributors may be
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
65 used to endorse or promote products derived from this software
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
66 without specific prior written permission.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
67
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
68 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
69 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
70 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
71 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
72 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
73 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
74 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
75 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
76 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
77 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
78 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
79
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
80 =========================================================================*/
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
81
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
82
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
83 #include "../../PrecompiledHeaders.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 #include "CommandDispatcher.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
86 #if !defined(DCMTK_VERSION_NUMBER)
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
87 # error The macro DCMTK_VERSION_NUMBER must be defined
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
88 #endif
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
89
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 #include "FindScp.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 #include "StoreScp.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 #include "MoveScp.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
93 #include "../../Toolbox.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
94 #include "../../Logging.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 #include <dcmtk/dcmnet/dcasccfg.h> /* for class DcmAssociationConfiguration */
3343
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
97 #include <dcmtk/dcmdata/dcuid.h> /* for variable dcmAllStorageSOPClassUIDs */
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
98
101
428784e59dcd trying to use log4cplus
jodogne
parents: 62
diff changeset
99 #include <boost/lexical_cast.hpp>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 static OFBool opt_rejectWithoutImplementationUID = OFFalse;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
503
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
104
1806
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
105 static DUL_PRESENTATIONCONTEXT *
503
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
106 findPresentationContextID(LST_HEAD * head,
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
107 T_ASC_PresentationContextID presentationContextID)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
108 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
109 DUL_PRESENTATIONCONTEXT *pc;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
110 LST_HEAD **l;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
111 OFBool found = OFFalse;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
112
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
113 if (head == NULL)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
114 return NULL;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
115
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
116 l = &head;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
117 if (*l == NULL)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
118 return NULL;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
119
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
120 pc = OFstatic_cast(DUL_PRESENTATIONCONTEXT *, LST_Head(l));
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
121 (void)LST_Position(l, OFstatic_cast(LST_NODE *, pc));
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
122
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
123 while (pc && !found) {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
124 if (pc->presentationContextID == presentationContextID) {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
125 found = OFTrue;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
126 } else {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
127 pc = OFstatic_cast(DUL_PRESENTATIONCONTEXT *, LST_Next(l));
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
128 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
129 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
130 return pc;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
131 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
132
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
133
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
134 /** accept all presenstation contexts for unknown SOP classes,
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
135 * i.e. UIDs appearing in the list of abstract syntaxes
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
136 * where no corresponding name is defined in the UID dictionary.
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
137 * @param params pointer to association parameters structure
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
138 * @param transferSyntax transfer syntax to accept
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
139 * @param acceptedRole SCU/SCP role to accept
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
140 */
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
141 static OFCondition acceptUnknownContextsWithTransferSyntax(
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
142 T_ASC_Parameters * params,
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
143 const char* transferSyntax,
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
144 T_ASC_SC_ROLE acceptedRole)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
145 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
146 OFCondition cond = EC_Normal;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
147 int n, i, k;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
148 DUL_PRESENTATIONCONTEXT *dpc;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
149 T_ASC_PresentationContext pc;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
150 OFBool accepted = OFFalse;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
151 OFBool abstractOK = OFFalse;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
152
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
153 n = ASC_countPresentationContexts(params);
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
154 for (i = 0; i < n; i++)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
155 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
156 cond = ASC_getPresentationContext(params, i, &pc);
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
157 if (cond.bad()) return cond;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
158 abstractOK = OFFalse;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
159 accepted = OFFalse;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
160
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
161 if (dcmFindNameOfUID(pc.abstractSyntax) == NULL)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
162 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
163 abstractOK = OFTrue;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
164
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
165 /* check the transfer syntax */
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
166 for (k = 0; (k < OFstatic_cast(int, pc.transferSyntaxCount)) && !accepted; k++)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
167 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
168 if (strcmp(pc.proposedTransferSyntaxes[k], transferSyntax) == 0)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
169 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
170 accepted = OFTrue;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
171 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
172 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
173 }
3343
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
174
503
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
175 if (accepted)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
176 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
177 cond = ASC_acceptPresentationContext(
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
178 params, pc.presentationContextID,
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
179 transferSyntax, acceptedRole);
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
180 if (cond.bad()) return cond;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
181 } else {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
182 T_ASC_P_ResultReason reason;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
183
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
184 /* do not refuse if already accepted */
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
185 dpc = findPresentationContextID(params->DULparams.acceptedPresentationContext,
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
186 pc.presentationContextID);
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
187 if ((dpc == NULL) || ((dpc != NULL) && (dpc->result != ASC_P_ACCEPTANCE)))
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
188 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
189
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
190 if (abstractOK) {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
191 reason = ASC_P_TRANSFERSYNTAXESNOTSUPPORTED;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
192 } else {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
193 reason = ASC_P_ABSTRACTSYNTAXNOTSUPPORTED;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
194 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
195 /*
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
196 * If previously this presentation context was refused
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
197 * because of bad transfer syntax let it stay that way.
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
198 */
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
199 if ((dpc != NULL) && (dpc->result == ASC_P_TRANSFERSYNTAXESNOTSUPPORTED))
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
200 reason = ASC_P_TRANSFERSYNTAXESNOTSUPPORTED;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
201
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
202 cond = ASC_refusePresentationContext(params, pc.presentationContextID, reason);
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
203 if (cond.bad()) return cond;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
204 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
205 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
206 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
207 return EC_Normal;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
208 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
209
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
210
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
211 /** accept all presenstation contexts for unknown SOP classes,
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
212 * i.e. UIDs appearing in the list of abstract syntaxes
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
213 * where no corresponding name is defined in the UID dictionary.
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
214 * This method is passed a list of "preferred" transfer syntaxes.
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
215 * @param params pointer to association parameters structure
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
216 * @param transferSyntax transfer syntax to accept
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
217 * @param acceptedRole SCU/SCP role to accept
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
218 */
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
219 static OFCondition acceptUnknownContextsWithPreferredTransferSyntaxes(
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
220 T_ASC_Parameters * params,
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
221 const char* transferSyntaxes[], int transferSyntaxCount,
3343
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
222 T_ASC_SC_ROLE acceptedRole)
503
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
223 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
224 OFCondition cond = EC_Normal;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
225 /*
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
226 ** Accept in the order "least wanted" to "most wanted" transfer
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
227 ** syntax. Accepting a transfer syntax will override previously
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
228 ** accepted transfer syntaxes.
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
229 */
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
230 for (int i = transferSyntaxCount - 1; i >= 0; i--)
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
231 {
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
232 cond = acceptUnknownContextsWithTransferSyntax(params, transferSyntaxes[i], acceptedRole);
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
233 if (cond.bad()) return cond;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
234 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
235 return cond;
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
236 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
237
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
238
1073
01414536c930 complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
239
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
240 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 namespace Internals
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 OFCondition AssociationCleanup(T_ASC_Association *assoc)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 OFCondition cond = ASC_dropSCPAssociation(assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
249 LOG(FATAL) << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 return cond;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 cond = ASC_destroyAssociation(&assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
256 LOG(FATAL) << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 return cond;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 return cond;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 CommandDispatcher* AcceptAssociation(const DicomServer& server, T_ASC_Network *net)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 DcmAssociationConfiguration asccfg;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 char buf[BUFSIZ];
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 T_ASC_Association *assoc;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 OFCondition cond;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 OFString sprofile;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 OFString temp_str;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 std::vector<const char*> knownAbstractSyntaxes;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 // For C-STORE
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 if (server.HasStoreRequestHandlerFactory())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 knownAbstractSyntaxes.push_back(UID_VerificationSOPClass);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 // For C-FIND
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 if (server.HasFindRequestHandlerFactory())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 knownAbstractSyntaxes.push_back(UID_FINDPatientRootQueryRetrieveInformationModel);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 knownAbstractSyntaxes.push_back(UID_FINDStudyRootQueryRetrieveInformationModel);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
289 if (server.HasWorklistRequestHandlerFactory())
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
290 {
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
291 knownAbstractSyntaxes.push_back(UID_FINDModalityWorklistInformationModel);
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
292 }
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
293
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 // For C-MOVE
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 if (server.HasMoveRequestHandlerFactory())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 knownAbstractSyntaxes.push_back(UID_MOVEStudyRootQueryRetrieveInformationModel);
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 661
diff changeset
298 knownAbstractSyntaxes.push_back(UID_MOVEPatientRootQueryRetrieveInformationModel);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 cond = ASC_receiveAssociation(net, &assoc,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 /*opt_maxPDU*/ ASC_DEFAULTMAXPDU,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 NULL, NULL,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 /*opt_secureConnection*/ OFFalse,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 DUL_NOBLOCK, 1);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 if (cond == DUL_NOASSOCIATIONREQUEST)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 // Timeout
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 AssociationCleanup(assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 return NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 // if some kind of error occured, take care of it
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
317 LOG(ERROR) << "Receiving Association failed: " << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 // no matter what kind of error occurred, we need to do a cleanup
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 AssociationCleanup(assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 return NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
323 // Retrieve the AET and the IP address of the remote modality
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
324 std::string remoteAet;
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
325 std::string remoteIp;
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
326 std::string calledAet;
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
327
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
328 {
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
329 DIC_AE remoteAet_C;
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
330 DIC_AE calledAet_C;
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
331 DIC_AE remoteIp_C;
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
332 DIC_AE calledIP_C;
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
333
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
334 if (
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
335 #if DCMTK_VERSION_NUMBER >= 364
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
336 ASC_getAPTitles(assoc->params, remoteAet_C, sizeof(remoteAet_C), calledAet_C, sizeof(calledAet_C), NULL, 0).bad() ||
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
337 ASC_getPresentationAddresses(assoc->params, remoteIp_C, sizeof(remoteIp_C), calledIP_C, sizeof(calledIP_C)).bad()
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
338 #else
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
339 ASC_getAPTitles(assoc->params, remoteAet_C, calledAet_C, NULL).bad() ||
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
340 ASC_getPresentationAddresses(assoc->params, remoteIp_C, calledIP_C).bad()
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
341 #endif
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
342 )
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
343 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
344 T_ASC_RejectParameters rej =
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
345 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
346 ASC_RESULT_REJECTEDPERMANENT,
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
347 ASC_SOURCE_SERVICEUSER,
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
348 ASC_REASON_SU_NOREASON
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
349 };
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
350 ASC_rejectAssociation(assoc, &rej);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
351 AssociationCleanup(assoc);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
352 return NULL;
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
353 }
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
354
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
355 remoteIp = std::string(/*OFSTRING_GUARD*/(remoteIp_C));
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
356 remoteAet = std::string(/*OFSTRING_GUARD*/(remoteAet_C));
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
357 calledAet = (/*OFSTRING_GUARD*/(calledAet_C));
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
358 }
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
359
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
360 LOG(INFO) << "Association Received from AET " << remoteAet
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
361 << " on IP " << remoteIp;
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
362
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
661
d233b5090105 accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
364 std::vector<const char*> transferSyntaxes;
d233b5090105 accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
365
d233b5090105 accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
366 // This is the list of the transfer syntaxes that were supported up to Orthanc 0.7.1
d233b5090105 accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
367 transferSyntaxes.push_back(UID_LittleEndianExplicitTransferSyntax);
d233b5090105 accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
368 transferSyntaxes.push_back(UID_BigEndianExplicitTransferSyntax);
d233b5090105 accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
369 transferSyntaxes.push_back(UID_LittleEndianImplicitTransferSyntax);
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 661
diff changeset
370
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 661
diff changeset
371 // New transfer syntaxes supported since Orthanc 0.7.2
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
372 if (!server.HasApplicationEntityFilter() ||
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
373 server.GetApplicationEntityFilter().IsAllowedTransferSyntax(remoteIp, remoteAet, calledAet, TransferSyntax_Deflated))
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
374 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
375 transferSyntaxes.push_back(UID_DeflatedExplicitVRLittleEndianTransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
376 }
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
377
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
378 if (!server.HasApplicationEntityFilter() ||
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
379 server.GetApplicationEntityFilter().IsAllowedTransferSyntax(remoteIp, remoteAet, calledAet, TransferSyntax_Jpeg))
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
380 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
381 transferSyntaxes.push_back(UID_JPEGProcess1TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
382 transferSyntaxes.push_back(UID_JPEGProcess2_4TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
383 transferSyntaxes.push_back(UID_JPEGProcess3_5TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
384 transferSyntaxes.push_back(UID_JPEGProcess6_8TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
385 transferSyntaxes.push_back(UID_JPEGProcess7_9TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
386 transferSyntaxes.push_back(UID_JPEGProcess10_12TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
387 transferSyntaxes.push_back(UID_JPEGProcess11_13TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
388 transferSyntaxes.push_back(UID_JPEGProcess14TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
389 transferSyntaxes.push_back(UID_JPEGProcess15TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
390 transferSyntaxes.push_back(UID_JPEGProcess16_18TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
391 transferSyntaxes.push_back(UID_JPEGProcess17_19TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
392 transferSyntaxes.push_back(UID_JPEGProcess20_22TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
393 transferSyntaxes.push_back(UID_JPEGProcess21_23TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
394 transferSyntaxes.push_back(UID_JPEGProcess24_26TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
395 transferSyntaxes.push_back(UID_JPEGProcess25_27TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
396 transferSyntaxes.push_back(UID_JPEGProcess28TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
397 transferSyntaxes.push_back(UID_JPEGProcess29TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
398 transferSyntaxes.push_back(UID_JPEGProcess14SV1TransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
399 }
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
400
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
401 if (!server.HasApplicationEntityFilter() ||
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
402 server.GetApplicationEntityFilter().IsAllowedTransferSyntax(remoteIp, remoteAet, calledAet, TransferSyntax_Jpeg2000))
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
403 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
404 transferSyntaxes.push_back(UID_JPEG2000LosslessOnlyTransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
405 transferSyntaxes.push_back(UID_JPEG2000TransferSyntax);
2786
e7a10626645f Fix incoming DICOM C-Store filtering for JPEG-LS transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
406 transferSyntaxes.push_back(UID_JPEG2000LosslessOnlyTransferSyntax);
e7a10626645f Fix incoming DICOM C-Store filtering for JPEG-LS transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
407 transferSyntaxes.push_back(UID_JPEG2000TransferSyntax);
e7a10626645f Fix incoming DICOM C-Store filtering for JPEG-LS transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
408 transferSyntaxes.push_back(UID_JPEG2000Part2MulticomponentImageCompressionLosslessOnlyTransferSyntax);
e7a10626645f Fix incoming DICOM C-Store filtering for JPEG-LS transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
409 transferSyntaxes.push_back(UID_JPEG2000Part2MulticomponentImageCompressionTransferSyntax);
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
410 }
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
411
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
412 if (!server.HasApplicationEntityFilter() ||
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
413 server.GetApplicationEntityFilter().IsAllowedTransferSyntax(remoteIp, remoteAet, calledAet, TransferSyntax_JpegLossless))
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
414 {
2786
e7a10626645f Fix incoming DICOM C-Store filtering for JPEG-LS transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
415 transferSyntaxes.push_back(UID_JPEGLSLosslessTransferSyntax);
e7a10626645f Fix incoming DICOM C-Store filtering for JPEG-LS transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
416 transferSyntaxes.push_back(UID_JPEGLSLossyTransferSyntax);
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
417 }
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
418
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
419 if (!server.HasApplicationEntityFilter() ||
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
420 server.GetApplicationEntityFilter().IsAllowedTransferSyntax(remoteIp, remoteAet, calledAet, TransferSyntax_Jpip))
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
421 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
422 transferSyntaxes.push_back(UID_JPIPReferencedTransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
423 transferSyntaxes.push_back(UID_JPIPReferencedDeflateTransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
424 }
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
425
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
426 if (!server.HasApplicationEntityFilter() ||
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
427 server.GetApplicationEntityFilter().IsAllowedTransferSyntax(remoteIp, remoteAet, calledAet, TransferSyntax_Mpeg2))
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
428 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
429 transferSyntaxes.push_back(UID_MPEG2MainProfileAtMainLevelTransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
430 transferSyntaxes.push_back(UID_MPEG2MainProfileAtHighLevelTransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
431 }
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
432
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
433 if (!server.HasApplicationEntityFilter() ||
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
434 server.GetApplicationEntityFilter().IsAllowedTransferSyntax(remoteIp, remoteAet, calledAet, TransferSyntax_Rle))
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
435 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
436 transferSyntaxes.push_back(UID_RLELosslessTransferSyntax);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
437 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 /* accept the Verification SOP Class if presented */
3343
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
440 cond = ASC_acceptContextsWithPreferredTransferSyntaxes(
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
441 assoc->params,
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
442 &knownAbstractSyntaxes[0], knownAbstractSyntaxes.size(),
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
443 &transferSyntaxes[0], transferSyntaxes.size());
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
446 LOG(INFO) << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 AssociationCleanup(assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 return NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450
3343
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
451 /* the array of Storage SOP Class UIDs that is defined within "dcmdata/libsrc/dcuid.cc" */
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
452 size_t count = 0;
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
453 while (dcmAllStorageSOPClassUIDs[count] != NULL)
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
454 {
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
455 count++;
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
456 }
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
457
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
458 #if DCMTK_VERSION_NUMBER >= 362
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
459 // The global variable "numberOfDcmAllStorageSOPClassUIDs" is
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
460 // only published if DCMTK >= 3.6.2:
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
461 // https://bitbucket.org/sjodogne/orthanc/issues/137
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
462 assert(count == numberOfDcmAllStorageSOPClassUIDs);
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
463 #endif
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
464
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
465 cond = ASC_acceptContextsWithPreferredTransferSyntaxes(
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
466 assoc->params,
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
467 dcmAllStorageSOPClassUIDs, count,
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
468 &transferSyntaxes[0], transferSyntaxes.size());
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
471 LOG(INFO) << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 AssociationCleanup(assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 return NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475
1806
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
476 if (!server.HasApplicationEntityFilter() ||
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
477 server.GetApplicationEntityFilter().IsUnknownSopClassAccepted(remoteIp, remoteAet, calledAet))
503
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
478 {
1806
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
479 /*
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
480 * Promiscous mode is enabled: Accept everything not known not
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
481 * to be a storage SOP class.
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
482 **/
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
483 cond = acceptUnknownContextsWithPreferredTransferSyntaxes(
3343
6e42d676401c Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3249
diff changeset
484 assoc->params, &transferSyntaxes[0], transferSyntaxes.size(), ASC_SC_ROLE_DEFAULT);
1806
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
485 if (cond.bad())
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
486 {
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
487 LOG(INFO) << cond.text();
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
488 AssociationCleanup(assoc);
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
489 return NULL;
cd213ebcaefd UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
490 }
503
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
491 }
273e7ad98ea9 promiscuous mode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
492
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 /* set our app title */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 ASC_setAPTitles(assoc->params, NULL, NULL, server.GetApplicationEntityTitle().c_str());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 /* acknowledge or reject this association */
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
497 #if DCMTK_VERSION_NUMBER >= 364
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
498 cond = ASC_getApplicationContextName(assoc->params, buf, sizeof(buf));
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
499 #else
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 cond = ASC_getApplicationContextName(assoc->params, buf);
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
501 #endif
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
502
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 if ((cond.bad()) || strcmp(buf, UID_StandardApplicationContext) != 0)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 /* reject: the application context name is not supported */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 T_ASC_RejectParameters rej =
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 ASC_RESULT_REJECTEDPERMANENT,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 ASC_SOURCE_SERVICEUSER,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510 ASC_REASON_SU_APPCONTEXTNAMENOTSUPPORTED
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
513 LOG(INFO) << "Association Rejected: Bad Application Context Name: " << buf;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 cond = ASC_rejectAssociation(assoc, &rej);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
517 LOG(INFO) << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 AssociationCleanup(assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 return NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 }
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
522
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 /* check the AETs */
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
524 if (!server.IsMyAETitle(calledAet))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 {
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
526 LOG(WARNING) << "Rejected association, because of a bad called AET in the request (" << calledAet << ")";
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
527 T_ASC_RejectParameters rej =
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
528 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
529 ASC_RESULT_REJECTEDPERMANENT,
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
530 ASC_SOURCE_SERVICEUSER,
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
531 ASC_REASON_SU_CALLEDAETITLENOTRECOGNIZED
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
532 };
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
533 ASC_rejectAssociation(assoc, &rej);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
534 AssociationCleanup(assoc);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
535 return NULL;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
538 if (server.HasApplicationEntityFilter() &&
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
539 !server.GetApplicationEntityFilter().IsAllowedConnection(remoteIp, remoteAet, calledAet))
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
540 {
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
541 LOG(WARNING) << "Rejected association for remote AET " << remoteAet << " on IP " << remoteIp;
1163
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
542 T_ASC_RejectParameters rej =
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
543 {
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
544 ASC_RESULT_REJECTEDPERMANENT,
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
545 ASC_SOURCE_SERVICEUSER,
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
546 ASC_REASON_SU_CALLINGAETITLENOTRECOGNIZED
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
547 };
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
548 ASC_rejectAssociation(assoc, &rej);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
549 AssociationCleanup(assoc);
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
550 return NULL;
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
551 }
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
552
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
553 if (opt_rejectWithoutImplementationUID &&
3db41779d8f9 abstraction to allow/prevent transfer syntaxes on AET basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1085
diff changeset
554 strlen(assoc->params->theirImplementationClassUID) == 0)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 /* reject: the no implementation Class UID provided */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 T_ASC_RejectParameters rej =
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 ASC_RESULT_REJECTEDPERMANENT,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 ASC_SOURCE_SERVICEUSER,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 ASC_REASON_SU_NOREASON
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
564 LOG(INFO) << "Association Rejected: No Implementation Class UID provided";
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 cond = ASC_rejectAssociation(assoc, &rej);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
568 LOG(INFO) << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 AssociationCleanup(assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 return NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 cond = ASC_acknowledgeAssociation(assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
578 LOG(ERROR) << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 AssociationCleanup(assoc);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 return NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 }
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
582 LOG(INFO) << "Association Acknowledged (Max Send PDV: " << assoc->sendPDVLength << ")";
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 if (ASC_countAcceptedPresentationContexts(assoc->params) == 0)
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
584 LOG(INFO) << " (but no valid presentation contexts)";
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
587 IApplicationEntityFilter* filter = server.HasApplicationEntityFilter() ? &server.GetApplicationEntityFilter() : NULL;
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
588 return new CommandDispatcher(server, assoc, remoteIp, remoteAet, calledAet, filter);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590
2134
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
591
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
592 CommandDispatcher::CommandDispatcher(const DicomServer& server,
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
593 T_ASC_Association* assoc,
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
594 const std::string& remoteIp,
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
595 const std::string& remoteAet,
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
596 const std::string& calledAet,
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
597 IApplicationEntityFilter* filter) :
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
598 server_(server),
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
599 assoc_(assoc),
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
600 remoteIp_(remoteIp),
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
601 remoteAet_(remoteAet),
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
602 calledAet_(calledAet),
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
603 filter_(filter)
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
604 {
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
605 associationTimeout_ = server.GetAssociationTimeout();
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
606 elapsedTimeSinceLastCommand_ = 0;
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
607 }
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
608
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
609
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
610 CommandDispatcher::~CommandDispatcher()
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
611 {
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
612 try
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
613 {
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
614 AssociationCleanup(assoc_);
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
615 }
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
616 catch (...)
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
617 {
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
618 LOG(ERROR) << "Some association was not cleanly aborted";
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
619 }
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
620 }
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
621
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2068
diff changeset
622
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 bool CommandDispatcher::Step()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624 /*
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 * This function receives DIMSE commmands over the network connection
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 * and handles these commands correspondingly. Note that in case of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 * storscp only C-ECHO-RQ and C-STORE-RQ commands can be processed.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 bool finished = false;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 // receive a DIMSE command over the network, with a timeout of 1 second
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 DcmDataset *statusDetail = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634 T_ASC_PresentationContextID presID = 0;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635 T_DIMSE_Message msg;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 OFCondition cond = DIMSE_receiveCommand(assoc_, DIMSE_NONBLOCKING, 1, &presID, &msg, &statusDetail);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 elapsedTimeSinceLastCommand_++;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640 // if the command which was received has extra status
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641 // detail information, dump this information
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 if (statusDetail != NULL)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 {
101
428784e59dcd trying to use log4cplus
jodogne
parents: 62
diff changeset
644 //LOG4CPP_WARN(Internals::GetLogger(), "Status Detail:" << OFendl << DcmObject::PrintHelper(*statusDetail));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645 delete statusDetail;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 if (cond == DIMSE_OUTOFRESOURCES)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 finished = true;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 else if (cond == DIMSE_NODATAAVAILABLE)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 // Timeout due to DIMSE_NONBLOCKING
2068
879f3be759ef renames to make code clearer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
655 if (associationTimeout_ != 0 &&
879f3be759ef renames to make code clearer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
656 elapsedTimeSinceLastCommand_ >= associationTimeout_)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 {
2068
879f3be759ef renames to make code clearer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
658 // This timeout is actually a association timeout
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659 finished = true;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
660 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
662 else if (cond == EC_Normal)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 {
2068
879f3be759ef renames to make code clearer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
664 // Reset the association timeout counter
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 elapsedTimeSinceLastCommand_ = 0;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
667 // Convert the type of request to Orthanc's internal type
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
668 bool supported = false;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
669 DicomRequestType request;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 switch (msg.CommandField)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 {
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
672 case DIMSE_C_ECHO_RQ:
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
673 request = DicomRequestType_Echo;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
674 supported = true;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
675 break;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
676
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
677 case DIMSE_C_STORE_RQ:
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
678 request = DicomRequestType_Store;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
679 supported = true;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
680 break;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
681
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
682 case DIMSE_C_MOVE_RQ:
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
683 request = DicomRequestType_Move;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
684 supported = true;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
685 break;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
686
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
687 case DIMSE_C_FIND_RQ:
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
688 request = DicomRequestType_Find;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
689 supported = true;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
690 break;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
692 default:
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
693 // we cannot handle this kind of message
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
694 cond = DIMSE_BADCOMMANDTYPE;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
695 LOG(ERROR) << "cannot handle command: 0x" << std::hex << msg.CommandField;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
696 break;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
697 }
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
698
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
699
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
700 // Check whether this request is allowed by the security filter
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
701 if (supported &&
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
702 filter_ != NULL &&
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
703 !filter_->IsAllowedRequest(remoteIp_, remoteAet_, calledAet_, request))
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
704 {
2352
3ab96768d144 Fix issue 52 (DICOM level security association problems)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
705 LOG(WARNING) << "Rejected " << EnumerationToString(request)
3ab96768d144 Fix issue 52 (DICOM level security association problems)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
706 << " request from remote DICOM modality with AET \""
3ab96768d144 Fix issue 52 (DICOM level security association problems)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
707 << remoteAet_ << "\" and hostname \"" << remoteIp_ << "\"";
1085
b161593551db Always allow incoming ECHO requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1073
diff changeset
708 cond = DIMSE_ILLEGALASSOCIATION;
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
709 supported = false;
1085
b161593551db Always allow incoming ECHO requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1073
diff changeset
710 finished = true;
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
711 }
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
712
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
713 // in case we received a supported message, process this command
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
714 if (supported)
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
715 {
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
716 // If anything goes wrong, there will be a "BADCOMMANDTYPE" answer
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
717 cond = DIMSE_BADCOMMANDTYPE;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
718
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
719 switch (request)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 {
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
721 case DicomRequestType_Echo:
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
722 cond = EchoScp(assoc_, &msg, presID);
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
723 break;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
724
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
725 case DicomRequestType_Store:
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
726 if (server_.HasStoreRequestHandlerFactory()) // Should always be true
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
727 {
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
728 std::auto_ptr<IStoreRequestHandler> handler
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
729 (server_.GetStoreRequestHandlerFactory().ConstructStoreRequestHandler());
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
730
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
731 if (handler.get() != NULL)
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
732 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
733 cond = Internals::storeScp(assoc_, &msg, presID, *handler, remoteIp_);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
734 }
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
735 }
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
736 break;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
738 case DicomRequestType_Move:
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
739 if (server_.HasMoveRequestHandlerFactory()) // Should always be true
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
740 {
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
741 std::auto_ptr<IMoveRequestHandler> handler
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
742 (server_.GetMoveRequestHandlerFactory().ConstructMoveRequestHandler());
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
743
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
744 if (handler.get() != NULL)
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
745 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
746 cond = Internals::moveScp(assoc_, &msg, presID, *handler, remoteIp_, remoteAet_, calledAet_);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
747 }
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
748 }
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
749 break;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
750
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
751 case DicomRequestType_Find:
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
752 if (server_.HasFindRequestHandlerFactory() || // Should always be true
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
753 server_.HasWorklistRequestHandlerFactory())
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
754 {
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
755 std::auto_ptr<IFindRequestHandler> findHandler;
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
756 if (server_.HasFindRequestHandlerFactory())
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
757 {
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
758 findHandler.reset(server_.GetFindRequestHandlerFactory().ConstructFindRequestHandler());
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
759 }
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
760
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
761 std::auto_ptr<IWorklistRequestHandler> worklistHandler;
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
762 if (server_.HasWorklistRequestHandlerFactory())
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
763 {
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
764 worklistHandler.reset(server_.GetWorklistRequestHandlerFactory().ConstructWorklistRequestHandler());
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
765 }
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
766
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2352
diff changeset
767 cond = Internals::findScp(assoc_, &msg, presID, server_.GetRemoteModalities(),
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2352
diff changeset
768 findHandler.get(), worklistHandler.get(),
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2352
diff changeset
769 remoteIp_, remoteAet_, calledAet_);
620
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
770 }
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
771 break;
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
772
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
773 default:
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
774 // Should never happen
4aa6f0d79947 security filter for dicom requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
775 break;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 // Bad status, which indicates the closing of the connection by
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782 // the peer or a network error
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
783 finished = true;
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 661
diff changeset
784
667
aa2ab67d913d log error to log info
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 665
diff changeset
785 LOG(INFO) << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 if (finished)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 if (cond == DUL_PEERREQUESTEDRELEASE)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
792 LOG(INFO) << "Association Release";
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793 ASC_acknowledgeRelease(assoc_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 else if (cond == DUL_PEERABORTEDASSOCIATION)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
797 LOG(INFO) << "Association Aborted";
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801 OFString temp_str;
2352
3ab96768d144 Fix issue 52 (DICOM level security association problems)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
802 LOG(INFO) << "DIMSE failure (aborting association): " << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803 /* some kind of error so abort the association */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
804 ASC_abortAssociation(assoc_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
807
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 return !finished;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811
1073
01414536c930 complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
812 OFCondition EchoScp(T_ASC_Association * assoc, T_DIMSE_Message * msg, T_ASC_PresentationContextID presID)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 OFString temp_str;
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
815 LOG(INFO) << "Received Echo Request";
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
816 //LOG(DEBUG) << DIMSE_dumpMessage(temp_str, msg->msg.CEchoRQ, DIMSE_INCOMING, NULL, presID));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 /* the echo succeeded !! */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 OFCondition cond = DIMSE_sendEchoResponse(assoc, presID, &msg->msg.CEchoRQ, STATUS_Success, NULL);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
822 LOG(ERROR) << "Echo SCP Failed: " << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824 return cond;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
825 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
826 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
827 }