-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathDCMTKServiceClassUser.mm
180 lines (149 loc) · 5.79 KB
/
DCMTKServiceClassUser.mm
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
169
170
171
172
173
174
175
176
177
178
179
180
/*=========================================================================
Program: OsiriX
Copyright (c) OsiriX Team
All rights reserved.
Distributed under GNU - LGPL
See http://www.osirix-viewer.com/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
=========================================================================*/
#import "DCMTKServiceClassUser.h"
#include "tlstrans.h"
#include "tlslayer.h"
#include "ofstring.h"
@implementation DCMTKServiceClassUser
@synthesize _abortAssociation;
- (id) initWithCallingAET:(NSString *)myAET
calledAET:(NSString *)theirAET
hostname:(NSString *)hostname
port:(int)port
transferSyntax:(int)transferSyntax
compression: (float)compression
extraParameters:(NSDictionary *)extraParameters
{
if (self = [super init])
{
_callingAET = [myAET retain];
_calledAET = [theirAET retain];
_port = port;
_hostname = [hostname retain];
_extraParameters = [extraParameters retain];
_shouldAbort = NO;
_transferSyntax = transferSyntax;
_compression = compression;
_verbose = NO;
_debug = NO;
_abortAssociation = NO;
_maxReceivePDULength = ASC_DEFAULTMAXPDU;
_repeatCount = -1;
_cancelAfterNResponses = -1;
_networkTransferSyntax = EXS_Unknown;
_blockMode = DIMSE_BLOCKING; //DIMSE_BLOCKING; ANR JANUARY 2009 - Move failed on HUG PACS
if( [[NSUserDefaults standardUserDefaults] integerForKey:@"DICOMTimeout"] <= 0)
[[NSUserDefaults standardUserDefaults] setInteger: 20 forKey:@"DICOMTimeout"];
_acse_timeout = _dimse_timeout = [[NSUserDefaults standardUserDefaults] integerForKey:@"DICOMTimeout"];
//TLS
_secureConnection = [[extraParameters objectForKey:@"TLSEnabled"] boolValue];
_doAuthenticate = NO;
_cipherSuites = nil;
_dhparam = NULL;
if (_secureConnection)
{
_doAuthenticate = [[extraParameters objectForKey:@"TLSAuthenticated"] boolValue];
_keyFileFormat = SSL_FILETYPE_PEM;
certVerification = (TLSCertificateVerificationType)[[extraParameters objectForKey:@"TLSCertificateVerification"] intValue];
NSArray *suites = [extraParameters objectForKey:@"TLSCipherSuites"];
NSMutableArray *selectedCipherSuites = [NSMutableArray array];
for (NSDictionary *suite in suites)
{
if ([[suite objectForKey:@"Supported"] boolValue])
[selectedCipherSuites addObject:[suite objectForKey:@"Cipher"]];
}
_cipherSuites = [[NSArray arrayWithArray:selectedCipherSuites] retain];
if([[extraParameters objectForKey:@"TLSUseDHParameterFileURL"] boolValue])
_dhparam = [[extraParameters objectForKey:@"TLSDHParameterFileURL"] cStringUsingEncoding:NSUTF8StringEncoding];
[DDKeychain generatePseudoRandomFileToPath:TLS_SEED_FILE];
_readSeedFile = [TLS_SEED_FILE cStringUsingEncoding:NSUTF8StringEncoding];
_writeSeedFile = TLS_WRITE_SEED_FILE;
}
}
return self;
}
- (void)dealloc{
[_callingAET release];
[_calledAET release];
[_hostname release];
[_extraParameters release];
// TLS
[_cipherSuites release];
[super dealloc];
}
- (OFCondition) addPresentationContext:(T_ASC_Parameters *)params abstractSyntax:(const char *)abstractSyntax{
/*
** We prefer to use Explicitly encoded transfer syntaxes.
** If we are running on a Little Endian machine we prefer
** LittleEndianExplicitTransferSyntax to BigEndianTransferSyntax.
** Some SCP implementations will just select the first transfer
** syntax they support (this is not part of the standard) so
** organise the proposed transfer syntaxes to take advantage
** of such behaviour.
**
** The presentation contexts proposed here are only used for
** C-FIND and C-MOVE and C-ECHO, so there is no need to support compressed
** transmission.
*/
const char* transferSyntaxes[] = { NULL, NULL, NULL };
int numTransferSyntaxes = 0;
switch (_networkTransferSyntax) {
case EXS_LittleEndianImplicit:
/* we only support Little Endian Implicit */
transferSyntaxes[0] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 1;
break;
case EXS_LittleEndianExplicit:
/* we prefer Little Endian Explicit */
transferSyntaxes[0] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[1] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 3;
break;
case EXS_BigEndianExplicit:
/* we prefer Big Endian Explicit */
transferSyntaxes[0] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 3;
break;
default:
/* We prefer explicit transfer syntaxes.
* If we are running on a Little Endian machine we prefer
* LittleEndianExplicitTransferSyntax to BigEndianTransferSyntax.
*/
if (gLocalByteOrder == EBO_LittleEndian) /* defined in dcxfer.h */
{
transferSyntaxes[0] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[1] = UID_BigEndianExplicitTransferSyntax;
} else {
transferSyntaxes[0] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
}
transferSyntaxes[2] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 3;
break;
}
return ASC_addPresentationContext(
params, 1, abstractSyntax,
transferSyntaxes, numTransferSyntaxes);
}
- (NSString *)calledAET{
return _calledAET;
}
- (NSString *)callingAET{
return _callingAET;
}
- (NSDictionary*) extraParameters
{
return _extraParameters;
}
@end