📄 dialog.cxx
字号:
return *i; } } return 0;}ClientSubscription*Dialog::findMatchingClientSub(const SipMessage& msg){ for (std::list<ClientSubscription*>::iterator i=mClientSubscriptions.begin(); i != mClientSubscriptions.end(); ++i) { if ((*i)->matches(msg)) { return *i; } } return 0;}InviteSessionHandleDialog::getInviteSession(){ if (mInviteSession) { return mInviteSession->getSessionHandle(); } else { return InviteSessionHandle::NotValid(); }}std::vector<ClientSubscriptionHandle>Dialog::findClientSubscriptions(const Data& event){ std::vector<ClientSubscriptionHandle> handles; for (std::list<ClientSubscription*>::const_iterator i = mClientSubscriptions.begin(); i != mClientSubscriptions.end(); ++i) { if ( (*i)->getEventType() == event) { handles.push_back((*i)->getHandle()); } } return handles;}std::vector<ServerSubscriptionHandle>Dialog::findServerSubscriptions(const Data& event){ std::vector<ServerSubscriptionHandle> handles; for (std::list<ServerSubscription*>::const_iterator i = mServerSubscriptions.begin(); i != mServerSubscriptions.end(); ++i) { if ( (*i)->getEventType() == event) { handles.push_back((*i)->getHandle()); } } return handles;}std::vector<ClientSubscriptionHandle>Dialog::getClientSubscriptions(){ std::vector<ClientSubscriptionHandle> handles; for (std::list<ClientSubscription*>::const_iterator i = mClientSubscriptions.begin(); i != mClientSubscriptions.end(); ++i) { handles.push_back((*i)->getHandle()); } return handles;}std::vector<ServerSubscriptionHandle>Dialog::getServerSubscriptions(){ std::vector<ServerSubscriptionHandle> handles; for (std::list<ServerSubscription*>::const_iterator i = mServerSubscriptions.begin(); i != mServerSubscriptions.end(); ++i) { handles.push_back((*i)->getHandle()); } return handles;}voidDialog::redirected(const SipMessage& msg){ //Established dialogs are not destroyed by a redirect if (!mClientSubscriptions.empty() || !mServerSubscriptions.empty()) { return; } if (mInviteSession) { ClientInviteSession* cInv = dynamic_cast<ClientInviteSession*>(mInviteSession); if (cInv) { cInv->handleRedirect(msg); mReUseDialogSet = true; // Set flag so that DialogSet will not be destroyed and new Request can use it } }}voidDialog::makeRequest(SipMessage& request, MethodTypes method){ RequestLine rLine(method); rLine.uri() = mRemoteTarget.uri(); request.header(h_RequestLine) = rLine; request.header(h_To) = mRemoteNameAddr;// request.header(h_To).param(p_tag) = mId.getRemoteTag(); request.header(h_From) = mLocalNameAddr;// request.header(h_From).param(p_tag) = mId.getLocalTag(); request.header(h_CallId) = mCallId; request.remove(h_RecordRoutes); //!dcm! -- all of this is rather messy request.remove(h_Replaces); request.remove(h_Contacts); request.header(h_Contacts).push_front(mLocalContact); request.header(h_CSeq).method() = method; request.header(h_MaxForwards).value() = 70; //must keep old via for cancel if (method != CANCEL) { request.header(h_Routes) = mRouteSet; request.remove(h_Vias); Via via; via.param(p_branch); // will create the branch request.header(h_Vias).push_front(via); } else { assert(request.exists(h_Vias)); } //don't increment CSeq for ACK or CANCEL if (method != ACK && method != CANCEL) { request.header(h_CSeq).sequence() = ++mLocalCSeq; } else { // ACK and cancel have a minimal header set request.remove(h_Accepts); request.remove(h_AcceptEncodings); request.remove(h_AcceptLanguages); request.remove(h_Allows); request.remove(h_Requires); request.remove(h_ProxyRequires); request.remove(h_Supporteds); // request.header(h_CSeq).sequence() = ?; // Caller should provide original request, or modify CSeq to proper value after calling this method } // If method is INVITE then advertise required headers if(method == INVITE || method == UPDATE) { if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::Allow)) request.header(h_Allows) = mDum.getMasterProfile()->getAllowedMethods(); if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::AcceptEncoding)) request.header(h_AcceptEncodings) = mDum.getMasterProfile()->getSupportedEncodings(); if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::AcceptLanguage)) request.header(h_AcceptLanguages) = mDum.getMasterProfile()->getSupportedLanguages(); if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::AllowEvents)) request.header(h_AllowEvents) = mDum.getMasterProfile()->getAllowedEvents(); if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::Supported)) request.header(h_Supporteds) = mDum.getMasterProfile()->getSupportedOptionTags(); } if (mDialogSet.mUserProfile->isAnonymous()) { request.header(h_Privacys).push_back(Token(Symbols::id)); } DebugLog ( << "Dialog::makeRequest: " << std::endl << std::endl << request );}voidDialog::makeResponse(SipMessage& response, const SipMessage& request, int code){ assert( code >= 100 ); response.remove(h_Contacts); if (code < 300 && code > 100) { assert(request.isRequest()); assert(request.header(h_RequestLine).getMethod() == INVITE || request.header(h_RequestLine).getMethod() == SUBSCRIBE || request.header(h_RequestLine).getMethod() == BYE || request.header(h_RequestLine).getMethod() == CANCEL || request.header(h_RequestLine).getMethod() == REFER || request.header(h_RequestLine).getMethod() == MESSAGE || request.header(h_RequestLine).getMethod() == NOTIFY || request.header(h_RequestLine).getMethod() == INFO || request.header(h_RequestLine).getMethod() == OPTIONS || request.header(h_RequestLine).getMethod() == UPDATE );// assert (request.header(h_RequestLine).getMethod() == CANCEL || // Contact header is not required for Requests that do not form a dialog// request.header(h_RequestLine).getMethod() == BYE ||// request.header(h_Contacts).size() == 1); Helper::makeResponse(response, request, code, mLocalContact); response.header(h_To).param(p_tag) = mId.getLocalTag(); if((request.header(h_RequestLine).getMethod() == INVITE || request.header(h_RequestLine).getMethod() == UPDATE) && code >= 200 && code < 300) { // Check if we should add our capabilites to the invite success response if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::Allow)) { response.header(h_Allows) = mDum.getMasterProfile()->getAllowedMethods(); } if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::AcceptEncoding)) { response.header(h_AcceptEncodings) = mDum.getMasterProfile()->getSupportedEncodings(); } if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::AcceptLanguage)) { response.header(h_AcceptLanguages) = mDum.getMasterProfile()->getSupportedLanguages(); } if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::AllowEvents)) { response.header(h_AllowEvents) = mDum.getMasterProfile()->getAllowedEvents(); } if(mDialogSet.getUserProfile()->isAdvertisedCapability(Headers::Supported)) { response.header(h_Supporteds) = mDum.getMasterProfile()->getSupportedOptionTags(); } } } else { Helper::makeResponse(response, request, code); response.header(h_To).param(p_tag) = mId.getLocalTag(); } DebugLog ( << "Dialog::makeResponse: " << std::endl << std::endl << response);}ClientInviteSession*Dialog::makeClientInviteSession(const SipMessage& response){ InviteSessionCreator* creator = dynamic_cast<InviteSessionCreator*>(mDialogSet.getCreator()); assert(creator); // !jf! this maybe can assert by evil UAS //return mDum.createAppClientInviteSession(*this, *creator); return new ClientInviteSession(mDum, *this, creator->getLastRequest(), creator->getInitialOffer(), creator->getEncryptionLevel(), creator->getServerSubscription());}ClientSubscription*Dialog::makeClientSubscription(const SipMessage& request){ return new ClientSubscription(mDum, *this, request, mDefaultSubExpiration);}ServerInviteSession*Dialog::makeServerInviteSession(const SipMessage& request){ return new ServerInviteSession(mDum, *this, request);}ServerSubscription*Dialog::makeServerSubscription(const SipMessage& request){ return new ServerSubscription(mDum, *this, request);}Dialog::Exception::Exception(const Data& msg, const Data& file, int line) : BaseException(msg, file, line){}voidDialog::send(SharedPtr<SipMessage> msg){ if (msg->isRequest() && msg->header(h_CSeq).method() != ACK) { mRequests[msg->header(h_CSeq).sequence()] = msg; } mDum.send(msg);}voidDialog::onForkAccepted(){ ClientInviteSession* uac = dynamic_cast<ClientInviteSession*>(mInviteSession); if (uac) { uac->onForkAccepted(); }}void Dialog::possiblyDie(){ // !slg! Note: dialogs should really stick around for 32s, in order to ensure that all 2xx retransmissions get Ack'd, then BYE'd correctly if (!mDestroying) { if (mClientSubscriptions.empty() && mServerSubscriptions.empty() && !mInviteSession) { mDestroying = true; mDum.destroy(this); } }}ostream&resip::operator<<(ostream& strm, const Dialog& dialog){ strm << "mClientSubscriptions(" << dialog.mClientSubscriptions.size() << "), " << "mServerSubscriptions(" << dialog.mServerSubscriptions.size() << ")"; return strm;}/* ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -