h323pdu.h

Go to the documentation of this file.
00001 /*
00002  * h323pdu.h
00003  *
00004  * H.323 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  * Portions of this code were written with the assisance of funding from
00025  * Vovida Networks, Inc. http://www.vovida.com.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Revision: 23923 $
00030  * $Author: rjongbloed $
00031  * $Date: 2010-01-11 19:49:45 -0600 (Mon, 11 Jan 2010) $
00032  */
00033 
00034 #ifndef OPAL_H323_H323PDU_H
00035 #define OPAL_H323_H323PDU_H
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 #include <opal/buildopts.h>
00042 
00043 #if OPAL_H323
00044 
00045 #include <ptlib/sockets.h>
00046 #include <h323/h323con.h>
00047 #include <h323/transaddr.h>
00048 #include <h323/q931.h>
00049 #include <h323/h235auth.h>
00050 #include <h323/h323trans.h>
00051 #include <rtp/rtp.h>
00052 #include <asn/h225.h>
00053 #include <asn/h245.h>
00054 
00055 
00056 class H323Connection;
00057 class H323TransportAddress;
00058 class H225_RAS;
00059 class OpalGloballyUniqueID;
00060 
00061 
00062 #define H225_PROTOCOL_VERSION 6
00063 #define H245_PROTOCOL_VERSION 13
00064 
00065 
00067 
00070 class H323SignalPDU : public H225_H323_UserInformation
00071 {
00072   PCLASSINFO(H323SignalPDU, H225_H323_UserInformation);
00073 
00074   public:
00079     H323SignalPDU();
00080 
00083     H225_Setup_UUIE & BuildSetup(
00084       const H323Connection & connection,    
00085       const H323TransportAddress & destAddr 
00086     );
00087 
00090     H225_CallProceeding_UUIE & BuildCallProceeding(
00091       const H323Connection & connection    
00092     );
00093 
00096     H225_Connect_UUIE & BuildConnect(
00097       const H323Connection & connection    
00098     );
00099 
00102     H225_Connect_UUIE & BuildConnect(
00103       const H323Connection & connection,    
00104       const PIPSocket::Address & h245Address, 
00105       WORD port                               
00106     );
00107 
00110     H225_Alerting_UUIE & BuildAlerting(
00111       const H323Connection & connection    
00112     );
00113 
00116     H225_Information_UUIE & BuildInformation(
00117       const H323Connection & connection    
00118     );
00119 
00122     H225_ReleaseComplete_UUIE & BuildReleaseComplete(
00123       const H323Connection & connection    
00124     );
00125 
00128     H225_Facility_UUIE * BuildFacility(
00129       const H323Connection & connection,  
00130       bool empty,                         
00131       unsigned reason = H225_FacilityReason::e_undefinedReason 
00132     );
00133 
00136     H225_Progress_UUIE & BuildProgress(
00137       const H323Connection & connection    
00138     );
00139 
00142     H225_Status_UUIE & BuildStatus(
00143       const H323Connection & connection    
00144     );
00145 
00148     H225_StatusInquiry_UUIE & BuildStatusInquiry(
00149       const H323Connection & connection    
00150     );
00151 
00154     H225_SetupAcknowledge_UUIE & BuildSetupAcknowledge(
00155       const H323Connection & connection    
00156     );
00157 
00160     H225_Notify_UUIE & BuildNotify(
00161       const H323Connection & connection    
00162     );
00164 
00165 
00170     void PrintOn(
00171       ostream & strm
00172     ) const;
00173 
00176     PBoolean Read(
00177       H323Transport & transport   
00178     );
00179 
00182     PBoolean Write(
00183       H323Transport & transport   
00184     );
00185 
00188     const Q931 & GetQ931() const { return q931pdu; }
00189 
00192     Q931 & GetQ931() { return q931pdu; }
00193 
00196     void SetQ931(const Q931 & _q931pdu) { q931pdu = _q931pdu; }
00197 
00202     void BuildQ931();
00203 
00208     PString GetSourceAliases(
00209       const H323Transport * transport = NULL  
00210     ) const;
00211 
00216     PString GetDestinationAlias(
00217       PBoolean firstAliasOnly = PFalse   
00218     ) const;
00219 
00224     PBoolean GetSourceE164(
00225       PString & number    
00226     ) const;
00227 
00232     PBoolean GetDestinationE164(
00233       PString & number    
00234     ) const;
00235 
00239     unsigned GetDistinctiveRing() const;
00240 
00245     void SetQ931Fields(
00246       const H323Connection & connection,
00247       bool insertPartyNumbers = false
00248     );
00249 
00250 #ifdef OPAL_H460
00251 
00255     void InsertH460Setup(
00256       const H323Connection & connection,
00257       H225_Setup_UUIE & setup
00258     );
00259 #endif
00260 
00261   protected:
00262     // Even though we generally deal with the H323 protocol (H225) it is
00263     // actually contained within a field of the Q931 protocol.
00264     Q931 q931pdu;
00265 };
00266 
00267 
00269 
00272 class H323ControlPDU : public H245_MultimediaSystemControlMessage
00273 {
00274   PCLASSINFO(H323ControlPDU, H245_MultimediaSystemControlMessage);
00275 
00276   public:
00277     H245_RequestMessage    & Build(H245_RequestMessage   ::Choices request);
00278     H245_ResponseMessage   & Build(H245_ResponseMessage  ::Choices response);
00279     H245_CommandMessage    & Build(H245_CommandMessage   ::Choices command);
00280     H245_IndicationMessage & Build(H245_IndicationMessage::Choices indication);
00281 
00282     H245_MasterSlaveDetermination & BuildMasterSlaveDetermination(
00283       unsigned terminalType,
00284       unsigned statusDeterminationNumber
00285     );
00286     H245_MasterSlaveDeterminationAck & BuildMasterSlaveDeterminationAck(
00287       PBoolean isMaster
00288     );
00289     H245_MasterSlaveDeterminationReject & BuildMasterSlaveDeterminationReject(
00290       unsigned cause
00291     );
00292 
00293     H245_TerminalCapabilitySet & BuildTerminalCapabilitySet(
00294       const H323Connection & connection,
00295       unsigned sequenceNumber,
00296       PBoolean empty
00297     );
00298     H245_TerminalCapabilitySetAck & BuildTerminalCapabilitySetAck(
00299       unsigned sequenceNumber
00300     );
00301     H245_TerminalCapabilitySetReject & BuildTerminalCapabilitySetReject(
00302       unsigned sequenceNumber,
00303       unsigned cause
00304     );
00305 
00306     H245_OpenLogicalChannel & BuildOpenLogicalChannel(
00307       unsigned forwardLogicalChannelNumber
00308     );
00309     H245_RequestChannelClose & BuildRequestChannelClose(
00310       unsigned channelNumber,
00311       unsigned reason
00312     );
00313     H245_CloseLogicalChannel & BuildCloseLogicalChannel(
00314       unsigned channelNumber
00315     );
00316     H245_OpenLogicalChannelAck & BuildOpenLogicalChannelAck(
00317       unsigned channelNumber
00318     );
00319     H245_OpenLogicalChannelReject & BuildOpenLogicalChannelReject(
00320       unsigned channelNumber,
00321       unsigned cause
00322     );
00323     H245_OpenLogicalChannelConfirm & BuildOpenLogicalChannelConfirm(
00324       unsigned channelNumber
00325     );
00326     H245_CloseLogicalChannelAck & BuildCloseLogicalChannelAck(
00327       unsigned channelNumber
00328     );
00329     H245_RequestChannelCloseAck & BuildRequestChannelCloseAck(
00330       unsigned channelNumber
00331     );
00332     H245_RequestChannelCloseReject & BuildRequestChannelCloseReject(
00333       unsigned channelNumber
00334     );
00335     H245_RequestChannelCloseRelease & BuildRequestChannelCloseRelease(
00336       unsigned channelNumber
00337     );
00338 
00339     H245_RequestMode & BuildRequestMode(
00340       unsigned sequenceNumber
00341     );
00342     H245_RequestModeAck & BuildRequestModeAck(
00343       unsigned sequenceNumber,
00344       unsigned response
00345     );
00346     H245_RequestModeReject & BuildRequestModeReject(
00347       unsigned sequenceNumber,
00348       unsigned cause
00349     );
00350 
00351     H245_RoundTripDelayRequest & BuildRoundTripDelayRequest(
00352       unsigned sequenceNumber
00353     );
00354     H245_RoundTripDelayResponse & BuildRoundTripDelayResponse(
00355       unsigned sequenceNumber
00356     );
00357 
00358     H245_UserInputIndication & BuildUserInputIndication(
00359       const PString & value
00360     );
00361     H245_UserInputIndication & BuildUserInputIndication(
00362       char tone,               
00363       unsigned duration,       
00364       unsigned logicalChannel, 
00365       unsigned rtpTimestamp    
00366     );
00367 
00368     H245_MiscellaneousCommand & BuildMiscellaneousCommand(
00369       unsigned channelNumber,
00370       unsigned type
00371     );
00372     
00373     H245_FlowControlCommand & BuildFlowControlCommand(
00374       unsigned channelNumber, 
00375       unsigned maxBitRate
00376     );
00377 
00378     H245_MiscellaneousIndication & BuildMiscellaneousIndication(
00379       unsigned channelNumber,
00380       unsigned type
00381     );
00382 
00383     H245_GenericMessage & BuildGenericRequest(
00384       const PString & identifier,
00385       unsigned subMsgId
00386     );
00387     H245_GenericMessage & BuildGenericResponse(
00388       const PString & identifier,
00389       unsigned subMsgId
00390     );
00391     H245_GenericMessage & BuildGenericCommand(
00392       const PString & identifier,
00393       unsigned subMsgId
00394     );
00395     H245_GenericMessage & BuildGenericIndication(
00396       const PString & identifier,
00397       unsigned subMsgId
00398     );
00399 
00400     H245_FunctionNotUnderstood & BuildFunctionNotUnderstood(
00401       const H323ControlPDU & pdu
00402     );
00403 
00404     H245_EndSessionCommand & BuildEndSessionCommand(
00405       unsigned reason
00406     );
00407 };
00408 
00409 
00411 
00414 class H323RasPDU : public H225_RasMessage, public H323TransactionPDU
00415 {
00416   PCLASSINFO(H323RasPDU, H225_RasMessage);
00417 
00418   public:
00419     H323RasPDU();
00420     H323RasPDU(
00421       const H235Authenticators & authenticators
00422     );
00423 
00424     // overrides from PObject
00425     virtual PObject * Clone() const;
00426 
00427     // overrides from H323TransactionPDU
00428     virtual PASN_Object & GetPDU();
00429     virtual PASN_Choice & GetChoice();
00430     virtual const PASN_Object & GetPDU() const;
00431     virtual const PASN_Choice & GetChoice() const;
00432     virtual unsigned GetSequenceNumber() const;
00433     virtual unsigned GetRequestInProgressDelay() const;
00434 #if PTRACING
00435     virtual const char * GetProtocolName() const;
00436 #endif
00437     virtual H323TransactionPDU * ClonePDU() const;
00438     virtual void DeletePDU();
00439 
00440     // new functions
00441     H225_GatekeeperRequest       & BuildGatekeeperRequest(unsigned seqNum);
00442     H225_GatekeeperConfirm       & BuildGatekeeperConfirm(unsigned seqNum);
00443     H225_GatekeeperReject        & BuildGatekeeperReject(unsigned seqNum, unsigned reason = H225_GatekeeperRejectReason::e_undefinedReason);
00444     H225_RegistrationRequest     & BuildRegistrationRequest(unsigned seqNum);
00445     H225_RegistrationConfirm     & BuildRegistrationConfirm(unsigned seqNum);
00446     H225_RegistrationReject      & BuildRegistrationReject(unsigned seqNum, unsigned reason = H225_RegistrationRejectReason::e_undefinedReason);
00447     H225_UnregistrationRequest   & BuildUnregistrationRequest(unsigned seqNum);
00448     H225_UnregistrationConfirm   & BuildUnregistrationConfirm(unsigned seqNum);
00449     H225_UnregistrationReject    & BuildUnregistrationReject(unsigned seqNum, unsigned reason = H225_UnregRejectReason::e_undefinedReason);
00450     H225_LocationRequest         & BuildLocationRequest(unsigned seqNum);
00451     H225_LocationConfirm         & BuildLocationConfirm(unsigned seqNum);
00452     H225_LocationReject          & BuildLocationReject(unsigned seqNum, unsigned reason = H225_LocationRejectReason::e_undefinedReason);
00453     H225_AdmissionRequest        & BuildAdmissionRequest(unsigned seqNum);
00454     H225_AdmissionConfirm        & BuildAdmissionConfirm(unsigned seqNum);
00455     H225_AdmissionReject         & BuildAdmissionReject(unsigned seqNum, unsigned reason = H225_AdmissionRejectReason::e_undefinedReason);
00456     H225_DisengageRequest        & BuildDisengageRequest(unsigned seqNum);
00457     H225_DisengageConfirm        & BuildDisengageConfirm(unsigned seqNum);
00458     H225_DisengageReject         & BuildDisengageReject(unsigned seqNum, unsigned reason = H225_DisengageRejectReason::e_securityDenial);
00459     H225_BandwidthRequest        & BuildBandwidthRequest(unsigned seqNum);
00460     H225_BandwidthConfirm        & BuildBandwidthConfirm(unsigned seqNum, unsigned bandwidth = 0);
00461     H225_BandwidthReject         & BuildBandwidthReject(unsigned seqNum, unsigned reason = H225_BandRejectReason::e_undefinedReason);
00462     H225_InfoRequest             & BuildInfoRequest(unsigned seqNum, unsigned callRef = 0, const OpalGloballyUniqueID * id = NULL);
00463     H225_InfoRequestResponse     & BuildInfoRequestResponse(unsigned seqNum);
00464     H225_InfoRequestAck          & BuildInfoRequestAck(unsigned seqNum);
00465     H225_InfoRequestNak          & BuildInfoRequestNak(unsigned seqNum, unsigned reason = H225_InfoRequestNakReason::e_undefinedReason);
00466     H225_ServiceControlIndication& BuildServiceControlIndication(unsigned seqNum, const OpalGloballyUniqueID * id = NULL);
00467     H225_ServiceControlResponse  & BuildServiceControlResponse(unsigned seqNum);
00468     H225_UnknownMessageResponse  & BuildUnknownMessageResponse(unsigned seqNum);
00469     H225_RequestInProgress       & BuildRequestInProgress(unsigned seqNum, unsigned delay);
00470 };
00471 
00472 
00474 
00475 void H323SetAliasAddresses(const H323TransportAddressArray & addresses, H225_ArrayOf_AliasAddress & aliases);
00476 void H323SetAliasAddresses(const PStringArray & names, H225_ArrayOf_AliasAddress & aliases, int tag = -1);
00477 void H323SetAliasAddresses(const PStringList & names, H225_ArrayOf_AliasAddress & aliases, int tag = -1);
00478 void H323SetAliasAddress(const H323TransportAddress & address, H225_AliasAddress & alias);
00479 void H323SetAliasAddress(const PString & name, H225_AliasAddress & alias, int tag = -1);
00480 PStringArray H323GetAliasAddressStrings(const H225_ArrayOf_AliasAddress & aliases);
00481 PString H323GetAliasAddressString(const H225_AliasAddress & alias);
00482 PString H323GetAliasAddressE164(const H225_AliasAddress & alias);
00483 PString H323GetAliasAddressE164(const H225_ArrayOf_AliasAddress & aliases);
00484 
00485 H323Connection::CallEndReason H323TranslateToCallEndReason(
00486   Q931::CauseValues cause,
00487   unsigned reason
00488 );
00489 Q931::CauseValues H323TranslateFromCallEndReason(
00490   H323Connection::CallEndReason callEndReason,
00491   H225_ReleaseCompleteReason & releaseCompleteReason
00492 );
00493 
00494 void H323GetApplicationInfo(OpalProductInfo & info, const H225_VendorIdentifier & vendor);
00495 
00496 void H323SetRTPPacketization(
00497   H245_ArrayOf_RTPPayloadType & rtpPacketizations,
00498   PINDEX & packetizationsCount,
00499   const OpalMediaFormat & mediaFormat,
00500   RTP_DataFrame::PayloadTypes payloadType
00501 );
00502 bool H323SetRTPPacketization(
00503   H245_RTPPayloadType & rtpPacketization,
00504   const OpalMediaFormat & mediaFormat,
00505   RTP_DataFrame::PayloadTypes payloadType
00506 );
00507 bool H323SetRTPPacketization(
00508   H245_RTPPayloadType & rtpPacketization,
00509   const PString & mediaPacketizationString,
00510   const OpalMediaFormat & mediaFormat,
00511   RTP_DataFrame::PayloadTypes payloadType
00512 );
00513 PString H323GetRTPPacketization(
00514   const H245_RTPPayloadType & rtpPacketization
00515 );
00516 bool H323GetRTPPacketization(
00517   OpalMediaFormat & mediaFormat,
00518   const H245_RTPPayloadType & rtpPacketization
00519 );
00520 
00521 PString H323GetCapabilityIdentifier(
00522   const H245_CapabilityIdentifier & capId
00523 );
00524 bool H323SetCapabilityIdentifier(
00525   const PString & str,
00526   H245_CapabilityIdentifier & capId
00527 );
00528 
00529 const H245_ParameterValue * H323GetGenericParameter(
00530   const H245_ArrayOf_GenericParameter & params,
00531   unsigned ordinal
00532 );
00533 bool H323GetGenericParameterBoolean(
00534   const H245_ArrayOf_GenericParameter & params,
00535   unsigned ordinal
00536 );
00537 unsigned H323GetGenericParameterInteger(
00538   const H245_ArrayOf_GenericParameter & params,
00539   unsigned ordinal,
00540   unsigned defValue = 0,
00541   H245_ParameterValue::Choices subType = H245_ParameterValue::e_unsignedMin
00542 );
00543 H245_ParameterValue * H323AddGenericParameter(
00544   H245_ArrayOf_GenericParameter & params,
00545   unsigned ordinal,
00546   bool reorder = true
00547 );
00548 void H323AddGenericParameterBoolean(
00549   H245_ArrayOf_GenericParameter & params,
00550   unsigned ordinal,
00551   bool value = true,
00552   bool reorder = true
00553 );
00554 void H323AddGenericParameterInteger(
00555   H245_ArrayOf_GenericParameter & params,
00556   unsigned ordinal,
00557   unsigned value,
00558   H245_ParameterValue::Choices subType = H245_ParameterValue::e_unsignedMin,
00559   bool reorder = true
00560 );
00561 void H323AddGenericParameterString(
00562   H245_ArrayOf_GenericParameter & params,
00563   unsigned ordinal,
00564   const PString & value,
00565   bool reorder = true
00566 );
00567 void H323AddGenericParameterOctets(
00568   H245_ArrayOf_GenericParameter & params,
00569   unsigned ordinal,
00570   const PBYTEArray & value,
00571   bool reorder = true
00572 );
00573 
00574 #if PTRACING
00575 void H323TraceDumpPDU(
00576   const char * proto,
00577   PBoolean writing,
00578   const PBYTEArray & rawData,
00579   const PASN_Object & pdu,
00580   const PASN_Choice & tag1,
00581   unsigned seqNum
00582 );
00583 #else
00584 #define H323TraceDumpPDU(proto, writing, rawData, pdu, tag1, seqNum)
00585 #endif
00586 
00587 
00588 #endif // OPAL_H323
00589 
00590 #endif // OPAL_H323_H323PDU_H
00591 
00592 

Generated on Mon Feb 21 20:19:20 2011 for OPAL by  doxygen 1.4.7