/[resiprocate]/main/resip/dum/RegistrationHandler.cxx
ViewVC logotype

Contents of /main/resip/dum/RegistrationHandler.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8178 - (show annotations) (download)
Sun Aug 3 12:45:55 2008 UTC (11 years, 4 months ago) by jmatthewsr
File size: 4797 byte(s)
Moved global server registration expires settings to MasterProfile.
1 #include "resip/dum/MasterProfile.hxx"
2 #include "resip/stack/SipMessage.hxx"
3 #include "resip/dum/RegistrationHandler.hxx"
4
5 using namespace resip;
6
7 void
8 ServerRegistrationHandler::getGlobalExpires(const SipMessage& msg, SharedPtr<MasterProfile> masterProfile,
9 UInt32 &expires, UInt32 &returnCode)
10 {
11 if (!masterProfile)
12 {
13 returnCode = 500;
14 assert(0);
15 return;
16 }
17
18 expires=3600;
19 returnCode=0;
20
21 if (!msg.empty(h_Expires) && msg.header(h_Expires).isWellFormed())
22 {
23 //only client specified Expires value is subject to the min/max constraints, default is used if none specified.
24 expires = msg.header(h_Expires).value();
25
26 if (expires != 0)
27 {
28 //check min expires first since max expires will not return an error and will just change the expires value.
29 UInt32 minExpires = masterProfile->serverRegistrationMinExpiresTime();
30
31 if (expires < minExpires)
32 {
33 returnCode = 423;
34 expires = minExpires;
35 }
36 else
37 {
38 UInt32 maxExpires = masterProfile->serverRegistrationMaxExpiresTime();
39
40 if (expires > maxExpires)
41 {
42 expires = maxExpires;
43 }
44 }
45 }
46 }
47 else
48 {
49 expires = masterProfile->serverRegistrationDefaultExpiresTime();
50 }
51 }
52
53 void
54 ServerRegistrationHandler::getContactExpires(const NameAddr &contact, SharedPtr<MasterProfile> masterProfile,
55 UInt32 &expires, UInt32 &returnCode)
56 {
57 if (!masterProfile)
58 {
59 returnCode = 500;
60 assert(0);
61 return;
62 }
63
64 returnCode=0;
65
66 if (contact.exists(p_expires))
67 {
68 expires = contact.param(p_expires);
69
70 if (expires != 0)
71 {
72 //check min expires first since max expires will not return an error and will just change the expires value.
73 UInt32 minExpires = masterProfile->serverRegistrationMinExpiresTime();
74
75 if (expires < minExpires)
76 {
77 returnCode = 423;
78 expires = minExpires;
79 }
80 else
81 {
82 UInt32 maxExpires = masterProfile->serverRegistrationMaxExpiresTime();
83
84 if (expires > maxExpires)
85 {
86 expires = maxExpires;
87 }
88 }
89 }
90 }
91 }
92
93
94 /* ====================================================================
95 * The Vovida Software License, Version 1.0
96 *
97 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
98 *
99 * Redistribution and use in source and binary forms, with or without
100 * modification, are permitted provided that the following conditions
101 * are met:
102 *
103 * 1. Redistributions of source code must retain the above copyright
104 * notice, this list of conditions and the following disclaimer.
105 *
106 * 2. Redistributions in binary form must reproduce the above copyright
107 * notice, this list of conditions and the following disclaimer in
108 * the documentation and/or other materials provided with the
109 * distribution.
110 *
111 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
112 * and "Vovida Open Communication Application Library (VOCAL)" must
113 * not be used to endorse or promote products derived from this
114 * software without prior written permission. For written
115 * permission, please contact vocal@vovida.org.
116 *
117 * 4. Products derived from this software may not be called "VOCAL", nor
118 * may "VOCAL" appear in their name, without prior written
119 * permission of Vovida Networks, Inc.
120 *
121 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
122 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
123 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
124 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
125 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
126 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
127 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
128 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
129 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
130 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
131 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
132 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
133 * DAMAGE.
134 *
135 * ====================================================================
136 *
137 * This software consists of voluntary contributions made by Vovida
138 * Networks, Inc. and many individuals on behalf of Vovida Networks,
139 * Inc. For more information on Vovida Networks, Inc., please see
140 * <http://www.vovida.org/>.
141 *
142 */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27