reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
AbstractDb.hxx
Go to the documentation of this file.
1#if !defined(RESIP_ABSTRACTDB_HXX)
2#define RESIP_ABSTRACTDB_HXX
3
4#include "rutil/Data.hxx"
5#include "rutil/Fifo.hxx"
7#include <set>
8#include <vector>
9
10namespace resip
11{
12 class TransactionUser;
13}
14
15namespace repro
16{
17
19{
20 public:
21 AbstractDb();
22 virtual ~AbstractDb();
23
36
43
54
56 {
57 public:
60 short mMask;
61 short mPort;
62 short mFamily;
64 };
65
67 {
68 public:
70 short mTlsPort;
71 };
72
80
94
105
107 typedef std::vector<RouteRecord> RouteRecordList;
108 typedef std::vector<AclRecord> AclRecordList;
109 typedef std::vector<ConfigRecord> ConfigRecordList;
110 typedef std::vector<StaticRegRecord> StaticRegRecordList;
111 typedef std::vector<FilterRecord> FilterRecordList;
112 typedef std::vector<SiloRecord> SiloRecordList;
113
114 virtual bool isSane() = 0;
115
116 // functions for User Records
117 virtual bool addUser(const Key& key, const UserRecord& rec);
118 virtual void eraseUser(const Key& key);
119 virtual UserRecord getUser(const Key& key) const;
120 virtual resip::Data getUserAuthInfo(const Key& key) const;
121 virtual Key firstUserKey();// return empty if no more
122 virtual Key nextUserKey(); // return empty if no more
123
124 // functions for TlsPeerIdentity Records
125 virtual bool addTlsPeerIdentity(const Key& key, const TlsPeerIdentityRecord& rec);
126 virtual void eraseTlsPeerIdentity(const Key& key);
127 virtual TlsPeerIdentityRecord getTlsPeerIdentity(const Key& key) const;
128 virtual bool isAuthorized(const std::set<resip::Data>& peerNames, const std::set<resip::Data>& identities) const;
129 virtual Key firstTlsPeerIdentityKey();// return empty if no more
130 virtual Key nextTlsPeerIdentityKey(); // return empty if no more
131
132 // functions for Route Records
133 virtual bool addRoute(const Key& key, const RouteRecord& rec);
134 virtual void eraseRoute(const Key& key);
135 virtual RouteRecord getRoute(const Key& key) const;
137 virtual Key firstRouteKey();// return empty if no more
138 virtual Key nextRouteKey(); // return empty if no more
139
140 // functions for Acl Records
141 virtual bool addAcl(const Key& key, const AclRecord& rec);
142 virtual void eraseAcl(const Key& key);
143 virtual AclRecordList getAllAcls();
144 virtual AclRecord getAcl(const Key& key) const;
145 virtual Key firstAclKey();// return empty if no more
146 virtual Key nextAclKey(); // return empty if no more
147
148 // functions for Config Records
149 virtual bool addConfig(const Key& key, const ConfigRecord& rec);
150 virtual void eraseConfig(const Key& key);
152 virtual ConfigRecord getConfig(const Key& key) const;
153 virtual Key firstConfigKey();// return empty if no more
154 virtual Key nextConfigKey(); // return empty if no more
155
156 // functions for StaticReg Records
157 virtual bool addStaticReg(const Key& key, const StaticRegRecord& rec);
158 virtual void eraseStaticReg(const Key& key );
160 virtual StaticRegRecord getStaticReg( const Key& key) const;
161 virtual Key firstStaticRegKey();// return empty if no more
162 virtual Key nextStaticRegKey(); // return empty if no more
163
164 // functions for Filter Records
165 virtual bool addFilter(const Key& key, const FilterRecord& rec);
166 virtual void eraseFilter(const Key& key);
167 virtual FilterRecord getFilter(const Key& key) const;
169 virtual Key firstFilterKey();// return empty if no more
170 virtual Key nextFilterKey(); // return empty if no more
171
172 // functions for Silo Records
173 virtual bool addToSilo(const Key& key, const SiloRecord& rec);
174 virtual bool getSiloRecords(const Key& skey, SiloRecordList& recordList);
175 virtual void eraseSiloRecord(const Key& key);
176 virtual void cleanupExpiredSiloRecords(uint64_t now, unsigned long expirationTime);
177
178 protected:
191
192 virtual int getSecondaryKey(const Table table,
193 const Key& key,
194 const resip::Data& data,
195 void** secondaryKey,
196 unsigned int* secondaryKeyLen);
197
198 // Db manipulation routines
199 virtual bool dbWriteRecord(const Table table,
200 const resip::Data& key,
201 const resip::Data& data) =0;
203 virtual bool dbReadRecord(const Table table,
204 const resip::Data& key,
205 resip::Data& data) const =0;
206 virtual void dbEraseRecord(const Table table,
207 const resip::Data& key,
208 bool isSecondaryKey=false) =0; // allows deleting records from a table that supports secondary keying using a secondary key
209 virtual resip::Data dbFirstKey(const Table table);
211 bool first=false) = 0; // return empty if no more
212
213 // Methods for tables that allow duplicate keys
214 virtual bool dbFirstRecord(const Table table,
215 const resip::Data& key,
216 resip::Data& data,
217 bool forUpdate);
218 virtual bool dbNextRecord(const Table table,
219 const resip::Data& key,
220 resip::Data& data,
221 bool forUpdate,
222 bool first=false) = 0; // return false if no more
223 virtual bool dbBeginTransaction(const Table table) = 0;
224 virtual bool dbCommitTransaction(const Table table) = 0;
225 virtual bool dbRollbackTransaction(const Table table) = 0;
226
227 virtual void encodeUser(const UserRecord& rec, resip::Data& buffer);
228 virtual void encodeRoute(const RouteRecord& rec, resip::Data& buffer);
229 virtual void encodeFilter(const FilterRecord& rec, resip::Data& buffer);
230 virtual void decodeSiloRecord(resip::Data& data, SiloRecord& rec);
231};
232
233}
234#endif
235
236/* ====================================================================
237 * The Vovida Software License, Version 1.0
238 *
239 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
240 *
241 * Redistribution and use in source and binary forms, with or without
242 * modification, are permitted provided that the following conditions
243 * are met:
244 *
245 * 1. Redistributions of source code must retain the above copyright
246 * notice, this list of conditions and the following disclaimer.
247 *
248 * 2. Redistributions in binary form must reproduce the above copyright
249 * notice, this list of conditions and the following disclaimer in
250 * the documentation and/or other materials provided with the
251 * distribution.
252 *
253 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
254 * and "Vovida Open Communication Application Library (VOCAL)" must
255 * not be used to endorse or promote products derived from this
256 * software without prior written permission. For written
257 * permission, please contact vocal@vovida.org.
258 *
259 * 4. Products derived from this software may not be called "VOCAL", nor
260 * may "VOCAL" appear in their name, without prior written
261 * permission of Vovida Networks, Inc.
262 *
263 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
264 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
265 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
266 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
267 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
268 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
269 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
270 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
271 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
272 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
273 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
274 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
275 * DAMAGE.
276 *
277 * ====================================================================
278 */
std::vector< RouteRecord > RouteRecordList
virtual bool dbNextRecord(const Table table, const resip::Data &key, resip::Data &data, bool forUpdate, bool first=false)=0
virtual bool addToSilo(const Key &key, const SiloRecord &rec)
virtual bool addTlsPeerIdentity(const Key &key, const TlsPeerIdentityRecord &rec)
virtual ConfigRecord getConfig(const Key &key) const
std::vector< ConfigRecord > ConfigRecordList
virtual Key nextStaticRegKey()
virtual Key nextTlsPeerIdentityKey()
virtual Key firstConfigKey()
virtual bool dbCommitTransaction(const Table table)=0
virtual resip::Data dbNextKey(const Table table, bool first=false)=0
virtual void decodeSiloRecord(resip::Data &data, SiloRecord &rec)
virtual void eraseStaticReg(const Key &key)
virtual ~AbstractDb()
virtual RouteRecord getRoute(const Key &key) const
virtual Key firstAclKey()
virtual resip::Data dbFirstKey(const Table table)
virtual void cleanupExpiredSiloRecords(uint64_t now, unsigned long expirationTime)
virtual AclRecord getAcl(const Key &key) const
virtual Key firstStaticRegKey()
std::vector< SiloRecord > SiloRecordList
virtual bool addAcl(const Key &key, const AclRecord &rec)
virtual bool addStaticReg(const Key &key, const StaticRegRecord &rec)
virtual void eraseSiloRecord(const Key &key)
virtual bool dbFirstRecord(const Table table, const resip::Data &key, resip::Data &data, bool forUpdate)
virtual FilterRecordList getAllFilters()
virtual void eraseTlsPeerIdentity(const Key &key)
virtual StaticRegRecord getStaticReg(const Key &key) const
virtual Key nextFilterKey()
virtual void eraseRoute(const Key &key)
virtual Key firstRouteKey()
virtual AclRecordList getAllAcls()
virtual Key nextUserKey()
std::vector< StaticRegRecord > StaticRegRecordList
virtual Key nextRouteKey()
virtual bool dbWriteRecord(const Table table, const resip::Data &key, const resip::Data &data)=0
virtual RouteRecordList getAllRoutes()
virtual bool addFilter(const Key &key, const FilterRecord &rec)
virtual Key firstUserKey()
virtual void eraseUser(const Key &key)
virtual bool isAuthorized(const std::set< resip::Data > &peerNames, const std::set< resip::Data > &identities) const
virtual void eraseAcl(const Key &key)
std::vector< FilterRecord > FilterRecordList
virtual Key firstTlsPeerIdentityKey()
virtual void eraseFilter(const Key &key)
virtual StaticRegRecordList getAllStaticRegs()
virtual void encodeRoute(const RouteRecord &rec, resip::Data &buffer)
virtual ConfigRecordList getAllConfigs()
virtual resip::Data getUserAuthInfo(const Key &key) const
virtual bool dbReadRecord(const Table table, const resip::Data &key, resip::Data &data) const =0
return false if not found
virtual Key nextAclKey()
virtual void encodeFilter(const FilterRecord &rec, resip::Data &buffer)
virtual bool getSiloRecords(const Key &skey, SiloRecordList &recordList)
virtual void eraseConfig(const Key &key)
virtual bool dbBeginTransaction(const Table table)=0
virtual FilterRecord getFilter(const Key &key) const
virtual bool isSane()=0
virtual bool addUser(const Key &key, const UserRecord &rec)
virtual bool addRoute(const Key &key, const RouteRecord &rec)
virtual Key nextConfigKey()
virtual Key firstFilterKey()
virtual bool addConfig(const Key &key, const ConfigRecord &rec)
virtual UserRecord getUser(const Key &key) const
virtual void dbEraseRecord(const Table table, const resip::Data &key, bool isSecondaryKey=false)=0
virtual TlsPeerIdentityRecord getTlsPeerIdentity(const Key &key) const
virtual bool dbRollbackTransaction(const Table table)=0
virtual void encodeUser(const UserRecord &rec, resip::Data &buffer)
std::vector< AclRecord > AclRecordList
virtual int getSecondaryKey(const Table table, const Key &key, const resip::Data &data, void **secondaryKey, unsigned int *secondaryKeyLen)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
unsigned __int64 uint64_t
Definition stdint.h:95
void list()
Definition userAdmin.cxx:66