reSIProcate/rutil  9694
RRVip.hxx
Go to the documentation of this file.
00001 #ifndef RESIP_RRVIP_HXX
00002 #define RESIP_RRVIP_HXX
00003 
00004 #include "rutil/dns/DnsStub.hxx"
00005 
00006 namespace resip
00007 {
00008 
00009 class RRVip : public DnsStub::ResultTransform
00010 {
00011    public:
00012       RRVip();
00013       ~RRVip();
00014 
00015       void vip(const Data& target, int rrType, const Data& vip);
00016       void removeVip(const Data& target, int rrType);
00017       void transform(const Data& target, int rrType, std::vector<DnsResourceRecord*>&);
00018 
00019    private:
00020 
00021       RRVip(const RRVip&);
00022       RRVip& operator=(const RRVip&);
00023 
00024       typedef std::vector<DnsResourceRecord*> RRVector;
00025       class Transform
00026       {
00027          public:
00028             Transform(const Data& vip);
00029             virtual ~Transform();
00030             virtual void transform(RRVector& rrs, bool& invalidVip);
00031             void updateVip(const Data& vip);
00032             const Data& vip() { return mVip; };
00033 
00034          protected:
00035             Data mVip; // ip for a/aaaa, target host for srv, and replacement for naptr.
00036       };
00037 
00038       class NaptrTransform : public Transform
00039       {
00040          public:
00041             NaptrTransform(const Data& vip);
00042             void transform(RRVector& rrs, bool&);
00043       };
00044 
00045       class SrvTransform : public Transform
00046       {
00047          public:
00048             SrvTransform(const Data& vip);
00049             void transform(RRVector& rrs, bool&);
00050       };
00051 
00052       class MapKey
00053       {
00054          public:
00055             MapKey();
00056             MapKey(const Data& target, int rrType);
00057             bool operator<(const MapKey&) const;
00058          private:
00059             Data mTarget;
00060             int mRRType;
00061       };
00062 
00063       class TransformFactory
00064       {
00065          public:
00066             virtual ~TransformFactory() {}
00067             virtual Transform* createTransform(const Data& vip) = 0;
00068       };
00069 
00070       class HostTransformFactory : public TransformFactory
00071       {
00072          public:
00073             Transform* createTransform(const Data& vip) { return new Transform(vip); }
00074       };
00075 
00076       class NaptrTransformFactroy : public TransformFactory
00077       {
00078          public:
00079             Transform* createTransform(const Data& vip) { return new NaptrTransform(vip); }
00080       };
00081 
00082       class SrvTransformFactory : public TransformFactory
00083       {
00084          public:
00085             Transform* createTransform(const Data& vip) { return new SrvTransform(vip); }
00086       };
00087 
00088       typedef std::map<int, TransformFactory*> TransformFactoryMap;
00089       TransformFactoryMap  mFactories;
00090 
00091       typedef std::map<MapKey, Transform*> TransformMap;
00092       TransformMap mTransforms;  
00093 };
00094 
00095 }
00096 
00097 #endif
00098 
00099 /* ====================================================================
00100  * The Vovida Software License, Version 1.0 
00101  * 
00102  * Copyright (c) 2000-2005 Vovida Networks, Inc.  All rights reserved.
00103  * 
00104  * Redistribution and use in source and binary forms, with or without
00105  * modification, are permitted provided that the following conditions
00106  * are met:
00107  * 
00108  * 1. Redistributions of source code must retain the above copyright
00109  *    notice, this list of conditions and the following disclaimer.
00110  * 
00111  * 2. Redistributions in binary form must reproduce the above copyright
00112  *    notice, this list of conditions and the following disclaimer in
00113  *    the documentation and/or other materials provided with the
00114  *    distribution.
00115  * 
00116  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00117  *    and "Vovida Open Communication Application Library (VOCAL)" must
00118  *    not be used to endorse or promote products derived from this
00119  *    software without prior written permission. For written
00120  *    permission, please contact vocal@vovida.org.
00121  *
00122  * 4. Products derived from this software may not be called "VOCAL", nor
00123  *    may "VOCAL" appear in their name, without prior written
00124  *    permission of Vovida Networks, Inc.
00125  * 
00126  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00127  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00128  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00129  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00130  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00131  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00132  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00133  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00134  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00135  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00136  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00137  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00138  * DAMAGE.
00139  * 
00140  * ====================================================================
00141  * 
00142  * This software consists of voluntary contributions made by Vovida
00143  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00144  * Inc.  For more information on Vovida Networks, Inc., please see
00145  * <http://www.vovida.org/>.
00146  *
00147  */