|
reSIProcate/repro
9694
|
00001 #if !defined(RESIP_ABSTRACTDB_HXX) 00002 #define RESIP_ABSTRACTDB_HXX 00003 00004 #include "rutil/Data.hxx" 00005 #include "rutil/Fifo.hxx" 00006 #include "resip/stack/Message.hxx" 00007 #include <vector> 00008 00009 namespace resip 00010 { 00011 class TransactionUser; 00012 } 00013 00014 namespace repro 00015 { 00016 00017 class AbstractDb 00018 { 00019 public: 00020 AbstractDb(); 00021 virtual ~AbstractDb(); 00022 00023 class UserRecord 00024 { 00025 public: 00026 resip::Data user; 00027 resip::Data domain; 00028 resip::Data realm; 00029 resip::Data passwordHash; 00030 resip::Data name; 00031 resip::Data email; 00032 resip::Data forwardAddress; 00033 }; 00034 00035 class RouteRecord 00036 { 00037 public: 00038 resip::Data mMethod; 00039 resip::Data mEvent; 00040 resip::Data mMatchingPattern; 00041 resip::Data mRewriteExpression; 00042 short mOrder; 00043 //bool mLocalUserOnly; 00044 }; 00045 00046 class AclRecord 00047 { 00048 public: 00049 resip::Data mTlsPeerName; 00050 resip::Data mAddress; 00051 short mMask; 00052 short mPort; 00053 short mFamily; 00054 short mTransport; 00055 }; 00056 00057 class ConfigRecord 00058 { 00059 public: 00060 resip::Data mDomain; 00061 short mTlsPort; 00062 }; 00063 00064 class StaticRegRecord 00065 { 00066 public: 00067 resip::Data mAor; 00068 resip::Data mContact; 00069 resip::Data mPath; 00070 }; 00071 00072 class FilterRecord 00073 { 00074 public: 00075 resip::Data mCondition1Header; 00076 resip::Data mCondition1Regex; 00077 resip::Data mCondition2Header; 00078 resip::Data mCondition2Regex; 00079 resip::Data mMethod; 00080 resip::Data mEvent; 00081 short mAction; // 0 - Accept, 1 - Reject, 2 - SQL Query 00082 resip::Data mActionData; 00083 short mOrder; 00084 }; 00085 00086 class SiloRecord 00087 { 00088 public: 00089 resip::Data mDestUri; 00090 resip::Data mSourceUri; 00091 UInt64 mOriginalSentTime; 00092 resip::Data mTid; 00093 resip::Data mMimeType; 00094 resip::Data mMessageBody; 00095 }; 00096 00097 typedef resip::Data Key; 00098 typedef std::vector<RouteRecord> RouteRecordList; 00099 typedef std::vector<AclRecord> AclRecordList; 00100 typedef std::vector<ConfigRecord> ConfigRecordList; 00101 typedef std::vector<StaticRegRecord> StaticRegRecordList; 00102 typedef std::vector<FilterRecord> FilterRecordList; 00103 typedef std::vector<SiloRecord> SiloRecordList; 00104 00105 virtual bool isSane() = 0; 00106 00107 // functions for User Records 00108 virtual bool addUser(const Key& key, const UserRecord& rec); 00109 virtual void eraseUser(const Key& key); 00110 virtual UserRecord getUser(const Key& key) const; 00111 virtual resip::Data getUserAuthInfo(const Key& key) const; 00112 virtual Key firstUserKey();// return empty if no more 00113 virtual Key nextUserKey(); // return empty if no more 00114 00115 // functions for Route Records 00116 virtual bool addRoute(const Key& key, const RouteRecord& rec); 00117 virtual void eraseRoute(const Key& key); 00118 virtual RouteRecord getRoute(const Key& key) const; 00119 virtual RouteRecordList getAllRoutes(); 00120 virtual Key firstRouteKey();// return empty if no more 00121 virtual Key nextRouteKey(); // return empty if no more 00122 00123 // functions for Acl Records 00124 virtual bool addAcl(const Key& key, const AclRecord& rec); 00125 virtual void eraseAcl(const Key& key); 00126 virtual AclRecordList getAllAcls(); 00127 virtual AclRecord getAcl(const Key& key) const; 00128 virtual Key firstAclKey();// return empty if no more 00129 virtual Key nextAclKey(); // return empty if no more 00130 00131 // functions for Config Records 00132 virtual bool addConfig(const Key& key, const ConfigRecord& rec); 00133 virtual void eraseConfig(const Key& key); 00134 virtual ConfigRecordList getAllConfigs(); 00135 virtual ConfigRecord getConfig(const Key& key) const; 00136 virtual Key firstConfigKey();// return empty if no more 00137 virtual Key nextConfigKey(); // return empty if no more 00138 00139 // functions for StaticReg Records 00140 virtual bool addStaticReg(const Key& key, const StaticRegRecord& rec); 00141 virtual void eraseStaticReg(const Key& key ); 00142 virtual StaticRegRecordList getAllStaticRegs(); 00143 virtual StaticRegRecord getStaticReg( const Key& key) const; 00144 virtual Key firstStaticRegKey();// return empty if no more 00145 virtual Key nextStaticRegKey(); // return empty if no more 00146 00147 // functions for Filter Records 00148 virtual bool addFilter(const Key& key, const FilterRecord& rec); 00149 virtual void eraseFilter(const Key& key); 00150 virtual FilterRecord getFilter(const Key& key) const; 00151 virtual FilterRecordList getAllFilters(); 00152 virtual Key firstFilterKey();// return empty if no more 00153 virtual Key nextFilterKey(); // return empty if no more 00154 00155 // functions for Silo Records 00156 virtual bool addToSilo(const Key& key, const SiloRecord& rec); 00157 virtual bool getSiloRecords(const Key& skey, SiloRecordList& recordList); 00158 virtual void eraseSiloRecord(const Key& key); 00159 virtual void cleanupExpiredSiloRecords(UInt64 now, unsigned long expirationTime); 00160 00161 protected: 00162 typedef enum 00163 { 00164 UserTable=0, 00165 RouteTable, 00166 AclTable, 00167 ConfigTable, 00168 StaticRegTable, 00169 FilterTable, 00170 SiloTable, 00171 MaxTable // This one MUST be last 00172 } Table; 00173 00174 virtual int getSecondaryKey(const Table table, 00175 const Key& key, 00176 const resip::Data& data, 00177 void** secondaryKey, 00178 unsigned int* secondaryKeyLen); 00179 00180 // Db manipulation routines 00181 virtual bool dbWriteRecord(const Table table, 00182 const resip::Data& key, 00183 const resip::Data& data) =0; 00184 /// return false if not found 00185 virtual bool dbReadRecord(const Table table, 00186 const resip::Data& key, 00187 resip::Data& data) const =0; 00188 virtual void dbEraseRecord(const Table table, 00189 const resip::Data& key, 00190 bool isSecondaryKey=false) =0; // allows deleting records from a table that supports secondary keying using a secondary key 00191 virtual resip::Data dbFirstKey(const Table table); 00192 virtual resip::Data dbNextKey(const Table table, 00193 bool first=false) = 0; // return empty if no more 00194 00195 // Methods for tables that allow duplicate keys 00196 virtual bool dbFirstRecord(const Table table, 00197 const resip::Data& key, 00198 resip::Data& data, 00199 bool forUpdate); 00200 virtual bool dbNextRecord(const Table table, 00201 const resip::Data& key, 00202 resip::Data& data, 00203 bool forUpdate, 00204 bool first=false) = 0; // return false if no more 00205 virtual bool dbBeginTransaction(const Table table) = 0; 00206 virtual bool dbCommitTransaction(const Table table) = 0; 00207 virtual bool dbRollbackTransaction(const Table table) = 0; 00208 00209 virtual void encodeUser(const UserRecord& rec, resip::Data& buffer); 00210 virtual void encodeRoute(const RouteRecord& rec, resip::Data& buffer); 00211 virtual void encodeFilter(const FilterRecord& rec, resip::Data& buffer); 00212 virtual void decodeSiloRecord(resip::Data& data, SiloRecord& rec); 00213 }; 00214 00215 } 00216 #endif 00217 00218 /* ==================================================================== 00219 * The Vovida Software License, Version 1.0 00220 * 00221 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00222 * 00223 * Redistribution and use in source and binary forms, with or without 00224 * modification, are permitted provided that the following conditions 00225 * are met: 00226 * 00227 * 1. Redistributions of source code must retain the above copyright 00228 * notice, this list of conditions and the following disclaimer. 00229 * 00230 * 2. Redistributions in binary form must reproduce the above copyright 00231 * notice, this list of conditions and the following disclaimer in 00232 * the documentation and/or other materials provided with the 00233 * distribution. 00234 * 00235 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00236 * and "Vovida Open Communication Application Library (VOCAL)" must 00237 * not be used to endorse or promote products derived from this 00238 * software without prior written permission. For written 00239 * permission, please contact vocal@vovida.org. 00240 * 00241 * 4. Products derived from this software may not be called "VOCAL", nor 00242 * may "VOCAL" appear in their name, without prior written 00243 * permission of Vovida Networks, Inc. 00244 * 00245 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00246 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00247 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00248 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00249 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00250 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00251 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00252 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00253 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00254 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00255 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00256 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00257 * DAMAGE. 00258 * 00259 * ==================================================================== 00260 */
1.7.5.1