OPAL  Version 3.14.3
h323pdu.h
Go to the documentation of this file.
1 /*
2  * h323pdu.h
3  *
4  * H.323 protocol handler
5  *
6  * Open H323 Library
7  *
8  * Copyright (c) 1998-2001 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open H323 Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions of this code were written with the assisance of funding from
25  * Vovida Networks, Inc. http://www.vovida.com.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 30945 $
30  * $Author: rjongbloed $
31  * $Date: 2013-11-22 13:25:05 +1100 (Fri, 22 Nov 2013) $
32  */
33 
34 #ifndef OPAL_H323_H323PDU_H
35 #define OPAL_H323_H323PDU_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <opal_config.h>
42 
43 #if OPAL_H323
44 
45 #include <ptlib/sockets.h>
46 #include <h323/h323con.h>
47 #include <h323/transaddr.h>
48 #include <h323/q931.h>
49 #include <h323/h235auth.h>
50 #include <h323/h323trans.h>
51 #include <rtp/rtp.h>
52 #include <asn/h225.h>
53 #include <asn/h245.h>
54 
55 
56 class H323Connection;
58 class H225_RAS;
60 
61 
62 #define H225_PROTOCOL_VERSION 6
63 #define H245_PROTOCOL_VERSION 13
64 
65 
67 
70 class H323SignalPDU : public H225_H323_UserInformation
71 {
72  PCLASSINFO(H323SignalPDU, H225_H323_UserInformation);
73 
74  public:
79  H323SignalPDU();
80 
83  H225_Setup_UUIE & BuildSetup(
84  const H323Connection & connection,
85  const H323TransportAddress & destAddr
86  );
87 
90  H225_CallProceeding_UUIE & BuildCallProceeding(
91  const H323Connection & connection
92  );
93 
96  H225_Connect_UUIE & BuildConnect(
97  const H323Connection & connection
98  );
99 
102  H225_Alerting_UUIE & BuildAlerting(
103  const H323Connection & connection
104  );
105 
108  H225_Information_UUIE & BuildInformation(
109  const H323Connection & connection
110  );
111 
114  H225_ReleaseComplete_UUIE & BuildReleaseComplete(
115  const H323Connection & connection
116  );
117 
120  H225_Facility_UUIE * BuildFacility(
121  const H323Connection & connection,
122  bool empty,
123  unsigned reason = H225_FacilityReason::e_undefinedReason
124  );
125 
128  H225_Facility_UUIE & BuildFacility(
129  const OpalGloballyUniqueID & callId
130  );
131 
134  H225_Progress_UUIE & BuildProgress(
135  const H323Connection & connection
136  );
137 
140  H225_Status_UUIE & BuildStatus(
141  const H323Connection & connection
142  );
143 
146  H225_StatusInquiry_UUIE & BuildStatusInquiry(
147  const H323Connection & connection
148  );
149 
152  H225_SetupAcknowledge_UUIE & BuildSetupAcknowledge(
153  const H323Connection & connection
154  );
155 
158  H225_Notify_UUIE & BuildNotify(
159  const H323Connection & connection
160  );
162 
163 
168  void PrintOn(
169  ostream & strm
170  ) const;
171 
174  PBoolean Read(
175  H323Transport & transport
176  );
177 
180  PBoolean Write(
181  H323Transport & transport
182  );
183 
186  const Q931 & GetQ931() const { return q931pdu; }
187 
190  Q931 & GetQ931() { return q931pdu; }
191 
194  void SetQ931(const Q931 & _q931pdu) { q931pdu = _q931pdu; }
195 
200  void BuildQ931();
201 
206  PString GetSourceAliases(
207  const H323Transport * transport = NULL
208  ) const;
209 
214  PString GetDestinationAlias(
215  PBoolean firstAliasOnly = false
216  ) const;
217 
222  PBoolean GetSourceE164(
223  PString & number
224  ) const;
225 
230  PBoolean GetDestinationE164(
231  PString & number
232  ) const;
233 
237  unsigned GetDistinctiveRing() const;
238 
243  void SetQ931Fields(
244  const H323Connection & connection,
245  bool insertPartyNumbers = false
246  );
247 
248  protected:
249  // Even though we generally deal with the H323 protocol (H225) it is
250  // actually contained within a field of the Q931 protocol.
252 };
253 
254 
256 
259 class H323ControlPDU : public H245_MultimediaSystemControlMessage
260 {
261  PCLASSINFO(H323ControlPDU, H245_MultimediaSystemControlMessage);
262 
263  public:
264  H245_RequestMessage & Build(H245_RequestMessage ::Choices request);
265  H245_ResponseMessage & Build(H245_ResponseMessage ::Choices response);
266  H245_CommandMessage & Build(H245_CommandMessage ::Choices command);
267  H245_IndicationMessage & Build(H245_IndicationMessage::Choices indication);
268 
269  H245_MasterSlaveDetermination & BuildMasterSlaveDetermination(
270  unsigned terminalType,
271  unsigned statusDeterminationNumber
272  );
273  H245_MasterSlaveDeterminationAck & BuildMasterSlaveDeterminationAck(
274  PBoolean isMaster
275  );
276  H245_MasterSlaveDeterminationReject & BuildMasterSlaveDeterminationReject(
277  unsigned cause
278  );
279 
280  H245_TerminalCapabilitySet & BuildTerminalCapabilitySet(
281  const H323Connection & connection,
282  unsigned sequenceNumber,
283  PBoolean empty
284  );
285  H245_TerminalCapabilitySetAck & BuildTerminalCapabilitySetAck(
286  unsigned sequenceNumber
287  );
288  H245_TerminalCapabilitySetReject & BuildTerminalCapabilitySetReject(
289  unsigned sequenceNumber,
290  unsigned cause
291  );
292 
293  H245_OpenLogicalChannel & BuildOpenLogicalChannel(
294  unsigned forwardLogicalChannelNumber
295  );
296  H245_RequestChannelClose & BuildRequestChannelClose(
297  unsigned channelNumber,
298  unsigned reason
299  );
300  H245_CloseLogicalChannel & BuildCloseLogicalChannel(
301  unsigned channelNumber
302  );
303  H245_OpenLogicalChannelAck & BuildOpenLogicalChannelAck(
304  unsigned channelNumber
305  );
306  H245_OpenLogicalChannelReject & BuildOpenLogicalChannelReject(
307  unsigned channelNumber,
308  unsigned cause
309  );
310  H245_OpenLogicalChannelConfirm & BuildOpenLogicalChannelConfirm(
311  unsigned channelNumber
312  );
313  H245_CloseLogicalChannelAck & BuildCloseLogicalChannelAck(
314  unsigned channelNumber
315  );
316  H245_RequestChannelCloseAck & BuildRequestChannelCloseAck(
317  unsigned channelNumber
318  );
319  H245_RequestChannelCloseReject & BuildRequestChannelCloseReject(
320  unsigned channelNumber
321  );
322  H245_RequestChannelCloseRelease & BuildRequestChannelCloseRelease(
323  unsigned channelNumber
324  );
325 
326  H245_RequestMode & BuildRequestMode(
327  unsigned sequenceNumber
328  );
329  H245_RequestModeAck & BuildRequestModeAck(
330  unsigned sequenceNumber,
331  unsigned response
332  );
333  H245_RequestModeReject & BuildRequestModeReject(
334  unsigned sequenceNumber,
335  unsigned cause
336  );
337 
338  H245_RoundTripDelayRequest & BuildRoundTripDelayRequest(
339  unsigned sequenceNumber
340  );
341  H245_RoundTripDelayResponse & BuildRoundTripDelayResponse(
342  unsigned sequenceNumber
343  );
344 
345  H245_UserInputIndication & BuildUserInputIndication(
346  const PString & value
347  );
348  H245_UserInputIndication & BuildUserInputIndication(
349  char tone,
350  unsigned duration,
351  unsigned logicalChannel,
352  unsigned rtpTimestamp
353  );
354 
355  H245_MiscellaneousCommand & BuildMiscellaneousCommand(
356  unsigned channelNumber,
357  unsigned type
358  );
359 
360  H245_FlowControlCommand & BuildFlowControlCommand(
361  unsigned channelNumber,
362  unsigned maxBitRate
363  );
364 
365  H245_MiscellaneousIndication & BuildMiscellaneousIndication(
366  unsigned channelNumber,
367  unsigned type
368  );
369 
370  H245_GenericMessage & BuildGenericRequest(
371  const PString & identifier,
372  unsigned subMsgId
373  );
374  H245_GenericMessage & BuildGenericResponse(
375  const PString & identifier,
376  unsigned subMsgId
377  );
378  H245_GenericMessage & BuildGenericCommand(
379  const PString & identifier,
380  unsigned subMsgId
381  );
382  H245_GenericMessage & BuildGenericIndication(
383  const PString & identifier,
384  unsigned subMsgId
385  );
386 
387  H245_FunctionNotUnderstood & BuildFunctionNotUnderstood(
388  const H323ControlPDU & pdu
389  );
390 
391  H245_EndSessionCommand & BuildEndSessionCommand(
392  unsigned reason
393  );
394 };
395 
396 
398 
401 class H323RasPDU : public H225_RasMessage, public H323TransactionPDU
402 {
403  PCLASSINFO(H323RasPDU, H225_RasMessage);
404 
405  public:
406  H323RasPDU();
407  H323RasPDU(
408  const H235Authenticators & authenticators
409  );
410 
411  // overrides from PObject
412  virtual PObject * Clone() const;
413 
414  // overrides from H323TransactionPDU
415  virtual PASN_Object & GetPDU();
416  virtual PASN_Choice & GetChoice();
417  virtual const PASN_Object & GetPDU() const;
418  virtual const PASN_Choice & GetChoice() const;
419  virtual unsigned GetSequenceNumber() const;
420  virtual unsigned GetRequestInProgressDelay() const;
421 #if PTRACING
422  virtual const char * GetProtocolName() const;
423 #endif
424  virtual H323TransactionPDU * ClonePDU() const;
425  virtual void DeletePDU();
426 
428 
429  // new functions
430  H225_GatekeeperRequest & BuildGatekeeperRequest(unsigned seqNum);
431  H225_GatekeeperConfirm & BuildGatekeeperConfirm(unsigned seqNum);
432  H225_GatekeeperReject & BuildGatekeeperReject(unsigned seqNum, unsigned reason = H225_GatekeeperRejectReason::e_undefinedReason);
433  H225_RegistrationRequest & BuildRegistrationRequest(unsigned seqNum);
434  H225_RegistrationConfirm & BuildRegistrationConfirm(unsigned seqNum);
435  H225_RegistrationReject & BuildRegistrationReject(unsigned seqNum, unsigned reason = H225_RegistrationRejectReason::e_undefinedReason);
436  H225_UnregistrationRequest & BuildUnregistrationRequest(unsigned seqNum);
437  H225_UnregistrationConfirm & BuildUnregistrationConfirm(unsigned seqNum);
438  H225_UnregistrationReject & BuildUnregistrationReject(unsigned seqNum, unsigned reason = H225_UnregRejectReason::e_undefinedReason);
439  H225_LocationRequest & BuildLocationRequest(unsigned seqNum);
440  H225_LocationConfirm & BuildLocationConfirm(unsigned seqNum);
441  H225_LocationReject & BuildLocationReject(unsigned seqNum, unsigned reason = H225_LocationRejectReason::e_undefinedReason);
442  H225_AdmissionRequest & BuildAdmissionRequest(unsigned seqNum);
443  H225_AdmissionConfirm & BuildAdmissionConfirm(unsigned seqNum);
444  H225_AdmissionReject & BuildAdmissionReject(unsigned seqNum, unsigned reason = H225_AdmissionRejectReason::e_undefinedReason);
445  H225_DisengageRequest & BuildDisengageRequest(unsigned seqNum);
446  H225_DisengageConfirm & BuildDisengageConfirm(unsigned seqNum);
447  H225_DisengageReject & BuildDisengageReject(unsigned seqNum, unsigned reason = H225_DisengageRejectReason::e_securityDenial);
448  H225_BandwidthRequest & BuildBandwidthRequest(unsigned seqNum);
449  H225_BandwidthConfirm & BuildBandwidthConfirm(unsigned seqNum, unsigned bandwidth = 0);
450  H225_BandwidthReject & BuildBandwidthReject(unsigned seqNum, unsigned reason = H225_BandRejectReason::e_undefinedReason);
451  H225_InfoRequest & BuildInfoRequest(unsigned seqNum, unsigned callRef = 0, const OpalGloballyUniqueID * id = NULL);
452  H225_InfoRequestResponse & BuildInfoRequestResponse(unsigned seqNum);
453  H225_InfoRequestAck & BuildInfoRequestAck(unsigned seqNum);
454  H225_InfoRequestNak & BuildInfoRequestNak(unsigned seqNum, unsigned reason = H225_InfoRequestNakReason::e_undefinedReason);
455  H225_ServiceControlIndication& BuildServiceControlIndication(unsigned seqNum, const OpalGloballyUniqueID * id = NULL);
456  H225_ServiceControlResponse & BuildServiceControlResponse(unsigned seqNum);
457  H225_UnknownMessageResponse & BuildUnknownMessageResponse(unsigned seqNum);
458  H225_RequestInProgress & BuildRequestInProgress(unsigned seqNum, unsigned delay);
459 };
460 
461 
463 
464 void H323SetAliasAddresses(const H323TransportAddressArray & addresses, H225_ArrayOf_AliasAddress & aliases);
465 void H323SetAliasAddresses(const PStringArray & names, H225_ArrayOf_AliasAddress & aliases, int tag = -1);
466 void H323SetAliasAddresses(const PStringList & names, H225_ArrayOf_AliasAddress & aliases, int tag = -1);
467 void H323SetAliasAddress(const H323TransportAddress & address, H225_AliasAddress & alias);
468 void H323SetAliasAddress(const PString & name, H225_AliasAddress & alias, int tag = -1);
469 PStringArray H323GetAliasAddressStrings(const H225_ArrayOf_AliasAddress & aliases);
470 PString H323GetAliasAddressString(const H225_AliasAddress & alias);
471 PString H323GetAliasAddressE164(const H225_AliasAddress & alias);
472 PString H323GetAliasAddressE164(const H225_ArrayOf_AliasAddress & aliases);
473 
475  Q931::CauseValues cause,
476  unsigned reason
477 );
479  H323Connection::CallEndReason callEndReason,
480  H225_ReleaseCompleteReason & releaseCompleteReason
481 );
482 
483 void H323GetApplicationInfo(OpalProductInfo & info, const H225_VendorIdentifier & vendor);
484 
486  H245_ArrayOf_RTPPayloadType & rtpPacketizations,
487  const PStringSet & mediaPacketizations
488 );
490  H245_RTPPayloadType & rtpPacketization,
491  const OpalMediaFormat & mediaFormat,
492  RTP_DataFrame::PayloadTypes payloadType
493 );
495  H245_RTPPayloadType & rtpPacketization,
496  const PString & mediaPacketizationString,
497  RTP_DataFrame::PayloadTypes payloadType
498 );
500  const H245_RTPPayloadType & rtpPacketization
501 );
502 
504  const H245_CapabilityIdentifier & capId
505 );
507  const PString & str,
508  H245_CapabilityIdentifier & capId
509 );
510 
511 const H245_ParameterValue * H323GetGenericParameter(
512  const H245_ArrayOf_GenericParameter & params,
513  unsigned ordinal
514 );
516  const H245_ArrayOf_GenericParameter & params,
517  unsigned ordinal
518 );
520  const H245_ArrayOf_GenericParameter & params,
521  unsigned ordinal,
522  unsigned defValue = 0,
523  H245_ParameterValue::Choices subType = H245_ParameterValue::e_unsignedMin
524 );
526  const H245_ArrayOf_GenericParameter & params,
527  unsigned ordinal,
528  PASN_Object & object
529 );
530 H245_ParameterValue & H323AddGenericParameter(
531  H245_ArrayOf_GenericParameter & params,
532  unsigned ordinal,
533  H245_ParameterValue::Choices tag
534 );
535 template <class CLS> CLS & H323AddGenericParameterAs(
536  H245_ArrayOf_GenericParameter & params,
537  unsigned ordinal,
538  H245_ParameterValue::Choices tag
539 ) { return (CLS &)H323AddGenericParameter(params, ordinal, tag); }
541  H245_ArrayOf_GenericParameter & params,
542  unsigned ordinal,
543  bool value
544 );
546  H245_ArrayOf_GenericParameter & params,
547  unsigned ordinal,
548  unsigned value,
549  H245_ParameterValue::Choices subType
550 );
552  H245_ArrayOf_GenericParameter & params,
553  unsigned ordinal,
554  const PString & value
555 );
557  H245_ArrayOf_GenericParameter & params,
558  unsigned ordinal,
559  const PBYTEArray & value
560 );
562  H245_ArrayOf_GenericParameter & params,
563  unsigned ordinal,
564  const PASN_Object & object
565 );
566 
567 #if PTRACING
568 void H323TraceDumpPDU(
569  const char * proto,
570  PBoolean writing,
571  const PBYTEArray & rawData,
572  const PASN_Object & pdu,
573  const PASN_Choice & tag1,
574  unsigned seqNum
575 );
576 #else
577 #define H323TraceDumpPDU(proto, writing, rawData, pdu, tag1, seqNum)
578 #endif
579 
580 
581 #endif // OPAL_H323
582 
583 #endif // OPAL_H323_H323PDU_H
584 
585