-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmovescu.cc.patch
168 lines (164 loc) · 5.41 KB
/
movescu.cc.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
diff -Naur dcmtk-3.6.1_20150924/dcmnet/apps/movescu.cc dcmtk-3.6.1_20150924_patched/dcmnet/apps/movescu.cc
--- dcmtk-3.6.1_20150924/dcmnet/apps/movescu.cc 2015-09-24 05:27:10.000000000 -0700
+++ dcmtk-3.6.1_20150924_patched/dcmnet/apps/movescu.cc 2016-03-28 16:03:13.666855196 -0700
@@ -53,6 +53,12 @@
#define OFFIS_CONSOLE_APPLICATION "movescu"
+static OFCondition acceptUnknownContextsWithPreferredTransferSyntaxes(
+ T_ASC_Parameters * params,
+ const char* transferSyntaxes[],
+ int transferSyntaxCount,
+ T_ASC_SC_ROLE acceptedRole = ASC_SC_ROLE_DEFAULT);
+
static OFLogger movescuLogger = OFLog::getLogger("dcmtk.apps." OFFIS_CONSOLE_APPLICATION);
static char rcsid[] = "$dcmtk: " OFFIS_CONSOLE_APPLICATION " v"
@@ -1170,6 +1176,9 @@
(*assoc)->params,
dcmAllStorageSOPClassUIDs, numberOfAllDcmStorageSOPClassUIDs,
transferSyntaxes, numTransferSyntaxes);
+ /* accept everything not known not to be a storage SOP class */
+ cond = acceptUnknownContextsWithPreferredTransferSyntaxes(
+ (*assoc)->params, transferSyntaxes, numTransferSyntaxes);
}
}
if (cond.good())
@@ -1189,6 +1198,141 @@
return cond;
}
+static
+DUL_PRESENTATIONCONTEXT *
+findPresentationContextID(LST_HEAD * head,
+ T_ASC_PresentationContextID presentationContextID)
+{
+ DUL_PRESENTATIONCONTEXT *pc;
+ LST_HEAD **l;
+ OFBool found = OFFalse;
+
+ if (head == NULL)
+ return NULL;
+
+ l = &head;
+ if (*l == NULL)
+ return NULL;
+
+ pc = OFstatic_cast(DUL_PRESENTATIONCONTEXT *, LST_Head(l));
+ (void)LST_Position(l, OFstatic_cast(LST_NODE *, pc));
+
+ while (pc && !found) {
+ if (pc->presentationContextID == presentationContextID) {
+ found = OFTrue;
+ } else {
+ pc = OFstatic_cast(DUL_PRESENTATIONCONTEXT *, LST_Next(l));
+ }
+ }
+ return pc;
+}
+
+
+/** accept all presenstation contexts for unknown SOP classes,
+ * i.e. UIDs appearing in the list of abstract syntaxes
+ * where no corresponding name is defined in the UID dictionary.
+ * @param params pointer to association parameters structure
+ * @param transferSyntax transfer syntax to accept
+ * @param acceptedRole SCU/SCP role to accept
+ */
+static OFCondition acceptUnknownContextsWithTransferSyntax(
+ T_ASC_Parameters * params,
+ const char* transferSyntax,
+ T_ASC_SC_ROLE acceptedRole)
+{
+ OFCondition cond = EC_Normal;
+ int n, i, k;
+ DUL_PRESENTATIONCONTEXT *dpc;
+ T_ASC_PresentationContext pc;
+ OFBool accepted = OFFalse;
+ OFBool abstractOK = OFFalse;
+
+ n = ASC_countPresentationContexts(params);
+ for (i = 0; i < n; i++)
+ {
+ cond = ASC_getPresentationContext(params, i, &pc);
+ if (cond.bad()) return cond;
+ abstractOK = OFFalse;
+ accepted = OFFalse;
+
+ if (dcmFindNameOfUID(pc.abstractSyntax) == NULL)
+ {
+ abstractOK = OFTrue;
+
+ /* check the transfer syntax */
+ for (k = 0; (k < OFstatic_cast(int, pc.transferSyntaxCount)) && !accepted; k++)
+ {
+ if (strcmp(pc.proposedTransferSyntaxes[k], transferSyntax) == 0)
+ {
+ accepted = OFTrue;
+ }
+ }
+ }
+
+ if (accepted)
+ {
+ cond = ASC_acceptPresentationContext(
+ params, pc.presentationContextID,
+ transferSyntax, acceptedRole);
+ if (cond.bad()) return cond;
+ } else {
+ T_ASC_P_ResultReason reason;
+
+ /* do not refuse if already accepted */
+ dpc = findPresentationContextID(params->DULparams.acceptedPresentationContext,
+ pc.presentationContextID);
+ if ((dpc == NULL) || ((dpc != NULL) && (dpc->result != ASC_P_ACCEPTANCE)))
+ {
+
+ if (abstractOK) {
+ reason = ASC_P_TRANSFERSYNTAXESNOTSUPPORTED;
+ } else {
+ reason = ASC_P_ABSTRACTSYNTAXNOTSUPPORTED;
+ }
+ /*
+ * If previously this presentation context was refused
+ * because of bad transfer syntax let it stay that way.
+ */
+ if ((dpc != NULL) && (dpc->result == ASC_P_TRANSFERSYNTAXESNOTSUPPORTED))
+ reason = ASC_P_TRANSFERSYNTAXESNOTSUPPORTED;
+
+ cond = ASC_refusePresentationContext(params, pc.presentationContextID, reason);
+ if (cond.bad()) return cond;
+ }
+ }
+ }
+ return EC_Normal;
+}
+
+
+/** accept all presenstation contexts for unknown SOP classes,
+ * i.e. UIDs appearing in the list of abstract syntaxes
+ * where no corresponding name is defined in the UID dictionary.
+ * This method is passed a list of "preferred" transfer syntaxes.
+ * @param params pointer to association parameters structure
+ * @param transferSyntax transfer syntax to accept
+ * @param acceptedRole SCU/SCP role to accept
+ */
+static OFCondition acceptUnknownContextsWithPreferredTransferSyntaxes(
+ T_ASC_Parameters * params,
+ const char* transferSyntaxes[], int transferSyntaxCount,
+ T_ASC_SC_ROLE acceptedRole)
+{
+ OFCondition cond = EC_Normal;
+ /*
+ ** Accept in the order "least wanted" to "most wanted" transfer
+ ** syntax. Accepting a transfer syntax will override previously
+ ** accepted transfer syntaxes.
+ */
+ for (int i = transferSyntaxCount - 1; i >= 0; i--)
+ {
+ cond = acceptUnknownContextsWithTransferSyntax(params, transferSyntaxes[i], acceptedRole);
+ if (cond.bad()) return cond;
+ }
+ return cond;
+}
+
+
static OFCondition echoSCP(
T_ASC_Association *assoc,
T_DIMSE_Message *msg,