| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "asterisk.h" |
| 17 |
#include "asterisk/lock.h" |
| 18 |
|
| 19 |
#include "ooh323ep.h" |
| 20 |
#include "ootrace.h" |
| 21 |
#include "ooCalls.h" |
| 22 |
#include "ooCapability.h" |
| 23 |
#include "ooGkClient.h" |
| 24 |
#include "ooStackCmds.h" |
| 25 |
#include "ooCmdChannel.h" |
| 26 |
|
| 27 |
ooEndPoint gH323ep; |
| 28 |
|
| 29 |
ast_mutex_t monitorLock; |
| 30 |
ast_mutex_t callListLock; |
| 31 |
ast_mutex_t newCallLock; |
| 32 |
ast_mutex_t bindPortLock; |
| 33 |
|
| 34 |
extern DList g_TimerList; |
| 35 |
|
| 36 |
int ooH323EpInitialize |
| 37 |
(enum OOCallMode callMode, const char* tracefile, char* errstr, int errstr_max) |
| 38 |
{ |
| 39 |
|
| 40 |
memset(&gH323ep, 0, sizeof(ooEndPoint)); |
| 41 |
|
| 42 |
initContext(&(gH323ep.ctxt)); |
| 43 |
initContext(&(gH323ep.msgctxt)); |
| 44 |
|
| 45 |
if(tracefile) |
| 46 |
{ |
| 47 |
if(strlen(tracefile)>= MAXFILENAME) |
| 48 |
{ |
| 49 |
snprintf(errstr, errstr_max, "Error:File name longer than allowed maximum %d\n", |
| 50 |
MAXFILENAME-1); |
| 51 |
return OO_FAILED; |
| 52 |
} |
| 53 |
strcpy(gH323ep.traceFile, tracefile); |
| 54 |
} |
| 55 |
else{ |
| 56 |
strcpy(gH323ep.traceFile, DEFAULT_TRACEFILE); |
| 57 |
} |
| 58 |
|
| 59 |
gH323ep.fptraceFile = fopen(gH323ep.traceFile, "a"); |
| 60 |
if(gH323ep.fptraceFile == NULL) |
| 61 |
{ |
| 62 |
snprintf(errstr, errstr_max, "Error:Failed to open trace file %s for write.\n", |
| 63 |
gH323ep.traceFile); |
| 64 |
return OO_FAILED; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
gH323ep.tcpPorts.start = TCPPORTSSTART; |
| 72 |
gH323ep.tcpPorts.max = TCPPORTSEND; |
| 73 |
gH323ep.tcpPorts.current=TCPPORTSSTART; |
| 74 |
|
| 75 |
gH323ep.udpPorts.start = UDPPORTSSTART; |
| 76 |
gH323ep.udpPorts.max = UDPPORTSEND; |
| 77 |
gH323ep.udpPorts.current = UDPPORTSSTART; |
| 78 |
|
| 79 |
gH323ep.rtpPorts.start = RTPPORTSSTART; |
| 80 |
gH323ep.rtpPorts.max = RTPPORTSEND; |
| 81 |
gH323ep.rtpPorts.current = RTPPORTSSTART; |
| 82 |
|
| 83 |
OO_SETFLAG(gH323ep.flags, OO_M_FASTSTART); |
| 84 |
OO_SETFLAG(gH323ep.flags, OO_M_TUNNELING); |
| 85 |
OO_SETFLAG(gH323ep.flags, OO_M_AUTOANSWER); |
| 86 |
OO_CLRFLAG(gH323ep.flags, OO_M_GKROUTED); |
| 87 |
|
| 88 |
gH323ep.aliases = NULL; |
| 89 |
|
| 90 |
gH323ep.termType = DEFAULT_TERMTYPE; |
| 91 |
|
| 92 |
gH323ep.t35CountryCode = DEFAULT_T35COUNTRYCODE; |
| 93 |
|
| 94 |
gH323ep.t35Extension = DEFAULT_T35EXTENSION; |
| 95 |
|
| 96 |
gH323ep.manufacturerCode = DEFAULT_MANUFACTURERCODE; |
| 97 |
|
| 98 |
gH323ep.productID = DEFAULT_PRODUCTID; |
| 99 |
|
| 100 |
gH323ep.versionID = OOH323C_VERSION; |
| 101 |
|
| 102 |
gH323ep.callType = T_H225CallType_pointToPoint; |
| 103 |
ooGetLocalIPAddress(gH323ep.signallingIP); |
| 104 |
gH323ep.listenPort = DEFAULT_H323PORT; |
| 105 |
|
| 106 |
gH323ep.listener = NULL; |
| 107 |
|
| 108 |
ooH323EpSetCallerID(DEFAULT_CALLERID); |
| 109 |
|
| 110 |
|
| 111 |
gH323ep.myCaps = NULL; |
| 112 |
gH323ep.noOfCaps = 0; |
| 113 |
gH323ep.callList = NULL; |
| 114 |
ast_mutex_init(&monitorLock); |
| 115 |
ast_mutex_init(&callListLock); |
| 116 |
ast_mutex_init(&newCallLock); |
| 117 |
ast_mutex_init(&bindPortLock); |
| 118 |
gH323ep.dtmfmode = 0; |
| 119 |
gH323ep.callingPartyNumber[0]='\0'; |
| 120 |
gH323ep.callMode = callMode; |
| 121 |
gH323ep.isGateway = FALSE; |
| 122 |
|
| 123 |
dListInit(&g_TimerList); |
| 124 |
|
| 125 |
gH323ep.callEstablishmentTimeout = DEFAULT_CALLESTB_TIMEOUT; |
| 126 |
|
| 127 |
gH323ep.msdTimeout = DEFAULT_MSD_TIMEOUT; |
| 128 |
|
| 129 |
gH323ep.tcsTimeout = DEFAULT_TCS_TIMEOUT; |
| 130 |
|
| 131 |
gH323ep.logicalChannelTimeout = DEFAULT_LOGICALCHAN_TIMEOUT; |
| 132 |
|
| 133 |
gH323ep.sessionTimeout = DEFAULT_ENDSESSION_TIMEOUT; |
| 134 |
gH323ep.ifList = NULL; |
| 135 |
|
| 136 |
ooSetTraceThreshold(OOTRCLVLINFO); |
| 137 |
OO_SETFLAG(gH323ep.flags, OO_M_ENDPOINTCREATED); |
| 138 |
|
| 139 |
gH323ep.cmdSock = 0; |
| 140 |
return OO_OK; |
| 141 |
} |
| 142 |
|
| 143 |
EXTERN int ooH323EpSetAsGateway() |
| 144 |
{ |
| 145 |
gH323ep.isGateway = TRUE; |
| 146 |
return OO_OK; |
| 147 |
} |
| 148 |
|
| 149 |
EXTERN void ooH323EpSetVersionInfo(int t35cc, int t35ext, int manc, char* prodid, char* verid) { |
| 150 |
|
| 151 |
if (t35cc) gH323ep.t35CountryCode = t35cc; |
| 152 |
if (t35ext) gH323ep.t35Extension = t35ext; |
| 153 |
if (manc) gH323ep.manufacturerCode = manc; |
| 154 |
if (prodid != NULL && prodid[0]) gH323ep.productID = prodid; |
| 155 |
if (verid != NULL && verid[0]) gH323ep.versionID = verid; |
| 156 |
} |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
int ooH323EpSetLocalAddress(const char* localip, int listenport) |
| 161 |
{ |
| 162 |
if(localip) |
| 163 |
{ |
| 164 |
strcpy(gH323ep.signallingIP, localip); |
| 165 |
OOTRACEINFO2("Signalling IP address is set to %s\n", localip); |
| 166 |
} |
| 167 |
|
| 168 |
if(listenport) |
| 169 |
{ |
| 170 |
gH323ep.listenPort = listenport; |
| 171 |
OOTRACEINFO2("Listen port number is set to %d\n", listenport); |
| 172 |
} |
| 173 |
return OO_OK; |
| 174 |
} |
| 175 |
|
| 176 |
int ooH323EpAddAliasH323ID(const char *h323id) |
| 177 |
{ |
| 178 |
ooAliases * psNewAlias=NULL; |
| 179 |
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases)); |
| 180 |
if(!psNewAlias) |
| 181 |
{ |
| 182 |
OOTRACEERR1("Error: Failed to allocate memory for new H323-ID alias\n"); |
| 183 |
return OO_FAILED; |
| 184 |
} |
| 185 |
psNewAlias->type = T_H225AliasAddress_h323_ID; |
| 186 |
psNewAlias->registered = FALSE; |
| 187 |
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(h323id)+1); |
| 188 |
if(!psNewAlias->value) |
| 189 |
{ |
| 190 |
OOTRACEERR1("Error: Failed to allocate memory for the new H323-ID alias " |
| 191 |
"value\n"); |
| 192 |
memFreePtr(&gH323ep.ctxt, psNewAlias); |
| 193 |
return OO_FAILED; |
| 194 |
} |
| 195 |
strcpy(psNewAlias->value, h323id); |
| 196 |
psNewAlias->next = gH323ep.aliases; |
| 197 |
gH323ep.aliases = psNewAlias; |
| 198 |
OOTRACEDBGA2("Added alias: H323ID - %s\n", h323id); |
| 199 |
return OO_OK; |
| 200 |
} |
| 201 |
|
| 202 |
int ooH323EpAddAliasDialedDigits(const char* dialedDigits) |
| 203 |
{ |
| 204 |
ooAliases * psNewAlias=NULL; |
| 205 |
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases)); |
| 206 |
if(!psNewAlias) |
| 207 |
{ |
| 208 |
OOTRACEERR1("Error: Failed to allocate memory for new DialedDigits " |
| 209 |
"alias\n"); |
| 210 |
return OO_FAILED; |
| 211 |
} |
| 212 |
psNewAlias->type = T_H225AliasAddress_dialedDigits; |
| 213 |
psNewAlias->registered = FALSE; |
| 214 |
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(dialedDigits)+1); |
| 215 |
if(!psNewAlias->value) |
| 216 |
{ |
| 217 |
OOTRACEERR1("Error: Failed to allocate memory for the new DialedDigits" |
| 218 |
" alias value\n"); |
| 219 |
memFreePtr(&gH323ep.ctxt, psNewAlias); |
| 220 |
return OO_FAILED; |
| 221 |
} |
| 222 |
strcpy(psNewAlias->value, dialedDigits); |
| 223 |
psNewAlias->next = gH323ep.aliases; |
| 224 |
gH323ep.aliases = psNewAlias; |
| 225 |
OOTRACEDBGA2("Added alias: DialedDigits - %s\n", dialedDigits); |
| 226 |
return OO_OK; |
| 227 |
} |
| 228 |
|
| 229 |
int ooH323EpAddAliasURLID(const char * url) |
| 230 |
{ |
| 231 |
ooAliases * psNewAlias=NULL; |
| 232 |
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases)); |
| 233 |
if(!psNewAlias) |
| 234 |
{ |
| 235 |
OOTRACEERR1("Error: Failed to allocate memory for new URL-ID alias\n"); |
| 236 |
return OO_FAILED; |
| 237 |
} |
| 238 |
psNewAlias->type = T_H225AliasAddress_url_ID; |
| 239 |
psNewAlias->registered = FALSE; |
| 240 |
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(url)+1); |
| 241 |
if(!psNewAlias->value) |
| 242 |
{ |
| 243 |
OOTRACEERR1("Error: Failed to allocate memory for the new URL-ID alias" |
| 244 |
" value\n"); |
| 245 |
memFreePtr(&gH323ep.ctxt, psNewAlias); |
| 246 |
return OO_FAILED; |
| 247 |
} |
| 248 |
strcpy(psNewAlias->value, url); |
| 249 |
psNewAlias->next = gH323ep.aliases; |
| 250 |
gH323ep.aliases = psNewAlias; |
| 251 |
OOTRACEDBGA2("Added alias: URL-ID - %s\n", url); |
| 252 |
return OO_OK; |
| 253 |
} |
| 254 |
|
| 255 |
int ooH323EpAddAliasEmailID(const char * email) |
| 256 |
{ |
| 257 |
ooAliases * psNewAlias=NULL; |
| 258 |
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases)); |
| 259 |
if(!psNewAlias) |
| 260 |
{ |
| 261 |
OOTRACEERR1("Error: Failed to allocate memory for new Email-ID alias\n"); |
| 262 |
return OO_FAILED; |
| 263 |
} |
| 264 |
psNewAlias->type = T_H225AliasAddress_email_ID; |
| 265 |
psNewAlias->registered = FALSE; |
| 266 |
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(email)+1); |
| 267 |
if(!psNewAlias->value) |
| 268 |
{ |
| 269 |
OOTRACEERR1("Error: Failed to allocate memory for the new Email-ID alias" |
| 270 |
" value\n"); |
| 271 |
memFreePtr(&gH323ep.ctxt, psNewAlias); |
| 272 |
return OO_FAILED; |
| 273 |
} |
| 274 |
strcpy(psNewAlias->value, email); |
| 275 |
psNewAlias->next = gH323ep.aliases; |
| 276 |
gH323ep.aliases = psNewAlias; |
| 277 |
OOTRACEDBGA2("Added alias: Email-ID - %s\n", email); |
| 278 |
return OO_OK; |
| 279 |
} |
| 280 |
|
| 281 |
int ooH323EpAddAliasTransportID(const char * ipaddress) |
| 282 |
{ |
| 283 |
ooAliases * psNewAlias=NULL; |
| 284 |
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases)); |
| 285 |
if(!psNewAlias) |
| 286 |
{ |
| 287 |
OOTRACEERR1("Error: Failed to allocate memory for new Transport-ID " |
| 288 |
"alias\n"); |
| 289 |
return OO_FAILED; |
| 290 |
} |
| 291 |
psNewAlias->type = T_H225AliasAddress_transportID; |
| 292 |
psNewAlias->registered = FALSE; |
| 293 |
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(ipaddress)+1); |
| 294 |
if(!psNewAlias->value) |
| 295 |
{ |
| 296 |
OOTRACEERR1("Error: Failed to allocate memory for the new Transport-ID " |
| 297 |
"alias value\n"); |
| 298 |
memFreePtr(&gH323ep.ctxt, psNewAlias); |
| 299 |
return OO_FAILED; |
| 300 |
} |
| 301 |
strcpy(psNewAlias->value, ipaddress); |
| 302 |
psNewAlias->next = gH323ep.aliases; |
| 303 |
gH323ep.aliases = psNewAlias; |
| 304 |
OOTRACEDBGA2("Added alias: Transport-ID - %s\n", ipaddress); |
| 305 |
return OO_OK; |
| 306 |
} |
| 307 |
|
| 308 |
int ooH323EpClearAllAliases(void) |
| 309 |
{ |
| 310 |
ooAliases *pAlias = NULL, *pTemp; |
| 311 |
if(gH323ep.aliases) |
| 312 |
{ |
| 313 |
pAlias = gH323ep.aliases; |
| 314 |
while(pAlias) |
| 315 |
{ |
| 316 |
pTemp = pAlias; |
| 317 |
pAlias = pAlias->next; |
| 318 |
memFreePtr(&gH323ep.ctxt, pTemp); |
| 319 |
} |
| 320 |
gH323ep.aliases = NULL; |
| 321 |
} |
| 322 |
return OO_OK; |
| 323 |
} |
| 324 |
|
| 325 |
|
| 326 |
int ooH323EpSetH225MsgCallbacks(OOH225MsgCallbacks h225Callbacks) |
| 327 |
{ |
| 328 |
gH323ep.h225Callbacks.onReceivedSetup = h225Callbacks.onReceivedSetup; |
| 329 |
gH323ep.h225Callbacks.onReceivedConnect = h225Callbacks.onReceivedConnect; |
| 330 |
gH323ep.h225Callbacks.onBuiltSetup = h225Callbacks.onBuiltSetup; |
| 331 |
gH323ep.h225Callbacks.onBuiltConnect = h225Callbacks.onBuiltConnect; |
| 332 |
|
| 333 |
return OO_OK; |
| 334 |
} |
| 335 |
|
| 336 |
int ooH323EpSetH323Callbacks(OOH323CALLBACKS h323Callbacks) |
| 337 |
{ |
| 338 |
gH323ep.h323Callbacks.onNewCallCreated = h323Callbacks.onNewCallCreated; |
| 339 |
gH323ep.h323Callbacks.onAlerting = h323Callbacks.onAlerting; |
| 340 |
gH323ep.h323Callbacks.onProgress = h323Callbacks.onProgress; |
| 341 |
gH323ep.h323Callbacks.onIncomingCall = h323Callbacks.onIncomingCall; |
| 342 |
gH323ep.h323Callbacks.onOutgoingCall = h323Callbacks.onOutgoingCall; |
| 343 |
gH323ep.h323Callbacks.onCallEstablished = h323Callbacks.onCallEstablished; |
| 344 |
gH323ep.h323Callbacks.onCallForwarded = h323Callbacks.onCallForwarded; |
| 345 |
gH323ep.h323Callbacks.onCallCleared = h323Callbacks.onCallCleared; |
| 346 |
gH323ep.h323Callbacks.openLogicalChannels = h323Callbacks.openLogicalChannels; |
| 347 |
gH323ep.h323Callbacks.onReceivedDTMF = h323Callbacks.onReceivedDTMF; |
| 348 |
gH323ep.h323Callbacks.onModeChanged = h323Callbacks.onModeChanged; |
| 349 |
gH323ep.h323Callbacks.onMediaChanged = h323Callbacks.onMediaChanged; |
| 350 |
return OO_OK; |
| 351 |
} |
| 352 |
|
| 353 |
int ooH323EpDestroy(void) |
| 354 |
{ |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
OOH323CallData * cur, *temp; |
| 359 |
if(OO_TESTFLAG(gH323ep.flags, OO_M_ENDPOINTCREATED)) |
| 360 |
{ |
| 361 |
OOTRACEINFO1("Destroying H323 Endpoint\n"); |
| 362 |
if(gH323ep.callList) |
| 363 |
{ |
| 364 |
cur = gH323ep.callList; |
| 365 |
while(cur) |
| 366 |
{ |
| 367 |
temp = cur; |
| 368 |
cur = cur->next; |
| 369 |
temp->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 370 |
ooCleanCall(temp); |
| 371 |
} |
| 372 |
gH323ep.callList = NULL; |
| 373 |
} |
| 374 |
|
| 375 |
|
| 376 |
if(gH323ep.listener) |
| 377 |
{ |
| 378 |
ooSocketClose(*(gH323ep.listener)); |
| 379 |
gH323ep.listener = NULL; |
| 380 |
} |
| 381 |
|
| 382 |
ooGkClientDestroy(); |
| 383 |
|
| 384 |
if(gH323ep.fptraceFile) |
| 385 |
{ |
| 386 |
fclose(gH323ep.fptraceFile); |
| 387 |
gH323ep.fptraceFile = NULL; |
| 388 |
} |
| 389 |
|
| 390 |
freeContext(&(gH323ep.ctxt)); |
| 391 |
freeContext(&(gH323ep.msgctxt)); |
| 392 |
|
| 393 |
OO_CLRFLAG(gH323ep.flags, OO_M_ENDPOINTCREATED); |
| 394 |
} |
| 395 |
return OO_OK; |
| 396 |
} |
| 397 |
|
| 398 |
int ooH323EpEnableGkRouted(void) |
| 399 |
{ |
| 400 |
OO_SETFLAG(gH323ep.flags, OO_M_GKROUTED); |
| 401 |
return OO_OK; |
| 402 |
} |
| 403 |
|
| 404 |
int ooH323EpDisableGkRouted(void) |
| 405 |
{ |
| 406 |
OO_CLRFLAG(gH323ep.flags, OO_M_GKROUTED); |
| 407 |
return OO_OK; |
| 408 |
} |
| 409 |
|
| 410 |
int ooH323EpEnableAutoAnswer(void) |
| 411 |
{ |
| 412 |
OO_SETFLAG(gH323ep.flags, OO_M_AUTOANSWER); |
| 413 |
return OO_OK; |
| 414 |
} |
| 415 |
|
| 416 |
int ooH323EpDisableAutoAnswer(void) |
| 417 |
{ |
| 418 |
OO_CLRFLAG(gH323ep.flags, OO_M_AUTOANSWER); |
| 419 |
return OO_OK; |
| 420 |
} |
| 421 |
|
| 422 |
int ooH323EpEnableManualRingback(void) |
| 423 |
{ |
| 424 |
OO_SETFLAG(gH323ep.flags, OO_M_MANUALRINGBACK); |
| 425 |
return OO_OK; |
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
int ooH323EpDisableManualRingback(void) |
| 430 |
{ |
| 431 |
OO_CLRFLAG(gH323ep.flags, OO_M_MANUALRINGBACK); |
| 432 |
return OO_OK; |
| 433 |
} |
| 434 |
|
| 435 |
int ooH323EpEnableMediaWaitForConnect(void) |
| 436 |
{ |
| 437 |
OO_SETFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN); |
| 438 |
return OO_OK; |
| 439 |
} |
| 440 |
|
| 441 |
int ooH323EpDisableMediaWaitForConnect(void) |
| 442 |
{ |
| 443 |
OO_CLRFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN); |
| 444 |
return OO_OK; |
| 445 |
} |
| 446 |
|
| 447 |
int ooH323EpEnableFastStart(void) |
| 448 |
{ |
| 449 |
OO_SETFLAG(gH323ep.flags, OO_M_FASTSTART); |
| 450 |
return OO_OK; |
| 451 |
} |
| 452 |
|
| 453 |
int ooH323EpDisableFastStart(void) |
| 454 |
{ |
| 455 |
OO_CLRFLAG(gH323ep.flags, OO_M_FASTSTART); |
| 456 |
return OO_OK; |
| 457 |
} |
| 458 |
|
| 459 |
int ooH323EpEnableH245Tunneling(void) |
| 460 |
{ |
| 461 |
OO_SETFLAG(gH323ep.flags, OO_M_TUNNELING); |
| 462 |
return OO_OK; |
| 463 |
} |
| 464 |
|
| 465 |
int ooH323EpDisableH245Tunneling(void) |
| 466 |
{ |
| 467 |
OO_CLRFLAG(gH323ep.flags, OO_M_TUNNELING); |
| 468 |
return OO_OK; |
| 469 |
} |
| 470 |
|
| 471 |
int ooH323EpTryBeMaster(int m) |
| 472 |
{ |
| 473 |
if (m) |
| 474 |
OO_SETFLAG(gH323ep.flags, OO_M_TRYBEMASTER); |
| 475 |
else |
| 476 |
OO_CLRFLAG(gH323ep.flags, OO_M_TRYBEMASTER); |
| 477 |
return OO_OK; |
| 478 |
} |
| 479 |
|
| 480 |
int ooH323EpSetTermType(int value) |
| 481 |
{ |
| 482 |
gH323ep.termType = value; |
| 483 |
return OO_OK; |
| 484 |
} |
| 485 |
|
| 486 |
int ooH323EpSetProductID (const char* productID) |
| 487 |
{ |
| 488 |
if (0 != productID) { |
| 489 |
char* pstr = (char*) memAlloc (&gH323ep.ctxt, strlen(productID)+1); |
| 490 |
strcpy (pstr, productID); |
| 491 |
if(gH323ep.productID) |
| 492 |
memFreePtr(&gH323ep.ctxt, gH323ep.productID); |
| 493 |
gH323ep.productID = pstr; |
| 494 |
return OO_OK; |
| 495 |
} |
| 496 |
else return OO_FAILED; |
| 497 |
} |
| 498 |
|
| 499 |
int ooH323EpSetVersionID (const char* versionID) |
| 500 |
{ |
| 501 |
if (0 != versionID) { |
| 502 |
char* pstr = (char*) memAlloc (&gH323ep.ctxt, strlen(versionID)+1); |
| 503 |
strcpy (pstr, versionID); |
| 504 |
if(gH323ep.versionID) |
| 505 |
memFreePtr(&gH323ep.ctxt, gH323ep.versionID); |
| 506 |
gH323ep.versionID = pstr; |
| 507 |
return OO_OK; |
| 508 |
} |
| 509 |
else return OO_FAILED; |
| 510 |
} |
| 511 |
|
| 512 |
int ooH323EpSetCallerID (const char* callerID) |
| 513 |
{ |
| 514 |
if (0 != callerID) { |
| 515 |
char* pstr = (char*) memAlloc (&gH323ep.ctxt, strlen(callerID)+1); |
| 516 |
strcpy (pstr, callerID); |
| 517 |
if(gH323ep.callerid) |
| 518 |
memFreePtr(&gH323ep.ctxt, gH323ep.callerid); |
| 519 |
gH323ep.callerid = pstr; |
| 520 |
return OO_OK; |
| 521 |
} |
| 522 |
else return OO_FAILED; |
| 523 |
} |
| 524 |
|
| 525 |
int ooH323EpSetCallingPartyNumber(const char* number) |
| 526 |
{ |
| 527 |
int ret=OO_OK; |
| 528 |
if(number) |
| 529 |
{ |
| 530 |
strncpy(gH323ep.callingPartyNumber, number, |
| 531 |
sizeof(gH323ep.callingPartyNumber)-1); |
| 532 |
ret = ooH323EpAddAliasDialedDigits((char*)number); |
| 533 |
return ret; |
| 534 |
} |
| 535 |
else return OO_FAILED; |
| 536 |
} |
| 537 |
|
| 538 |
int ooH323EpSetTraceLevel(int traceLevel) |
| 539 |
{ |
| 540 |
ooSetTraceThreshold(traceLevel); |
| 541 |
return OO_OK; |
| 542 |
} |
| 543 |
|
| 544 |
void ooH323EpPrintConfig(void) |
| 545 |
{ |
| 546 |
OOTRACEINFO1("H.323 Endpoint Configuration is as follows:\n"); |
| 547 |
|
| 548 |
OOTRACEINFO2("\tTrace File: %s\n", gH323ep.traceFile); |
| 549 |
|
| 550 |
if(!OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART)) |
| 551 |
{ |
| 552 |
OOTRACEINFO1("\tFastStart - disabled\n"); |
| 553 |
} |
| 554 |
else{ |
| 555 |
OOTRACEINFO1("\tFastStart - enabled\n"); |
| 556 |
} |
| 557 |
|
| 558 |
if(!OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING)) |
| 559 |
{ |
| 560 |
OOTRACEINFO1("\tH245 Tunneling - disabled\n"); |
| 561 |
} |
| 562 |
else{ |
| 563 |
OOTRACEINFO1("\tH245 Tunneling - enabled\n"); |
| 564 |
} |
| 565 |
|
| 566 |
if(!OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN)) |
| 567 |
{ |
| 568 |
OOTRACEINFO1("\tMediaWaitForConnect - disabled\n"); |
| 569 |
} |
| 570 |
else{ |
| 571 |
OOTRACEINFO1("\tMediaWaitForConnect - enabled\n"); |
| 572 |
} |
| 573 |
|
| 574 |
if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER)) |
| 575 |
OOTRACEINFO1("\tAutoAnswer - enabled\n"); |
| 576 |
else |
| 577 |
OOTRACEINFO1("\tAutoAnswer - disabled\n"); |
| 578 |
|
| 579 |
OOTRACEINFO2("\tTerminal Type - %d\n", gH323ep.termType); |
| 580 |
|
| 581 |
OOTRACEINFO2("\tT35 CountryCode - %d\n", gH323ep.t35CountryCode); |
| 582 |
|
| 583 |
OOTRACEINFO2("\tT35 Extension - %d\n", gH323ep.t35Extension); |
| 584 |
|
| 585 |
OOTRACEINFO2("\tManufacturer Code - %d\n", gH323ep.manufacturerCode); |
| 586 |
|
| 587 |
OOTRACEINFO2("\tProductID - %s\n", gH323ep.productID); |
| 588 |
|
| 589 |
OOTRACEINFO2("\tVersionID - %s\n", gH323ep.versionID); |
| 590 |
|
| 591 |
OOTRACEINFO2("\tLocal signalling IP address - %s\n", gH323ep.signallingIP); |
| 592 |
|
| 593 |
OOTRACEINFO2("\tH225 ListenPort - %d\n", gH323ep.listenPort); |
| 594 |
|
| 595 |
OOTRACEINFO2("\tCallerID - %s\n", gH323ep.callerid); |
| 596 |
|
| 597 |
|
| 598 |
OOTRACEINFO2("\tCall Establishment Timeout - %d seconds\n", |
| 599 |
gH323ep.callEstablishmentTimeout); |
| 600 |
|
| 601 |
OOTRACEINFO2("\tMasterSlaveDetermination Timeout - %d seconds\n", |
| 602 |
gH323ep.msdTimeout); |
| 603 |
|
| 604 |
OOTRACEINFO2("\tTerminalCapabilityExchange Timeout - %d seconds\n", |
| 605 |
gH323ep.tcsTimeout); |
| 606 |
|
| 607 |
OOTRACEINFO2("\tLogicalChannel Timeout - %d seconds\n", |
| 608 |
gH323ep.logicalChannelTimeout); |
| 609 |
|
| 610 |
OOTRACEINFO2("\tSession Timeout - %d seconds\n", gH323ep.sessionTimeout); |
| 611 |
|
| 612 |
return; |
| 613 |
} |
| 614 |
|
| 615 |
|
| 616 |
int ooH323EpAddG711Capability(int cap, int txframes, int rxframes, int dir, |
| 617 |
cb_StartReceiveChannel startReceiveChannel, |
| 618 |
cb_StartTransmitChannel startTransmitChannel, |
| 619 |
cb_StopReceiveChannel stopReceiveChannel, |
| 620 |
cb_StopTransmitChannel stopTransmitChannel) |
| 621 |
{ |
| 622 |
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, FALSE, |
| 623 |
dir, startReceiveChannel, startTransmitChannel, |
| 624 |
stopReceiveChannel, stopTransmitChannel, FALSE); |
| 625 |
} |
| 626 |
|
| 627 |
int ooH323EpAddG728Capability(int cap, int txframes, int rxframes, int dir, |
| 628 |
cb_StartReceiveChannel startReceiveChannel, |
| 629 |
cb_StartTransmitChannel startTransmitChannel, |
| 630 |
cb_StopReceiveChannel stopReceiveChannel, |
| 631 |
cb_StopTransmitChannel stopTransmitChannel) |
| 632 |
{ |
| 633 |
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, FALSE, |
| 634 |
dir, startReceiveChannel, startTransmitChannel, |
| 635 |
stopReceiveChannel, stopTransmitChannel, FALSE); |
| 636 |
} |
| 637 |
|
| 638 |
int ooH323EpAddG729Capability(int cap, int txframes, int rxframes, int dir, |
| 639 |
cb_StartReceiveChannel startReceiveChannel, |
| 640 |
cb_StartTransmitChannel startTransmitChannel, |
| 641 |
cb_StopReceiveChannel stopReceiveChannel, |
| 642 |
cb_StopTransmitChannel stopTransmitChannel) |
| 643 |
{ |
| 644 |
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, FALSE, |
| 645 |
dir, startReceiveChannel, startTransmitChannel, |
| 646 |
stopReceiveChannel, stopTransmitChannel, FALSE); |
| 647 |
} |
| 648 |
|
| 649 |
|
| 650 |
int ooH323EpAddG7231Capability(int cap, int txframes, int rxframes, |
| 651 |
OOBOOL silenceSuppression, int dir, |
| 652 |
cb_StartReceiveChannel startReceiveChannel, |
| 653 |
cb_StartTransmitChannel startTransmitChannel, |
| 654 |
cb_StopReceiveChannel stopReceiveChannel, |
| 655 |
cb_StopTransmitChannel stopTransmitChannel) |
| 656 |
{ |
| 657 |
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, |
| 658 |
silenceSuppression, dir, startReceiveChannel, |
| 659 |
startTransmitChannel, stopReceiveChannel, |
| 660 |
stopTransmitChannel, FALSE); |
| 661 |
} |
| 662 |
|
| 663 |
int ooH323EpAddG726Capability(int cap, int txframes, int rxframes, |
| 664 |
OOBOOL silenceSuppression, int dir, |
| 665 |
cb_StartReceiveChannel startReceiveChannel, |
| 666 |
cb_StartTransmitChannel startTransmitChannel, |
| 667 |
cb_StopReceiveChannel stopReceiveChannel, |
| 668 |
cb_StopTransmitChannel stopTransmitChannel) |
| 669 |
{ |
| 670 |
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, |
| 671 |
silenceSuppression, dir, startReceiveChannel, |
| 672 |
startTransmitChannel, stopReceiveChannel, |
| 673 |
stopTransmitChannel, FALSE); |
| 674 |
} |
| 675 |
int ooH323EpAddAMRNBCapability(int cap, int txframes, int rxframes, |
| 676 |
OOBOOL silenceSuppression, int dir, |
| 677 |
cb_StartReceiveChannel startReceiveChannel, |
| 678 |
cb_StartTransmitChannel startTransmitChannel, |
| 679 |
cb_StopReceiveChannel stopReceiveChannel, |
| 680 |
cb_StopTransmitChannel stopTransmitChannel) |
| 681 |
{ |
| 682 |
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, |
| 683 |
silenceSuppression, dir, startReceiveChannel, |
| 684 |
startTransmitChannel, stopReceiveChannel, |
| 685 |
stopTransmitChannel, FALSE); |
| 686 |
} |
| 687 |
int ooH323EpAddSpeexCapability(int cap, int txframes, int rxframes, |
| 688 |
OOBOOL silenceSuppression, int dir, |
| 689 |
cb_StartReceiveChannel startReceiveChannel, |
| 690 |
cb_StartTransmitChannel startTransmitChannel, |
| 691 |
cb_StopReceiveChannel stopReceiveChannel, |
| 692 |
cb_StopTransmitChannel stopTransmitChannel) |
| 693 |
{ |
| 694 |
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, |
| 695 |
silenceSuppression, dir, startReceiveChannel, |
| 696 |
startTransmitChannel, stopReceiveChannel, |
| 697 |
stopTransmitChannel, FALSE); |
| 698 |
} |
| 699 |
|
| 700 |
int ooH323EpAddGSMCapability(int cap, ASN1USINT framesPerPkt, |
| 701 |
OOBOOL comfortNoise, OOBOOL scrambled, int dir, |
| 702 |
cb_StartReceiveChannel startReceiveChannel, |
| 703 |
cb_StartTransmitChannel startTransmitChannel, |
| 704 |
cb_StopReceiveChannel stopReceiveChannel, |
| 705 |
cb_StopTransmitChannel stopTransmitChannel) |
| 706 |
{ |
| 707 |
return ooCapabilityAddGSMCapability(NULL, cap, framesPerPkt, comfortNoise, |
| 708 |
scrambled, dir, startReceiveChannel, |
| 709 |
startTransmitChannel, stopReceiveChannel, |
| 710 |
stopTransmitChannel, FALSE); |
| 711 |
} |
| 712 |
|
| 713 |
|
| 714 |
int ooH323EpAddH263VideoCapability(int cap, unsigned sqcifMPI, |
| 715 |
unsigned qcifMPI, unsigned cifMPI, |
| 716 |
unsigned cif4MPI, unsigned cif16MPI, |
| 717 |
unsigned maxBitRate, int dir, |
| 718 |
cb_StartReceiveChannel startReceiveChannel, |
| 719 |
cb_StartTransmitChannel startTransmitChannel, |
| 720 |
cb_StopReceiveChannel stopReceiveChannel, |
| 721 |
cb_StopTransmitChannel stopTransmitChannel) |
| 722 |
{ |
| 723 |
|
| 724 |
return ooCapabilityAddH263VideoCapability(NULL, sqcifMPI, qcifMPI, cifMPI, |
| 725 |
cif4MPI, cif16MPI, maxBitRate,dir, |
| 726 |
startReceiveChannel, startTransmitChannel, |
| 727 |
stopReceiveChannel, stopTransmitChannel, |
| 728 |
FALSE); |
| 729 |
|
| 730 |
} |
| 731 |
|
| 732 |
|
| 733 |
int ooH323EpEnableDTMFCISCO(int dynamicRTPPayloadType) |
| 734 |
{ |
| 735 |
return ooCapabilityEnableDTMFCISCO(NULL, dynamicRTPPayloadType); |
| 736 |
} |
| 737 |
|
| 738 |
int ooH323EpDisableDTMFCISCO(void) |
| 739 |
{ |
| 740 |
return ooCapabilityDisableDTMFCISCO(NULL); |
| 741 |
} |
| 742 |
|
| 743 |
int ooH323EpEnableDTMFRFC2833(int dynamicRTPPayloadType) |
| 744 |
{ |
| 745 |
return ooCapabilityEnableDTMFRFC2833(NULL, dynamicRTPPayloadType); |
| 746 |
} |
| 747 |
|
| 748 |
int ooH323EpDisableDTMFRFC2833(void) |
| 749 |
{ |
| 750 |
return ooCapabilityDisableDTMFRFC2833(NULL); |
| 751 |
} |
| 752 |
|
| 753 |
int ooH323EpEnableDTMFH245Alphanumeric() |
| 754 |
{ |
| 755 |
return ooCapabilityEnableDTMFH245Alphanumeric(NULL); |
| 756 |
} |
| 757 |
|
| 758 |
int ooH323EpDisableDTMFH245Alphanumeric() |
| 759 |
{ |
| 760 |
return ooCapabilityDisableDTMFH245Alphanumeric(NULL); |
| 761 |
} |
| 762 |
|
| 763 |
int ooH323EpEnableDTMFH245Signal() |
| 764 |
{ |
| 765 |
return ooCapabilityEnableDTMFH245Signal(NULL); |
| 766 |
} |
| 767 |
|
| 768 |
int ooH323EpDisableDTMFH245Signal() |
| 769 |
{ |
| 770 |
return ooCapabilityDisableDTMFH245Signal(NULL); |
| 771 |
} |
| 772 |
|
| 773 |
int ooH323EpEnableDTMFQ931Keypad() |
| 774 |
{ |
| 775 |
return ooCapabilityEnableDTMFQ931Keypad(NULL); |
| 776 |
} |
| 777 |
|
| 778 |
int ooH323EpDisableDTMFQ931Keypad() |
| 779 |
{ |
| 780 |
return ooCapabilityDisableDTMFQ931Keypad(NULL); |
| 781 |
} |
| 782 |
|
| 783 |
int ooH323EpSetGkClientCallbacks(OOGKCLIENTCALLBACKS gkClientCallbacks) |
| 784 |
{ |
| 785 |
|
| 786 |
if(gH323ep.gkClient) |
| 787 |
{ |
| 788 |
return ooGkClientSetCallbacks(gH323ep.gkClient, gkClientCallbacks); |
| 789 |
} |
| 790 |
else{ |
| 791 |
OOTRACEERR1("Error:Gk Client hasn't been initialized yet\n"); |
| 792 |
return OO_FAILED; |
| 793 |
} |
| 794 |
|
| 795 |
} |
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
int ooH323EpSetTCPPortRange(int base, int max) |
| 801 |
{ |
| 802 |
if(base <= 1024) |
| 803 |
gH323ep.tcpPorts.start = 1025; |
| 804 |
else |
| 805 |
gH323ep.tcpPorts.start = base; |
| 806 |
if(max > 65500) |
| 807 |
gH323ep.tcpPorts.max = 65500; |
| 808 |
else |
| 809 |
gH323ep.tcpPorts.max = max; |
| 810 |
|
| 811 |
if(gH323ep.tcpPorts.max<gH323ep.tcpPorts.start) |
| 812 |
{ |
| 813 |
OOTRACEERR1("Error: Failed to set tcp ports- " |
| 814 |
"Max port number less than Start port number\n"); |
| 815 |
return OO_FAILED; |
| 816 |
} |
| 817 |
gH323ep.tcpPorts.current = gH323ep.tcpPorts.start; |
| 818 |
|
| 819 |
OOTRACEINFO1("TCP port range initialize - successful\n"); |
| 820 |
return OO_OK; |
| 821 |
} |
| 822 |
|
| 823 |
int ooH323EpSetUDPPortRange(int base, int max) |
| 824 |
{ |
| 825 |
if(base <= 1024) |
| 826 |
gH323ep.udpPorts.start = 1025; |
| 827 |
else |
| 828 |
gH323ep.udpPorts.start = base; |
| 829 |
if(max > 65500) |
| 830 |
gH323ep.udpPorts.max = 65500; |
| 831 |
else |
| 832 |
gH323ep.udpPorts.max = max; |
| 833 |
|
| 834 |
if(gH323ep.udpPorts.max<gH323ep.udpPorts.start) |
| 835 |
{ |
| 836 |
OOTRACEERR1("Error: Failed to set udp ports- Max port number" |
| 837 |
" less than Start port number\n"); |
| 838 |
return OO_FAILED; |
| 839 |
} |
| 840 |
|
| 841 |
gH323ep.udpPorts.current = gH323ep.udpPorts.start; |
| 842 |
|
| 843 |
OOTRACEINFO1("UDP port range initialize - successful\n"); |
| 844 |
|
| 845 |
return OO_OK; |
| 846 |
} |
| 847 |
|
| 848 |
int ooH323EpSetRTPPortRange(int base, int max) |
| 849 |
{ |
| 850 |
if(base <= 1024) |
| 851 |
gH323ep.rtpPorts.start = 1025; |
| 852 |
else |
| 853 |
gH323ep.rtpPorts.start = base; |
| 854 |
if(max > 65500) |
| 855 |
gH323ep.rtpPorts.max = 65500; |
| 856 |
else |
| 857 |
gH323ep.rtpPorts.max = max; |
| 858 |
|
| 859 |
if(gH323ep.rtpPorts.max<gH323ep.rtpPorts.start) |
| 860 |
{ |
| 861 |
OOTRACEERR1("Error: Failed to set rtp ports- Max port number" |
| 862 |
" less than Start port number\n"); |
| 863 |
return OO_FAILED; |
| 864 |
} |
| 865 |
|
| 866 |
gH323ep.rtpPorts.current = gH323ep.rtpPorts.start; |
| 867 |
OOTRACEINFO1("RTP port range initialize - successful\n"); |
| 868 |
return OO_OK; |
| 869 |
} |