Objective Systems, Inc.  

ooq931.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2009 by Objective Systems, Inc.
00003  *
00004  * This software is furnished under an open source license and may be
00005  * used and copied only in accordance with the terms of this license.
00006  * The text of the license may generally be found in the root
00007  * directory of this installation in the COPYING file.  It
00008  * can also be viewed online at the following URL:
00009  *
00010  *   http://www.obj-sys.com/open/license.html
00011  *
00012  * Any redistributions of this file including modified versions must
00013  * maintain this copyright notice.
00014  *
00015  *****************************************************************************/
00021 #ifndef _OOQ931HDR_H_
00022 #define _OOQ931HDR_H_
00023 
00024 #include "ooasn1.h"
00025 #include "ootypes.h"
00026 #include "H323-MESSAGES.h"
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 #ifndef EXTERN
00033 #ifdef MAKE_DLL
00034 #define EXTERN __declspec(dllexport)
00035 #else
00036 #define EXTERN
00037 #endif /* MAKE_DLL */
00038 #endif /* EXTERN */
00039 
00044 /* Maximum length of the Calling/Called party number number */
00045 #define OO_MAX_NUMBER_LENGTH 50
00046 
00047 /* Maximum value for a call token identifier */
00048 #define OO_MAX_CALL_TOKEN 9999
00049 
00050 /* Q.931 packet must be at least 5 bytes long */
00051 #define Q931_E_TOOSHORT         (-1001)
00052 /* callReference field must be 2 bytes long */
00053 #define Q931_E_INVCALLREF       (-1002)
00054 /* invalid length of message */
00055 #define Q931_E_INVLENGTH        (-1003)
00056 
00057 enum Q931MsgTypes {
00058    Q931NationalEscapeMsg  = 0x00,
00059    Q931AlertingMsg        = 0x01,
00060    Q931CallProceedingMsg  = 0x02,
00061    Q931ConnectMsg         = 0x07,
00062    Q931ConnectAckMsg      = 0x0f,
00063    Q931ProgressMsg        = 0x03,
00064    Q931SetupMsg           = 0x05,
00065    Q931SetupAckMsg        = 0x0d,
00066    Q931ResumeMsg          = 0x26,
00067    Q931ResumeAckMsg       = 0x2e,
00068    Q931ResumeRejectMsg    = 0x22,
00069    Q931SuspendMsg         = 0x25,
00070    Q931SuspendAckMsg      = 0x2d,
00071    Q931SuspendRejectMsg   = 0x21,
00072    Q931UserInformationMsg = 0x20,
00073    Q931DisconnectMsg      = 0x45,
00074    Q931ReleaseMsg         = 0x4d,
00075    Q931ReleaseCompleteMsg = 0x5a,
00076    Q931RestartMsg         = 0x46,
00077    Q931RestartAckMsg      = 0x4e,
00078    Q931SegmentMsg         = 0x60,
00079    Q931CongestionCtrlMsg  = 0x79,
00080    Q931InformationMsg     = 0x7b,
00081    Q931NotifyMsg          = 0x6e,
00082    Q931StatusMsg          = 0x7d,
00083    Q931StatusEnquiryMsg   = 0x75,
00084    Q931FacilityMsg        = 0x62
00085 };
00086 
00087 enum Q931IECodes {
00088    Q931BearerCapabilityIE   = 0x04,
00089    Q931CauseIE              = 0x08,
00090    Q931FacilityIE           = 0x1c,
00091    Q931ProgressIndicatorIE  = 0x1e,
00092    Q931CallStateIE          = 0x14,
00093    Q931DisplayIE            = 0x28,
00094    Q931SignalIE             = 0x34,
00095    Q931CallingPartyNumberIE = 0x6c,
00096    Q931CalledPartyNumberIE  = 0x70,
00097    Q931RedirectingNumberIE  = 0x74,
00098    Q931UserUserIE           = 0x7e,
00099    Q931KeypadIE             = 0x2c
00100 };
00101 
00102 enum Q931InformationTransferCapability {
00103    Q931TransferSpeech,
00104    Q931TransferUnrestrictedDigital = 8,
00105    Q931TransferRestrictedDigital = 9,
00106    Q931Transfer3_1kHzAudio = 16,
00107    Q931TrasnferUnrestrictedDigitalWithTones = 17,
00108    Q931TransferVideo = 24
00109 };
00110 
00111 enum Q931CauseValues {
00112    Q931UnallocatedNumber           = 0x01,
00113    Q931NoRouteToNetwork            = 0x02,
00114    Q931NoRouteToDestination        = 0x03,
00115    Q931ChannelUnacceptable         = 0x06,
00116    Q931NormalCallClearing          = 0x10,
00117    Q931UserBusy                    = 0x11,
00118    Q931NoResponse                  = 0x12,
00119    Q931NoAnswer                    = 0x13,
00120    Q931SubscriberAbsent            = 0x14,
00121    Q931CallRejected                = 0x15,
00122    Q931NumberChanged               = 0x16,
00123    Q931Redirection                 = 0x17,
00124    Q931DestinationOutOfOrder       = 0x1b,
00125    Q931InvalidNumberFormat         = 0x1c,
00126    Q931NormalUnspecified           = 0x1f,
00127    Q931StatusEnquiryResponse       = 0x1e,
00128    Q931NoCircuitChannelAvailable   = 0x22,
00129    Q931NetworkOutOfOrder           = 0x26,
00130    Q931TemporaryFailure            = 0x29,
00131    Q931Congestion                  = 0x2a,
00132    Q931RequestedCircuitUnAvailable = 0x2c,
00133    Q931ResourcesUnavailable        = 0x2f,
00134    Q931IncompatibleDestination     = 0x58,
00135    Q931ProtocolErrorUnspecified    = 0x6f,
00136    Q931RecoveryOnTimerExpiry       = 0x66,
00137    Q931InvalidCallReference        = 0x51,
00138    Q931ErrorInCauseIE              = 0
00139 };
00140 
00141 enum Q931SignalInfo {
00142    Q931SignalDialToneOn,
00143    Q931SignalRingBackToneOn,
00144    Q931SignalInterceptToneOn,
00145    Q931SignalNetworkCongestionToneOn,
00146    Q931SignalBusyToneOn,
00147    Q931SignalConfirmToneOn,
00148    Q931SignalAnswerToneOn,
00149    Q931SignalCallWaitingTone,
00150    Q931SignalOffhookWarningTone,
00151    Q931SignalPreemptionToneOn,
00152    Q931SignalTonesOff = 0x3f,
00153    Q931SignalAlertingPattern0 = 0x40,
00154    Q931SignalAlertingPattern1,
00155    Q931SignalAlertingPattern2,
00156    Q931SignalAlertingPattern3,
00157    Q931SignalAlertingPattern4,
00158    Q931SignalAlertingPattern5,
00159    Q931SignalAlertingPattern6,
00160    Q931SignalAlertingPattern7,
00161    Q931SignalAlretingOff = 0x4f,
00162    Q931SignalErrorInIE = 0x100
00163 };
00164 
00165 enum Q931NumberingPlanCodes {
00166    Q931UnknownPlan          = 0x00,
00167    Q931ISDNPlan             = 0x01,
00168    Q931DataPlan             = 0x03,
00169    Q931TelexPlan            = 0x04,
00170    Q931NationalStandardPlan = 0x08,
00171    Q931PrivatePlan          = 0x09,
00172    Q931ReservedPlan         = 0x0f
00173 };
00174 
00175 enum Q931TypeOfNumberCodes {
00176    Q931UnknownType          = 0x00,
00177    Q931InternationalType    = 0x01,
00178    Q931NationalType         = 0x02,
00179    Q931NetworkSpecificType  = 0x03,
00180    Q931SubscriberType       = 0x04,
00181    Q931AbbreviatedType      = 0x06,
00182    Q931ReservedType         = 0x07
00183 };
00184 
00185 enum Q931CodingStandard{
00186   Q931CCITTStd = 0,
00187   Q931ReservedInternationalStd,
00188   Q931NationalStd,
00189   Q931NetworkStd
00190 };
00191 
00192 enum Q931TransferMode {
00193   Q931TransferCircuitMode = 0,   /* 00 */
00194   Q931TransferPacketMode  = 2   /* 10 */
00195 };
00196 
00197 enum Q931TransferRate{
00198   Q931TransferRatePacketMode = 0x00,  /* 00000 */
00199   Q931TransferRate64Kbps     = 0x10,  /* 10000 */
00200   Q931TransferRate128kbps    = 0x11,  /* 10001 */
00201   Q931TransferRate384kbps    = 0x13,  /* 10011 */
00202   Q931TransferRate1536kbps   = 0x15,  /* 10101 */
00203   Q931TransferRate1920kbps   = 0x17   /* 10111 */
00204 };
00205 
00206 enum Q931UserInfoLayer1Protocol{
00207   Q931UserInfoLayer1CCITTStdRate = 1,
00208   Q931UserInfoLayer1G711ULaw,
00209   Q931UserInfoLayer1G711ALaw,
00210   Q931UserInfoLayer1G721ADPCM,
00211   Q931UserInfoLayer1G722G725,
00212   Q931UserInfoLayer1H261,
00213   Q931UserInfoLayer1NonCCITTStdRate,
00214   Q931UserInfoLayer1CCITTStdRateV120,
00215   Q931UserInfoLayer1X31
00216 };
00217 
00218 /*
00219   Structure to build store outgoing encoded UUIE
00220   The different fields in the structure have octet lengths
00221   as specified in the spec.
00222 */
00223 typedef struct Q931InformationElement {
00224    int discriminator;
00225    int offset;
00226    int length;
00227    ASN1OCTET data[1];
00228 } Q931InformationElement;
00229 
00235 typedef struct Q931Message {
00236    ASN1UINT protocolDiscriminator;
00237    ASN1UINT callReference;
00238    ASN1BOOL fromDestination;
00239    ASN1UINT messageType;      /* Q931MsgTypes */
00240    ASN1UINT tunneledMsgType;  /* The H245 message this message is tunneling*/
00241    ASN1INT  logicalChannelNo; /* channel number associated with tunneled */
00242                               /* message, 0 if no channel */
00243    DList ies;
00244    Q931InformationElement *bearerCapabilityIE;
00245    Q931InformationElement *callingPartyNumberIE;
00246    Q931InformationElement *calledPartyNumberIE;
00247    Q931InformationElement *causeIE;
00248    Q931InformationElement *keypadIE;
00249    H225H323_UserInformation *userInfo;
00250 } Q931Message;
00251 
00255 typedef struct OOAliases {
00256    int type;           
00257    char *value;        
00258    OOBOOL registered;
00259    struct OOAliases *next;
00260 } OOAliases;
00261 
00262 #define ooAliases OOAliases
00263 
00264 struct OOH323CallData;
00265 
00266 /*
00267  * These are message callbacks which can be used by user applications
00268  * to perform application specific things on receiving a particular
00269  * message or before sending a particular message. For ex. user application
00270  * can change values of some parameters of setup message before it is actually
00271  * sent out.
00272  */
00280 typedef int (*cb_OnReceivedSetup)
00281    (struct OOH323CallData *call, struct Q931Message *pmsg);
00282 
00290 typedef int (*cb_OnReceivedConnect)
00291    (struct OOH323CallData *call, struct Q931Message *pmsg);
00292 
00301 typedef int (*cb_OnBuiltSetup)
00302    (struct OOH323CallData *call, struct Q931Message *pmsg);
00303 
00312 typedef int (*cb_OnBuiltConnect)
00313    (struct OOH323CallData *call, struct Q931Message *pmsg);
00314 
00320 typedef struct OOH225MsgCallbacks {
00321    cb_OnReceivedSetup onReceivedSetup;
00322    cb_OnReceivedConnect onReceivedConnect;
00323    cb_OnBuiltSetup onBuiltSetup;
00324    cb_OnBuiltConnect onBuiltConnect;
00325 } OOH225MsgCallbacks;
00326 
00337 EXTERN int ooQ931Decode
00338 (struct OOH323CallData *call, Q931Message* msg, int length, ASN1OCTET *data);
00339 
00349 EXTERN int ooDecodeUUIE(Q931Message *q931Msg);
00350 
00359 EXTERN int ooEncodeUUIE(Q931Message *q931msg);
00360 
00370 EXTERN Q931InformationElement* ooQ931GetIE (const Q931Message* q931msg,
00371                                             int ieCode);
00372 
00380 EXTERN void ooQ931Print (const Q931Message* q931msg);
00381 
00382 
00391 EXTERN int ooCreateQ931Message(Q931Message **msg, int msgType);
00392 
00398 EXTERN ASN1USINT ooGenerateCallReference(void);
00399 
00400 
00408 EXTERN int ooGenerateCallIdentifier(H225CallIdentifier *callid);
00409 
00417 EXTERN int ooFreeQ931Message(Q931Message *q931Msg);
00418 
00434 EXTERN int ooGetOutgoingQ931Msgbuf
00435 (struct OOH323CallData *call, ASN1OCTET * msgbuf, int* len, int *msgType);
00436 
00446 EXTERN int ooSendReleaseComplete(struct OOH323CallData *call);
00447 
00457 EXTERN int ooSendCallProceeding(struct OOH323CallData *call);
00458 
00468 EXTERN int ooSendAlerting(struct OOH323CallData *call);
00469 
00478 EXTERN int ooSendFacility(struct OOH323CallData *call);
00479 
00480 
00489 EXTERN int ooQ931SendDTMFAsKeyPadIE
00490           (struct OOH323CallData *call, const char* data);
00491 
00501 EXTERN int ooSendConnect(struct OOH323CallData *call);
00502 
00514 EXTERN int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts);
00515 
00523 int ooH323CallAdmitted( struct OOH323CallData *call);
00524 
00532 EXTERN int ooH323HandleCallFwdRequest(struct OOH323CallData *call);
00533 
00542 EXTERN int ooH323ForwardCall(char* callToken, char *dest);
00543 
00552 EXTERN int ooH323HangCall(char * callToken, OOCallClearReason reason);
00553 
00554 
00562 EXTERN int ooAcceptCall(struct OOH323CallData *call);
00563 
00564 /*
00565  * An helper function to ooMakeCall.
00566  * @param call      Pointer to the new call.
00567  *
00568  * @return          OO_OK, on success. OO_FAILED, on failure.
00569  */
00570 EXTERN int ooH323MakeCall_helper(struct OOH323CallData *call);
00571 
00582 int ooParseDestination
00583    (struct OOH323CallData *call, char *dest, char *parsedIP, unsigned len,
00584     OOAliases** aliasList);
00585 
00594 int ooGenerateCallToken (char *callToken, size_t size);
00595 
00596 
00612 EXTERN int ooSendAsTunneledMessage
00613 (struct OOH323CallData *call, ASN1OCTET* msgbuf,
00614  int h245Len, int h245MsgType, int associatedChan);
00615 
00616 
00627 int ooEncodeH225Message(struct OOH323CallData *call, Q931Message *pq931Msg,
00628                         ASN1OCTET* msgbuf, size_t size);
00629 
00639 int ooCallEstbTimerExpired(void *data);
00640 
00641 
00642 
00651 EXTERN int ooQ931SetKeypadIE(Q931Message *pmsg, const char* data);
00652 
00665 EXTERN int ooSetBearerCapabilityIE
00666    (Q931Message *pmsg, enum Q931CodingStandard codingStandard,
00667     enum Q931InformationTransferCapability capability,
00668     enum Q931TransferMode transferMode, enum Q931TransferRate transferRate,
00669     enum Q931UserInfoLayer1Protocol userInfoLayer1);
00670 
00681 EXTERN int ooQ931SetCalledPartyNumberIE
00682    (Q931Message *pmsg, const char *number, unsigned plan, unsigned type);
00683 
00684 
00698 EXTERN int ooQ931SetCallingPartyNumberIE
00699    (Q931Message *pmsg, const char *number, unsigned plan, unsigned type,
00700     unsigned presentation, unsigned screening);
00701 
00711 EXTERN int ooQ931SetCauseIE
00712    (Q931Message *pmsg,enum Q931CauseValues cause, unsigned coding,
00713     unsigned location);
00714 
00727 EXTERN int ooQ931GetCauseAndReasonCodeFromCallClearReason
00728    (OOCallClearReason clearReason, enum Q931CauseValues *cause,
00729     unsigned *reasonCode);
00730 
00739 EXTERN OOCallClearReason ooGetCallClearReasonFromCauseAndReasonCode
00740    (enum Q931CauseValues cause, unsigned reasonCode);
00741 
00749 EXTERN const char* ooGetMsgTypeText (int msgType);
00750 
00757 EXTERN const char* ooGetQ931CauseValueText (int val);
00758 
00762 #ifdef __cplusplus
00763 }
00764 #endif
00765 
00766 #endif /* __Q931HDR_H */

This file was last modified on 28 May 2010.
Objective Open H.323 Stack, 0.9.1