reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ServerRegistration.hxx
Go to the documentation of this file.
1#if !defined(RESIP_SERVERREGISTRATION_HXX)
2#define RESIP_SERVERREGISTRATION_HXX
3
7
8#include <memory>
9#include <utility>
10
11namespace resip
12{
13
15{
16 public:
18
24 void accept(SipMessage& ok);
25
31 void accept(int statusCode = 200);
32
38 void reject(SipMessage& failure);
39
45 void reject(int statusCode);
46
47 void end() override;
48 void dispatch(const SipMessage& msg) override;
49 void dispatch(const DumTimeout& timer) override;
50
51 EncodeStream& dump(EncodeStream& strm) const override;
52
60 bool asyncProvideContacts(std::unique_ptr<resip::ContactPtrList> contacts);
61
62 std::shared_ptr<ContactList> getOriginalContacts() const noexcept { return mOriginalContacts; } // WARNING - use this only if async mode is not used
63 const ContactList& getRequestContacts() const noexcept { return mRequestContacts; }
64
65 protected:
66 virtual ~ServerRegistration();
67 private:
68 friend class DialogSet;
70
71 bool tryFlow(ContactInstanceRecord& rec,
72 const resip::SipMessage& msg);
73 bool flowTokenNeededForTls(const ContactInstanceRecord &rec) const;
74 bool flowTokenNeededForSigcomp(const ContactInstanceRecord &rec) const;
75 bool testFlowRequirements(ContactInstanceRecord &rec,
76 const resip::SipMessage& msg,
77 bool hasFlow) const;
78
79 SipMessage mRequest;
80 Uri mAor;
81 std::shared_ptr<ContactList> mOriginalContacts; // Used only for non-async processing
82 ContactList mRequestContacts; // Contains the Contacts from the REGISTER request
83 bool mDidOutbound;
84
113 typedef enum AsyncState
114 {
115 asyncStateNone,
116 asyncStateWaitingForInitialContactList,
117 asyncStateProcessingRegistration,
118 asyncStateWaitingForAcceptReject,
119 asyncStateAcceptedWaitingForFinalContactList,
120 asyncStateProvidedFinalContacts,
121 asyncStateQueryOnly
122 } AsyncState;
123
124 AsyncState mAsyncState;
125
128 void processRegistration(const SipMessage& msg);
129
130 void asyncProcessFinalOkMsg(SipMessage &msg, ContactPtrList &contacts);
131
135 void processFinalOkMsg(SipMessage &msg, ContactList &contacts);
136
141 void asyncProcessFinalContacts(std::unique_ptr<resip::ContactPtrList> contacts);
142
145 class AsyncLocalStore
146 {
147 public:
148
149 AsyncLocalStore(std::unique_ptr<ContactPtrList> originalContacts)
150 {
151 create(std::move(originalContacts));
152 }
153
154 ~AsyncLocalStore(void)
155 {
156 destroy();
157 }
158
162 void create(std::unique_ptr<ContactPtrList> originalContacts);
163
164 void destroy(void);
165
166 void removeContact(const ContactInstanceRecord &rec);
169 void removeAllContacts(void);
170
174 updateContact(const ContactInstanceRecord &rec);
175
179 void releaseLog(std::unique_ptr<ContactRecordTransactionLog> &log, std::unique_ptr<ContactPtrList> &modifiedContacts)
180 {
181 log = std::move(mLog);
182 modifiedContacts = std::move(mModifiedContacts);
183 }
184
185 unsigned int numContacts() { if(mModifiedContacts.get()) return (unsigned int)mModifiedContacts->size(); return 0; }
186 private:
187 std::unique_ptr<ContactRecordTransactionLog> mLog;
188 std::unique_ptr<ContactPtrList> mModifiedContacts;
189 };
190
191 std::shared_ptr<AsyncLocalStore> mAsyncLocalStore;
192
196 std::shared_ptr<SipMessage> mAsyncOkMsg;
197};
198
199}
200
201#endif
202
203/* ====================================================================
204 * The Vovida Software License, Version 1.0
205 *
206 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
207 *
208 * Redistribution and use in source and binary forms, with or without
209 * modification, are permitted provided that the following conditions
210 * are met:
211 *
212 * 1. Redistributions of source code must retain the above copyright
213 * notice, this list of conditions and the following disclaimer.
214 *
215 * 2. Redistributions in binary form must reproduce the above copyright
216 * notice, this list of conditions and the following disclaimer in
217 * the documentation and/or other materials provided with the
218
219 * distribution.
220 *
221 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
222 * and "Vovida Open Communication Application Library (VOCAL)" must
223 * not be used to endorse or promote products derived from this
224 * software without prior written permission. For written
225 * permission, please contact vocal@vovida.org.
226 *
227 * 4. Products derived from this software may not be called "VOCAL", nor
228 * may "VOCAL" appear in their name, without prior written
229 * permission of Vovida Networks, Inc.
230 *
231 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
232 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
233 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
234 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
235 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
236 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
237 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
238 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
239 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
240 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
241 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
242 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
243 * DAMAGE.
244 *
245 * ====================================================================
246 *
247 * This software consists of voluntary contributions made by Vovida
248 * Networks, Inc. and many individuals on behalf of Vovida Networks,
249 * Inc. For more information on Vovida Networks, Inc., please see
250 * <http://www.vovida.org/>.
251 *
252 */
A single contact record, bound to an Aor during registration.
const ContactList & getRequestContacts() const noexcept
std::shared_ptr< ContactList > getOriginalContacts() const noexcept
ServerRegistrationHandle getHandle()
void reject(SipMessage &failure)
Reject a SIP registration with a specific response.
EncodeStream & dump(EncodeStream &strm) const override
void accept(SipMessage &ok)
Accept a SIP registration with a specific response.
bool asyncProvideContacts(std::unique_ptr< resip::ContactPtrList > contacts)
Used when useAsyncProcessing() is true.
void dispatch(const SipMessage &msg) override
Represents a SIP message.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
Definition Uri.hxx:22
dcm! – add UnusedChecking(_enum) below;
std::list< std::shared_ptr< ContactInstanceRecord > > ContactPtrList
Used to reduce copying ContactInstanceRecord objects when processing registration.
std::list< ContactInstanceRecord > ContactList
#define EncodeStream
void list()
Definition userAdmin.cxx:66