reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Dialog.hxx
Go to the documentation of this file.
1#if !defined(RESIP_CLIENTDIALOG_HXX)
2#define RESIP_CLIENTDIALOG_HXX
3
4#include <iosfwd>
5#include <vector>
6#include <list>
7#include <map>
8
10#include "resip/dum/Handles.hxx"
17
18namespace resip
19{
20class BaseUsage;
21class SipMessage;
22class DialogUsageManager;
23class DialogSet;
24class AppDialog;
25
27
28class Dialog
29{
30 public:
31 class Exception final : public BaseException
32 {
33 public:
34 Exception(const Data& msg, const Data& file, int line);
35 const char* name() const noexcept override { return "Dialog::Exception"; }
36 };
37
38 // different behavior from request vs. response
39 // (request creates to tag)
40 Dialog(DialogUsageManager& dum, const SipMessage& msg, DialogSet& ds);
41
42 const DialogId& getId() const noexcept;
43 const NameAddr& getLocalNameAddr() const noexcept;
44 const NameAddr& getLocalContact() const noexcept;
45 const NameAddr& getRemoteNameAddr() const noexcept;
46 const NameAddr& getRemoteTarget() const noexcept;
47 const NameAddr& getPendingRemoteTarget() const;
48 const NameAddrs& getRouteSet() const noexcept;
49
50 // pass dialog sip messages through dialog so we can cache the requests on
51 // the way out to be able to respond to digest authenticate requests
52 void send(std::shared_ptr<SipMessage> msg);
53 //void send(SipMessage& msg);
54
55 void makeRequest(SipMessage& request, MethodTypes method, bool incrementCSeq = true);
56 void makeResponse(SipMessage& response, const SipMessage& request, int responseCode);
57 void setRequestNextCSeq(SipMessage& request);
58
59 //void setLocalContact(const NameAddr& localContact);
60 //void setRemoteTarget(const NameAddr& remoteTarget);
61
63 std::vector<ClientSubscriptionHandle> findClientSubscriptions(const Data& event);
64
66 std::vector<ServerSubscriptionHandle> findServerSubscriptions(const Data& event);
67
68 //returns an invalid handle if there is no session
70
71 void end(const Data& endReason, const ParserContainer<Token>& endReasons);
72 void dispatch(const SipMessage& msg);
73 void processNotify(const SipMessage& notify);
74
75 //will end this dialog(if it makes sense)
76 void redirected(const SipMessage& msg);
77
78 void onForkAccepted();
79 void cancel();
80
81 bool isDestroying() const noexcept { return mDestroying; };
82
83 private:
84 virtual ~Dialog();
85 friend class DialogUsage;
86 friend class DialogSet;
87 friend class DialogUsageManager;
88 friend class DestroyUsage;
89
90 friend class ClientSubscription;
91 friend class InviteSession;
92 friend class ClientInviteSession;
93 friend class ServerInviteSession;
94 friend class ServerSubscription;
95 friend class ClientRegistration;
96 friend class ServerRegistration;
97 friend class ClientPublication;
98 friend class ServerPublication;
101
102 friend class AppDialog;
103 void possiblyDie();
104
105 ClientSubscription* findMatchingClientSub(const SipMessage& msg);
106 ServerSubscription* findMatchingServerSub(const SipMessage& msg);
107
108 void addUsage(BaseUsage* usage);
109 ClientInviteSession* makeClientInviteSession(const SipMessage& msg);
110 ClientSubscription* makeClientSubscription(const SipMessage& msg);
111
112 ServerInviteSession* makeServerInviteSession(const SipMessage& msg);
113 ServerSubscription* makeServerSubscription(const SipMessage& msg);
114
115 //matches using tid of response
116 bool matches(const SipMessage& msg);
117 void handleTargetRefresh(const SipMessage& msg);
118 void handlePendingTargetRefresh(const SipMessage& msg);
119
120 void flowTerminated();
121
122 DialogUsageManager& mDum;
123 DialogSet& mDialogSet;
124 DialogId mId;
125
126 std::list<ClientSubscription*> mClientSubscriptions;
127 std::list<ServerSubscription*> mServerSubscriptions;
128 InviteSession* mInviteSession;
129
130 NetworkAssociation mNetworkAssociation;
131
132 //invariants
133 typedef enum // need to add
134 {
135 Invitation, // INVITE dialog
136 Subscription, // Created by a SUBSCRIBE / NOTIFY / REFER
137 Fake // Not really a dialog (e.g. created by a REGISTER)
138 } DialogType;
139
140 DialogType mType; // !jf! is this necessary?
141 NameAddrs mRouteSet;
142
143 //variants
144 NameAddr mLocalContact;
145 unsigned int mLocalCSeq;
146 unsigned int mRemoteCSeq;
147 NameAddr mPendingRemoteTarget;
148 unsigned int mPendingRemoteTargetCSeq;
149 NameAddr mRemoteTarget;
150 NameAddr mLocalNameAddr;
151 NameAddr mRemoteNameAddr;
152 CallID mCallId;
153
154 // store until we get a response (non-401/407)
155 // !jf! this shouldn't be necessary
156 // !dcm! -- no longer used for subscriptions, INVITE will take more thought/work
157 typedef std::map<int, std::shared_ptr<SipMessage>> RequestMap;
158 RequestMap mRequests;
159
160 AppDialog* mAppDialog;
161
162 bool mDestroying;
163 bool mReUseDialogSet;
164
166};
167
169
170}
171
172#endif
173
174/* ====================================================================
175 * The Vovida Software License, Version 1.0
176 *
177 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
178 *
179 * Redistribution and use in source and binary forms, with or without
180 * modification, are permitted provided that the following conditions
181 * are met:
182 *
183 * 1. Redistributions of source code must retain the above copyright
184 * notice, this list of conditions and the following disclaimer.
185 *
186 * 2. Redistributions in binary form must reproduce the above copyright
187 * notice, this list of conditions and the following disclaimer in
188 * the documentation and/or other materials provided with the
189 * distribution.
190 *
191 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
192 * and "Vovida Open Communication Application Library (VOCAL)" must
193 * not be used to endorse or promote products derived from this
194 * software without prior written permission. For written
195 * permission, please contact vocal@vovida.org.
196 *
197 * 4. Products derived from this software may not be called "VOCAL", nor
198 * may "VOCAL" appear in their name, without prior written
199 * permission of Vovida Networks, Inc.
200 *
201 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
202 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
203 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
204 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
205 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
206 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
207 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
208 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
209 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
210 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
211 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
212 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
213 * DAMAGE.
214 *
215 * ====================================================================
216 *
217 * This software consists of voluntary contributions made by Vovida
218 * Networks, Inc. and many individuals on behalf of Vovida Networks,
219 * Inc. For more information on Vovida Networks, Inc., please see
220 * <http://www.vovida.org/>.
221 *
222 */
static void usage(void)
Definition adig.c:755
The abstract base-class for all exceptions thrown by resip code.
Represents the "callid" element in the SIP grammar.
Definition CallId.hxx:18
dcm! – shutdown/deletion API – end?
dcm! – update contact in dialog if required
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
const char * name() const noexcept override
Definition Dialog.hxx:35
dcm! – kill typedef std::list<DialogId> DialogIdSet;
Definition Dialog.hxx:29
friend EncodeStream & operator<<(EncodeStream &strm, const Dialog &dialog)
const NameAddr & getRemoteNameAddr() const noexcept
Definition Dialog.cxx:343
std::vector< ClientSubscriptionHandle > findClientSubscriptions(const Data &event)
Definition Dialog.cxx:954
const NameAddr & getRemoteTarget() const noexcept
Definition Dialog.cxx:349
const NameAddr & getLocalNameAddr() const noexcept
Definition Dialog.cxx:331
void cancel()
Definition Dialog.cxx:367
void redirected(const SipMessage &msg)
Definition Dialog.cxx:1014
const NameAddr & getLocalContact() const noexcept
Definition Dialog.cxx:337
void makeRequest(SipMessage &request, MethodTypes method, bool incrementCSeq=true)
Definition Dialog.cxx:1033
bool isDestroying() const noexcept
Definition Dialog.hxx:81
void end(const Data &endReason, const ParserContainer< Token > &endReasons)
Definition Dialog.cxx:377
const DialogId & getId() const noexcept
Definition Dialog.cxx:325
const NameAddrs & getRouteSet() const noexcept
Definition Dialog.cxx:361
void setRequestNextCSeq(SipMessage &request)
Definition Dialog.cxx:1153
void onForkAccepted()
Definition Dialog.cxx:1209
InviteSessionHandle getInviteSession()
Definition Dialog.cxx:941
void processNotify(const SipMessage &notify)
std::vector< ServerSubscriptionHandle > getServerSubscriptions()
Definition Dialog.cxx:1000
std::vector< ServerSubscriptionHandle > findServerSubscriptions(const Data &event)
Definition Dialog.cxx:970
void dispatch(const SipMessage &msg)
Definition Dialog.cxx:477
void makeResponse(SipMessage &response, const SipMessage &request, int responseCode)
Definition Dialog.cxx:1108
const NameAddr & getPendingRemoteTarget() const
Definition Dialog.cxx:355
std::vector< ClientSubscriptionHandle > getClientSubscriptions()
Definition Dialog.cxx:986
void send(std::shared_ptr< SipMessage > msg)
Definition Dialog.cxx:1198
Base class for class ClientInviteSession and class ServerInviteSession.
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Definition NameAddr.hxx:19
dcm! – no Subscription State expires parameter generation yet.
Represents a SIP message.
Represents the "token" element in the RFC 3261 grammar.
Definition Token.hxx:18
dcm! – add UnusedChecking(_enum) below;
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
#define EncodeStream
void list()
Definition userAdmin.cxx:66