reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
OutboundTargetHandler.cxx
Go to the documentation of this file.
2
3#include "rutil/Logger.hxx"
9
10#include <utility>
11
12#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
13
14namespace repro
15{
16
22
26
29{
30 resip::Message* msg = rc.getCurrentEvent();
31 ResponseContext& rsp = rc.getResponseContext();
32 if(!msg)
33 {
35 }
36
37 // !bwc! Check to see whether we need to move on to another reg-id
38 resip::SipMessage* sip = dynamic_cast<resip::SipMessage*>(msg);
39 if(sip && sip->isResponse() && sip->header(resip::h_StatusLine).responseCode() > 299)
40 {
41 const resip::Data& tid=sip->getTransactionId();
42 DebugLog(<<"Looking for tid " << tid);
43 Target* target = rsp.getTarget(tid);
44 resip_assert(target);
45 OutboundTarget* ot = dynamic_cast<OutboundTarget*>(target);
46 if(ot)
47 {
48 int flowDeadCode;
50 {
51 flowDeadCode = 430;
52 }
53 else
54 {
55 flowDeadCode = 410;
56 }
57
58 // Note: Locally generated 408 timeouts are ignored here to prevent premature registration teardown.
59 // We only remove contacts on hard transport failures (503 or flowDeadCode), ensuring that
60 // transient network or app-layer lag doesn't wipe our registration database
61 // while the RFC 5626 Flow is still physically established.
62 int responseCode = sip->header(resip::h_StatusLine).responseCode();
63 if(responseCode ==flowDeadCode || // Remote or locally(stack) generate 430
64 (!sip->isFromWire() && responseCode == 503)) // Locally (stack) generated 503
65 {
66 // Flow is dead remove contact from Location Database
67 resip::Uri inputUri(ot->getAor());
68
71 DebugLog(<< "Removing contact registration due to flow dead response code=" << responseCode <<", aor=" << inputUri << ", contact=" << ot->rec().mContact);
74
75 std::unique_ptr<Target> newTarget(ot->nextInstance());
76 if(newTarget)
77 {
78 // Try next reg-id
79 rsp.addTarget(std::move(newTarget));
81 }
82 }
83 }
84 }
85
87}
88
89}
90
91/* ====================================================================
92 * The Vovida Software License, Version 1.0
93 *
94 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
95 *
96 * Redistribution and use in source and binary forms, with or without
97 * modification, are permitted provided that the following conditions
98 * are met:
99 *
100 * 1. Redistributions of source code must retain the above copyright
101 * notice, this list of conditions and the following disclaimer.
102 *
103 * 2. Redistributions in binary form must reproduce the above copyright
104 * notice, this list of conditions and the following disclaimer in
105 * the documentation and/or other materials provided with the
106 * distribution.
107 *
108 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
109 * and "Vovida Open Communication Application Library (VOCAL)" must
110 * not be used to endorse or promote products derived from this
111 * software without prior written permission. For written
112 * permission, please contact vocal@vovida.org.
113 *
114 * 4. Products derived from this software may not be called "VOCAL", nor
115 * may "VOCAL" appear in their name, without prior written
116 * permission of Vovida Networks, Inc.
117 *
118 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
119 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
120 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
121 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
122 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
123 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
124 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
125 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
126 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
127 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
128 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
129 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
130 * DAMAGE.
131 *
132 * ====================================================================
133 */
#define DebugLog(args_)
Definition Logger.hxx:128
#define resip_assert(x)
This file needs to work for both C and C++ code.
virtual processor_action_t process(RequestContext &)
OutboundTargetHandler(resip::RegistrationPersistenceManager &store)
resip::RegistrationPersistenceManager & mRegStore
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static int getOutboundVersion()
The base-class used for message-passing.
Definition Message.hxx:21
Abstract interface of a datastore of all registered endpoints processed by DUM.
virtual void unlockRecord(const Uri &aor)=0
virtual void lockRecord(const Uri &aor)=0
virtual void removeContact(const Uri &aor, const ContactInstanceRecord &rec)=0
Represents a SIP message.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
Definition Uri.hxx:22
This Class is used to implement a primitive form of RPC using loose XML formatting.
StatusLineType h_StatusLine
Definition Headers.cxx:348
void list()
Definition userAdmin.cxx:66