corrections in gk interface, small fixes in call clearing.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@255199 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Alexandr Anikin
2010-03-27 23:51:13 +00:00
parent b8aeb50b7b
commit 89e4c15783
6 changed files with 83 additions and 67 deletions

View File

@@ -609,6 +609,10 @@ static struct ast_channel *ooh323_request(const char *type, format_t format,
if (dest) { if (dest) {
peer = find_peer(dest, port); peer = find_peer(dest, port);
} else{ } else{
ast_mutex_lock(&iflock);
ast_mutex_unlock(&p->lock);
ooh323_destroy(p);
ast_mutex_unlock(&iflock);
ast_log(LOG_ERROR, "Destination format is not supported\n"); ast_log(LOG_ERROR, "Destination format is not supported\n");
return NULL; return NULL;
} }
@@ -642,6 +646,15 @@ static struct ast_channel *ooh323_request(const char *type, format_t format,
ast_copy_string(p->accountcode, peer->accountcode, sizeof(p->accountcode)); ast_copy_string(p->accountcode, peer->accountcode, sizeof(p->accountcode));
p->amaflags = peer->amaflags; p->amaflags = peer->amaflags;
} else { } else {
if (gRasGkMode == RasNoGatekeeper) {
/* no gk and no peer */
ast_log(LOG_ERROR, "Call to undefined peer %s", dest);
ast_mutex_lock(&iflock);
ast_mutex_unlock(&p->lock);
ooh323_destroy(p);
ast_mutex_unlock(&iflock);
return NULL;
}
p->dtmfmode = gDTMFMode; p->dtmfmode = gDTMFMode;
p->dtmfcodec = gDTMFCodec; p->dtmfcodec = gDTMFCodec;
p->t38support = gT38Support; p->t38support = gT38Support;
@@ -672,23 +685,22 @@ static struct ast_channel *ooh323_request(const char *type, format_t format,
ast_mutex_lock(&iflock); ast_mutex_lock(&iflock);
ooh323_destroy(p); ooh323_destroy(p);
ast_mutex_unlock(&iflock); ast_mutex_unlock(&iflock);
} else { } else {
ast_mutex_lock(&p->lock); ast_mutex_lock(&p->lock);
p->callToken = (char*)ast_malloc(AST_MAX_EXTENSION); p->callToken = (char*)ast_malloc(AST_MAX_EXTENSION);
if(!p->callToken) if(!p->callToken) {
{ ast_mutex_unlock(&p->lock);
ast_mutex_unlock(&p->lock); ast_mutex_lock(&iflock);
ast_mutex_lock(&iflock); ooh323_destroy(p);
ooh323_destroy(p); ast_mutex_unlock(&iflock);
ast_mutex_unlock(&iflock); ast_log(LOG_ERROR, "Failed to allocate memory for callToken\n");
ast_log(LOG_ERROR, "Failed to allocate memory for callToken\n"); return NULL;
return NULL; }
}
ast_mutex_unlock(&p->lock); ast_mutex_unlock(&p->lock);
ast_mutex_lock(&ooh323c_cmd_lock); ast_mutex_lock(&ooh323c_cmd_lock);
ooMakeCall(data, p->callToken, AST_MAX_EXTENSION, NULL); ooMakeCall(data, p->callToken, AST_MAX_EXTENSION, NULL);
ast_mutex_unlock(&ooh323c_cmd_lock); ast_mutex_unlock(&ooh323c_cmd_lock);
} }
restart_monitor(); restart_monitor();
@@ -955,17 +967,17 @@ static int ooh323_call(struct ast_channel *ast, char *dest, int timeout)
else else
ast_copy_string(destination, dest, sizeof(destination)); ast_copy_string(destination, dest, sizeof(destination));
destination[sizeof(destination)-1]='\0'; destination[sizeof(destination)-1]='\0';
opts.transfercap = ast->transfercapability; opts.transfercap = ast->transfercapability;
for (i=0;i<480 && !isRunning(p->callToken);i++) usleep(12000); for (i=0;i<480 && !isRunning(p->callToken);i++) usleep(12000);
if(OO_TESTFLAG(p->flags, H323_DISABLEGK)) { if(OO_TESTFLAG(p->flags, H323_DISABLEGK)) {
res = ooRunCall(destination, p->callToken, AST_MAX_EXTENSION, &opts); res = ooRunCall(destination, p->callToken, AST_MAX_EXTENSION, &opts);
} else { } else {
res = ooRunCall(destination, p->callToken, AST_MAX_EXTENSION, NULL); res = ooRunCall(destination, p->callToken, AST_MAX_EXTENSION, NULL);
} }
ast_mutex_unlock(&p->lock); ast_mutex_unlock(&p->lock);
if (res != OO_OK) { if (res != OO_OK) {

View File

@@ -217,6 +217,11 @@ int ooEndCall(OOH323CallData *call)
if (call->callIdentifier.guid.numocts == 0) call->callState = OO_CALL_CLEARED; if (call->callIdentifier.guid.numocts == 0) call->callState = OO_CALL_CLEARED;
if(!call->pH225Channel || call->pH225Channel->sock ==0)
{
call->callState = OO_CALL_CLEARED;
}
if(call->callState == OO_CALL_CLEARED || call->callState == OO_CALL_CLEAR_RELEASESENT) if(call->callState == OO_CALL_CLEARED || call->callState == OO_CALL_CLEAR_RELEASESENT)
{ {
ooCleanCall(call); ooCleanCall(call);
@@ -242,20 +247,14 @@ int ooEndCall(OOH323CallData *call)
} }
if(!call->pH225Channel || call->pH225Channel->sock ==0) if(!OO_TESTFLAG(call->flags, OO_M_RELEASE_BUILT))
{ {
call->callState = OO_CALL_CLEARED; if(call->callState == OO_CALL_CLEAR ||
} call->callState == OO_CALL_CLEAR_RELEASERECVD)
else{ {
if(!OO_TESTFLAG(call->flags, OO_M_RELEASE_BUILT)) ooSendReleaseComplete(call);
{ OO_SETFLAG(call->flags, OO_M_RELEASE_BUILT);
if(call->callState == OO_CALL_CLEAR || }
call->callState == OO_CALL_CLEAR_RELEASERECVD)
{
ooSendReleaseComplete(call);
OO_SETFLAG(call->flags, OO_M_RELEASE_BUILT);
}
}
} }
return OO_OK; return OO_OK;

View File

@@ -686,7 +686,7 @@ int ooGkClientSendGRQ(ooGkClient *pGkClient)
pGkReq->m.endpointAliasPresent=TRUE; pGkReq->m.endpointAliasPresent=TRUE;
if(OO_OK != ooPopulateAliasList(&pGkClient->msgCtxt, gH323ep.aliases, if(OO_OK != ooPopulateAliasList(&pGkClient->msgCtxt, gH323ep.aliases,
&pGkReq->endpointAlias)) &pGkReq->endpointAlias, 0))
{ {
OOTRACEERR1("Error Failed to fill alias information for GRQ message\n"); OOTRACEERR1("Error Failed to fill alias information for GRQ message\n");
memReset(&pGkClient->msgCtxt); memReset(&pGkClient->msgCtxt);
@@ -1010,7 +1010,7 @@ int ooGkClientSendRRQ(ooGkClient *pGkClient, ASN1BOOL keepAlive)
pRegReq->m.terminalAliasPresent=TRUE; pRegReq->m.terminalAliasPresent=TRUE;
if(OO_OK != ooPopulateAliasList(pctxt, gH323ep.aliases, if(OO_OK != ooPopulateAliasList(pctxt, gH323ep.aliases,
&pRegReq->terminalAlias)) { &pRegReq->terminalAlias, 0)) {
OOTRACEERR1("Error filling alias for RRQ\n"); OOTRACEERR1("Error filling alias for RRQ\n");
memReset(pctxt); memReset(pctxt);
pGkClient->state = GkClientFailed; pGkClient->state = GkClientFailed;
@@ -1457,7 +1457,7 @@ int ooGkClientSendURQ(ooGkClient *pGkClient, ooAliases *aliases)
if(aliases) if(aliases)
{ {
pUnregReq->m.endpointAliasPresent = TRUE; pUnregReq->m.endpointAliasPresent = TRUE;
ooPopulateAliasList(pctxt, aliases, &pUnregReq->endpointAlias); ooPopulateAliasList(pctxt, aliases, &pUnregReq->endpointAlias, 0);
} }
@@ -1716,7 +1716,7 @@ int ooGkClientSendAdmissionRequest
{ {
pAdmReq->m.destinationInfoPresent = 1; pAdmReq->m.destinationInfoPresent = 1;
if(OO_OK != ooPopulateAliasList(&pGkClient->msgCtxt, destAliases, if(OO_OK != ooPopulateAliasList(&pGkClient->msgCtxt, destAliases,
&pAdmReq->destinationInfo)) &pAdmReq->destinationInfo, T_H225AliasAddress_dialedDigits))
{ {
OOTRACEERR1("Error:Failed to populate destination aliases - " OOTRACEERR1("Error:Failed to populate destination aliases - "
"ARQ message\n"); "ARQ message\n");
@@ -1731,7 +1731,7 @@ int ooGkClientSendAdmissionRequest
if(srcAliases) if(srcAliases)
{ {
iRet = ooPopulateAliasList(&pGkClient->msgCtxt, srcAliases, iRet = ooPopulateAliasList(&pGkClient->msgCtxt, srcAliases,
&pAdmReq->srcInfo); &pAdmReq->srcInfo, 0);
if(OO_OK != iRet) if(OO_OK != iRet)
{ {
OOTRACEERR1("Error:Failed to populate source aliases -ARQ message\n"); OOTRACEERR1("Error:Failed to populate source aliases -ARQ message\n");
@@ -2027,7 +2027,7 @@ int ooGkClientHandleAdmissionReject
"(%s, %s)\n", pAdmissionReject->rejectReason.t, call->callType, "(%s, %s)\n", pAdmissionReject->rejectReason.t, call->callType,
call->callToken); call->callToken);
call->callState = OO_CALL_CLEAR; call->callState = OO_CALL_CLEARED;
switch(pAdmissionReject->rejectReason.t) switch(pAdmissionReject->rejectReason.t)
{ {
@@ -2204,10 +2204,10 @@ int ooGkClientSendIRR
if(srcAliases) if(srcAliases)
{ {
iRet = ooPopulateAliasList(&pGkClient->msgCtxt, srcAliases, iRet = ooPopulateAliasList(&pGkClient->msgCtxt, srcAliases,
&pIRR->endpointAlias); &pIRR->endpointAlias, T_H225AliasAddress_h323_ID);
if(OO_OK != iRet) if(OO_OK != iRet)
{ {
OOTRACEERR1("Error:Failed to populate source aliases -ARQ message\n"); OOTRACEERR1("Error:Failed to populate source aliases -IRR message\n");
memReset(pctxt); memReset(pctxt);
pGkClient->state = GkClientFailed; pGkClient->state = GkClientFailed;
ast_mutex_unlock(&pGkClient->Lock); ast_mutex_unlock(&pGkClient->Lock);

View File

@@ -2219,7 +2219,7 @@ int ooPopulatePrefixList(OOCTXT *pctxt, OOAliases *pAliases,
return OO_OK; return OO_OK;
} }
int ooPopulateAliasList(OOCTXT *pctxt, OOAliases *pAliases, int ooPopulateAliasList(OOCTXT *pctxt, OOAliases *pAliases,
H225_SeqOfH225AliasAddress *pAliasList ) H225_SeqOfH225AliasAddress *pAliasList, int pAliasType)
{ {
H225AliasAddress *pAliasEntry=NULL; H225AliasAddress *pAliasEntry=NULL;
OOAliases * pAlias=NULL; OOAliases * pAlias=NULL;
@@ -2243,23 +2243,27 @@ int ooPopulateAliasList(OOCTXT *pctxt, OOAliases *pAliases,
OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - pAliasEntry\n"); OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - pAliasEntry\n");
return OO_FAILED; return OO_FAILED;
} }
if (pAliasType && pAlias->type != pAliasType) {
pAlias = pAlias->next;
continue;
}
switch(pAlias->type) switch(pAlias->type)
{ {
/* Don't populate DialedDigits as alias they populate as prefixes
case T_H225AliasAddress_dialedDigits: case T_H225AliasAddress_dialedDigits:
pAliasEntry->t = T_H225AliasAddress_dialedDigits; pAliasEntry->t = T_H225AliasAddress_dialedDigits;
pAliasEntry->u.dialedDigits = (ASN1IA5String)memAlloc(pctxt, pAliasEntry->u.dialedDigits = (ASN1IA5String)memAlloc(pctxt,
strlen(pAlias->value)+1); strlen(pAlias->value)+1);
if(!pAliasEntry->u.dialedDigits) if(!pAliasEntry->u.dialedDigits)
{ {
OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - " OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - "
"dialedDigits\n"); "dialedDigits\n");
memFreePtr(pctxt, pAliasEntry); memFreePtr(pctxt, pAliasEntry);
return OO_FAILED; return OO_FAILED;
} }
strcpy(*(char**)&pAliasEntry->u.dialedDigits, pAlias->value); strcpy(*(char**)&pAliasEntry->u.dialedDigits, pAlias->value);
bValid = TRUE; bValid = TRUE;
break; */ break;
case T_H225AliasAddress_h323_ID: case T_H225AliasAddress_h323_ID:
pAliasEntry->t = T_H225AliasAddress_h323_ID; pAliasEntry->t = T_H225AliasAddress_h323_ID;
pAliasEntry->u.h323_ID.nchars = strlen(pAlias->value); pAliasEntry->u.h323_ID.nchars = strlen(pAlias->value);

View File

@@ -136,7 +136,7 @@ EXTERN int ooPopulatePrefixList(OOCTXT *pctxt, OOAliases *pAliases,
* @return OO_OK, on success. OO_FAILED, otherwise. * @return OO_OK, on success. OO_FAILED, otherwise.
*/ */
EXTERN int ooPopulateAliasList(OOCTXT *pctxt, OOAliases *pAliases, EXTERN int ooPopulateAliasList(OOCTXT *pctxt, OOAliases *pAliases,
H225_SeqOfH225AliasAddress *pAliasList); H225_SeqOfH225AliasAddress *pAliasList, int pAliasType);
/** /**
* This function is used to search a particular alias in the alias list. The * This function is used to search a particular alias in the alias list. The

View File

@@ -1383,10 +1383,10 @@ int ooSendAlerting(OOH323CallData *call)
alerting->m.alertingAddressPresent = TRUE; alerting->m.alertingAddressPresent = TRUE;
if(call->ourAliases) if(call->ourAliases)
ret = ooPopulateAliasList(pctxt, call->ourAliases, ret = ooPopulateAliasList(pctxt, call->ourAliases,
&alerting->alertingAddress); &alerting->alertingAddress, 0);
else else
ret = ooPopulateAliasList(pctxt, gH323ep.aliases, ret = ooPopulateAliasList(pctxt, gH323ep.aliases,
&alerting->alertingAddress); &alerting->alertingAddress, 0);
if(OO_OK != ret) if(OO_OK != ret)
{ {
OOTRACEERR1("Error:Failed to populate alias list in Alert message\n"); OOTRACEERR1("Error:Failed to populate alias list in Alert message\n");
@@ -1889,10 +1889,10 @@ int ooAcceptCall(OOH323CallData *call)
connect->m.connectedAddressPresent = TRUE; connect->m.connectedAddressPresent = TRUE;
if(call->ourAliases) if(call->ourAliases)
ret = ooPopulateAliasList(pctxt, call->ourAliases, ret = ooPopulateAliasList(pctxt, call->ourAliases,
&connect->connectedAddress); &connect->connectedAddress, 0);
else else
ret = ooPopulateAliasList(pctxt, gH323ep.aliases, ret = ooPopulateAliasList(pctxt, gH323ep.aliases,
&connect->connectedAddress); &connect->connectedAddress, 0);
if(OO_OK != ret) if(OO_OK != ret)
{ {
OOTRACEERR1("Error:Failed to populate alias list in Connect message\n"); OOTRACEERR1("Error:Failed to populate alias list in Connect message\n");
@@ -2114,7 +2114,7 @@ int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts)
{ {
OOCTXT *pctxt; OOCTXT *pctxt;
OOH323CallData *call; OOH323CallData *call;
int ret=0, i=0, irand=0; int ret=OO_OK, i=0, irand=0;
char tmp[30]="\0"; char tmp[30]="\0";
char *ip=NULL, *port = NULL; char *ip=NULL, *port = NULL;
struct timeval tv; struct timeval tv;
@@ -2211,14 +2211,15 @@ int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts)
/* Send as H225 message to calling endpoint */ /* Send as H225 message to calling endpoint */
ast_mutex_lock(&call->Lock); ast_mutex_lock(&call->Lock);
if (call->callState < OO_CALL_CLEAR) if (call->callState < OO_CALL_CLEAR) {
if ((ret = ooH323CallAdmitted (call)) != OO_OK) { if ((ret = ooH323CallAdmitted (call)) != OO_OK) {
ast_mutex_unlock(&call->Lock); ast_mutex_unlock(&call->Lock);
return ret; return ret;
} }
} else ret = OO_FAILED;
ast_mutex_unlock(&call->Lock); ast_mutex_unlock(&call->Lock);
return OO_OK; return ret;
} }
@@ -2376,10 +2377,10 @@ int ooH323MakeCall_helper(OOH323CallData *call)
setup->m.sourceAddressPresent = TRUE; setup->m.sourceAddressPresent = TRUE;
if(call->ourAliases) if(call->ourAliases)
ret = ooPopulateAliasList(pctxt, call->ourAliases, ret = ooPopulateAliasList(pctxt, call->ourAliases,
&setup->sourceAddress); &setup->sourceAddress, 0);
else if(gH323ep.aliases) else if(gH323ep.aliases)
ret = ooPopulateAliasList(pctxt, gH323ep.aliases, ret = ooPopulateAliasList(pctxt, gH323ep.aliases,
&setup->sourceAddress); &setup->sourceAddress, 0);
if(OO_OK != ret) if(OO_OK != ret)
{ {
OOTRACEERR1("Error:Failed to populate alias list in SETUP message\n"); OOTRACEERR1("Error:Failed to populate alias list in SETUP message\n");
@@ -2404,7 +2405,7 @@ int ooH323MakeCall_helper(OOH323CallData *call)
{ {
setup->m.destinationAddressPresent = TRUE; setup->m.destinationAddressPresent = TRUE;
ret = ooPopulateAliasList(pctxt, call->remoteAliases, ret = ooPopulateAliasList(pctxt, call->remoteAliases,
&setup->destinationAddress); &setup->destinationAddress, 0);
if(OO_OK != ret) if(OO_OK != ret)
{ {
OOTRACEERR1("Error:Failed to populate destination alias list in SETUP" OOTRACEERR1("Error:Failed to populate destination alias list in SETUP"
@@ -2953,7 +2954,7 @@ int ooH323ForwardCall(char* callToken, char *dest)
{ {
facility->m.alternativeAliasAddressPresent = TRUE; facility->m.alternativeAliasAddressPresent = TRUE;
ret = ooPopulateAliasList(pctxt, call->pCallFwdData->aliases, ret = ooPopulateAliasList(pctxt, call->pCallFwdData->aliases,
&facility->alternativeAliasAddress); &facility->alternativeAliasAddress, 0);
if(ret != OO_OK) if(ret != OO_OK)
{ {
OOTRACEERR3("Error:Failed to populate alternate aliases in " OOTRACEERR3("Error:Failed to populate alternate aliases in "