reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
RegistrationHandler.cxx
Go to the documentation of this file.
5#include "rutil/Logger.hxx"
6
7#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
8
9using namespace resip;
10
11void
13{
14 InfoLog (<< "ClientRegistrationHandler::onFlowTerminated, refreshing registration to open new flow");
15 h->requestRefresh();
16}
17
18bool
20{
21 InfoLog(<<"ClientRegistrationHandler::onRefreshRequired, returning true");
22 return true;
23}
24
25void
26ServerRegistrationHandler::getGlobalExpires(const SipMessage& msg, const std::shared_ptr<MasterProfile>& masterProfile,
27 uint32_t &expires, uint32_t &returnCode)
28{
29 if (!masterProfile)
30 {
31 returnCode = 500;
32 resip_assert(0);
33 return;
34 }
35
36 expires=3600;
37 returnCode=0;
38
39 if (!msg.empty(h_Expires) && msg.header(h_Expires).isWellFormed())
40 {
41 //only client specified Expires value is subject to the min/max constraints, default is used if none specified.
42 expires = msg.header(h_Expires).value();
43
44 if (expires != 0)
45 {
46 //check min expires first since max expires will not return an error and will just change the expires value.
47 uint32_t minExpires = masterProfile->serverRegistrationMinExpiresTime();
48
49 if (expires < minExpires)
50 {
51 returnCode = 423;
52 expires = minExpires;
53 }
54 else
55 {
56 uint32_t maxExpires = masterProfile->serverRegistrationMaxExpiresTime();
57
58 if (expires > maxExpires)
59 {
60 expires = maxExpires;
61 }
62 }
63 }
64 }
65 else
66 {
67 expires = masterProfile->serverRegistrationDefaultExpiresTime();
68 }
69}
70
71void
72ServerRegistrationHandler::getContactExpires(const NameAddr &contact, const std::shared_ptr<MasterProfile>& masterProfile,
73 uint32_t &expires, uint32_t &returnCode)
74{
75 if (!masterProfile)
76 {
77 returnCode = 500;
78 resip_assert(0);
79 return;
80 }
81
82 returnCode=0;
83
84 if (contact.exists(p_expires))
85 {
86 expires = contact.param(p_expires);
87
88 if (expires != 0)
89 {
90 //check min expires first since max expires will not return an error and will just change the expires value.
91 uint32_t minExpires = masterProfile->serverRegistrationMinExpiresTime();
92
93 if (expires < minExpires)
94 {
95 returnCode = 423;
96 expires = minExpires;
97 }
98 else
99 {
100 uint32_t maxExpires = masterProfile->serverRegistrationMaxExpiresTime();
101
102 if (expires > maxExpires)
103 {
104 expires = maxExpires;
105 }
106 }
107 }
108 }
109}
110
111
112/* ====================================================================
113 * The Vovida Software License, Version 1.0
114 *
115 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
116 *
117 * Redistribution and use in source and binary forms, with or without
118 * modification, are permitted provided that the following conditions
119 * are met:
120 *
121 * 1. Redistributions of source code must retain the above copyright
122 * notice, this list of conditions and the following disclaimer.
123 *
124 * 2. Redistributions in binary form must reproduce the above copyright
125 * notice, this list of conditions and the following disclaimer in
126 * the documentation and/or other materials provided with the
127 * distribution.
128 *
129 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
130 * and "Vovida Open Communication Application Library (VOCAL)" must
131 * not be used to endorse or promote products derived from this
132 * software without prior written permission. For written
133 * permission, please contact vocal@vovida.org.
134 *
135 * 4. Products derived from this software may not be called "VOCAL", nor
136 * may "VOCAL" appear in their name, without prior written
137 * permission of Vovida Networks, Inc.
138 *
139 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
140 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
141 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
142 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
143 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
144 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
145 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
146 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
147 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
148 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
149 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
150 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
151 * DAMAGE.
152 *
153 * ====================================================================
154 *
155 * This software consists of voluntary contributions made by Vovida
156 * Networks, Inc. and many individuals on behalf of Vovida Networks,
157 * Inc. For more information on Vovida Networks, Inc., please see
158 * <http://www.vovida.org/>.
159 *
160 */
#define InfoLog(args_)
Definition Logger.hxx:131
#define resip_assert(x)
This file needs to work for both C and C++ code.
virtual void onFlowTerminated(ClientRegistrationHandle)
Called when a TCP or TLS flow to the server has terminated.
virtual bool onRefreshRequired(ClientRegistrationHandle, const SipMessage &lastRequest)
Called before attempting to refresh a registration Return true if the refresh should go ahead or fals...
bool isWellFormed() const
Returns true iff this element was parsed successfully, according to the implementation of parse().
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Definition NameAddr.hxx:19
bool exists(const Param< NameAddr > &paramType) const
Definition NameAddr.cxx:477
const Data & param(const ExtensionParameter &param) const
Const accessor for non-natively-supported parameter types.
virtual void getContactExpires(const NameAddr &contact, const std::shared_ptr< MasterProfile > &masterProfile, uint32_t &expires, uint32_t &returnCode)
When processing a REGISTER request, return the desired expires value by processing this contact's exp...
virtual void getGlobalExpires(const SipMessage &msg, const std::shared_ptr< MasterProfile > &masterProfile, uint32_t &expires, uint32_t &returnCode)
When processing a REGISTER request, return the desired expires value when processing the "Expires" he...
Represents a SIP message.
bool empty(const HeaderBase &headerType) const
Returns true if the header field is present and non-empty, false otherwise.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
dcm! – add UnusedChecking(_enum) below;
unsigned int uint32_t
Definition Stun.hxx:34