| 1 | /* |
| 2 | * Copyright (C) 2004-2005 by Objective Systems, Inc. |
| 3 | * |
| 4 | * This software is furnished under an open source license and may be |
| 5 | * used and copied only in accordance with the terms of this license. |
| 6 | * The text of the license may generally be found in the root |
| 7 | * directory of this installation in the COPYING file. It |
| 8 | * can also be viewed online at the following URL: |
| 9 | * |
| 10 | * http://www.obj-sys.com/open/license.html |
| 11 | * |
| 12 | * Any redistributions of this file including modified versions must |
| 13 | * maintain this copyright notice. |
| 14 | * |
| 15 | *****************************************************************************/ |
| 16 | /** |
| 17 | * @file ooq931.h |
| 18 | * This file contains functions to support call signalling. |
| 19 | */ |
| 20 | |
| 21 | #ifndef _OOQ931HDR_H_ |
| 22 | #define _OOQ931HDR_H_ |
| 23 | |
| 24 | #include "ooasn1.h" |
| 25 | #include "ootypes.h" |
| 26 | #include "H323-MESSAGES.h" |
| 27 | |
| 28 | #ifdef __cplusplus |
| 29 | extern "C" { |
| 30 | #endif |
| 31 | |
| 32 | #ifndef EXTERN |
| 33 | #ifdef MAKE_DLL |
| 34 | #define EXTERN __declspec(dllexport) |
| 35 | #else |
| 36 | #define EXTERN |
| 37 | #endif /* MAKE_DLL */ |
| 38 | #endif /* EXTERN */ |
| 39 | |
| 40 | /** |
| 41 | * @defgroup q931 Q.931/H.2250 Message Handling |
| 42 | * @{ |
| 43 | */ |
| 44 | /* Maximum length of the Calling/Called party number number */ |
| 45 | #define OO_MAX_NUMBER_LENGTH 50 |
| 46 | |
| 47 | /* Maximum value for a call token identifier */ |
| 48 | #define OO_MAX_CALL_TOKEN 999999 |
| 49 | |
| 50 | /* Q.931 packet must be at least 5 bytes long */ |
| 51 | #define Q931_E_TOOSHORT (-1001) |
| 52 | /* callReference field must be 2 bytes long */ |
| 53 | #define Q931_E_INVCALLREF (-1002) |
| 54 | /* invalid length of message */ |
| 55 | #define Q931_E_INVLENGTH (-1003) |
| 56 | |
| 57 | enum Q931MsgTypes { |
| 58 | Q931NationalEscapeMsg = 0x00, |
| 59 | Q931AlertingMsg = 0x01, |
| 60 | Q931CallProceedingMsg = 0x02, |
| 61 | Q931ConnectMsg = 0x07, |
| 62 | Q931ConnectAckMsg = 0x0f, |
| 63 | Q931ProgressMsg = 0x03, |
| 64 | Q931SetupMsg = 0x05, |
| 65 | Q931SetupAckMsg = 0x0d, |
| 66 | Q931ResumeMsg = 0x26, |
| 67 | Q931ResumeAckMsg = 0x2e, |
| 68 | Q931ResumeRejectMsg = 0x22, |
| 69 | Q931SuspendMsg = 0x25, |
| 70 | Q931SuspendAckMsg = 0x2d, |
| 71 | Q931SuspendRejectMsg = 0x21, |
| 72 | Q931UserInformationMsg = 0x20, |
| 73 | Q931DisconnectMsg = 0x45, |
| 74 | Q931ReleaseMsg = 0x4d, |
| 75 | Q931ReleaseCompleteMsg = 0x5a, |
| 76 | Q931RestartMsg = 0x46, |
| 77 | Q931RestartAckMsg = 0x4e, |
| 78 | Q931SegmentMsg = 0x60, |
| 79 | Q931CongestionCtrlMsg = 0x79, |
| 80 | Q931InformationMsg = 0x7b, |
| 81 | Q931NotifyMsg = 0x6e, |
| 82 | Q931StatusMsg = 0x7d, |
| 83 | Q931StatusEnquiryMsg = 0x75, |
| 84 | Q931FacilityMsg = 0x62 |
| 85 | }; |
| 86 | |
| 87 | enum Q931IECodes { |
| 88 | Q931BearerCapabilityIE = 0x04, |
| 89 | Q931CauseIE = 0x08, |
| 90 | Q931FacilityIE = 0x1c, |
| 91 | Q931ProgressIndicatorIE = 0x1e, |
| 92 | Q931CallStateIE = 0x14, |
| 93 | Q931DisplayIE = 0x28, |
| 94 | Q931SignalIE = 0x34, |
| 95 | Q931CallingPartyNumberIE = 0x6c, |
| 96 | Q931CalledPartyNumberIE = 0x70, |
| 97 | Q931RedirectingNumberIE = 0x74, |
| 98 | Q931UserUserIE = 0x7e, |
| 99 | Q931KeypadIE = 0x2c |
| 100 | }; |
| 101 | |
| 102 | enum Q931InformationTransferCapability { |
| 103 | Q931TransferSpeech, |
| 104 | Q931TransferUnrestrictedDigital = 8, |
| 105 | Q931TransferRestrictedDigital = 9, |
| 106 | Q931Transfer3_1kHzAudio = 16, |
| 107 | Q931TrasnferUnrestrictedDigitalWithTones = 17, |
| 108 | Q931TransferVideo = 24 |
| 109 | }; |
| 110 | |
| 111 | enum Q931CauseValues { |
| 112 | Q931UnallocatedNumber = 0x01, |
| 113 | Q931NoRouteToNetwork = 0x02, |
| 114 | Q931NoRouteToDestination = 0x03, |
| 115 | Q931ChannelUnacceptable = 0x06, |
| 116 | Q931NormalCallClearing = 0x10, |
| 117 | Q931UserBusy = 0x11, |
| 118 | Q931NoResponse = 0x12, |
| 119 | Q931NoAnswer = 0x13, |
| 120 | Q931SubscriberAbsent = 0x14, |
| 121 | Q931CallRejected = 0x15, |
| 122 | Q931NumberChanged = 0x16, |
| 123 | Q931Redirection = 0x17, |
| 124 | Q931DestinationOutOfOrder = 0x1b, |
| 125 | Q931InvalidNumberFormat = 0x1c, |
| 126 | Q931NormalUnspecified = 0x1f, |
| 127 | Q931StatusEnquiryResponse = 0x1e, |
| 128 | Q931NoCircuitChannelAvailable = 0x22, |
| 129 | Q931NetworkOutOfOrder = 0x26, |
| 130 | Q931TemporaryFailure = 0x29, |
| 131 | Q931Congestion = 0x2a, |
| 132 | Q931RequestedCircuitUnAvailable = 0x2c, |
| 133 | Q931ResourcesUnavailable = 0x2f, |
| 134 | Q931IncompatibleDestination = 0x58, |
| 135 | Q931ProtocolErrorUnspecified = 0x6f, |
| 136 | Q931RecoveryOnTimerExpiry = 0x66, |
| 137 | Q931InvalidCallReference = 0x51, |
| 138 | Q931ErrorInCauseIE = 0 |
| 139 | }; |
| 140 | |
| 141 | enum Q931SignalInfo { |
| 142 | Q931SignalDialToneOn, |
| 143 | Q931SignalRingBackToneOn, |
| 144 | Q931SignalInterceptToneOn, |
| 145 | Q931SignalNetworkCongestionToneOn, |
| 146 | Q931SignalBusyToneOn, |
| 147 | Q931SignalConfirmToneOn, |
| 148 | Q931SignalAnswerToneOn, |
| 149 | Q931SignalCallWaitingTone, |
| 150 | Q931SignalOffhookWarningTone, |
| 151 | Q931SignalPreemptionToneOn, |
| 152 | Q931SignalTonesOff = 0x3f, |
| 153 | Q931SignalAlertingPattern0 = 0x40, |
| 154 | Q931SignalAlertingPattern1, |
| 155 | Q931SignalAlertingPattern2, |
| 156 | Q931SignalAlertingPattern3, |
| 157 | Q931SignalAlertingPattern4, |
| 158 | Q931SignalAlertingPattern5, |
| 159 | Q931SignalAlertingPattern6, |
| 160 | Q931SignalAlertingPattern7, |
| 161 | Q931SignalAlretingOff = 0x4f, |
| 162 | Q931SignalErrorInIE = 0x100 |
| 163 | }; |
| 164 | |
| 165 | enum Q931NumberingPlanCodes { |
| 166 | Q931UnknownPlan = 0x00, |
| 167 | Q931ISDNPlan = 0x01, |
| 168 | Q931DataPlan = 0x03, |
| 169 | Q931TelexPlan = 0x04, |
| 170 | Q931NationalStandardPlan = 0x08, |
| 171 | Q931PrivatePlan = 0x09, |
| 172 | Q931ReservedPlan = 0x0f |
| 173 | }; |
| 174 | |
| 175 | enum Q931TypeOfNumberCodes { |
| 176 | Q931UnknownType = 0x00, |
| 177 | Q931InternationalType = 0x01, |
| 178 | Q931NationalType = 0x02, |
| 179 | Q931NetworkSpecificType = 0x03, |
| 180 | Q931SubscriberType = 0x04, |
| 181 | Q931AbbreviatedType = 0x06, |
| 182 | Q931ReservedType = 0x07 |
| 183 | }; |
| 184 | |
| 185 | enum Q931CodingStandard{ |
| 186 | Q931CCITTStd = 0, |
| 187 | Q931ReservedInternationalStd, |
| 188 | Q931NationalStd, |
| 189 | Q931NetworkStd |
| 190 | }; |
| 191 | |
| 192 | enum Q931TransferMode { |
| 193 | Q931TransferCircuitMode = 0, /* 00 */ |
| 194 | Q931TransferPacketMode = 2 /* 10 */ |
| 195 | }; |
| 196 | |
| 197 | enum Q931TransferRate{ |
| 198 | Q931TransferRatePacketMode = 0x00, /* 00000 */ |
| 199 | Q931TransferRate64Kbps = 0x10, /* 10000 */ |
| 200 | Q931TransferRate128kbps = 0x11, /* 10001 */ |
| 201 | Q931TransferRate384kbps = 0x13, /* 10011 */ |
| 202 | Q931TransferRate1536kbps = 0x15, /* 10101 */ |
| 203 | Q931TransferRate1920kbps = 0x17 /* 10111 */ |
| 204 | }; |
| 205 | |
| 206 | enum Q931UserInfoLayer1Protocol{ |
| 207 | Q931UserInfoLayer1CCITTStdRate = 1, |
| 208 | Q931UserInfoLayer1G711ULaw, |
| 209 | Q931UserInfoLayer1G711ALaw, |
| 210 | Q931UserInfoLayer1G721ADPCM, |
| 211 | Q931UserInfoLayer1G722G725, |
| 212 | Q931UserInfoLayer1H261, |
| 213 | Q931UserInfoLayer1NonCCITTStdRate, |
| 214 | Q931UserInfoLayer1CCITTStdRateV120, |
| 215 | Q931UserInfoLayer1X31 |
| 216 | }; |
| 217 | |
| 218 | /* |
| 219 | Structure to build store outgoing encoded UUIE |
| 220 | The different fields in the structure have octet lengths |
| 221 | as specified in the spec. |
| 222 | */ |
| 223 | typedef struct Q931InformationElement { |
| 224 | int discriminator; |
| 225 | int offset; |
| 226 | int length; |
| 227 | ASN1OCTET data[1]; |
| 228 | } Q931InformationElement; |
| 229 | |
| 230 | /** |
| 231 | * Q.931 message structure. Contains context for memory allocation, |
| 232 | * protocol discriminator, call reference, meesage type and list of |
| 233 | * user-user information elements (IEs). |
| 234 | */ |
| 235 | typedef struct Q931Message { |
| 236 | ASN1UINT protocolDiscriminator; |
| 237 | ASN1UINT callReference; |
| 238 | ASN1BOOL fromDestination; |
| 239 | ASN1UINT messageType; /* Q931MsgTypes */ |
| 240 | ASN1UINT tunneledMsgType; /* The H245 message this message is tunneling*/ |
| 241 | ASN1INT logicalChannelNo; /* channel number associated with tunneled */ |
| 242 | /* message, 0 if no channel */ |
| 243 | DList ies; |
| 244 | Q931InformationElement *bearerCapabilityIE; |
| 245 | Q931InformationElement *callingPartyNumberIE; |
| 246 | Q931InformationElement *calledPartyNumberIE; |
| 247 | Q931InformationElement *causeIE; |
| 248 | Q931InformationElement *keypadIE; |
| 249 | Q931InformationElement *callstateIE; |
| 250 | H225H323_UserInformation *userInfo; |
| 251 | } Q931Message; |
| 252 | |
| 253 | /** |
| 254 | * This structure is used to hold an H.323 alias address. |
| 255 | */ |
| 256 | typedef struct OOAliases { |
| 257 | int type; /*!< H.225 AliasAddress choice option (t value) */ |
| 258 | char *value; /*!< H.225 AliasAddress value */ |
| 259 | OOBOOL registered; |
| 260 | struct OOAliases *next; |
| 261 | } OOAliases; |
| 262 | |
| 263 | #define ooAliases OOAliases |
| 264 | |
| 265 | struct OOH323CallData; |
| 266 | |
| 267 | /* |
| 268 | * These are message callbacks which can be used by user applications |
| 269 | * to perform application specific things on receiving a particular |
| 270 | * message or before sending a particular message. For ex. user application |
| 271 | * can change values of some parameters of setup message before it is actually |
| 272 | * sent out. |
| 273 | */ |
| 274 | /** |
| 275 | * This callback is triggered when an H.225 SETUP message is received by |
| 276 | * the application. |
| 277 | * @param call The call the message is associated with. |
| 278 | * @param pmsg Q.931 message structure. |
| 279 | * @return OO_OK if message processing successful or OO_FAILED if not. |
| 280 | */ |
| 281 | typedef int (*cb_OnReceivedSetup) |
| 282 | (struct OOH323CallData *call, struct Q931Message *pmsg); |
| 283 | |
| 284 | /** |
| 285 | * This callback is triggered when an H.225 CONNECT message is received by |
| 286 | * the application. |
| 287 | * @param call The call the message is associated with. |
| 288 | * @param pmsg Q.931 message structure. |
| 289 | * @return OO_OK if message processing successful or OO_FAILED if not. |
| 290 | */ |
| 291 | typedef int (*cb_OnReceivedConnect) |
| 292 | (struct OOH323CallData *call, struct Q931Message *pmsg); |
| 293 | |
| 294 | /** |
| 295 | * This callback is triggered after an H.225 SETUP message has been |
| 296 | * constructed and is ready to be sent out. It provides the application |
| 297 | * with an opportunity to add additional non-standard information. |
| 298 | * @param call The call the message is associated with. |
| 299 | * @param pmsg Q.931 message structure. |
| 300 | * @return OO_OK if message processing successful or OO_FAILED if not. |
| 301 | */ |
| 302 | typedef int (*cb_OnBuiltSetup) |
| 303 | (struct OOH323CallData *call, struct Q931Message *pmsg); |
| 304 | |
| 305 | /** |
| 306 | * This callback is triggered after an H.225 CONNECT message has been |
| 307 | * constructed and is ready to be sent out. It provides the application |
| 308 | * with an opportunity to add additional non-standard information. |
| 309 | * @param call The call the message is associated with. |
| 310 | * @param pmsg Q.931 message structure. |
| 311 | * @return OO_OK if message processing successful or OO_FAILED if not. |
| 312 | */ |
| 313 | typedef int (*cb_OnBuiltConnect) |
| 314 | (struct OOH323CallData *call, struct Q931Message *pmsg); |
| 315 | |
| 316 | /** |
| 317 | * This structure holds the various callback functions that are |
| 318 | * triggered when H.225 messages are received or constructed. |
| 319 | * @see ooH323EpSetH225MsgCallbacks |
| 320 | */ |
| 321 | typedef struct OOH225MsgCallbacks { |
| 322 | cb_OnReceivedSetup onReceivedSetup; |
| 323 | cb_OnReceivedConnect onReceivedConnect; |
| 324 | cb_OnBuiltSetup onBuiltSetup; |
| 325 | cb_OnBuiltConnect onBuiltConnect; |
| 326 | } OOH225MsgCallbacks; |
| 327 | |
| 328 | /** |
| 329 | * This function is invoked to decode a Q931 message. |
| 330 | * |
| 331 | * @param call Handle to call which owns the message. |
| 332 | * @param msg Pointer to the Q931 message |
| 333 | * @param length Length of the encoded data |
| 334 | * @param data Pointer to the data to be decoded |
| 335 | * |
| 336 | * @return Completion status - 0 on success, -1 on failure |
| 337 | */ |
| 338 | EXTERN int ooQ931Decode |
| 339 | (struct OOH323CallData *call, Q931Message* msg, int length, ASN1OCTET *data, int docallbacks); |
| 340 | |
| 341 | /** |
| 342 | * This function is used to decode the UUIE of the message from the list of |
| 343 | * ies. It decodes the User-User ie and populates the userInfo field of the |
| 344 | * message. |
| 345 | * @param q931Msg Pointer to the message whose User-User ie has to be |
| 346 | * decoded. |
| 347 | * |
| 348 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 349 | */ |
| 350 | EXTERN int ooDecodeUUIE(OOCTXT* pctxt, Q931Message *q931Msg); |
| 351 | |
| 352 | /** |
| 353 | * This function is used to encode the UUIE field of the Q931 message. |
| 354 | * It encodes UUIE and adds the encoded data to the list of ies. |
| 355 | * @param q931msg Pointer to the Q931 message whose UUIE field has to be |
| 356 | * encoded. |
| 357 | * |
| 358 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 359 | */ |
| 360 | EXTERN int ooEncodeUUIE(OOCTXT* pctxt, Q931Message *q931msg); |
| 361 | |
| 362 | /** |
| 363 | * This function is invoked to retrieve an IE element from a Q931 message. |
| 364 | * |
| 365 | * @param q931msg Pointer to the Q931 message |
| 366 | * @param ieCode IE code for the IE element to be retrieved |
| 367 | * |
| 368 | * @return Pointer to a Q931InformationElement contating |
| 369 | * the IE element. |
| 370 | */ |
| 371 | EXTERN Q931InformationElement* ooQ931GetIE (const Q931Message* q931msg, |
| 372 | int ieCode); |
| 373 | |
| 374 | /** |
| 375 | * This function is invoked to print a Q931 message. |
| 376 | * |
| 377 | * @param q931msg Pointer to the Q931 message |
| 378 | * |
| 379 | * @return - none |
| 380 | */ |
| 381 | EXTERN void ooQ931Print (const Q931Message* q931msg); |
| 382 | |
| 383 | |
| 384 | /** |
| 385 | * This function is invoked to create an outgoing Q931 message. |
| 386 | * |
| 387 | * @param msg Reference to the pointer of type Q931 message. |
| 388 | * @param msgType Type of Q931 message to be created |
| 389 | * |
| 390 | * @return Completion status - 0 on success, -1 on failure |
| 391 | */ |
| 392 | EXTERN int ooCreateQ931Message(OOCTXT* pctxt, Q931Message **msg, int msgType); |
| 393 | |
| 394 | /** |
| 395 | * This function is invoked to generate a unique call reference number. |
| 396 | * |
| 397 | * @return - call reference number |
| 398 | */ |
| 399 | EXTERN ASN1USINT ooGenerateCallReference(void); |
| 400 | |
| 401 | |
| 402 | /** |
| 403 | * This function is used to generate a unique call identifier for the call. |
| 404 | * @param callid Pointer to the callid structure, which will be populated |
| 405 | * with the generated callid. |
| 406 | * |
| 407 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 408 | */ |
| 409 | EXTERN int ooGenerateCallIdentifier(H225CallIdentifier *callid); |
| 410 | |
| 411 | /** |
| 412 | * This function is invoked to release the memory used up by a Q931 message |
| 413 | * |
| 414 | * @param q931Msg Pointer to a Q931 message which has to be freed. |
| 415 | * |
| 416 | * @return Completion status - 0 on success, -1 on failure |
| 417 | */ |
| 418 | EXTERN int ooFreeQ931Message(OOCTXT* pctxt, Q931Message *q931Msg); |
| 419 | |
| 420 | /** |
| 421 | * This function is invoked to retrive the outgoing message buffer for |
| 422 | * Q931 message |
| 423 | * |
| 424 | * @param call Pointer to call for which outgoing Q931 message has to be |
| 425 | * retrieved. |
| 426 | * @param msgbuf Pointer to a buffer in which retrieved message will |
| 427 | * be returned. |
| 428 | * @param len Pointer to int in which length of the buffer will |
| 429 | * be returned. |
| 430 | * @param msgType Pointer to integer in which message type of the ougoing |
| 431 | * message is returned. |
| 432 | * |
| 433 | * @return Completion status - 0 on success, -1 on failure |
| 434 | */ |
| 435 | EXTERN int ooGetOutgoingQ931Msgbuf |
| 436 | (struct OOH323CallData *call, ASN1OCTET * msgbuf, int* len, int *msgType); |
| 437 | |
| 438 | /** |
| 439 | * This function is invoked to send a ReleaseComplete message for |
| 440 | * the currently active call. |
| 441 | * |
| 442 | * @param call Pointer to the call for which ReleaseComplete message have |
| 443 | * to be sent. |
| 444 | * |
| 445 | * @return Completion status - 0 on success, -1 on failure |
| 446 | */ |
| 447 | EXTERN int ooSendReleaseComplete(struct OOH323CallData *call); |
| 448 | |
| 449 | /** |
| 450 | * This function is invoked to send a call proceeding message in response to |
| 451 | * received setup message. |
| 452 | * |
| 453 | * @param call Pointer to the call for which CallProceeding message have to |
| 454 | * be sent. |
| 455 | * |
| 456 | * @return Completion status - 0 on success, -1 on failure |
| 457 | */ |
| 458 | EXTERN int ooSendCallProceeding(struct OOH323CallData *call); |
| 459 | |
| 460 | /** |
| 461 | * This function is invoked to send alerting message in response to received |
| 462 | * setup message. |
| 463 | * |
| 464 | * @param call Pointer to the call for which Alerting message have to be |
| 465 | * sent. |
| 466 | * |
| 467 | * @return Completion status - 0 on success, -1 on failure |
| 468 | */ |
| 469 | EXTERN int ooSendAlerting(struct OOH323CallData *call); |
| 470 | |
| 471 | EXTERN int ooSendProgress(struct OOH323CallData *call); |
| 472 | |
| 473 | EXTERN int ooSendStatus(struct OOH323CallData *call); |
| 474 | |
| 475 | EXTERN int ooSendStatusInquiry(struct OOH323CallData *call); |
| 476 | |
| 477 | /** |
| 478 | * This function is invoked to send Facility message. |
| 479 | * |
| 480 | * @param call Pointer to the call for which Facility message have to be |
| 481 | * sent. |
| 482 | * |
| 483 | * @return Completion status - 0 on success, -1 on failure |
| 484 | */ |
| 485 | EXTERN int ooSendFacility(struct OOH323CallData *call); |
| 486 | |
| 487 | |
| 488 | /** |
| 489 | * This function is used to send dtmf data as Q931 keypad information element |
| 490 | * as part of information message. |
| 491 | * @param call Pointer to the call for dtmf data has to be sent. |
| 492 | * @param data Dtmf data to be sent. |
| 493 | * |
| 494 | * @return OO_OK, on success; OO_FAILED, on failure. |
| 495 | */ |
| 496 | EXTERN int ooQ931SendDTMFAsKeyPadIE |
| 497 | (struct OOH323CallData *call, const char* data); |
| 498 | |
| 499 | /** |
| 500 | * This function is invoked to send a Connect message in response to received |
| 501 | * setup message. |
| 502 | * |
| 503 | * @param call Pointer to the call for which connect message has to be |
| 504 | * sent. |
| 505 | * |
| 506 | * @return Completion status - 0 on success, -1 on failure |
| 507 | */ |
| 508 | EXTERN int ooSendConnect(struct OOH323CallData *call); |
| 509 | |
| 510 | /** |
| 511 | * This function is used to send a SETUP message for outgoing call. It first |
| 512 | * creates an H.225 TCP connection with the remote end point and then sends |
| 513 | * SETUP message over this connection. |
| 514 | * @param dest Destination - IP:Port/alias. |
| 515 | * @param callToken Unique token for the new call. |
| 516 | * @param opts Call specific options. If passed a non-null value, these |
| 517 | * options will override global endpoint settings. |
| 518 | * |
| 519 | * @return OO_OK, on success. OO_FAILED, on failure |
| 520 | */ |
| 521 | EXTERN int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts); |
| 522 | |
| 523 | /** |
| 524 | * Helper function used to make a call once it is approved by the Gk. |
| 525 | * In case of no gk, this function is directly called to make a call. |
| 526 | * @param call Handle to the new call. |
| 527 | * |
| 528 | * @return OO_OK, on success. OO_FAILED, on failure |
| 529 | */ |
| 530 | int ooH323CallAdmitted( struct OOH323CallData *call); |
| 531 | |
| 532 | /** |
| 533 | * This function is used to handle a call forward request sent to local |
| 534 | * endpoint by remote endpoint. |
| 535 | * @param call Handle to the call which is being forwarded |
| 536 | * |
| 537 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 538 | */ |
| 539 | EXTERN int ooH323HandleCallFwdRequest(struct OOH323CallData *call); |
| 540 | |
| 541 | /** |
| 542 | * This function is used for forwarding/redirecting a call to third party. |
| 543 | * @param callToken callToken for the call which has to be redirected. |
| 544 | * @param dest Address to which call has to be forwarded. Can be |
| 545 | * IP:Port or alias. |
| 546 | * |
| 547 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 548 | */ |
| 549 | EXTERN int ooH323ForwardCall(char* callToken, char *dest); |
| 550 | |
| 551 | /** |
| 552 | * This function is used to hangup a currently active call. It sets the call |
| 553 | * state to CLEARING and initiates closing of all logical channels. |
| 554 | * @param callToken Unique token of the call to be hanged. |
| 555 | * @param reason Reason for ending call. |
| 556 | * |
| 557 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 558 | */ |
| 559 | EXTERN int ooH323HangCall(char * callToken, OOCallClearReason reason, int q931); |
| 560 | |
| 561 | |
| 562 | /** |
| 563 | * Function to accept a call by sending connect. This function is used |
| 564 | * as a helper function to ooSendConnect. |
| 565 | * @param call Pointer to the call for which connect has to be sent |
| 566 | * |
| 567 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 568 | */ |
| 569 | EXTERN int ooAcceptCall(struct OOH323CallData *call); |
| 570 | |
| 571 | /* |
| 572 | * An helper function to ooMakeCall. |
| 573 | * @param call Pointer to the new call. |
| 574 | * |
| 575 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 576 | */ |
| 577 | EXTERN int ooH323MakeCall_helper(struct OOH323CallData *call); |
| 578 | |
| 579 | /** |
| 580 | * This function is used to parse the destination |
| 581 | * @param call Handle to related call. |
| 582 | * @param dest Destination string to be parsed. |
| 583 | * @param parsedIP Pointer to buffer in which parsed ip:port will be returned. |
| 584 | * @param len Length of the buffer passed. |
| 585 | * @param aliasList Aliases List in which new aliases will be added. |
| 586 | * |
| 587 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 588 | */ |
| 589 | int ooParseDestination |
| 590 | (struct OOH323CallData *call, char *dest, char *parsedIP, unsigned len, |
| 591 | OOAliases** aliasList); |
| 592 | |
| 593 | /** |
| 594 | * This function is used to generate a new call token |
| 595 | * @param callToken Handle to the buffer in which new call token will be |
| 596 | * returned |
| 597 | * @param size size of the buffer |
| 598 | * |
| 599 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 600 | */ |
| 601 | int ooGenerateCallToken (char *callToken, size_t size); |
| 602 | |
| 603 | |
| 604 | /** |
| 605 | * This function sends an encoded H.245 message buffer as a tunneled |
| 606 | * H.245 Facility message. |
| 607 | * @param call Pointer to the call for which H.245 message has to |
| 608 | * be tunneled. |
| 609 | * @param msgbuf Pointer to the encoded H.245 message to be tunneled. |
| 610 | * |
| 611 | * @param h245Len Length of the encoded H.245 message buffer. |
| 612 | * @param h245MsgType Type of the H245 message |
| 613 | * @param associatedChan The logical channel number with which the tunneled |
| 614 | * message is associated. In case of no channel, this |
| 615 | * value should be 0. |
| 616 | * |
| 617 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 618 | */ |
| 619 | EXTERN int ooSendAsTunneledMessage |
| 620 | (struct OOH323CallData *call, ASN1OCTET* msgbuf, |
| 621 | int h245Len, int h245MsgType, int associatedChan); |
| 622 | |
| 623 | |
| 624 | /** |
| 625 | * This function is used to encode an H.225 message. |
| 626 | * @param call Handle to the call. |
| 627 | * @param pq931Msg Pointer to the message to be encoded. |
| 628 | * @param msgbuf Pointer to the buffer in which encoded message will |
| 629 | * be returned. |
| 630 | * @param size Size of the buffer passed. |
| 631 | * |
| 632 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 633 | */ |
| 634 | int ooEncodeH225Message(struct OOH323CallData *call, Q931Message *pq931Msg, |
| 635 | char *msgbuf, int size); |
| 636 | |
| 637 | /** |
| 638 | * This is a callback function which is called when there is no CONNECT |
| 639 | * response from the remote endpoint after the SETUP has been sent and timeout |
| 640 | * period has passed. |
| 641 | * @param data The callback data registered at the time of timer |
| 642 | * creation. |
| 643 | * |
| 644 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 645 | */ |
| 646 | int ooCallEstbTimerExpired(void *data); |
| 647 | |
| 648 | |
| 649 | |
| 650 | /** |
| 651 | * This function is used to add a keypad IE to a Q931 message for sending dtmf. |
| 652 | * @param pmsg Q931 message to which keypad ie has to be |
| 653 | * added. |
| 654 | * @param data DTMF data to be sent. |
| 655 | * |
| 656 | * @return OO_OK on success, OO_FAILED, on failure. |
| 657 | */ |
| 658 | EXTERN int ooQ931SetKeypadIE(OOCTXT* pctxt, Q931Message *pmsg, const char* data); |
| 659 | |
| 660 | /** |
| 661 | * This function is used to add a bearer capability IE to a Q931 message. |
| 662 | * @param pmsg Q931 message to which bearer capability ie has to be |
| 663 | * added. |
| 664 | * @param codingStandard Coding standard to be used. |
| 665 | * @param capability Information transfer capability |
| 666 | * @param transferMode Information transfer mode.(circuit/packet modes). |
| 667 | * @param transferRate Information transfer rate. |
| 668 | * @param userInfoLayer1 User information layer 1 protocol. |
| 669 | * |
| 670 | * @return OO_OK on success, OO_FAILED, on failure. |
| 671 | */ |
| 672 | EXTERN int ooSetBearerCapabilityIE |
| 673 | (OOCTXT* pctxt, Q931Message *pmsg, enum Q931CodingStandard codingStandard, |
| 674 | enum Q931InformationTransferCapability capability, |
| 675 | enum Q931TransferMode transferMode, enum Q931TransferRate transferRate, |
| 676 | enum Q931UserInfoLayer1Protocol userInfoLayer1); |
| 677 | |
| 678 | /** |
| 679 | * This function is used to add a called party number ie to a q931 message. |
| 680 | * @param pmsg Q931 message to which CalledPartyNumber IE has to be |
| 681 | * added. |
| 682 | * @param number Number for called party. |
| 683 | * @param plan Numbering Plan used |
| 684 | * @param type Type of number |
| 685 | * |
| 686 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 687 | */ |
| 688 | EXTERN int ooQ931SetCalledPartyNumberIE |
| 689 | (OOCTXT *pctxt, Q931Message *pmsg, const char *number, unsigned plan, unsigned type); |
| 690 | |
| 691 | |
| 692 | /** |
| 693 | * This function is used to add a CallingPartyNumber ie to a q931 message. |
| 694 | * @param pmsg Q931 message to which CallingPartyNumber IE has to be |
| 695 | * added. |
| 696 | * @param number Number for calling party. |
| 697 | * @param plan Numbering Plan used |
| 698 | * @param type Type of number |
| 699 | * @param presentation Presentation of the address is allowed or restricted. |
| 700 | * @param screening Whether address was provided by endpoint or screened |
| 701 | * by gatekeeper. |
| 702 | * |
| 703 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 704 | */ |
| 705 | EXTERN int ooQ931SetCallingPartyNumberIE |
| 706 | (OOCTXT* pctxt, Q931Message *pmsg, const char *number, unsigned plan, unsigned type, |
| 707 | unsigned presentation, unsigned screening); |
| 708 | |
| 709 | /** |
| 710 | * This function is used to set a cause ie for a q931 message. |
| 711 | * @param pmsg Valid Q931 Message |
| 712 | * @param cause Q931 Cause Value |
| 713 | * @param coding coding standard used. 0 for ITU-T standard coding |
| 714 | * @param location location. 0 for user. |
| 715 | * |
| 716 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 717 | */ |
| 718 | EXTERN int ooQ931SetCauseIE |
| 719 | (OOCTXT *pctxt, Q931Message *pmsg,enum Q931CauseValues cause, unsigned coding, |
| 720 | unsigned location); |
| 721 | |
| 722 | EXTERN int ooQ931SetCallStateIE |
| 723 | (OOCTXT *pctxt, Q931Message *pmsg, unsigned char callstate); |
| 724 | |
| 725 | /** |
| 726 | * This function is used to convert a call clear reason to cause and |
| 727 | * reason code. It is used when local user is endoing the call and |
| 728 | * sending releaseComplete. |
| 729 | * @param clearReason Reason for ending call. |
| 730 | * @param cause Pointer to Q931CauseVaules enum in which cause |
| 731 | * will be returned. |
| 732 | * @param reasonCode Pointer to unsigned int in which reasonCode will |
| 733 | * be returned. |
| 734 | * |
| 735 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 736 | */ |
| 737 | EXTERN int ooQ931GetCauseAndReasonCodeFromCallClearReason |
| 738 | (OOCallClearReason clearReason, enum Q931CauseValues *cause, |
| 739 | unsigned *reasonCode); |
| 740 | |
| 741 | /** |
| 742 | * This function is used to convert a cause value and reason code received |
| 743 | * in ReleaseComplete message from remote endpoint into a CallClearReason. |
| 744 | * @param cause cause value received. |
| 745 | * @param reasonCode reasonCode received. |
| 746 | * |
| 747 | * @return Returns a CallClearReason. |
| 748 | */ |
| 749 | EXTERN OOCallClearReason ooGetCallClearReasonFromCauseAndReasonCode |
| 750 | (enum Q931CauseValues cause, unsigned reasonCode); |
| 751 | |
| 752 | /** |
| 753 | * This function is used to retrieve the description text for a |
| 754 | * message type. |
| 755 | * |
| 756 | * @param msgType Message type. |
| 757 | * @return The text description string. |
| 758 | */ |
| 759 | EXTERN const char* ooGetMsgTypeText (int msgType); |
| 760 | |
| 761 | /** |
| 762 | * This function is used to retrieve the text description for a Q931 Cause |
| 763 | * value in Cause IE. |
| 764 | * @param val Q931 Cause value |
| 765 | * @return The text description string |
| 766 | */ |
| 767 | EXTERN const char* ooGetQ931CauseValueText (int val); |
| 768 | |
| 769 | EXTERN int ooH323NewCall(char *callToken); |
| 770 | |
| 771 | EXTERN char* ooQ931GetMessageTypeName(int messageType, char* buf); |
| 772 | EXTERN char* ooQ931GetIEName(int number, char* buf); |
| 773 | EXTERN int ooSendTCSandMSD(struct OOH323CallData *call); |
| 774 | EXTERN int ooSendStartH245Facility(struct OOH323CallData *call); |
| 775 | EXTERN int ooSendFSUpdate(struct OOH323CallData *call); |
| 776 | EXTERN int ooHandleFastStartChannels(struct OOH323CallData *pCall); |
| 777 | |
| 778 | /** |
| 779 | * @} |
| 780 | */ |
| 781 | #ifdef __cplusplus |
| 782 | } |
| 783 | #endif |
| 784 | |
| 785 | #endif /* __Q931HDR_H */ |