reSIProcate/stack  9694
BranchParameter.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_BRANCHPARAMETER_HXX)
00002 #define RESIP_BRANCHPARAMETER_HXX 
00003 
00004 #include <iosfwd>
00005 
00006 #include "resip/stack/Parameter.hxx"
00007 #include "resip/stack/ParameterTypeEnums.hxx"
00008 #include "rutil/Data.hxx"
00009 #include "rutil/PoolBase.hxx"
00010 
00011 namespace resip
00012 {
00013 
00014 class ParseBuffer;
00015 
00016 // BranchParameter of the form: 
00017 // rfc3261cookie-sip2cookie-tid-transportseq-clientdata-sip2cookie
00018 // Notably, the tid MAY contain dashes by the clientdata MUST NOT.
00019 //
00020 
00026 class BranchParameter : public Parameter
00027 {
00028    public:
00029       typedef BranchParameter Type;
00030       
00031       BranchParameter(ParameterTypes::Type, ParseBuffer& pb, const std::bitset<256>& terminators);
00032       explicit BranchParameter(ParameterTypes::Type);
00033 
00034       ~BranchParameter();
00035 
00036       // contains z9hG4bK
00037       bool hasMagicCookie() const;
00038 
00039       // returns tid
00040       const Data& getTransactionId() const;
00041 
00042       // increments the transport sequence component - not part of tid
00043       void incrementTransportSequence();
00044 
00045       // pseudo-random tid if none specified, zero sequences either way
00046       void reset(const Data& transactionId = Data::Empty);
00047 
00048       // access the client specific portion of the branch - not part of tid
00049       Data& clientData();
00050       const Data& clientData() const;
00051 
00052       // access sigcomp id -- we do pre- and post-processing on this,
00053       // so we need "normal" setters and getters
00054       void setSigcompCompartment(const Data &);
00055       Data getSigcompCompartment() const;
00056 
00057       static Parameter* decode(ParameterTypes::Type type, 
00058                                  ParseBuffer& pb, 
00059                                  const std::bitset<256>& terminators,
00060                                  PoolBase* pool)
00061       {
00062          return new (pool) BranchParameter(type, pb, terminators);
00063       }
00064       
00065       virtual Parameter* clone() const;
00066       virtual EncodeStream& encode(EncodeStream& stream) const;
00067 
00068       BranchParameter(const BranchParameter& other);
00069       BranchParameter& operator=(const BranchParameter& other);
00070       bool operator==(const BranchParameter& other);
00071 
00072       Type& value() {return *this;}
00073 
00074    private:
00075       bool mHasMagicCookie;
00076       bool mIsMyBranch;
00077       Data mTransactionId;
00078       unsigned int mTransportSeq;
00079       Data mClientData;
00080       //magic cookie for interop; if case is different some proxies will treat this as a different tid
00081       const Data* mInteropMagicCookie; 
00082 
00083       // If we're compressing, this will hold the compartment ID
00084       // for the host that the request was sent to.
00085       Data mSigcompCompartment;
00086                                 
00087 };
00088  
00089 }
00090 
00091 #endif
00092 
00093 /* ====================================================================
00094  * The Vovida Software License, Version 1.0 
00095  * 
00096  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00097  * 
00098  * Redistribution and use in source and binary forms, with or without
00099  * modification, are permitted provided that the following conditions
00100  * are met:
00101  * 
00102  * 1. Redistributions of source code must retain the above copyright
00103  *    notice, this list of conditions and the following disclaimer.
00104  * 
00105  * 2. Redistributions in binary form must reproduce the above copyright
00106  *    notice, this list of conditions and the following disclaimer in
00107  *    the documentation and/or other materials provided with the
00108  *    distribution.
00109  * 
00110  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00111  *    and "Vovida Open Communication Application Library (VOCAL)" must
00112  *    not be used to endorse or promote products derived from this
00113  *    software without prior written permission. For written
00114  *    permission, please contact vocal@vovida.org.
00115  *
00116  * 4. Products derived from this software may not be called "VOCAL", nor
00117  *    may "VOCAL" appear in their name, without prior written
00118  *    permission of Vovida Networks, Inc.
00119  * 
00120  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00121  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00122  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00123  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00124  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00125  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00126  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00127  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00128  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00129  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00130  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00131  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00132  * DAMAGE.
00133  * 
00134  * ====================================================================
00135  * 
00136  * This software consists of voluntary contributions made by Vovida
00137  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00138  * Inc.  For more information on Vovida Networks, Inc., please see
00139  * <http://www.vovida.org/>.
00140  *
00141  */