OPAL  Version 3.12.9
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: 30322 $
30  * $Author: rjongbloed $
31  * $Date: 2013-08-16 10:43:01 +1000 (Fri, 16 Aug 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/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_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_Progress_UUIE & BuildProgress(
129  const H323Connection & connection
130  );
131 
134  H225_Status_UUIE & BuildStatus(
135  const H323Connection & connection
136  );
137 
140  H225_StatusInquiry_UUIE & BuildStatusInquiry(
141  const H323Connection & connection
142  );
143 
146  H225_SetupAcknowledge_UUIE & BuildSetupAcknowledge(
147  const H323Connection & connection
148  );
149 
152  H225_Notify_UUIE & BuildNotify(
153  const H323Connection & connection
154  );
156 
157 
162  void PrintOn(
163  ostream & strm
164  ) const;
165 
168  PBoolean Read(
169  H323Transport & transport
170  );
171 
174  PBoolean Write(
175  H323Transport & transport
176  );
177 
180  const Q931 & GetQ931() const { return q931pdu; }
181 
184  Q931 & GetQ931() { return q931pdu; }
185 
188  void SetQ931(const Q931 & _q931pdu) { q931pdu = _q931pdu; }
189 
194  void BuildQ931();
195 
200  PString GetSourceAliases(
201  const H323Transport * transport = NULL
202  ) const;
203 
208  PString GetDestinationAlias(
209  PBoolean firstAliasOnly = false
210  ) const;
211 
216  PBoolean GetSourceE164(
217  PString & number
218  ) const;
219 
224  PBoolean GetDestinationE164(
225  PString & number
226  ) const;
227 
231  unsigned GetDistinctiveRing() const;
232 
237  void SetQ931Fields(
238  const H323Connection & connection,
239  bool insertPartyNumbers = false
240  );
241 
242 #ifdef OPAL_H460
243 
247  void InsertH460Setup(
248  const H323Connection & connection,
249  H225_Setup_UUIE & setup
250  );
251 #endif
252 
253  protected:
254  // Even though we generally deal with the H323 protocol (H225) it is
255  // actually contained within a field of the Q931 protocol.
257 };
258 
259 
261 
264 class H323ControlPDU : public H245_MultimediaSystemControlMessage
265 {
266  PCLASSINFO(H323ControlPDU, H245_MultimediaSystemControlMessage);
267 
268  public:
269  H245_RequestMessage & Build(H245_RequestMessage ::Choices request);
270  H245_ResponseMessage & Build(H245_ResponseMessage ::Choices response);
271  H245_CommandMessage & Build(H245_CommandMessage ::Choices command);
272  H245_IndicationMessage & Build(H245_IndicationMessage::Choices indication);
273 
274  H245_MasterSlaveDetermination & BuildMasterSlaveDetermination(
275  unsigned terminalType,
276  unsigned statusDeterminationNumber
277  );
278  H245_MasterSlaveDeterminationAck & BuildMasterSlaveDeterminationAck(
279  PBoolean isMaster
280  );
281  H245_MasterSlaveDeterminationReject & BuildMasterSlaveDeterminationReject(
282  unsigned cause
283  );
284 
285  H245_TerminalCapabilitySet & BuildTerminalCapabilitySet(
286  const H323Connection & connection,
287  unsigned sequenceNumber,
288  PBoolean empty
289  );
290  H245_TerminalCapabilitySetAck & BuildTerminalCapabilitySetAck(
291  unsigned sequenceNumber
292  );
293  H245_TerminalCapabilitySetReject & BuildTerminalCapabilitySetReject(
294  unsigned sequenceNumber,
295  unsigned cause
296  );
297 
298  H245_OpenLogicalChannel & BuildOpenLogicalChannel(
299  unsigned forwardLogicalChannelNumber
300  );
301  H245_RequestChannelClose & BuildRequestChannelClose(
302  unsigned channelNumber,
303  unsigned reason
304  );
305  H245_CloseLogicalChannel & BuildCloseLogicalChannel(
306  unsigned channelNumber
307  );
308  H245_OpenLogicalChannelAck & BuildOpenLogicalChannelAck(
309  unsigned channelNumber
310  );
311  H245_OpenLogicalChannelReject & BuildOpenLogicalChannelReject(
312  unsigned channelNumber,
313  unsigned cause
314  );
315  H245_OpenLogicalChannelConfirm & BuildOpenLogicalChannelConfirm(
316  unsigned channelNumber
317  );
318  H245_CloseLogicalChannelAck & BuildCloseLogicalChannelAck(
319  unsigned channelNumber
320  );
321  H245_RequestChannelCloseAck & BuildRequestChannelCloseAck(
322  unsigned channelNumber
323  );
324  H245_RequestChannelCloseReject & BuildRequestChannelCloseReject(
325  unsigned channelNumber
326  );
327  H245_RequestChannelCloseRelease & BuildRequestChannelCloseRelease(
328  unsigned channelNumber
329  );
330 
331  H245_RequestMode & BuildRequestMode(
332  unsigned sequenceNumber
333  );
334  H245_RequestModeAck & BuildRequestModeAck(
335  unsigned sequenceNumber,
336  unsigned response
337  );
338  H245_RequestModeReject & BuildRequestModeReject(
339  unsigned sequenceNumber,
340  unsigned cause
341  );
342 
343  H245_RoundTripDelayRequest & BuildRoundTripDelayRequest(
344  unsigned sequenceNumber
345  );
346  H245_RoundTripDelayResponse & BuildRoundTripDelayResponse(
347  unsigned sequenceNumber
348  );
349 
350  H245_UserInputIndication & BuildUserInputIndication(
351  const PString & value
352  );
353  H245_UserInputIndication & BuildUserInputIndication(
354  char tone,
355  unsigned duration,
356  unsigned logicalChannel,
357  unsigned rtpTimestamp
358  );
359 
360  H245_MiscellaneousCommand & BuildMiscellaneousCommand(
361  unsigned channelNumber,
362  unsigned type
363  );
364 
365  H245_FlowControlCommand & BuildFlowControlCommand(
366  unsigned channelNumber,
367  unsigned maxBitRate
368  );
369 
370  H245_MiscellaneousIndication & BuildMiscellaneousIndication(
371  unsigned channelNumber,
372  unsigned type
373  );
374 
375  H245_GenericMessage & BuildGenericRequest(
376  const PString & identifier,
377  unsigned subMsgId
378  );
379  H245_GenericMessage & BuildGenericResponse(
380  const PString & identifier,
381  unsigned subMsgId
382  );
383  H245_GenericMessage & BuildGenericCommand(
384  const PString & identifier,
385  unsigned subMsgId
386  );
387  H245_GenericMessage & BuildGenericIndication(
388  const PString & identifier,
389  unsigned subMsgId
390  );
391 
392  H245_FunctionNotUnderstood & BuildFunctionNotUnderstood(
393  const H323ControlPDU & pdu
394  );
395 
396  H245_EndSessionCommand & BuildEndSessionCommand(
397  unsigned reason
398  );
399 };
400 
401 
403 
406 class H323RasPDU : public H225_RasMessage, public H323TransactionPDU
407 {
408  PCLASSINFO(H323RasPDU, H225_RasMessage);
409 
410  public:
411  H323RasPDU();
412  H323RasPDU(
413  const H235Authenticators & authenticators
414  );
415 
416  // overrides from PObject
417  virtual PObject * Clone() const;
418 
419  // overrides from H323TransactionPDU
420  virtual PASN_Object & GetPDU();
421  virtual PASN_Choice & GetChoice();
422  virtual const PASN_Object & GetPDU() const;
423  virtual const PASN_Choice & GetChoice() const;
424  virtual unsigned GetSequenceNumber() const;
425  virtual unsigned GetRequestInProgressDelay() const;
426 #if PTRACING
427  virtual const char * GetProtocolName() const;
428 #endif
429  virtual H323TransactionPDU * ClonePDU() const;
430  virtual void DeletePDU();
431 
433 
434  // new functions
435  H225_GatekeeperRequest & BuildGatekeeperRequest(unsigned seqNum);
436  H225_GatekeeperConfirm & BuildGatekeeperConfirm(unsigned seqNum);
437  H225_GatekeeperReject & BuildGatekeeperReject(unsigned seqNum, unsigned reason = H225_GatekeeperRejectReason::e_undefinedReason);
438  H225_RegistrationRequest & BuildRegistrationRequest(unsigned seqNum);
439  H225_RegistrationConfirm & BuildRegistrationConfirm(unsigned seqNum);
440  H225_RegistrationReject & BuildRegistrationReject(unsigned seqNum, unsigned reason = H225_RegistrationRejectReason::e_undefinedReason);
441  H225_UnregistrationRequest & BuildUnregistrationRequest(unsigned seqNum);
442  H225_UnregistrationConfirm & BuildUnregistrationConfirm(unsigned seqNum);
443  H225_UnregistrationReject & BuildUnregistrationReject(unsigned seqNum, unsigned reason = H225_UnregRejectReason::e_undefinedReason);
444  H225_LocationRequest & BuildLocationRequest(unsigned seqNum);
445  H225_LocationConfirm & BuildLocationConfirm(unsigned seqNum);
446  H225_LocationReject & BuildLocationReject(unsigned seqNum, unsigned reason = H225_LocationRejectReason::e_undefinedReason);
447  H225_AdmissionRequest & BuildAdmissionRequest(unsigned seqNum);
448  H225_AdmissionConfirm & BuildAdmissionConfirm(unsigned seqNum);
449  H225_AdmissionReject & BuildAdmissionReject(unsigned seqNum, unsigned reason = H225_AdmissionRejectReason::e_undefinedReason);
450  H225_DisengageRequest & BuildDisengageRequest(unsigned seqNum);
451  H225_DisengageConfirm & BuildDisengageConfirm(unsigned seqNum);
452  H225_DisengageReject & BuildDisengageReject(unsigned seqNum, unsigned reason = H225_DisengageRejectReason::e_securityDenial);
453  H225_BandwidthRequest & BuildBandwidthRequest(unsigned seqNum);
454  H225_BandwidthConfirm & BuildBandwidthConfirm(unsigned seqNum, unsigned bandwidth = 0);
455  H225_BandwidthReject & BuildBandwidthReject(unsigned seqNum, unsigned reason = H225_BandRejectReason::e_undefinedReason);
456  H225_InfoRequest & BuildInfoRequest(unsigned seqNum, unsigned callRef = 0, const OpalGloballyUniqueID * id = NULL);
457  H225_InfoRequestResponse & BuildInfoRequestResponse(unsigned seqNum);
458  H225_InfoRequestAck & BuildInfoRequestAck(unsigned seqNum);
459  H225_InfoRequestNak & BuildInfoRequestNak(unsigned seqNum, unsigned reason = H225_InfoRequestNakReason::e_undefinedReason);
460  H225_ServiceControlIndication& BuildServiceControlIndication(unsigned seqNum, const OpalGloballyUniqueID * id = NULL);
461  H225_ServiceControlResponse & BuildServiceControlResponse(unsigned seqNum);
462  H225_UnknownMessageResponse & BuildUnknownMessageResponse(unsigned seqNum);
463  H225_RequestInProgress & BuildRequestInProgress(unsigned seqNum, unsigned delay);
464 };
465 
466 
468 
469 void H323SetAliasAddresses(const H323TransportAddressArray & addresses, H225_ArrayOf_AliasAddress & aliases);
470 void H323SetAliasAddresses(const PStringArray & names, H225_ArrayOf_AliasAddress & aliases, int tag = -1);
471 void H323SetAliasAddresses(const PStringList & names, H225_ArrayOf_AliasAddress & aliases, int tag = -1);
472 void H323SetAliasAddress(const H323TransportAddress & address, H225_AliasAddress & alias);
473 void H323SetAliasAddress(const PString & name, H225_AliasAddress & alias, int tag = -1);
474 PStringArray H323GetAliasAddressStrings(const H225_ArrayOf_AliasAddress & aliases);
475 PString H323GetAliasAddressString(const H225_AliasAddress & alias);
476 PString H323GetAliasAddressE164(const H225_AliasAddress & alias);
477 PString H323GetAliasAddressE164(const H225_ArrayOf_AliasAddress & aliases);
478 
480  Q931::CauseValues cause,
481  unsigned reason
482 );
484  H323Connection::CallEndReason callEndReason,
485  H225_ReleaseCompleteReason & releaseCompleteReason
486 );
487 
488 void H323GetApplicationInfo(OpalProductInfo & info, const H225_VendorIdentifier & vendor);
489 
491  H245_ArrayOf_RTPPayloadType & rtpPacketizations,
492  const PStringSet & mediaPacketizations
493 );
495  H245_RTPPayloadType & rtpPacketization,
496  const OpalMediaFormat & mediaFormat,
497  RTP_DataFrame::PayloadTypes payloadType
498 );
500  H245_RTPPayloadType & rtpPacketization,
501  const PString & mediaPacketizationString,
502  RTP_DataFrame::PayloadTypes payloadType
503 );
505  const H245_RTPPayloadType & rtpPacketization
506 );
507 
509  const H245_CapabilityIdentifier & capId
510 );
512  const PString & str,
513  H245_CapabilityIdentifier & capId
514 );
515 
516 const H245_ParameterValue * H323GetGenericParameter(
517  const H245_ArrayOf_GenericParameter & params,
518  unsigned ordinal
519 );
521  const H245_ArrayOf_GenericParameter & params,
522  unsigned ordinal
523 );
525  const H245_ArrayOf_GenericParameter & params,
526  unsigned ordinal,
527  unsigned defValue = 0,
528  H245_ParameterValue::Choices subType = H245_ParameterValue::e_unsignedMin
529 );
530 H245_ParameterValue * H323AddGenericParameter(
531  H245_ArrayOf_GenericParameter & params,
532  unsigned ordinal
533 );
535  H245_ArrayOf_GenericParameter & params,
536  unsigned ordinal,
537  bool value
538 );
540  H245_ArrayOf_GenericParameter & params,
541  unsigned ordinal,
542  unsigned value,
543  H245_ParameterValue::Choices subType
544 );
546  H245_ArrayOf_GenericParameter & params,
547  unsigned ordinal,
548  const PString & value
549 );
551  H245_ArrayOf_GenericParameter & params,
552  unsigned ordinal,
553  const PBYTEArray & value
554 );
555 
556 #if PTRACING
557 void H323TraceDumpPDU(
558  const char * proto,
559  PBoolean writing,
560  const PBYTEArray & rawData,
561  const PASN_Object & pdu,
562  const PASN_Choice & tag1,
563  unsigned seqNum
564 );
565 #else
566 #define H323TraceDumpPDU(proto, writing, rawData, pdu, tag1, seqNum)
567 #endif
568 
569 
570 #endif // OPAL_H323
571 
572 #endif // OPAL_H323_H323PDU_H
573 
574