ooh323.c
来自「一个非常美妙的proxy。功能强大。基于sip的协议。如果还要的话」· C语言 代码 · 共 1,721 行 · 第 1/5 页
C
1,721 行
/* * Copyright (C) 2004-2005 by Objective Systems, Inc. * * This software is furnished under an open source license and may be * used and copied only in accordance with the terms of this license. * The text of the license may generally be found in the root * directory of this installation in the COPYING file. It * can also be viewed online at the following URL: * * http://www.obj-sys.com/open/license.html * * Any redistributions of this file including modified versions must * maintain this copyright notice. * *****************************************************************************/#include "ootypes.h"#include "ooq931.h"#include "ootrace.h"#include "oochannels.h"#include "ooh245.h"#include "ooCalls.h"#include "printHandler.h"#include "ooh323.h"#include "ooh323ep.h"#include "ooGkClient.h"#include "ooTimer.h"/** Global endpoint structure */extern OOH323EndPoint gH323ep;int ooOnReceivedReleaseComplete(OOH323CallData *call, Q931Message *q931Msg){ int ret = OO_OK; H225ReleaseComplete_UUIE * releaseComplete = NULL; ASN1UINT i; DListNode *pNode = NULL; OOTimer *pTimer = NULL; unsigned reasonCode=T_H225ReleaseCompleteReason_undefinedReason; enum Q931CauseValues cause= Q931ErrorInCauseIE; if(q931Msg->causeIE) { cause = q931Msg->causeIE->data[1]; /* Get rid of the extension bit.For more info, check ooQ931SetCauseIE */ cause = cause & 0x7f; OOTRACEDBGA4("Cause of Release Complete is %x. (%s, %s)\n", cause, call->callType, call->callToken); } /* Remove session timer, if active*/ for(i = 0; i<call->timerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if(((ooTimerCallback*)pTimer->cbData)->timerType & OO_SESSION_TIMER) { memFreePtr(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted Session Timer. (%s, %s)\n", call->callType, call->callToken); break; } } if(!q931Msg->userInfo) { OOTRACEERR3("ERROR:No User-User IE in received ReleaseComplete message " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } releaseComplete = q931Msg->userInfo->h323_uu_pdu.h323_message_body.u.releaseComplete; if(!releaseComplete) { OOTRACEWARN3("WARN: ReleaseComplete UUIE not found in received " "ReleaseComplete message - %s " "%s\n", call->callType, call->callToken); }else{ if(releaseComplete->m.reasonPresent) { OOTRACEINFO4("Release complete reason code %d. (%s, %s)\n", releaseComplete->reason.t, call->callType, call->callToken); reasonCode = releaseComplete->reason.t; } } if(call->callEndReason == OO_REASON_UNKNOWN) call->callEndReason = ooGetCallClearReasonFromCauseAndReasonCode(cause, reasonCode);#if 0 if (q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && q931Msg->userInfo->h323_uu_pdu.h245Tunneling && OO_TESTFLAG (call->flags, OO_M_TUNNELING) ) { OOTRACEDBGB3("Handling tunneled messages in ReleaseComplete. (%s, %s)\n", call->callType, call->callToken); ret = ooHandleTunneledH245Messages (call, &q931Msg->userInfo->h323_uu_pdu); OOTRACEDBGB3("Finished handling tunneled messages in ReleaseComplete." " (%s, %s)\n", call->callType, call->callToken); }#endif if(call->h245SessionState != OO_H245SESSION_IDLE && call->h245SessionState != OO_H245SESSION_CLOSED) { ooCloseH245Connection(call); } if(call->callState != OO_CALL_CLEAR_RELEASESENT) { if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK)) { if(gH323ep.gkClient->state == GkClientRegistered){ OOTRACEDBGA3("Sending DRQ after received ReleaseComplete." "(%s, %s)\n", call->callType, call->callToken); ooGkClientSendDisengageRequest(gH323ep.gkClient, call); } } } call->callState = OO_CALL_CLEARED; return ret;}int ooOnReceivedSetup(OOH323CallData *call, Q931Message *q931Msg){ H225Setup_UUIE *setup=NULL; int i=0, ret=0; H245OpenLogicalChannel* olc; ASN1OCTET msgbuf[MAXMSGLEN]; H225TransportAddress_ipAddress_ip *ip = NULL; Q931InformationElement* pDisplayIE=NULL; OOAliases *pAlias=NULL; call->callReference = q931Msg->callReference; if(!q931Msg->userInfo) { OOTRACEERR3("ERROR:No User-User IE in received SETUP message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } setup = q931Msg->userInfo->h323_uu_pdu.h323_message_body.u.setup; if(!setup) { OOTRACEERR3("Error: Setup UUIE not found in received setup message - %s " "%s\n", call->callType, call->callToken); return OO_FAILED; } memcpy(call->callIdentifier.guid.data, setup->callIdentifier.guid.data, setup->callIdentifier.guid.numocts); call->callIdentifier.guid.numocts = setup->callIdentifier.guid.numocts; memcpy(call->confIdentifier.data, setup->conferenceID.data, setup->conferenceID.numocts); call->confIdentifier.numocts = setup->conferenceID.numocts; /* check for display ie */ pDisplayIE = ooQ931GetIE(q931Msg, Q931DisplayIE); if(pDisplayIE) { call->remoteDisplayName = (ASN1OCTET*) memAlloc(call->pctxt, pDisplayIE->length*sizeof(ASN1OCTET)+1); strcpy(call->remoteDisplayName, pDisplayIE->data); } /*Extract Remote Aliases, if present*/ if(setup->m.sourceAddressPresent) { if(setup->sourceAddress.count>0) { ooH323RetrieveAliases(call, &setup->sourceAddress, &call->remoteAliases); pAlias = call->remoteAliases; while(pAlias) { if(pAlias->type == T_H225AliasAddress_dialedDigits) { if(!call->callingPartyNumber) { call->callingPartyNumber = (char*)memAlloc(call->pctxt, strlen(pAlias->value)*+1); if(call->callingPartyNumber) { strcpy(call->callingPartyNumber, pAlias->value); } } break; } pAlias = pAlias->next; } } } /* Extract, aliases used for us, if present. Also, Populate calledPartyNumber from dialedDigits, if not yet populated using calledPartyNumber Q931 IE. */ if(setup->m.destinationAddressPresent) { if(setup->destinationAddress.count>0) { ooH323RetrieveAliases(call, &setup->destinationAddress, &call->ourAliases); pAlias = call->ourAliases; while(pAlias) { if(pAlias->type == T_H225AliasAddress_dialedDigits) { if(!call->calledPartyNumber) { call->calledPartyNumber = (char*)memAlloc(call->pctxt, strlen(pAlias->value)*+1); if(call->calledPartyNumber) { strcpy(call->calledPartyNumber, pAlias->value); } } break; } pAlias = pAlias->next; } } } /* Check for tunneling */ if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent) { /* Tunneling enabled only when tunneling is set to true and h245 address is absent. In the presence of H.245 address in received SETUP message, tunneling is disabled, irrespective of tunneling flag in the setup message*/ if(q931Msg->userInfo->h323_uu_pdu.h245Tunneling && !setup->m.h245AddressPresent) { if(OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING)) { OO_SETFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Call has tunneling active (%s,%s)\n", call->callType, call->callToken); } else OOTRACEINFO3("ERROR:Remote endpoint wants to use h245Tunneling, " "local endpoint has it disabled (%s,%s)\n", call->callType, call->callToken); }else { if(OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING)) { OOTRACEINFO3("Tunneling disabled by remote endpoint. (%s, %s)\n", call->callType, call->callToken); } OO_CLRFLAG (call->flags, OO_M_TUNNELING); } } else { if(OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING)) { OOTRACEINFO3("Tunneling disabled by remote endpoint. (%s, %s)\n", call->callType, call->callToken); } OO_CLRFLAG (call->flags, OO_M_TUNNELING); } /* Extract Remote IP address */ if(!setup->m.sourceCallSignalAddressPresent) { OOTRACEWARN3("WARNING:Missing source call signal address in received " "setup (%s, %s)\n", call->callType, call->callToken); }else{ if(setup->sourceCallSignalAddress.t != T_H225TransportAddress_ipAddress) { OOTRACEERR3("ERROR: Source call signalling address type not ip " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ip = &setup->sourceCallSignalAddress.u.ipAddress->ip; sprintf(call->remoteIP, "%d.%d.%d.%d", ip->data[0], ip->data[1], ip->data[2], ip->data[3]); call->remotePort = setup->sourceCallSignalAddress.u.ipAddress->port; } /* check for fast start */ if(setup->m.fastStartPresent) { if(!OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART)) { OOTRACEINFO3("Local endpoint does not support fastStart. Ignoring " "fastStart. (%s, %s)\n", call->callType, call->callToken); OO_CLRFLAG (call->flags, OO_M_FASTSTART); } else if(setup->fastStart.n == 0) { OOTRACEINFO3("Empty faststart element received. Ignoring fast start. " "(%s, %s)\n", call->callType, call->callToken); OO_CLRFLAG (call->flags, OO_M_FASTSTART); } else{ OO_SETFLAG (call->flags, OO_M_FASTSTART); OOTRACEINFO3("FastStart enabled for call(%s, %s)\n", call->callType, call->callToken); } } if (OO_TESTFLAG (call->flags, OO_M_FASTSTART)) { /* For printing the decoded message to log, initialize handler. */ initializePrintHandler(&printHandler, "FastStart Elements"); /* Set print handler */ setEventHandler (call->pctxt, &printHandler); for(i=0; i<(int)setup->fastStart.n; i++) { olc = NULL; /* memset(msgbuf, 0, sizeof(msgbuf));*/ olc = (H245OpenLogicalChannel*)memAlloc(call->pctxt, sizeof(H245OpenLogicalChannel)); if(!olc) { OOTRACEERR3("ERROR:Memory - ooOnReceivedSetup - olc (%s, %s)\n", call->callType, call->callToken); /*Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } memset(olc, 0, sizeof(H245OpenLogicalChannel)); memcpy(msgbuf, setup->fastStart.elem[i].data, setup->fastStart.elem[i].numocts); setPERBuffer(call->pctxt, msgbuf, setup->fastStart.elem[i].numocts, 1); ret = asn1PD_H245OpenLogicalChannel(call->pctxt, olc); if(ret != ASN_OK) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?