reSIProcate/repro  9694
RequestContext.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_REQUEST_CONTEXT_HXX)
00002 #define RESIP_REQUEST_CONTEXT_HXX 
00003 
00004 #include <vector>
00005 #include <iosfwd>
00006 #include "resip/stack/Uri.hxx"
00007 #include "repro/ProcessorChain.hxx"
00008 #include "repro/ResponseContext.hxx"
00009 #include "resip/stack/NameAddr.hxx"
00010 #include "repro/ResponseContext.hxx"
00011 #include "repro/TimerCMessage.hxx"
00012 #include "rutil/resipfaststreams.hxx"
00013 #include "rutil/KeyValueStore.hxx"
00014 
00015 namespace resip
00016 {
00017 class SipMessage;
00018 class TransactionTerminated;
00019 }
00020 
00021 
00022 namespace repro
00023 {
00024 class Proxy;
00025 
00026 class RequestContext
00027 {
00028    public:
00029       RequestContext(Proxy& proxy,
00030                      ProcessorChain& requestP, // monkeys
00031                      ProcessorChain& responseP, // lemurs
00032                      ProcessorChain& targetP); // baboons
00033       virtual ~RequestContext();
00034 
00035       virtual void process(resip::TransactionTerminated& msg);
00036       virtual void process(std::auto_ptr<resip::SipMessage> sip);
00037       virtual void process(std::auto_ptr<resip::ApplicationMessage> app);
00038       
00039       virtual void handleSelfAimedStrayAck(resip::SipMessage* sip);
00040       virtual void cancelClientTransaction(const resip::Data& tid);
00041 
00042       /// Returns the SipMessage associated with the server transaction
00043       resip::SipMessage& getOriginalRequest();
00044       const resip::SipMessage& getOriginalRequest() const;
00045       resip::Data getTransactionId() const;
00046       
00047       /** Returns the event that we are currently working on. Use a pointer
00048           since users need to check for null */
00049       resip::Message* getCurrentEvent();
00050       const resip::Message* getCurrentEvent() const;
00051       
00052       void setDigestIdentity (const resip::Data&);
00053       const resip::Data& getDigestIdentity() const;
00054 
00055       Proxy& getProxy();
00056       ResponseContext& getResponseContext();
00057       
00058       resip::NameAddr& getTopRoute();
00059             
00060       virtual void send(resip::SipMessage& msg);
00061       void sendResponse(resip::SipMessage& response);
00062 
00063       void forwardAck200(const resip::SipMessage& ack);
00064       void postAck200Done();
00065       
00066       void updateTimerC();
00067       bool mInitialTimerCSet;
00068 
00069       void postTimedMessage(std::auto_ptr<resip::ApplicationMessage> msg,int seconds);
00070 
00071       // Accessor for per-requset extensible state storage for monkeys
00072       resip::KeyValueStore& getKeyValueStore() { return mKeyValueStore; }
00073       
00074       bool mHaveSentFinalResponse;
00075    protected:
00076       resip::SipMessage*  mOriginalRequest;
00077       resip::Message*  mCurrentEvent;
00078       resip::SipMessage* mAck200ToRetransmit;
00079       ProcessorChain& mRequestProcessorChain; // monkeys
00080       ProcessorChain& mResponseProcessorChain; // lemurs
00081       ProcessorChain& mTargetProcessorChain; // baboons
00082 
00083       bool processRequestInviteTransaction(resip::SipMessage* msg,bool original);
00084       bool processRequestNonInviteTransaction(resip::SipMessage* msg,bool original);
00085       void processRequestAckTransaction(resip::SipMessage* msg,bool original);
00086       void doPostRequestProcessing(resip::SipMessage* msg, bool original);
00087       bool processResponseInviteTransaction(resip::SipMessage* msg);
00088       bool processResponseNonInviteTransaction(resip::SipMessage* msg);
00089       void processResponseAckTransaction(resip::SipMessage* msg);
00090       void doPostResponseProcessing(resip::SipMessage* msg);
00091       
00092       resip::Data mDigestIdentity;
00093       int mTransactionCount;
00094       Proxy& mProxy;
00095       resip::NameAddr mTopRoute;
00096       ResponseContext mResponseContext;
00097       int mTCSerial;
00098       resip::KeyValueStore mKeyValueStore;
00099 
00100       typedef std::vector<ProcessorChain::Chain::iterator>
00101 
00102       /** Stack of iterators used to keep track of where
00103           we are in the request processor chain(s) for
00104           async processing */
00105       ChainIteratorStack;
00106       ChainIteratorStack mChainIteratorStack;
00107       
00108       void fixStrictRouterDamage();
00109       void removeTopRouteIfSelf();
00110       
00111       friend class ResponseContext;
00112       friend EncodeStream& operator<<(EncodeStream& strm, const repro::RequestContext& rc);
00113 };
00114 
00115 EncodeStream&
00116 operator<<(EncodeStream& strm, const repro::RequestContext& rc);
00117 
00118 
00119 }
00120 
00121 #endif
00122 
00123 /* ====================================================================
00124  * The Vovida Software License, Version 1.0 
00125  * 
00126  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00127  * 
00128  * Redistribution and use in source and binary forms, with or without
00129  * modification, are permitted provided that the following conditions
00130  * are met:
00131  * 
00132  * 1. Redistributions of source code must retain the above copyright
00133  *    notice, this list of conditions and the following disclaimer.
00134  * 
00135  * 2. Redistributions in binary form must reproduce the above copyright
00136  *    notice, this list of conditions and the following disclaimer in
00137  *    the documentation and/or other materials provided with the
00138  *    distribution.
00139  * 
00140  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00141  *    and "Vovida Open Communication Application Library (VOCAL)" must
00142  *    not be used to endorse or promote products derived from this
00143  *    software without prior written permission. For written
00144  *    permission, please contact vocal@vovida.org.
00145  *
00146  * 4. Products derived from this software may not be called "VOCAL", nor
00147  *    may "VOCAL" appear in their name, without prior written
00148  *    permission of Vovida Networks, Inc.
00149  * 
00150  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00151  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00152  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00153  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00154  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00155  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00156  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00157  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00158  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00159  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00160  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00161  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00162  * DAMAGE.
00163  * 
00164  * ====================================================================
00165  * 
00166  * This software consists of voluntary contributions made by Vovida
00167  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00168  * Inc.  For more information on Vovida Networks, Inc., please see
00169  * <http://www.vovida.org/>.
00170  *
00171  */