OPAL  Version 3.12.5
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: 28394 $
30  * $Author: rjongbloed $
31  * $Date: 2012-09-24 00:17:07 -0500 (Mon, 24 Sep 2012) $
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/buildopts.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_Connect_UUIE & BuildConnect(
103  const H323Connection & connection,
104  const PIPSocket::Address & h245Address,
105  WORD port
106  );
107 
110  H225_Alerting_UUIE & BuildAlerting(
111  const H323Connection & connection
112  );
113 
116  H225_Information_UUIE & BuildInformation(
117  const H323Connection & connection
118  );
119 
122  H225_ReleaseComplete_UUIE & BuildReleaseComplete(
123  const H323Connection & connection
124  );
125 
128  H225_Facility_UUIE * BuildFacility(
129  const H323Connection & connection,
130  bool empty,
131  unsigned reason = H225_FacilityReason::e_undefinedReason
132  );
133 
136  H225_Progress_UUIE & BuildProgress(
137  const H323Connection & connection
138  );
139 
142  H225_Status_UUIE & BuildStatus(
143  const H323Connection & connection
144  );
145 
148  H225_StatusInquiry_UUIE & BuildStatusInquiry(
149  const H323Connection & connection
150  );
151 
154  H225_SetupAcknowledge_UUIE & BuildSetupAcknowledge(
155  const H323Connection & connection
156  );
157 
160  H225_Notify_UUIE & BuildNotify(
161  const H323Connection & connection
162  );
164 
165 
170  void PrintOn(
171  ostream & strm
172  ) const;
173 
176  PBoolean Read(
177  H323Transport & transport
178  );
179 
182  PBoolean Write(
183  H323Transport & transport
184  );
185 
188  const Q931 & GetQ931() const { return q931pdu; }
189 
192  Q931 & GetQ931() { return q931pdu; }
193 
196  void SetQ931(const Q931 & _q931pdu) { q931pdu = _q931pdu; }
197 
202  void BuildQ931();
203 
208  PString GetSourceAliases(
209  const H323Transport * transport = NULL
210  ) const;
211 
216  PString GetDestinationAlias(
217  PBoolean firstAliasOnly = false
218  ) const;
219 
224  PBoolean GetSourceE164(
225  PString & number
226  ) const;
227 
232  PBoolean GetDestinationE164(
233  PString & number
234  ) const;
235 
239  unsigned GetDistinctiveRing() const;
240 
245  void SetQ931Fields(
246  const H323Connection & connection,
247  bool insertPartyNumbers = false
248  );
249 
250 #ifdef OPAL_H460
251 
255  void InsertH460Setup(
256  const H323Connection & connection,
257  H225_Setup_UUIE & setup
258  );
259 #endif
260 
261  protected:
262  // Even though we generally deal with the H323 protocol (H225) it is
263  // actually contained within a field of the Q931 protocol.
265 };
266 
267 
269 
272 class H323ControlPDU : public H245_MultimediaSystemControlMessage
273 {
274  PCLASSINFO(H323ControlPDU, H245_MultimediaSystemControlMessage);
275 
276  public:
277  H245_RequestMessage & Build(H245_RequestMessage ::Choices request);
278  H245_ResponseMessage & Build(H245_ResponseMessage ::Choices response);
279  H245_CommandMessage & Build(H245_CommandMessage ::Choices command);
280  H245_IndicationMessage & Build(H245_IndicationMessage::Choices indication);
281 
282  H245_MasterSlaveDetermination & BuildMasterSlaveDetermination(
283  unsigned terminalType,
284  unsigned statusDeterminationNumber
285  );
286  H245_MasterSlaveDeterminationAck & BuildMasterSlaveDeterminationAck(
287  PBoolean isMaster
288  );
289  H245_MasterSlaveDeterminationReject & BuildMasterSlaveDeterminationReject(
290  unsigned cause
291  );
292 
293  H245_TerminalCapabilitySet & BuildTerminalCapabilitySet(
294  const H323Connection & connection,
295  unsigned sequenceNumber,
296  PBoolean empty
297  );
298  H245_TerminalCapabilitySetAck & BuildTerminalCapabilitySetAck(
299  unsigned sequenceNumber
300  );
301  H245_TerminalCapabilitySetReject & BuildTerminalCapabilitySetReject(
302  unsigned sequenceNumber,
303  unsigned cause
304  );
305 
306  H245_OpenLogicalChannel & BuildOpenLogicalChannel(
307  unsigned forwardLogicalChannelNumber
308  );
309  H245_RequestChannelClose & BuildRequestChannelClose(
310  unsigned channelNumber,
311  unsigned reason
312  );
313  H245_CloseLogicalChannel & BuildCloseLogicalChannel(
314  unsigned channelNumber
315  );
316  H245_OpenLogicalChannelAck & BuildOpenLogicalChannelAck(
317  unsigned channelNumber
318  );
319  H245_OpenLogicalChannelReject & BuildOpenLogicalChannelReject(
320  unsigned channelNumber,
321  unsigned cause
322  );
323  H245_OpenLogicalChannelConfirm & BuildOpenLogicalChannelConfirm(
324  unsigned channelNumber
325  );
326  H245_CloseLogicalChannelAck & BuildCloseLogicalChannelAck(
327  unsigned channelNumber
328  );
329  H245_RequestChannelCloseAck & BuildRequestChannelCloseAck(
330  unsigned channelNumber
331  );
332  H245_RequestChannelCloseReject & BuildRequestChannelCloseReject(
333  unsigned channelNumber
334  );
335  H245_RequestChannelCloseRelease & BuildRequestChannelCloseRelease(
336  unsigned channelNumber
337  );
338 
339  H245_RequestMode & BuildRequestMode(
340  unsigned sequenceNumber
341  );
342  H245_RequestModeAck & BuildRequestModeAck(
343  unsigned sequenceNumber,
344  unsigned response
345  );
346  H245_RequestModeReject & BuildRequestModeReject(
347  unsigned sequenceNumber,
348  unsigned cause
349  );
350 
351  H245_RoundTripDelayRequest & BuildRoundTripDelayRequest(
352  unsigned sequenceNumber
353  );
354  H245_RoundTripDelayResponse & BuildRoundTripDelayResponse(
355  unsigned sequenceNumber
356  );
357 
358  H245_UserInputIndication & BuildUserInputIndication(
359  const PString & value
360  );
361  H245_UserInputIndication & BuildUserInputIndication(
362  char tone,
363  unsigned duration,
364  unsigned logicalChannel,
365  unsigned rtpTimestamp
366  );
367 
368  H245_MiscellaneousCommand & BuildMiscellaneousCommand(
369  unsigned channelNumber,
370  unsigned type
371  );
372 
373  H245_FlowControlCommand & BuildFlowControlCommand(
374  unsigned channelNumber,
375  unsigned maxBitRate
376  );
377 
378  H245_MiscellaneousIndication & BuildMiscellaneousIndication(
379  unsigned channelNumber,
380  unsigned type
381  );
382 
383  H245_GenericMessage & BuildGenericRequest(
384  const PString & identifier,
385  unsigned subMsgId
386  );
387  H245_GenericMessage & BuildGenericResponse(
388  const PString & identifier,
389  unsigned subMsgId
390  );
391  H245_GenericMessage & BuildGenericCommand(
392  const PString & identifier,
393  unsigned subMsgId
394  );
395  H245_GenericMessage & BuildGenericIndication(
396  const PString & identifier,
397  unsigned subMsgId
398  );
399 
400  H245_FunctionNotUnderstood & BuildFunctionNotUnderstood(
401  const H323ControlPDU & pdu
402  );
403 
404  H245_EndSessionCommand & BuildEndSessionCommand(
405  unsigned reason
406  );
407 };
408 
409 
411 
414 class H323RasPDU : public H225_RasMessage, public H323TransactionPDU
415 {
416  PCLASSINFO(H323RasPDU, H225_RasMessage);
417 
418  public:
419  H323RasPDU();
420  H323RasPDU(
421  const H235Authenticators & authenticators
422  );
423 
424  // overrides from PObject
425  virtual PObject * Clone() const;
426 
427  // overrides from H323TransactionPDU
428  virtual PASN_Object & GetPDU();
429  virtual PASN_Choice & GetChoice();
430  virtual const PASN_Object & GetPDU() const;
431  virtual const PASN_Choice & GetChoice() const;
432  virtual unsigned GetSequenceNumber() const;
433  virtual unsigned GetRequestInProgressDelay() const;
434 #if PTRACING
435  virtual const char * GetProtocolName() const;
436 #endif
437  virtual H323TransactionPDU * ClonePDU() const;
438  virtual void DeletePDU();
439 
441 
442  // new functions
443  H225_GatekeeperRequest & BuildGatekeeperRequest(unsigned seqNum);
444  H225_GatekeeperConfirm & BuildGatekeeperConfirm(unsigned seqNum);
445  H225_GatekeeperReject & BuildGatekeeperReject(unsigned seqNum, unsigned reason = H225_GatekeeperRejectReason::e_undefinedReason);
446  H225_RegistrationRequest & BuildRegistrationRequest(unsigned seqNum);
447  H225_RegistrationConfirm & BuildRegistrationConfirm(unsigned seqNum);
448  H225_RegistrationReject & BuildRegistrationReject(unsigned seqNum, unsigned reason = H225_RegistrationRejectReason::e_undefinedReason);
449  H225_UnregistrationRequest & BuildUnregistrationRequest(unsigned seqNum);
450  H225_UnregistrationConfirm & BuildUnregistrationConfirm(unsigned seqNum);
451  H225_UnregistrationReject & BuildUnregistrationReject(unsigned seqNum, unsigned reason = H225_UnregRejectReason::e_undefinedReason);
452  H225_LocationRequest & BuildLocationRequest(unsigned seqNum);
453  H225_LocationConfirm & BuildLocationConfirm(unsigned seqNum);
454  H225_LocationReject & BuildLocationReject(unsigned seqNum, unsigned reason = H225_LocationRejectReason::e_undefinedReason);
455  H225_AdmissionRequest & BuildAdmissionRequest(unsigned seqNum);
456  H225_AdmissionConfirm & BuildAdmissionConfirm(unsigned seqNum);
457  H225_AdmissionReject & BuildAdmissionReject(unsigned seqNum, unsigned reason = H225_AdmissionRejectReason::e_undefinedReason);
458  H225_DisengageRequest & BuildDisengageRequest(unsigned seqNum);
459  H225_DisengageConfirm & BuildDisengageConfirm(unsigned seqNum);
460  H225_DisengageReject & BuildDisengageReject(unsigned seqNum, unsigned reason = H225_DisengageRejectReason::e_securityDenial);
461  H225_BandwidthRequest & BuildBandwidthRequest(unsigned seqNum);
462  H225_BandwidthConfirm & BuildBandwidthConfirm(unsigned seqNum, unsigned bandwidth = 0);
463  H225_BandwidthReject & BuildBandwidthReject(unsigned seqNum, unsigned reason = H225_BandRejectReason::e_undefinedReason);
464  H225_InfoRequest & BuildInfoRequest(unsigned seqNum, unsigned callRef = 0, const OpalGloballyUniqueID * id = NULL);
465  H225_InfoRequestResponse & BuildInfoRequestResponse(unsigned seqNum);
466  H225_InfoRequestAck & BuildInfoRequestAck(unsigned seqNum);
467  H225_InfoRequestNak & BuildInfoRequestNak(unsigned seqNum, unsigned reason = H225_InfoRequestNakReason::e_undefinedReason);
468  H225_ServiceControlIndication& BuildServiceControlIndication(unsigned seqNum, const OpalGloballyUniqueID * id = NULL);
469  H225_ServiceControlResponse & BuildServiceControlResponse(unsigned seqNum);
470  H225_UnknownMessageResponse & BuildUnknownMessageResponse(unsigned seqNum);
471  H225_RequestInProgress & BuildRequestInProgress(unsigned seqNum, unsigned delay);
472 };
473 
474 
476 
477 void H323SetAliasAddresses(const H323TransportAddressArray & addresses, H225_ArrayOf_AliasAddress & aliases);
478 void H323SetAliasAddresses(const PStringArray & names, H225_ArrayOf_AliasAddress & aliases, int tag = -1);
479 void H323SetAliasAddresses(const PStringList & names, H225_ArrayOf_AliasAddress & aliases, int tag = -1);
480 void H323SetAliasAddress(const H323TransportAddress & address, H225_AliasAddress & alias);
481 void H323SetAliasAddress(const PString & name, H225_AliasAddress & alias, int tag = -1);
482 PStringArray H323GetAliasAddressStrings(const H225_ArrayOf_AliasAddress & aliases);
483 PString H323GetAliasAddressString(const H225_AliasAddress & alias);
484 PString H323GetAliasAddressE164(const H225_AliasAddress & alias);
485 PString H323GetAliasAddressE164(const H225_ArrayOf_AliasAddress & aliases);
486 
488  Q931::CauseValues cause,
489  unsigned reason
490 );
492  H323Connection::CallEndReason callEndReason,
493  H225_ReleaseCompleteReason & releaseCompleteReason
494 );
495 
496 void H323GetApplicationInfo(OpalProductInfo & info, const H225_VendorIdentifier & vendor);
497 
499  H245_ArrayOf_RTPPayloadType & rtpPacketizations,
500  const PStringSet & mediaPacketizations
501 );
503  H245_RTPPayloadType & rtpPacketization,
504  const OpalMediaFormat & mediaFormat,
505  RTP_DataFrame::PayloadTypes payloadType
506 );
508  H245_RTPPayloadType & rtpPacketization,
509  const PString & mediaPacketizationString,
510  RTP_DataFrame::PayloadTypes payloadType
511 );
513  const H245_RTPPayloadType & rtpPacketization
514 );
515 
517  const H245_CapabilityIdentifier & capId
518 );
520  const PString & str,
521  H245_CapabilityIdentifier & capId
522 );
523 
524 const H245_ParameterValue * H323GetGenericParameter(
525  const H245_ArrayOf_GenericParameter & params,
526  unsigned ordinal
527 );
529  const H245_ArrayOf_GenericParameter & params,
530  unsigned ordinal
531 );
533  const H245_ArrayOf_GenericParameter & params,
534  unsigned ordinal,
535  unsigned defValue = 0,
536  H245_ParameterValue::Choices subType = H245_ParameterValue::e_unsignedMin
537 );
538 H245_ParameterValue * H323AddGenericParameter(
539  H245_ArrayOf_GenericParameter & params,
540  unsigned ordinal
541 );
543  H245_ArrayOf_GenericParameter & params,
544  unsigned ordinal,
545  bool value
546 );
548  H245_ArrayOf_GenericParameter & params,
549  unsigned ordinal,
550  unsigned value,
551  H245_ParameterValue::Choices subType
552 );
554  H245_ArrayOf_GenericParameter & params,
555  unsigned ordinal,
556  const PString & value
557 );
559  H245_ArrayOf_GenericParameter & params,
560  unsigned ordinal,
561  const PBYTEArray & value
562 );
563 
564 #if PTRACING
565 void H323TraceDumpPDU(
566  const char * proto,
567  PBoolean writing,
568  const PBYTEArray & rawData,
569  const PASN_Object & pdu,
570  const PASN_Choice & tag1,
571  unsigned seqNum
572 );
573 #else
574 #define H323TraceDumpPDU(proto, writing, rawData, pdu, tag1, seqNum)
575 #endif
576 
577 
578 #endif // OPAL_H323
579 
580 #endif // OPAL_H323_H323PDU_H
581 
582