|
reSIProcate/rutil
9694
|
00001 #ifndef RESIP_DNS_RR_LIST 00002 #define RESIP_DNS_RR_LIST 00003 00004 #include <vector> 00005 00006 #include "rutil/IntrusiveListElement.hxx" 00007 #include "rutil/dns/RRFactory.hxx" 00008 00009 namespace resip 00010 { 00011 class DnsResourceRecord; 00012 class DnsHostRecord; 00013 00014 class RRList : public IntrusiveListElement<RRList*> 00015 { 00016 public: 00017 00018 class Protocol 00019 { 00020 public: 00021 static const int Reserved = 0; 00022 static const int Sip = 1; 00023 static const int Stun = 2; 00024 static const int Http = 3; 00025 static const int Enum = 4; 00026 }; 00027 00028 typedef std::vector<DnsResourceRecord*> Records; 00029 typedef IntrusiveListElement<RRList*> LruList; 00030 typedef std::vector<RROverlay>::const_iterator Itr; 00031 typedef std::vector<Data> DataArr; 00032 00033 RRList(); 00034 explicit RRList(const Data& key, const int rrtype, int ttl, int status); 00035 explicit RRList(const Data& key, int rrtype); 00036 ~RRList(); 00037 RRList(const RRFactoryBase* factory, 00038 const Data& key, 00039 const int rrType, 00040 Itr begin, 00041 Itr end, 00042 int ttl); 00043 00044 RRList(const DnsHostRecord &record, int ttl); 00045 void update(const DnsHostRecord &record, int ttl); 00046 00047 void update(const RRFactoryBase* factory, Itr begin, Itr end, int ttl); 00048 Records records(const int protocol); 00049 00050 const Data& key() const { return mKey; } 00051 int status() const { return mStatus; } 00052 int rrType() const { return mRRType; } 00053 UInt64 absoluteExpiry() const { return mAbsoluteExpiry; } 00054 UInt64& absoluteExpiry() { return mAbsoluteExpiry; } 00055 void log(); 00056 EncodeStream& encodeRRList(EncodeStream& strm); 00057 00058 private: 00059 00060 struct RecordItem 00061 { 00062 DnsResourceRecord* record; 00063 std::vector<int> blacklistedProtocols; 00064 }; 00065 00066 typedef std::vector<RecordItem> RecordArr; 00067 typedef RecordArr::iterator RecordItr; 00068 00069 RecordArr mRecords; 00070 00071 Data mKey; 00072 int mRRType; 00073 00074 int mStatus; // dns query status. 00075 UInt64 mAbsoluteExpiry; 00076 00077 RecordItr find(const Data&); 00078 void clear(); 00079 EncodeStream& encodeRecordItem(RRList::RecordItem& item, EncodeStream& strm); 00080 }; 00081 00082 } 00083 00084 #endif 00085 00086 00087 /* ==================================================================== 00088 * The Vovida Software License, Version 1.0 00089 * 00090 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00091 * Copyright (c) 2010 SIP Spectrum, Inc. All rights reserved. 00092 * 00093 * Redistribution and use in source and binary forms, with or without 00094 * modification, are permitted provided that the following conditions 00095 * are met: 00096 * 00097 * 1. Redistributions of source code must retain the above copyright 00098 * notice, this list of conditions and the following disclaimer. 00099 * 00100 * 2. Redistributions in binary form must reproduce the above copyright 00101 * notice, this list of conditions and the following disclaimer in 00102 * the documentation and/or other materials provided with the 00103 * distribution. 00104 * 00105 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00106 * and "Vovida Open Communication Application Library (VOCAL)" must 00107 * not be used to endorse or promote products derived from this 00108 * software without prior written permission. For written 00109 * permission, please contact vocal@vovida.org. 00110 * 00111 * 4. Products derived from this software may not be called "VOCAL", nor 00112 * may "VOCAL" appear in their name, without prior written 00113 * permission of Vovida Networks, Inc. 00114 * 00115 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00116 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00117 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00118 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00119 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00120 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00121 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00122 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00123 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00124 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00125 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00126 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00127 * DAMAGE. 00128 * 00129 * ==================================================================== 00130 * 00131 * This software consists of voluntary contributions made by Vovida 00132 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00133 * Inc. For more information on Vovida Networks, Inc., please see 00134 * <http://www.vovida.org/>. 00135 * 00136 */
1.7.5.1