00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 #ifndef ASSOCIATION_H
00081 #define ASSOCIATION_H
00082
00083 #include "dcmtk/config/osconfig.h"
00084
00085
00086
00087
00088 #include "dcmtk/dcmnet/dicom.h"
00089 #include "dcmtk/dcmnet/lst.h"
00090 #include "dcmtk/dcmnet/dul.h"
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #define ASC_DEFAULTMAXPDU 16384
00102 #define ASC_MINIMUMPDUSIZE 4096
00103 #define ASC_MAXIMUMPDUSIZE 131072
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 enum T_ASC_NetworkRole
00115 {
00116 NET_ACCEPTOR,
00117 NET_REQUESTOR,
00118 NET_ACCEPTORREQUESTOR
00119 };
00120
00121 struct T_ASC_Network
00122 {
00123 T_ASC_NetworkRole role;
00124 int acceptorPort;
00125 DUL_NETWORKKEY *network;
00126 };
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 #define DICOM_MAXTRANSFERSYNTAXES 50
00140
00141
00142 typedef DUL_PRESENTATIONCONTEXTID T_ASC_PresentationContextID;
00143
00144 enum T_ASC_P_ResultReason
00145 {
00146 ASC_P_ACCEPTANCE = 0,
00147 ASC_P_USERREJECTION = 1,
00148 ASC_P_NOREASON = 2,
00149 ASC_P_ABSTRACTSYNTAXNOTSUPPORTED = 3,
00150 ASC_P_TRANSFERSYNTAXESNOTSUPPORTED = 4,
00151 ASC_P_NOTYETNEGOTIATED = 255
00152 };
00153
00154 enum T_ASC_SC_ROLE
00155 {
00156 ASC_SC_ROLE_DEFAULT,
00157 ASC_SC_ROLE_SCU,
00158 ASC_SC_ROLE_SCP,
00159 ASC_SC_ROLE_SCUSCP
00160 };
00161
00162 struct T_ASC_PresentationContext
00163 {
00164 T_ASC_PresentationContextID presentationContextID;
00165 DIC_UI abstractSyntax;
00166 unsigned char transferSyntaxCount;
00167 DIC_UI proposedTransferSyntaxes[DICOM_MAXTRANSFERSYNTAXES];
00168 DIC_UI acceptedTransferSyntax;
00169 T_ASC_P_ResultReason resultReason;
00170 T_ASC_SC_ROLE proposedRole;
00171 T_ASC_SC_ROLE acceptedRole;
00172 };
00173
00174 enum T_ASC_RejectParametersResult
00175 {
00176 ASC_RESULT_REJECTEDPERMANENT = 1,
00177 ASC_RESULT_REJECTEDTRANSIENT = 2
00178 };
00179
00180 enum T_ASC_RejectParametersSource
00181 {
00182 ASC_SOURCE_SERVICEUSER = 1,
00183 ASC_SOURCE_SERVICEPROVIDER_ACSE_RELATED = 2,
00184 ASC_SOURCE_SERVICEPROVIDER_PRESENTATION_RELATED = 3
00185 };
00186
00187 enum T_ASC_RejectParametersReason
00188 {
00189
00190 ASC_REASON_SU_NOREASON = 0x0101,
00191 ASC_REASON_SU_APPCONTEXTNAMENOTSUPPORTED = 0x0102,
00192 ASC_REASON_SU_CALLINGAETITLENOTRECOGNIZED = 0x0103,
00193 ASC_REASON_SU_CALLEDAETITLENOTRECOGNIZED = 0x0107,
00194
00195 ASC_REASON_SP_ACSE_NOREASON = 0x0201,
00196 ASC_REASON_SP_ACSE_PROTOCOLVERSIONNOTSUPPORTED = 0x0202,
00197
00198 ASC_REASON_SP_PRES_TEMPORARYCONGESTION = 0x0301,
00199 ASC_REASON_SP_PRES_LOCALLIMITEXCEEDED = 0x0302
00200 };
00201
00202 struct T_ASC_RejectParameters
00203 {
00204 T_ASC_RejectParametersResult result;
00205 T_ASC_RejectParametersSource source;
00206 T_ASC_RejectParametersReason reason;
00207 };
00208
00209
00210 struct T_ASC_Parameters
00211 {
00212 DIC_UI ourImplementationClassUID;
00213 DIC_SH ourImplementationVersionName;
00214 DIC_UI theirImplementationClassUID;
00215 DIC_SH theirImplementationVersionName;
00216 DUL_ModeCallback *modeCallback;
00217
00218 DUL_ASSOCIATESERVICEPARAMETERS DULparams;
00219
00220
00221
00222
00223
00224 long ourMaxPDUReceiveSize;
00225 long theirMaxPDUReceiveSize;
00226
00227 };
00228
00229
00230
00231
00232
00233 struct T_ASC_Association
00234 {
00235 DUL_ASSOCIATIONKEY *DULassociation;
00236 T_ASC_Parameters *params;
00237
00238 unsigned short nextMsgID;
00239 unsigned long sendPDVLength;
00240 unsigned char *sendPDVBuffer;
00241 };
00242
00243
00244
00245
00246
00257 OFCondition ASC_initializeNetwork(
00258 T_ASC_NetworkRole role,
00259 int acceptorPort,
00260 int timeout,
00261 T_ASC_Network ** network,
00262 unsigned long options = 0);
00263
00268 OFCondition ASC_dropNetwork(T_ASC_Network ** network);
00269
00270
00271
00272
00273
00274 OFCondition
00275 ASC_createAssociationParameters(
00276 T_ASC_Parameters ** params,
00277 long maxReceivePDUSize);
00278
00279 OFCondition
00280 ASC_destroyAssociationParameters(
00281 T_ASC_Parameters ** params);
00282
00283
00284 OFCondition
00285 ASC_setTransportLayerType(
00286 T_ASC_Parameters * params,
00287 OFBool useSecureLayer);
00288
00289 OFCondition
00290 ASC_setAPTitles(
00291 T_ASC_Parameters * params,
00292 const char* callingAPTitle,
00293 const char* calledAPTitle,
00294 const char* respondingAPTitle);
00295
00296 OFCondition
00297 ASC_getAPTitles(
00298 T_ASC_Parameters * params,
00299 char* callingAPTitle,
00300 char* calledAPTitle,
00301 char* respondingAPTitle);
00302
00303 OFCondition
00304 ASC_getApplicationContextName(
00305 T_ASC_Parameters * params,
00306 char* applicationContextName);
00307
00308 OFCondition
00309 ASC_setPresentationAddresses(
00310 T_ASC_Parameters * params,
00311 const char* callingPresentationAddress,
00312 const char* calledPresentationAddress);
00313
00314 OFCondition
00315 ASC_getPresentationAddresses(
00316 T_ASC_Parameters * params,
00317 char* callingPresentationAddress,
00318 char* calledPresentationAddress);
00319
00320 OFCondition
00321 ASC_getRejectParameters(
00322 T_ASC_Parameters * params,
00323 T_ASC_RejectParameters * rejectParameters);
00324
00325 void
00326 ASC_printRejectParameters(
00327 FILE *f,
00328 T_ASC_RejectParameters *rej);
00329
00330 void
00331 ASC_printRejectParameters(
00332 ostream &out,
00333 T_ASC_RejectParameters *rej);
00334
00335 OFCondition
00336 ASC_addPresentationContext(
00337 T_ASC_Parameters * params,
00338 T_ASC_PresentationContextID presentationContextID,
00339 const char* abstractSyntax,
00340 const char* transferSyntaxList[],
00341 int transferSyntaxListCount,
00342 T_ASC_SC_ROLE proposedRole = ASC_SC_ROLE_DEFAULT);
00343
00344 int
00345 ASC_countPresentationContexts(
00346 T_ASC_Parameters * params);
00347
00348 int
00349 ASC_countAcceptedPresentationContexts(
00350 T_ASC_Parameters * params);
00351
00352 OFCondition
00353 ASC_getPresentationContext(
00354 T_ASC_Parameters * params,
00355 int listPosition,
00356 T_ASC_PresentationContext * presentationContext);
00357
00358 OFCondition
00359 ASC_acceptPresentationContext(
00360 T_ASC_Parameters * params,
00361 T_ASC_PresentationContextID presentationContextID,
00362 const char* transferSyntax,
00363 T_ASC_SC_ROLE acceptedRole = ASC_SC_ROLE_DEFAULT);
00364
00365 OFCondition
00366 ASC_acceptContextsWithPreferredTransferSyntaxes(
00367 T_ASC_Parameters * params,
00368 const char* abstractSyntaxes[], int abstractSyntaxCount,
00369 const char* transferSyntaxes[], int transferSyntaxCount,
00370 T_ASC_SC_ROLE acceptedRole = ASC_SC_ROLE_DEFAULT);
00371
00372 OFCondition
00373 ASC_acceptContextsWithTransferSyntax(
00374 T_ASC_Parameters * params,
00375 const char* transferSyntax, int abstractSyntaxCount,
00376 const char* abstractSyntaxes[],
00377 T_ASC_SC_ROLE acceptedRole = ASC_SC_ROLE_DEFAULT);
00378
00379 OFCondition
00380 ASC_refusePresentationContext(
00381 T_ASC_Parameters * params,
00382 T_ASC_PresentationContextID presentationContextID,
00383 T_ASC_P_ResultReason resultReason);
00384
00385 OFCondition
00386 ASC_findAcceptedPresentationContext(
00387 T_ASC_Parameters * params,
00388 T_ASC_PresentationContextID presentationContextID,
00389 T_ASC_PresentationContext * presentationContext);
00390
00391 T_ASC_PresentationContextID
00392 ASC_findAcceptedPresentationContextID(
00393 T_ASC_Association *assoc,
00394 const char* abstractSyntax);
00395
00396 T_ASC_PresentationContextID
00397 ASC_findAcceptedPresentationContextID(
00398 T_ASC_Association *assoc,
00399 const char* abstractSyntax,
00400 const char * transferSyntax);
00401
00402
00403 void ASC_getRequestedExtNegList(T_ASC_Parameters* params, SOPClassExtendedNegotiationSubItemList** extNegList);
00404 void ASC_getAcceptedExtNegList(T_ASC_Parameters* params, SOPClassExtendedNegotiationSubItemList** extNegList);
00405 void ASC_setRequestedExtNegList(T_ASC_Parameters* params, SOPClassExtendedNegotiationSubItemList* extNegList);
00406 void ASC_setAcceptedExtNegList(T_ASC_Parameters* params, SOPClassExtendedNegotiationSubItemList* extNegList);
00407
00408
00409 unsigned long ASC_getPeerCertificateLength(T_ASC_Association *assoc);
00410 unsigned long ASC_getPeerCertificate(T_ASC_Association *assoc, void *buf, unsigned long bufLen);
00411
00412
00413 OFCondition
00414 ASC_setTransportLayer(T_ASC_Network *network, DcmTransportLayer *newLayer, int takeoverOwnership);
00415
00416 void
00417 ASC_dumpParameters(T_ASC_Parameters * params, ostream& outstream);
00418
00419 void
00420 ASC_dumpPresentationContext(T_ASC_PresentationContext * presentationContext, ostream& outstream);
00421
00422 void
00423 ASC_dumpConnectionParameters(T_ASC_Association *association, ostream& outstream);
00424
00425 void ASC_activateCallback(T_ASC_Parameters *params, DUL_ModeCallback *cb);
00426
00427
00428
00429
00430
00431 OFBool
00432 ASC_associationWaiting(T_ASC_Network * network, int timeout);
00433
00434 OFBool
00435 ASC_dataWaiting(T_ASC_Association * association, int timeout);
00436
00437 OFBool
00438 ASC_selectReadableAssociation(
00439 T_ASC_Association* assocs[],
00440 int assocCount, int timeout);
00441
00442
00443
00444
00445
00446 OFCondition
00447 ASC_requestAssociation(
00448 T_ASC_Network * network,
00449 T_ASC_Parameters * params,
00450
00451
00452 T_ASC_Association ** association,
00453 void **associatePDU=NULL,
00454 unsigned long *associatePDUlength=NULL);
00455
00456 OFCondition
00457 ASC_receiveAssociation(
00458 T_ASC_Network * network,
00459 T_ASC_Association ** association,
00460 long maxReceivePDUSize,
00461 void **associatePDU=NULL,
00462 unsigned long *associatePDUlength=NULL,
00463 OFBool useSecureLayer=OFFalse,
00464 DUL_BLOCKOPTIONS block=DUL_BLOCK,
00465 int timeout=0);
00466
00467 OFCondition
00468 ASC_acknowledgeAssociation(
00469 T_ASC_Association * assoc,
00470 void **associatePDU=NULL,
00471 unsigned long *associatePDUlength=NULL);
00472
00473 OFCondition
00474 ASC_rejectAssociation(
00475 T_ASC_Association * association,
00476 T_ASC_RejectParameters * rejectParameters,
00477 void **associatePDU=NULL,
00478 unsigned long *associatePDUlength=NULL);
00479
00480 OFCondition
00481 ASC_releaseAssociation(T_ASC_Association * association);
00482
00483 OFCondition
00484 ASC_acknowledgeRelease(T_ASC_Association * association);
00485
00486 OFCondition
00487 ASC_abortAssociation(T_ASC_Association * association);
00488
00489 OFCondition
00490 ASC_dropSCPAssociation(T_ASC_Association * association, int timeout = DUL_TIMEOUT);
00491
00492 OFCondition
00493 ASC_dropAssociation(T_ASC_Association * association);
00494
00495 OFCondition
00496 ASC_destroyAssociation(T_ASC_Association ** association);
00497
00498
00499 #endif
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600