00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 #ifndef __OPAL_Q931_H
00212 #define __OPAL_Q931_H
00213
00214 #ifdef P_USE_PRAGMA
00215 #pragma interface
00216 #endif
00217
00218
00220
00223 class Q931 : public PObject
00224 {
00225 PCLASSINFO(Q931, PObject)
00226 public:
00227 enum MsgTypes {
00228 NationalEscapeMsg = 0x00,
00229 AlertingMsg = 0x01,
00230 CallProceedingMsg = 0x02,
00231 ConnectMsg = 0x07,
00232 ConnectAckMsg = 0x0f,
00233 ProgressMsg = 0x03,
00234 SetupMsg = 0x05,
00235 SetupAckMsg = 0x0d,
00236 ResumeMsg = 0x26,
00237 ResumeAckMsg = 0x2e,
00238 ResumeRejectMsg = 0x22,
00239 SuspendMsg = 0x25,
00240 SuspendAckMsg = 0x2d,
00241 SuspendRejectMsg = 0x21,
00242 UserInformationMsg = 0x20,
00243 DisconnectMsg = 0x45,
00244 ReleaseMsg = 0x4d,
00245 ReleaseCompleteMsg = 0x5a,
00246 RestartMsg = 0x46,
00247 RestartAckMsg = 0x4e,
00248 SegmentMsg = 0x60,
00249 CongestionCtrlMsg = 0x79,
00250 InformationMsg = 0x7b,
00251 NotifyMsg = 0x6e,
00252 StatusMsg = 0x7d,
00253 StatusEnquiryMsg = 0x75,
00254 FacilityMsg = 0x62
00255 };
00256
00257 Q931();
00258 Q931(const Q931 & other);
00259 Q931 & operator=(const Q931 & other);
00260
00261 void BuildFacility(int callRef, BOOL fromDest);
00262 void BuildInformation(int callRef, BOOL fromDest);
00263 void BuildProgress(
00264 int callRef,
00265 BOOL fromDest,
00266 unsigned description,
00267 unsigned codingStandard = 0,
00268 unsigned location = 0
00269 );
00270 void BuildNotify(int callRef, BOOL fromDest);
00271 void BuildCallProceeding(int callRef);
00272 void BuildSetupAcknowledge(int callRef);
00273 void BuildAlerting(int callRef);
00274 void BuildSetup(int callRef = -1);
00275 void BuildConnect(int callRef);
00276 void BuildConnectAck(int callRef, BOOL fromDest);
00277 void BuildStatus(int callRef, BOOL fromDest);
00278 void BuildStatusEnquiry(int callRef, BOOL fromDest);
00279 void BuildReleaseComplete(int callRef, BOOL fromDest);
00280
00281 BOOL Decode(const PBYTEArray & data);
00282 BOOL Encode(PBYTEArray & data) const;
00283
00284 void PrintOn(ostream & strm) const;
00285 PString GetMessageTypeName() const;
00286
00287 static unsigned GenerateCallReference();
00288 unsigned GetCallReference() const { return callReference; }
00289 BOOL IsFromDestination() const { return fromDestination; }
00290 MsgTypes GetMessageType() const { return messageType; }
00291
00292 enum InformationElementCodes {
00293 BearerCapabilityIE = 0x04,
00294 CauseIE = 0x08,
00295 ChannelIdentificationIE = 0x18,
00296 FacilityIE = 0x1c,
00297 ProgressIndicatorIE = 0x1e,
00298 CallStateIE = 0x14,
00299 DisplayIE = 0x28,
00300 KeypadIE = 0x2c,
00301 SignalIE = 0x34,
00302 ConnectedNumberIE = 0x4c,
00303 CallingPartyNumberIE = 0x6c,
00304 CalledPartyNumberIE = 0x70,
00305 RedirectingNumberIE = 0x74,
00306 UserUserIE = 0x7e
00307 };
00308 friend ostream & operator<<(ostream & strm, InformationElementCodes ie);
00309
00310 BOOL HasIE(InformationElementCodes ie) const;
00311 PBYTEArray GetIE(InformationElementCodes ie) const;
00312 void SetIE(InformationElementCodes ie, const PBYTEArray & userData);
00313 void RemoveIE(InformationElementCodes ie);
00314
00315 enum InformationTransferCapability {
00316 TransferSpeech,
00317 TransferUnrestrictedDigital = 8,
00318 TransferRestrictedDigital = 9,
00319 Transfer3_1kHzAudio = 16,
00320 TransferUnrestrictedDigitalWithTones = 17,
00321 TransferVideo = 24
00322 };
00323
00324 void SetBearerCapabilities(
00325 InformationTransferCapability capability,
00326 unsigned transferRate,
00327 unsigned codingStandard = 0,
00328 unsigned userInfoLayer1 = 5
00329 );
00330
00331 BOOL GetBearerCapabilities(
00332 InformationTransferCapability & capability,
00333 unsigned & transferRate,
00334 unsigned * codingStandard = NULL,
00335 unsigned * userInfoLayer1 = NULL
00336 );
00337
00338 enum CauseValues {
00339 UnknownCauseIE = 0,
00340 UnallocatedNumber = 1,
00341 NoRouteToNetwork = 2,
00342 NoRouteToDestination = 3,
00343 SendSpecialTone = 4,
00344 MisdialledTrunkPrefix = 5,
00345 ChannelUnacceptable = 6,
00346 CallAwarded = 7,
00347 Preemption = 8,
00348 PreemptionCircuitReserved = 9,
00349 NormalCallClearing = 16,
00350 UserBusy = 17,
00351 NoResponse = 18,
00352 NoAnswer = 19,
00353 SubscriberAbsent = 20,
00354 CallRejected = 21,
00355 NumberChanged = 22,
00356 Redirection = 23,
00357 ExchangeRoutingError = 25,
00358 NonSelectedUserClearing = 26,
00359 DestinationOutOfOrder = 27,
00360 InvalidNumberFormat = 28,
00361 FacilityRejected = 29,
00362 StatusEnquiryResponse = 30,
00363 NormalUnspecified = 31,
00364 NoCircuitChannelAvailable = 34,
00365 CallQueued = 35,
00366 NetworkOutOfOrder = 38,
00367 FrameModeOOS = 39,
00368 FrameModeOperational = 40,
00369 TemporaryFailure = 41,
00370 Congestion = 42,
00371 AccessInformationDiscarded = 43,
00372 RequestedCircuitNotAvailable = 44,
00373 PrecedenceCallBlocked = 46,
00374 ResourceUnavailable = 47,
00375 QoSNotAvailable = 49,
00376 RequestedFacilityNotSubscribed = 50,
00377 OutgoingCallsBarred = 52,
00378 OutgoingCallsBarredInCUG = 53,
00379 IncomingCallsBarred = 54,
00380 IncomingCallsBarredInCUG = 55,
00381 BearerCapNotAuthorised = 57,
00382 BearerCapNotPresentlyAvailable = 58,
00383 InconsistentOutgoingIE = 62,
00384 ServiceOptionNotAvailable = 63,
00385 BearerCapNotImplemented = 65,
00386 ChannelTypeNotImplemented = 66,
00387 RequestedFacilityNotImplemented = 69,
00388 OnlyRestrictedDigitalBearerCapAvailable = 70,
00389 ServiceOrOptionNotImplemented = 79,
00390 InvalidCallReference = 81,
00391 IdentifiedChannelNonExistent = 82,
00392 CallIdentifyNotSuspendedCall = 83,
00393 CallIdentifyInUse = 84,
00394 NoCallSuspended = 85,
00395 ClearedRequestedCallIdentity = 86,
00396 UserNotInCUG = 87,
00397 IncompatibleDestination = 88,
00398 NonexistentCUG = 90,
00399 InvalidTransitNetwork = 91,
00400 InvalidMessageUnspecified = 95,
00401 MandatoryIEMissing = 96,
00402 MessageTypeNonexistent = 97,
00403 MessageNotCompatible = 98,
00404 IENonExistantOrNotImplemented = 99,
00405 InvalidIEContents = 100,
00406 MessageNotCompatibleWithCallState = 101,
00407 TimerExpiry = 102,
00408 ParameterNonexistent = 103,
00409 UnrecognisedParamaterDiscarded = 110,
00410 ProtocolErrorUnspecified = 111,
00411 InterworkingUnspecified = 127,
00412 ErrorInCauseIE = 0x100
00413 };
00414 friend ostream & operator<<(ostream & strm, CauseValues cause);
00415
00416 void SetCause(
00417 CauseValues value,
00418 unsigned standard = 0,
00419 unsigned location = 0
00420 );
00421 CauseValues GetCause(
00422 unsigned * standard = NULL,
00423 unsigned * location = NULL
00424 ) const;
00425
00426 enum CallStates {
00427 CallState_Null = 0,
00428 CallState_CallInitiated = 1,
00429 CallState_OverlapSending = 2,
00430 CallState_OutgoingCallProceeding= 3,
00431 CallState_CallDelivered = 4,
00432 CallState_CallPresent = 6,
00433 CallState_CallReceived = 7,
00434 CallState_ConnectRequest = 8,
00435 CallState_IncomingCallProceeding= 9,
00436 CallState_Active = 10,
00437 CallState_DisconnectRequest = 11,
00438 CallState_DisconnectIndication = 12,
00439 CallState_SuspendRequest = 15,
00440 CallState_ResumeRequest = 17,
00441 CallState_ReleaseRequest = 19,
00442 CallState_OverlapReceiving = 25,
00443 CallState_ErrorInIE = 0x100
00444 };
00445 void SetCallState(
00446 CallStates value,
00447 unsigned standard = 0
00448 );
00449 CallStates GetCallState(
00450 unsigned * standard = NULL
00451 ) const;
00452
00453 enum SignalInfo {
00454 SignalDialToneOn,
00455 SignalRingBackToneOn,
00456 SignalInterceptToneOn,
00457 SignalNetworkCongestionToneOn,
00458 SignalBusyToneOn,
00459 SignalConfirmToneOn,
00460 SignalAnswerToneOn,
00461 SignalCallWaitingTone,
00462 SignalOffhookWarningTone,
00463 SignalPreemptionToneOn,
00464 SignalTonesOff = 0x3f,
00465 SignalAlertingPattern0 = 0x40,
00466 SignalAlertingPattern1,
00467 SignalAlertingPattern2,
00468 SignalAlertingPattern3,
00469 SignalAlertingPattern4,
00470 SignalAlertingPattern5,
00471 SignalAlertingPattern6,
00472 SignalAlertingPattern7,
00473 SignalAlertingOff = 0x4f,
00474 SignalErrorInIE = 0x100
00475 };
00476 void SetSignalInfo(SignalInfo value);
00477 SignalInfo GetSignalInfo() const;
00478
00479 void SetKeypad(const PString & digits);
00480 PString GetKeypad() const;
00481
00482 enum ProgressIndication {
00483 ProgressNotEndToEndISDN = 1,
00484
00485 ProgressDestinationNonISDN = 2,
00486 ProgressOriginNotISDN = 3,
00487 ProgressReturnedToISDN = 4,
00488 ProgressServiceChange = 5,
00489
00490 ProgressInbandInformationAvailable = 8
00491 };
00492
00493 void SetProgressIndicator(
00494 unsigned description,
00495 unsigned codingStandard = 0,
00496 unsigned location = 0
00497 );
00498 BOOL GetProgressIndicator(
00499 unsigned & description,
00500 unsigned * codingStandard = NULL,
00501 unsigned * location = NULL
00502 ) const;
00503
00504 void SetDisplayName(const PString & name);
00505 PString GetDisplayName() const;
00506
00507 enum NumberingPlanCodes {
00508 UnknownPlan = 0x00,
00509 ISDNPlan = 0x01,
00510 DataPlan = 0x03,
00511 TelexPlan = 0x04,
00512 NationalStandardPlan = 0x08,
00513 PrivatePlan = 0x09,
00514 ReservedPlan = 0x0f
00515 };
00516
00517 enum TypeOfNumberCodes {
00518 UnknownType = 0x00,
00519 InternationalType = 0x01,
00520 NationalType = 0x02,
00521 NetworkSpecificType = 0x03,
00522 SubscriberType = 0x04,
00523 AbbreviatedType = 0x06,
00524 ReservedType = 0x07
00525 };
00526
00527 void SetCallingPartyNumber(
00528 const PString & number,
00529 unsigned plan = 1,
00530 unsigned type = 0,
00531 int presentation = -1,
00532 int screening = -1
00533 );
00534 BOOL GetCallingPartyNumber(
00535 PString & number,
00536 unsigned * plan = NULL,
00537 unsigned * type = NULL,
00538 unsigned * presentation = NULL,
00539 unsigned * screening = NULL,
00540 unsigned defPresentation = 0,
00541 unsigned defScreening = 0
00542 ) const;
00543
00544 void SetCalledPartyNumber(
00545 const PString & number,
00546 unsigned plan = 1,
00547 unsigned type = 0
00548 );
00549 BOOL GetCalledPartyNumber(
00550 PString & number,
00551 unsigned * plan = NULL,
00552 unsigned * type = NULL
00553 ) const;
00554
00555 void SetRedirectingNumber(
00556 const PString & number,
00557 unsigned plan = 1,
00558 unsigned type = 0,
00559 int presentation = -1,
00560 int screening = -1,
00561 int reason = -1
00562 );
00563 BOOL GetRedirectingNumber(
00564 PString & number,
00565 unsigned * plan = NULL,
00566 unsigned * type = NULL,
00567 unsigned * presentation = NULL,
00568 unsigned * screening = NULL,
00569 unsigned * reason = NULL,
00570 unsigned defPresentation = 0,
00571 unsigned defScreening = 0,
00572 unsigned defReason =0
00573 ) const;
00574
00575 void SetConnectedNumber(
00576 const PString & number,
00577 unsigned plan = 1,
00578 unsigned type = 0,
00579 int presentation = -1,
00580 int screening = -1,
00581 int reason = -1
00582 );
00583 BOOL GetConnectedNumber(
00584 PString & number,
00585 unsigned * plan = NULL,
00586 unsigned * type = NULL,
00587 unsigned * presentation = NULL,
00588 unsigned * screening = NULL,
00589 unsigned * reason = NULL,
00590 unsigned defPresentation = 0,
00591 unsigned defScreening = 0,
00592 unsigned defReason =0
00593 ) const;
00594
00601 void SetChannelIdentification(
00602 unsigned interfaceType = 0,
00603 unsigned preferredOrExclusive = 0,
00604 int channelNumber = 1
00605 );
00606
00609 BOOL GetChannelIdentification(
00610 unsigned * interfaceType = NULL,
00611 unsigned * preferredOrExclusive = NULL,
00612 int * channelNumber = NULL
00613 ) const;
00614
00615 protected:
00616 unsigned callReference;
00617 BOOL fromDestination;
00618 unsigned protocolDiscriminator;
00619 MsgTypes messageType;
00620
00621 PDICTIONARY(InternalInformationElements, POrdinalKey, PBYTEArray);
00622 InternalInformationElements informationElements;
00623 };
00624
00625
00626 #endif // __OPAL_Q931_H
00627
00628