|
reSIProcate/stack
9694
|
00001 #if !defined(RESIP_DIALOG_HXX) 00002 #define RESIP_DIALOG_HXX 00003 00004 #include <iosfwd> 00005 #include "resip/stack/MethodTypes.hxx" 00006 #include "resip/stack/NameAddr.hxx" 00007 #include "resip/stack/Uri.hxx" 00008 #include "resip/stack/CallId.hxx" 00009 #include "rutil/BaseException.hxx" 00010 #include "rutil/Timer.hxx" 00011 00012 namespace resip 00013 { 00014 00015 class SipMessage; 00016 class NameAddr; 00017 class CallID; 00018 00019 class DeprecatedDialog 00020 { 00021 public: 00022 class Exception : public BaseException 00023 { 00024 public: 00025 Exception( const resip::Data& msg, 00026 const resip::Data& file, 00027 const int line): BaseException(msg,file,line){} 00028 const char* name() const { return "Dialog::Exception"; } 00029 }; 00030 00031 // pass in a contact for this location e.g. "sip:local@domain:5060" 00032 DeprecatedDialog(const NameAddr& localContact); 00033 00034 // If a dialog is not yet created, make a dialog or early dialog as 00035 // follows. Otherwise, just make response from the dialog state 00036 // Used by the UAS to create a dialog or early dialog, will return a 1xx(code) 00037 // UAS should call this upon receiving the invite/subscribe. 00038 // This should not be called twice if the UAS sends back a 180 and a 200, 00039 // it should call it for the 180 and then use Dialog::makeResponse to make 00040 // the 200 00041 SipMessage* makeResponse(const SipMessage& request, int code=200); 00042 00043 // This happens when a dialog gets created on a UAC when 00044 // a UAC receives a response that creates a dialog. Also works for NOTIFY 00045 // requests which create a dialog 00046 void createDialogAsUAC(const SipMessage& response); 00047 00048 // Called when a 2xx response is received in an existing dialog 00049 // Replace the _remoteTarget with uri from Contact header in response 00050 void targetRefreshResponse(const SipMessage& response); 00051 00052 // Called when a request is received in an existing dialog 00053 // return status code of response to generate - 0 if ok 00054 int targetRefreshRequest(const SipMessage& request); 00055 00056 // given a template of a request, update the relevant fields based on this 00057 void updateRequest(SipMessage& msg); 00058 00059 // For UAS, make a response and create the dialog if necessary 00060 void makeResponse(const SipMessage& request, SipMessage& response, int code=200); 00061 00062 bool isCreated() const { return mCreated; } 00063 bool isEarly() const { return mEarly; } 00064 00065 static Data dialogId(const SipMessage& msg); 00066 const Data dialogId() const; 00067 const CallID& getCallId() const { return mCallId; } 00068 const NameAddr& getRemoteTarget() const { return mRemoteTarget; } 00069 //const Data& getLocalTag() const { return mLocalTag; } 00070 const Data& getRemoteTag() const { return mRemoteTag; } 00071 00072 // For creating request which do not form a dialog but whose response 00073 // might create a dialog 00074 SipMessage* makeInitialRegister(const NameAddr& registrar, const NameAddr& from); 00075 SipMessage* makeInitialSubscribe(const NameAddr& target, const NameAddr& from); 00076 SipMessage* makeInitialPublish(const NameAddr& target, const NameAddr& from); 00077 SipMessage* makeInitialInvite(const NameAddr& target, const NameAddr& from); 00078 SipMessage* makeInitialMessage(const NameAddr& target, const NameAddr& from); 00079 00080 // For creating requests within a dialog 00081 SipMessage* makeInvite(); 00082 SipMessage* makeUpdate(); 00083 SipMessage* makeRegister(); 00084 SipMessage* makeSubscribe(); 00085 SipMessage* makeBye(); 00086 SipMessage* makeRefer(const NameAddr& referTo); 00087 SipMessage* makeNotify(); 00088 SipMessage* makeOptions(); 00089 SipMessage* makePublish(); 00090 SipMessage* makeAck(); 00091 SipMessage* makeAck(const SipMessage& request); 00092 SipMessage* makeCancel(const SipMessage& request); 00093 SipMessage* makeRequest(MethodTypes method); 00094 CallID makeReplaces(); 00095 00096 // resets to an empty dialog with no state 00097 void clear(); 00098 00099 // set how many seconds in the futre this dialog will expire 00100 void setExpirySeconds( int secondsInFuture ); 00101 int getExpirySeconds(); // get number Seconds till this expires, it can 00102 // be negative 00103 00104 00105 private: 00106 SipMessage* makeRequestInternal(MethodTypes method); 00107 void incrementCSeq(SipMessage& request); 00108 void copyCSeq(SipMessage& request); 00109 00110 NameAddr mContact; // for this UA 00111 00112 // Dialog State 00113 bool mCreated; 00114 bool mEarly; 00115 00116 Uri mRequestUri; 00117 00118 NameAddrs mRouteSet; 00119 NameAddr mRemoteTarget; 00120 00121 unsigned long mRemoteSequence; 00122 bool mRemoteEmpty; 00123 unsigned long mLocalSequence; 00124 bool mLocalEmpty; 00125 00126 CallID mCallId; 00127 Data mLocalTag; 00128 Data mRemoteTag; 00129 CallID mDialogId; 00130 00131 NameAddr mRemoteUri; 00132 NameAddr mLocalUri; 00133 00134 bool secure; // indicates the messages in this Dialog must use TLS 00135 00136 UInt64 expireyTimeAbsoluteMs; 00137 00138 friend EncodeStream& operator<<(EncodeStream&, const DeprecatedDialog&); 00139 }; 00140 00141 EncodeStream& 00142 operator<<(EncodeStream& strm, const DeprecatedDialog& d); 00143 00144 } // namespace Cathay 00145 00146 #endif 00147 00148 /* ==================================================================== 00149 * The Vovida Software License, Version 1.0 00150 * 00151 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00152 * 00153 * Redistribution and use in source and binary forms, with or without 00154 * modification, are permitted provided that the following conditions 00155 * are met: 00156 * 00157 * 1. Redistributions of source code must retain the above copyright 00158 * notice, this list of conditions and the following disclaimer. 00159 * 00160 * 2. Redistributions in binary form must reproduce the above copyright 00161 * notice, this list of conditions and the following disclaimer in 00162 * the documentation and/or other materials provided with the 00163 * distribution. 00164 * 00165 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00166 * and "Vovida Open Communication Application Library (VOCAL)" must 00167 * not be used to endorse or promote products derived from this 00168 * software without prior written permission. For written 00169 * permission, please contact vocal@vovida.org. 00170 * 00171 * 4. Products derived from this software may not be called "VOCAL", nor 00172 * may "VOCAL" appear in their name, without prior written 00173 * permission of Vovida Networks, Inc. 00174 * 00175 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00176 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00177 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00178 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00179 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00180 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00181 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00182 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00183 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00184 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00185 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00186 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00187 * DAMAGE. 00188 * 00189 * ==================================================================== 00190 * 00191 * This software consists of voluntary contributions made by Vovida 00192 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00193 * Inc. For more information on Vovida Networks, Inc., please see 00194 * <http://www.vovida.org/>. 00195 * 00196 */
1.7.5.1