q931.h

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

Generated on Fri Mar 7 06:33:40 2008 for OPAL by  doxygen 1.5.1