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
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236 #ifndef __OPAL_Q931_H
00237 #define __OPAL_Q931_H
00238
00239 #ifdef P_USE_PRAGMA
00240 #pragma interface
00241 #endif
00242
00243
00245
00248 class Q931 : public PObject
00249 {
00250 PCLASSINFO(Q931, PObject)
00251 public:
00252 enum MsgTypes {
00253 NationalEscapeMsg = 0x00,
00254 AlertingMsg = 0x01,
00255 CallProceedingMsg = 0x02,
00256 ConnectMsg = 0x07,
00257 ConnectAckMsg = 0x0f,
00258 ProgressMsg = 0x03,
00259 SetupMsg = 0x05,
00260 SetupAckMsg = 0x0d,
00261 ResumeMsg = 0x26,
00262 ResumeAckMsg = 0x2e,
00263 ResumeRejectMsg = 0x22,
00264 SuspendMsg = 0x25,
00265 SuspendAckMsg = 0x2d,
00266 SuspendRejectMsg = 0x21,
00267 UserInformationMsg = 0x20,
00268 DisconnectMsg = 0x45,
00269 ReleaseMsg = 0x4d,
00270 ReleaseCompleteMsg = 0x5a,
00271 RestartMsg = 0x46,
00272 RestartAckMsg = 0x4e,
00273 SegmentMsg = 0x60,
00274 CongestionCtrlMsg = 0x79,
00275 InformationMsg = 0x7b,
00276 NotifyMsg = 0x6e,
00277 StatusMsg = 0x7d,
00278 StatusEnquiryMsg = 0x75,
00279 FacilityMsg = 0x62
00280 };
00281
00282 Q931();
00283 Q931(const Q931 & other);
00284 Q931 & operator=(const Q931 & other);
00285
00286 void BuildFacility(int callRef, BOOL fromDest);
00287 void BuildInformation(int callRef, BOOL fromDest);
00288 void BuildProgress(
00289 int callRef,
00290 BOOL fromDest,
00291 unsigned description,
00292 unsigned codingStandard = 0,
00293 unsigned location = 0
00294 );
00295 void BuildNotify(int callRef, BOOL fromDest);
00296 void BuildCallProceeding(int callRef);
00297 void BuildSetupAcknowledge(int callRef);
00298 void BuildAlerting(int callRef);
00299 void BuildSetup(int callRef = -1);
00300 void BuildConnect(int callRef);
00301 void BuildStatus(int callRef, BOOL fromDest);
00302 void BuildStatusEnquiry(int callRef, BOOL fromDest);
00303 void BuildReleaseComplete(int callRef, BOOL fromDest);
00304
00305 BOOL Decode(const PBYTEArray & data);
00306 BOOL Encode(PBYTEArray & data) const;
00307
00308 void PrintOn(ostream & strm) const;
00309 PString GetMessageTypeName() const;
00310
00311 static unsigned GenerateCallReference();
00312 unsigned GetCallReference() const { return callReference; }
00313 BOOL IsFromDestination() const { return fromDestination; }
00314 MsgTypes GetMessageType() const { return messageType; }
00315
00316 enum InformationElementCodes {
00317 BearerCapabilityIE = 0x04,
00318 CauseIE = 0x08,
00319 ChannelIdentificationIE = 0x18,
00320 FacilityIE = 0x1c,
00321 ProgressIndicatorIE = 0x1e,
00322 CallStateIE = 0x14,
00323 DisplayIE = 0x28,
00324 KeypadIE = 0x2c,
00325 SignalIE = 0x34,
00326 ConnectedNumberIE = 0x4c,
00327 CallingPartyNumberIE = 0x6c,
00328 CalledPartyNumberIE = 0x70,
00329 RedirectingNumberIE = 0x74,
00330 UserUserIE = 0x7e
00331 };
00332 friend ostream & operator<<(ostream & strm, InformationElementCodes ie);
00333
00334 BOOL HasIE(InformationElementCodes ie) const;
00335 PBYTEArray GetIE(InformationElementCodes ie) const;
00336 void SetIE(InformationElementCodes ie, const PBYTEArray & userData);
00337 void RemoveIE(InformationElementCodes ie);
00338
00339 enum InformationTransferCapability {
00340 TransferSpeech,
00341 TransferUnrestrictedDigital = 8,
00342 TransferRestrictedDigital = 9,
00343 Transfer3_1kHzAudio = 16,
00344 TrasnferUnrestrictedDigitalWithTones = 17,
00345 TransferVideo = 24
00346 };
00347
00348 void SetBearerCapabilities(
00349 InformationTransferCapability capability,
00350 unsigned transferRate,
00351 unsigned codingStandard = 0,
00352 unsigned userInfoLayer1 = 5
00353 );
00354
00355 BOOL GetBearerCapabilities(
00356 InformationTransferCapability & capability,
00357 unsigned & transferRate,
00358 unsigned * codingStandard = NULL,
00359 unsigned * userInfoLayer1 = NULL
00360 );
00361
00362 enum CauseValues {
00363 UnknownCauseIE = 0,
00364 UnallocatedNumber = 1,
00365 NoRouteToNetwork = 2,
00366 NoRouteToDestination = 3,
00367 SendSpecialTone = 4,
00368 MisdialledTrunkPrefix = 5,
00369 ChannelUnacceptable = 6,
00370 NormalCallClearing = 16,
00371 UserBusy = 17,
00372 NoResponse = 18,
00373 NoAnswer = 19,
00374 SubscriberAbsent = 20,
00375 CallRejected = 21,
00376 NumberChanged = 22,
00377 Redirection = 23,
00378 ExchangeRoutingError = 25,
00379 NonSelectedUserClearing = 26,
00380 DestinationOutOfOrder = 27,
00381 InvalidNumberFormat = 28,
00382 FacilityRejected = 29,
00383 StatusEnquiryResponse = 30,
00384 NormalUnspecified = 31,
00385 NoCircuitChannelAvailable = 34,
00386 NetworkOutOfOrder = 38,
00387 TemporaryFailure = 41,
00388 Congestion = 42,
00389 RequestedCircuitNotAvailable = 44,
00390 ResourceUnavailable = 47,
00391 ServiceOptionNotAvailable = 63,
00392 InvalidCallReference = 81,
00393 ClearedRequestedCallIdentity = 86,
00394 IncompatibleDestination = 88,
00395 IENonExistantOrNotImplemented= 99,
00396 TimerExpiry = 102,
00397 ProtocolErrorUnspecified = 111,
00398 InterworkingUnspecified = 127,
00399 ErrorInCauseIE = 0x100
00400 };
00401 friend ostream & operator<<(ostream & strm, CauseValues cause);
00402
00403 void SetCause(
00404 CauseValues value,
00405 unsigned standard = 0,
00406 unsigned location = 0
00407 );
00408 CauseValues GetCause(
00409 unsigned * standard = NULL,
00410 unsigned * location = NULL
00411 ) const;
00412
00413 enum CallStates {
00414 CallState_Null = 0,
00415 CallState_CallInitiated = 1,
00416 CallState_OverlapSending = 2,
00417 CallState_OutgoingCallProceeding= 3,
00418 CallState_CallDelivered = 4,
00419 CallState_CallPresent = 6,
00420 CallState_CallReceived = 7,
00421 CallState_ConnectRequest = 8,
00422 CallState_IncomingCallProceeding= 9,
00423 CallState_Active = 10,
00424 CallState_DisconnectRequest = 11,
00425 CallState_DisconnectIndication = 12,
00426 CallState_SuspendRequest = 15,
00427 CallState_ResumeRequest = 17,
00428 CallState_ReleaseRequest = 19,
00429 CallState_OverlapReceiving = 25,
00430 CallState_ErrorInIE = 0x100
00431 };
00432 void SetCallState(
00433 CallStates value,
00434 unsigned standard = 0
00435 );
00436 CallStates GetCallState(
00437 unsigned * standard = NULL
00438 ) const;
00439
00440 enum SignalInfo {
00441 SignalDialToneOn,
00442 SignalRingBackToneOn,
00443 SignalInterceptToneOn,
00444 SignalNetworkCongestionToneOn,
00445 SignalBusyToneOn,
00446 SignalConfirmToneOn,
00447 SignalAnswerToneOn,
00448 SignalCallWaitingTone,
00449 SignalOffhookWarningTone,
00450 SignalPreemptionToneOn,
00451 SignalTonesOff = 0x3f,
00452 SignalAlertingPattern0 = 0x40,
00453 SignalAlertingPattern1,
00454 SignalAlertingPattern2,
00455 SignalAlertingPattern3,
00456 SignalAlertingPattern4,
00457 SignalAlertingPattern5,
00458 SignalAlertingPattern6,
00459 SignalAlertingPattern7,
00460 SignalAlertingOff = 0x4f,
00461 SignalErrorInIE = 0x100
00462 };
00463 void SetSignalInfo(SignalInfo value);
00464 SignalInfo GetSignalInfo() const;
00465
00466 void SetKeypad(const PString & digits);
00467 PString GetKeypad() const;
00468
00469 enum ProgressIndication {
00470 ProgressNotEndToEndISDN = 1,
00471
00472 ProgressDestinationNonISDN = 2,
00473 ProgressOriginNotISDN = 3,
00474 ProgressReturnedToISDN = 4,
00475 ProgressServiceChange = 5,
00476
00477 ProgressInbandInformationAvailable = 8
00478 };
00479
00480 void SetProgressIndicator(
00481 unsigned description,
00482 unsigned codingStandard = 0,
00483 unsigned location = 0
00484 );
00485 BOOL GetProgressIndicator(
00486 unsigned & description,
00487 unsigned * codingStandard = NULL,
00488 unsigned * location = NULL
00489 ) const;
00490
00491 void SetDisplayName(const PString & name);
00492 PString GetDisplayName() const;
00493
00494 enum NumberingPlanCodes {
00495 UnknownPlan = 0x00,
00496 ISDNPlan = 0x01,
00497 DataPlan = 0x03,
00498 TelexPlan = 0x04,
00499 NationalStandardPlan = 0x08,
00500 PrivatePlan = 0x09,
00501 ReservedPlan = 0x0f
00502 };
00503
00504 enum TypeOfNumberCodes {
00505 UnknownType = 0x00,
00506 InternationalType = 0x01,
00507 NationalType = 0x02,
00508 NetworkSpecificType = 0x03,
00509 SubscriberType = 0x04,
00510 AbbreviatedType = 0x06,
00511 ReservedType = 0x07
00512 };
00513
00514 void SetCallingPartyNumber(
00515 const PString & number,
00516 unsigned plan = 1,
00517 unsigned type = 0,
00518 int presentation = -1,
00519 int screening = -1
00520 );
00521 BOOL GetCallingPartyNumber(
00522 PString & number,
00523 unsigned * plan = NULL,
00524 unsigned * type = NULL,
00525 unsigned * presentation = NULL,
00526 unsigned * screening = NULL,
00527 unsigned defPresentation = 0,
00528 unsigned defScreening = 0
00529 ) const;
00530
00531 void SetCalledPartyNumber(
00532 const PString & number,
00533 unsigned plan = 1,
00534 unsigned type = 0
00535 );
00536 BOOL GetCalledPartyNumber(
00537 PString & number,
00538 unsigned * plan = NULL,
00539 unsigned * type = NULL
00540 ) const;
00541
00542 void SetRedirectingNumber(
00543 const PString & number,
00544 unsigned plan = 1,
00545 unsigned type = 0,
00546 int presentation = -1,
00547 int screening = -1,
00548 int reason = -1
00549 );
00550 BOOL GetRedirectingNumber(
00551 PString & number,
00552 unsigned * plan = NULL,
00553 unsigned * type = NULL,
00554 unsigned * presentation = NULL,
00555 unsigned * screening = NULL,
00556 unsigned * reason = NULL,
00557 unsigned defPresentation = 0,
00558 unsigned defScreening = 0,
00559 unsigned defReason =0
00560 ) const;
00561
00562 void SetConnectedNumber(
00563 const PString & number,
00564 unsigned plan = 1,
00565 unsigned type = 0,
00566 int presentation = -1,
00567 int screening = -1,
00568 int reason = -1
00569 );
00570 BOOL GetConnectedNumber(
00571 PString & number,
00572 unsigned * plan = NULL,
00573 unsigned * type = NULL,
00574 unsigned * presentation = NULL,
00575 unsigned * screening = NULL,
00576 unsigned * reason = NULL,
00577 unsigned defPresentation = 0,
00578 unsigned defScreening = 0,
00579 unsigned defReason =0
00580 ) const;
00581
00588 void SetChannelIdentification(
00589 unsigned interfaceType = 0,
00590 unsigned preferredOrExclusive = 0,
00591 int channelNumber = 1
00592 );
00593
00596 BOOL GetChannelIdentification(
00597 unsigned * interfaceType = NULL,
00598 unsigned * preferredOrExclusive = NULL,
00599 int * channelNumber = NULL
00600 ) const;
00601
00602 protected:
00603 unsigned callReference;
00604 BOOL fromDestination;
00605 unsigned protocolDiscriminator;
00606 MsgTypes messageType;
00607
00608 PDICTIONARY(InternalInformationElements, POrdinalKey, PBYTEArray);
00609 InternalInformationElements informationElements;
00610 };
00611
00612
00613 #endif // __OPAL_Q931_H
00614
00615