OpenH323 1.18.0
|
00001 /* 00002 * q931.h 00003 * 00004 * Q.931 protocol handler 00005 * 00006 * Open H323 Library 00007 * 00008 * Copyright (c) 1998-2000 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Open H323 Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Contributor(s): ______________________________________. 00025 * 00026 * $Log: q931.h,v $ 00027 * Revision 1.56 2005/11/30 13:05:01 csoutheren 00028 * Changed tags for Doxygen 00029 * 00030 * Revision 1.55 2004/12/10 00:20:22 csoutheren 00031 * Fixed typo 00032 * 00033 * Revision 1.54 2004/12/09 23:37:14 csoutheren 00034 * Added new Q.931 termination codes 00035 * 00036 * Revision 1.53 2004/07/11 11:37:28 rjongbloed 00037 * Added ConnectAck support and fixed bugs in ChannelIdentificationIE, thanks Eize Slange 00038 * 00039 * Revision 1.52 2003/03/18 05:54:14 robertj 00040 * Added ChannelIdentifier IE support, thanks Eize Slange 00041 * 00042 * Revision 1.51 2003/02/12 00:02:06 robertj 00043 * Added more Q.931 cause codes. 00044 * Added ability to trace text version of cause codes and IE codes. 00045 * 00046 * Revision 1.50 2002/11/25 22:40:00 robertj 00047 * Added another Q.850 code 00048 * 00049 * Revision 1.49 2002/11/07 03:49:49 robertj 00050 * Added extra "congested" Q.931 codes. 00051 * 00052 * Revision 1.48 2002/09/16 01:14:15 robertj 00053 * Added #define so can select if #pragma interface/implementation is used on 00054 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00055 * 00056 * Revision 1.47 2002/09/03 05:42:27 robertj 00057 * Normalised the multi-include header prevention ifdef/define symbol. 00058 * Removed redundent includes. 00059 * 00060 * Revision 1.46 2002/08/05 10:03:47 robertj 00061 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00062 * 00063 * Revision 1.45 2002/07/05 03:13:35 robertj 00064 * Added copy constructor for Q.931 so makes duplicate instead of reference to IE's. 00065 * 00066 * Revision 1.44 2002/05/22 23:12:01 robertj 00067 * Enhanced the display of Release-Complete cause codes. 00068 * 00069 * Revision 1.43 2002/05/03 05:38:16 robertj 00070 * Added Q.931 Keypad IE mechanism for user indications (DTMF). 00071 * 00072 * Revision 1.42 2002/04/22 08:03:41 craigs 00073 * Added Q931 progress codes 00074 * 00075 * Revision 1.41 2002/04/22 07:33:02 craigs 00076 * Changed GetProgressIndicator to be const 00077 * Fixed spelling mistake in SignalType enums list 00078 * 00079 * Revision 1.40 2002/04/18 09:35:00 robertj 00080 * Added CallState IE processing. 00081 * 00082 * Revision 1.39 2002/03/27 06:04:42 robertj 00083 * Added Temporary Failure end code for connection, an application may 00084 * immediately retry the call if this occurs. 00085 * 00086 * Revision 1.38 2002/02/08 00:05:14 robertj 00087 * Changed release complete causes so can dsitinguish between unknown 00088 * cause and no cause at all. 00089 * 00090 * Revision 1.37 2002/01/07 04:25:41 robertj 00091 * Added support for Connected-Number Information Element, thanks Hans Verbeek 00092 * 00093 * Revision 1.36 2001/09/17 02:06:38 robertj 00094 * Added Redirecting Number IE to Q.931, thanks Frank Derks 00095 * 00096 * Revision 1.35 2001/09/13 02:41:32 robertj 00097 * Fixed call reference generation to use full range and common code, thanks Carlo Kielstra 00098 * 00099 * Revision 1.34 2001/09/12 02:01:33 robertj 00100 * Added "No Circuit" release complete code. 00101 * 00102 * Revision 1.33 2001/08/20 06:48:26 robertj 00103 * Added Q.931 function for setting bearer capabilities, allowing 00104 * applications to set the data rate as they require. 00105 * 00106 * Revision 1.32 2001/08/03 14:12:07 robertj 00107 * Fixed value for Call State Information Element 00108 * 00109 * Revision 1.31 2001/07/24 23:40:15 craigs 00110 * Added ability to remove Q931 IE 00111 * 00112 * Revision 1.30 2001/06/14 06:25:13 robertj 00113 * Added further H.225 PDU build functions. 00114 * Moved some functionality from connection to PDU class. 00115 * 00116 * Revision 1.29 2001/05/30 04:38:38 robertj 00117 * Added BuildStatusEnquiry() Q.931 function, thanks Markus Storm 00118 * 00119 * Revision 1.28 2001/04/11 00:12:38 robertj 00120 * Added some enums for numbering plans and call types, thanks Markus Storm. 00121 * 00122 * Revision 1.27 2001/02/09 05:16:24 robertj 00123 * Added #pragma interface for GNU C++. 00124 * 00125 * Revision 1.26 2001/01/19 07:01:42 robertj 00126 * Added all of the Q.931 message type codes. 00127 * 00128 * Revision 1.25 2000/10/13 02:15:23 robertj 00129 * Added support for Progress Indicator Q.931/H.225 message. 00130 * 00131 * Revision 1.24 2000/07/09 14:53:17 robertj 00132 * Added facility IE to facility message. 00133 * Changed reference to the word "field" to be more correct IE or "Information Element" 00134 * 00135 * Revision 1.23 2000/06/21 08:07:39 robertj 00136 * Added cause/reason to release complete PDU, where relevent. 00137 * 00138 * Revision 1.22 2000/05/18 11:53:34 robertj 00139 * Changes to support doc++ documentation generation. 00140 * 00141 * Revision 1.21 2000/05/09 12:19:23 robertj 00142 * Added ability to get and set "distinctive ring" Q.931 functionality. 00143 * 00144 * Revision 1.20 2000/05/08 14:07:26 robertj 00145 * Improved the provision and detection of calling and caller numbers, aliases and hostnames. 00146 * 00147 * Revision 1.19 2000/05/06 02:17:49 robertj 00148 * Changed the new CallingPartyNumber code so defaults for octet3a are application dependent. 00149 * 00150 * Revision 1.18 2000/05/05 00:44:05 robertj 00151 * Added presentation and screening fields to Calling Party Number field, thanks Dean Anderson. 00152 * 00153 * Revision 1.17 2000/05/02 04:32:25 robertj 00154 * Fixed copyright notice comment. 00155 * 00156 * Revision 1.16 2000/03/21 01:07:21 robertj 00157 * Fixed incorrect call reference code being used in originated call. 00158 * 00159 * Revision 1.15 1999/12/23 22:43:36 robertj 00160 * Added calling party number field. 00161 * 00162 * Revision 1.14 1999/09/10 03:36:48 robertj 00163 * Added simple Q.931 Status response to Q.931 Status Enquiry 00164 * 00165 * Revision 1.13 1999/08/31 12:34:18 robertj 00166 * Added gatekeeper support. 00167 * 00168 * Revision 1.12 1999/08/13 06:34:38 robertj 00169 * Fixed problem in CallPartyNumber Q.931 encoding. 00170 * Added field name display to Q.931 protocol. 00171 * 00172 * Revision 1.11 1999/08/10 13:14:15 robertj 00173 * Added Q.931 Called Number field if have "phone number" style destination addres. 00174 * 00175 * Revision 1.10 1999/07/23 02:36:56 robertj 00176 * Finally found correct value for FACILITY message. 00177 * 00178 * Revision 1.9 1999/07/16 02:15:30 robertj 00179 * Fixed more tunneling problems. 00180 * 00181 * Revision 1.8 1999/07/09 06:09:49 robertj 00182 * Major implementation. An ENORMOUS amount of stuff added everywhere. 00183 * 00184 * Revision 1.7 1999/06/13 12:41:14 robertj 00185 * Implement logical channel transmitter. 00186 * Fixed H245 connect on receiving call. 00187 * 00188 * Revision 1.6 1999/06/09 05:26:20 robertj 00189 * Major restructuring of classes. 00190 * 00191 * Revision 1.5 1999/02/23 11:04:29 robertj 00192 * Added capability to make outgoing call. 00193 * 00194 * Revision 1.4 1999/01/16 11:31:46 robertj 00195 * Fixed name in header comment. 00196 * 00197 * Revision 1.3 1999/01/16 01:31:39 robertj 00198 * Major implementation. 00199 * 00200 * Revision 1.2 1999/01/02 04:00:55 robertj 00201 * Added higher level protocol negotiations. 00202 * 00203 * Revision 1.1 1998/12/14 09:13:41 robertj 00204 * Initial revision 00205 * 00206 */ 00207 00208 #ifndef __OPAL_Q931_H 00209 #define __OPAL_Q931_H 00210 00211 #ifdef P_USE_PRAGMA 00212 #pragma interface 00213 #endif 00214 00215 00217 00220 class Q931 : public PObject 00221 { 00222 PCLASSINFO(Q931, PObject) 00223 public: 00224 enum MsgTypes { 00225 NationalEscapeMsg = 0x00, 00226 AlertingMsg = 0x01, 00227 CallProceedingMsg = 0x02, 00228 ConnectMsg = 0x07, 00229 ConnectAckMsg = 0x0f, 00230 ProgressMsg = 0x03, 00231 SetupMsg = 0x05, 00232 SetupAckMsg = 0x0d, 00233 ResumeMsg = 0x26, 00234 ResumeAckMsg = 0x2e, 00235 ResumeRejectMsg = 0x22, 00236 SuspendMsg = 0x25, 00237 SuspendAckMsg = 0x2d, 00238 SuspendRejectMsg = 0x21, 00239 UserInformationMsg = 0x20, 00240 DisconnectMsg = 0x45, 00241 ReleaseMsg = 0x4d, 00242 ReleaseCompleteMsg = 0x5a, 00243 RestartMsg = 0x46, 00244 RestartAckMsg = 0x4e, 00245 SegmentMsg = 0x60, 00246 CongestionCtrlMsg = 0x79, 00247 InformationMsg = 0x7b, 00248 NotifyMsg = 0x6e, 00249 StatusMsg = 0x7d, 00250 StatusEnquiryMsg = 0x75, 00251 FacilityMsg = 0x62 00252 }; 00253 00254 Q931(); 00255 Q931(const Q931 & other); 00256 Q931 & operator=(const Q931 & other); 00257 00258 void BuildFacility(int callRef, BOOL fromDest); 00259 void BuildInformation(int callRef, BOOL fromDest); 00260 void BuildProgress( 00261 int callRef, 00262 BOOL fromDest, 00263 unsigned description, 00264 unsigned codingStandard = 0, 00265 unsigned location = 0 00266 ); 00267 void BuildNotify(int callRef, BOOL fromDest); 00268 void BuildCallProceeding(int callRef); 00269 void BuildSetupAcknowledge(int callRef); 00270 void BuildAlerting(int callRef); 00271 void BuildSetup(int callRef = -1); 00272 void BuildConnect(int callRef); 00273 void BuildConnectAck(int callRef, BOOL fromDest); 00274 void BuildStatus(int callRef, BOOL fromDest); 00275 void BuildStatusEnquiry(int callRef, BOOL fromDest); 00276 void BuildReleaseComplete(int callRef, BOOL fromDest); 00277 00278 BOOL Decode(const PBYTEArray & data); 00279 BOOL Encode(PBYTEArray & data) const; 00280 00281 void PrintOn(ostream & strm) const; 00282 PString GetMessageTypeName() const; 00283 00284 static unsigned GenerateCallReference(); 00285 unsigned GetCallReference() const { return callReference; } 00286 BOOL IsFromDestination() const { return fromDestination; } 00287 MsgTypes GetMessageType() const { return messageType; } 00288 00289 enum InformationElementCodes { 00290 BearerCapabilityIE = 0x04, 00291 CauseIE = 0x08, 00292 ChannelIdentificationIE = 0x18, 00293 FacilityIE = 0x1c, 00294 ProgressIndicatorIE = 0x1e, 00295 CallStateIE = 0x14, 00296 DisplayIE = 0x28, 00297 KeypadIE = 0x2c, 00298 SignalIE = 0x34, 00299 ConnectedNumberIE = 0x4c, 00300 CallingPartyNumberIE = 0x6c, 00301 CalledPartyNumberIE = 0x70, 00302 RedirectingNumberIE = 0x74, 00303 UserUserIE = 0x7e 00304 }; 00305 friend ostream & operator<<(ostream & strm, InformationElementCodes ie); 00306 00307 BOOL HasIE(InformationElementCodes ie) const; 00308 PBYTEArray GetIE(InformationElementCodes ie) const; 00309 void SetIE(InformationElementCodes ie, const PBYTEArray & userData); 00310 void RemoveIE(InformationElementCodes ie); 00311 00312 enum InformationTransferCapability { 00313 TransferSpeech, 00314 TransferUnrestrictedDigital = 8, 00315 TransferRestrictedDigital = 9, 00316 Transfer3_1kHzAudio = 16, 00317 TransferUnrestrictedDigitalWithTones = 17, 00318 TransferVideo = 24 00319 }; 00320 00321 void SetBearerCapabilities( 00322 InformationTransferCapability capability, 00323 unsigned transferRate, 00324 unsigned codingStandard = 0, 00325 unsigned userInfoLayer1 = 5 00326 ); 00327 00328 BOOL GetBearerCapabilities( 00329 InformationTransferCapability & capability, 00330 unsigned & transferRate, 00331 unsigned * codingStandard = NULL, 00332 unsigned * userInfoLayer1 = NULL 00333 ); 00334 00335 enum CauseValues { 00336 UnknownCauseIE = 0, 00337 UnallocatedNumber = 1, 00338 NoRouteToNetwork = 2, 00339 NoRouteToDestination = 3, 00340 SendSpecialTone = 4, 00341 MisdialledTrunkPrefix = 5, 00342 ChannelUnacceptable = 6, 00343 CallAwarded = 7, 00344 Preemption = 8, 00345 PreemptionCircuitReserved = 9, 00346 NormalCallClearing = 16, 00347 UserBusy = 17, 00348 NoResponse = 18, 00349 NoAnswer = 19, 00350 SubscriberAbsent = 20, 00351 CallRejected = 21, 00352 NumberChanged = 22, 00353 Redirection = 23, 00354 ExchangeRoutingError = 25, 00355 NonSelectedUserClearing = 26, 00356 DestinationOutOfOrder = 27, 00357 InvalidNumberFormat = 28, 00358 FacilityRejected = 29, 00359 StatusEnquiryResponse = 30, 00360 NormalUnspecified = 31, 00361 NoCircuitChannelAvailable = 34, 00362 CallQueued = 35, 00363 NetworkOutOfOrder = 38, 00364 FrameModeOOS = 39, 00365 FrameModeOperational = 40, 00366 TemporaryFailure = 41, 00367 Congestion = 42, 00368 AccessInformationDiscarded = 43, 00369 RequestedCircuitNotAvailable = 44, 00370 PrecedenceCallBlocked = 46, 00371 ResourceUnavailable = 47, 00372 QoSNotAvailable = 49, 00373 RequestedFacilityNotSubscribed = 50, 00374 OutgoingCallsBarred = 52, 00375 OutgoingCallsBarredInCUG = 53, 00376 IncomingCallsBarred = 54, 00377 IncomingCallsBarredInCUG = 55, 00378 BearerCapNotAuthorised = 57, 00379 BearerCapNotPresentlyAvailable = 58, 00380 InconsistentOutgoingIE = 62, 00381 ServiceOptionNotAvailable = 63, 00382 BearerCapNotImplemented = 65, 00383 ChannelTypeNotImplemented = 66, 00384 RequestedFacilityNotImplemented = 69, 00385 OnlyRestrictedDigitalBearerCapAvailable = 70, 00386 ServiceOrOptionNotImplemented = 79, 00387 InvalidCallReference = 81, 00388 IdentifiedChannelNonExistent = 82, 00389 CallIdentifyNotSuspendedCall = 83, 00390 CallIdentifyInUse = 84, 00391 NoCallSuspended = 85, 00392 ClearedRequestedCallIdentity = 86, 00393 UserNotInCUG = 87, 00394 IncompatibleDestination = 88, 00395 NonexistentCUG = 90, 00396 InvalidTransitNetwork = 91, 00397 InvalidMessageUnspecified = 95, 00398 MandatoryIEMissing = 96, 00399 MessageTypeNonexistent = 97, 00400 MessageNotCompatible = 98, 00401 IENonExistantOrNotImplemented = 99, 00402 InvalidIEContents = 100, 00403 MessageNotCompatibleWithCallState = 101, 00404 TimerExpiry = 102, 00405 ParameterNonexistent = 103, 00406 UnrecognisedParamaterDiscarded = 110, 00407 ProtocolErrorUnspecified = 111, 00408 InterworkingUnspecified = 127, 00409 ErrorInCauseIE = 0x100 00410 }; 00411 friend ostream & operator<<(ostream & strm, CauseValues cause); 00412 00413 void SetCause( 00414 CauseValues value, 00415 unsigned standard = 0, 00416 unsigned location = 0 00417 ); 00418 CauseValues GetCause( 00419 unsigned * standard = NULL, 00420 unsigned * location = NULL 00421 ) const; 00422 00423 enum CallStates { 00424 CallState_Null = 0, 00425 CallState_CallInitiated = 1, 00426 CallState_OverlapSending = 2, 00427 CallState_OutgoingCallProceeding= 3, 00428 CallState_CallDelivered = 4, 00429 CallState_CallPresent = 6, 00430 CallState_CallReceived = 7, 00431 CallState_ConnectRequest = 8, 00432 CallState_IncomingCallProceeding= 9, 00433 CallState_Active = 10, 00434 CallState_DisconnectRequest = 11, 00435 CallState_DisconnectIndication = 12, 00436 CallState_SuspendRequest = 15, 00437 CallState_ResumeRequest = 17, 00438 CallState_ReleaseRequest = 19, 00439 CallState_OverlapReceiving = 25, 00440 CallState_ErrorInIE = 0x100 00441 }; 00442 void SetCallState( 00443 CallStates value, 00444 unsigned standard = 0 00445 ); 00446 CallStates GetCallState( 00447 unsigned * standard = NULL 00448 ) const; 00449 00450 enum SignalInfo { 00451 SignalDialToneOn, 00452 SignalRingBackToneOn, 00453 SignalInterceptToneOn, 00454 SignalNetworkCongestionToneOn, 00455 SignalBusyToneOn, 00456 SignalConfirmToneOn, 00457 SignalAnswerToneOn, 00458 SignalCallWaitingTone, 00459 SignalOffhookWarningTone, 00460 SignalPreemptionToneOn, 00461 SignalTonesOff = 0x3f, 00462 SignalAlertingPattern0 = 0x40, 00463 SignalAlertingPattern1, 00464 SignalAlertingPattern2, 00465 SignalAlertingPattern3, 00466 SignalAlertingPattern4, 00467 SignalAlertingPattern5, 00468 SignalAlertingPattern6, 00469 SignalAlertingPattern7, 00470 SignalAlertingOff = 0x4f, 00471 SignalErrorInIE = 0x100 00472 }; 00473 void SetSignalInfo(SignalInfo value); 00474 SignalInfo GetSignalInfo() const; 00475 00476 void SetKeypad(const PString & digits); 00477 PString GetKeypad() const; 00478 00479 enum ProgressIndication { 00480 ProgressNotEndToEndISDN = 1, // Call is not end-to-end ISDN; 00481 // further call progress information may be available in-band 00482 ProgressDestinationNonISDN = 2, // Destination address is non ISDN 00483 ProgressOriginNotISDN = 3, // Origination address is non ISDN 00484 ProgressReturnedToISDN = 4, // Call has returned to the ISDN 00485 ProgressServiceChange = 5, // Interworking has occurred and has 00486 // resulted in a telecommunication service change 00487 ProgressInbandInformationAvailable = 8 // In-band information or an appropriate pattern is now available. 00488 }; 00489 00490 void SetProgressIndicator( 00491 unsigned description, 00492 unsigned codingStandard = 0, 00493 unsigned location = 0 00494 ); 00495 BOOL GetProgressIndicator( 00496 unsigned & description, 00497 unsigned * codingStandard = NULL, 00498 unsigned * location = NULL 00499 ) const; 00500 00501 void SetDisplayName(const PString & name); 00502 PString GetDisplayName() const; 00503 00504 enum NumberingPlanCodes { 00505 UnknownPlan = 0x00, 00506 ISDNPlan = 0x01, 00507 DataPlan = 0x03, 00508 TelexPlan = 0x04, 00509 NationalStandardPlan = 0x08, 00510 PrivatePlan = 0x09, 00511 ReservedPlan = 0x0f 00512 }; 00513 00514 enum TypeOfNumberCodes { 00515 UnknownType = 0x00, 00516 InternationalType = 0x01, 00517 NationalType = 0x02, 00518 NetworkSpecificType = 0x03, 00519 SubscriberType = 0x04, 00520 AbbreviatedType = 0x06, 00521 ReservedType = 0x07 00522 }; 00523 00524 void SetCallingPartyNumber( 00525 const PString & number, 00526 unsigned plan = 1, 00527 unsigned type = 0, 00528 int presentation = -1, 00529 int screening = -1 00530 ); 00531 BOOL GetCallingPartyNumber( 00532 PString & number, 00533 unsigned * plan = NULL, 00534 unsigned * type = NULL, 00535 unsigned * presentation = NULL, 00536 unsigned * screening = NULL, 00537 unsigned defPresentation = 0, 00538 unsigned defScreening = 0 00539 ) const; 00540 00541 void SetCalledPartyNumber( 00542 const PString & number, 00543 unsigned plan = 1, 00544 unsigned type = 0 00545 ); 00546 BOOL GetCalledPartyNumber( 00547 PString & number, 00548 unsigned * plan = NULL, 00549 unsigned * type = NULL 00550 ) const; 00551 00552 void SetRedirectingNumber( 00553 const PString & number, 00554 unsigned plan = 1, 00555 unsigned type = 0, 00556 int presentation = -1, 00557 int screening = -1, 00558 int reason = -1 00559 ); 00560 BOOL GetRedirectingNumber( 00561 PString & number, 00562 unsigned * plan = NULL, 00563 unsigned * type = NULL, 00564 unsigned * presentation = NULL, 00565 unsigned * screening = NULL, 00566 unsigned * reason = NULL, 00567 unsigned defPresentation = 0, 00568 unsigned defScreening = 0, 00569 unsigned defReason =0 00570 ) const; 00571 00572 void SetConnectedNumber( 00573 const PString & number, 00574 unsigned plan = 1, 00575 unsigned type = 0, 00576 int presentation = -1, 00577 int screening = -1, 00578 int reason = -1 00579 ); 00580 BOOL GetConnectedNumber( 00581 PString & number, 00582 unsigned * plan = NULL, 00583 unsigned * type = NULL, 00584 unsigned * presentation = NULL, 00585 unsigned * screening = NULL, 00586 unsigned * reason = NULL, 00587 unsigned defPresentation = 0, 00588 unsigned defScreening = 0, 00589 unsigned defReason =0 00590 ) const; 00591 00598 void SetChannelIdentification( 00599 unsigned interfaceType = 0, 00600 unsigned preferredOrExclusive = 0, 00601 int channelNumber = 1 00602 ); 00603 00606 BOOL GetChannelIdentification( 00607 unsigned * interfaceType = NULL, 00608 unsigned * preferredOrExclusive = NULL, 00609 int * channelNumber = NULL 00610 ) const; 00611 00612 protected: 00613 unsigned callReference; 00614 BOOL fromDestination; 00615 unsigned protocolDiscriminator; 00616 MsgTypes messageType; 00617 00618 PDICTIONARY(InternalInformationElements, POrdinalKey, PBYTEArray); 00619 InternalInformationElements informationElements; 00620 }; 00621 00622 00623 #endif // __OPAL_Q931_H 00624 00625