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 #ifndef ASSOCIATION_H
00080 #define ASSOCIATION_H
00081
00082 #include "dcmtk/config/osconfig.h"
00083
00084
00085
00086
00087 #include "dcmtk/dcmnet/dicom.h"
00088 #include "dcmtk/dcmnet/lst.h"
00089 #include "dcmtk/dcmnet/dul.h"
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #define ASC_DEFAULTMAXPDU 16384
00101 #define ASC_MINIMUMPDUSIZE 4096
00102 #define ASC_MAXIMUMPDUSIZE 131072
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 enum T_ASC_NetworkRole
00114 {
00115 NET_ACCEPTOR,
00116 NET_REQUESTOR,
00117 NET_ACCEPTORREQUESTOR
00118 };
00119
00120 struct T_ASC_Network
00121 {
00122 T_ASC_NetworkRole role;
00123 int acceptorPort;
00124 DUL_NETWORKKEY *network;
00125 };
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 #define DICOM_MAXTRANSFERSYNTAXES 50
00139
00140
00141 typedef DUL_PRESENTATIONCONTEXTID T_ASC_PresentationContextID;
00142
00143 enum T_ASC_P_ResultReason
00144 {
00145 ASC_P_ACCEPTANCE = 0,
00146 ASC_P_USERREJECTION = 1,
00147 ASC_P_NOREASON = 2,
00148 ASC_P_ABSTRACTSYNTAXNOTSUPPORTED = 3,
00149 ASC_P_TRANSFERSYNTAXESNOTSUPPORTED = 4,
00150 ASC_P_NOTYETNEGOTIATED = 255
00151 };
00152
00153 enum T_ASC_SC_ROLE
00154 {
00155 ASC_SC_ROLE_NONE,
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 OFString&
00326 ASC_printRejectParameters(
00327 OFString& str,
00328 T_ASC_RejectParameters *rej);
00329
00330 OFCondition
00331 ASC_addPresentationContext(
00332 T_ASC_Parameters * params,
00333 T_ASC_PresentationContextID presentationContextID,
00334 const char* abstractSyntax,
00335 const char* transferSyntaxList[],
00336 int transferSyntaxListCount,
00337 T_ASC_SC_ROLE proposedRole = ASC_SC_ROLE_DEFAULT);
00338
00339 int
00340 ASC_countPresentationContexts(
00341 T_ASC_Parameters * params);
00342
00343 int
00344 ASC_countAcceptedPresentationContexts(
00345 T_ASC_Parameters * params);
00346
00347 OFCondition
00348 ASC_getPresentationContext(
00349 T_ASC_Parameters * params,
00350 int listPosition,
00351 T_ASC_PresentationContext * presentationContext);
00352
00353 OFCondition
00354 ASC_acceptPresentationContext(
00355 T_ASC_Parameters * params,
00356 T_ASC_PresentationContextID presentationContextID,
00357 const char* transferSyntax,
00358 T_ASC_SC_ROLE acceptedRole = ASC_SC_ROLE_DEFAULT);
00359
00360 OFCondition
00361 ASC_acceptContextsWithPreferredTransferSyntaxes(
00362 T_ASC_Parameters * params,
00363 const char* abstractSyntaxes[], int abstractSyntaxCount,
00364 const char* transferSyntaxes[], int transferSyntaxCount,
00365 T_ASC_SC_ROLE acceptedRole = ASC_SC_ROLE_DEFAULT);
00366
00367 OFCondition
00368 ASC_acceptContextsWithTransferSyntax(
00369 T_ASC_Parameters * params,
00370 const char* transferSyntax, int abstractSyntaxCount,
00371 const char* abstractSyntaxes[],
00372 T_ASC_SC_ROLE acceptedRole = ASC_SC_ROLE_DEFAULT);
00373
00374 OFCondition
00375 ASC_refusePresentationContext(
00376 T_ASC_Parameters * params,
00377 T_ASC_PresentationContextID presentationContextID,
00378 T_ASC_P_ResultReason resultReason);
00379
00380 OFCondition
00381 ASC_findAcceptedPresentationContext(
00382 T_ASC_Parameters * params,
00383 T_ASC_PresentationContextID presentationContextID,
00384 T_ASC_PresentationContext * presentationContext);
00385
00386 T_ASC_PresentationContextID
00387 ASC_findAcceptedPresentationContextID(
00388 T_ASC_Association *assoc,
00389 const char* abstractSyntax);
00390
00391 T_ASC_PresentationContextID
00392 ASC_findAcceptedPresentationContextID(
00393 T_ASC_Association *assoc,
00394 const char* abstractSyntax,
00395 const char * transferSyntax);
00396
00397
00398 void ASC_getRequestedExtNegList(T_ASC_Parameters* params, SOPClassExtendedNegotiationSubItemList** extNegList);
00399 void ASC_getAcceptedExtNegList(T_ASC_Parameters* params, SOPClassExtendedNegotiationSubItemList** extNegList);
00400 void ASC_setRequestedExtNegList(T_ASC_Parameters* params, SOPClassExtendedNegotiationSubItemList* extNegList);
00401 void ASC_setAcceptedExtNegList(T_ASC_Parameters* params, SOPClassExtendedNegotiationSubItemList* extNegList);
00402
00403
00404
00405
00406
00407
00408
00409
00410 void ASC_getUserIdentRQ(T_ASC_Parameters* params, UserIdentityNegotiationSubItemRQ** usrIdentRQ);
00411
00412
00413
00414
00415
00416
00417
00418
00419 void ASC_getUserIdentAC(T_ASC_Parameters* params, UserIdentityNegotiationSubItemAC** usrIdentAC);
00420
00428 OFCondition
00429 ASC_setIdentRQUserPassword(
00430 T_ASC_Parameters * params,
00431 const OFString& userName,
00432 const OFString& password,
00433 const OFBool& requestRsp = OFTrue);
00434
00441 OFCondition
00442 ASC_setIdentRQUserOnly(
00443 T_ASC_Parameters * params,
00444 const OFString& userName,
00445 const OFBool& requestRsp = OFTrue);
00446
00453 OFCondition
00454 ASC_setIdentRQKerberos(
00455 T_ASC_Parameters * params,
00456 const char* kerbTicket,
00457 const Uint16& length,
00458 const OFBool& requestRsp = OFTrue);
00459
00466 OFCondition
00467 ASC_setIdentRQSaml(
00468 T_ASC_Parameters * params,
00469 const char* saml,
00470 const Uint16& length,
00471 const OFBool& requestRsp = OFTrue);
00472
00473
00480 OFCondition ASC_setIdentAC(
00481 T_ASC_Parameters * params,
00482 const char* response,
00483 const Uint16& length );
00484
00497 void
00498 ASC_getCopyOfIdentResponse(T_ASC_Parameters * params,
00499 void*& buffer,
00500 unsigned short& bufferLen);
00501
00502
00503
00504
00505 unsigned long ASC_getPeerCertificateLength(T_ASC_Association *assoc);
00506 unsigned long ASC_getPeerCertificate(T_ASC_Association *assoc, void *buf, unsigned long bufLen);
00507
00508
00509 OFCondition
00510 ASC_setTransportLayer(T_ASC_Network *network, DcmTransportLayer *newLayer, int takeoverOwnership);
00511
00512 enum ASC_associateType
00513 {
00514 ASC_ASSOC_RQ,
00515 ASC_ASSOC_AC,
00516 ASC_ASSOC_RJ
00517 };
00518
00519 OFString&
00520 ASC_dumpParameters(OFString& str, T_ASC_Parameters * param, ASC_associateType dir);
00521
00522 OFString&
00523 ASC_dumpConnectionParameters(OFString& str, T_ASC_Association *association);
00524
00525 void ASC_activateCallback(T_ASC_Parameters *params, DUL_ModeCallback *cb);
00526
00527
00528
00529
00530
00531 OFBool
00532 ASC_associationWaiting(T_ASC_Network * network, int timeout);
00533
00534 OFBool
00535 ASC_dataWaiting(T_ASC_Association * association, int timeout);
00536
00537 OFBool
00538 ASC_selectReadableAssociation(
00539 T_ASC_Association* assocs[],
00540 int assocCount, int timeout);
00541
00542
00543
00544
00545
00546 OFCondition
00547 ASC_requestAssociation(
00548 T_ASC_Network * network,
00549 T_ASC_Parameters * params,
00550
00551
00552 T_ASC_Association ** association,
00553 void **associatePDU=NULL,
00554 unsigned long *associatePDUlength=NULL);
00555
00556 OFCondition
00557 ASC_receiveAssociation(
00558 T_ASC_Network * network,
00559 T_ASC_Association ** association,
00560 long maxReceivePDUSize,
00561 void **associatePDU=NULL,
00562 unsigned long *associatePDUlength=NULL,
00563 OFBool useSecureLayer=OFFalse,
00564 DUL_BLOCKOPTIONS block=DUL_BLOCK,
00565 int timeout=0);
00566
00567 OFCondition
00568 ASC_acknowledgeAssociation(
00569 T_ASC_Association * assoc,
00570 void **associatePDU=NULL,
00571 unsigned long *associatePDUlength=NULL);
00572
00573 OFCondition
00574 ASC_rejectAssociation(
00575 T_ASC_Association * association,
00576 T_ASC_RejectParameters * rejectParameters,
00577 void **associatePDU=NULL,
00578 unsigned long *associatePDUlength=NULL);
00579
00580 OFCondition
00581 ASC_releaseAssociation(T_ASC_Association * association);
00582
00583 OFCondition
00584 ASC_acknowledgeRelease(T_ASC_Association * association);
00585
00586 OFCondition
00587 ASC_abortAssociation(T_ASC_Association * association);
00588
00589 OFCondition
00590 ASC_dropSCPAssociation(T_ASC_Association * association, int timeout = DUL_TIMEOUT);
00591
00592 OFCondition
00593 ASC_dropAssociation(T_ASC_Association * association);
00594
00595 OFCondition
00596 ASC_destroyAssociation(T_ASC_Association ** association);
00597
00599 void
00600 ASC_printRejectParameters(
00601 FILE *f,
00602 T_ASC_RejectParameters *rej);
00603
00605 void
00606 ASC_printRejectParameters(
00607 STD_NAMESPACE ostream& out,
00608 T_ASC_RejectParameters *rej);
00609
00614 void
00615 ASC_dumpParameters(T_ASC_Parameters * params, STD_NAMESPACE ostream& outstream);
00616
00618 void
00619 ASC_dumpPresentationContext(T_ASC_PresentationContext * presentationContext, STD_NAMESPACE ostream& outstream);
00620
00625 void
00626 ASC_dumpConnectionParameters(T_ASC_Association *association, STD_NAMESPACE ostream& outstream);
00627
00628
00629 #endif
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756