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  * $Revision: 19279 $
00027  * $Author: rjongbloed $
00028  * $Date: 2008-01-17 04:08:34 +0000 (Thu, 17 Jan 2008) $
00029  */
00030 
00031 #ifndef __OPAL_Q931_H
00032 #define __OPAL_Q931_H
00033 
00034 #ifdef P_USE_PRAGMA
00035 #pragma interface
00036 #endif
00037 
00038 
00040 
00043 class Q931 : public PObject
00044 {
00045   PCLASSINFO(Q931, PObject)
00046   public:
00047     enum MsgTypes {
00048       NationalEscapeMsg  = 0x00,
00049       AlertingMsg        = 0x01,
00050       CallProceedingMsg  = 0x02,
00051       ConnectMsg         = 0x07,
00052       ConnectAckMsg      = 0x0f,
00053       ProgressMsg        = 0x03,
00054       SetupMsg           = 0x05,
00055       SetupAckMsg        = 0x0d,
00056       ResumeMsg          = 0x26,
00057       ResumeAckMsg       = 0x2e,
00058       ResumeRejectMsg    = 0x22,
00059       SuspendMsg         = 0x25,
00060       SuspendAckMsg      = 0x2d,
00061       SuspendRejectMsg   = 0x21,
00062       UserInformationMsg = 0x20,
00063       DisconnectMsg      = 0x45,
00064       ReleaseMsg         = 0x4d,
00065       ReleaseCompleteMsg = 0x5a,
00066       RestartMsg         = 0x46,
00067       RestartAckMsg      = 0x4e,
00068       SegmentMsg         = 0x60,
00069       CongestionCtrlMsg  = 0x79,
00070       InformationMsg     = 0x7b,
00071       NotifyMsg          = 0x6e,
00072       StatusMsg          = 0x7d,
00073       StatusEnquiryMsg   = 0x75,
00074       FacilityMsg        = 0x62
00075     };
00076 
00077     Q931();
00078     Q931(const Q931 & other);
00079     Q931 & operator=(const Q931 & other);
00080 
00081     void BuildFacility(int callRef, PBoolean fromDest);
00082     void BuildInformation(int callRef, PBoolean fromDest);
00083     void BuildProgress(
00084       int callRef,
00085       PBoolean fromDest,
00086       unsigned description,
00087       unsigned codingStandard = 0,
00088       unsigned location = 0
00089     );
00090     void BuildNotify(int callRef, PBoolean fromDest);
00091     void BuildCallProceeding(int callRef);
00092     void BuildSetupAcknowledge(int callRef);
00093     void BuildAlerting(int callRef);
00094     void BuildSetup(int callRef = -1);
00095     void BuildConnect(int callRef);
00096     void BuildStatus(int callRef, PBoolean fromDest);
00097     void BuildStatusEnquiry(int callRef, PBoolean fromDest);
00098     void BuildReleaseComplete(int callRef, PBoolean fromDest);
00099 
00100     PBoolean Decode(const PBYTEArray & data);
00101     PBoolean Encode(PBYTEArray & data) const;
00102 
00103     void PrintOn(ostream & strm) const;
00104     PString GetMessageTypeName() const;
00105 
00106     static unsigned GenerateCallReference();
00107     unsigned GetCallReference() const { return callReference; }
00108     PBoolean IsFromDestination() const { return fromDestination; }
00109     MsgTypes GetMessageType() const { return messageType; }
00110 
00111     enum InformationElementCodes {
00112       BearerCapabilityIE      = 0x04,
00113       CauseIE                 = 0x08,
00114       ChannelIdentificationIE = 0x18,
00115       FacilityIE              = 0x1c,
00116       ProgressIndicatorIE     = 0x1e,
00117       CallStateIE             = 0x14,
00118       DisplayIE               = 0x28,
00119       KeypadIE                = 0x2c,
00120       SignalIE                = 0x34,
00121       ConnectedNumberIE       = 0x4c,
00122       CallingPartyNumberIE    = 0x6c,
00123       CalledPartyNumberIE     = 0x70,
00124       RedirectingNumberIE     = 0x74,
00125       UserUserIE              = 0x7e
00126     };
00127     friend ostream & operator<<(ostream & strm, InformationElementCodes ie);
00128 
00129     PBoolean HasIE(InformationElementCodes ie) const;
00130     PBYTEArray GetIE(
00131       InformationElementCodes ie,
00132       PINDEX idx = 0 // Index of duplicate IE entry
00133     ) const;
00134     void SetIE(
00135       InformationElementCodes ie,
00136       const PBYTEArray & userData,
00137       bool append = FALSE
00138     );
00139     void RemoveIE(InformationElementCodes ie);
00140 
00141     enum InformationTransferCapability {
00142       TransferSpeech,
00143       TransferUnrestrictedDigital = 8,
00144       TransferRestrictedDigital = 9,
00145       Transfer3_1kHzAudio = 16,
00146       TrasnferUnrestrictedDigitalWithTones = 17,
00147       TransferVideo = 24
00148     };
00149 
00150     void SetBearerCapabilities(
00151       InformationTransferCapability capability,
00152       unsigned transferRate,        
00153       unsigned codingStandard = 0,  
00154       unsigned userInfoLayer1 = 5   
00155     );
00156 
00157     PBoolean GetBearerCapabilities(
00158       InformationTransferCapability & capability,
00159       unsigned & transferRate,        
00160       unsigned * codingStandard = NULL,
00161       unsigned * userInfoLayer1 = NULL
00162     );
00163 
00164     enum CauseValues {
00165       UnknownCauseIE               =  0,
00166       UnallocatedNumber            =  1,
00167       NoRouteToNetwork             =  2,
00168       NoRouteToDestination         =  3,
00169       SendSpecialTone              =  4,
00170       MisdialledTrunkPrefix        =  5,
00171       ChannelUnacceptable          =  6,
00172       NormalCallClearing           = 16,
00173       UserBusy                     = 17,
00174       NoResponse                   = 18,
00175       NoAnswer                     = 19,
00176       SubscriberAbsent             = 20,
00177       CallRejected                 = 21,
00178       NumberChanged                = 22,
00179       Redirection                  = 23,
00180       ExchangeRoutingError         = 25,
00181       NonSelectedUserClearing      = 26,
00182       DestinationOutOfOrder        = 27,
00183       InvalidNumberFormat          = 28,
00184       FacilityRejected             = 29,
00185       StatusEnquiryResponse        = 30,
00186       NormalUnspecified            = 31,
00187       NoCircuitChannelAvailable    = 34,
00188       NetworkOutOfOrder            = 38,
00189       TemporaryFailure             = 41,
00190       Congestion                   = 42,
00191       RequestedCircuitNotAvailable = 44,
00192       ResourceUnavailable          = 47,
00193       ServiceOptionNotAvailable    = 63,
00194       InvalidCallReference         = 81,
00195       ClearedRequestedCallIdentity = 86,
00196       IncompatibleDestination      = 88,
00197       IENonExistantOrNotImplemented= 99,
00198       TimerExpiry                  = 102,
00199       ProtocolErrorUnspecified     = 111,
00200       InterworkingUnspecified      = 127,
00201       ErrorInCauseIE               = 0x100
00202     };
00203     friend ostream & operator<<(ostream & strm, CauseValues cause);
00204 
00205     void SetCause(
00206       CauseValues value,
00207       unsigned standard = 0,  
00208       unsigned location = 0   
00209     );
00210     CauseValues GetCause(
00211       unsigned * standard = NULL,  
00212       unsigned * location = NULL   
00213     ) const;
00214 
00215     enum CallStates {
00216       CallState_Null                  = 0,
00217       CallState_CallInitiated         = 1,
00218       CallState_OverlapSending        = 2,
00219       CallState_OutgoingCallProceeding= 3,
00220       CallState_CallDelivered         = 4,
00221       CallState_CallPresent           = 6,
00222       CallState_CallReceived          = 7,
00223       CallState_ConnectRequest        = 8,
00224       CallState_IncomingCallProceeding= 9,
00225       CallState_Active                = 10,
00226       CallState_DisconnectRequest     = 11,
00227       CallState_DisconnectIndication  = 12,
00228       CallState_SuspendRequest        = 15,
00229       CallState_ResumeRequest         = 17,
00230       CallState_ReleaseRequest        = 19,
00231       CallState_OverlapReceiving      = 25,
00232       CallState_ErrorInIE             = 0x100
00233     };
00234     void SetCallState(
00235       CallStates value,
00236       unsigned standard = 0  
00237     );
00238     CallStates GetCallState(
00239       unsigned * standard = NULL  
00240     ) const;
00241 
00242     enum SignalInfo {
00243       SignalDialToneOn,
00244       SignalRingBackToneOn,
00245       SignalInterceptToneOn,
00246       SignalNetworkCongestionToneOn,
00247       SignalBusyToneOn,
00248       SignalConfirmToneOn,
00249       SignalAnswerToneOn,
00250       SignalCallWaitingTone,
00251       SignalOffhookWarningTone,
00252       SignalPreemptionToneOn,
00253       SignalTonesOff = 0x3f,
00254       SignalAlertingPattern0 = 0x40,
00255       SignalAlertingPattern1,
00256       SignalAlertingPattern2,
00257       SignalAlertingPattern3,
00258       SignalAlertingPattern4,
00259       SignalAlertingPattern5,
00260       SignalAlertingPattern6,
00261       SignalAlertingPattern7,
00262       SignalAlertingOff = 0x4f,
00263       SignalErrorInIE = 0x100
00264     };
00265     void SetSignalInfo(SignalInfo value);
00266     SignalInfo GetSignalInfo() const;
00267 
00268     void SetKeypad(const PString & digits);
00269     PString GetKeypad() const;
00270 
00271     enum ProgressIndication {
00272        ProgressNotEndToEndISDN      = 1,      // Call is not end-to-end ISDN; 
00273                                               // further call progress information may be available in-band  
00274        ProgressDestinationNonISDN   = 2,      // Destination address is non ISDN  
00275        ProgressOriginNotISDN        = 3,      // Origination address is non ISDN  
00276        ProgressReturnedToISDN       = 4,      // Call has returned to the ISDN 
00277        ProgressServiceChange        = 5,      // Interworking has occurred and has 
00278                                               // resulted in a telecommunication service change
00279        ProgressInbandInformationAvailable = 8 // In-band information or an appropriate pattern is now available.   
00280     };
00281 
00282     void SetProgressIndicator(
00283       unsigned description,
00284       unsigned codingStandard = 0,
00285       unsigned location = 0
00286     );
00287     PBoolean GetProgressIndicator(
00288       unsigned & description,
00289       unsigned * codingStandard = NULL,
00290       unsigned * location = NULL
00291     ) const;
00292 
00293     void SetDisplayName(const PString & name);
00294     PString GetDisplayName() const;
00295 
00296     enum NumberingPlanCodes {
00297       UnknownPlan          = 0x00,
00298       ISDNPlan             = 0x01,
00299       DataPlan             = 0x03,
00300       TelexPlan            = 0x04,
00301       NationalStandardPlan = 0x08,
00302       PrivatePlan          = 0x09,
00303       ReservedPlan         = 0x0f
00304     };
00305 
00306     enum TypeOfNumberCodes {
00307       UnknownType          = 0x00,
00308       InternationalType    = 0x01,
00309       NationalType         = 0x02,
00310       NetworkSpecificType  = 0x03,
00311       SubscriberType       = 0x04,
00312       AbbreviatedType      = 0x06,
00313       ReservedType         = 0x07
00314     };
00315 
00316     void SetCallingPartyNumber(
00317       const PString & number, 
00318       unsigned plan = 1,      
00319       unsigned type = 0,      
00320       int presentation = -1,  
00321       int screening = -1      
00322     );
00323     PBoolean GetCallingPartyNumber(
00324       PString & number,               
00325       unsigned * plan = NULL,         
00326       unsigned * type = NULL,         
00327       unsigned * presentation = NULL, 
00328       unsigned * screening = NULL,    
00329       unsigned defPresentation = 0,   
00330       unsigned defScreening = 0       
00331     ) const;
00332 
00333     void SetCalledPartyNumber(
00334       const PString & number, 
00335       unsigned plan = 1,      
00336       unsigned type = 0       
00337     );
00338     PBoolean GetCalledPartyNumber(
00339       PString & number,       
00340       unsigned * plan = NULL, 
00341       unsigned * type = NULL  
00342     ) const;
00343 
00344     void SetRedirectingNumber(
00345       const PString & number, 
00346       unsigned plan = 1,      
00347       unsigned type = 0,      
00348       int presentation = -1,  
00349       int screening = -1,     
00350       int reason = -1         
00351     );
00352     PBoolean GetRedirectingNumber(
00353       PString & number,               
00354       unsigned * plan = NULL,         
00355       unsigned * type = NULL,         
00356       unsigned * presentation = NULL, 
00357       unsigned * screening = NULL,    
00358       unsigned * reason = NULL,       
00359       unsigned defPresentation = 0,   
00360       unsigned defScreening = 0,      
00361       unsigned defReason =0           
00362     ) const;
00363 
00364     void SetConnectedNumber(
00365       const PString & number, 
00366       unsigned plan = 1,      
00367       unsigned type = 0,      
00368       int presentation = -1,  
00369       int screening = -1,     
00370       int reason = -1         
00371     );
00372     PBoolean GetConnectedNumber(
00373       PString & number,               
00374       unsigned * plan = NULL,         
00375       unsigned * type = NULL,         
00376       unsigned * presentation = NULL, 
00377       unsigned * screening = NULL,    
00378       unsigned * reason = NULL,       
00379       unsigned defPresentation = 0,   
00380       unsigned defScreening = 0,      
00381       unsigned defReason =0           
00382     ) const;
00383 
00390     void SetChannelIdentification(
00391       unsigned interfaceType = 0,        
00392       unsigned preferredOrExclusive = 0, 
00393       int      channelNumber = 1         
00394     );
00395 
00398     PBoolean GetChannelIdentification(
00399       unsigned * interfaceType = NULL,        
00400       unsigned * preferredOrExclusive = NULL, 
00401       int      * channelNumber = NULL         
00402     ) const;
00403 
00404   protected:
00405     unsigned callReference;
00406     PBoolean fromDestination;
00407     unsigned protocolDiscriminator;
00408     MsgTypes messageType;
00409 
00410     PARRAY(InternalInformationElement, PBYTEArray);
00411     PDICTIONARY(InternalInformationElements, POrdinalKey, InternalInformationElement);
00412     InternalInformationElements informationElements;
00413 };
00414 
00415 
00416 #endif // __OPAL_Q931_H
00417 
00418 

Generated on Mon Sep 15 11:49:14 2008 for OPAL by  doxygen 1.5.1