oogkclient.c
来自「一个非常美妙的proxy。功能强大。基于sip的协议。如果还要的话」· C语言 代码 · 共 1,899 行 · 第 1/5 页
C
1,899 行
pAdmReq->srcCallSignalAddress.t = T_H225TransportAddress_ipAddress; pAdmReq->srcCallSignalAddress.u.ipAddress = pIpAddressRemote; } }else { pAdmReq->m.srcCallSignalAddressPresent = TRUE; pAdmReq->srcCallSignalAddress.t = T_H225TransportAddress_ipAddress; pAdmReq->srcCallSignalAddress.u.ipAddress = pIpAddressLocal; if(!ooUtilsIsStrEmpty(call->remoteIP)) { pAdmReq->m.destCallSignalAddressPresent = TRUE; pAdmReq->destCallSignalAddress.t = T_H225TransportAddress_ipAddress; pAdmReq->destCallSignalAddress.u.ipAddress = pIpAddressRemote; } } /* Populate seq number */ pAdmReq->requestSeqNum = pGkClient->requestSeqNum++; if(!pAdmReq->requestSeqNum) pAdmReq->requestSeqNum = pGkClient->requestSeqNum++; /* Populate call type - For now only PointToPoint supported*/ pAdmReq->callType.t = T_H225CallType_pointToPoint; /* Add call model to message*/ pAdmReq->m.callModelPresent = 1; if(OO_TESTFLAG(call->flags, OO_M_GKROUTED)) pAdmReq->callModel.t = T_H225CallModel_gatekeeperRouted; else pAdmReq->callModel.t = T_H225CallModel_direct; /* Populate Endpoint Identifier */ pAdmReq->endpointIdentifier.nchars = pGkClient->endpointId.nchars; pAdmReq->endpointIdentifier.data = (ASN116BITCHAR*)memAlloc(pctxt, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); if(!pAdmReq->endpointIdentifier.data) { OOTRACEERR3("Error:Memory - ooGkClientSendAdmissionRequest - " "endpointIdentifier.data(%s, %s)\n", call->callType, call->callToken); memReset(pctxt); pGkClient->state = GkClientFailed; return OO_FAILED; } memcpy((void*)pAdmReq->endpointIdentifier.data, (void*)pGkClient->endpointId.data, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); /* Get Destination And source aliases for call - */ if(!strcmp(call->callType, "incoming")) { if(call->ourAliases) destAliases = call->ourAliases; else destAliases = gH323ep.aliases; srcAliases = call->remoteAliases; }else { if(call->ourAliases) srcAliases = call->ourAliases; else srcAliases = gH323ep.aliases; destAliases = call->remoteAliases; } /* Populate destination info */ if(destAliases) { pAdmReq->m.destinationInfoPresent = 1; if(OO_OK != ooPopulateAliasList(&pGkClient->msgCtxt, destAliases, &pAdmReq->destinationInfo)) { OOTRACEERR1("Error:Failed to populate destination aliases - " "ARQ message\n"); pGkClient->state = GkClientFailed; memReset(pctxt); return OO_FAILED; } } /* Populate Source Info */ if(srcAliases) { iRet = ooPopulateAliasList(&pGkClient->msgCtxt, srcAliases, &pAdmReq->srcInfo); if(OO_OK != iRet) { OOTRACEERR1("Error:Failed to populate source aliases -ARQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; return OO_FAILED; } } /* Populate bandwidth*/ pAdmReq->bandWidth = DEFAULT_BW_REQUEST; /* Populate call Reference */ pAdmReq->callReferenceValue = call->callReference; /* populate conferenceID */ memcpy((void*)&pAdmReq->conferenceID, (void*)&call->confIdentifier, sizeof(H225ConferenceIdentifier)); /*populate answerCall */ if(!strcmp(call->callType, "incoming")) pAdmReq->answerCall = TRUE; else pAdmReq->answerCall = FALSE; /* Populate CanMapAlias */ pAdmReq->m.canMapAliasPresent = TRUE; pAdmReq->canMapAlias = FALSE; /* Populate call identifier */ pAdmReq->m.callIdentifierPresent = TRUE; memcpy((void*)&pAdmReq->callIdentifier, (void*)&call->callIdentifier, sizeof(H225CallIdentifier)); /* Populate Gatekeeper Id */ pAdmReq->m.gatekeeperIdentifierPresent = TRUE; pAdmReq->gatekeeperIdentifier.nchars = pGkClient->gkId.nchars; pAdmReq->gatekeeperIdentifier.data = (ASN116BITCHAR*)memAlloc(pctxt, sizeof(ASN116BITCHAR)*pGkClient->gkId.nchars); if(!pAdmReq->gatekeeperIdentifier.data) { OOTRACEERR1("Error:Failed to allocate memory for GKID of ARQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; return OO_FAILED; } memcpy((void*)pAdmReq->gatekeeperIdentifier.data, (void*)pGkClient->gkId.data, sizeof(ASN116BITCHAR)*pGkClient->gkId.nchars); pAdmReq->m.willSupplyUUIEsPresent = 1; pAdmReq->willSupplyUUIEs = FALSE; /* Create RasCallAdmissionInfo */ if(!retransmit) { pCallAdmInfo = (RasCallAdmissionInfo*)memAlloc(&pGkClient->ctxt, sizeof(RasCallAdmissionInfo)); if(!pCallAdmInfo) { OOTRACEERR1("Error: Failed to allocate memory for new CallAdmission" " Info entry\n"); memReset(pctxt); pGkClient->state = GkClientFailed; return OO_FAILED; } pCallAdmInfo->call = call; pCallAdmInfo->retries = 0; pCallAdmInfo->requestSeqNum = pAdmReq->requestSeqNum; dListAppend(&pGkClient->ctxt, &pGkClient->callsPendingList,pCallAdmInfo); }else{ for(x=0; x<pGkClient->callsPendingList.count; x++) { pNode = dListFindByIndex(&pGkClient->callsPendingList, x); pCallAdmInfo = (RasCallAdmissionInfo*)pNode->data; if(pCallAdmInfo->call->callReference == call->callReference) { pCallAdmInfo->requestSeqNum = pAdmReq->requestSeqNum; break; } } } iRet = ooGkClientSendMsg(pGkClient, pRasMsg); if(iRet != OO_OK) { OOTRACEERR1("Error:Failed to send AdmissionRequest message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; return OO_FAILED; } OOTRACEINFO3("Admission Request message sent for (%s, %s)\n", call->callType, call->callToken); memReset(pctxt); /* Add ARQ timer */ cbData = (ooGkClientTimerCb*) memAlloc (&pGkClient->ctxt, sizeof(ooGkClientTimerCb)); if(!cbData) { OOTRACEERR1("Error:Failed to allocate memory for Regisration timer." "\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } cbData->timerType = OO_ARQ_TIMER; cbData->pGkClient = pGkClient; cbData->pAdmInfo = pCallAdmInfo; if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList, &ooGkClientARQTimerExpired, pGkClient->arqTimeout, cbData, FALSE)) { OOTRACEERR1("Error:Unable to create ARQ timer.\n "); memFreePtr(&pGkClient->ctxt, cbData); pGkClient->state = GkClientFailed; return OO_FAILED; } return OO_OK;}/** * Manage incoming ACF message. */int ooGkClientHandleAdmissionConfirm (ooGkClient *pGkClient, H225AdmissionConfirm *pAdmissionConfirm){ RasCallAdmissionInfo* pCallAdmInfo=NULL; unsigned int x, y; DListNode *pNode, *pNode1=NULL; H225TransportAddress_ipAddress * ipAddress=NULL; OOTimer *pTimer = NULL; char ip[20]; /* Search call in pending calls list */ for(x=0 ; x<pGkClient->callsPendingList.count; x++) { pNode = dListFindByIndex(&pGkClient->callsPendingList, x); pCallAdmInfo = (RasCallAdmissionInfo*) pNode->data; if(pCallAdmInfo->requestSeqNum == pAdmissionConfirm->requestSeqNum) { OOTRACEDBGC3("Found Pending call(%s, %s)\n", pCallAdmInfo->call->callType, pCallAdmInfo->call->callToken); /* Populate Remote IP */ if(pAdmissionConfirm->destCallSignalAddress.t != T_H225TransportAddress_ipAddress) { OOTRACEERR1("Error:Destination Call Signal Address provided by" "Gatekeeper is not an IPv4 address\n"); OOTRACEINFO1("Ignoring ACF, will wait for timeout and retransmit " "ARQ\n"); return OO_FAILED; } ipAddress = pAdmissionConfirm->destCallSignalAddress.u.ipAddress; sprintf(ip, "%d.%d.%d.%d", ipAddress->ip.data[0], ipAddress->ip.data[1], ipAddress->ip.data[2], ipAddress->ip.data[3]); if(strcmp(ip, "0.0.0.0")) strcpy(pCallAdmInfo->call->remoteIP, ip); pCallAdmInfo->call->remotePort = ipAddress->port; /* Update call model */ if(pAdmissionConfirm->callModel.t == T_H225CallModel_direct) { if(OO_TESTFLAG(pCallAdmInfo->call->flags, OO_M_GKROUTED)) { OOTRACEINFO3("Gatekeeper changed call model from GkRouted to " "direct. (%s, %s)\n", pCallAdmInfo->call->callType, pCallAdmInfo->call->callToken); OO_CLRFLAG(pCallAdmInfo->call->flags, OO_M_GKROUTED); } } if(pAdmissionConfirm->callModel.t == T_H225CallModel_gatekeeperRouted) { if(!OO_TESTFLAG(pCallAdmInfo->call->flags, OO_M_GKROUTED)) { OOTRACEINFO3("Gatekeeper changed call model from direct to " "GkRouted. (%s, %s)\n", pCallAdmInfo->call->callType, pCallAdmInfo->call->callToken); OO_SETFLAG(pCallAdmInfo->call->flags, OO_M_GKROUTED); } } /* Delete ARQ timer */ for(y=0; y<pGkClient->timerList.count; y++) { pNode1 = dListFindByIndex(&pGkClient->timerList, y); pTimer = (OOTimer*)pNode1->data; if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_ARQ_TIMER) { if(((ooGkClientTimerCb*)pTimer->cbData)->pAdmInfo == pCallAdmInfo) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); OOTRACEDBGA1("Deleted ARQ Timer.\n"); break; } } } OOTRACEINFO3("Admission Confirm message received for (%s, %s)\n", pCallAdmInfo->call->callType, pCallAdmInfo->call->callToken); ooH323CallAdmitted( pCallAdmInfo->call); dListRemove(&pGkClient->callsPendingList, pNode); dListAppend(&pGkClient->ctxt, &pGkClient->callsAdmittedList, pNode->data); memFreePtr(&pGkClient->ctxt, pNode); return OO_OK; break; } else { pNode = pNode->next; } } OOTRACEERR1("Error: Failed to process ACF as there is no corresponding " "pending call\n"); return OO_OK;}int ooGkClientHandleAdmissionReject (ooGkClient *pGkClient, H225AdmissionReject *pAdmissionReject){ RasCallAdmissionInfo* pCallAdmInfo=NULL; unsigned int x; DListNode *pNode=NULL; OOH323CallData *call=NULL; /* Search call in pending calls list */ for(x=0 ; x<pGkClient->callsPendingList.count; x++) { pNode = dListFindByIndex(&pGkClient->callsPendingList, x); pCallAdmInfo = (RasCallAdmissionInfo*) pNode->data; if(pCallAdmInfo->requestSeqNum == pAdmissionReject->requestSeqNum) break; pNode = NULL; pCallAdmInfo = NULL; } if(!pCallAdmInfo) { OOTRACEWARN2("Received admission reject with request number %d can not" " be matched with any pending call.\n", pAdmissionReject->requestSeqNum); return OO_OK; }else{ call = pCallAdmInfo->call; dListRemove(&pGkClient->callsPendingList, pNode); memFreePtr(&pGkClient->ctxt, pCallAdmInfo); memFreePtr(&pGkClient->ctxt, pNode); } OOTRACEINFO4("Admission Reject message received with reason code %d for " "(%s, %s)\n", pAdmissionReject->rejectReason.t, call->callType, call->callToken); call->callState = OO_CALL_CLEAR; switch(pAdmissionReject->rejectReason.t) { case T_H225AdmissionRejectReason_calledPartyNotRegistered: call->callEndReason = OO_REASON_GK_NOCALLEDUSER; break; case T_H225AdmissionRejectReason_invalidPermission: case T_H225AdmissionRejectReason_requestDenied: case T_H225AdmissionRejectReason_undefinedReason: call->callEndReason = OO_REASON_GK_CLEARED; break; case T_H225AdmissionRejectReason_callerNotRegistered: call->callEndReason = OO_REASON_GK_NOCALLERUSER; break; case T_H225AdmissionRejectReason_exceedsCallCapacity: case T_H225AdmissionRejectReason_resourceUnavailable: call->callEndReason = OO_REASON_GK_NORESOURCES; break; case T_H225AdmissionRejectReason_noRouteToDestination: case T_H225AdmissionRejectReason_unallocatedNumber: call->callEndReason = OO_REASON_GK_UNREACHABLE; break; case T_H225AdmissionRejectReason_routeCallToGatekeeper: case T_H225AdmissionRejectReason_invalidEndpointIdentifier: case T_H225AdmissionRejectReason_securityDenial: case T_H225AdmissionRejectReason_qosControlNotSupported: case T_H225AdmissionRejectReason_incompleteAddress: case T_H225AdmissionRejectReason_aliasesInconsistent: case T_H225AdmissionRejectReason_routeCallToSCN: case T_H225AdmissionRejectReas
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?